summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKentoku <kentokushiba@gmail.com>2019-06-10 13:34:43 +0900
committerKentoku <kentokushiba@gmail.com>2019-06-11 02:12:38 +0900
commit7ea0afd8611771de1278a35445d3b413c5f678f4 (patch)
tree13027e07c07c6d94a25d4b4fd17e5b20cf7ff2d3
parentbe5c432a42eed10535354f31dfd6daa07095e555 (diff)
downloadmariadb-git-bb-10.4-MDEV-6275.tar.gz
MDEV-6275 spider_same_server_link not enforcedbb-10.4-MDEV-6275
-rw-r--r--storage/spider/ha_spider.cc4
-rw-r--r--storage/spider/mysql-test/spider/bugfix/include/same_server_link_deinit.inc11
-rw-r--r--storage/spider/mysql-test/spider/bugfix/include/same_server_link_init.inc15
-rw-r--r--storage/spider/mysql-test/spider/bugfix/r/same_server_link.result42
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/same_server_link.cnf2
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/same_server_link.test55
-rw-r--r--storage/spider/spd_db_mysql.cc26
-rw-r--r--storage/spider/spd_err.h3
-rw-r--r--storage/spider/spd_table.cc8
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 313c6d0495c..48d2c21d74a 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