diff options
author | Kentoku SHIBA <kentokushiba@gmail.com> | 2019-06-12 19:30:50 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-12 19:30:50 +0900 |
commit | 8e3a4be45c551883d37e5598f0b4108ccf31521c (patch) | |
tree | 01182fde7f7694adf4a6df1cf46e941e9c2e1470 /storage | |
parent | 2fd82471aba9447e5490b24da5da89c33a21525e (diff) | |
download | mariadb-git-8e3a4be45c551883d37e5598f0b4108ccf31521c.tar.gz |
MDEV-6275 spider_same_server_link not enforced (#1330)
Diffstat (limited to 'storage')
-rw-r--r-- | storage/spider/ha_spider.cc | 4 | ||||
-rw-r--r-- | storage/spider/mysql-test/spider/bugfix/include/same_server_link_deinit.inc | 11 | ||||
-rw-r--r-- | storage/spider/mysql-test/spider/bugfix/include/same_server_link_init.inc | 15 | ||||
-rw-r--r-- | storage/spider/mysql-test/spider/bugfix/r/same_server_link.result | 42 | ||||
-rw-r--r-- | storage/spider/mysql-test/spider/bugfix/t/same_server_link.cnf | 2 | ||||
-rw-r--r-- | storage/spider/mysql-test/spider/bugfix/t/same_server_link.test | 55 | ||||
-rw-r--r-- | storage/spider/spd_db_mysql.cc | 26 | ||||
-rw-r--r-- | storage/spider/spd_err.h | 3 | ||||
-rw-r--r-- | storage/spider/spd_table.cc | 8 |
9 files changed, 164 insertions, 2 deletions
diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 4fbb6d1a8c1..33e81201fff 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -9431,9 +9431,9 @@ int ha_spider::calculate_checksum() stats.checksum = 0; } else { share->stat.checksum_null = FALSE; - share->stat.checksum = checksum_val; + share->stat.checksum = (ha_checksum) checksum_val; stats.checksum_null = FALSE; - stats.checksum = checksum_val; + stats.checksum = (ha_checksum) checksum_val; } DBUG_RETURN(0); } diff --git a/storage/spider/mysql-test/spider/bugfix/include/same_server_link_deinit.inc b/storage/spider/mysql-test/spider/bugfix/include/same_server_link_deinit.inc new file mode 100644 index 00000000000..a4e8a10db19 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/include/same_server_link_deinit.inc @@ -0,0 +1,11 @@ +--connection master_1 +set global spider_same_server_link= @old_global_spider_same_server_link; +set session spider_same_server_link= @old_session_spider_same_server_link; +--let $MASTER_1_COMMENT_2_1= $MASTER_1_COMMENT_2_1_BACKUP +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/bugfix/include/same_server_link_init.inc b/storage/spider/mysql-test/spider/bugfix/include/same_server_link_init.inc new file mode 100644 index 00000000000..2c8150c905d --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/include/same_server_link_init.inc @@ -0,0 +1,15 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_init.inc +--enable_result_log +--enable_query_log +--enable_warnings +--let $MASTER_1_COMMENT_2_1_BACKUP= $MASTER_1_COMMENT_2_1 +let $MASTER_1_COMMENT_2_1= + COMMENT='table "tbl_b", host "127.0.0.1", port "$MASTER_1_MYPORT", user "root"'; +--connection master_1 +set @old_global_spider_same_server_link= @@global.spider_same_server_link; +set @old_session_spider_same_server_link= @@session.spider_same_server_link; +set global spider_same_server_link= 0; +set session spider_same_server_link= 0; diff --git a/storage/spider/mysql-test/spider/bugfix/r/same_server_link.result b/storage/spider/mysql-test/spider/bugfix/r/same_server_link.result new file mode 100644 index 00000000000..1f4177568a7 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/same_server_link.result @@ -0,0 +1,42 @@ +for master_1 +for child2 +for child3 +connection master_1; +set @old_global_spider_same_server_link= @@global.spider_same_server_link; +set @old_session_spider_same_server_link= @@session.spider_same_server_link; +set global spider_same_server_link= 0; +set session spider_same_server_link= 0; + +this test is for MDEV-6268 + +drop and create databases +connection master_1; +CREATE DATABASE auto_test_local; +USE auto_test_local; + +create table +connection master_1; +CREATE TABLE tbl_a ( +pkey int NOT NULL, +PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +CREATE TABLE tbl_b ( +pkey int NOT NULL, +PRIMARY KEY (pkey) +) MASTER_1_ENGINE2 MASTER_1_CHARSET MASTER_1_COMMENT_2_1 + +select test 1 +connection master_1; +INSERT INTO tbl_a VALUES(1); + +deinit +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +connection master_1; +set global spider_same_server_link= @old_global_spider_same_server_link; +set session spider_same_server_link= @old_session_spider_same_server_link; +for master_1 +for child2 +for child3 + +end of test diff --git a/storage/spider/mysql-test/spider/bugfix/t/same_server_link.cnf b/storage/spider/mysql-test/spider/bugfix/t/same_server_link.cnf new file mode 100644 index 00000000000..b0853e32654 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/same_server_link.cnf @@ -0,0 +1,2 @@ +!include include/default_mysqld.cnf +!include ../my_1_1.cnf diff --git a/storage/spider/mysql-test/spider/bugfix/t/same_server_link.test b/storage/spider/mysql-test/spider/bugfix/t/same_server_link.test new file mode 100644 index 00000000000..1468f00cd1c --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/same_server_link.test @@ -0,0 +1,55 @@ +--source ../include/same_server_link_init.inc +--echo +--echo this test is for MDEV-6268 +--echo +--echo drop and create databases + +--connection master_1 +--disable_warnings +CREATE DATABASE auto_test_local; +USE auto_test_local; +--enable_warnings + +--echo +--echo create table + +--connection master_1 +--disable_query_log +echo CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +echo CREATE TABLE tbl_b ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) MASTER_1_ENGINE2 MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE tbl_b ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) $MASTER_1_ENGINE2 $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log + +--echo +--echo select test 1 + +--connection master_1 +--disable_result_log +--error 12720 +INSERT INTO tbl_a VALUES(1); +--enable_result_log + +--echo +--echo deinit +--disable_warnings + +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; + +--enable_warnings +--source ../include/same_server_link_deinit.inc +--echo +--echo end of test diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 393263e152d..18e2d2acbd5 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -56,6 +56,8 @@ extern HASH spider_open_connections; extern HASH spider_ipport_conns; extern SPIDER_DBTON spider_dbton[SPIDER_DBTON_SIZE]; extern const char spider_dig_upper[]; +extern const char **spd_mysqld_unix_port; +extern uint *spd_mysqld_port; spider_db_mysql_util spider_db_mysql_utility; spider_db_mariadb_util spider_db_mariadb_utility; @@ -1970,6 +1972,30 @@ int spider_db_mbase::connect( conn->tgt_default_group); } + if (!spider_param_same_server_link(thd)) + { + if (!strcmp(tgt_host, my_localhost)) + { + if (!strcmp(tgt_socket, *spd_mysqld_unix_port)) + { + my_printf_error(ER_SPIDER_SAME_SERVER_LINK_NUM, + ER_SPIDER_SAME_SERVER_LINK_STR1, MYF(0), + tgt_host, tgt_socket); + DBUG_RETURN(ER_SPIDER_SAME_SERVER_LINK_NUM); + } + } else if (!strcmp(tgt_host, "127.0.0.1") || + !strcmp(tgt_host, glob_hostname)) + { + if (tgt_port == *spd_mysqld_port) + { + my_printf_error(ER_SPIDER_SAME_SERVER_LINK_NUM, + ER_SPIDER_SAME_SERVER_LINK_STR2, MYF(0), + tgt_host, tgt_port); + DBUG_RETURN(ER_SPIDER_SAME_SERVER_LINK_NUM); + } + } + } + if (connect_mutex) pthread_mutex_lock(&spider_open_conn_mutex); /* tgt_db not use */ diff --git a/storage/spider/spd_err.h b/storage/spider/spd_err.h index a80d903bd6e..9889fcfa7fb 100644 --- a/storage/spider/spd_err.h +++ b/storage/spider/spd_err.h @@ -124,6 +124,9 @@ #define ER_SPIDER_CON_COUNT_ERROR_STR "Too many connections between spider and remote" #define ER_SPIDER_TABLE_OPEN_TIMEOUT_NUM 12714 #define ER_SPIDER_TABLE_OPEN_TIMEOUT_STR "Table %s.%s open timeout" +#define ER_SPIDER_SAME_SERVER_LINK_NUM 12720 +#define ER_SPIDER_SAME_SERVER_LINK_STR1 "Host:%s and Socket:%s aim self server. Please change spider_same_server_link parameter if this link is required." +#define ER_SPIDER_SAME_SERVER_LINK_STR2 "Host:%s and Port:%ld aim self server. Please change spider_same_server_link parameter if this link is required." #define ER_SPIDER_COND_SKIP_NUM 12801 #define ER_SPIDER_UNKNOWN_NUM 12500 diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index ad3d10dc642..fc2aa6c1d60 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -122,6 +122,8 @@ HASH *spd_db_att_xid_cache; struct charset_info_st *spd_charset_utf8_bin; const char **spd_defaults_extra_file; const char **spd_defaults_file; +const char **spd_mysqld_unix_port; +uint *spd_mysqld_port; bool volatile *spd_abort_loop; Time_zone *spd_tz_system; extern long spider_conn_mutex_id; @@ -6934,6 +6936,10 @@ int spider_db_init( GetProcAddress(current_module, "my_defaults_extra_file"); spd_defaults_file = (const char **) GetProcAddress(current_module, "my_defaults_file"); + spd_mysqld_unix_port = (const char **) + GetProcAddress(current_module, "?mysqld_unix_port@@3PADA"); + spd_mysqld_port = (uint *) + GetProcAddress(current_module, "?mysqld_port@@3IA"); spd_abort_loop = (bool volatile *) GetProcAddress(current_module, "?abort_loop@@3_NC"); spd_tz_system = *(Time_zone **) @@ -6960,6 +6966,8 @@ int spider_db_init( spd_charset_utf8_bin = &my_charset_utf8_bin; spd_defaults_extra_file = &my_defaults_extra_file; spd_defaults_file = &my_defaults_file; + spd_mysqld_unix_port = (const char **) &mysqld_unix_port; + spd_mysqld_port = &mysqld_port; spd_abort_loop = &abort_loop; spd_tz_system = my_tz_SYSTEM; #endif |