Skip to content
Permalink
Browse files
MDEV-23561 Spider doesn't work with ps protocol
  • Loading branch information
Kentoku committed Aug 25, 2020
1 parent e1a9b7c commit 8f8f2ae
Show file tree
Hide file tree
Showing 10 changed files with 193 additions and 294 deletions.
@@ -11401,11 +11401,7 @@ int ha_spider::create(
uint sql_command = thd_sql_command(thd), roop_count;
SPIDER_TRX *trx;
TABLE *table_tables = NULL;
#if MYSQL_VERSION_ID < 50500
Open_tables_state open_tables_backup;
#else
Open_tables_backup open_tables_backup;
#endif
SPIDER_Open_tables_backup open_tables_backup;
bool need_lock = FALSE;
DBUG_ENTER("ha_spider::create");
DBUG_PRINT("info",("spider this=%p", this));
@@ -11657,11 +11653,7 @@ int ha_spider::rename_table(
TABLE *table_tables = NULL;
SPIDER_ALTER_TABLE *alter_table_from, *alter_table_to;
SPIDER_LGTM_TBLHND_SHARE *from_lgtm_tblhnd_share, *to_lgtm_tblhnd_share;
#if MYSQL_VERSION_ID < 50500
Open_tables_state open_tables_backup;
#else
Open_tables_backup open_tables_backup;
#endif
SPIDER_Open_tables_backup open_tables_backup;
bool need_lock = FALSE;
DBUG_ENTER("ha_spider::rename_table");
DBUG_PRINT("info",("spider this=%p", this));
@@ -11885,11 +11877,7 @@ int ha_spider::delete_table(
TABLE *table_tables = NULL;
uint sql_command = thd_sql_command(thd);
SPIDER_ALTER_TABLE *alter_table;
#if MYSQL_VERSION_ID < 50500
Open_tables_state open_tables_backup;
#else
Open_tables_backup open_tables_backup;
#endif
SPIDER_Open_tables_backup open_tables_backup;
bool need_lock = FALSE;
DBUG_ENTER("ha_spider::delete_table");
DBUG_PRINT("info",("spider this=%p", this));
@@ -33,8 +33,6 @@ XA START 'test';
INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
XA END 'test';
XA PREPARE 'test';
Warnings:
Warning 1030 Got error 131 "Command not supported by the engine" from storage engine Aria
XA COMMIT 'test';
connection child2_1;
SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
@@ -353,11 +353,7 @@ int spider_udf_get_copy_tgt_tables(
) {
int error_num, roop_count;
TABLE *table_tables = NULL;
#if MYSQL_VERSION_ID < 50500
Open_tables_state open_tables_backup;
#else
Open_tables_backup open_tables_backup;
#endif
SPIDER_Open_tables_backup open_tables_backup;
char table_key[MAX_KEY_LENGTH];
SPIDER_COPY_TABLE_CONN *table_conn = NULL, *src_table_conn_prev = NULL,
*dst_table_conn_prev = NULL;
@@ -10036,9 +10036,9 @@ int spider_db_open_item_string(
if (str)
{
THD *thd = NULL;
TABLE *table;
TABLE *UNINIT_VAR(table);
my_bitmap_map *saved_map = NULL;
Time_zone *saved_time_zone;
Time_zone *UNINIT_VAR(saved_time_zone);
String str_value;
char tmp_buf[MAX_FIELD_WIDTH];
spider_string tmp_str(tmp_buf, MAX_FIELD_WIDTH, str->charset());
@@ -10761,7 +10761,7 @@ int spider_db_udf_direct_sql(
#else
if (direct_sql->real_table_used)
{
if (spider_sys_open_tables(c_thd, &direct_sql->table_list_first,
if (spider_sys_open_and_lock_tables(c_thd, &direct_sql->table_list_first,
&direct_sql->open_tables_backup))
{
direct_sql->real_table_used = FALSE;
@@ -238,6 +238,33 @@ const char SPIDER_empty_string = "";
#define SPIDER_get_linkage(A) A->linkage
#endif

#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100500
typedef start_new_trans *SPIDER_Open_tables_backup;
#elif MYSQL_VERSION_ID < 50500
typedef Open_tables_state SPIDER_Open_tables_backup;
#else
typedef Open_tables_backup SPIDER_Open_tables_backup;
#endif

#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100500
#define SPIDER_reset_n_backup_open_tables_state(A,B,C) do { \
if (!(*(B) = new start_new_trans(A))) \
{ \
DBUG_RETURN(C); \
} \
} while (0)
#define SPIDER_restore_backup_open_tables_state(A,B) do { \
(*(B))->restore_old_transaction(); \
delete *(B); \
} while (0)
#define SPIDER_sys_close_thread_tables(A) (A)->commit_whole_transaction_and_close_tables()
#else
#define SPIDER_REQUIRE_DEFINE_FOR_SECONDARY_OPEN_TABLES_BACKUP
#define SPIDER_reset_n_backup_open_tables_state(A,B,C) (A)->reset_n_backup_open_tables_state(B)
#define SPIDER_restore_backup_open_tables_state(A,B) (A)->restore_backup_open_tables_state(B)
#define SPIDER_sys_close_thread_tables(A) close_thread_tables(A)
#endif

#define spider_bitmap_size(A) ((A + 7) / 8)
#define spider_set_bit(BITMAP, BIT) \
((BITMAP)[(BIT) / 8] |= (1 << ((BIT) & 7)))
@@ -1330,7 +1357,7 @@ typedef struct st_spider_direct_sql
TABLE_LIST *table_list_first;
TABLE_LIST *table_list;
uchar *real_table_bitmap;
Open_tables_backup open_tables_backup;
SPIDER_Open_tables_backup open_tables_backup;
THD *open_tables_thd;
#endif

@@ -290,11 +290,7 @@ int spider_get_ping_table_mon(
) {
int error_num;
TABLE *table_link_mon = NULL;
#if MYSQL_VERSION_ID < 50500
Open_tables_state open_tables_backup;
#else
Open_tables_backup open_tables_backup;
#endif
SPIDER_Open_tables_backup open_tables_backup;
char table_key[MAX_KEY_LENGTH];
SPIDER_TABLE_MON *table_mon, *table_mon_prev = NULL;
SPIDER_SHARE *tmp_share;
@@ -475,11 +471,7 @@ SPIDER_TABLE_MON_LIST *spider_get_ping_table_tgt(
int *error_num
) {
TABLE *table_tables = NULL;
#if MYSQL_VERSION_ID < 50500
Open_tables_state open_tables_backup;
#else
Open_tables_backup open_tables_backup;
#endif
SPIDER_Open_tables_backup open_tables_backup;
char table_key[MAX_KEY_LENGTH];

SPIDER_TABLE_MON_LIST *table_mon_list = NULL;
@@ -698,12 +690,9 @@ int spider_get_ping_table_gtid_pos(
int error_num, source_link_idx, need_mon;
char table_key[MAX_KEY_LENGTH];
TABLE *table_tables, *table_gtid_pos;
#if MYSQL_VERSION_ID < 50500
Open_tables_state open_tables_backup_tables;
Open_tables_state open_tables_backup_gtid_pos;
#else
Open_tables_backup open_tables_backup_tables;
Open_tables_backup open_tables_backup_gtid_pos;
SPIDER_Open_tables_backup open_tables_backup_tables;
#ifdef SPIDER_REQUIRE_DEFINE_FOR_SECONDARY_OPEN_TABLES_BACKUP
SPIDER_Open_tables_backup open_tables_backup_gtid_pos;
#endif
MEM_ROOT mem_root;
long link_status;
@@ -721,6 +710,7 @@ int spider_get_ping_table_gtid_pos(
db_name = setted db_name and
table_name = setted table_name
*/
#ifdef SPIDER_REQUIRE_DEFINE_FOR_SECONDARY_OPEN_TABLES_BACKUP
if (
!(table_tables = spider_open_sys_table(
thd, SPIDER_SYS_TABLES_TABLE_NAME_STR,
@@ -736,6 +726,44 @@ int spider_get_ping_table_gtid_pos(
&open_tables_backup_gtid_pos, need_lock, &error_num))
)
goto error_open_table_gtid_pos;
#else
TABLE_LIST tables_tables;
TABLE_LIST tables_gtid_pos;
TABLE_LIST *tables = &tables_tables;
LEX_CSTRING db_name =
{
"mysql",
sizeof("mysql") - 1
};
LEX_CSTRING tbl_name_tables =
{
SPIDER_SYS_TABLES_TABLE_NAME_STR,
SPIDER_SYS_TABLES_TABLE_NAME_LEN
};
LEX_CSTRING tbl_name_gtid_pos =
{
SPIDER_SYS_POS_FOR_RECOVERY_TABLE_NAME_STR,
SPIDER_SYS_POS_FOR_RECOVERY_TABLE_NAME_LEN
};
tables_tables.init_one_table(&db_name, &tbl_name_tables, 0, TL_READ);
tables_gtid_pos.init_one_table(&db_name, &tbl_name_gtid_pos, 0, TL_READ);
MDL_REQUEST_INIT(&tables_tables.mdl_request, MDL_key::TABLE,
SPIDER_TABLE_LIST_db_str(&tables_tables),
SPIDER_TABLE_LIST_table_name_str(&tables_tables),
MDL_SHARED_READ, MDL_TRANSACTION);
MDL_REQUEST_INIT(&tables_gtid_pos.mdl_request, MDL_key::TABLE,
SPIDER_TABLE_LIST_db_str(&tables_gtid_pos),
SPIDER_TABLE_LIST_table_name_str(&tables_gtid_pos),
MDL_SHARED_READ, MDL_TRANSACTION);
tables_tables.next_global = &tables_gtid_pos;
if (spider_sys_open_and_lock_tables(thd, &tables,
&open_tables_backup_tables))
{
goto error_open_table_tables;
}
table_tables = tables_tables.table;
table_gtid_pos = tables_gtid_pos.table;
#endif

table_tables->use_all_columns();
table_gtid_pos->use_all_columns();
@@ -822,8 +850,10 @@ int spider_get_ping_table_gtid_pos(
{
goto error_sys_index_end;
}
spider_close_sys_table(thd, table_gtid_pos, &open_tables_backup_gtid_pos,
need_lock);
#ifdef SPIDER_REQUIRE_DEFINE_FOR_SECONDARY_OPEN_TABLES_BACKUP
spider_close_sys_table(thd, table_gtid_pos,
&open_tables_backup_gtid_pos, need_lock);
#endif
spider_close_sys_table(thd, table_tables, &open_tables_backup_tables,
need_lock);

@@ -835,9 +865,12 @@ int spider_get_ping_table_gtid_pos(
spider_sys_index_end(table_tables);
error_sys_index_end:
error_get_sys_table_by_idx:
spider_close_sys_table(thd, table_gtid_pos, &open_tables_backup_gtid_pos,
#ifdef SPIDER_REQUIRE_DEFINE_FOR_SECONDARY_OPEN_TABLES_BACKUP
spider_close_sys_table(thd, table_gtid_pos,
&open_tables_backup_gtid_pos,
need_lock);
error_open_table_gtid_pos:
#endif
spider_close_sys_table(thd, table_tables, &open_tables_backup_tables,
need_lock);
error_open_table_tables:
@@ -852,11 +885,7 @@ int spider_init_ping_table_mon_cache(
int error_num, same;
uint old_elements;
TABLE *table_link_mon = NULL;
#if MYSQL_VERSION_ID < 50500
Open_tables_state open_tables_backup;
#else
Open_tables_backup open_tables_backup;
#endif
SPIDER_Open_tables_backup open_tables_backup;
SPIDER_MON_KEY mon_key;
DBUG_ENTER("spider_init_ping_table_mon_cache");

0 comments on commit 8f8f2ae

Please sign in to comment.