Commit b28f99f7 authored by Yuchen Pei's avatar Yuchen Pei

MDEV-34708 Spider: report error when self-reference is detected

Self-reference is serious enough to stop the query execution.
parent eadf0f63
......@@ -16,12 +16,11 @@ INSERT INTO mysql.spider_link_mon_servers
create table t1 (c int) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", monitoring_kind "2"';
/* 1 */ insert into t1 values (42);
ERROR HY000: Table 'test.t2' get a problem
ERROR 42S02: Table 'test.t2' doesn't exist
/* 2 */ insert into t1 values (42);
ERROR HY000: All links of 'test.t1' are failed
ERROR 42S02: Table 'test.t2' doesn't exist
create table t2 (c int);
/* 3 */ insert into t1 values (42);
ERROR HY000: All links of 'test.t1' are failed
drop table t1, t2;
create table t1 (c int) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", monitoring_bg_kind "2",
......
......@@ -24,7 +24,7 @@ ERROR HY000: Unable to connect to foreign data source: localhost
drop table t;
CREATE TABLE t1 (a INT,b VARCHAR(255),PRIMARY KEY(a)) ENGINE=Spider comment="srv 'srv', table 't1', read_only_mode '1'";
INSERT INTO t1 VALUES (1,'aaa'),(2,'bbb'),(3,'ccc'),(4,'ddd');
ERROR HY000: Table 'test.t1' is read only
ERROR HY000: An infinite loop is detected when opening table test.t1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
......@@ -42,7 +42,7 @@ drop table t1;
CREATE TABLE t1 (c INT, KEY(c)) ENGINE=Spider COMMENT='WRAPPER "mysql", SRV "srv",TABLE "t2", PK_NAME "f"';
SET GLOBAL general_log=1;
INSERT INTO t1 VALUES (1, "aaa"),(2, "bbb"),(3, "ccc"),(4, "ddd");
ERROR 21S01: Column count doesn't match value count at row 1
ERROR 42S02: Table 'test.t2' doesn't exist
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
......
......@@ -17,9 +17,9 @@ CREATE TABLE t6 (c INT KEY) ENGINE=InnoDB PARTITION BY RANGE (c) (PARTITION p VA
CREATE TABLE t7 (a INT) ENGINE=Spider COMMENT='WRAPPER "mysql",SRV "srv",TABLE "t"';
CREATE TABLE t8 (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql",SRV "srv",TABLE "t"';
SELECT * FROM t8;
ERROR HY000: Remote table 'test.t' is not found
ERROR 42S02: Table 'test.t' doesn't exist
CREATE TEMPORARY TABLE t7 (c INT) ENGINE=InnoDB SELECT * FROM t7;
ERROR HY000: Remote table 'test.t' is not found
ERROR 42S02: Table 'test.t' doesn't exist
CALL foo;
ERROR 42000: PROCEDURE test.foo does not exist
CREATE TEMPORARY TABLE t7 (c INT) ENGINE=InnoDB;
......
INSTALL PLUGIN Spider SONAME 'ha_spider.so';
set @old_completion_type=@@global.completion_type;
SET SESSION autocommit=0, GLOBAL completion_type=2;
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 KEY) ENGINE=Spider COMMENT='WRAPPER "mysql",SRV "srv",TABLE "t"';
INSERT INTO t VALUES (1);
ERROR HY000: An infinite loop is detected when opening table test.t
alter table t COMMENT='WRAPPER "mysql",SRV "srv",TABLE "t1"';
INSERT INTO t VALUES (1);
ERROR 42S02: Table 'test.t1' doesn't exist
DROP PROCEDURE IF EXISTS p;
Warnings:
Note 1305 PROCEDURE test.p does not exist
drop table t;
drop server srv;
set global completion_type=@old_completion_type;
Warnings:
Warning 1620 Plugin is busy and will be uninstalled on shutdown
Note 1305 PLUGIN SPIDER_ALLOC_MEM does not exist
Note 1305 PLUGIN SPIDER_WRAPPER_PROTOCOLS does not exist
......@@ -24,14 +24,11 @@ INSERT INTO mysql.spider_link_mon_servers
create table t1 (c int) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", monitoring_kind "2"';
--error 12511
--error ER_NO_SUCH_TABLE
/* 1 */ insert into t1 values (42);
--error 12514
--error ER_NO_SUCH_TABLE
/* 2 */ insert into t1 values (42);
create table t2 (c int);
# Even though the table is available now, we still get "all links
# failed" error
--error 12514
/* 3 */ insert into t1 values (42);
drop table t1, t2;
......
......@@ -22,7 +22,7 @@ DELETE FROM t;
drop table t;
CREATE TABLE t1 (a INT,b VARCHAR(255),PRIMARY KEY(a)) ENGINE=Spider comment="srv 'srv', table 't1', read_only_mode '1'";
--error 12518
--error 12719
INSERT INTO t1 VALUES (1,'aaa'),(2,'bbb'),(3,'ccc'),(4,'ddd');
--disable_ps_protocol
SHOW CREATE TABLE t1;
......@@ -36,7 +36,7 @@ drop table t1;
CREATE TABLE t1 (c INT, KEY(c)) ENGINE=Spider COMMENT='WRAPPER "mysql", SRV "srv",TABLE "t2", PK_NAME "f"';
SET GLOBAL general_log=1;
--error ER_WRONG_VALUE_COUNT_ON_ROW
--error ER_NO_SUCH_TABLE
INSERT INTO t1 VALUES (1, "aaa"),(2, "bbb"),(3, "ccc"),(4, "ddd");
--disable_ps_protocol
SHOW CREATE TABLE t1;
......
......@@ -22,9 +22,9 @@ CREATE TABLE t5 (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql",SRV "srv",TABLE "
CREATE TABLE t6 (c INT KEY) ENGINE=InnoDB PARTITION BY RANGE (c) (PARTITION p VALUES LESS THAN (5));
CREATE TABLE t7 (a INT) ENGINE=Spider COMMENT='WRAPPER "mysql",SRV "srv",TABLE "t"';
CREATE TABLE t8 (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql",SRV "srv",TABLE "t"';
--error 12702
--error ER_NO_SUCH_TABLE
SELECT * FROM t8;
--error 12702
--error ER_NO_SUCH_TABLE
CREATE TEMPORARY TABLE t7 (c INT) ENGINE=InnoDB SELECT * FROM t7;
--error ER_SP_DOES_NOT_EXIST
CALL foo;
......
INSTALL PLUGIN Spider SONAME 'ha_spider.so';
set @old_completion_type=@@global.completion_type;
SET SESSION autocommit=0, GLOBAL completion_type=2;
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 (a INT KEY) ENGINE=Spider COMMENT='WRAPPER "mysql",SRV "srv",TABLE "t"';
--error 12719
INSERT INTO t VALUES (1);
alter table t COMMENT='WRAPPER "mysql",SRV "srv",TABLE "t1"';
--error 1146
INSERT INTO t VALUES (1);
DROP PROCEDURE IF EXISTS p;
drop table t;
drop server srv;
set global completion_type=@old_completion_type;
--disable_query_log
--source ../../include/clean_up_spider.inc
......@@ -4838,7 +4838,9 @@ SPIDER_SHARE *spider_get_share(
#endif
1))
) {
if (*error_num != ER_SPIDER_SYS_TABLE_VERSION_NUM)
if (*error_num != ER_SPIDER_SYS_TABLE_VERSION_NUM &&
*error_num != ER_SPIDER_INFINITE_LOOP_NUM &&
*error_num != ER_NO_SUCH_TABLE)
{
thd->clear_error();
} else {
......
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