1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Merge branch '10.4' into 10.5

This commit is contained in:
Yuchen Pei
2023-09-15 15:21:48 +10:00
15 changed files with 485 additions and 111 deletions

View File

@@ -0,0 +1,180 @@
#
# MDEV-28856 Spider: Implement more engine-defined options
#
for master_1
for child2
for child3
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
# testing monitoring_*
INSERT INTO mysql.spider_link_mon_servers
(db_name, table_name, link_id, sid, server) VALUES
('test', 't1', '0', 1, 'srv');
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
/* 2 */ insert into t1 values (42);
ERROR HY000: All links of 'test.t1' are failed
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",
monitoring_bg_interval "500000"';
/* 4 */ insert into t1 values (42);
ERROR 42S02: Table 'test.t2' doesn't exist
drop table t1;
# testing query_cache_sync
create table t1 (c int) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", query_cache_sync "3"';
create table t2 (c int);
/* 5 */ insert into t1 values (42);
select sql_cache * from t1;
c
42
select sql_no_cache * from t1;
c
42
drop table t1, t2;
# testing tgt_pk_names
create table t2 (c int);
create table t1 (c int, primary key (c)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
/* 6 */ insert ignore into t1 values (42), (42);
select * from t1;
c
42
42
drop table t1, t2;
create table t2 (c int, primary key (c));
create table t1 (c int) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
/* 7 */ insert ignore into t1 values (42), (42);
Warnings:
Warning 1022 Can't write; duplicate key in table 't1'
select * from t1;
c
42
drop table t1, t2;
create table t2 (c int, primary key (c));
create table t1 (c int, primary key (c)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
/* 8 */ insert ignore into t1 values (42), (42);
Warnings:
Warning 1062 Duplicate entry '42' for key 'PRIMARY'
select * from t1;
c
42
drop table t1, t2;
create table t2 (c int, primary key (c));
create table t1 (c int, primary key (c)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "c"';
/* 9 */ insert ignore into t1 values (42), (42);
Warnings:
Warning 1022 Can't write; duplicate key in table 't1'
select * from t1;
c
42
drop table t1, t2;
create table t2 (c int, unique key (c));
create table t1 (c int, primary key (c)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "c"';
/* 9.1 */ insert ignore into t1 values (42), (42);
Warnings:
Warning 1062 Duplicate entry '42' for key 'PRIMARY'
select * from t1;
c
42
drop table t1, t2;
create table t2 (c int, unique key (c));
create table t1 (c int, key (c)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "f"';
/* 10 */ insert ignore into t1 values (42), (42);
Warnings:
Warning 1062 Duplicate entry '42' for key 'c'
select * from t1;
c
42
drop table t1, t2;
create table t2 (c int, primary key (c));
create table t1 (c int, key (c)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "blah"';
/* 11 */ insert ignore into t1 values (42), (42);
Warnings:
Warning 1022 Can't write; duplicate key in table 't1'
select * from t1;
c
42
drop table t1, t2;
create table t2 (c int, d int, unique key (c), unique key (d));
create table t1 (c int, d int, key (c), key (d)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "blah"';
/* 12 */ insert ignore into t1 values (42, 43), (43, 43);
Warnings:
Warning 1062 Duplicate entry '43' for key 'd'
select * from t1;
c d
42 43
drop table t1, t2;
# Testing index hint
create table t2 (c int, d int, primary key (c), key (d));
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`c` int(11) NOT NULL,
`d` int(11) DEFAULT NULL,
PRIMARY KEY (`c`),
KEY `d` (`d`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
create table t1 (c int, d int, primary key (c), key (d)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", idx000 "f d"';
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` int(11) NOT NULL,
`d` int(11) DEFAULT NULL,
PRIMARY KEY (`c`),
KEY `d` (`d`)
) ENGINE=SPIDER DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", idx000 "f d"'
/* 13 */ insert into t1 values (42, 23), (37, 93);
select max(d) from t1;
max(d)
93
drop table t1, t2;
create table t2 (c int, d int, e int, primary key (c), key (d), unique key (e));
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`c` int(11) NOT NULL,
`d` int(11) DEFAULT NULL,
`e` int(11) DEFAULT NULL,
PRIMARY KEY (`c`),
UNIQUE KEY `e` (`e`),
KEY `d` (`d`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
create table t1 (c int, d int, e int, primary key (c), key (d), unique key (e)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", idx000 "f PRIMARY", idx001 "u d", idx002 "ig e"';
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` int(11) NOT NULL,
`d` int(11) DEFAULT NULL,
`e` int(11) DEFAULT NULL,
PRIMARY KEY (`c`),
UNIQUE KEY `e` (`e`),
KEY `d` (`d`)
) 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"'
/* 14 */ insert into t1 values (42, 23, 89), (37, 93, 47);
select max(d) from t1;
max(d)
93
drop table t1, t2;
drop server srv;
for master_1
for child2
for child3
#
# end of test mdev_28856
#

View File

@@ -14,6 +14,7 @@ create table t1 (c int) ENGINE=Spider COMMENT='WRAPPER "mysql", "srv" "srv",TABL
ERROR HY000: The connect info '"srv" "srv",TABLE "t2"' is invalid
create table t1 (c int) ENGINE=Spider CONNECTION='WRAPPER "mysql", srv \'srv\',TABLE "t2", password "say \\"hello\\ world!\\""';
drop table t1, t2;
drop server srv;
for master_1
for child2
for child3

View File

@@ -10,6 +10,7 @@ CREATE TABLE ts (c BLOB) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "srv",TABLE
SELECT TRIM(BOTH ' ' FROM c) FROM ts ORDER BY c;
TRIM(BOTH ' ' FROM c)
drop table t, ts;
drop server srv;
for master_1
for child2
for child3

View File

@@ -16,6 +16,7 @@ ERROR HY000: An infinite loop is detected when opening table test.t0
select * from t2;
ERROR HY000: An infinite loop is detected when opening table test.t0
drop table t0, t1, t2;
drop server srv_self_reference_multi;
for master_1
for child2
for child3

View File

@@ -0,0 +1,163 @@
--echo #
--echo # MDEV-28856 Spider: Implement more engine-defined options
--echo #
--disable_query_log
--disable_result_log
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
# This test covers some table params under consideration for inclusion
# in the engine-defined options to be implemented in MDEV-28856.
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
--echo # testing monitoring_*
INSERT INTO mysql.spider_link_mon_servers
(db_name, table_name, link_id, sid, server) VALUES
('test', 't1', '0', 1, 'srv');
create table t1 (c int) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", monitoring_kind "2"';
--error 12511
/* 1 */ insert into t1 values (42);
--error 12514
/* 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;
create table t1 (c int) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", monitoring_bg_kind "2",
monitoring_bg_interval "500000"';
# The monitoring thread was killed before it could ping the remote
# table, so the error is not 12511 or 12514
--error ER_NO_SUCH_TABLE
/* 4 */ insert into t1 values (42);
drop table t1;
--echo # testing query_cache_sync
create table t1 (c int) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", query_cache_sync "3"';
create table t2 (c int);
/* 5 */ insert into t1 values (42);
select sql_cache * from t1;
select sql_no_cache * from t1;
drop table t1, t2;
--echo # testing tgt_pk_names
# can insert duplicates...
create table t2 (c int);
create table t1 (c int, primary key (c)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
/* 6 */ insert ignore into t1 values (42), (42);
select * from t1;
drop table t1, t2;
# pk_names not used because no key declared in t1, 1022
create table t2 (c int, primary key (c));
create table t1 (c int) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
/* 7 */ insert ignore into t1 values (42), (42);
select * from t1;
drop table t1, t2;
# pk_name is the default "PRIMARY", 1062
create table t2 (c int, primary key (c));
create table t1 (c int, primary key (c)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
/* 8 */ insert ignore into t1 values (42), (42);
select * from t1;
drop table t1, t2;
# key name c does not match PRIMARY, 1022
create table t2 (c int, primary key (c));
create table t1 (c int, primary key (c)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "c"';
/* 9 */ insert ignore into t1 values (42), (42);
select * from t1;
drop table t1, t2;
# local primary key name c matches remote unique key name c, 1062 but
# warning says PRIMARY instead of c, because key->name is PRIMARY
# instead of c
create table t2 (c int, unique key (c));
create table t1 (c int, primary key (c)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "c"';
/* 9.1 */ insert ignore into t1 values (42), (42);
select * from t1;
drop table t1, t2;
# key name f does not match t2 key name, but it is not used any way
# because there's no primary key, 1062
create table t2 (c int, unique key (c));
create table t1 (c int, key (c)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "f"';
/* 10 */ insert ignore into t1 values (42), (42);
select * from t1;
drop table t1, t2;
# key name blah does not match t2 error key name PRIMARY, and the
# non-primary key-route does not return PRIMARY, 1022
create table t2 (c int, primary key (c));
create table t1 (c int, key (c)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "blah"';
/* 11 */ insert ignore into t1 values (42), (42);
select * from t1;
drop table t1, t2;
# key name blah does not match t2 key name, but still 1062, because we
# go through the non-primary key route
create table t2 (c int, d int, unique key (c), unique key (d));
create table t1 (c int, d int, key (c), key (d)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "blah"';
/* 12 */ insert ignore into t1 values (42, 43), (43, 43);
select * from t1;
drop table t1, t2;
--echo # Testing index hint
create table t2 (c int, d int, primary key (c), key (d));
show create table t2;
create table t1 (c int, d int, primary key (c), key (d)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", idx000 "f d"';
show create table t1;
/* 13 */ insert into t1 values (42, 23), (37, 93);
select max(d) from t1;
drop table t1, t2;
# multiple indices
create table t2 (c int, d int, e int, primary key (c), key (d), unique key (e));
show create table t2;
create table t1 (c int, d int, e int, primary key (c), key (d), unique key (e)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", idx000 "f PRIMARY", idx001 "u d", idx002 "ig e"';
show create table t1;
/* 14 */ insert into t1 values (42, 23, 89), (37, 93, 47);
select max(d) from 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
--echo #
--echo # end of test mdev_28856
--echo #

View File

@@ -23,6 +23,7 @@ create table t1 (c int) ENGINE=Spider COMMENT='WRAPPER "mysql", "srv" "srv",TABL
create table t1 (c int) ENGINE=Spider CONNECTION='WRAPPER "mysql", srv \'srv\',TABLE "t2", password "say \\"hello\\ world!\\""';
drop table t1, t2;
drop server srv;
--disable_query_log
--disable_result_log
--source ../t/test_deinit.inc

View File

@@ -15,6 +15,7 @@ CREATE TABLE ts (c BLOB) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "srv",TABLE
SELECT TRIM(BOTH ' ' FROM c) FROM ts ORDER BY c;
drop table t, ts;
drop server srv;
--disable_query_log
--disable_result_log
--source ../../t/test_deinit.inc

View File

@@ -21,6 +21,7 @@ select * from t1;
--error 12719
select * from t2;
drop table t0, t1, t2;
eval drop server $srv;
--disable_query_log
--disable_result_log