Commit eabc74aa authored by Yuchen Pei's avatar Yuchen Pei

MDEV-33008 Fix spider table discovery

A new column was introduced to the show index output in 10.6 in
f691d986

Thus we update the check of the number of columns to be at least 13,
rather than exactly 13.

Also backport an err number and format from 10.5 for better error
messages when the column number is wrong.
parent 2310f659
for master_1
for child2
for child3
set spider_same_server_link=on;
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t2 (
`id` int(11) NOT NULL AUTO_INCREMENT,
`code` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
);
create table t1 ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`code` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=SPIDER DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"'
drop table t1, t2;
drop server srv;
for master_1
for child2
for child3
--disable_query_log
--disable_result_log
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
set spider_same_server_link=on;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t2 (
`id` int(11) NOT NULL AUTO_INCREMENT,
`code` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
);
create table t1 ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
show create table t1;
drop table t1, t2;
drop server srv;
--disable_query_log
--disable_result_log
--source ../../t/test_deinit.inc
--enable_result_log
--enable_query_log
......@@ -1566,10 +1566,13 @@ int spider_db_mbase_result::fetch_index_for_discover_table_structure(
}
DBUG_RETURN(0);
}
if (num_fields() != 13)
if (num_fields() < 13)
{
DBUG_PRINT("info",("spider num_fields != 13"));
my_printf_error(ER_SPIDER_UNKNOWN_NUM, ER_SPIDER_UNKNOWN_STR, MYF(0));
DBUG_PRINT("info",("spider num_fields < 13"));
my_printf_error(ER_SPIDER_CANT_NUM, ER_SPIDER_CANT_STR1, MYF(0),
"fetch index for table structure discovery because of "
"wrong number of columns in SHOW INDEX FROM output: ",
num_fields());
DBUG_RETURN(ER_SPIDER_UNKNOWN_NUM);
}
bool first = TRUE;
......
......@@ -127,6 +127,8 @@
#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_CANT_NUM 12721
#define ER_SPIDER_CANT_STR1 "Can't %s%d"
#define ER_SPIDER_COND_SKIP_NUM 12801
#define ER_SPIDER_UNKNOWN_NUM 12500
......
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