summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKentoku SHIBA <kentokushiba@gmail.com>2020-08-25 20:41:33 +0900
committerKentoku SHIBA <kentokushiba@gmail.com>2020-08-25 20:56:10 +0900
commit20b3c637d830c52f7ab26d22b9132a25fc12da5b (patch)
tree11aee53e3833981ee79145379956db87a8e30e6c
parent3cf298180500a136c2e83e57b4c1f7130dc866e4 (diff)
downloadmariadb-git-bb-10.6-MDEV-23561.tar.gz
MDEV-23561 Spider doesn't work with ps protocolbb-10.6-MDEV-23561
-rw-r--r--storage/spider/ha_spider.cc18
-rw-r--r--storage/spider/mysql-test/spider/bugfix/r/xa_cmd.result2
-rw-r--r--storage/spider/spd_copy_tables.cc6
-rw-r--r--storage/spider/spd_db_conn.cc6
-rw-r--r--storage/spider/spd_include.h29
-rw-r--r--storage/spider/spd_ping_table.cc77
-rw-r--r--storage/spider/spd_sys_table.cc143
-rw-r--r--storage/spider/spd_sys_table.h32
-rw-r--r--storage/spider/spd_table.cc41
-rw-r--r--storage/spider/spd_trx.cc133
10 files changed, 193 insertions, 294 deletions
diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc
index 51ceee310ae..366554855d0 100644
--- a/storage/spider/ha_spider.cc
+++ b/storage/spider/ha_spider.cc
@@ -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));
diff --git a/storage/spider/mysql-test/spider/bugfix/r/xa_cmd.result b/storage/spider/mysql-test/spider/bugfix/r/xa_cmd.result
index 3ff39317de6..846dc6c737b 100644
--- a/storage/spider/mysql-test/spider/bugfix/r/xa_cmd.result
+++ b/storage/spider/mysql-test/spider/bugfix/r/xa_cmd.result
@@ -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 %';
diff --git a/storage/spider/spd_copy_tables.cc b/storage/spider/spd_copy_tables.cc
index 28bc5464e13..51e3b920eea 100644
--- a/storage/spider/spd_copy_tables.cc
+++ b/storage/spider/spd_copy_tables.cc
@@ -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;
diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc
index e0538259fb2..88371d85d5a 100644
--- a/storage/spider/spd_db_conn.cc
+++ b/storage/spider/spd_db_conn.cc
@@ -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;
diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h
index da2f360d9d5..fde5746e418 100644
--- a/storage/spider/spd_include.h
+++ b/storage/spider/spd_include.h
@@ -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)))
@@ -1350,7 +1377,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
diff --git a/storage/spider/spd_ping_table.cc b/storage/spider/spd_ping_table.cc
index e233fc1fd86..18d60fddb5d 100644
--- a/storage/spider/spd_ping_table.cc
+++ b/storage/spider/spd_ping_table.cc
@@ -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 @@ error_get_sys_tables_link_status:
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");
diff --git a/storage/spider/spd_sys_table.cc b/storage/spider/spd_sys_table.cc
index ed456d8fd67..871dbb77027 100644
--- a/storage/spider/spd_sys_table.cc
+++ b/storage/spider/spd_sys_table.cc
@@ -234,28 +234,15 @@ inline int spider_delete_sys_table_row(TABLE *table, int record_number = 0,
return error_num;
}
-#if MYSQL_VERSION_ID < 50500
TABLE *spider_open_sys_table(
THD *thd,
const char *table_name,
int table_name_length,
bool write,
- Open_tables_state *open_tables_backup,
+ SPIDER_Open_tables_backup *open_tables_backup,
bool need_lock,
int *error_num
-)
-#else
-TABLE *spider_open_sys_table(
- THD *thd,
- const char *table_name,
- int table_name_length,
- bool write,
- Open_tables_backup *open_tables_backup,
- bool need_lock,
- int *error_num
-)
-#endif
-{
+) {
TABLE *table;
TABLE_LIST tables;
#if MYSQL_VERSION_ID < 50500
@@ -312,7 +299,7 @@ TABLE *spider_open_sys_table(
}
#if MYSQL_VERSION_ID < 50500
} else {
- thd->reset_n_backup_open_tables_state(open_tables_backup);
+ SPIDER_reset_n_backup_open_tables_state(thd, open_tables_backup, NULL);
if (!(table = (TABLE*) spider_malloc(spider_current_trx, 12,
sizeof(*table), MYF(MY_WME))))
@@ -607,28 +594,18 @@ TABLE *spider_open_sys_table(
error:
spider_free(spider_current_trx, table, MYF(0));
error_malloc:
- thd->restore_backup_open_tables_state(open_tables_backup);
+ SPIDER_restore_backup_open_tables_state(thd, open_tables_backup);
#endif
error_col_num_chk:
DBUG_RETURN(NULL);
}
-#if MYSQL_VERSION_ID < 50500
-void spider_close_sys_table(
- THD *thd,
- TABLE *table,
- Open_tables_state *open_tables_backup,
- bool need_lock
-)
-#else
void spider_close_sys_table(
THD *thd,
TABLE *table,
- Open_tables_backup *open_tables_backup,
+ SPIDER_Open_tables_backup *open_tables_backup,
bool need_lock
-)
-#endif
-{
+) {
DBUG_ENTER("spider_close_sys_table");
#if MYSQL_VERSION_ID < 50500
if (need_lock)
@@ -638,7 +615,7 @@ void spider_close_sys_table(
table->file->ha_reset();
closefrm(table, TRUE);
spider_free(spider_current_trx, table, MYF(0));
- thd->restore_backup_open_tables_state(open_tables_backup);
+ SPIDER_restore_backup_open_tables_state(thd, open_tables_backup);
}
#else
spider_sys_close_table(thd, open_tables_backup);
@@ -648,20 +625,28 @@ void spider_close_sys_table(
#if MYSQL_VERSION_ID < 50500
#else
-bool spider_sys_open_tables(
+bool spider_sys_open_and_lock_tables(
THD *thd,
TABLE_LIST **tables,
- Open_tables_backup *open_tables_backup
+ SPIDER_Open_tables_backup *open_tables_backup
) {
uint counter;
+ uint flags = MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK |
+ MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY | MYSQL_OPEN_IGNORE_FLUSH |
+ MYSQL_LOCK_IGNORE_TIMEOUT | MYSQL_LOCK_LOG_TABLE;
ulonglong utime_after_lock_backup = thd->utime_after_lock;
- DBUG_ENTER("spider_sys_open_tables");
- thd->reset_n_backup_open_tables_state(open_tables_backup);
- if (open_tables(thd, tables, &counter,
- MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK | MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY |
- MYSQL_OPEN_IGNORE_FLUSH | MYSQL_LOCK_IGNORE_TIMEOUT | MYSQL_LOCK_LOG_TABLE
- )) {
- thd->restore_backup_open_tables_state(open_tables_backup);
+ DBUG_ENTER("spider_sys_open_and_lock_tables");
+ SPIDER_reset_n_backup_open_tables_state(thd, open_tables_backup, TRUE);
+ if (open_tables(thd, tables, &counter, flags))
+ {
+ SPIDER_restore_backup_open_tables_state(thd, open_tables_backup);
+ thd->utime_after_lock = utime_after_lock_backup;
+ DBUG_RETURN(TRUE);
+ }
+ if (lock_tables(thd, *tables, counter, flags))
+ {
+ SPIDER_sys_close_thread_tables(thd);
+ SPIDER_restore_backup_open_tables_state(thd, open_tables_backup);
thd->utime_after_lock = utime_after_lock_backup;
DBUG_RETURN(TRUE);
}
@@ -672,13 +657,15 @@ bool spider_sys_open_tables(
TABLE *spider_sys_open_table(
THD *thd,
TABLE_LIST *tables,
- Open_tables_backup *open_tables_backup
+ SPIDER_Open_tables_backup *open_tables_backup
) {
TABLE *table;
ulonglong utime_after_lock_backup = thd->utime_after_lock;
DBUG_ENTER("spider_sys_open_table");
if (open_tables_backup)
- thd->reset_n_backup_open_tables_state(open_tables_backup);
+ {
+ SPIDER_reset_n_backup_open_tables_state(thd, open_tables_backup, NULL);
+ }
if ((table = open_ltable(thd, tables, tables->lock_type,
MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK | MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY |
MYSQL_OPEN_IGNORE_FLUSH | MYSQL_LOCK_IGNORE_TIMEOUT | MYSQL_LOCK_LOG_TABLE
@@ -686,19 +673,23 @@ TABLE *spider_sys_open_table(
table->use_all_columns();
table->s->no_replicate = 1;
} else if (open_tables_backup)
- thd->restore_backup_open_tables_state(open_tables_backup);
+ {
+ SPIDER_restore_backup_open_tables_state(thd, open_tables_backup);
+ }
thd->utime_after_lock = utime_after_lock_backup;
DBUG_RETURN(table);
}
void spider_sys_close_table(
THD *thd,
- Open_tables_backup *open_tables_backup
+ SPIDER_Open_tables_backup *open_tables_backup
) {
DBUG_ENTER("spider_sys_close_table");
- close_thread_tables(thd);
if (open_tables_backup)
- thd->restore_backup_open_tables_state(open_tables_backup);
+ {
+ SPIDER_sys_close_thread_tables(thd);
+ SPIDER_restore_backup_open_tables_state(thd, open_tables_backup);
+ }
DBUG_VOID_RETURN;
}
#endif
@@ -2973,11 +2964,7 @@ int spider_sys_update_tables_link_status(
) {
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;
DBUG_ENTER("spider_sys_update_tables_link_status");
if (
!(table_tables = spider_open_sys_table(
@@ -3011,11 +2998,7 @@ int spider_sys_log_tables_link_failed(
) {
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;
DBUG_ENTER("spider_sys_log_tables_link_failed");
if (
!(table_tables = spider_open_sys_table(
@@ -3050,11 +3033,7 @@ int spider_sys_log_xa_failed(
) {
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;
DBUG_ENTER("spider_sys_log_xa_failed");
if (
!(table_tables = spider_open_sys_table(
@@ -3421,11 +3400,7 @@ int spider_sys_insert_or_update_table_sts(
) {
int error_num;
TABLE *table_sts = 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;
DBUG_ENTER("spider_sys_insert_or_update_table_sts");
if (
!(table_sts = spider_open_sys_table(
@@ -3462,11 +3437,7 @@ int spider_sys_insert_or_update_table_crd(
) {
int error_num;
TABLE *table_crd = 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;
DBUG_ENTER("spider_sys_insert_or_update_table_crd");
if (
!(table_crd = spider_open_sys_table(
@@ -3502,11 +3473,7 @@ int spider_sys_delete_table_sts(
) {
int error_num;
TABLE *table_sts = 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;
DBUG_ENTER("spider_sys_delete_table_sts");
if (
!(table_sts = spider_open_sys_table(
@@ -3540,11 +3507,7 @@ int spider_sys_delete_table_crd(
) {
int error_num;
TABLE *table_crd = 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;
DBUG_ENTER("spider_sys_delete_table_crd");
if (
!(table_crd = spider_open_sys_table(
@@ -3580,11 +3543,7 @@ int spider_sys_get_table_sts(
int error_num;
char table_key[MAX_KEY_LENGTH];
TABLE *table_sts = 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;
DBUG_ENTER("spider_sys_get_table_sts");
if (
!(table_sts = spider_open_sys_table(
@@ -3633,17 +3592,14 @@ int spider_sys_get_table_crd(
char table_key[MAX_KEY_LENGTH];
bool index_inited = FALSE;
TABLE *table_crd = NULL;
-#if MYSQL_VERSION_ID < 50500
- Open_tables_state open_tables_backup;
-#endif
+ SPIDER_Open_tables_backup open_tables_backup;
DBUG_ENTER("spider_sys_get_table_crd");
- start_new_trans new_trans(thd);
if (
!(table_crd = spider_open_sys_table(
thd, SPIDER_SYS_TABLE_CRD_TABLE_NAME_STR,
SPIDER_SYS_TABLE_CRD_TABLE_NAME_LEN, TRUE,
- 0, need_lock, &error_num))
+ &open_tables_backup, need_lock, &error_num))
) {
goto error;
}
@@ -3676,8 +3632,8 @@ int spider_sys_get_table_crd(
goto error;
}
- thd->commit_whole_transaction_and_close_tables();
- new_trans.restore_old_transaction();
+ spider_close_sys_table(thd, table_crd, &open_tables_backup, need_lock);
+ table_crd = NULL;
DBUG_RETURN(0);
error:
@@ -3685,8 +3641,7 @@ error:
spider_sys_index_end(table_crd);
if (table_crd)
- thd->commit_whole_transaction_and_close_tables();
- new_trans.restore_old_transaction();
+ spider_close_sys_table(thd, table_crd, &open_tables_backup, need_lock);
DBUG_RETURN(error_num);
}
diff --git a/storage/spider/spd_sys_table.h b/storage/spider/spd_sys_table.h
index 90d9ca70a81..22f48b05dfb 100644
--- a/storage/spider/spd_sys_table.h
+++ b/storage/spider/spd_sys_table.h
@@ -86,30 +86,12 @@ public:
uint link_id_length;
};
-#if MYSQL_VERSION_ID < 50500
-TABLE *spider_open_sys_table(
- THD *thd,
- const char *table_name,
- int table_name_length,
- bool write,
- Open_tables_state *open_tables_backup,
- bool need_lock,
- int *error_num
-);
-
-void spider_close_sys_table(
- THD *thd,
- TABLE *table,
- Open_tables_state *open_tables_backup,
- bool need_lock
-);
-#else
TABLE *spider_open_sys_table(
THD *thd,
const char *table_name,
int table_name_length,
bool write,
- Open_tables_backup *open_tables_backup,
+ SPIDER_Open_tables_backup *open_tables_backup,
bool need_lock,
int *error_num
);
@@ -117,25 +99,27 @@ TABLE *spider_open_sys_table(
void spider_close_sys_table(
THD *thd,
TABLE *table,
- Open_tables_backup *open_tables_backup,
+ SPIDER_Open_tables_backup *open_tables_backup,
bool need_lock
);
-bool spider_sys_open_tables(
+#if MYSQL_VERSION_ID < 50500
+#else
+bool spider_sys_open_and_lock_tables(
THD *thd,
TABLE_LIST **tables,
- Open_tables_backup *open_tables_backup
+ SPIDER_Open_tables_backup *open_tables_backup
);
TABLE *spider_sys_open_table(
THD *thd,
TABLE_LIST *tables,
- Open_tables_backup *open_tables_backup
+ SPIDER_Open_tables_backup *open_tables_backup
);
void spider_sys_close_table(
THD *thd,
- Open_tables_backup *open_tables_backup
+ SPIDER_Open_tables_backup *open_tables_backup
);
#endif
diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc
index f8ef49aa9fc..52d2c9b28c4 100644
--- a/storage/spider/spd_table.cc
+++ b/storage/spider/spd_table.cc
@@ -5077,11 +5077,7 @@ SPIDER_SHARE *spider_get_share(
int semi_table_lock_conn;
int search_link_idx;
uint sql_command = thd_sql_command(thd);
-#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;
MEM_ROOT mem_root;
TABLE *table_tables = NULL;
bool init_mem_root = FALSE;
@@ -5218,11 +5214,10 @@ SPIDER_SHARE *spider_get_share(
SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME));
init_mem_root = TRUE;
- start_new_trans new_trans(thd);
if (
!(table_tables = spider_open_sys_table(
thd, SPIDER_SYS_TABLES_TABLE_NAME_STR,
- SPIDER_SYS_TABLES_TABLE_NAME_LEN, FALSE, 0,
+ SPIDER_SYS_TABLES_TABLE_NAME_LEN, FALSE, &open_tables_backup,
FALSE, error_num))
) {
for (roop_count = 0;
@@ -5259,8 +5254,9 @@ SPIDER_SHARE *spider_get_share(
share->init_error_time = (time_t) time((time_t*) 0);
share->init = TRUE;
spider_free_share(share);
- thd->commit_whole_transaction_and_close_tables();
- new_trans.restore_old_transaction();
+ spider_close_sys_table(thd, table_tables,
+ &open_tables_backup, FALSE);
+ table_tables = NULL;
goto error_open_sys_table;
}
} else {
@@ -5268,8 +5264,9 @@ SPIDER_SHARE *spider_get_share(
sizeof(long) * share->all_link_count);
share->link_status_init = TRUE;
}
- thd->commit_whole_transaction_and_close_tables();
- new_trans.restore_old_transaction();
+ spider_close_sys_table(thd, table_tables,
+ &open_tables_backup, FALSE);
+ table_tables = NULL;
}
share->have_recovery_link = spider_conn_check_recovery_link(share);
if (init_mem_root)
@@ -5775,12 +5772,11 @@ SPIDER_SHARE *spider_get_share(
{
SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME));
init_mem_root = TRUE;
- start_new_trans new_trans(thd);
if (
!(table_tables = spider_open_sys_table(
thd, SPIDER_SYS_TABLES_TABLE_NAME_STR,
- SPIDER_SYS_TABLES_TABLE_NAME_LEN, FALSE, 0,
+ SPIDER_SYS_TABLES_TABLE_NAME_LEN, FALSE, &open_tables_backup,
FALSE, error_num))
) {
for (roop_count = 0;
@@ -5811,8 +5807,9 @@ SPIDER_SHARE *spider_get_share(
}
pthread_mutex_unlock(&share->mutex);
spider_free_share(share);
- thd->commit_whole_transaction_and_close_tables();
- new_trans.restore_old_transaction();
+ spider_close_sys_table(thd, table_tables,
+ &open_tables_backup, FALSE);
+ table_tables = NULL;
goto error_open_sys_table;
}
} else {
@@ -5820,9 +5817,9 @@ SPIDER_SHARE *spider_get_share(
sizeof(long) * share->all_link_count);
share->link_status_init = TRUE;
}
- thd->commit_whole_transaction_and_close_tables();
- new_trans.restore_old_transaction();
- table_tables= 0;
+ spider_close_sys_table(thd, table_tables,
+ &open_tables_backup, FALSE);
+ table_tables = NULL;
}
share->have_recovery_link = spider_conn_check_recovery_link(share);
if (init_mem_root)
@@ -6774,11 +6771,7 @@ int spider_open_all_tables(
long *long_info;
longlong *longlong_info;
MEM_ROOT mem_root;
-#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;
DBUG_ENTER("spider_open_all_tables");
if (
!(table_tables = spider_open_sys_table(
@@ -9784,7 +9777,7 @@ int spider_discover_table_structure(
#ifdef WITH_PARTITION_STORAGE_ENGINE
partition_info *part_info = thd->work_part_info;
#endif
- Open_tables_backup open_tables_backup;
+ SPIDER_Open_tables_backup open_tables_backup;
TABLE *table_tables;
#ifdef WITH_PARTITION_STORAGE_ENGINE
uint str_len;
diff --git a/storage/spider/spd_trx.cc b/storage/spider/spd_trx.cc
index 6595984e728..defa9be3f8c 100644
--- a/storage/spider/spd_trx.cc
+++ b/storage/spider/spd_trx.cc
@@ -2194,11 +2194,7 @@ int spider_internal_xa_commit(
SPIDER_CONN *conn;
uint force_commit = spider_param_force_commit(thd);
MEM_ROOT mem_root;
-#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 table_xa_opened = FALSE;
bool table_xa_member_opened = FALSE;
DBUG_ENTER("spider_internal_xa_commit");
@@ -2382,11 +2378,7 @@ int spider_internal_xa_rollback(
SPIDER_CONN *conn;
uint force_commit = spider_param_force_commit(thd);
MEM_ROOT mem_root;
-#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 server_lost = FALSE;
bool table_xa_opened = FALSE;
bool table_xa_member_opened = FALSE;
@@ -2624,11 +2616,7 @@ int spider_internal_xa_prepare(
int error_num;
SPIDER_CONN *conn;
uint force_commit = spider_param_force_commit(thd);
-#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 table_xa_opened = FALSE;
bool table_xa_member_opened = FALSE;
DBUG_ENTER("spider_internal_xa_prepare");
@@ -2799,11 +2787,7 @@ int spider_internal_xa_recover(
int cnt = 0;
char xa_key[MAX_KEY_LENGTH];
MEM_ROOT mem_root;
-#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;
DBUG_ENTER("spider_internal_xa_recover");
/*
select
@@ -2858,50 +2842,24 @@ int spider_initinal_xa_recover(
uint len
) {
int error_num;
- static THD *thd = NULL;
- static TABLE *table_xa = NULL;
- static READ_RECORD *read_record = NULL;
-#if MYSQL_VERSION_ID < 50500
- static Open_tables_state *open_tables_backup = NULL;
-#else
- static Open_tables_backup *open_tables_backup = NULL;
-#endif
+ THD *thd;
+ TABLE *table_xa;
+ READ_RECORD *read_record;
+ SPIDER_Open_tables_backup open_tables_backup;
int cnt = 0;
MEM_ROOT mem_root;
DBUG_ENTER("spider_initinal_xa_recover");
- if (!open_tables_backup)
+ if (!(read_record = new READ_RECORD))
{
-#if MYSQL_VERSION_ID < 50500
- if (!(open_tables_backup = new Open_tables_state))
-#else
- if (!(open_tables_backup = new Open_tables_backup))
-#endif
- {
- error_num = HA_ERR_OUT_OF_MEM;
- goto error_create_state;
- }
- }
- if (!read_record)
- {
- if (!(read_record = new READ_RECORD))
- {
- error_num = HA_ERR_OUT_OF_MEM;
- goto error_create_read_record;
- }
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error_create_read_record;
}
-/*
- if (!thd)
+ if (!(thd = spider_create_tmp_thd()))
{
-*/
- if (!(thd = spider_create_tmp_thd()))
- {
- error_num = HA_ERR_OUT_OF_MEM;
- goto error_create_thd;
- }
-/*
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error_create_thd;
}
-*/
/*
select
@@ -2912,17 +2870,14 @@ int spider_initinal_xa_recover(
from
mysql.spider_xa
*/
- if (!table_xa)
- {
- if (
- !(table_xa = spider_open_sys_table(
- thd, SPIDER_SYS_XA_TABLE_NAME_STR, SPIDER_SYS_XA_TABLE_NAME_LEN,
- FALSE, open_tables_backup, TRUE, &error_num))
- )
- goto error_open_table;
- SPIDER_init_read_record(read_record, thd, table_xa, NULL, NULL, TRUE,
- FALSE, FALSE);
- }
+ if (
+ !(table_xa = spider_open_sys_table(
+ thd, SPIDER_SYS_XA_TABLE_NAME_STR, SPIDER_SYS_XA_TABLE_NAME_LEN,
+ FALSE, &open_tables_backup, TRUE, &error_num))
+ )
+ goto error_open_table;
+ SPIDER_init_read_record(read_record, thd, table_xa, NULL, NULL, TRUE,
+ FALSE, FALSE);
SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME));
while ((!(read_record->SPIDER_read_record_read_record(read_record))) &&
cnt < (int) len)
@@ -2932,30 +2887,15 @@ int spider_initinal_xa_recover(
}
free_root(&mem_root, MYF(0));
-/*
- if (cnt < (int) len)
- {
-*/
- end_read_record(read_record);
- spider_close_sys_table(thd, table_xa, open_tables_backup, TRUE);
- table_xa = NULL;
- spider_free_tmp_thd(thd);
- thd = NULL;
- delete read_record;
- read_record = NULL;
- delete open_tables_backup;
- open_tables_backup = NULL;
-/*
- }
-*/
- DBUG_RETURN(cnt);
-
-/*
-error:
- end_read_record(&read_record_info);
+ end_read_record(read_record);
spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE);
table_xa = NULL;
-*/
+ spider_free_tmp_thd(thd);
+ thd = NULL;
+ delete read_record;
+ read_record = NULL;
+ DBUG_RETURN(cnt);
+
error_open_table:
spider_free_tmp_thd(thd);
thd = NULL;
@@ -2963,9 +2903,6 @@ error_create_thd:
delete read_record;
read_record = NULL;
error_create_read_record:
- delete open_tables_backup;
- open_tables_backup = NULL;
-error_create_state:
DBUG_RETURN(0);
}
@@ -2986,11 +2923,7 @@ int spider_internal_xa_commit_by_xid(
SPIDER_CONN *conn;
uint force_commit = spider_param_force_commit(thd);
MEM_ROOT mem_root;
-#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 table_xa_opened = FALSE;
bool table_xa_member_opened = FALSE;
DBUG_ENTER("spider_internal_xa_commit_by_xid");
@@ -3221,11 +3154,7 @@ int spider_internal_xa_rollback_by_xid(
SPIDER_CONN *conn;
uint force_commit = spider_param_force_commit(thd);
MEM_ROOT mem_root;
-#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 table_xa_opened = FALSE;
bool table_xa_member_opened = FALSE;
DBUG_ENTER("spider_internal_xa_rollback_by_xid");