Commit bc3d416a authored by Yuchen Pei's avatar Yuchen Pei

MDEV-29718 Fix spider detection of same data node server

When the host is not specified, it defaults to localhost.
parent eabc74aa
......@@ -6,6 +6,9 @@ for child2
for child3
set @old_spider_bgs_mode= @@spider_bgs_mode;
set session spider_bgs_mode=1;
set spider_same_server_link=1;
set @old_spider_same_server_link=@@global.spider_same_server_link;
set global spider_same_server_link=1;
CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table td (a int, PRIMARY KEY (a));
create table ts (a int, PRIMARY KEY (a)) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv_mdev_26151",TABLE "td", casual_read "3"';
......@@ -26,6 +29,7 @@ min(a)
drop table td, ts;
drop server srv_mdev_26151;
set session spider_bgs_mode=@old_spider_bgs_mode;
set global spider_same_server_link=@old_spider_same_server_link;
for master_1
for child2
for child3
......
......@@ -5,6 +5,7 @@ for master_1
for child2
for child3
set global query_cache_type= on;
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t2 (c int);
......
......@@ -4,6 +4,7 @@
for master_1
for child2
for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
# testing monitoring_*
......
......@@ -4,6 +4,7 @@
for master_1
for child2
for child3
set spider_same_server_link=1;
CREATE SERVER s FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
......
......@@ -4,6 +4,7 @@
for master_1
for child2
for child3
set spider_same_server_link=1;
CREATE SERVER s FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t1 (a INT);
CREATE TABLE t2 (b INT);
......
......@@ -4,6 +4,7 @@
for master_1
for child2
for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t1 (c int);
......
......@@ -4,6 +4,7 @@
for master_1
for child2
for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t (a INT) ENGINE=Spider;
......
......@@ -4,6 +4,7 @@
for master_1
for child2
for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t1 (c int);
......
......@@ -4,6 +4,7 @@
for master_1
for child2
for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
......
......@@ -4,6 +4,7 @@
for master_1
for child2
for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t (c BLOB) ENGINE=InnoDB;
CREATE TABLE ts (c BLOB) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "srv",TABLE "t"';
......
......@@ -5,6 +5,7 @@ for master_1
for child2
for child3
SET @old_spider_read_only_mode = @@session.spider_read_only_mode;
set spider_same_server_link=1;
CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
set session spider_read_only_mode = default;
create table t2 (c int);
......
......@@ -4,6 +4,7 @@
for master_1
for child2
for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t1 ( a bigint(20) NOT NULL, b bigint(20) DEFAULT 0, PRIMARY KEY (a));
CREATE TABLE t2 ( a bigint(20) NOT NULL, b bigint(20) DEFAULT 0, PRIMARY KEY (a)) ENGINE=SPIDER COMMENT='srv "srv", WRAPPER "mysql", TABLE "t1"';
......
for master_1
for child2
for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
set session spider_delete_all_rows_type=0;
......
......@@ -4,6 +4,7 @@
for master_1
for child2
for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t2 (c varchar(16));
......
......@@ -4,6 +4,7 @@
for master_1
for child2
for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t1 (c int);
create table t2 (d int);
......
......@@ -4,6 +4,7 @@
for master_1
for child2
for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t1 (c1 int);
create table t2 (c2 int);
......
......@@ -14,6 +14,10 @@
--let $srv=srv_mdev_26151
set @old_spider_bgs_mode= @@spider_bgs_mode;
set session spider_bgs_mode=1;
set spider_same_server_link=1;
set @old_spider_same_server_link=@@global.spider_same_server_link;
set global spider_same_server_link=1;
evalp CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
# casual_read != 0 && casual_read != 1
......@@ -42,6 +46,7 @@ drop table td, ts;
eval drop server $srv;
set session spider_bgs_mode=@old_spider_bgs_mode;
set global spider_same_server_link=@old_spider_same_server_link;
--disable_query_log
--disable_result_log
......
......@@ -12,6 +12,7 @@
#set @@global.debug_dbug="d:t:i:o,mysqld.trace";
set global query_cache_type= on;
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t2 (c int);
......
......@@ -9,6 +9,7 @@
# This test covers some table params under consideration for inclusion
# in the engine-defined options to be implemented in MDEV-28856.
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
......
......@@ -12,6 +12,7 @@ if (`select not(count(*)) from information_schema.system_variables where variabl
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER s FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t1 (a INT);
......
......@@ -6,6 +6,7 @@
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER s FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t1 (a INT);
......
......@@ -8,6 +8,7 @@
--enable_result_log
--enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
......
......@@ -7,6 +7,7 @@
--enable_result_log
--enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
......
......@@ -7,6 +7,7 @@
--enable_result_log
--enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
......
......@@ -6,6 +6,7 @@
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t1 (a INT);
......
......@@ -9,6 +9,7 @@
--enable_result_log
--enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t (c BLOB) ENGINE=InnoDB;
CREATE TABLE ts (c BLOB) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "srv",TABLE "t"';
......
......@@ -10,6 +10,7 @@
--let $srv=srv_mdev_31524
SET @old_spider_read_only_mode = @@session.spider_read_only_mode;
set spider_same_server_link=1;
evalp CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
# when the user does not set var nor the table option, the default
......
......@@ -6,6 +6,7 @@
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t1 ( a bigint(20) NOT NULL, b bigint(20) DEFAULT 0, PRIMARY KEY (a));
......
......@@ -4,6 +4,7 @@
--enable_result_log
--enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
......
......@@ -6,6 +6,7 @@
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
......
......@@ -8,6 +8,7 @@
--enable_result_log
--enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t1 (c int);
create table t2 (d int);
......
......@@ -6,6 +6,7 @@
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t1 (c1 int);
create table t2 (c2 int);
......
......@@ -1985,7 +1985,7 @@ int spider_db_mbase::connect(
if (!spider_param_same_server_link(thd))
{
if (!strcmp(tgt_host, my_localhost))
if (!strcmp(tgt_host, my_localhost) || !tgt_host || !tgt_host[0])
{
if (!strcmp(tgt_socket, *spd_mysqld_unix_port))
{
......@@ -1995,7 +1995,7 @@ int spider_db_mbase::connect(
DBUG_RETURN(ER_SPIDER_SAME_SERVER_LINK_NUM);
}
} else if (!strcmp(tgt_host, "127.0.0.1") ||
!strcmp(tgt_host, glob_hostname))
!strcmp(tgt_host, glob_hostname) || !tgt_host || !tgt_host[0])
{
if (tgt_port == (long) *spd_mysqld_port)
{
......
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