Skip to content

Commit 0f87091

Browse files
Merge branch '10.5' into 10.6
2 parents b70d8fb + cf81626 commit 0f87091

15 files changed

+485
-111
lines changed

storage/spider/ha_spider.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8666,6 +8666,10 @@ ha_rows ha_spider::records_in_range(
86668666
dbton_id = share->sql_dbton_ids[search_link_idx];
86678667
dbton_hdl = dbton_handler[dbton_id];
86688668
crd_mode = dbton_hdl->crd_mode_exchange(crd_mode);
8669+
/* This assertion simply demonstrates that the
8670+
static_key_cardinality field is unused. It will be deprecated
8671+
(MDEV-28861) and removed (MDEV-31146). */
8672+
DBUG_ASSERT(share->static_key_cardinality[inx] == -1);
86698673
if (crd_mode == 1 || crd_mode == 2)
86708674
{
86718675
DBUG_PRINT("info", ("spider static_key_cardinality[%u]=%lld", inx,
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
#
2+
# MDEV-28856 Spider: Implement more engine-defined options
3+
#
4+
for master_1
5+
for child2
6+
for child3
7+
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
8+
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
9+
# testing monitoring_*
10+
INSERT INTO mysql.spider_link_mon_servers
11+
(db_name, table_name, link_id, sid, server) VALUES
12+
('test', 't1', '0', 1, 'srv');
13+
create table t1 (c int) ENGINE=Spider
14+
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", monitoring_kind "2"';
15+
/* 1 */ insert into t1 values (42);
16+
ERROR HY000: Table 'test.t2' get a problem
17+
/* 2 */ insert into t1 values (42);
18+
ERROR HY000: All links of 'test.t1' are failed
19+
create table t2 (c int);
20+
/* 3 */ insert into t1 values (42);
21+
ERROR HY000: All links of 'test.t1' are failed
22+
drop table t1, t2;
23+
create table t1 (c int) ENGINE=Spider
24+
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", monitoring_bg_kind "2",
25+
monitoring_bg_interval "500000"';
26+
/* 4 */ insert into t1 values (42);
27+
ERROR 42S02: Table 'test.t2' doesn't exist
28+
drop table t1;
29+
# testing query_cache_sync
30+
create table t1 (c int) ENGINE=Spider
31+
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", query_cache_sync "3"';
32+
create table t2 (c int);
33+
/* 5 */ insert into t1 values (42);
34+
select sql_cache * from t1;
35+
c
36+
42
37+
select sql_no_cache * from t1;
38+
c
39+
42
40+
drop table t1, t2;
41+
# testing tgt_pk_names
42+
create table t2 (c int);
43+
create table t1 (c int, primary key (c)) ENGINE=Spider
44+
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
45+
/* 6 */ insert ignore into t1 values (42), (42);
46+
select * from t1;
47+
c
48+
42
49+
42
50+
drop table t1, t2;
51+
create table t2 (c int, primary key (c));
52+
create table t1 (c int) ENGINE=Spider
53+
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
54+
/* 7 */ insert ignore into t1 values (42), (42);
55+
Warnings:
56+
Warning 1022 Can't write; duplicate key in table 't1'
57+
select * from t1;
58+
c
59+
42
60+
drop table t1, t2;
61+
create table t2 (c int, primary key (c));
62+
create table t1 (c int, primary key (c)) ENGINE=Spider
63+
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
64+
/* 8 */ insert ignore into t1 values (42), (42);
65+
Warnings:
66+
Warning 1062 Duplicate entry '42' for key 'PRIMARY'
67+
select * from t1;
68+
c
69+
42
70+
drop table t1, t2;
71+
create table t2 (c int, primary key (c));
72+
create table t1 (c int, primary key (c)) ENGINE=Spider
73+
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "c"';
74+
/* 9 */ insert ignore into t1 values (42), (42);
75+
Warnings:
76+
Warning 1022 Can't write; duplicate key in table 't1'
77+
select * from t1;
78+
c
79+
42
80+
drop table t1, t2;
81+
create table t2 (c int, unique key (c));
82+
create table t1 (c int, primary key (c)) ENGINE=Spider
83+
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "c"';
84+
/* 9.1 */ insert ignore into t1 values (42), (42);
85+
Warnings:
86+
Warning 1062 Duplicate entry '42' for key 'PRIMARY'
87+
select * from t1;
88+
c
89+
42
90+
drop table t1, t2;
91+
create table t2 (c int, unique key (c));
92+
create table t1 (c int, key (c)) ENGINE=Spider
93+
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "f"';
94+
/* 10 */ insert ignore into t1 values (42), (42);
95+
Warnings:
96+
Warning 1062 Duplicate entry '42' for key 'c'
97+
select * from t1;
98+
c
99+
42
100+
drop table t1, t2;
101+
create table t2 (c int, primary key (c));
102+
create table t1 (c int, key (c)) ENGINE=Spider
103+
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "blah"';
104+
/* 11 */ insert ignore into t1 values (42), (42);
105+
Warnings:
106+
Warning 1022 Can't write; duplicate key in table 't1'
107+
select * from t1;
108+
c
109+
42
110+
drop table t1, t2;
111+
create table t2 (c int, d int, unique key (c), unique key (d));
112+
create table t1 (c int, d int, key (c), key (d)) ENGINE=Spider
113+
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "blah"';
114+
/* 12 */ insert ignore into t1 values (42, 43), (43, 43);
115+
Warnings:
116+
Warning 1062 Duplicate entry '43' for key 'd'
117+
select * from t1;
118+
c d
119+
42 43
120+
drop table t1, t2;
121+
# Testing index hint
122+
create table t2 (c int, d int, primary key (c), key (d));
123+
show create table t2;
124+
Table Create Table
125+
t2 CREATE TABLE `t2` (
126+
`c` int(11) NOT NULL,
127+
`d` int(11) DEFAULT NULL,
128+
PRIMARY KEY (`c`),
129+
KEY `d` (`d`)
130+
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
131+
create table t1 (c int, d int, primary key (c), key (d)) ENGINE=Spider
132+
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", idx000 "f d"';
133+
show create table t1;
134+
Table Create Table
135+
t1 CREATE TABLE `t1` (
136+
`c` int(11) NOT NULL,
137+
`d` int(11) DEFAULT NULL,
138+
PRIMARY KEY (`c`),
139+
KEY `d` (`d`)
140+
) ENGINE=SPIDER DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", idx000 "f d"'
141+
/* 13 */ insert into t1 values (42, 23), (37, 93);
142+
select max(d) from t1;
143+
max(d)
144+
93
145+
drop table t1, t2;
146+
create table t2 (c int, d int, e int, primary key (c), key (d), unique key (e));
147+
show create table t2;
148+
Table Create Table
149+
t2 CREATE TABLE `t2` (
150+
`c` int(11) NOT NULL,
151+
`d` int(11) DEFAULT NULL,
152+
`e` int(11) DEFAULT NULL,
153+
PRIMARY KEY (`c`),
154+
UNIQUE KEY `e` (`e`),
155+
KEY `d` (`d`)
156+
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
157+
create table t1 (c int, d int, e int, primary key (c), key (d), unique key (e)) ENGINE=Spider
158+
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", idx000 "f PRIMARY", idx001 "u d", idx002 "ig e"';
159+
show create table t1;
160+
Table Create Table
161+
t1 CREATE TABLE `t1` (
162+
`c` int(11) NOT NULL,
163+
`d` int(11) DEFAULT NULL,
164+
`e` int(11) DEFAULT NULL,
165+
PRIMARY KEY (`c`),
166+
UNIQUE KEY `e` (`e`),
167+
KEY `d` (`d`)
168+
) ENGINE=SPIDER DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", idx000 "f PRIMARY", idx001 "u d", idx002 "ig e"'
169+
/* 14 */ insert into t1 values (42, 23, 89), (37, 93, 47);
170+
select max(d) from t1;
171+
max(d)
172+
93
173+
drop table t1, t2;
174+
drop server srv;
175+
for master_1
176+
for child2
177+
for child3
178+
#
179+
# end of test mdev_28856
180+
#

storage/spider/mysql-test/spider/bugfix/r/mdev_31117.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ create table t1 (c int) ENGINE=Spider COMMENT='WRAPPER "mysql", "srv" "srv",TABL
1414
ERROR HY000: The connect info '"srv" "srv",TABLE "t2"' is invalid
1515
create table t1 (c int) ENGINE=Spider CONNECTION='WRAPPER "mysql", srv \'srv\',TABLE "t2", password "say \\"hello\\ world!\\""';
1616
drop table t1, t2;
17+
drop server srv;
1718
for master_1
1819
for child2
1920
for child3

storage/spider/mysql-test/spider/bugfix/r/mdev_31338.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ CREATE TABLE ts (c BLOB) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "srv",TABLE
1010
SELECT TRIM(BOTH ' ' FROM c) FROM ts ORDER BY c;
1111
TRIM(BOTH ' ' FROM c)
1212
drop table t, ts;
13+
drop server srv;
1314
for master_1
1415
for child2
1516
for child3

storage/spider/mysql-test/spider/bugfix/r/self_reference_multi.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ ERROR HY000: An infinite loop is detected when opening table test.t0
1616
select * from t2;
1717
ERROR HY000: An infinite loop is detected when opening table test.t0
1818
drop table t0, t1, t2;
19+
drop server srv_self_reference_multi;
1920
for master_1
2021
for child2
2122
for child3
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
--echo #
2+
--echo # MDEV-28856 Spider: Implement more engine-defined options
3+
--echo #
4+
--disable_query_log
5+
--disable_result_log
6+
--source ../../t/test_init.inc
7+
--enable_result_log
8+
--enable_query_log
9+
10+
# This test covers some table params under consideration for inclusion
11+
# in the engine-defined options to be implemented in MDEV-28856.
12+
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
13+
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
14+
15+
--echo # testing monitoring_*
16+
INSERT INTO mysql.spider_link_mon_servers
17+
(db_name, table_name, link_id, sid, server) VALUES
18+
('test', 't1', '0', 1, 'srv');
19+
20+
create table t1 (c int) ENGINE=Spider
21+
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", monitoring_kind "2"';
22+
23+
--error 12511
24+
/* 1 */ insert into t1 values (42);
25+
--error 12514
26+
/* 2 */ insert into t1 values (42);
27+
create table t2 (c int);
28+
# Even though the table is available now, we still get "all links
29+
# failed" error
30+
--error 12514
31+
/* 3 */ insert into t1 values (42);
32+
drop table t1, t2;
33+
34+
create table t1 (c int) ENGINE=Spider
35+
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", monitoring_bg_kind "2",
36+
monitoring_bg_interval "500000"';
37+
38+
# The monitoring thread was killed before it could ping the remote
39+
# table, so the error is not 12511 or 12514
40+
--error ER_NO_SUCH_TABLE
41+
/* 4 */ insert into t1 values (42);
42+
drop table t1;
43+
44+
--echo # testing query_cache_sync
45+
create table t1 (c int) ENGINE=Spider
46+
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", query_cache_sync "3"';
47+
create table t2 (c int);
48+
/* 5 */ insert into t1 values (42);
49+
select sql_cache * from t1;
50+
select sql_no_cache * from t1;
51+
52+
drop table t1, t2;
53+
54+
--echo # testing tgt_pk_names
55+
# can insert duplicates...
56+
create table t2 (c int);
57+
create table t1 (c int, primary key (c)) ENGINE=Spider
58+
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
59+
/* 6 */ insert ignore into t1 values (42), (42);
60+
select * from t1;
61+
62+
drop table t1, t2;
63+
64+
# pk_names not used because no key declared in t1, 1022
65+
create table t2 (c int, primary key (c));
66+
create table t1 (c int) ENGINE=Spider
67+
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
68+
/* 7 */ insert ignore into t1 values (42), (42);
69+
select * from t1;
70+
71+
drop table t1, t2;
72+
73+
# pk_name is the default "PRIMARY", 1062
74+
create table t2 (c int, primary key (c));
75+
create table t1 (c int, primary key (c)) ENGINE=Spider
76+
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
77+
/* 8 */ insert ignore into t1 values (42), (42);
78+
select * from t1;
79+
80+
drop table t1, t2;
81+
82+
# key name c does not match PRIMARY, 1022
83+
create table t2 (c int, primary key (c));
84+
create table t1 (c int, primary key (c)) ENGINE=Spider
85+
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "c"';
86+
/* 9 */ insert ignore into t1 values (42), (42);
87+
select * from t1;
88+
89+
drop table t1, t2;
90+
91+
# local primary key name c matches remote unique key name c, 1062 but
92+
# warning says PRIMARY instead of c, because key->name is PRIMARY
93+
# instead of c
94+
create table t2 (c int, unique key (c));
95+
create table t1 (c int, primary key (c)) ENGINE=Spider
96+
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "c"';
97+
/* 9.1 */ insert ignore into t1 values (42), (42);
98+
select * from t1;
99+
100+
drop table t1, t2;
101+
102+
# key name f does not match t2 key name, but it is not used any way
103+
# because there's no primary key, 1062
104+
create table t2 (c int, unique key (c));
105+
create table t1 (c int, key (c)) ENGINE=Spider
106+
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "f"';
107+
/* 10 */ insert ignore into t1 values (42), (42);
108+
select * from t1;
109+
110+
drop table t1, t2;
111+
112+
# key name blah does not match t2 error key name PRIMARY, and the
113+
# non-primary key-route does not return PRIMARY, 1022
114+
create table t2 (c int, primary key (c));
115+
create table t1 (c int, key (c)) ENGINE=Spider
116+
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "blah"';
117+
/* 11 */ insert ignore into t1 values (42), (42);
118+
select * from t1;
119+
120+
drop table t1, t2;
121+
122+
# key name blah does not match t2 key name, but still 1062, because we
123+
# go through the non-primary key route
124+
create table t2 (c int, d int, unique key (c), unique key (d));
125+
create table t1 (c int, d int, key (c), key (d)) ENGINE=Spider
126+
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "blah"';
127+
/* 12 */ insert ignore into t1 values (42, 43), (43, 43);
128+
select * from t1;
129+
130+
drop table t1, t2;
131+
132+
--echo # Testing index hint
133+
create table t2 (c int, d int, primary key (c), key (d));
134+
show create table t2;
135+
create table t1 (c int, d int, primary key (c), key (d)) ENGINE=Spider
136+
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", idx000 "f d"';
137+
show create table t1;
138+
/* 13 */ insert into t1 values (42, 23), (37, 93);
139+
select max(d) from t1;
140+
141+
drop table t1, t2;
142+
143+
# multiple indices
144+
create table t2 (c int, d int, e int, primary key (c), key (d), unique key (e));
145+
show create table t2;
146+
create table t1 (c int, d int, e int, primary key (c), key (d), unique key (e)) ENGINE=Spider
147+
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", idx000 "f PRIMARY", idx001 "u d", idx002 "ig e"';
148+
show create table t1;
149+
/* 14 */ insert into t1 values (42, 23, 89), (37, 93, 47);
150+
select max(d) from t1;
151+
152+
drop table t1, t2;
153+
154+
drop server srv;
155+
156+
--disable_query_log
157+
--disable_result_log
158+
--source ../../t/test_deinit.inc
159+
--enable_result_log
160+
--enable_query_log
161+
--echo #
162+
--echo # end of test mdev_28856
163+
--echo #

storage/spider/mysql-test/spider/bugfix/t/mdev_31117.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ create table t1 (c int) ENGINE=Spider COMMENT='WRAPPER "mysql", "srv" "srv",TABL
2323
create table t1 (c int) ENGINE=Spider CONNECTION='WRAPPER "mysql", srv \'srv\',TABLE "t2", password "say \\"hello\\ world!\\""';
2424
drop table t1, t2;
2525

26+
drop server srv;
2627
--disable_query_log
2728
--disable_result_log
2829
--source ../t/test_deinit.inc

storage/spider/mysql-test/spider/bugfix/t/mdev_31338.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ CREATE TABLE ts (c BLOB) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "srv",TABLE
1515
SELECT TRIM(BOTH ' ' FROM c) FROM ts ORDER BY c;
1616
drop table t, ts;
1717

18+
drop server srv;
1819
--disable_query_log
1920
--disable_result_log
2021
--source ../../t/test_deinit.inc

0 commit comments

Comments
 (0)