summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuchen Pei <yuchen.pei@mariadb.com>2023-03-23 17:32:09 +1100
committerYuchen Pei <yuchen.pei@mariadb.com>2023-03-23 17:40:24 +1100
commit0804983fedee01484a9538655a4abb6b7c186c11 (patch)
tree42b7181693e9b04349cebff27e5ef766f1df700e
parentf6cb93ba8d24c2e67d396c3dd9ef2b0bb3a3e665 (diff)
downloadmariadb-git-bb-11.0-mdev-30265.tar.gz
MDEV-30265 Document some sts related functions in spider.bb-11.0-mdev-30265
-rw-r--r--storage/spider/spd_db_mysql.cc7
-rw-r--r--storage/spider/spd_sys_table.cc55
-rw-r--r--storage/spider/spd_table.cc3
3 files changed, 64 insertions, 1 deletions
diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc
index 21c2e6bb434..089d8e800f7 100644
--- a/storage/spider/spd_db_mysql.cc
+++ b/storage/spider/spd_db_mysql.cc
@@ -803,6 +803,7 @@ SPIDER_DB_ROW *spider_db_mbase_result::fetch_row_from_tmp_table(
DBUG_RETURN((SPIDER_DB_ROW *) &row);
}
+/* Fetches table status into `stat` */
int spider_db_mbase_result::fetch_table_status(
int mode,
ha_statistics &stat
@@ -13450,6 +13451,9 @@ int spider_mbase_handler::sts_mode_exchange(
DBUG_RETURN(sts_mode);
}
+/**
+ Executes show table status query and stores results in share->stat.
+*/
int spider_mbase_handler::show_table_status(
int link_idx,
int sts_mode,
@@ -13480,7 +13484,7 @@ int spider_mbase_handler::show_table_status(
share);
if (
(error_num = spider_db_set_names(spider, conn, link_idx)) ||
- (
+ ( /* Executes the `show table status` query */
spider_db_query(
conn,
mysql_share->show_table_status[0 + pos].ptr(),
@@ -13593,6 +13597,7 @@ int spider_mbase_handler::show_table_status(
conn->mta_conn_mutex_unlock_later = FALSE;
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
+ /* Fetches query results into share->stat. */
error_num = res->fetch_table_status(
sts_mode,
share->stat
diff --git a/storage/spider/spd_sys_table.cc b/storage/spider/spd_sys_table.cc
index df95336cc19..442857a5bce 100644
--- a/storage/spider/spd_sys_table.cc
+++ b/storage/spider/spd_sys_table.cc
@@ -991,6 +991,16 @@ void spider_store_xa_member_info(
DBUG_VOID_RETURN;
}
+/**
+ Store the DB and table names in a table.
+
+ If `name` starts with "./", separate out db and table names from
+ `name`. Otherwise store empty strings as names.
+
+ @param table The table to store the info
+ @param name The name of the table
+ @param name_length The length of the name
+*/
void spider_store_tables_name(
TABLE *table,
const char *name,
@@ -1455,6 +1465,12 @@ void spider_store_binlog_pos_gtid(
DBUG_VOID_RETURN;
}
+/**
+ Store sts info in the spider sts table.
+
+ Stores all fields except the db name and table name, which are
+ stored in `spider_store_tables_name()`.
+*/
void spider_store_table_sts_info(
TABLE *table,
ha_statistics *stat
@@ -1607,6 +1623,18 @@ int spider_insert_sys_table(
DBUG_RETURN(error_num);
}
+/**
+ Inserts or updates a row in the spider sts system table
+
+ @param table The spider sts system table
+ @param name The name of the spider table whose stat will be
+ inserted / updated in the sts table
+ @param name_length Length of the name
+ @param stat The stat of the spider table that will be
+ inserted / updated in the sts table
+
+ @retval 0 or error
+*/
int spider_insert_or_update_table_sts(
TABLE *table,
const char *name,
@@ -2728,6 +2756,14 @@ int spider_get_sys_tables_static_link_id(
DBUG_RETURN(error_num);
}
+/**
+ Reads the table status from the system sts table
+
+ The result is set into `stat`
+
+ @param table The system sts table
+ @param stat The stat to read the table status into
+*/
void spider_get_sys_table_sts_info(
TABLE *table,
ha_statistics *stat
@@ -3226,6 +3262,16 @@ int spider_get_link_statuses(
DBUG_RETURN(0);
}
+/**
+ Insert or update status of a table into the system sts table
+
+ @param thd Connection
+ @param name Name of the table whose status will be stored
+ @param name_length Length of `name`
+ @param stat The table status that will be stored into the
+ system sts table
+ @param need_lock Unused (fixme)
+*/
int spider_sys_insert_or_update_table_sts(
THD *thd,
const char *name,
@@ -3368,6 +3414,15 @@ error:
DBUG_RETURN(error_num);
}
+/**
+ Read table status of a table from the system sts table.
+
+ @param thd Connection
+ @param name The name of the table for which to read status of
+ @param name_length The length `name`
+ @param stat The struct to read the status into
+ @param need_lock Unused (fixme)
+*/
int spider_sys_get_table_sts(
THD *thd,
const char *name,
diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc
index 13afb5077d3..6fb245ca75b 100644
--- a/storage/spider/spd_table.cc
+++ b/storage/spider/spd_table.cc
@@ -7157,8 +7157,11 @@ int spider_get_sts(
if (need_to_get)
{
if (get_type == 0)
+ /* Copy table status from share to share->wide_share */
spider_copy_sts_to_share(share, share->wide_share);
else {
+ /* Executes a `show table status` query and store the results in
+ share->stat */
error_num = spider_db_show_table_status(spider, link_idx, sts_mode, flag);
}
}