Commit b56fb14b authored by Yuchen Pei's avatar Yuchen Pei

MDEV-30265 Document some sts related functions in spider.

parent 5499906d
......@@ -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
......@@ -13393,6 +13394,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,
......@@ -13423,7 +13427,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(),
......@@ -13536,6 +13540,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
......
......@@ -979,6 +979,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,
......@@ -1443,6 +1453,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
......@@ -1595,6 +1611,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,
......@@ -2716,6 +2744,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
......@@ -3207,6 +3243,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,
......@@ -3345,6 +3391,15 @@ int spider_sys_delete_table_crd(
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,
......
......@@ -7138,8 +7138,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);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment