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

Merge branch '10.6' into 10.11

This commit is contained in:
Sergei Golubchik
2024-04-22 11:00:03 +02:00
418 changed files with 7074 additions and 2930 deletions

View File

@@ -72,7 +72,6 @@ SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argum
argument
select `pkey`,`val` from `auto_test_remote`.`tbl_a`
select `pkey`,`val` from `auto_test_remote`.`tbl_a` where `pkey` = 1
select 1 from (select 1) t0
select `pkey`,`val` from `auto_test_remote`.`tbl_a`
select `pkey`,`val` from `auto_test_remote`.`tbl_a`
SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'
@@ -86,7 +85,6 @@ argument
select `pkey`,`val` from `auto_test_remote2`.`tbl_a`
select `pkey`,`val` from `auto_test_remote2`.`tbl_a`
select `pkey`,`val` from `auto_test_remote2`.`tbl_a` where `pkey` = 2
select 1 from (select 1) t0
select `pkey`,`val` from `auto_test_remote2`.`tbl_a`
SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'
SELECT pkey, val FROM tbl_a ORDER BY pkey;

View File

@@ -66,9 +66,6 @@ id greeting
connection child2_1;
SELECT argument FROM mysql.general_log WHERE argument LIKE 'select `id`,`greeting` from %';
argument
select `id`,`greeting` from `auto_test_remote`.`tbl_a` where `greeting` = 'Aloha!' and ((`greeting` = 'Aloha!'))
select `id`,`greeting` from `auto_test_remote`.`tbl_b` where `greeting` like 'Aloha%' and ((`greeting` = 'Aloha!'))
select `id`,`greeting` from `auto_test_remote`.`tbl_c` where `greeting` like 'Aloha%' and ((`greeting` = 'Aloha!'))
connection child2_1;
SET @@global.general_log = @general_log_backup;
SET @@global.log_output = @log_output_backup;

View File

@@ -5,6 +5,8 @@ for master_1
for child2
for child3
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');
# testing monitoring_*
@@ -173,6 +175,7 @@ max(d)
93
drop table t1, t2;
drop server srv;
set global spider_same_server_link=@old_spider_same_server_link;
for master_1
for child2
for child3

View File

@@ -0,0 +1,4 @@
set @old_sql_mode=@@global.sql_mode;
set global sql_mode='traditional';
install soname 'ha_spider';
set global sql_mode=@old_sql_mode;

View File

@@ -0,0 +1,25 @@
#
# MDEV-33679 spider returns parsing failure on valid left join select by translating the on expression to ()
#
for master_1
for child2
for child3
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE `t1` (`c` INT(10) UNSIGNED NOT NULL, `b` VARCHAR(255) NOT NULL , PRIMARY KEY (`c`) USING BTREE ) ENGINE=MYISAM;
CREATE TABLE `t2` (`a` INT(10) UNSIGNED NOT NULL, `c` INT(10) UNSIGNED NOT NULL ) ENGINE=MYISAM;
SET spider_same_server_link= on;
CREATE TABLE `t1_spider` (`c` INT(10) UNSIGNED NOT NULL, `b` VARCHAR(255) NOT NULL , PRIMARY KEY (`c`) USING BTREE ) COMMENT='wrapper "mysql",srv "srv", table "t1"' ENGINE=SPIDER;
CREATE TABLE `t2_spider` (`a` INT(10) UNSIGNED NOT NULL, `c` INT(10) UNSIGNED NOT NULL
, PRIMARY KEY (`a`) USING BTREE
) COMMENT='wrapper "mysql",srv "srv",table "t2"' ENGINE=SPIDER;
INSERT INTO t1_spider VALUES(1,'oooo');
INSERT INTO t2_spider VALUES(1,1);
SELECT t2_spider.a,t1_spider.c FRoM t2_spider LEFT join t1_spider ON (t2_spider.c = t1_spider.c) WHERE t2_spider.a = 1;
a c
1 1
drop table t1, t2, t1_spider, t2_spider;
drop server srv;
for master_1
for child2
for child3

View File

@@ -0,0 +1,10 @@
for master_1
for child2
for child3
CREATE TABLE t (a INT) ENGINE=Spider PARTITION BY LIST (a) PARTITIONS 2 (PARTITION p1 VALUES IN (0,1),PARTITION p2 VALUES IN (2,3));
DELETE FROM t PARTITION (p2);
ERROR HY000: Unable to connect to foreign data source: localhost
drop table t;
for master_1
for child2
for child3

View File

@@ -10,6 +10,9 @@
# 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;
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');
@@ -153,6 +156,7 @@ select max(d) from t1;
drop table t1, t2;
drop server srv;
set global spider_same_server_link=@old_spider_same_server_link;
--disable_query_log
--disable_result_log

View File

@@ -0,0 +1,11 @@
# This test tests spider init with global no_zero_date sql mode
set @old_sql_mode=@@global.sql_mode;
set global sql_mode='traditional';
install soname 'ha_spider';
set global sql_mode=@old_sql_mode;
--disable_query_log
--disable_result_log
--source ../../include/clean_up_spider.inc
--enable_result_log
--enable_query_log

View File

@@ -0,0 +1,29 @@
--echo #
--echo # MDEV-33679 spider returns parsing failure on valid left join select by translating the on expression to ()
--echo #
--disable_query_log
--disable_result_log
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE `t1` (`c` INT(10) UNSIGNED NOT NULL, `b` VARCHAR(255) NOT NULL , PRIMARY KEY (`c`) USING BTREE ) ENGINE=MYISAM;
CREATE TABLE `t2` (`a` INT(10) UNSIGNED NOT NULL, `c` INT(10) UNSIGNED NOT NULL ) ENGINE=MYISAM;
SET spider_same_server_link= on;
CREATE TABLE `t1_spider` (`c` INT(10) UNSIGNED NOT NULL, `b` VARCHAR(255) NOT NULL , PRIMARY KEY (`c`) USING BTREE ) COMMENT='wrapper "mysql",srv "srv", table "t1"' ENGINE=SPIDER;
CREATE TABLE `t2_spider` (`a` INT(10) UNSIGNED NOT NULL, `c` INT(10) UNSIGNED NOT NULL
, PRIMARY KEY (`a`) USING BTREE
) COMMENT='wrapper "mysql",srv "srv",table "t2"' ENGINE=SPIDER;
INSERT INTO t1_spider VALUES(1,'oooo');
INSERT INTO t2_spider VALUES(1,1);
SELECT t2_spider.a,t1_spider.c FRoM t2_spider LEFT join t1_spider ON (t2_spider.c = t1_spider.c) WHERE t2_spider.a = 1;
drop table t1, t2, t1_spider, t2_spider;
drop server srv;
--disable_query_log
--disable_result_log
--source ../../t/test_deinit.inc
--enable_result_log
--enable_query_log

View File

@@ -0,0 +1,16 @@
--disable_query_log
--disable_result_log
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
CREATE TABLE t (a INT) ENGINE=Spider PARTITION BY LIST (a) PARTITIONS 2 (PARTITION p1 VALUES IN (0,1),PARTITION p2 VALUES IN (2,3));
--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE
DELETE FROM t PARTITION (p2);
drop table t;
--disable_query_log
--disable_result_log
--source ../../t/test_deinit.inc
--enable_result_log
--enable_query_log

View File

@@ -0,0 +1,57 @@
#
# MDEV-28993 Spider: Push down CASE statement
#
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 int);
create table t1 (c int) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
insert into t1 values (42), (3), (848), (100);
explain select case c when 3 then "three" when 42 then "answer" else "other" end from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY
select case c when 3 then "three" when 42 then "answer" else "other" end from t1;
case c when 3 then "three" when 42 then "answer" else "other" end
answer
three
other
other
explain select case c when 3 then "three" when 42 then "answer" end from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY
select case c when 3 then "three" when 42 then "answer" end from t1;
case c when 3 then "three" when 42 then "answer" end
answer
three
NULL
NULL
explain select case when c = 3 then "three" when c = 42 then "answer" else "other" end from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY
select case when c = 3 then "three" when c = 42 then "answer" else "other" end from t1;
case when c = 3 then "three" when c = 42 then "answer" else "other" end
answer
three
other
other
explain select case when c = 3 then "three" when c = 42 then "answer" end from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY
select case when c = 3 then "three" when c = 42 then "answer" end from t1;
case when c = 3 then "three" when c = 42 then "answer" end
answer
three
NULL
NULL
drop table t1, t2;
drop server srv;
for master_1
for child2
for child3
#
# end of test pushdown_case
#

View File

@@ -0,0 +1,111 @@
#
# MDEV-28992 Spider: Push down TIMESTAMPDIFF function
#
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 (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
);
CREATE TABLE t1 (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
INSERT INTO t1 (a, b, c) VALUES
(1, 'a', '2018-11-01 10:21:39'),
(2, 'b', '2015-06-30 23:59:59'),
(3, 'c', '2013-11-01 01:01:01');
interval year
explain select a, b, timestampdiff(year, '2000-01-01 00:00:00', c) from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY
select a, b, timestampdiff(year, '2000-01-01 00:00:00', c) from t1;
a b timestampdiff(year, '2000-01-01 00:00:00', c)
1 a 18
2 b 15
3 c 13
interval quarter
explain select a, b, timestampdiff(quarter, '2000-01-01 00:00:00', c) from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY
select a, b, timestampdiff(quarter, '2000-01-01 00:00:00', c) from t1;
a b timestampdiff(quarter, '2000-01-01 00:00:00', c)
1 a 75
2 b 61
3 c 55
interval month
explain select a, b, timestampdiff(month, '2000-01-01 00:00:00', c) from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY
select a, b, timestampdiff(month, '2000-01-01 00:00:00', c) from t1;
a b timestampdiff(month, '2000-01-01 00:00:00', c)
1 a 226
2 b 185
3 c 166
interval week
explain select a, b, timestampdiff(week, '2000-01-01 00:00:00', c) from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY
select a, b, timestampdiff(week, '2000-01-01 00:00:00', c) from t1;
a b timestampdiff(week, '2000-01-01 00:00:00', c)
1 a 982
2 b 808
3 c 721
interval day
explain select a, b, timestampdiff(day, '2000-01-01 00:00:00', c) from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY
select a, b, timestampdiff(day, '2000-01-01 00:00:00', c) from t1;
a b timestampdiff(day, '2000-01-01 00:00:00', c)
1 a 6879
2 b 5659
3 c 5053
internal hour
explain select a, b, timestampdiff(hour, '2000-01-01 00:00:00', c) from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY
select a, b, timestampdiff(hour, '2000-01-01 00:00:00', c) from t1;
a b timestampdiff(hour, '2000-01-01 00:00:00', c)
1 a 165106
2 b 135839
3 c 121273
internal minute
explain select a, b, timestampdiff(minute, '2000-01-01 00:00:00', c) from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY
select a, b, timestampdiff(minute, '2000-01-01 00:00:00', c) from t1;
a b timestampdiff(minute, '2000-01-01 00:00:00', c)
1 a 9906381
2 b 8150399
3 c 7276381
internal second
explain select a, b, timestampdiff(second, '2000-01-01 00:00:00', c) from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY
select a, b, timestampdiff(second, '2000-01-01 00:00:00', c) from t1;
a b timestampdiff(second, '2000-01-01 00:00:00', c)
1 a 594382899
2 b 489023999
3 c 436582861
internal microsecond
explain select a, b, timestampdiff(microsecond, '2000-01-01 00:00:00', c) from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY
select a, b, timestampdiff(microsecond, '2000-01-01 00:00:00', c) from t1;
a b timestampdiff(microsecond, '2000-01-01 00:00:00', c)
1 a 594382899000000
2 b 489023999000000
3 c 436582861000000
drop table t1, t2;
drop server srv;
for master_1
for child2
for child3

View File

@@ -0,0 +1,50 @@
--echo #
--echo # MDEV-28993 Spider: Push down CASE statement
--echo #
--disable_query_log
--disable_result_log
--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 t2 (c int);
create table t1 (c int) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
insert into t1 values (42), (3), (848), (100);
# everything
let $query=
select case c when 3 then "three" when 42 then "answer" else "other" end from t1;
eval explain $query;
eval $query;
# no else
let $query=
select case c when 3 then "three" when 42 then "answer" end from t1;
eval explain $query;
eval $query;
# no value
let $query=
select case when c = 3 then "three" when c = 42 then "answer" else "other" end from t1;
eval explain $query;
eval $query;
# neither
let $query=
select case when c = 3 then "three" when c = 42 then "answer" end from t1;
eval explain $query;
eval $query;
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 pushdown_case
--echo #

View File

@@ -0,0 +1,93 @@
--echo #
--echo # MDEV-28992 Spider: Push down TIMESTAMPDIFF function
--echo #
--disable_query_log
--disable_result_log
--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 t2 (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
);
CREATE TABLE t1 (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
INSERT INTO t1 (a, b, c) VALUES
(1, 'a', '2018-11-01 10:21:39'),
(2, 'b', '2015-06-30 23:59:59'),
(3, 'c', '2013-11-01 01:01:01');
--echo interval year
let $query=
select a, b, timestampdiff(year, '2000-01-01 00:00:00', c) from t1;
eval explain $query;
eval $query;
--echo interval quarter
let $query=
select a, b, timestampdiff(quarter, '2000-01-01 00:00:00', c) from t1;
eval explain $query;
eval $query;
--echo interval month
let $query=
select a, b, timestampdiff(month, '2000-01-01 00:00:00', c) from t1;
eval explain $query;
eval $query;
--echo interval week
let $query=
select a, b, timestampdiff(week, '2000-01-01 00:00:00', c) from t1;
eval explain $query;
eval $query;
--echo interval day
let $query=
select a, b, timestampdiff(day, '2000-01-01 00:00:00', c) from t1;
eval explain $query;
eval $query;
--echo internal hour
let $query=
select a, b, timestampdiff(hour, '2000-01-01 00:00:00', c) from t1;
eval explain $query;
eval $query;
--echo internal minute
let $query=
select a, b, timestampdiff(minute, '2000-01-01 00:00:00', c) from t1;
eval explain $query;
eval $query;
--echo internal second
let $query=
select a, b, timestampdiff(second, '2000-01-01 00:00:00', c) from t1;
eval explain $query;
eval $query;
--echo internal microsecond
let $query=
select a, b, timestampdiff(microsecond, '2000-01-01 00:00:00', c) from t1;
eval explain $query;
eval $query;
drop table t1, t2;
drop server srv;
--disable_query_log
--disable_result_log
--source ../../t/test_deinit.inc
--enable_result_log
--enable_query_log

View File

@@ -3,7 +3,6 @@ DROP FUNCTION spider_copy_tables;
DROP FUNCTION spider_ping_table;
DROP FUNCTION spider_bg_direct_sql;
DROP FUNCTION spider_direct_sql;
--replace_regex /\.dll/.so/
UNINSTALL SONAME IF EXISTS 'ha_spider';
DROP TABLE IF EXISTS mysql.spider_xa;
DROP TABLE IF EXISTS mysql.spider_xa_member;

View File

@@ -86,10 +86,8 @@ SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argum
argument
select `value` from `auto_test_remote2`.`tbl_a` where `value` = 5
select `value2` from `auto_test_remote2`.`tbl_b` where `value2` = 5
select sum('5') `sum(a.value)`,count('5') `count(b.value2)` from (select 1) t0 join (select 1) t1
select `value` from `auto_test_remote2`.`tbl_a` where `value` = 5
select `value2` from `auto_test_remote2`.`tbl_b` where `value2` = 5
select sum('5') `sum(a.value)`,count('5') `count(b.value2)` from (select 1) t0 join (select 1) t1
SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'
SELECT value FROM tbl_a ORDER BY value;
value