diff options
Diffstat (limited to 'mysql-test/main')
566 files changed, 28322 insertions, 4847 deletions
diff --git a/mysql-test/main/alter_events.result b/mysql-test/main/alter_events.result new file mode 100644 index 00000000000..b3bd8d26fe6 --- /dev/null +++ b/mysql-test/main/alter_events.result @@ -0,0 +1,14 @@ +SET GLOBAL event_scheduler=1; +CREATE TABLE t1 (a int primary key, b int) engine=innodb; +insert into t1 values (1,1),(2,2),(3,3); +CREATE TABLE t2 (a int primary key) engine=innodb; +CREATE EVENT e_t1 ON SCHEDULE EVERY 1 SECOND DO insert ignore into test.t2 select a from test.t1; +select * from t2; +a +1 +2 +3 +drop event e_t1; +ALTER TABLE mysql.event DROP PRIMARY KEY, ADD PRIMARY KEY(db,name); +drop table t1,t2; +SET GLOBAL event_scheduler=default; diff --git a/mysql-test/main/alter_events.test b/mysql-test/main/alter_events.test new file mode 100644 index 00000000000..309a0ce06ce --- /dev/null +++ b/mysql-test/main/alter_events.test @@ -0,0 +1,31 @@ +--source include/not_embedded.inc +--source include/have_innodb.inc +#--source include/have_metadata_lock_info.inc + +# +# Testing of problems with ALTER TABLE and events on the same table(s) +# + +# +# MDEV-24452 ALTER TABLE event take infinite time which for example breaks +# mysql_upgrade +# + +SET GLOBAL event_scheduler=1; + +CREATE TABLE t1 (a int primary key, b int) engine=innodb; +insert into t1 values (1,1),(2,2),(3,3); +CREATE TABLE t2 (a int primary key) engine=innodb; + +CREATE EVENT e_t1 ON SCHEDULE EVERY 1 SECOND DO insert ignore into test.t2 select a from test.t1; + +let $wait_condition=SELECT count(*) > 0 from t2; +--source include/wait_condition.inc +select * from t2; +drop event e_t1; + +# select * from information_schema.metadata_lock_info; +ALTER TABLE mysql.event DROP PRIMARY KEY, ADD PRIMARY KEY(db,name); +drop table t1,t2; + +SET GLOBAL event_scheduler=default; diff --git a/mysql-test/main/alter_table,aria.rdiff b/mysql-test/main/alter_table,aria.rdiff new file mode 100644 index 00000000000..40bbf95494c --- /dev/null +++ b/mysql-test/main/alter_table,aria.rdiff @@ -0,0 +1,22 @@ +--- ./mysql-test/main/alter_table.result 2020-02-27 19:35:41.279992329 +0300 ++++ ./mysql-test/main/alter_table,aria.reject 2020-02-27 19:37:13.251994491 +0300 +@@ -2716,8 +2716,7 @@ + t3 CREATE TABLE `t3` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, +- KEY `b` (`b`), +- CONSTRAINT `t3_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`bb`) ++ KEY `b` (`b`) + ) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 + ALTER TABLE t1 RENAME COLUMN bb TO b; + SHOW CREATE TABLE t1; +@@ -2733,8 +2732,7 @@ + t3 CREATE TABLE `t3` ( + `a` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, +- KEY `b` (`c`), +- CONSTRAINT `t3_ibfk_1` FOREIGN KEY (`c`) REFERENCES `t1` (`b`) ++ KEY `b` (`c`) + ) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 + CREATE TABLE t4(a int); + ALTER TABLE t4 RENAME COLUMN a TO aa, ALGORITHM = INPLACE; diff --git a/mysql-test/main/alter_table,heap.rdiff b/mysql-test/main/alter_table,heap.rdiff new file mode 100644 index 00000000000..ad6fd194cc9 --- /dev/null +++ b/mysql-test/main/alter_table,heap.rdiff @@ -0,0 +1,59 @@ +--- ./mysql-test/main/alter_table.result 2020-02-27 19:35:41.279992329 +0300 ++++ ./mysql-test/main/alter_table,heap.reject 2020-02-27 19:39:44.175998039 +0300 +@@ -2716,8 +2716,7 @@ + t3 CREATE TABLE `t3` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, +- KEY `b` (`b`), +- CONSTRAINT `t3_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`bb`) ++ KEY `b` (`b`) + ) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 + ALTER TABLE t1 RENAME COLUMN bb TO b; + SHOW CREATE TABLE t1; +@@ -2733,8 +2732,7 @@ + t3 CREATE TABLE `t3` ( + `a` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, +- KEY `b` (`c`), +- CONSTRAINT `t3_ibfk_1` FOREIGN KEY (`c`) REFERENCES `t1` (`b`) ++ KEY `b` (`c`) + ) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 + CREATE TABLE t4(a int); + ALTER TABLE t4 RENAME COLUMN a TO aa, ALGORITHM = INPLACE; +@@ -2774,36 +2772,6 @@ + ERROR 42S22: Unknown column 'd' in 'field list' + DROP TRIGGER trg1; + DROP PROCEDURE sp1; +-CREATE TABLE t_gen(a INT, b DOUBLE GENERATED ALWAYS AS (SQRT(a))); +-INSERT INTO t_gen(a) VALUES(4); +-SELECT * FROM t_gen; +-a b +-4 2 +-SHOW CREATE TABLE t_gen; +-Table Create Table +-t_gen CREATE TABLE `t_gen` ( +- `a` int(11) DEFAULT NULL, +- `b` double GENERATED ALWAYS AS (sqrt(`a`)) VIRTUAL +-) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 +-ALTER TABLE t_gen RENAME COLUMN a TO c, CHANGE COLUMN b b DOUBLE GENERATED ALWAYS AS (SQRT(c)); +-SELECT * FROM t_gen; +-c b +-4 2 +-SHOW CREATE TABLE t_gen; +-Table Create Table +-t_gen CREATE TABLE `t_gen` ( +- `c` int(11) DEFAULT NULL, +- `b` double GENERATED ALWAYS AS (sqrt(`c`)) VIRTUAL +-) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 +-ALTER TABLE t_gen CHANGE COLUMN c x INT; +-show create table t_gen; +-Table Create Table +-t_gen CREATE TABLE `t_gen` ( +- `x` int(11) DEFAULT NULL, +- `b` double GENERATED ALWAYS AS (sqrt(`x`)) VIRTUAL +-) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 +-ALTER TABLE t_gen RENAME COLUMN x TO a; +-DROP TABLE t_gen; + SHOW CREATE TABLE t1; + Table Create Table + t1 CREATE TABLE `t1` ( diff --git a/mysql-test/main/alter_table.combinations b/mysql-test/main/alter_table.combinations new file mode 100644 index 00000000000..824e0a3be04 --- /dev/null +++ b/mysql-test/main/alter_table.combinations @@ -0,0 +1,5 @@ +[innodb] + +[aria] + +[heap] diff --git a/mysql-test/main/alter_table.result b/mysql-test/main/alter_table.result index 3c59b83f2ce..a43d9845947 100644 --- a/mysql-test/main/alter_table.result +++ b/mysql-test/main/alter_table.result @@ -272,8 +272,7 @@ ERROR 42000: Incorrect table name '' drop table t1; drop table if exists t1, t2; Warnings: -Note 1051 Unknown table 'test.t1' -Note 1051 Unknown table 'test.t2' +Note 1051 Unknown table 'test.t1,test.t2' create table t1 ( a varchar(10) not null primary key ) engine=myisam; create table t2 ( a varchar(10) not null primary key ) engine=merge union=(t1); flush tables; @@ -1679,6 +1678,8 @@ ALTER TABLE t1 DROP INDEX i1, DROP INDEX i2, DROP INDEX i3, DROP INDEX i4; # SET SESSION old_alter_table= 1; affected rows: 0 +Warnings: +Warning 1287 '@@old_alter_table' is deprecated and will be removed in a future release. Please use '@@alter_algorithm' instead ALTER TABLE t1 ADD INDEX i1(b); affected rows: 2 info: Records: 2 Duplicates: 0 Warnings: 0 @@ -1699,6 +1700,8 @@ Warnings: Note 1831 Duplicate index `i4`. This is deprecated and will be disallowed in a future release SET SESSION old_alter_table= 0; affected rows: 0 +Warnings: +Warning 1287 '@@old_alter_table' is deprecated and will be removed in a future release. Please use '@@alter_algorithm' instead ALTER TABLE t1 DROP INDEX i1, DROP INDEX i2, DROP INDEX i3, DROP INDEX i4; # # 3: Test unsupported in-place operation @@ -2627,3 +2630,748 @@ insert into t1 (id,name,enabled,domain_id) values (1,"Monty",1,"domain_id"); insert into t1 (id,name,enabled,domain_id) values (2,"Monty2",1,"domain_id2"); ALTER TABLE t1 ADD CONSTRAINT ixu_user2_name_domain_id UNIQUE (domain_id, name); DROP TABLE t1; +# +# End of 10.4 tests +# +# +# MDEV-16290 ALTER TABLE ... RENAME COLUMN syntax +# +SET @save_default_engine= @@DEFAULT_STORAGE_ENGINE; +CREATE TABLE t1(a INT, b VARCHAR(30), c FLOAT); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(30) DEFAULT NULL, + `c` float DEFAULT NULL +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES(1,'abcd',1.234); +CREATE TABLE t2(a INT, b VARCHAR(30), c FLOAT) ENGINE=MyIsam; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `b` varchar(30) DEFAULT NULL, + `c` float DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +INSERT INTO t2 VALUES(1,'abcd',1.234); +ALTER TABLE t1 RENAME COLUMN a TO a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(30) DEFAULT NULL, + `c` float DEFAULT NULL +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 +ALTER TABLE t1 RENAME COLUMN a TO m; +ALTER TABLE t1 RENAME COLUMN a TO m; +ERROR 42S22: Unknown column 'a' in 't1' +ALTER TABLE t1 RENAME COLUMN IF EXISTS a TO m; +Warnings: +Note 1054 Unknown column 'a' in 't1' +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `m` int(11) DEFAULT NULL, + `b` varchar(30) DEFAULT NULL, + `c` float DEFAULT NULL +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 +SELECT * FROM t1; +m b c +1 abcd 1.234 +ALTER TABLE t1 RENAME COLUMN m TO x, +RENAME COLUMN b TO y, +RENAME COLUMN c TO z; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `x` int(11) DEFAULT NULL, + `y` varchar(30) DEFAULT NULL, + `z` float DEFAULT NULL +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 +SELECT * FROM t1; +x y z +1 abcd 1.234 +ALTER TABLE t2 RENAME COLUMN a TO d, RENAME COLUMN b TO e, RENAME COLUMN c to f; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `d` int(11) DEFAULT NULL, + `e` varchar(30) DEFAULT NULL, + `f` float DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT * FROM t2; +d e f +1 abcd 1.234 +ALTER TABLE t1 CHANGE COLUMN x a INT, RENAME COLUMN y TO b; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(30) DEFAULT NULL, + `z` float DEFAULT NULL +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 +ALTER TABLE t1 CHANGE COLUMN z c DOUBLE, RENAME COLUMN b to b; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(30) DEFAULT NULL, + `c` double DEFAULT NULL +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 +ALTER TABLE t1 CHANGE COLUMN a b int, RENAME COLUMN b TO c, CHANGE COLUMN c d FLOAT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `b` int(11) DEFAULT NULL, + `c` varchar(30) DEFAULT NULL, + `d` float DEFAULT NULL +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 +ALTER TABLE t1 ADD COLUMN zz INT, RENAME COLUMN d TO f; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `b` int(11) DEFAULT NULL, + `c` varchar(30) DEFAULT NULL, + `f` float DEFAULT NULL, + `zz` int(11) DEFAULT NULL +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 +ALTER TABLE t1 DROP COLUMN zz, RENAME COLUMN c TO zz; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `b` int(11) DEFAULT NULL, + `zz` varchar(30) DEFAULT NULL, + `f` float DEFAULT NULL +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 +ALTER TABLE t1 RENAME COLUMN zz to c, DROP COLUMN f; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `b` int(11) DEFAULT NULL, + `c` varchar(30) DEFAULT NULL +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 +ALTER TABLE t1 ADD COLUMN d INT DEFAULT 5, RENAME COLUMN c TO b, DROP COLUMN b; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `b` varchar(30) DEFAULT NULL, + `d` int(11) DEFAULT 5 +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 +ALTER TABLE t1 RENAME COLUMN b TO d, RENAME COLUMN d TO b; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `d` varchar(30) DEFAULT NULL, + `b` int(11) DEFAULT 5 +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 +ALTER TABLE t1 ADD KEY(b); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `d` varchar(30) DEFAULT NULL, + `b` int(11) DEFAULT 5, + KEY `b` (`b`) +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 +ALTER TABLE t1 RENAME COLUMN b TO bb; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `d` varchar(30) DEFAULT NULL, + `bb` int(11) DEFAULT 5, + KEY `b` (`bb`) +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 +SELECT * FROM t1; +d bb +abcd 5 +CREATE TABLE t3(a int, b int, KEY(b)); +ALTER TABLE t3 ADD CONSTRAINT FOREIGN KEY(b) REFERENCES t1(bb); +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `b` (`b`), + CONSTRAINT `t3_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`bb`) +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 +ALTER TABLE t1 RENAME COLUMN bb TO b; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `d` varchar(30) DEFAULT NULL, + `b` int(11) DEFAULT 5, + KEY `b` (`b`) +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 +ALTER TABLE t3 RENAME COLUMN b TO c; +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `a` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `b` (`c`), + CONSTRAINT `t3_ibfk_1` FOREIGN KEY (`c`) REFERENCES `t1` (`b`) +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 +CREATE TABLE t4(a int); +ALTER TABLE t4 RENAME COLUMN a TO aa, ALGORITHM = INPLACE; +SHOW CREATE TABLE t4; +Table Create Table +t4 CREATE TABLE `t4` ( + `aa` int(11) DEFAULT NULL +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 +ALTER TABLE t4 RENAME COLUMN aa TO a, ALGORITHM = COPY; +SHOW CREATE TABLE t4; +Table Create Table +t4 CREATE TABLE `t4` ( + `a` int(11) DEFAULT NULL +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 +DROP TABLE t4; +CREATE VIEW v1 AS SELECT d,e,f FROM t2; +CREATE TRIGGER trg1 BEFORE UPDATE on t2 FOR EACH ROW SET NEW.d=OLD.d + 10; +CREATE PROCEDURE sp1() INSERT INTO t2(d) VALUES(10); +ALTER TABLE t2 RENAME COLUMN d TO g; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `g` int(11) DEFAULT NULL, + `e` varchar(30) DEFAULT NULL, + `f` float DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`t2`.`d` AS `d`,`test`.`t2`.`e` AS `e`,`test`.`t2`.`f` AS `f` from `t2` koi8r koi8r_general_ci +Warnings: +Warning 1356 View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM v1; +ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE t2 SET f = f + 10; +ERROR 42S22: Unknown column 'd' in 'OLD' +CALL sp1(); +ERROR 42S22: Unknown column 'd' in 'field list' +DROP TRIGGER trg1; +DROP PROCEDURE sp1; +CREATE TABLE t_gen(a INT, b DOUBLE GENERATED ALWAYS AS (SQRT(a))); +INSERT INTO t_gen(a) VALUES(4); +SELECT * FROM t_gen; +a b +4 2 +SHOW CREATE TABLE t_gen; +Table Create Table +t_gen CREATE TABLE `t_gen` ( + `a` int(11) DEFAULT NULL, + `b` double GENERATED ALWAYS AS (sqrt(`a`)) VIRTUAL +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 +ALTER TABLE t_gen RENAME COLUMN a TO c, CHANGE COLUMN b b DOUBLE GENERATED ALWAYS AS (SQRT(c)); +SELECT * FROM t_gen; +c b +4 2 +SHOW CREATE TABLE t_gen; +Table Create Table +t_gen CREATE TABLE `t_gen` ( + `c` int(11) DEFAULT NULL, + `b` double GENERATED ALWAYS AS (sqrt(`c`)) VIRTUAL +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 +ALTER TABLE t_gen CHANGE COLUMN c x INT; +show create table t_gen; +Table Create Table +t_gen CREATE TABLE `t_gen` ( + `x` int(11) DEFAULT NULL, + `b` double GENERATED ALWAYS AS (sqrt(`x`)) VIRTUAL +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 +ALTER TABLE t_gen RENAME COLUMN x TO a; +DROP TABLE t_gen; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `d` varchar(30) DEFAULT NULL, + `b` int(11) DEFAULT 5, + KEY `b` (`b`) +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 +ALTER TABLE t1 RENAME COLUMN b z; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'z' at line 1 +ALTER TABLE t1 RENAME COLUMN FROM b TO z; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'FROM b TO z' at line 1 +ALTER TABLE t1 RENAME COLUMN b TO 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '1' at line 1 +ALTER TABLE t1 RENAME COLUMN b TO e, RENAME COLUMN c TO e; +ERROR 42S22: Unknown column 'c' in 't1' +ALTER TABLE t1 ADD COLUMN z INT, RENAME COLUMN b TO z; +ERROR 42S21: Duplicate column name 'z' +ALTER TABLE t1 DROP COLUMN b, RENAME COLUMN b TO z; +ERROR 42S22: Unknown column 'b' in 't1' +ALTER TABLE t1 RENAME COLUMN b TO b, RENAME COLUMN b TO b; +ERROR 42S22: Unknown column 'b' in 't1' +ALTER TABLE t1 RENAME COLUMN b TO c3, DROP COLUMN c3; +ERROR 42000: Can't DROP COLUMN `c3`; check that it exists +ALTER TABLE t1 ADD COLUMN z INT, CHANGE COLUMN z y INT, DROP COLUMN y; +ERROR 42S22: Unknown column 'z' in 't1' +ALTER TABLE t1 ADD COLUMN z INT, RENAME COLUMN z TO y, DROP COLUMN y; +ERROR 42S22: Unknown column 'z' in 't1' +ALTER TABLE t1 RENAME COLUMN b TO `nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn`; +ERROR 42000: Incorrect column name 'nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn' +ALTER TABLE t1 CHANGE b `nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn` int; +ERROR 42000: Identifier name 'nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn' is too long +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `d` varchar(30) DEFAULT NULL, + `b` int(11) DEFAULT 5, + KEY `b` (`b`) +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 +SELECT * FROM t1; +d b +abcd 5 +DROP VIEW v1; +DROP TABLE t3,t1,t2; +SET DEFAULT_STORAGE_ENGINE= @save_default_engine; +# +# MDEV-7318 RENAME INDEX +# +# +# 1) Tests for syntax and semantics of ALTER TABLE RENAME +# KEY/INDEX result. +# +# 1.a) Both RENAME KEY and RENAME INDEX variants should be +# allowed and produce expected results. +create table t1 (pk int primary key, i int, j int, key a(i)); +alter table t1 rename key a to b; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk` int(11) NOT NULL, + `i` int(11) DEFAULT NULL, + `j` int(11) DEFAULT NULL, + PRIMARY KEY (`pk`), + KEY `b` (`i`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +alter table t1 rename index b to c; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk` int(11) NOT NULL, + `i` int(11) DEFAULT NULL, + `j` int(11) DEFAULT NULL, + PRIMARY KEY (`pk`), + KEY `c` (`i`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +# 1.b) It should be impossible to rename index that doesn't +# exists, dropped or added within the same ALTER TABLE. +alter table t1 rename key d to e; +ERROR 42000: Key 'd' doesn't exist in table 't1' +alter table t1 rename key if exists d to e; +Warnings: +Note 1176 Key 'd' doesn't exist in table 't1' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk` int(11) NOT NULL, + `i` int(11) DEFAULT NULL, + `j` int(11) DEFAULT NULL, + PRIMARY KEY (`pk`), + KEY `c` (`i`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +alter table t1 drop key c, rename key c to d; +ERROR 42000: Key 'c' doesn't exist in table 't1' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk` int(11) NOT NULL, + `i` int(11) DEFAULT NULL, + `j` int(11) DEFAULT NULL, + PRIMARY KEY (`pk`), + KEY `c` (`i`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +alter table t1 add key d(j), rename key d to e; +ERROR 42000: Key 'd' doesn't exist in table 't1' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk` int(11) NOT NULL, + `i` int(11) DEFAULT NULL, + `j` int(11) DEFAULT NULL, + PRIMARY KEY (`pk`), + KEY `c` (`i`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +# 1.c) It should be impossible to rename index to a name +# which is already used by another index, or is used +# by index which is added within the same ALTER TABLE. +alter table t1 add key d(j); +alter table t1 rename key c to d; +ERROR 42000: Duplicate key name 'd' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk` int(11) NOT NULL, + `i` int(11) DEFAULT NULL, + `j` int(11) DEFAULT NULL, + PRIMARY KEY (`pk`), + KEY `c` (`i`), + KEY `d` (`j`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +alter table t1 drop key d; +alter table t1 add key d(j), rename key c to d; +ERROR 42000: Duplicate key name 'd' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk` int(11) NOT NULL, + `i` int(11) DEFAULT NULL, + `j` int(11) DEFAULT NULL, + PRIMARY KEY (`pk`), + KEY `c` (`i`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +# 1.d) It should be possible to rename index to a name +# which belongs to index which is dropped within the +# same ALTER TABLE. +alter table t1 add key d(j); +alter table t1 drop key c, rename key d to c; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk` int(11) NOT NULL, + `i` int(11) DEFAULT NULL, + `j` int(11) DEFAULT NULL, + PRIMARY KEY (`pk`), + KEY `c` (`j`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +# 1.e) We disallow renaming from/to PRIMARY as it might +# lead to some other key becoming "primary" internally, +# which will be interpreted as dropping/addition of +# primary key. +alter table t1 rename key primary to d; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'primary to d' at line 1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk` int(11) NOT NULL, + `i` int(11) DEFAULT NULL, + `j` int(11) DEFAULT NULL, + PRIMARY KEY (`pk`), + KEY `c` (`j`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +# Even using 'funny' syntax. +alter table t1 rename key `primary` to d; +ERROR 42000: Incorrect index name 'primary' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk` int(11) NOT NULL, + `i` int(11) DEFAULT NULL, + `j` int(11) DEFAULT NULL, + PRIMARY KEY (`pk`), + KEY `c` (`j`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +alter table t1 rename key c to primary; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'primary' at line 1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk` int(11) NOT NULL, + `i` int(11) DEFAULT NULL, + `j` int(11) DEFAULT NULL, + PRIMARY KEY (`pk`), + KEY `c` (`j`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +alter table t1 rename key c to `primary`; +ERROR 42000: Incorrect index name 'primary' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk` int(11) NOT NULL, + `i` int(11) DEFAULT NULL, + `j` int(11) DEFAULT NULL, + PRIMARY KEY (`pk`), + KEY `c` (`j`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +# +# 2) More complex tests for semantics of ALTER TABLE. +# +# 2.a) Check that standalone RENAME KEY works as expected +# for unique and non-unique indexes. +create table t1 (a int, unique u(a), b int, key k(b)); +alter table t1 rename key u to uu; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + UNIQUE KEY `uu` (`a`), + KEY `k` (`b`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +alter table t1 rename key k to kk; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + UNIQUE KEY `uu` (`a`), + KEY `kk` (`b`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +# 2.b) Check how that this clause can be mixed with other +# clauses which don't affect key or its columns. +alter table t1 rename key kk to kkk, add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + UNIQUE KEY `uu` (`a`), + KEY `kkk` (`b`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +alter table t1 rename key uu to uuu, add key c(c); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + UNIQUE KEY `uuu` (`a`), + KEY `kkk` (`b`), + KEY `c` (`c`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +alter table t1 rename key kkk to k, drop key uuu; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `k` (`b`), + KEY `c` (`c`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +alter table t1 rename key k to kk, rename to t2; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `kk` (`b`), + KEY `c` (`c`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t2; +# +# 3) Test coverage for handling of RENAME INDEX clause in +# various storage engines and using different ALTER +# algorithm. +# +# 3.a) Test coverage for simple storage engines (MyISAM/Heap). +create table t1 (i int, key k(i)) engine=myisam; +insert into t1 values (1); +create table t2 (i int, key k(i)) engine=memory; +insert into t2 values (1); +# MyISAM and Heap should be able to handle key renaming in-place. +alter table t1 algorithm=inplace, rename key k to kk; +alter table t2 algorithm=inplace, rename key k to kk; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) DEFAULT NULL, + KEY `kk` (`i`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `i` int(11) DEFAULT NULL, + KEY `kk` (`i`) +) ENGINE=MEMORY DEFAULT CHARSET=latin1 +# So by default in-place algorithm should be chosen. +# (ALTER TABLE should report 0 rows affected). +alter table t1 rename key kk to kkk; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +alter table t2 rename key kk to kkk; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) DEFAULT NULL, + KEY `kkk` (`i`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `i` int(11) DEFAULT NULL, + KEY `kkk` (`i`) +) ENGINE=MEMORY DEFAULT CHARSET=latin1 +# Copy algorithm should work as well. +alter table t1 algorithm=copy, rename key kkk to kkkk; +alter table t2 algorithm=copy, rename key kkk to kkkk; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) DEFAULT NULL, + KEY `kkkk` (`i`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `i` int(11) DEFAULT NULL, + KEY `kkkk` (`i`) +) ENGINE=MEMORY DEFAULT CHARSET=latin1 +# When renaming is combined with other in-place operation +# it still works as expected (i.e. works in-place). +alter table t1 algorithm=inplace, rename key kkkk to k, alter column i set default 100; +alter table t2 algorithm=inplace, rename key kkkk to k, alter column i set default 100; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) DEFAULT 100, + KEY `k` (`i`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `i` int(11) DEFAULT 100, + KEY `k` (`i`) +) ENGINE=MEMORY DEFAULT CHARSET=latin1 +# Combining with non-inplace operation results in the whole ALTER +# becoming non-inplace. +alter table t1 algorithm=inplace, rename key k to kk, add column j int; +ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY +alter table t2 algorithm=inplace, rename key k to kk, add column j int; +ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY +drop table t1, t2; +# 3.b) Basic tests for InnoDB. More tests can be found in +# innodb.innodb_rename_index* +create table t1 (i int, key k(i)) engine=innodb; +insert into t1 values (1); +# Basic rename, inplace algorithm should be chosen +alter table t1 algorithm=inplace, rename key k to kk; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) DEFAULT NULL, + KEY `kk` (`i`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +# copy algorithm should work as well. +alter table t1 algorithm=copy, rename key kk to kkk; +affected rows: 1 +info: Records: 1 Duplicates: 0 Warnings: 0 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) DEFAULT NULL, + KEY `kkk` (`i`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +drop table t1; +# +# 4) Additional coverage for complex cases in which code +# in ALTER TABLE comparing old and new table version +# got confused. +# +# Once InnoDB starts to support in-place index renaming the result +# of below statements should stay the same. Information about +# indexes returned by SHOW CREATE TABLE (from .FRM) and by +# InnoDB (from InnoDB data-dictionary) should be consistent. +# +create table t1 ( a int, b int, c int, d int, +primary key (a), index i1 (b), index i2 (c) ) engine=innodb; +alter table t1 add index i1 (d), rename index i1 to x; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + `d` int(11) DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `x` (`b`), + KEY `i2` (`c`), + KEY `i1` (`d`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +select i.name as k, f.name as c from information_schema.innodb_sys_tables as t, +information_schema.innodb_sys_indexes as i, +information_schema.innodb_sys_fields as f +where t.name='test/t1' and t.table_id = i.table_id and i.index_id = f.index_id +order by k, c; +k c +i1 d +i2 c +PRIMARY a +x b +drop table t1; +create table t1 (a int, b int, c int, d int, +primary key (a), index i1 (b), index i2 (c)) engine=innodb; +alter table t1 add index i1 (d), rename index i1 to i2, drop index i2; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + `d` int(11) DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `i2` (`b`), + KEY `i1` (`d`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +select i.name as k, f.name as c from information_schema.innodb_sys_tables as t, +information_schema.innodb_sys_indexes as i, +information_schema.innodb_sys_fields as f +where t.name='test/t1' and t.table_id = i.table_id and i.index_id = f.index_id +order by k, c; +k c +i1 d +i2 b +PRIMARY a +drop table t1; +# +# ALTER TABLE IF EXISTS +# +create table t1 (a int); +alter table if exists t1 add column b int; +alter table if exists t2 add column c int; +Warnings: +Error 1146 Table 'test.t2' doesn't exist +alter table if exists t9 rename t1; +Warnings: +Error 1146 Table 'test.t9' doesn't exist +alter table if exists t1 rename t2; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t2; +# +# MDEV-22881 Unexpected errors, corrupt output, Valgrind / ASAN errors in Item_ident::print or append_identifier +# +create table t1 (a int check (a >= 0)); +lock tables t1 write; +alter table t1 rename column a to a; +alter table t1 rename key if exists x to xx; +Warnings: +Note 1176 Key 'x' doesn't exist in table 't1' +unlock tables; +drop table t1; +# +# MDEV-23852 alter table rename column to uppercase doesn't work +# +create table t1 (abc int); +alter table t1 rename column abc to Abc, algorithm=copy; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `Abc` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +alter table t1 rename column abc to ABc, algorithm=inplace; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `ABc` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +alter table t1 rename column abc to ABC; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `ABC` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/alter_table.test b/mysql-test/main/alter_table.test index fa931fcadbf..e65a4edf13e 100644 --- a/mysql-test/main/alter_table.test +++ b/mysql-test/main/alter_table.test @@ -2146,3 +2146,427 @@ insert into t1 (id,name,enabled,domain_id) values (1,"Monty",1,"domain_id"); insert into t1 (id,name,enabled,domain_id) values (2,"Monty2",1,"domain_id2"); ALTER TABLE t1 ADD CONSTRAINT ixu_user2_name_domain_id UNIQUE (domain_id, name); DROP TABLE t1; + +--echo # +--echo # End of 10.4 tests +--echo # + +--echo # +--echo # MDEV-16290 ALTER TABLE ... RENAME COLUMN syntax +--echo # +SET @save_default_engine= @@DEFAULT_STORAGE_ENGINE; +--disable_query_log +if ($MTR_COMBINATION_INNODB) +{ +SET DEFAULT_STORAGE_ENGINE= INNODB; +} +if ($MTR_COMBINATION_ARIA) +{ +SET DEFAULT_STORAGE_ENGINE= ARIA; +} +if ($MTR_COMBINATION_HEAP) +{ +SET DEFAULT_STORAGE_ENGINE= MEMORY; +} +--enable_query_log +let $default_engine= `select @@default_storage_engine`; + +CREATE TABLE t1(a INT, b VARCHAR(30), c FLOAT); +--replace_result $default_engine DEFAULT_ENGINE " PAGE_CHECKSUM=1" "" +SHOW CREATE TABLE t1; +INSERT INTO t1 VALUES(1,'abcd',1.234); +CREATE TABLE t2(a INT, b VARCHAR(30), c FLOAT) ENGINE=MyIsam; +SHOW CREATE TABLE t2; +INSERT INTO t2 VALUES(1,'abcd',1.234); + +# Rename one column +ALTER TABLE t1 RENAME COLUMN a TO a; +--replace_result $default_engine DEFAULT_ENGINE " PAGE_CHECKSUM=1" "" +SHOW CREATE TABLE t1; +ALTER TABLE t1 RENAME COLUMN a TO m; +--error ER_BAD_FIELD_ERROR +ALTER TABLE t1 RENAME COLUMN a TO m; +ALTER TABLE t1 RENAME COLUMN IF EXISTS a TO m; +--replace_result $default_engine DEFAULT_ENGINE " PAGE_CHECKSUM=1" "" +SHOW CREATE TABLE t1; +SELECT * FROM t1; + +# Rename multiple column +ALTER TABLE t1 RENAME COLUMN m TO x, + RENAME COLUMN b TO y, + RENAME COLUMN c TO z; +--replace_result $default_engine DEFAULT_ENGINE " PAGE_CHECKSUM=1" "" +SHOW CREATE TABLE t1; +SELECT * FROM t1; + +# Rename multiple columns with MyIsam Engine +ALTER TABLE t2 RENAME COLUMN a TO d, RENAME COLUMN b TO e, RENAME COLUMN c to f; +SHOW CREATE TABLE t2; +SELECT * FROM t2; + +# Mix different ALTER operations with RENAME COLUMN +ALTER TABLE t1 CHANGE COLUMN x a INT, RENAME COLUMN y TO b; +--replace_result $default_engine DEFAULT_ENGINE " PAGE_CHECKSUM=1" "" +SHOW CREATE TABLE t1; +ALTER TABLE t1 CHANGE COLUMN z c DOUBLE, RENAME COLUMN b to b; +--replace_result $default_engine DEFAULT_ENGINE " PAGE_CHECKSUM=1" "" +SHOW CREATE TABLE t1; +ALTER TABLE t1 CHANGE COLUMN a b int, RENAME COLUMN b TO c, CHANGE COLUMN c d FLOAT; +--replace_result $default_engine DEFAULT_ENGINE " PAGE_CHECKSUM=1" "" +SHOW CREATE TABLE t1; +ALTER TABLE t1 ADD COLUMN zz INT, RENAME COLUMN d TO f; +--replace_result $default_engine DEFAULT_ENGINE " PAGE_CHECKSUM=1" "" +SHOW CREATE TABLE t1; +ALTER TABLE t1 DROP COLUMN zz, RENAME COLUMN c TO zz; +--replace_result $default_engine DEFAULT_ENGINE " PAGE_CHECKSUM=1" "" +SHOW CREATE TABLE t1; +ALTER TABLE t1 RENAME COLUMN zz to c, DROP COLUMN f; +--replace_result $default_engine DEFAULT_ENGINE " PAGE_CHECKSUM=1" "" +SHOW CREATE TABLE t1; +ALTER TABLE t1 ADD COLUMN d INT DEFAULT 5, RENAME COLUMN c TO b, DROP COLUMN b; +--replace_result $default_engine DEFAULT_ENGINE " PAGE_CHECKSUM=1" "" +SHOW CREATE TABLE t1; + +#Cyclic Rename +ALTER TABLE t1 RENAME COLUMN b TO d, RENAME COLUMN d TO b; +--replace_result $default_engine DEFAULT_ENGINE " PAGE_CHECKSUM=1" "" +SHOW CREATE TABLE t1; + +# Rename with Indexes +ALTER TABLE t1 ADD KEY(b); +--replace_result $default_engine DEFAULT_ENGINE " PAGE_CHECKSUM=1" "" +SHOW CREATE TABLE t1; +ALTER TABLE t1 RENAME COLUMN b TO bb; +--replace_result $default_engine DEFAULT_ENGINE " PAGE_CHECKSUM=1" "" +SHOW CREATE TABLE t1; +SELECT * FROM t1; + +# Rename with Foreign keys. +CREATE TABLE t3(a int, b int, KEY(b)); +ALTER TABLE t3 ADD CONSTRAINT FOREIGN KEY(b) REFERENCES t1(bb); +--replace_result $default_engine DEFAULT_ENGINE " PAGE_CHECKSUM=1" "" +SHOW CREATE TABLE t3; +ALTER TABLE t1 RENAME COLUMN bb TO b; +--replace_result $default_engine DEFAULT_ENGINE " PAGE_CHECKSUM=1" "" +SHOW CREATE TABLE t1; +ALTER TABLE t3 RENAME COLUMN b TO c; +--replace_result $default_engine DEFAULT_ENGINE " PAGE_CHECKSUM=1" "" +SHOW CREATE TABLE t3; + +# Different Algorithm +CREATE TABLE t4(a int); +ALTER TABLE t4 RENAME COLUMN a TO aa, ALGORITHM = INPLACE; +--replace_result $default_engine DEFAULT_ENGINE " PAGE_CHECKSUM=1" "" +SHOW CREATE TABLE t4; +ALTER TABLE t4 RENAME COLUMN aa TO a, ALGORITHM = COPY; +--replace_result $default_engine DEFAULT_ENGINE " PAGE_CHECKSUM=1" "" +SHOW CREATE TABLE t4; +DROP TABLE t4; + +# View, Trigger and SP +CREATE VIEW v1 AS SELECT d,e,f FROM t2; +CREATE TRIGGER trg1 BEFORE UPDATE on t2 FOR EACH ROW SET NEW.d=OLD.d + 10; +CREATE PROCEDURE sp1() INSERT INTO t2(d) VALUES(10); +ALTER TABLE t2 RENAME COLUMN d TO g; +--replace_result $default_engine DEFAULT_ENGINE " PAGE_CHECKSUM=1" "" +SHOW CREATE TABLE t2; +SHOW CREATE VIEW v1; +--error ER_VIEW_INVALID +SELECT * FROM v1; +--error ER_BAD_FIELD_ERROR +UPDATE t2 SET f = f + 10; +--error ER_BAD_FIELD_ERROR +CALL sp1(); +DROP TRIGGER trg1; +DROP PROCEDURE sp1; + +# Generated Columns +if (!$MTR_COMBINATION_HEAP) +{ +CREATE TABLE t_gen(a INT, b DOUBLE GENERATED ALWAYS AS (SQRT(a))); +INSERT INTO t_gen(a) VALUES(4); +SELECT * FROM t_gen; +--replace_result $default_engine DEFAULT_ENGINE " PAGE_CHECKSUM=1" "" +SHOW CREATE TABLE t_gen; +ALTER TABLE t_gen RENAME COLUMN a TO c, CHANGE COLUMN b b DOUBLE GENERATED ALWAYS AS (SQRT(c)); +SELECT * FROM t_gen; +--replace_result $default_engine DEFAULT_ENGINE " PAGE_CHECKSUM=1" "" +SHOW CREATE TABLE t_gen; +#--error ER_DEPENDENT_BY_GENERATED_COLUMN +ALTER TABLE t_gen CHANGE COLUMN c x INT; +--replace_result $default_engine DEFAULT_ENGINE " PAGE_CHECKSUM=1" "" +show create table t_gen; +#--error ER_DEPENDENT_BY_GENERATED_COLUMN +ALTER TABLE t_gen RENAME COLUMN x TO a; +DROP TABLE t_gen; +} + + +# +# Negative tests +# +--replace_result $default_engine DEFAULT_ENGINE " PAGE_CHECKSUM=1" "" +SHOW CREATE TABLE t1; + +# Invalid Syntax +--error ER_PARSE_ERROR +ALTER TABLE t1 RENAME COLUMN b z; +--error ER_PARSE_ERROR +ALTER TABLE t1 RENAME COLUMN FROM b TO z; +--error ER_PARSE_ERROR +ALTER TABLE t1 RENAME COLUMN b TO 1; + +# Duplicate column name +--error ER_BAD_FIELD_ERROR +ALTER TABLE t1 RENAME COLUMN b TO e, RENAME COLUMN c TO e; +--error ER_DUP_FIELDNAME +ALTER TABLE t1 ADD COLUMN z INT, RENAME COLUMN b TO z; + +# Multiple operation on same column +--error ER_BAD_FIELD_ERROR +ALTER TABLE t1 DROP COLUMN b, RENAME COLUMN b TO z; +--error ER_BAD_FIELD_ERROR +ALTER TABLE t1 RENAME COLUMN b TO b, RENAME COLUMN b TO b; +--error ER_CANT_DROP_FIELD_OR_KEY +ALTER TABLE t1 RENAME COLUMN b TO c3, DROP COLUMN c3; +--error ER_BAD_FIELD_ERROR +ALTER TABLE t1 ADD COLUMN z INT, CHANGE COLUMN z y INT, DROP COLUMN y; +--error ER_BAD_FIELD_ERROR +ALTER TABLE t1 ADD COLUMN z INT, RENAME COLUMN z TO y, DROP COLUMN y; + +# Invalid column name while renaming +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1 RENAME COLUMN b TO `nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn`; +# This error is different compared to ALTER TABLE ... CHANGE command +--error ER_TOO_LONG_IDENT +ALTER TABLE t1 CHANGE b `nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn` int; + +--replace_result $default_engine DEFAULT_ENGINE " PAGE_CHECKSUM=1" "" +SHOW CREATE TABLE t1; +SELECT * FROM t1; + +# Cleanup +DROP VIEW v1; +DROP TABLE t3,t1,t2; +SET DEFAULT_STORAGE_ENGINE= @save_default_engine; + +--echo # +--echo # MDEV-7318 RENAME INDEX +--echo # + +--echo # +--echo # 1) Tests for syntax and semantics of ALTER TABLE RENAME +--echo # KEY/INDEX result. +--echo # +--echo # 1.a) Both RENAME KEY and RENAME INDEX variants should be +--echo # allowed and produce expected results. +create table t1 (pk int primary key, i int, j int, key a(i)); +alter table t1 rename key a to b; +show create table t1; +alter table t1 rename index b to c; +show create table t1; + +--echo # 1.b) It should be impossible to rename index that doesn't +--echo # exists, dropped or added within the same ALTER TABLE. +--error ER_KEY_DOES_NOT_EXISTS +alter table t1 rename key d to e; +alter table t1 rename key if exists d to e; +show create table t1; +--error ER_KEY_DOES_NOT_EXISTS +alter table t1 drop key c, rename key c to d; +show create table t1; +--error ER_KEY_DOES_NOT_EXISTS +alter table t1 add key d(j), rename key d to e; +show create table t1; + +--echo # 1.c) It should be impossible to rename index to a name +--echo # which is already used by another index, or is used +--echo # by index which is added within the same ALTER TABLE. +alter table t1 add key d(j); +--error ER_DUP_KEYNAME +alter table t1 rename key c to d; +show create table t1; +alter table t1 drop key d; +--error ER_DUP_KEYNAME +alter table t1 add key d(j), rename key c to d; +show create table t1; + +--echo # 1.d) It should be possible to rename index to a name +--echo # which belongs to index which is dropped within the +--echo # same ALTER TABLE. +alter table t1 add key d(j); +alter table t1 drop key c, rename key d to c; +show create table t1; + +--echo # 1.e) We disallow renaming from/to PRIMARY as it might +--echo # lead to some other key becoming "primary" internally, +--echo # which will be interpreted as dropping/addition of +--echo # primary key. +--error ER_PARSE_ERROR +alter table t1 rename key primary to d; +show create table t1; +--echo # Even using 'funny' syntax. +--error ER_WRONG_NAME_FOR_INDEX +alter table t1 rename key `primary` to d; +show create table t1; +--error ER_PARSE_ERROR +alter table t1 rename key c to primary; +show create table t1; +--error ER_WRONG_NAME_FOR_INDEX +alter table t1 rename key c to `primary`; +show create table t1; +drop table t1; + + +--echo # +--echo # 2) More complex tests for semantics of ALTER TABLE. +--echo # +--echo # 2.a) Check that standalone RENAME KEY works as expected +--echo # for unique and non-unique indexes. +create table t1 (a int, unique u(a), b int, key k(b)); +alter table t1 rename key u to uu; +show create table t1; +alter table t1 rename key k to kk; +show create table t1; + +--echo # 2.b) Check how that this clause can be mixed with other +--echo # clauses which don't affect key or its columns. +alter table t1 rename key kk to kkk, add column c int; +show create table t1; +alter table t1 rename key uu to uuu, add key c(c); +show create table t1; +alter table t1 rename key kkk to k, drop key uuu; +show create table t1; +alter table t1 rename key k to kk, rename to t2; +show create table t2; +drop table t2; + + +--echo # +--echo # 3) Test coverage for handling of RENAME INDEX clause in +--echo # various storage engines and using different ALTER +--echo # algorithm. +--echo # +--echo # 3.a) Test coverage for simple storage engines (MyISAM/Heap). +create table t1 (i int, key k(i)) engine=myisam; +insert into t1 values (1); +create table t2 (i int, key k(i)) engine=memory; +insert into t2 values (1); +--echo # MyISAM and Heap should be able to handle key renaming in-place. +alter table t1 algorithm=inplace, rename key k to kk; +alter table t2 algorithm=inplace, rename key k to kk; +show create table t1; +show create table t2; +--echo # So by default in-place algorithm should be chosen. +--echo # (ALTER TABLE should report 0 rows affected). +--enable_info +alter table t1 rename key kk to kkk; +alter table t2 rename key kk to kkk; +--disable_info +show create table t1; +show create table t2; +--echo # Copy algorithm should work as well. +alter table t1 algorithm=copy, rename key kkk to kkkk; +alter table t2 algorithm=copy, rename key kkk to kkkk; +show create table t1; +show create table t2; +--echo # When renaming is combined with other in-place operation +--echo # it still works as expected (i.e. works in-place). +alter table t1 algorithm=inplace, rename key kkkk to k, alter column i set default 100; +alter table t2 algorithm=inplace, rename key kkkk to k, alter column i set default 100; +show create table t1; +show create table t2; +--echo # Combining with non-inplace operation results in the whole ALTER +--echo # becoming non-inplace. +--error ER_ALTER_OPERATION_NOT_SUPPORTED +alter table t1 algorithm=inplace, rename key k to kk, add column j int; +--error ER_ALTER_OPERATION_NOT_SUPPORTED +alter table t2 algorithm=inplace, rename key k to kk, add column j int; +drop table t1, t2; + +--echo # 3.b) Basic tests for InnoDB. More tests can be found in +--echo # innodb.innodb_rename_index* +create table t1 (i int, key k(i)) engine=innodb; +insert into t1 values (1); +--echo # Basic rename, inplace algorithm should be chosen +--enable_info +alter table t1 algorithm=inplace, rename key k to kk; +--disable_info +show create table t1; +--echo # copy algorithm should work as well. +--enable_info +alter table t1 algorithm=copy, rename key kk to kkk; +--disable_info +show create table t1; +drop table t1; + +--echo # +--echo # 4) Additional coverage for complex cases in which code +--echo # in ALTER TABLE comparing old and new table version +--echo # got confused. +--echo # +--echo # Once InnoDB starts to support in-place index renaming the result +--echo # of below statements should stay the same. Information about +--echo # indexes returned by SHOW CREATE TABLE (from .FRM) and by +--echo # InnoDB (from InnoDB data-dictionary) should be consistent. +--echo # +create table t1 ( a int, b int, c int, d int, + primary key (a), index i1 (b), index i2 (c) ) engine=innodb; +alter table t1 add index i1 (d), rename index i1 to x; +show create table t1; +select i.name as k, f.name as c from information_schema.innodb_sys_tables as t, + information_schema.innodb_sys_indexes as i, + information_schema.innodb_sys_fields as f +where t.name='test/t1' and t.table_id = i.table_id and i.index_id = f.index_id +order by k, c; +drop table t1; +create table t1 (a int, b int, c int, d int, + primary key (a), index i1 (b), index i2 (c)) engine=innodb; +alter table t1 add index i1 (d), rename index i1 to i2, drop index i2; +show create table t1; +select i.name as k, f.name as c from information_schema.innodb_sys_tables as t, + information_schema.innodb_sys_indexes as i, + information_schema.innodb_sys_fields as f +where t.name='test/t1' and t.table_id = i.table_id and i.index_id = f.index_id +order by k, c; +drop table t1; + +--echo # +--echo # ALTER TABLE IF EXISTS +--echo # + +create table t1 (a int); +alter table if exists t1 add column b int; +alter table if exists t2 add column c int; +alter table if exists t9 rename t1; +alter table if exists t1 rename t2; +show create table t2; +drop table t2; + +--echo # +--echo # MDEV-22881 Unexpected errors, corrupt output, Valgrind / ASAN errors in Item_ident::print or append_identifier +--echo # +create table t1 (a int check (a >= 0)); +lock tables t1 write; +alter table t1 rename column a to a; +alter table t1 rename key if exists x to xx; + +# cleanup +unlock tables; +drop table t1; + +--echo # +--echo # MDEV-23852 alter table rename column to uppercase doesn't work +--echo # +create table t1 (abc int); +alter table t1 rename column abc to Abc, algorithm=copy; +show create table t1; +alter table t1 rename column abc to ABc, algorithm=inplace; +show create table t1; +alter table t1 rename column abc to ABC; +show create table t1; +drop table t1; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/alter_table_debug.result b/mysql-test/main/alter_table_debug.result new file mode 100644 index 00000000000..3366f1721cd --- /dev/null +++ b/mysql-test/main/alter_table_debug.result @@ -0,0 +1,26 @@ +# +# Start of 10.5 tests +# +# +# MDEV-19612 Split ALTER related data type specific code in sql_table.cc to Type_handler +# +SET sql_mode='STRICT_ALL_TABLES,STRICT_TRANS_TABLES,NO_ZERO_DATE'; +CREATE TABLE t1 (a INT); +ALTER TABLE t1 ALGORITHM=COPY, ADD b INT NOT NULL; +DROP TABLE t1; +SET sql_mode='STRICT_ALL_TABLES,STRICT_TRANS_TABLES,NO_ZERO_DATE'; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0); +ALTER TABLE t1 ALGORITHM=COPY, ADD b INT NOT NULL; +DROP TABLE t1; +SET sql_mode='STRICT_ALL_TABLES,STRICT_TRANS_TABLES,NO_ZERO_DATE'; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0); +SET debug_dbug='+d,validate_implicit_default_value_error'; +ALTER TABLE t1 ALGORITHM=COPY, ADD b INT NOT NULL; +ERROR 22007: Incorrect int value: '0' for column `test`.`t1`.`b` at row 1 +SET debug_dbug='-d,validate_implicit_default_value_error'; +DROP TABLE t1; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/alter_table_debug.test b/mysql-test/main/alter_table_debug.test new file mode 100644 index 00000000000..8c9293b06b9 --- /dev/null +++ b/mysql-test/main/alter_table_debug.test @@ -0,0 +1,33 @@ +--source include/have_debug.inc + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-19612 Split ALTER related data type specific code in sql_table.cc to Type_handler +--echo # + +SET sql_mode='STRICT_ALL_TABLES,STRICT_TRANS_TABLES,NO_ZERO_DATE'; +CREATE TABLE t1 (a INT); +ALTER TABLE t1 ALGORITHM=COPY, ADD b INT NOT NULL; +DROP TABLE t1; + +SET sql_mode='STRICT_ALL_TABLES,STRICT_TRANS_TABLES,NO_ZERO_DATE'; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0); +ALTER TABLE t1 ALGORITHM=COPY, ADD b INT NOT NULL; +DROP TABLE t1; + +SET sql_mode='STRICT_ALL_TABLES,STRICT_TRANS_TABLES,NO_ZERO_DATE'; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0); +SET debug_dbug='+d,validate_implicit_default_value_error'; +--error ER_TRUNCATED_WRONG_VALUE +ALTER TABLE t1 ALGORITHM=COPY, ADD b INT NOT NULL; +SET debug_dbug='-d,validate_implicit_default_value_error'; +DROP TABLE t1; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/alter_table_mdev539_maria.result b/mysql-test/main/alter_table_mdev539_maria.result index 0206f4070a0..01b2982edce 100644 --- a/mysql-test/main/alter_table_mdev539_maria.result +++ b/mysql-test/main/alter_table_mdev539_maria.result @@ -1,5 +1,5 @@ # -set @@storage_engine= Aria; +set @@default_storage_engine= Aria; # # mdev-539: fast build of unique/primary indexes for MyISAM/Aria # @@ -250,4 +250,4 @@ select * from customer where c_custkey=3; c_custkey c_name c_address c_nationkey c_phone c_acctbal c_mktsegment c_comment 3 Customer#000000003 MG9kdTD2WBHm 1 11-719-748-3364 7498.12 AUTOMOBILE special packages wake. slyly reg DROP DATABASE dbt3_s001; -set @@storage_engine= default; +set @@default_storage_engine= default; diff --git a/mysql-test/main/alter_table_mdev539_maria.test b/mysql-test/main/alter_table_mdev539_maria.test index 7e01bc3be84..2fead7bdab4 100644 --- a/mysql-test/main/alter_table_mdev539_maria.test +++ b/mysql-test/main/alter_table_mdev539_maria.test @@ -1,7 +1,7 @@ --echo # -set @@storage_engine= Aria; +set @@default_storage_engine= Aria; --source include/alter_table_mdev539.inc -set @@storage_engine= default; +set @@default_storage_engine= default; diff --git a/mysql-test/main/alter_table_mdev539_myisam.result b/mysql-test/main/alter_table_mdev539_myisam.result index 0339a64c9c7..490e5a4073a 100644 --- a/mysql-test/main/alter_table_mdev539_myisam.result +++ b/mysql-test/main/alter_table_mdev539_myisam.result @@ -1,5 +1,5 @@ # -set @@storage_engine= MyISAM; +set @@default_storage_engine= MyISAM; # # mdev-539: fast build of unique/primary indexes for MyISAM/Aria # @@ -250,4 +250,4 @@ select * from customer where c_custkey=3; c_custkey c_name c_address c_nationkey c_phone c_acctbal c_mktsegment c_comment 3 Customer#000000003 MG9kdTD2WBHm 1 11-719-748-3364 7498.12 AUTOMOBILE special packages wake. slyly reg DROP DATABASE dbt3_s001; -set @@storage_engine= default; +set @@default_storage_engine= default; diff --git a/mysql-test/main/alter_table_mdev539_myisam.test b/mysql-test/main/alter_table_mdev539_myisam.test index 0a5669088bf..c600e37c52c 100644 --- a/mysql-test/main/alter_table_mdev539_myisam.test +++ b/mysql-test/main/alter_table_mdev539_myisam.test @@ -1,7 +1,7 @@ --echo # -set @@storage_engine= MyISAM; +set @@default_storage_engine= MyISAM; --source include/alter_table_mdev539.inc -set @@storage_engine= default; +set @@default_storage_engine= default; diff --git a/mysql-test/main/alter_table_online.result b/mysql-test/main/alter_table_online.result index 2e3de2c0635..719d6fe1751 100644 --- a/mysql-test/main/alter_table_online.result +++ b/mysql-test/main/alter_table_online.result @@ -253,19 +253,19 @@ Feature_delay_key_write 0 alter online table t1 delay_key_write=1; show status like 'Feature_delay_key_write'; Variable_name Value -Feature_delay_key_write 1 +Feature_delay_key_write 0 flush tables; insert t1 values (1,2),(2,3),(3,4); show status like 'Feature_delay_key_write'; Variable_name Value -Feature_delay_key_write 2 +Feature_delay_key_write 1 alter online table t1 delay_key_write=0; show status like 'Feature_delay_key_write'; Variable_name Value -Feature_delay_key_write 2 +Feature_delay_key_write 1 flush tables; insert t1 values (1,2),(2,3),(3,4); show status like 'Feature_delay_key_write'; Variable_name Value -Feature_delay_key_write 2 +Feature_delay_key_write 1 drop table t1; diff --git a/mysql-test/main/alter_user.result b/mysql-test/main/alter_user.result index 0dcec5835b7..0bbf0aa6788 100644 --- a/mysql-test/main/alter_user.result +++ b/mysql-test/main/alter_user.result @@ -21,26 +21,30 @@ alter user foo; select * from mysql.user where user = 'foo'; Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time % foo N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 mysql_native_password N N 0.000000 -# Test super privilege works correctly with a read only database. +# +# Test READ_ONLY privilege works correctly with a read only database. +# SET @start_read_only = @@global.read_only; SET GLOBAL read_only=1; grant create user on *.* to foo; -# Currently no super privileges. +# Currently no READ_ONLY ADMIN privileges. connect a, localhost, foo; select @@global.read_only; @@global.read_only 1 alter user foo; ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement -# Grant super privilege to the user. +# Grant READ_ONLY ADMIN privilege to the user. connection default; -grant super on *.* to foo; -# We now have super privilege. We should be able to run alter user. +grant READ_ONLY ADMIN on *.* to foo; +# We now have READ_ONLY ADMIN privilege. We should be able to run alter user. connect b, localhost, foo; alter user foo; connection default; SET GLOBAL read_only = @start_read_only; +# # Test inexistant user. +# alter user boo; ERROR HY000: Operation ALTER USER failed for 'boo' #--warning ER_CANNOT_USER @@ -48,23 +52,25 @@ alter user if exists boo; Warnings: Error 1133 Can't find any matching row in the user table Note 1396 Operation ALTER USER failed for 'boo' +# # Test password related altering. +# alter user foo identified by 'something'; select * from mysql.user where user = 'foo'; Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time -% foo *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N N N N N N N N N N N N N N Y N N N N N N N N N Y N N N N 0 0 0 0 mysql_native_password *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N 0.000000 +% foo *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N N N N N N N N N N N N N N N N N N N N N N N N Y N N N N 0 0 0 0 mysql_native_password *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N 0.000000 alter user foo identified by 'something2'; select * from mysql.user where user = 'foo'; Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time -% foo *9CD58369E930E28C8996A89DB18B63294E6DC10C N N N N N N N N N N N N N N N Y N N N N N N N N N Y N N N N 0 0 0 0 mysql_native_password *9CD58369E930E28C8996A89DB18B63294E6DC10C N N 0.000000 +% foo *9CD58369E930E28C8996A89DB18B63294E6DC10C N N N N N N N N N N N N N N N N N N N N N N N N N Y N N N N 0 0 0 0 mysql_native_password *9CD58369E930E28C8996A89DB18B63294E6DC10C N N 0.000000 alter user foo identified by password '*88C89BE093D4ECF72D039F62EBB7477EA1FD4D63'; select * from mysql.user where user = 'foo'; Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time -% foo *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N N N N N N N N N N N N N N Y N N N N N N N N N Y N N N N 0 0 0 0 mysql_native_password *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N 0.000000 +% foo *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N N N N N N N N N N N N N N N N N N N N N N N N Y N N N N 0 0 0 0 mysql_native_password *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N 0.000000 alter user foo identified by password 'invalid'; select * from mysql.user where user = 'foo'; Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time -% foo invalid N N N N N N N N N N N N N N N Y N N N N N N N N N Y N N N N 0 0 0 0 mysql_native_password invalid N N 0.000000 +% foo invalid N N N N N N N N N N N N N N N N N N N N N N N N N Y N N N N 0 0 0 0 mysql_native_password invalid N N 0.000000 alter user foo identified with 'somecoolplugin'; ERROR HY000: Operation ALTER USER failed for 'foo'@'%' show warnings; @@ -74,32 +80,36 @@ Error 1396 Operation ALTER USER failed for 'foo'@'%' alter user foo identified with 'mysql_old_password'; select * from mysql.user where user = 'foo'; Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time -% foo N N N N N N N N N N N N N N N Y N N N N N N N N N Y N N N N 0 0 0 0 mysql_old_password N N 0.000000 +% foo N N N N N N N N N N N N N N N N N N N N N N N N N Y N N N N 0 0 0 0 mysql_old_password N N 0.000000 alter user foo identified with 'mysql_old_password' using '0123456789ABCDEF'; select * from mysql.user where user = 'foo'; Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time -% foo 0123456789ABCDEF N N N N N N N N N N N N N N N Y N N N N N N N N N Y N N N N 0 0 0 0 mysql_old_password 0123456789ABCDEF N N 0.000000 +% foo 0123456789ABCDEF N N N N N N N N N N N N N N N N N N N N N N N N N Y N N N N 0 0 0 0 mysql_old_password 0123456789ABCDEF N N 0.000000 +# # Test ssl related altering. +# alter user foo identified by 'something' require SSL; select * from mysql.user where user = 'foo'; Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time -% foo *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N N N N N N N N N N N N N N Y N N N N N N N N N Y N N N N ANY 0 0 0 0 mysql_native_password *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N 0.000000 +% foo *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N N N N N N N N N N N N N N N N N N N N N N N N Y N N N N ANY 0 0 0 0 mysql_native_password *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N 0.000000 alter user foo identified by 'something' require X509; select * from mysql.user where user = 'foo'; Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time -% foo *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N N N N N N N N N N N N N N Y N N N N N N N N N Y N N N N X509 0 0 0 0 mysql_native_password *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N 0.000000 +% foo *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N N N N N N N N N N N N N N N N N N N N N N N N Y N N N N X509 0 0 0 0 mysql_native_password *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N 0.000000 alter user foo identified by 'something' require cipher 'text' issuer 'foo_issuer' subject 'foo_subject'; select * from mysql.user where user = 'foo'; Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time -% foo *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N N N N N N N N N N N N N N Y N N N N N N N N N Y N N N N SPECIFIED text foo_issuer foo_subject 0 0 0 0 mysql_native_password *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N 0.000000 +% foo *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N N N N N N N N N N N N N N N N N N N N N N N N Y N N N N SPECIFIED text foo_issuer foo_subject 0 0 0 0 mysql_native_password *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N 0.000000 +# # Test resource limits altering. +# alter user foo with MAX_QUERIES_PER_HOUR 10 MAX_UPDATES_PER_HOUR 20 MAX_CONNECTIONS_PER_HOUR 30 MAX_USER_CONNECTIONS 40; select * from mysql.user where user = 'foo'; Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time -% foo *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N N N N N N N N N N N N N N Y N N N N N N N N N Y N N N N SPECIFIED text foo_issuer foo_subject 10 20 30 40 mysql_native_password *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N 0.000000 +% foo *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N N N N N N N N N N N N N N N N N N N N N N N N Y N N N N SPECIFIED text foo_issuer foo_subject 10 20 30 40 mysql_native_password *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N 0.000000 drop user foo; update mysql.global_priv set priv=@root_priv where user='root' and host='localhost'; diff --git a/mysql-test/main/alter_user.test b/mysql-test/main/alter_user.test index 5a05a671277..37f77c26496 100644 --- a/mysql-test/main/alter_user.test +++ b/mysql-test/main/alter_user.test @@ -16,36 +16,47 @@ select * from mysql.user where user = 'foo'; alter user foo; select * from mysql.user where user = 'foo'; ---echo # Test super privilege works correctly with a read only database. +--echo # +--echo # Test READ_ONLY privilege works correctly with a read only database. +--echo # + SET @start_read_only = @@global.read_only; SET GLOBAL read_only=1; grant create user on *.* to foo; ---echo # Currently no super privileges. +--echo # Currently no READ_ONLY ADMIN privileges. connect (a, localhost, foo); select @@global.read_only; --error ER_OPTION_PREVENTS_STATEMENT alter user foo; ---echo # Grant super privilege to the user. +--echo # Grant READ_ONLY ADMIN privilege to the user. connection default; -grant super on *.* to foo; +grant READ_ONLY ADMIN on *.* to foo; ---echo # We now have super privilege. We should be able to run alter user. +--echo # We now have READ_ONLY ADMIN privilege. We should be able to run alter user. connect (b, localhost, foo); alter user foo; connection default; SET GLOBAL read_only = @start_read_only; + +--echo # --echo # Test inexistant user. +--echo # + --error ER_CANNOT_USER alter user boo; --echo #--warning ER_CANNOT_USER alter user if exists boo; + +--echo # --echo # Test password related altering. +--echo # + alter user foo identified by 'something'; select * from mysql.user where user = 'foo'; @@ -68,7 +79,11 @@ select * from mysql.user where user = 'foo'; alter user foo identified with 'mysql_old_password' using '0123456789ABCDEF'; select * from mysql.user where user = 'foo'; + +--echo # --echo # Test ssl related altering. +--echo # + alter user foo identified by 'something' require SSL; select * from mysql.user where user = 'foo'; @@ -79,7 +94,11 @@ alter user foo identified by 'something' require cipher 'text' issuer 'foo_issuer' subject 'foo_subject'; select * from mysql.user where user = 'foo'; + +--echo # --echo # Test resource limits altering. +--echo # + alter user foo with MAX_QUERIES_PER_HOUR 10 MAX_UPDATES_PER_HOUR 20 MAX_CONNECTIONS_PER_HOUR 30 diff --git a/mysql-test/main/analyze_format_json.result b/mysql-test/main/analyze_format_json.result index c306c2fc1b3..fc643d1a8af 100644 --- a/mysql-test/main/analyze_format_json.result +++ b/mysql-test/main/analyze_format_json.result @@ -15,7 +15,8 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 30, "attached_condition": "t0.a < 3" @@ -43,7 +44,8 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 0, "attached_condition": "t0.a > 9 and t0.a is not null" @@ -83,7 +85,8 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "attached_condition": "t0.a is not null" @@ -99,7 +102,8 @@ ANALYZE "r_loops": 10, "rows": 1, "r_rows": 1, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 40, "attached_condition": "t1.b < 4" @@ -125,7 +129,8 @@ ANALYZE "r_loops": 1, "rows": 100, "r_rows": 100, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 20, "attached_condition": "tbl1.b < 20" @@ -137,7 +142,8 @@ ANALYZE "r_loops": 1, "rows": 100, "r_rows": 100, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 60, "attached_condition": "tbl2.b < 60" @@ -163,7 +169,8 @@ ANALYZE "r_loops": 1, "rows": 100, "r_rows": 100, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 20, "attached_condition": "tbl1.b < 20" @@ -175,7 +182,8 @@ ANALYZE "r_loops": 1, "rows": 100, "r_rows": 100, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 60, "attached_condition": "tbl2.b < 60" @@ -184,7 +192,7 @@ ANALYZE "buffer_size": "1Kb", "join_type": "BNL", "attached_condition": "tbl1.c > tbl2.c", - "r_filtered": 15.833 + "r_filtered": 15.83333333 } } } @@ -210,7 +218,8 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "attached_condition": "t1.a is not null" @@ -226,7 +235,8 @@ ANALYZE "r_loops": 10, "rows": 2, "r_rows": 0.2, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "using_index": true @@ -260,7 +270,8 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 50, "attached_condition": "test.t1.a < 5" @@ -317,7 +328,8 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 50, "index_condition": "t1.pk < 10", @@ -382,7 +394,8 @@ ANALYZE "r_loops": 1, "rows": 5, "r_rows": 5, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 }, @@ -405,9 +418,10 @@ ANALYZE "r_loops": 5, "rows": 1010, "r_rows": 203.8, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, - "r_filtered": 98.135 + "r_filtered": 98.13542689 } } } @@ -441,7 +455,8 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 50, "attached_condition": "tbl1.a < 5" @@ -460,7 +475,8 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 20, "attached_condition": "tbl2.a in (2,3)" @@ -501,6 +517,7 @@ ANALYZE "r_used_priority_queue": false, "r_output_rows": 0, "r_buffer_size": "REPLACED", + "r_sort_mode": "sort_key,rowid", "temporary_table": { "table": { "table_name": "t2", @@ -508,7 +525,8 @@ ANALYZE "r_loops": 1, "rows": 256, "r_rows": 256, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 } @@ -531,6 +549,7 @@ ANALYZE "r_used_priority_queue": false, "r_output_rows": 256, "r_buffer_size": "REPLACED", + "r_sort_mode": "sort_key,rowid", "temporary_table": { "table": { "table_name": "t2", @@ -538,7 +557,8 @@ ANALYZE "r_loops": 1, "rows": 256, "r_rows": 256, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 } @@ -572,6 +592,7 @@ ANALYZE "r_used_priority_queue": false, "r_output_rows": 256, "r_buffer_size": "REPLACED", + "r_sort_mode": "sort_key,rowid", "temporary_table": { "table": { "table_name": "t2", @@ -579,7 +600,8 @@ ANALYZE "r_loops": 1, "rows": 256, "r_rows": 256, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 } @@ -608,7 +630,8 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 }, @@ -619,7 +642,8 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 0, "attached_condition": "<in_optimizer>(t2.b,t2.b in (subquery#2))" @@ -642,7 +666,8 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 } @@ -679,6 +704,7 @@ ANALYZE "r_used_priority_queue": false, "r_output_rows": 0, "r_buffer_size": "REPLACED", + "r_sort_mode": "packed_sort_key,rowid", "temporary_table": { "filesort": { "sort_key": "(subquery#2)", @@ -687,6 +713,7 @@ ANALYZE "r_used_priority_queue": false, "r_output_rows": 0, "r_buffer_size": "REPLACED", + "r_sort_mode": "sort_key,rowid", "temporary_table": { "table": { "table_name": "t2", @@ -694,7 +721,8 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 }, @@ -705,7 +733,8 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 0, "attached_condition": "t3.f3 in (1,2)" @@ -779,7 +808,8 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 0, "attached_condition": "t1.a < 0" @@ -799,6 +829,7 @@ ANALYZE "r_limit": null, "r_used_priority_queue": null, "r_output_rows": null, + "r_sort_mode": "sort_key,rowid", "table": { "table_name": "t2", "access_type": "ALL", diff --git a/mysql-test/main/analyze_stmt_orderby.result b/mysql-test/main/analyze_stmt_orderby.result index 23f4c39dd5b..11736c47a49 100644 --- a/mysql-test/main/analyze_stmt_orderby.result +++ b/mysql-test/main/analyze_stmt_orderby.result @@ -44,6 +44,7 @@ ANALYZE "r_limit": 5, "r_used_priority_queue": true, "r_output_rows": 6, + "r_sort_mode": "sort_key,rowid", "table": { "update": 1, "table_name": "t2", @@ -145,6 +146,7 @@ ANALYZE "r_used_priority_queue": false, "r_output_rows": 10000, "r_buffer_size": "REPLACED", + "r_sort_mode": "sort_key,rowid", "table": { "delete": 1, "table_name": "t2", @@ -211,6 +213,7 @@ ANALYZE "r_limit": 4, "r_used_priority_queue": true, "r_output_rows": 4, + "r_sort_mode": "sort_key,rowid", "temporary_table": { "table": { "table_name": "t0", @@ -218,7 +221,8 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "attached_condition": "t0.a is not null" @@ -234,7 +238,8 @@ ANALYZE "r_loops": 10, "rows": 1, "r_rows": 0.4, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 } @@ -298,13 +303,15 @@ ANALYZE "r_used_priority_queue": false, "r_output_rows": 10, "r_buffer_size": "REPLACED", + "r_sort_mode": "sort_key,addon_fields", "table": { "table_name": "t0", "access_type": "ALL", "r_loops": 1, "rows": 10, "r_rows": 10, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "attached_condition": "t0.a is not null" @@ -322,7 +329,8 @@ ANALYZE "r_loops": 10, "rows": 1, "r_rows": 0.4, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 } @@ -355,6 +363,7 @@ ANALYZE "r_used_priority_queue": false, "r_output_rows": 10, "r_buffer_size": "REPLACED", + "r_sort_mode": "sort_key,rowid", "temporary_table": { "table": { "table_name": "t2", @@ -362,7 +371,8 @@ ANALYZE "r_loops": 1, "rows": 1000, "r_rows": 1000, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 50, "attached_condition": "t2.a MOD 2 = 0" @@ -410,7 +420,8 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 }, @@ -421,7 +432,8 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 }, @@ -465,6 +477,7 @@ ANALYZE "r_limit": 1, "r_used_priority_queue": true, "r_output_rows": 2, + "r_sort_mode": "sort_key,rowid", "temporary_table": { "filesort": { "sort_key": "t5.a", @@ -473,6 +486,7 @@ ANALYZE "r_used_priority_queue": false, "r_output_rows": 6, "r_buffer_size": "REPLACED", + "r_sort_mode": "sort_key,rowid", "temporary_table": { "table": { "table_name": "t6", @@ -480,7 +494,8 @@ ANALYZE "r_loops": 1, "rows": 5, "r_rows": 5, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 80, "attached_condition": "t6.b > 0 and t6.a <= 5" @@ -492,7 +507,8 @@ ANALYZE "r_loops": 1, "rows": 7, "r_rows": 7, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 }, @@ -500,7 +516,7 @@ ANALYZE "buffer_size": "119", "join_type": "BNL", "attached_condition": "t5.a = t6.a", - "r_filtered": 21.429 + "r_filtered": 21.42857143 } } } @@ -586,7 +602,8 @@ ANALYZE "r_loops": 1, "rows": 7, "r_rows": 20, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "using_index_for_group_by": true diff --git a/mysql-test/main/backup_interaction.result b/mysql-test/main/backup_interaction.result index 3c3071b8e70..a6fe7cf448d 100644 --- a/mysql-test/main/backup_interaction.result +++ b/mysql-test/main/backup_interaction.result @@ -37,7 +37,7 @@ unlock tables; # backup stage start; unlock tables; -select lock_mode from information_schema.metadata_lock_info; +select lock_mode from information_schema.metadata_lock_info where thread_id>0; lock_mode MDL_BACKUP_START lock table t1 write; @@ -98,11 +98,11 @@ drop table t1; create table t1(a int) engine=InnoDB; begin; insert into t1 values(1); -select lock_mode from information_schema.metadata_lock_info; +select lock_mode from information_schema.metadata_lock_info where thread_id>0; lock_mode MDL_SHARED_WRITE backup stage start; -select lock_mode from information_schema.metadata_lock_info; +select lock_mode from information_schema.metadata_lock_info where thread_id>0; lock_mode MDL_BACKUP_START backup stage block_commit; @@ -205,12 +205,12 @@ begin; select * from t1; col1 1 -select lock_mode from information_schema.metadata_lock_info; +select lock_mode from information_schema.metadata_lock_info where thread_id>0; lock_mode MDL_BACKUP_WAIT_COMMIT MDL_SHARED_READ backup stage end; -select lock_mode from information_schema.metadata_lock_info; +select lock_mode from information_schema.metadata_lock_info where thread_id>0; lock_mode drop table t1; # diff --git a/mysql-test/main/backup_interaction.test b/mysql-test/main/backup_interaction.test index 09ed769c898..a398a4a2d2d 100644 --- a/mysql-test/main/backup_interaction.test +++ b/mysql-test/main/backup_interaction.test @@ -52,7 +52,7 @@ unlock tables; --echo # backup stage start; unlock tables; -select lock_mode from information_schema.metadata_lock_info; +select lock_mode from information_schema.metadata_lock_info where thread_id>0; --error ER_BACKUP_LOCK_IS_ACTIVE lock table t1 write; @@ -121,9 +121,9 @@ drop table t1; create table t1(a int) engine=InnoDB; begin; insert into t1 values(1); -select lock_mode from information_schema.metadata_lock_info; +select lock_mode from information_schema.metadata_lock_info where thread_id>0; backup stage start; -select lock_mode from information_schema.metadata_lock_info; +select lock_mode from information_schema.metadata_lock_info where thread_id>0; backup stage block_commit; commit; backup stage end; @@ -224,9 +224,9 @@ backup stage start; backup stage block_commit; begin; select * from t1; -select lock_mode from information_schema.metadata_lock_info; +select lock_mode from information_schema.metadata_lock_info where thread_id>0; backup stage end; -select lock_mode from information_schema.metadata_lock_info; +select lock_mode from information_schema.metadata_lock_info where thread_id>0; drop table t1; --echo # diff --git a/mysql-test/main/backup_lock.result b/mysql-test/main/backup_lock.result index 95b2f520d90..96503814d00 100644 --- a/mysql-test/main/backup_lock.result +++ b/mysql-test/main/backup_lock.result @@ -192,28 +192,71 @@ BACKUP STAGE END; SET GLOBAL lock_wait_timeout=0; CREATE TABLE t_permanent_innodb (col1 INT) ENGINE = InnoDB; CREATE TABLE t_permanent_myisam (col1 INT) ENGINE = MyISAM; +CREATE TABLE t_permanent_aria (col1 INT) ENGINE = Aria transactional=1; +CREATE TABLE t_permanent_aria2 (col1 INT) ENGINE = Aria transactional=0; INSERT INTO t_permanent_innodb SET col1 = 1; INSERT INTO t_permanent_myisam SET col1 = 1; +INSERT INTO t_permanent_aria SET col1 = 1; +INSERT INTO t_permanent_aria2 SET col1 = 1; CREATE TABLE t_con1_innodb (col1 INT) ENGINE = InnoDB; CREATE TABLE t_con1_myisam (col1 INT) ENGINE = MyISAM; connect con1,localhost,root,,; -SET AUTOCOMMIT = 0; connection default; BACKUP STAGE START; BACKUP STAGE FLUSH; BACKUP STAGE BLOCK_DDL; BACKUP STAGE BLOCK_COMMIT; connection con1; +SET AUTOCOMMIT = 1; +UPDATE t_permanent_aria SET col1 = 1; +UPDATE t_permanent_innodb SET col1 = 1; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction UPDATE t_permanent_innodb SET col1 = 8; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction UPDATE t_permanent_myisam SET col1 = 8; ERROR HY000: Lock wait timeout exceeded; try restarting transaction +UPDATE t_permanent_aria SET col1 = 8; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +UPDATE t_permanent_aria2 SET col1 = 8; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +select * from t_permanent_innodb; +col1 +1 +select * from t_permanent_myisam; +col1 +1 +select * from t_permanent_aria; +col1 +8 +select * from t_permanent_aria2; +col1 +1 +SET AUTOCOMMIT = 0; +UPDATE t_permanent_innodb SET col1 = 9; +UPDATE t_permanent_aria SET col1 = 9; +UPDATE t_permanent_myisam SET col1 = 9; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +UPDATE t_permanent_aria2 SET col1 = 9; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction DROP TABLE t_con1_innodb; ERROR HY000: Lock wait timeout exceeded; try restarting transaction DROP TABLE t_con1_myisam; ERROR HY000: Lock wait timeout exceeded; try restarting transaction connection default; BACKUP STAGE END; -DROP TABLE t_permanent_myisam, t_permanent_innodb; +select * from t_permanent_innodb; +col1 +1 +select * from t_permanent_myisam; +col1 +1 +select * from t_permanent_aria; +col1 +9 +select * from t_permanent_aria2; +col1 +1 +DROP TABLE t_permanent_myisam, t_permanent_innodb, t_permanent_aria, t_permanent_aria2; DROP TABLE t_con1_innodb, t_con1_myisam; disconnect con1; set global lock_wait_timeout=default; diff --git a/mysql-test/main/backup_lock.test b/mysql-test/main/backup_lock.test index d6db7a6364e..0d4da8cb892 100644 --- a/mysql-test/main/backup_lock.test +++ b/mysql-test/main/backup_lock.test @@ -251,14 +251,17 @@ BACKUP STAGE END; SET GLOBAL lock_wait_timeout=0; CREATE TABLE t_permanent_innodb (col1 INT) ENGINE = InnoDB; CREATE TABLE t_permanent_myisam (col1 INT) ENGINE = MyISAM; +CREATE TABLE t_permanent_aria (col1 INT) ENGINE = Aria transactional=1; +CREATE TABLE t_permanent_aria2 (col1 INT) ENGINE = Aria transactional=0; INSERT INTO t_permanent_innodb SET col1 = 1; - INSERT INTO t_permanent_myisam SET col1 = 1; +INSERT INTO t_permanent_aria SET col1 = 1; +INSERT INTO t_permanent_aria2 SET col1 = 1; + CREATE TABLE t_con1_innodb (col1 INT) ENGINE = InnoDB; CREATE TABLE t_con1_myisam (col1 INT) ENGINE = MyISAM; --connect(con1,localhost,root,,) -SET AUTOCOMMIT = 0; --connection default BACKUP STAGE START; @@ -267,10 +270,36 @@ BACKUP STAGE BLOCK_DDL; BACKUP STAGE BLOCK_COMMIT; --connection con1 +SET AUTOCOMMIT = 1; + +# These should work as values are not changed +UPDATE t_permanent_aria SET col1 = 1; +--error ER_LOCK_WAIT_TIMEOUT +UPDATE t_permanent_innodb SET col1 = 1; + +--error ER_LOCK_WAIT_TIMEOUT UPDATE t_permanent_innodb SET col1 = 8; --error ER_LOCK_WAIT_TIMEOUT UPDATE t_permanent_myisam SET col1 = 8; --error ER_LOCK_WAIT_TIMEOUT +UPDATE t_permanent_aria SET col1 = 8; +--error ER_LOCK_WAIT_TIMEOUT +UPDATE t_permanent_aria2 SET col1 = 8; + +select * from t_permanent_innodb; +select * from t_permanent_myisam; +select * from t_permanent_aria; +select * from t_permanent_aria2; + +SET AUTOCOMMIT = 0; +UPDATE t_permanent_innodb SET col1 = 9; +UPDATE t_permanent_aria SET col1 = 9; +--error ER_LOCK_WAIT_TIMEOUT +UPDATE t_permanent_myisam SET col1 = 9; +--error ER_LOCK_WAIT_TIMEOUT +UPDATE t_permanent_aria2 SET col1 = 9; + +--error ER_LOCK_WAIT_TIMEOUT DROP TABLE t_con1_innodb; --error ER_LOCK_WAIT_TIMEOUT @@ -278,7 +307,13 @@ DROP TABLE t_con1_myisam; --connection default BACKUP STAGE END; -DROP TABLE t_permanent_myisam, t_permanent_innodb; + +select * from t_permanent_innodb; +select * from t_permanent_myisam; +select * from t_permanent_aria; +select * from t_permanent_aria2; + +DROP TABLE t_permanent_myisam, t_permanent_innodb, t_permanent_aria, t_permanent_aria2; DROP TABLE t_con1_innodb, t_con1_myisam; --disconnect con1 set global lock_wait_timeout=default; diff --git a/mysql-test/main/brackets.result b/mysql-test/main/brackets.result index c221d64fd17..69b479d7820 100644 --- a/mysql-test/main/brackets.result +++ b/mysql-test/main/brackets.result @@ -54,7 +54,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNION RESULT <union1,4> ALL NULL NULL NULL NULL NULL NULL Warnings: -Note 1003 /* select#1 */ select 1 AS `1` union /* select#4 */ select `__4`.`1` AS `1` from (/* select#2 */ select 1 AS `1` union all /* select#3 */ select 1 AS `1`) `__4` +Note 1003 /* select#1 */ select 1 AS `1` union /* select#4 */ select `__4`.`1` AS `1` from (/* select#2 */ select 1 AS `1` union /* select#3 */ select 1 AS `1`) `__4` select 1 union select 1 union all select 1; 1 1 @@ -4454,7 +4454,7 @@ create view v1 as with t(a) as (values (2), (1)) select a from t; show create view v1; View Create View character_set_client collation_connection -v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS with t(a) as (values (2),(1))select `t`.`a` AS `a` from `t` latin1 latin1_swedish_ci +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS with t(`a`) as (values (2),(1))select `t`.`a` AS `a` from `t` latin1 latin1_swedish_ci select * from v1; a 2 @@ -4469,7 +4469,7 @@ order by 1 desc limit 3 ) select a from t1 where a=4 union select a from t where a=7 order by a desc; show create view v1; View Create View character_set_client collation_connection -v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS with t(a) as (values (2),(1) union (values (4),(7)) order by 1 desc limit 3)select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 4 union select `t`.`a` AS `a` from `t` where `t`.`a` = 7 order by `a` desc latin1 latin1_swedish_ci +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS with t(`a`) as (values (2),(1) union (values (4),(7)) order by 1 desc limit 3)select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 4 union select `t`.`a` AS `a` from `t` where `t`.`a` = 7 order by `a` desc latin1 latin1_swedish_ci select * from v1; a 7 @@ -4484,7 +4484,7 @@ order by 1 desc limit 3 ) select a from t1 where a=1 union select a from t where a=7 order by a desc; show create view v1; View Create View character_set_client collation_connection -v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS with t(a) as ((values (2),(1)) union (values (4),(7) order by 1 desc) order by 1 desc limit 3)select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 1 union select `t`.`a` AS `a` from `t` where `t`.`a` = 7 order by `a` desc latin1 latin1_swedish_ci +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS with t(`a`) as ((values (2),(1)) union (values (4),(7) order by 1 desc) order by 1 desc limit 3)select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 1 union select `t`.`a` AS `a` from `t` where `t`.`a` = 7 order by `a` desc latin1 latin1_swedish_ci select * from v1; a 7 diff --git a/mysql-test/main/cache_innodb.result b/mysql-test/main/cache_innodb.result index 18ae0ac8a83..d6e67b472b0 100644 --- a/mysql-test/main/cache_innodb.result +++ b/mysql-test/main/cache_innodb.result @@ -1,6 +1,6 @@ SET global query_cache_type=ON; SET local query_cache_type=ON; -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; drop table if exists t1,t2,t3; set @save_query_cache_size = @@global.query_cache_size; set GLOBAL query_cache_size = 1355776; @@ -132,7 +132,7 @@ id a 1 me drop table t3,t2,t1; connect connection1,localhost,root,,; -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; SET @@autocommit=1; connection default; SHOW VARIABLES LIKE 'have_query_cache'; @@ -141,7 +141,7 @@ have_query_cache YES SET GLOBAL query_cache_size = 204800; flush status; SET @@autocommit=1; -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; CREATE TABLE t2 (s1 int, s2 varchar(1000), key(s1)); INSERT INTO t2 VALUES (1,repeat('a',10)),(2,repeat('a',10)),(3,repeat('a',10)),(4,repeat('a',10)); COMMIT; diff --git a/mysql-test/main/column_compression.result b/mysql-test/main/column_compression.result index bd843736ccc..01f906b5f31 100644 --- a/mysql-test/main/column_compression.result +++ b/mysql-test/main/column_compression.result @@ -2672,3 +2672,19 @@ SET column_compression_threshold=0; INSERT INTO t1 VALUES('aa'); SET column_compression_threshold=DEFAULT; DROP TABLE t1; +# +# End of 10.3 tests +# +# +# Start of 10.5 tests +# +# +# MDEV-19727 Add Type_handler::Key_part_spec_init_ft +# +CREATE TABLE t1 (a VARCHAR(1000) COMPRESSED, FULLTEXT INDEX(a)); +ERROR HY000: Compressed column 'a' can't be used in key specification +CREATE TABLE t1 (a TEXT COMPRESSED, FULLTEXT INDEX(a)); +ERROR HY000: Compressed column 'a' can't be used in key specification +# +# End of 10.5 tests +# diff --git a/mysql-test/main/column_compression.test b/mysql-test/main/column_compression.test index 1560b23ad3e..2ae50be95d2 100644 --- a/mysql-test/main/column_compression.test +++ b/mysql-test/main/column_compression.test @@ -256,7 +256,6 @@ CREATE TABLE t1 (a NVARCHAR(10) COMPRESSED BINARY COMPRESSED); --error ER_PARSE_ERROR CREATE TABLE t1 (a NVARCHAR(10) COMPRESSED DEFAULT '' COMPRESSED); - --echo # --echo # MDEV-21348 - Memory leak in Storage-Engine Independent Column --echo # Compression @@ -266,3 +265,32 @@ SET column_compression_threshold=0; INSERT INTO t1 VALUES('aa'); SET column_compression_threshold=DEFAULT; DROP TABLE t1; + +--echo # +--echo # End of 10.3 tests +--echo # + + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-19727 Add Type_handler::Key_part_spec_init_ft +--echo # + +# +# Indexes on COMPRESSED columns are generally prohibited, so we don't have +# to override Type_handler_xxx_compressed::Key_part_spec_init_ft(). +# Note, we could support FULLTEXT indexes on compressed columns eventually. +# + +--error ER_COMPRESSED_COLUMN_USED_AS_KEY +CREATE TABLE t1 (a VARCHAR(1000) COMPRESSED, FULLTEXT INDEX(a)); + +--error ER_COMPRESSED_COLUMN_USED_AS_KEY +CREATE TABLE t1 (a TEXT COMPRESSED, FULLTEXT INDEX(a)); + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/comment_column.test b/mysql-test/main/comment_column.test index a4f3893dd4a..e883f64766a 100644 --- a/mysql-test/main/comment_column.test +++ b/mysql-test/main/comment_column.test @@ -6,7 +6,7 @@ create table t1 (c1 VARCHAR(10) NOT NULL COMMENT 'Abcdefghijabcdefghijabcdefghij SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1'; SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1'; SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1'; -let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`; +let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='DEFAULT_STORAGE_ENGINE'`; --replace_result $ENGINE ENGINE SHOW CREATE TABLE t1; @@ -14,7 +14,7 @@ ALTER TABLE t1 ADD COLUMN c8 INTEGER COMMENT 'ABCdefghijabcdefghijabcdefghijabcd SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1'; SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1'; SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1'; -let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`; +let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='DEFAULT_STORAGE_ENGINE'`; --replace_result $ENGINE ENGINE SHOW CREATE TABLE t1; @@ -23,7 +23,7 @@ ALTER TABLE t1 ADD COLUMN c9 INTEGER COMMENT 'ABCDefghijabcdefghijabcdefghijabcd SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1'; SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1'; SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1'; -let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`; +let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='DEFAULT_STORAGE_ENGINE'`; --replace_result $ENGINE ENGINE SHOW CREATE TABLE t1; @@ -32,7 +32,7 @@ ALTER TABLE t1 ADD COLUMN c10 INTEGER COMMENT 'ABCDEfghijabcdefghijabcdefghijabc SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1'; SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1'; SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1'; -let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`; +let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='DEFAULT_STORAGE_ENGINE'`; --replace_result $ENGINE ENGINE SHOW CREATE TABLE t1; @@ -41,14 +41,14 @@ ALTER TABLE t1 MODIFY COLUMN c8 CHAR(10); SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1'; SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1'; SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1'; -let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`; +let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='DEFAULT_STORAGE_ENGINE'`; --replace_result $ENGINE ENGINE SHOW CREATE TABLE t1; ALTER TABLE t1 CHANGE COLUMN c9 c9_1 INTEGER COMMENT '1234567890'; SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1'; SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1'; SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1'; -let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`; +let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='DEFAULT_STORAGE_ENGINE'`; --replace_result $ENGINE ENGINE SHOW CREATE TABLE t1; @@ -56,7 +56,7 @@ ALTER TABLE t1 DROP COLUMN c1; SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1'; SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1'; SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1'; -let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`; +let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='DEFAULT_STORAGE_ENGINE'`; --replace_result $ENGINE ENGINE SHOW CREATE TABLE t1; @@ -67,7 +67,7 @@ ALTER TABLE t1 ADD COLUMN c11 INTEGER COMMENT 'ABCDEfghijabcdefghijabcdefghijabc SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1'; SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1'; SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1'; -let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`; +let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='DEFAULT_STORAGE_ENGINE'`; --replace_result $ENGINE ENGINE SHOW CREATE TABLE t1; @@ -78,7 +78,7 @@ ALTER TABLE t1 ADD COLUMN c12 INTEGER COMMENT 'ABCDEfghijabcdefghijabcdefghijabc SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1'; SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1'; SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1'; -let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`; +let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='DEFAULT_STORAGE_ENGINE'`; --replace_result $ENGINE ENGINE SHOW CREATE TABLE t1; @@ -87,7 +87,7 @@ ALTER TABLE t1 ADD COLUMN c12 CHAR(100) COMMENT 'ABCDefghijabcdefghijabcdefghija SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1'; SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1'; SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1'; -let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`; +let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='DEFAULT_STORAGE_ENGINE'`; --replace_result $ENGINE ENGINE SHOW CREATE TABLE t1; @@ -99,7 +99,7 @@ create table t1 (c1 VARCHAR(10) NOT NULL COMMENT 'Abcdefghijabcdefghijabcdefghij SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1'; SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1'; SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1'; -let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`; +let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='DEFAULT_STORAGE_ENGINE'`; --replace_result $ENGINE ENGINE SHOW CREATE TABLE t1; diff --git a/mysql-test/main/comment_database.result b/mysql-test/main/comment_database.result new file mode 100644 index 00000000000..628a3259b6b --- /dev/null +++ b/mysql-test/main/comment_database.result @@ -0,0 +1,78 @@ +# +# MDEV-307: Add functionality for database comments +# +CREATE DATABASE db1 COMMENT=; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1 +CREATE DATABASE db1 +COMMENT='abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd'; +SHOW CREATE DATABASE db1; +Database Create Database +db1 CREATE DATABASE `db1` /*!40100 DEFAULT CHARACTER SET latin1 */ COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd' +SELECT schema_comment, char_length(schema_comment) +FROM information_schema.schemata +WHERE schema_name='db1'; +schema_comment char_length(schema_comment) +abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd 1024 +DROP DATABASE db1; +SET SQL_MODE=''; +CREATE DATABASE db1 +COMMENT='abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcde'; +Warnings: +Warning 4160 Comment for database 'db1' is too long (max = 1024) +SHOW CREATE DATABASE db1; +Database Create Database +db1 CREATE DATABASE `db1` /*!40100 DEFAULT CHARACTER SET latin1 */ COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd' +SELECT schema_comment, char_length(schema_comment) +FROM information_schema.schemata +WHERE schema_name='db1'; +schema_comment char_length(schema_comment) +abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd 1024 +DROP DATABASE db1; +SET SQL_MODE='TRADITIONAL'; +CREATE DATABASE db1 +COMMENT='abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcde'; +ERROR HY000: Comment for database 'db1' is too long (max = 1024) +SELECT schema_comment, char_length(schema_comment) +FROM information_schema.schemata +WHERE schema_name='db1'; +schema_comment char_length(schema_comment) +CREATE DATABASE db1 COMMENT 'db1'; +SHOW CREATE DATABASE db1; +Database Create Database +db1 CREATE DATABASE `db1` /*!40100 DEFAULT CHARACTER SET latin1 */ COMMENT 'db1' +ALTER DATABASE db1 COMMENT = "db1 comment"; +SELECT * FROM information_schema.schemata +WHERE schema_name='db1'; +CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME SQL_PATH SCHEMA_COMMENT +def db1 latin1 latin1_swedish_ci NULL db1 comment +DROP DATABASE db1; +CREATE DATABASE db1; +USE db1; +ALTER DATABASE COMMENT 'db1 comment' CHARACTER SET 'utf8'; +SHOW CREATE DATABASE db1; +Database Create Database +db1 CREATE DATABASE `db1` /*!40100 DEFAULT CHARACTER SET utf8 */ COMMENT 'db1 comment' +ALTER DATABASE db1 COMMENT 'this is db1 comment'; +SHOW CREATE DATABASE db1; +Database Create Database +db1 CREATE DATABASE `db1` /*!40100 DEFAULT CHARACTER SET utf8 */ COMMENT 'this is db1 comment' +ALTER DATABASE CHARACTER SET 'latin1'; +SHOW CREATE DATABASE db1; +Database Create Database +db1 CREATE DATABASE `db1` /*!40100 DEFAULT CHARACTER SET latin1 */ COMMENT 'this is db1 comment' +DROP DATABASE db1; +CREATE DATABASE comment COMMENT 'comment' CHARACTER SET 'latin2'; +SHOW CREATE DATABASE comment; +Database Create Database +comment CREATE DATABASE `comment` /*!40100 DEFAULT CHARACTER SET latin2 */ COMMENT 'comment' +ALTER DATABASE comment COMMENT 'comment comment'; +SHOW CREATE DATABASE comment; +Database Create Database +comment CREATE DATABASE `comment` /*!40100 DEFAULT CHARACTER SET latin2 */ COMMENT 'comment comment' +USE comment; +ALTER DATABASE COMMENT 'comment'; +SELECT * FROM information_schema.schemata +WHERE schema_name='comment'; +CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME SQL_PATH SCHEMA_COMMENT +def comment latin2 latin2_general_ci NULL comment +DROP DATABASE comment; diff --git a/mysql-test/main/comment_database.test b/mysql-test/main/comment_database.test new file mode 100644 index 00000000000..3fe1c7b205c --- /dev/null +++ b/mysql-test/main/comment_database.test @@ -0,0 +1,63 @@ +--echo # +--echo # MDEV-307: Add functionality for database comments +--echo # + +# Check an error state +--error ER_PARSE_ERROR +CREATE DATABASE db1 COMMENT=; + +# 1024 bytes +CREATE DATABASE db1 +COMMENT='abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd'; +SHOW CREATE DATABASE db1; +SELECT schema_comment, char_length(schema_comment) +FROM information_schema.schemata +WHERE schema_name='db1'; +DROP DATABASE db1; + +# 1025 bytes (warning) +SET SQL_MODE=''; +CREATE DATABASE db1 +COMMENT='abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcde'; +SHOW CREATE DATABASE db1; +SELECT schema_comment, char_length(schema_comment) +FROM information_schema.schemata +WHERE schema_name='db1'; +DROP DATABASE db1; +SET SQL_MODE='TRADITIONAL'; + +# 1025 bytes (error) +--error ER_TOO_LONG_DATABASE_COMMENT +CREATE DATABASE db1 +COMMENT='abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcde'; +SELECT schema_comment, char_length(schema_comment) +FROM information_schema.schemata +WHERE schema_name='db1'; + +CREATE DATABASE db1 COMMENT 'db1'; +SHOW CREATE DATABASE db1; +ALTER DATABASE db1 COMMENT = "db1 comment"; +SELECT * FROM information_schema.schemata +WHERE schema_name='db1'; +DROP DATABASE db1; + +CREATE DATABASE db1; +USE db1; +ALTER DATABASE COMMENT 'db1 comment' CHARACTER SET 'utf8'; +SHOW CREATE DATABASE db1; +ALTER DATABASE db1 COMMENT 'this is db1 comment'; +SHOW CREATE DATABASE db1; +ALTER DATABASE CHARACTER SET 'latin1'; +SHOW CREATE DATABASE db1; +DROP DATABASE db1; + +# Test the case when the database is named 'comment' +CREATE DATABASE comment COMMENT 'comment' CHARACTER SET 'latin2'; +SHOW CREATE DATABASE comment; +ALTER DATABASE comment COMMENT 'comment comment'; +SHOW CREATE DATABASE comment; +USE comment; +ALTER DATABASE COMMENT 'comment'; +SELECT * FROM information_schema.schemata +WHERE schema_name='comment'; +DROP DATABASE comment; diff --git a/mysql-test/main/comment_index.test b/mysql-test/main/comment_index.test index 4ba1f336ddb..5db60368dac 100644 --- a/mysql-test/main/comment_index.test +++ b/mysql-test/main/comment_index.test @@ -6,7 +6,7 @@ create table t1 (c1 VARCHAR(10) NOT NULL COMMENT 'Abcdefghijabcdefghijabcdefghij SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1'; SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1'; SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1'; -let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`; +let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='DEFAULT_STORAGE_ENGINE'`; --replace_result $ENGINE ENGINE SHOW CREATE TABLE t1; @@ -15,7 +15,7 @@ CREATE INDEX i4 ON t1(c4) COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcde SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1'; SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1'; SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1'; -let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`; +let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='DEFAULT_STORAGE_ENGINE'`; --replace_result $ENGINE ENGINE SHOW CREATE TABLE t1; @@ -24,7 +24,7 @@ ALTER TABLE t1 ADD INDEX (c6) COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghija SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1'; SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1'; SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1'; -let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`; +let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='DEFAULT_STORAGE_ENGINE'`; --replace_result $ENGINE ENGINE SHOW CREATE TABLE t1; @@ -33,7 +33,7 @@ ALTER TABLE t1 DROP INDEX i2, DROP INDEX i4; SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1'; SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1'; SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1'; -let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`; +let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='DEFAULT_STORAGE_ENGINE'`; --replace_result $ENGINE ENGINE SHOW CREATE TABLE t1; @@ -41,7 +41,7 @@ ALTER TABLE t1 ADD INDEX i8(c8) COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghi SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1'; SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1'; SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1'; -let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`; +let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='DEFAULT_STORAGE_ENGINE'`; --replace_result $ENGINE ENGINE SHOW CREATE TABLE t1; @@ -51,7 +51,7 @@ CREATE INDEX i1_3 ON t1(c1,c2,c3) COMMENT 'abcdefghijabcdefghijabcdefghijabcdefg SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1'; SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1'; SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1'; -let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`; +let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='DEFAULT_STORAGE_ENGINE'`; --replace_result $ENGINE ENGINE SHOW CREATE TABLE t1; @@ -62,7 +62,7 @@ CREATE INDEX i11 ON t1(c11) COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabc SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1'; SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1'; SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1'; -let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`; +let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='DEFAULT_STORAGE_ENGINE'`; --replace_result $ENGINE ENGINE SHOW CREATE TABLE t1; @@ -71,7 +71,7 @@ ALTER TABLE t1 ADD INDEX (c13) COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghij SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1'; SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1'; SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1'; -let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`; +let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='DEFAULT_STORAGE_ENGINE'`; --replace_result $ENGINE ENGINE SHOW CREATE TABLE t1; @@ -84,7 +84,7 @@ ALTER TABLE t1 ADD INDEX i12 (c12) COMMENT 'abcdefghijabcdefghijabcdefghijabcdef SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1'; SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1'; SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1'; -let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`; +let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='DEFAULT_STORAGE_ENGINE'`; --replace_result $ENGINE ENGINE SHOW CREATE TABLE t1; @@ -95,7 +95,7 @@ CREATE INDEX i12 ON t1(c12) COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabc SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1'; SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1'; SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1'; -let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`; +let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='DEFAULT_STORAGE_ENGINE'`; --replace_result $ENGINE ENGINE SHOW CREATE TABLE t1; diff --git a/mysql-test/main/comment_table.test b/mysql-test/main/comment_table.test index db8bdf54ba6..ba1ab9dda33 100644 --- a/mysql-test/main/comment_table.test +++ b/mysql-test/main/comment_table.test @@ -3,7 +3,7 @@ create table t1 (c1 VARCHAR(10) NOT NULL COMMENT 'c1 comment', c2 INTEGER,c3 INT ) COMMENT='abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd'; SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1'; SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1'; -let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`; +let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='DEFAULT_STORAGE_ENGINE'`; --replace_result $ENGINE ENGINE SHOW CREATE TABLE t1; drop table t1; @@ -13,7 +13,7 @@ create table t1 (c1 VARCHAR(10) NOT NULL COMMENT 'c1 comment', c2 INTEGER,c3 INT ) COMMENT='abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcde'; SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1'; SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1'; -let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`; +let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='DEFAULT_STORAGE_ENGINE'`; --replace_result $ENGINE ENGINE SHOW CREATE TABLE t1; drop table t1; @@ -30,7 +30,7 @@ create table t1 (c1 VARCHAR(10) NOT NULL COMMENT 'c1 comment', c2 INTEGER,c3 INT ) COMMENT='abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd'; SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1'; SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1'; -let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`; +let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='DEFAULT_STORAGE_ENGINE'`; --replace_result $ENGINE ENGINE SHOW CREATE TABLE t1; drop table t1; diff --git a/mysql-test/main/commit_1innodb.result b/mysql-test/main/commit_1innodb.result index a7b544dc282..d090844cb74 100644 --- a/mysql-test/main/commit_1innodb.result +++ b/mysql-test/main/commit_1innodb.result @@ -386,6 +386,11 @@ end| # Reset Handler_commit and Handler_prepare counters flush status; # +# Count of reading of p_verify_status_increment() from mysql.proc +call p_verify_status_increment(2, 0, 2, 0); +SUCCESS + +# # 1. Read-only statement: SELECT # select * from t1; @@ -568,7 +573,7 @@ begin insert t2 set a=2; return 2; end| -call p_verify_status_increment(0, 0, 0, 0); +call p_verify_status_increment(4, 0, 4, 0); SUCCESS # 16. A function changes non-trans-table. @@ -580,7 +585,7 @@ SUCCESS select f1(); f1() 2 -call p_verify_status_increment(1, 0, 1, 0); +call p_verify_status_increment(3, 0, 3, 0); SUCCESS commit; @@ -688,9 +693,9 @@ SUCCESS # 24. DDL: TRUNCATE TEMPORARY TABLE truncate table t2; -call p_verify_status_increment(4, 0, 4, 0); -ERROR -Expected commit increment: 4 actual: 2 +call p_verify_status_increment(2, 0, 2, 0); +SUCCESS + commit; # There is nothing left to commit call p_verify_status_increment(0, 0, 0, 0); @@ -855,7 +860,7 @@ call p_verify_status_increment(2, 0, 2, 0); SUCCESS create view v1 as select * from t2; -call p_verify_status_increment(2, 0, 2, 0); +call p_verify_status_increment(4, 0, 4, 0); SUCCESS check table t1; @@ -882,7 +887,7 @@ call p_verify_status_increment(0, 0, 0, 0); SUCCESS drop view v1; -call p_verify_status_increment(0, 0, 0, 0); +call p_verify_status_increment(2, 0, 2, 0); SUCCESS # diff --git a/mysql-test/main/compress.result b/mysql-test/main/compress.result index 8fbbb324b16..788eb7ab13b 100644 --- a/mysql-test/main/compress.result +++ b/mysql-test/main/compress.result @@ -515,7 +515,7 @@ insert into tmp select * from t3; insert into t3 select * from tmp; alter table t3 add t2nr int not null auto_increment primary key first; drop table tmp; -SET BIG_TABLES=1; +set tmp_memory_table_size=0; select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10; namn Abraham Abraham @@ -528,7 +528,7 @@ ammonium ammonium analyzable analyzable animals animals animized animized -SET BIG_TABLES=0; +set tmp_memory_table_size=default; select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10; concat(fld3," ",fld3) Abraham Abraham @@ -565,7 +565,7 @@ attendants 1 bedlam 1 bedpost 1 boasted 1 -SET BIG_TABLES=1; +set tmp_memory_table_size=0; select distinct fld3,count(*) from t2 group by companynr,fld3 limit 10; fld3 count(*) affixed 1 @@ -578,7 +578,7 @@ attendants 1 bedlam 1 bedpost 1 boasted 1 -SET BIG_TABLES=0; +set tmp_memory_table_size=default; select distinct fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr,fld3 limit 100,10; fld3 repeat("a",length(fld3)) count(*) circus aaaaaa 1 diff --git a/mysql-test/main/concurrent_innodb_safelog-master.opt b/mysql-test/main/concurrent_innodb_safelog-master.opt deleted file mode 100644 index 82dec8b25fd..00000000000 --- a/mysql-test/main/concurrent_innodb_safelog-master.opt +++ /dev/null @@ -1 +0,0 @@ ---loose-innodb_lock_wait_timeout=1 diff --git a/mysql-test/main/concurrent_innodb_safelog.result b/mysql-test/main/concurrent_innodb_safelog.result index 27889777ac1..7d120547570 100644 --- a/mysql-test/main/concurrent_innodb_safelog.result +++ b/mysql-test/main/concurrent_innodb_safelog.result @@ -1,15 +1,13 @@ +SET @save_timeout = @@GLOBAL.innodb_lock_wait_timeout; +SET GLOBAL innodb_lock_wait_timeout = 1; SET GLOBAL TRANSACTION ISOLATION LEVEL REPEATABLE READ; connection default; SET SQL_MODE=""; SELECT @@global.tx_isolation; @@global.tx_isolation REPEATABLE-READ -SELECT @@global.innodb_locks_unsafe_for_binlog; -@@global.innodb_locks_unsafe_for_binlog -0 # keep_locks == 1 GRANT USAGE ON test.* TO mysqltest@localhost; -drop table if exists t1; ** ** two UPDATE's running and both changing distinct result sets @@ -17,7 +15,7 @@ drop table if exists t1; connect thread1, localhost, mysqltest,,; connection thread1; ** Set up table -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; create table t1(eta int(11) not null, tipo int(11), c varchar(255)); insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); @@ -47,7 +45,7 @@ begin; ** Update on t1 will cause a table scan which will be blocked because ** the previously initiated table scan applied exclusive key locks on ** all primary keys. -** Not so if innodb_locks_unsafe_for_binlog is set. The locks that +** Not so for READ UNCOMMITTED or READ COMMITTED. The locks that ** do not match the WHERE condition are released. update t1 set eta=2 where tipo=22; ERROR HY000: Lock wait timeout exceeded; try restarting transaction @@ -157,7 +155,7 @@ drop table t1; ** connection thread1; ** Set up table -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; create table t1(eta int(11) not null, tipo int(11), c varchar(255)); insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); @@ -187,7 +185,7 @@ begin; ** Update on t1 will cause a table scan which will be blocked because ** the previously initiated table scan applied exclusive key locks on ** all primary keys. -** Not so if innodb_locks_unsafe_for_binlog is set. The locks that +** Not so for READ UNCOMMITTED or READ COMMITTED. The locks that ** do not match the WHERE condition are released. update t1 set tipo=1 where tipo=2; ERROR HY000: Lock wait timeout exceeded; try restarting transaction @@ -295,7 +293,7 @@ drop table t1; ** connection thread1; ** Set up table -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; create table t1 (a int not null, b int not null); insert into t1 values (1,1),(2,1),(3,1),(4,1); ** Create ULL 'hello2' @@ -344,7 +342,7 @@ drop table t1; ** connection thread1; ** Set up table -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; create table t1(eta int(11) not null, tipo int(11), c varchar(255)); insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); @@ -447,7 +445,7 @@ drop table t1; ** connection thread1; ** Set up table -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; create table t1(eta int(11) not null, tipo int(11), c varchar(255)); insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); @@ -476,7 +474,7 @@ begin; ** Updating single row using a table scan. This will time out ** because of ongoing transaction on thread 1 holding lock on ** all primary keys in the scan. -** Not so if innodb_locks_unsafe_for_binlog is set. The locks that +** Not so for READ UNCOMMITTED or READ COMMITTED. The locks that ** do not match the WHERE condition are released. update t1 set tipo=11 where tipo=22; ERROR HY000: Lock wait timeout exceeded; try restarting transaction @@ -551,7 +549,7 @@ drop table t1; ** connection thread1; ** Set up table -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; create table t1(eta int(11) not null, tipo int(11), c varchar(255)); insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); @@ -638,7 +636,7 @@ drop table t1; ** connection thread1; ** Set up table -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; create table t1(eta int(11) not null, tipo int(11), c varchar(255)); insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); @@ -715,7 +713,7 @@ drop table t1; ** connection thread1; ** Set up table -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; create table t1(eta int(11) not null, tipo int(11), c varchar(255)); insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); @@ -736,7 +734,7 @@ begin; ** Update on t1 will cause a table scan which will be blocked because ** the previously initiated table scan applied exclusive key locks on ** all primary keys. -** Not so if innodb_locks_unsafe_for_binlog is set. The locks that +** Not so for READ UNCOMMITTED or READ COMMITTED. The locks that ** do not match the WHERE condition are released. update t1 set tipo=1 where tipo=22; ERROR HY000: Lock wait timeout exceeded; try restarting transaction @@ -789,12 +787,10 @@ eta tipo c 70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk -** Cleanup -connection thread1; disconnect thread1; -connection thread2; disconnect thread2; connection default; drop table t1; drop user mysqltest@localhost; SET SQL_MODE=default; +SET GLOBAL innodb_lock_wait_timeout = @save_timeout; diff --git a/mysql-test/main/concurrent_innodb_safelog.test b/mysql-test/main/concurrent_innodb_safelog.test index 828df9ef717..7f6b3c328f2 100644 --- a/mysql-test/main/concurrent_innodb_safelog.test +++ b/mysql-test/main/concurrent_innodb_safelog.test @@ -16,8 +16,10 @@ let $engine_type= InnoDB; +SET @save_timeout = @@GLOBAL.innodb_lock_wait_timeout; +SET GLOBAL innodb_lock_wait_timeout = 1; SET GLOBAL TRANSACTION ISOLATION LEVEL REPEATABLE READ; -# innodb_locks_unsafe_for_binlog not set for this test --source include/concurrent.inc +SET GLOBAL innodb_lock_wait_timeout = @save_timeout; diff --git a/mysql-test/main/concurrent_innodb_unsafelog-master.opt b/mysql-test/main/concurrent_innodb_unsafelog-master.opt deleted file mode 100644 index ea9c1b860e9..00000000000 --- a/mysql-test/main/concurrent_innodb_unsafelog-master.opt +++ /dev/null @@ -1,2 +0,0 @@ ---loose-innodb_locks_unsafe_for_binlog ---loose-innodb_lock_wait_timeout=1 diff --git a/mysql-test/main/concurrent_innodb_unsafelog.result b/mysql-test/main/concurrent_innodb_unsafelog.result index 39e757aeeb1..9ae80328c0b 100644 --- a/mysql-test/main/concurrent_innodb_unsafelog.result +++ b/mysql-test/main/concurrent_innodb_unsafelog.result @@ -1,15 +1,14 @@ -SET GLOBAL TRANSACTION ISOLATION LEVEL REPEATABLE READ; +SET @save_timeout = @@GLOBAL.innodb_lock_wait_timeout; +SET GLOBAL innodb_lock_wait_timeout = 1; +SET @save_isolation = @@GLOBAL.tx_isolation; +SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED; connection default; SET SQL_MODE=""; SELECT @@global.tx_isolation; @@global.tx_isolation -REPEATABLE-READ -SELECT @@global.innodb_locks_unsafe_for_binlog; -@@global.innodb_locks_unsafe_for_binlog -1 +READ-COMMITTED # keep_locks == 0 GRANT USAGE ON test.* TO mysqltest@localhost; -drop table if exists t1; ** ** two UPDATE's running and both changing distinct result sets @@ -17,7 +16,7 @@ drop table if exists t1; connect thread1, localhost, mysqltest,,; connection thread1; ** Set up table -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; create table t1(eta int(11) not null, tipo int(11), c varchar(255)); insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); @@ -47,7 +46,7 @@ begin; ** Update on t1 will cause a table scan which will be blocked because ** the previously initiated table scan applied exclusive key locks on ** all primary keys. -** Not so if innodb_locks_unsafe_for_binlog is set. The locks that +** Not so for READ UNCOMMITTED or READ COMMITTED. The locks that ** do not match the WHERE condition are released. update t1 set eta=2 where tipo=22; ** Release user level name lock from thread 1. This will cause the ULL @@ -101,7 +100,7 @@ eta tipo c 60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh 70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 2 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj -90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk +1 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk ** And send final commit on thread 1. commit; ** Table should now be updated by both updates in the order of @@ -156,7 +155,7 @@ drop table t1; ** connection thread1; ** Set up table -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; create table t1(eta int(11) not null, tipo int(11), c varchar(255)); insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); @@ -186,7 +185,7 @@ begin; ** Update on t1 will cause a table scan which will be blocked because ** the previously initiated table scan applied exclusive key locks on ** all primary keys. -** Not so if innodb_locks_unsafe_for_binlog is set. The locks that +** Not so for READ UNCOMMITTED or READ COMMITTED. The locks that ** do not match the WHERE condition are released. update t1 set tipo=1 where tipo=2; ** Release ULL. This will release the next waiting ULL on thread 2. @@ -231,13 +230,13 @@ select * from t1; eta tipo c 7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb -10 1 ccccccccccccccccccccccccccccccccccccccccccc +1 1 ccccccccccccccccccccccccccccccccccccccccccc 20 1 ddddddddddddddddddddddddddddddddddddddddddd -30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee +1 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee 40 1 fffffffffffffffffffffffffffffffffffffffffff -50 1 ggggggggggggggggggggggggggggggggggggggggggg +1 1 ggggggggggggggggggggggggggggggggggggggggggg 60 1 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh -70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii +1 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk commit; @@ -293,7 +292,7 @@ drop table t1; ** connection thread1; ** Set up table -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; create table t1 (a int not null, b int not null); insert into t1 values (1,1),(2,1),(3,1),(4,1); ** Create ULL 'hello2' @@ -342,7 +341,7 @@ drop table t1; ** connection thread1; ** Set up table -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; create table t1(eta int(11) not null, tipo int(11), c varchar(255)); insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); @@ -445,7 +444,7 @@ drop table t1; ** connection thread1; ** Set up table -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; create table t1(eta int(11) not null, tipo int(11), c varchar(255)); insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); @@ -474,7 +473,7 @@ begin; ** Updating single row using a table scan. This will time out ** because of ongoing transaction on thread 1 holding lock on ** all primary keys in the scan. -** Not so if innodb_locks_unsafe_for_binlog is set. The locks that +** Not so for READ UNCOMMITTED or READ COMMITTED. The locks that ** do not match the WHERE condition are released. update t1 set tipo=11 where tipo=22; ** After the time out the transaction is aborted; no rows should @@ -548,7 +547,7 @@ drop table t1; ** connection thread1; ** Set up table -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; create table t1(eta int(11) not null, tipo int(11), c varchar(255)); insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); @@ -635,7 +634,7 @@ drop table t1; ** connection thread1; ** Set up table -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; create table t1(eta int(11) not null, tipo int(11), c varchar(255)); insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); @@ -712,7 +711,7 @@ drop table t1; ** connection thread1; ** Set up table -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; create table t1(eta int(11) not null, tipo int(11), c varchar(255)); insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); @@ -733,7 +732,7 @@ begin; ** Update on t1 will cause a table scan which will be blocked because ** the previously initiated table scan applied exclusive key locks on ** all primary keys. -** Not so if innodb_locks_unsafe_for_binlog is set. The locks that +** Not so for READ UNCOMMITTED or READ COMMITTED. The locks that ** do not match the WHERE condition are released. update t1 set tipo=1 where tipo=22; select * from t1; @@ -785,12 +784,11 @@ eta tipo c 70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 80 1 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk -** Cleanup -connection thread1; disconnect thread1; -connection thread2; disconnect thread2; connection default; drop table t1; drop user mysqltest@localhost; SET SQL_MODE=default; +SET GLOBAL innodb_lock_wait_timeout = @save_timeout; +SET GLOBAL tx_isolation = @save_isolation; diff --git a/mysql-test/main/concurrent_innodb_unsafelog.test b/mysql-test/main/concurrent_innodb_unsafelog.test index e2c03655e43..eee2295211e 100644 --- a/mysql-test/main/concurrent_innodb_unsafelog.test +++ b/mysql-test/main/concurrent_innodb_unsafelog.test @@ -16,8 +16,12 @@ let $engine_type= InnoDB; -SET GLOBAL TRANSACTION ISOLATION LEVEL REPEATABLE READ; -# innodb_locks_unsafe_for_binlog is set fro this test. +SET @save_timeout = @@GLOBAL.innodb_lock_wait_timeout; +SET GLOBAL innodb_lock_wait_timeout = 1; +SET @save_isolation = @@GLOBAL.tx_isolation; +SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED; --source include/concurrent.inc +SET GLOBAL innodb_lock_wait_timeout = @save_timeout; +SET GLOBAL tx_isolation = @save_isolation; diff --git a/mysql-test/main/crash_commit_before-master.opt b/mysql-test/main/crash_commit_before-master.opt index 9bcf94dca97..f464a1013d7 100644 --- a/mysql-test/main/crash_commit_before-master.opt +++ b/mysql-test/main/crash_commit_before-master.opt @@ -1,3 +1,3 @@ ---skip-stack-trace --skip-core-file +--loose-skip-stack-trace --skip-core-file --default-storage-engine=MyISAM --loose-skip-innodb-file-per-table diff --git a/mysql-test/main/create.result b/mysql-test/main/create.result index 39ede1f90b9..e6af42db1ff 100644 --- a/mysql-test/main/create.result +++ b/mysql-test/main/create.result @@ -26,8 +26,7 @@ create table t2 select auto+1 from t1; ERROR 42S02: Table 'test.t1' doesn't exist drop table if exists t1,t2; Warnings: -Note 1051 Unknown table 'test.t1' -Note 1051 Unknown table 'test.t2' +Note 1051 Unknown table 'test.t1,test.t2' create table t1 (b char(0) not null, index(b)); ERROR 42000: The storage engine MyISAM can't index column `b` create table t1 (a int not null,b text) engine=heap; @@ -255,9 +254,9 @@ select * from t1; if('2002'='2002','Y','N') Y drop table if exists t1; -SET SESSION storage_engine="heap"; -SELECT @@storage_engine; -@@storage_engine +SET SESSION default_storage_engine="heap"; +SELECT @@default_storage_engine; +@@default_storage_engine MEMORY CREATE TABLE t1 (a int not null); show create table t1; @@ -266,10 +265,10 @@ t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL ) ENGINE=MEMORY DEFAULT CHARSET=latin1 drop table t1; -SET SESSION storage_engine="gemini"; +SET SESSION default_storage_engine="gemini"; ERROR 42000: Unknown storage engine 'gemini' -SELECT @@storage_engine; -@@storage_engine +SELECT @@default_storage_engine; +@@default_storage_engine MEMORY CREATE TABLE t1 (a int not null); show create table t1; @@ -277,7 +276,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL ) ENGINE=MEMORY DEFAULT CHARSET=latin1 -SET SESSION storage_engine=default; +SET SESSION default_storage_engine=default; drop table t1; create table t1 ( k1 varchar(2), k2 int, primary key(k1,k2)); insert into t1 values ("a", 1), ("b", 2); @@ -419,9 +418,9 @@ create temporary table t3 like t2; ERROR HY000: Table 't2' was not locked with LOCK TABLES unlock tables; drop tables t1, t2; -SET SESSION storage_engine="heap"; -SELECT @@storage_engine; -@@storage_engine +SET SESSION default_storage_engine="heap"; +SELECT @@default_storage_engine; +@@default_storage_engine MEMORY CREATE TABLE t1 (a int not null); show create table t1; @@ -430,10 +429,10 @@ t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL ) ENGINE=MEMORY DEFAULT CHARSET=latin1 drop table t1; -SET SESSION storage_engine="gemini"; +SET SESSION default_storage_engine="gemini"; ERROR 42000: Unknown storage engine 'gemini' -SELECT @@storage_engine; -@@storage_engine +SELECT @@default_storage_engine; +@@default_storage_engine MEMORY CREATE TABLE t1 (a int not null); show create table t1; @@ -441,7 +440,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL ) ENGINE=MEMORY DEFAULT CHARSET=latin1 -SET SESSION storage_engine=default; +SET SESSION default_storage_engine=default; drop table t1; create table t1(a int,b int,c int unsigned,d date,e char,f datetime,g time,h blob); insert into t1(a)values(1); @@ -2049,3 +2048,6 @@ DROP TABLE t1; # # End of 10.4 tests # +CREATE TABLE t1 (id1 INT, id2 INT, primary key (id1), unique index (id2) visible); +drop table t1; +# End of 10.5 Test diff --git a/mysql-test/main/create.test b/mysql-test/main/create.test index adac81f02c5..5f84e282570 100644 --- a/mysql-test/main/create.test +++ b/mysql-test/main/create.test @@ -191,17 +191,17 @@ drop table if exists t1; # # Test default table type # -SET SESSION storage_engine="heap"; -SELECT @@storage_engine; +SET SESSION default_storage_engine="heap"; +SELECT @@default_storage_engine; CREATE TABLE t1 (a int not null); show create table t1; drop table t1; --error ER_UNKNOWN_STORAGE_ENGINE -SET SESSION storage_engine="gemini"; -SELECT @@storage_engine; +SET SESSION default_storage_engine="gemini"; +SELECT @@default_storage_engine; CREATE TABLE t1 (a int not null); show create table t1; -SET SESSION storage_engine=default; +SET SESSION default_storage_engine=default; drop table t1; @@ -349,17 +349,17 @@ drop tables t1, t2; # # Test default table type # -SET SESSION storage_engine="heap"; -SELECT @@storage_engine; +SET SESSION default_storage_engine="heap"; +SELECT @@default_storage_engine; CREATE TABLE t1 (a int not null); show create table t1; drop table t1; --error ER_UNKNOWN_STORAGE_ENGINE -SET SESSION storage_engine="gemini"; -SELECT @@storage_engine; +SET SESSION default_storage_engine="gemini"; +SELECT @@default_storage_engine; CREATE TABLE t1 (a int not null); show create table t1; -SET SESSION storage_engine=default; +SET SESSION default_storage_engine=default; drop table t1; # @@ -1905,3 +1905,12 @@ DROP TABLE t1; --echo # --echo # End of 10.4 tests --echo # + +# +# MDEV-22199 Add VISIBLE option for indexes in create table +# + +CREATE TABLE t1 (id1 INT, id2 INT, primary key (id1), unique index (id2) visible); +drop table t1; + +--echo # End of 10.5 Test diff --git a/mysql-test/main/create_drop_view.result b/mysql-test/main/create_drop_view.result index 9d7e42552bf..a62639545e1 100644 --- a/mysql-test/main/create_drop_view.result +++ b/mysql-test/main/create_drop_view.result @@ -52,8 +52,15 @@ id 50 80 40 +DROP TABLE IF EXISTS v1; +Warnings: +Note 1965 'test.v1' is a view DROP VIEW IF EXISTS v1; DROP VIEW IF EXISTS v1; Warnings: Note 4092 Unknown VIEW: 'test.v1' +DROP VIEW IF EXISTS t1; +Warnings: +Warning 1347 'test.t1' is not of type 'VIEW' +Note 4092 Unknown VIEW: 'test.t1' DROP TABLE t1; diff --git a/mysql-test/main/create_drop_view.test b/mysql-test/main/create_drop_view.test index 5f5df43a7e0..0ebf643e1f1 100644 --- a/mysql-test/main/create_drop_view.test +++ b/mysql-test/main/create_drop_view.test @@ -22,6 +22,8 @@ INSERT INTO t1 VALUES (50), (80), (3), (2), (40); SELECT * FROM t1; SELECT * FROM v1; +DROP TABLE IF EXISTS v1; DROP VIEW IF EXISTS v1; DROP VIEW IF EXISTS v1; +DROP VIEW IF EXISTS t1; DROP TABLE t1; diff --git a/mysql-test/main/create_or_replace.result b/mysql-test/main/create_or_replace.result index 485091e5810..1eaf87d190d 100644 --- a/mysql-test/main/create_or_replace.result +++ b/mysql-test/main/create_or_replace.result @@ -255,8 +255,7 @@ drop table t1,t3,t4; create database mysqltest2; drop table if exists test.t1,mysqltest2.t2; Warnings: -Note 1051 Unknown table 'test.t1' -Note 1051 Unknown table 'mysqltest2.t2' +Note 1051 Unknown table 'test.t1,mysqltest2.t2' create table test.t1 (i int) engine=myisam; create table mysqltest2.t2 like test.t1; lock table test.t1 write, mysqltest2.t2 write; diff --git a/mysql-test/main/cte_cycle.result b/mysql-test/main/cte_cycle.result new file mode 100644 index 00000000000..e7e0cc5f801 --- /dev/null +++ b/mysql-test/main/cte_cycle.result @@ -0,0 +1,156 @@ +# +# check errors +# +WITH RECURSIVE cte AS ( +SELECT 1 AS a UNION ALL +SELECT NULL FROM cte WHERE a IS NOT NULL) +CYCLE a, a RESTRICT +SELECT * FROM cte; +ERROR 42S21: Duplicate column name 'a' +WITH RECURSIVE cte AS ( +SELECT 1 AS a UNION ALL +SELECT NULL FROM cte WHERE a IS NOT NULL) +CYCLE b RESTRICT +SELECT * FROM cte; +ERROR 42S22: Unknown column 'b' in 'CYCLE clause' +WITH cte AS ( +SELECT 1 AS a UNION ALL +SELECT NULL FROM cte WHERE a IS NOT NULL) +CYCLE b RESTRICT +SELECT * FROM cte; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CYCLE b RESTRICT +SELECT * FROM cte' at line 4 +# +# A degenerate case +# +WITH RECURSIVE cte AS ( +SELECT 1 AS a, 2 as b) +CYCLE b RESTRICT +SELECT * FROM cte; +a b +1 2 +# +# A simple case +# +WITH RECURSIVE cte AS ( +SELECT 1 AS a, 2 as b UNION ALL +SELECT 2, 2 FROM cte WHERE a IS NOT NULL) +CYCLE b RESTRICT +SELECT * FROM cte; +a b +1 2 +# +# MDEV-20632 case (with fixed syntax) +# +create table t1 (from_ int, to_ int); +insert into t1 values (1,2), (1,100), (2,3), (3,4), (4,1); +WITH RECURSIVE cte (depth, from_, to_) as ( +SELECT 0,1,1 +UNION +SELECT depth+1, t1.from_, t1.to_ +FROM t1, cte WHERE t1.from_ = cte.to_ +) CYCLE from_, to_ RESTRICT +select * from cte; +depth from_ to_ +0 1 1 +1 1 2 +1 1 100 +2 2 3 +3 3 4 +4 4 1 +create view v1 as WITH RECURSIVE cte (depth, from_, to_) as ( +SELECT 0,1,1 +UNION +SELECT depth+1, t1.from_, t1.to_ +FROM t1, cte WHERE t1.from_ = cte.to_ +) CYCLE from_, to_ RESTRICT +select * from cte; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS with recursive cte(`depth`,`from_`,`to_`) as (select 0 AS `depth`,1 AS `from_`,1 AS `to_` union select `cte`.`depth` + 1 AS `depth+1`,`test`.`t1`.`from_` AS `from_`,`test`.`t1`.`to_` AS `to_` from (`test`.`t1` join `cte`) where `test`.`t1`.`from_` = `cte`.`to_`) CYCLE `from_`,`to_` RESTRICT select `cte`.`depth` AS `depth`,`cte`.`from_` AS `from_`,`cte`.`to_` AS `to_` from `cte` latin1 latin1_swedish_ci +select * from v1; +depth from_ to_ +0 1 1 +1 1 2 +1 1 100 +2 2 3 +3 3 4 +4 4 1 +delete from t1; +insert into t1 values (1,2), (1,NULL), (NULL,NULL), (NULL, 1); +select * from v1; +depth from_ to_ +0 1 1 +1 1 2 +1 1 NULL +drop view v1; +drop table t1; +# +# A simple blob case +# +create table t1 (a int, b text); +insert into t1 values (1, "a"); +WITH RECURSIVE cte AS ( +SELECT a, b from t1 UNION ALL +SELECT a, b FROM cte WHERE a IS NOT NULL) +CYCLE b RESTRICT +SELECT * FROM cte; +a b +1 a +drop table t1; +# +# check bit types +# +create table t1 (from_ bit(3), to_ bit(3)); +insert into t1 values (1,2), (1,7), (2,3), (3,4), (4,1); +WITH RECURSIVE cte (depth, from_, to_) as ( +SELECT 0,1,1 +UNION +SELECT depth+1, t1.from_, t1.to_ +FROM t1, cte WHERE t1.from_ = cte.to_ +) CYCLE from_, to_ RESTRICT +select * from cte; +depth from_ to_ +0 1 1 +1 1 2 +1 1 7 +2 2 3 +3 3 4 +4 4 1 +drop table t1; +# +# check bit types with BLOBs (TEXT) +# +create table t1 (from_ bit(3), to_ bit(3), load_ text); +insert into t1 values (1,2,"A"), (1,7,"A"), (2,3,"A"), (3,4,"A"), (4,1,"A"); +WITH RECURSIVE cte (depth, from_, to_, load_) as ( +SELECT 0,1,1,"A" + UNION +SELECT depth+1, t1.from_, t1.to_, t1.load_ +FROM t1, cte WHERE t1.from_ = cte.to_ +) CYCLE from_, to_, load_ RESTRICT +select * from cte; +depth from_ to_ load_ +0 1 1 A +1 1 2 A +1 1 7 A +2 2 3 A +3 3 4 A +4 4 1 A +insert into t1 values (4,1,"B"); +WITH RECURSIVE cte (depth, from_, to_, load_) as ( +SELECT 0,1,1,"A" + UNION +SELECT depth+1, t1.from_, t1.to_, t1.load_ +FROM t1, cte WHERE t1.from_ = cte.to_ +) CYCLE from_, to_, load_ RESTRICT +select * from cte; +depth from_ to_ load_ +0 1 1 A +1 1 2 A +1 1 7 A +2 2 3 A +3 3 4 A +4 4 1 A +4 4 1 B +drop table t1; diff --git a/mysql-test/main/cte_cycle.test b/mysql-test/main/cte_cycle.test new file mode 100644 index 00000000000..505980353fd --- /dev/null +++ b/mysql-test/main/cte_cycle.test @@ -0,0 +1,143 @@ + +--echo # +--echo # check errors +--echo # + +--error ER_DUP_FIELDNAME +WITH RECURSIVE cte AS ( + SELECT 1 AS a UNION ALL + SELECT NULL FROM cte WHERE a IS NOT NULL) + CYCLE a, a RESTRICT +SELECT * FROM cte; + +--error ER_BAD_FIELD_ERROR +WITH RECURSIVE cte AS ( + SELECT 1 AS a UNION ALL + SELECT NULL FROM cte WHERE a IS NOT NULL) + CYCLE b RESTRICT +SELECT * FROM cte; + +--error ER_PARSE_ERROR +WITH cte AS ( + SELECT 1 AS a UNION ALL + SELECT NULL FROM cte WHERE a IS NOT NULL) + CYCLE b RESTRICT +SELECT * FROM cte; + + +--echo # +--echo # A degenerate case +--echo # + +WITH RECURSIVE cte AS ( + SELECT 1 AS a, 2 as b) + CYCLE b RESTRICT +SELECT * FROM cte; + + +--echo # +--echo # A simple case +--echo # + +WITH RECURSIVE cte AS ( + SELECT 1 AS a, 2 as b UNION ALL + SELECT 2, 2 FROM cte WHERE a IS NOT NULL) + CYCLE b RESTRICT +SELECT * FROM cte; + + +--echo # +--echo # MDEV-20632 case (with fixed syntax) +--echo # + +create table t1 (from_ int, to_ int); +insert into t1 values (1,2), (1,100), (2,3), (3,4), (4,1); + +WITH RECURSIVE cte (depth, from_, to_) as ( + SELECT 0,1,1 + UNION + SELECT depth+1, t1.from_, t1.to_ + FROM t1, cte WHERE t1.from_ = cte.to_ +) CYCLE from_, to_ RESTRICT +select * from cte; + +create view v1 as WITH RECURSIVE cte (depth, from_, to_) as ( + SELECT 0,1,1 + UNION + SELECT depth+1, t1.from_, t1.to_ + FROM t1, cte WHERE t1.from_ = cte.to_ +) CYCLE from_, to_ RESTRICT +select * from cte; + +show create view v1; + +select * from v1; + +delete from t1; + +insert into t1 values (1,2), (1,NULL), (NULL,NULL), (NULL, 1); + +select * from v1; + +drop view v1; + +drop table t1; + + +--echo # +--echo # A simple blob case +--echo # + +create table t1 (a int, b text); +insert into t1 values (1, "a"); + +WITH RECURSIVE cte AS ( + SELECT a, b from t1 UNION ALL + SELECT a, b FROM cte WHERE a IS NOT NULL) + CYCLE b RESTRICT +SELECT * FROM cte; + +drop table t1; + +--echo # +--echo # check bit types +--echo # + +create table t1 (from_ bit(3), to_ bit(3)); +insert into t1 values (1,2), (1,7), (2,3), (3,4), (4,1); + +WITH RECURSIVE cte (depth, from_, to_) as ( + SELECT 0,1,1 + UNION + SELECT depth+1, t1.from_, t1.to_ + FROM t1, cte WHERE t1.from_ = cte.to_ +) CYCLE from_, to_ RESTRICT +select * from cte; +drop table t1; + +--echo # +--echo # check bit types with BLOBs (TEXT) +--echo # + +create table t1 (from_ bit(3), to_ bit(3), load_ text); +insert into t1 values (1,2,"A"), (1,7,"A"), (2,3,"A"), (3,4,"A"), (4,1,"A"); + +WITH RECURSIVE cte (depth, from_, to_, load_) as ( + SELECT 0,1,1,"A" + UNION + SELECT depth+1, t1.from_, t1.to_, t1.load_ + FROM t1, cte WHERE t1.from_ = cte.to_ +) CYCLE from_, to_, load_ RESTRICT +select * from cte; +insert into t1 values (4,1,"B"); +WITH RECURSIVE cte (depth, from_, to_, load_) as ( + SELECT 0,1,1,"A" + UNION + SELECT depth+1, t1.from_, t1.to_, t1.load_ + FROM t1, cte WHERE t1.from_ = cte.to_ +) CYCLE from_, to_, load_ RESTRICT +select * from cte; + +drop table t1; + + diff --git a/mysql-test/main/cte_nonrecursive.result b/mysql-test/main/cte_nonrecursive.result index 11101d7d0f1..17c73f74a49 100644 --- a/mysql-test/main/cte_nonrecursive.result +++ b/mysql-test/main/cte_nonrecursive.result @@ -606,7 +606,7 @@ with t(c) as (select a from t1 where b >= 'c') select * from t r1 where r1.c=4; show create view v3; View Create View character_set_client collation_connection -v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS with t(c) as (select `test`.`t1`.`a` AS `c` from `test`.`t1` where `test`.`t1`.`b` >= 'c')select `r1`.`c` AS `c` from `t` `r1` where `r1`.`c` = 4 latin1 latin1_swedish_ci +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS with t(`c`) as (select `test`.`t1`.`a` AS `c` from `test`.`t1` where `test`.`t1`.`b` >= 'c')select `r1`.`c` AS `c` from `t` `r1` where `r1`.`c` = 4 latin1 latin1_swedish_ci select * from v3; c 4 @@ -618,7 +618,7 @@ with t(c) as (select a from t1 where b >= 'c') select * from t r1, t r2 where r1.c=r2.c and r2.c=4; show create view v4; View Create View character_set_client collation_connection -v4 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v4` AS with t(c) as (select `test`.`t1`.`a` AS `c` from `test`.`t1` where `test`.`t1`.`b` >= 'c')select `r1`.`c` AS `c`,`r2`.`c` AS `d` from (`t` `r1` join `t` `r2`) where `r1`.`c` = `r2`.`c` and `r2`.`c` = 4 latin1 latin1_swedish_ci +v4 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v4` AS with t(`c`) as (select `test`.`t1`.`a` AS `c` from `test`.`t1` where `test`.`t1`.`b` >= 'c')select `r1`.`c` AS `c`,`r2`.`c` AS `d` from (`t` `r1` join `t` `r2`) where `r1`.`c` = `r2`.`c` and `r2`.`c` = 4 latin1 latin1_swedish_ci select * from v4; c d 4 4 @@ -1159,10 +1159,10 @@ with cte as union (select a from t1 where a < 2); a +1 4 5 7 -1 prepare stmt from "with cte as (select a from t1 where a between 4 and 7 group by a) (select a from cte where exists( select a from t1 where cte.a=t1.a )) @@ -1170,16 +1170,16 @@ union (select a from t1 where a < 2)"; execute stmt; a +1 4 5 7 -1 execute stmt; a +1 4 5 7 -1 deallocate prepare stmt; with cte as (select a from t1 where a between 4 and 7 group by a) @@ -1216,9 +1216,9 @@ union (select a from cte where exists( select a from t1 where cte.a=t1.a )); a 1 -7 -5 4 +5 +7 prepare stmt from "with cte as (select a from t1 where a between 4 and 7) (select a from t1 where a < 2) @@ -1227,15 +1227,15 @@ union execute stmt; a 1 -7 -5 4 +5 +7 execute stmt; a 1 -7 -5 4 +5 +7 deallocate prepare stmt; with cte as (select a from t1 where a between 4 and 7) @@ -1244,9 +1244,9 @@ where exists( select a from t1 where t1.a < 2 and cte.a=t1.a )) union (select a from cte where exists( select a from t1 where cte.a=t1.a )); a -7 -5 4 +5 +7 prepare stmt from "with cte as (select a from t1 where a between 4 and 7) (select a from cte @@ -1255,14 +1255,14 @@ union (select a from cte where exists( select a from t1 where cte.a=t1.a ))"; execute stmt; a -7 -5 4 +5 +7 execute stmt; a -7 -5 4 +5 +7 deallocate prepare stmt; drop table t1; # diff --git a/mysql-test/main/cte_nonrecursive.test b/mysql-test/main/cte_nonrecursive.test index e1be68563d2..8ab3bddc410 100644 --- a/mysql-test/main/cte_nonrecursive.test +++ b/mysql-test/main/cte_nonrecursive.test @@ -808,9 +808,12 @@ with cte as union (select a from t1 where a < 2); +--sorted_result eval $q1; eval prepare stmt from "$q1"; +--sorted_result execute stmt; +--sorted_result execute stmt; deallocate prepare stmt; @@ -821,9 +824,12 @@ with cte as union (select a from cte where exists( select a from t1 where cte.a=t1.a )); +--sorted_result eval $q2; eval prepare stmt from "$q2"; +--sorted_result execute stmt; +--sorted_result execute stmt; deallocate prepare stmt; @@ -834,9 +840,12 @@ with cte as union (select a from cte where exists( select a from t1 where cte.a=t1.a )); +--sorted_result eval $q3; eval prepare stmt from "$q3"; +--sorted_result execute stmt; +--sorted_result execute stmt; deallocate prepare stmt; @@ -848,9 +857,12 @@ with cte as union (select a from cte where exists( select a from t1 where cte.a=t1.a )); +--sorted_result eval $q4; eval prepare stmt from "$q4"; +--sorted_result execute stmt; +--sorted_result execute stmt; deallocate prepare stmt; diff --git a/mysql-test/main/cte_recursive.result b/mysql-test/main/cte_recursive.result index 72d8d5cc00e..478bd9a92a5 100644 --- a/mysql-test/main/cte_recursive.result +++ b/mysql-test/main/cte_recursive.result @@ -699,7 +699,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra NULL UNION RESULT <union3,4,5> ALL NULL NULL NULL NULL NULL NULL 2 DERIVED <derived3> ALL NULL NULL NULL NULL 12 100.00 Using where Warnings: -Note 1003 with recursive ancestor_couple_ids(h_id,w_id) as (/* select#2 */ select `a`.`father` AS `h_id`,`a`.`mother` AS `w_id` from `coupled_ancestors` `a` where `a`.`father` is not null and `a`.`mother` is not null), coupled_ancestors(id,name,dob,father,mother) as (/* select#3 */ select `test`.`folks`.`id` AS `id`,`test`.`folks`.`name` AS `name`,`test`.`folks`.`dob` AS `dob`,`test`.`folks`.`father` AS `father`,`test`.`folks`.`mother` AS `mother` from `test`.`folks` where `test`.`folks`.`name` = 'Me' union all /* select#4 */ select `test`.`p`.`id` AS `id`,`test`.`p`.`name` AS `name`,`test`.`p`.`dob` AS `dob`,`test`.`p`.`father` AS `father`,`test`.`p`.`mother` AS `mother` from `test`.`folks` `p` join `ancestor_couple_ids` `fa` where `test`.`p`.`id` = `fa`.`h_id` union all /* select#5 */ select `test`.`p`.`id` AS `id`,`test`.`p`.`name` AS `name`,`test`.`p`.`dob` AS `dob`,`test`.`p`.`father` AS `father`,`test`.`p`.`mother` AS `mother` from `test`.`folks` `p` join `ancestor_couple_ids` `ma` where `test`.`p`.`id` = `ma`.`w_id`)/* select#1 */ select `h`.`name` AS `name`,`h`.`dob` AS `dob`,`w`.`name` AS `name`,`w`.`dob` AS `dob` from `ancestor_couple_ids` `c` join `coupled_ancestors` `h` join `coupled_ancestors` `w` where `h`.`id` = `c`.`h_id` and `w`.`id` = `c`.`w_id` +Note 1003 with recursive ancestor_couple_ids(`h_id`,`w_id`) as (/* select#2 */ select `a`.`father` AS `h_id`,`a`.`mother` AS `w_id` from `coupled_ancestors` `a` where `a`.`father` is not null and `a`.`mother` is not null), coupled_ancestors(`id`,`name`,`dob`,`father`,`mother`) as (/* select#3 */ select `test`.`folks`.`id` AS `id`,`test`.`folks`.`name` AS `name`,`test`.`folks`.`dob` AS `dob`,`test`.`folks`.`father` AS `father`,`test`.`folks`.`mother` AS `mother` from `test`.`folks` where `test`.`folks`.`name` = 'Me' union all /* select#4 */ select `test`.`p`.`id` AS `id`,`test`.`p`.`name` AS `name`,`test`.`p`.`dob` AS `dob`,`test`.`p`.`father` AS `father`,`test`.`p`.`mother` AS `mother` from `test`.`folks` `p` join `ancestor_couple_ids` `fa` where `test`.`p`.`id` = `fa`.`h_id` union all /* select#5 */ select `test`.`p`.`id` AS `id`,`test`.`p`.`name` AS `name`,`test`.`p`.`dob` AS `dob`,`test`.`p`.`father` AS `father`,`test`.`p`.`mother` AS `mother` from `test`.`folks` `p` join `ancestor_couple_ids` `ma` where `test`.`p`.`id` = `ma`.`w_id`)/* select#1 */ select `h`.`name` AS `name`,`h`.`dob` AS `dob`,`w`.`name` AS `name`,`w`.`dob` AS `dob` from `ancestor_couple_ids` `c` join `coupled_ancestors` `h` join `coupled_ancestors` `w` where `h`.`id` = `c`.`h_id` and `w`.`id` = `c`.`w_id` # simple mutual recursion with recursive ancestor_couple_ids(h_id, w_id) @@ -2407,7 +2407,8 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 10, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "materialized": { @@ -2438,7 +2439,8 @@ ANALYZE "r_loops": 10, "rows": 2, "r_rows": 1, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 90, "attached_condition": "src.counter < 10" @@ -3091,7 +3093,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 4 DEPENDENT SUBQUERY <derived2> ALL NULL NULL NULL NULL 16 100.00 Using where NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: -Note 1003 with recursive destinations(city,legs) as (/* select#2 */ select `test`.`a`.`arrival` AS `city`,1 AS `legs` from `test`.`flights` `a` where `test`.`a`.`departure` = 'Cairo' union /* select#3 */ select `test`.`b`.`arrival` AS `arrival`,`r`.`legs` + 1 AS `r.legs + 1` from `destinations` `r` join `test`.`flights` `b` where `r`.`city` = `test`.`b`.`departure` and !<in_optimizer>(`test`.`b`.`arrival`,<exists>(/* select#4 */ select `destinations`.`city` from `destinations` where trigcond(`test`.`b`.`arrival` = `destinations`.`city` or `destinations`.`city` is null) having trigcond(`destinations`.`city` is null))))/* select#1 */ select `destinations`.`city` AS `city`,`destinations`.`legs` AS `legs` from `destinations` +Note 1003 with recursive destinations(`city`,`legs`) as (/* select#2 */ select `test`.`a`.`arrival` AS `city`,1 AS `legs` from `test`.`flights` `a` where `test`.`a`.`departure` = 'Cairo' union /* select#3 */ select `test`.`b`.`arrival` AS `arrival`,`r`.`legs` + 1 AS `r.legs + 1` from `destinations` `r` join `test`.`flights` `b` where `r`.`city` = `test`.`b`.`departure` and !(<in_optimizer>(`test`.`b`.`arrival`,<exists>(/* select#4 */ select `destinations`.`city` from `destinations` where trigcond(`test`.`b`.`arrival` = `destinations`.`city` or `destinations`.`city` is null) having trigcond(`destinations`.`city` is null)))))/* select#1 */ select `destinations`.`city` AS `city`,`destinations`.`legs` AS `legs` from `destinations` set standard_compliant_cte=default; drop table flights; # @@ -3110,7 +3112,7 @@ SELECT * FROM cte; # # MDEV-15575: using recursive cte with big_tables enabled # -set big_tables=1; +set tmp_memory_table_size=0; with recursive qn as (select 123 as a union all select 1+a from qn where a<130) select * from qn; @@ -3123,13 +3125,13 @@ a 128 129 130 -set big_tables=default; +set tmp_memory_table_size=default; # # MDEV-15571: using recursive cte with big_tables enabled # create table t1 (a bigint); insert into t1 values(1); -set big_tables=1; +set tmp_memory_table_size=0; with recursive qn as ( select a from t1 @@ -3138,13 +3140,13 @@ select a*2000 from qn where a<10000000000000000000 ) select * from qn; ERROR 22003: BIGINT value is out of range in '`qn`.`a` * 2000' -set big_tables=default; +set tmp_memory_table_size=default; drop table t1; # # MDEV-15556: using recursive cte with big_tables enabled # when recursive tables are accessed by key # -SET big_tables=1; +set tmp_memory_table_size=0; CREATE TABLE t1 (id int, name char(10), leftpar int, rightpar int); INSERT INTO t1 VALUES (1, "A", 2, 3), (2, "LA", 4, 5), (4, "LLA", 6, 7), @@ -3195,7 +3197,7 @@ id select_type table type possible_keys key key_len ref rows Extra 4 RECURSIVE UNION <derived2> ref key0 key0 5 test.t2.id 2 NULL UNION RESULT <union2,3,4> ALL NULL NULL NULL NULL NULL DROP TABLE t1,t2; -SET big_tables=0; +set tmp_memory_table_size=default; # # MDEV-15840: recursive tables are accessed by key # (the same problem as for MDEV-15556) @@ -3378,7 +3380,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL 5 DERIVED <derived2> ALL NULL NULL NULL NULL 2 100.00 Using where 5 DERIVED t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) Warnings: -Note 1003 with recursive rcte(a) as (/* select#2 */ select 1 AS `a` union /* select#3 */ select cast(`rcte`.`a` + 1 as unsigned) AS `cast(a+1 as unsigned)` from `rcte` where `rcte`.`a` < 10), cte1 as (/* select#4 */ select count(0) AS `c1` from `rcte` join `test`.`t1` where `rcte`.`a` between 3 and 5 and `test`.`t1`.`id` = `rcte`.`a` - 3), cte2 as (/* select#5 */ select count(0) AS `c2` from `rcte` join `test`.`t1` where `rcte`.`a` between 7 and 8 and `test`.`t1`.`id` = `rcte`.`a` - 7)/* select#1 */ select `cte1`.`c1` AS `c1`,`cte2`.`c2` AS `c2` from `cte1` join `cte2` +Note 1003 with recursive rcte(`a`) as (/* select#2 */ select 1 AS `a` union /* select#3 */ select cast(`rcte`.`a` + 1 as unsigned) AS `cast(a+1 as unsigned)` from `rcte` where `rcte`.`a` < 10), cte1 as (/* select#4 */ select count(0) AS `c1` from `rcte` join `test`.`t1` where `rcte`.`a` between 3 and 5 and `test`.`t1`.`id` = `rcte`.`a` - 3), cte2 as (/* select#5 */ select count(0) AS `c2` from `rcte` join `test`.`t1` where `rcte`.`a` between 7 and 8 and `test`.`t1`.`id` = `rcte`.`a` - 7)/* select#1 */ select `cte1`.`c1` AS `c1`,`cte2`.`c2` AS `c2` from `cte1` join `cte2` prepare stmt from "with recursive rcte(a) as (select 1 union select cast(a+1 as unsigned) from rcte where a < 10), @@ -3464,7 +3466,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL 4 DERIVED <derived2> ALL NULL NULL NULL NULL 2 100.00 Using where 4 DERIVED t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) Warnings: -Note 1003 with recursive rcte(a) as (/* select#2 */ select 1 AS `a` union /* select#3 */ select cast(`rcte`.`a` + 1 as unsigned) AS `cast(a+1 as unsigned)` from `rcte` where `rcte`.`a` < 10), cte1 as (/* select#4 */ select count(0) AS `c1` from `rcte` join `test`.`t1` where `rcte`.`a` between 3 and 5 and `test`.`t1`.`id` = `rcte`.`a` - 3), cte2 as (/* select#5 */ select count(0) AS `c2` from `rcte` join `test`.`t1` where `rcte`.`a` between 7 and 8 and `test`.`t1`.`id` = `rcte`.`a` - 7)/* select#1 */ select `cte2`.`c2` AS `c2`,`cte1`.`c1` AS `c1` from `cte2` join `cte1` +Note 1003 with recursive rcte(`a`) as (/* select#2 */ select 1 AS `a` union /* select#3 */ select cast(`rcte`.`a` + 1 as unsigned) AS `cast(a+1 as unsigned)` from `rcte` where `rcte`.`a` < 10), cte1 as (/* select#4 */ select count(0) AS `c1` from `rcte` join `test`.`t1` where `rcte`.`a` between 3 and 5 and `test`.`t1`.`id` = `rcte`.`a` - 3), cte2 as (/* select#5 */ select count(0) AS `c2` from `rcte` join `test`.`t1` where `rcte`.`a` between 7 and 8 and `test`.`t1`.`id` = `rcte`.`a` - 7)/* select#1 */ select `cte2`.`c2` AS `c2`,`cte1`.`c1` AS `c1` from `cte2` join `cte1` prepare stmt from "with recursive rcte(a) as (select 1 union select cast(a+1 as unsigned) from rcte where a < 10), @@ -3780,9 +3782,8 @@ where (dt.a1) in (with recursive cte as (select a2 from t2 where a2='2' union select tt2.a2 from t2 tt2 join cte on tt2.b1=cte.a2) select a2 from cte); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 -1 PRIMARY <subquery5> eq_ref distinct_key distinct_key 23 func 1 -5 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 2 +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY <derived3> ref key0 key0 23 test.t1.a1 1 FirstMatch(t1) 3 DERIVED t2 const PRIMARY PRIMARY 22 const 1 Using index 4 RECURSIVE UNION <derived3> ALL NULL NULL NULL NULL 2 Using where 4 RECURSIVE UNION tt2 ref b1 b1 23 cte.a2 2 @@ -3798,112 +3799,101 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "const_condition": "1", "table": { "table_name": "t1", "access_type": "ALL", "r_loops": 1, "rows": 3, "r_rows": 3, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, - "r_filtered": 100 + "r_filtered": 100, + "attached_condition": "t1.a1 is not null" }, "table": { - "table_name": "<subquery5>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", + "table_name": "<derived3>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", "key_length": "23", "used_key_parts": ["a2"], - "ref": ["func"], + "ref": ["test.t1.a1"], "r_loops": 3, "rows": 1, - "r_rows": 0.3333, - "r_total_time_ms": "REPLACED", + "r_rows": 0.333333333, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, + "first_match": "t1", "materialized": { - "unique": 1, "query_block": { - "select_id": 5, - "table": { - "table_name": "<derived3>", + "recursive_union": { + "table_name": "<union3,4>", "access_type": "ALL", - "r_loops": 1, - "rows": 2, - "r_rows": 1, - "r_total_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "materialized": { - "query_block": { - "recursive_union": { - "table_name": "<union3,4>", - "access_type": "ALL", - "r_loops": 0, - "r_rows": null, - "query_specifications": [ - { - "query_block": { - "select_id": 3, - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t2", - "access_type": "const", - "possible_keys": ["PRIMARY"], - "key": "PRIMARY", - "key_length": "22", - "used_key_parts": ["a2"], - "ref": ["const"], - "r_loops": 0, - "rows": 1, - "r_rows": null, - "filtered": 100, - "r_filtered": null, - "using_index": true - } - } - }, - { - "query_block": { - "select_id": 4, - "operation": "UNION", - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "r_loops": 1, - "rows": 2, - "r_rows": 1, - "r_total_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "attached_condition": "cte.a2 is not null" - }, - "table": { - "table_name": "tt2", - "access_type": "ref", - "possible_keys": ["b1"], - "key": "b1", - "key_length": "23", - "used_key_parts": ["b1"], - "ref": ["cte.a2"], - "r_loops": 1, - "rows": 2, - "r_rows": 1, - "r_total_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - } - } - } - ] + "r_loops": 0, + "r_rows": null, + "query_specifications": [ + { + "query_block": { + "select_id": 3, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "t2", + "access_type": "const", + "possible_keys": ["PRIMARY"], + "key": "PRIMARY", + "key_length": "22", + "used_key_parts": ["a2"], + "ref": ["const"], + "r_loops": 0, + "rows": 1, + "r_rows": null, + "filtered": 100, + "r_filtered": null, + "using_index": true + } + } + }, + { + "query_block": { + "select_id": 4, + "operation": "UNION", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "r_loops": 1, + "rows": 2, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "attached_condition": "cte.a2 is not null" + }, + "table": { + "table_name": "tt2", + "access_type": "ref", + "possible_keys": ["b1"], + "key": "b1", + "key_length": "23", + "used_key_parts": ["b1"], + "ref": ["cte.a2"], + "r_loops": 1, + "rows": 2, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } } } - } + ] } } } @@ -4075,7 +4065,8 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 4, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "materialized": { @@ -4097,7 +4088,8 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 4, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 } @@ -4115,7 +4107,8 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 4, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "attached_condition": "t1.c is not null" @@ -4131,7 +4124,8 @@ ANALYZE "r_loops": 4, "rows": 2, "r_rows": 0.5, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 } @@ -4209,7 +4203,8 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 4, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 } @@ -4285,6 +4280,8 @@ use test; # set @save_big_tables=@@big_tables; set big_tables=1; +Warnings: +Warning 1287 '@@big_tables' is deprecated and will be removed in a future release create table folks(id int, name char(32), dob date, father int, mother int); insert into folks values (100, 'Me', '2000-01-01', 20, 30), @@ -4459,9 +4456,9 @@ id select_type table type possible_keys key key_len ref rows Extra 4 RECURSIVE UNION <derived2> ALL NULL NULL NULL NULL 2 5 RECURSIVE UNION <derived2> ALL NULL NULL NULL NULL 2 NULL UNION RESULT <union3,4,5> ALL NULL NULL NULL NULL NULL -2 DERIVED h ALL NULL NULL NULL NULL 12 Using where -2 DERIVED <derived3> ref key0 key0 5 test.h.id 2 -2 DERIVED w ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) +2 DERIVED h ALL NULL NULL NULL NULL 12 +2 DERIVED w ALL NULL NULL NULL NULL 12 Using join buffer (flat, BNL join) +2 DERIVED <derived3> ALL NULL NULL NULL NULL 12 Using where; Using join buffer (incremental, BNL join) prepare stmt from "with recursive ancestor_couples(h_id, h_name, h_dob, h_father, h_mother, w_id, w_name, w_dob, w_father, w_mother) @@ -4499,6 +4496,8 @@ Grandpa Ben 1940-10-21 Grandma Sally 1943-08-23 deallocate prepare stmt; drop table folks; set big_tables=@save_big_tables; +Warnings: +Warning 1287 '@@big_tables' is deprecated and will be removed in a future release # # MDEV-26135: execution of PS for query with hanging recursive CTE # diff --git a/mysql-test/main/cte_recursive.test b/mysql-test/main/cte_recursive.test index 8ac6f841f6e..f8c41dbc3ea 100644 --- a/mysql-test/main/cte_recursive.test +++ b/mysql-test/main/cte_recursive.test @@ -2138,13 +2138,13 @@ SELECT * FROM cte; --echo # MDEV-15575: using recursive cte with big_tables enabled --echo # -set big_tables=1; +set tmp_memory_table_size=0; # force on-disk tmp table with recursive qn as (select 123 as a union all select 1+a from qn where a<130) select * from qn; -set big_tables=default; +set tmp_memory_table_size=default; --echo # --echo # MDEV-15571: using recursive cte with big_tables enabled @@ -2153,7 +2153,7 @@ set big_tables=default; create table t1 (a bigint); insert into t1 values(1); -set big_tables=1; +set tmp_memory_table_size=0; # force on-disk tmp table --error ER_DATA_OUT_OF_RANGE with recursive qn as @@ -2164,7 +2164,7 @@ with recursive qn as ) select * from qn; -set big_tables=default; +set tmp_memory_table_size=default; drop table t1; @@ -2173,7 +2173,7 @@ drop table t1; --echo # when recursive tables are accessed by key --echo # -SET big_tables=1; +set tmp_memory_table_size=0; # force on-disk tmp table CREATE TABLE t1 (id int, name char(10), leftpar int, rightpar int); INSERT INTO t1 VALUES @@ -2202,7 +2202,7 @@ eval EXPLAIN $q; DROP TABLE t1,t2; -SET big_tables=0; +set tmp_memory_table_size=default; --echo # --echo # MDEV-15840: recursive tables are accessed by key diff --git a/mysql-test/main/ctype_big5.result b/mysql-test/main/ctype_big5.result index 8895e2d89df..41ce8f0b82e 100644 --- a/mysql-test/main/ctype_big5.result +++ b/mysql-test/main/ctype_big5.result @@ -4827,7 +4827,7 @@ DROP TABLE t1; # MDEV-9711 NO PAD Collatons # SET character_set_connection=big5; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -4965,7 +4965,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -5103,8 +5103,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -5242,7 +5242,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -5380,7 +5380,65 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; # # End of 10.2 tests # +# +# Start of 10.5 tests +# +# +# MDEV-22625 SIGSEGV in intern_find_sys_var (optimized builds) +# +SET NAMES big5; +SET @seq=_big5 0xA3C0; +# +# SET STATEMENT (bad|good.bad|bad.good)=1 +# +EXECUTE IMMEDIATE CONCAT('SET STATEMENT ',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid big5 character string: '\xA3\xC0' +EXECUTE IMMEDIATE CONCAT('SET STATEMENT ',@seq, '.a=1 SELECT 1'); +ERROR HY000: Invalid big5 character string: '\xA3\xC0' +EXECUTE IMMEDIATE CONCAT('SET STATEMENT a.',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid big5 character string: '\xA3\xC0' +# +# SET SESSION (bad|good.bad|bad.good)=1 +# +EXECUTE IMMEDIATE CONCAT('SET SESSION ',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid big5 character string: '\xA3\xC0' +EXECUTE IMMEDIATE CONCAT('SET SESSION ',@seq, '.a=1 SELECT 1'); +ERROR HY000: Invalid big5 character string: '\xA3\xC0' +EXECUTE IMMEDIATE CONCAT('SET SESSION a.',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid big5 character string: '\xA3\xC0' +# +# SET (bad|good.bad|bad.good)=1 +# +EXECUTE IMMEDIATE CONCAT('SET ', @seq, '=1'); +ERROR HY000: Invalid big5 character string: '\xA3\xC0' +EXECUTE IMMEDIATE CONCAT('SET ', @seq, '.a=1'); +ERROR HY000: Invalid big5 character string: '\xA3\xC0' +EXECUTE IMMEDIATE CONCAT('SET a.', @seq, '=1'); +ERROR HY000: Invalid big5 character string: '\xA3\xC0' +# +# Oracle SP call: BEGIN (bad|good.bad|bad.good)(params); END +# +SET sql_mode=ORACLE; +EXECUTE IMMEDIATE CONCAT('BEGIN ',@seq, '(1); END;'); +ERROR HY000: Invalid big5 character string: '\xA3\xC0' +EXECUTE IMMEDIATE CONCAT('BEGIN ',@seq, '.a(1); END;'); +ERROR HY000: Invalid big5 character string: '\xA3\xC0' +EXECUTE IMMEDIATE CONCAT('BEGIN a.',@seq, '(1); END;'); +ERROR HY000: Invalid big5 character string: '\xA3\xC0' +# +# Oracle assignment: (bad|good.bad|bad.good):= value +# +EXECUTE IMMEDIATE CONCAT(@seq, ':=1'); +ERROR HY000: Invalid big5 character string: '\xA3\xC0' +EXECUTE IMMEDIATE CONCAT(@seq, '.a:=1'); +ERROR HY000: Invalid big5 character string: '\xA3\xC0' +EXECUTE IMMEDIATE CONCAT('a.', @seq, ':=1'); +ERROR HY000: Invalid big5 character string: '\xA3\xC0' +SET sql_mode=DEFAULT; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/ctype_big5.test b/mysql-test/main/ctype_big5.test index 410203c7c86..41991258886 100644 --- a/mysql-test/main/ctype_big5.test +++ b/mysql-test/main/ctype_big5.test @@ -269,3 +269,20 @@ let $coll_pad='big5_bin'; --echo # --echo # End of 10.2 tests --echo # + + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-22625 SIGSEGV in intern_find_sys_var (optimized builds) +--echo # + +SET NAMES big5; +SET @seq=_big5 0xA3C0; +--source include/ctype_ident_sys.inc + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/ctype_binary.result b/mysql-test/main/ctype_binary.result index 97f970a9e49..05f31f13dc7 100644 --- a/mysql-test/main/ctype_binary.result +++ b/mysql-test/main/ctype_binary.result @@ -1,7 +1,4 @@ set names binary; -# -# Start of 5.5 tests -# SET TIME_ZONE = _latin1 '+03:00'; # # Start of WL#2649 Number-to-string conversions @@ -809,12 +806,12 @@ create table t1 as select concat(uuid()) as c1; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `c1` varchar(36) CHARACTER SET utf8 DEFAULT NULL + `c1` varbinary(36) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; select coercibility(uuid()), coercibility(cast('a' as char character set latin1)); coercibility(uuid()) coercibility(cast('a' as char character set latin1)) -4 2 +5 2 select charset(concat(uuid(), cast('a' as char character set latin1))); charset(concat(uuid(), cast('a' as char character set latin1))) latin1 @@ -2927,9 +2924,6 @@ SET sql_mode=default; # # End of 5.5 tests # -# -# Start of 10.0 tests -# SET NAMES binary; # # MDEV-7149 Constant condition propagation erroneously applied for LIKE @@ -3077,9 +3071,6 @@ SET optimizer_switch=@save_optimizer_switch; # End of 10.0 tests # # -# Start of 10.1 tests -# -# # MDEV-8695 Wrong result for SELECT..WHERE varchar_column='a' AND CRC32(varchar_column)=3904355907 # CREATE TABLE t1 (a VARBINARY(10)); @@ -3270,9 +3261,6 @@ ERROR HY000: Incorrect information in file: 'DIR/t1.frm' # End of 10.1 tests # # -# Start of 10.2 tests -# -# # MDEV-22111 ERROR 1064 & 1033 and SIGSEGV on CREATE TABLE w/ various charsets on 10.4/5 optimized builds | Assertion `(uint) (table_check_constraints - share->check_constraints) == (uint) (share->table_check_constraints - share->field_check_constraints)' failed # 10.2 tests # @@ -3318,3 +3306,29 @@ DROP TABLE t1; # # End of 10.2 tests # +# +# Start of 10.5 tests +# +# +# MDEV-8844 Unreadable control characters printed as is in warnings +# +SET NAMES binary; +CREATE TABLE t1 (a VARCHAR(20) CHARACTER SET latin1, UNIQUE(a)); +INSERT INTO t1 VALUES (0x61000162FF); +INSERT INTO t1 VALUES (0x61000162FF); +ERROR 23000: Duplicate entry 'a\0000\0001bÿ' for key 'a' +INSERT IGNORE INTO t1 VALUES (0x61000162FF); +Warnings: +Warning 1062 Duplicate entry 'a\0000\0001bÿ' for key 'a' +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(20) CHARACTER SET utf8, UNIQUE(a)); +INSERT INTO t1 VALUES (_latin1 0x61000162FF); +INSERT INTO t1 VALUES (_latin1 0x61000162FF); +ERROR 23000: Duplicate entry 'a\0000\0001bÿ' for key 'a' +INSERT IGNORE INTO t1 VALUES (_latin1 0x61000162FF); +Warnings: +Warning 1062 Duplicate entry 'a\0000\0001bÿ' for key 'a' +DROP TABLE t1; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/ctype_binary.test b/mysql-test/main/ctype_binary.test index b871a41309b..3cf184576b4 100644 --- a/mysql-test/main/ctype_binary.test +++ b/mysql-test/main/ctype_binary.test @@ -1,10 +1,6 @@ set names binary; ---echo # ---echo # Start of 5.5 tests ---echo # - --source include/ctype_numconv.inc --echo # @@ -12,10 +8,6 @@ set names binary; --echo # ---echo # ---echo # Start of 10.0 tests ---echo # - SET NAMES binary; --source include/ctype_like_cond_propagation.inc @@ -32,10 +24,6 @@ SET NAMES utf8, character_set_connection=binary; --echo # --echo # ---echo # Start of 10.1 tests ---echo # - ---echo # --echo # MDEV-8695 Wrong result for SELECT..WHERE varchar_column='a' AND CRC32(varchar_column)=3904355907 --echo # CREATE TABLE t1 (a VARBINARY(10)); @@ -139,10 +127,6 @@ CREATE TABLE t1 (a ENUM('a',0x0061), b ENUM('b')); --echo # --echo # ---echo # Start of 10.2 tests ---echo # - ---echo # --echo # MDEV-22111 ERROR 1064 & 1033 and SIGSEGV on CREATE TABLE w/ various charsets on 10.4/5 optimized builds | Assertion `(uint) (table_check_constraints - share->check_constraints) == (uint) (share->table_check_constraints - share->field_check_constraints)' failed --echo # 10.2 tests --echo # @@ -169,12 +153,33 @@ INSERT INTO t1 VALUES (1); SELECT HEX(c) FROM t1; DROP TABLE t1; +--echo # +--echo # End of 10.2 tests +--echo # +--echo # +--echo # Start of 10.5 tests +--echo # +--echo # +--echo # MDEV-8844 Unreadable control characters printed as is in warnings +--echo # +SET NAMES binary; +CREATE TABLE t1 (a VARCHAR(20) CHARACTER SET latin1, UNIQUE(a)); +INSERT INTO t1 VALUES (0x61000162FF); +--error ER_DUP_ENTRY +INSERT INTO t1 VALUES (0x61000162FF); +INSERT IGNORE INTO t1 VALUES (0x61000162FF); +DROP TABLE t1; - +CREATE TABLE t1 (a VARCHAR(20) CHARACTER SET utf8, UNIQUE(a)); +INSERT INTO t1 VALUES (_latin1 0x61000162FF); +--error ER_DUP_ENTRY +INSERT INTO t1 VALUES (_latin1 0x61000162FF); +INSERT IGNORE INTO t1 VALUES (_latin1 0x61000162FF); +DROP TABLE t1; --echo # ---echo # End of 10.2 tests +--echo # End of 10.5 tests --echo # diff --git a/mysql-test/main/ctype_cp1251.result b/mysql-test/main/ctype_cp1251.result index b0e6e1e6506..7d9b47f1f54 100644 --- a/mysql-test/main/ctype_cp1251.result +++ b/mysql-test/main/ctype_cp1251.result @@ -1218,12 +1218,12 @@ create table t1 as select concat(uuid()) as c1; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `c1` varchar(36) CHARACTER SET utf8 DEFAULT NULL + `c1` varchar(36) CHARACTER SET cp1251 DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; select coercibility(uuid()), coercibility(cast('a' as char character set latin1)); coercibility(uuid()) coercibility(cast('a' as char character set latin1)) -4 2 +5 2 select charset(concat(uuid(), cast('a' as char character set latin1))); charset(concat(uuid(), cast('a' as char character set latin1))) latin1 diff --git a/mysql-test/main/ctype_cp932.result b/mysql-test/main/ctype_cp932.result index eb714e9f8d7..952130cf11c 100644 --- a/mysql-test/main/ctype_cp932.result +++ b/mysql-test/main/ctype_cp932.result @@ -40,7 +40,7 @@ SET @@character_set_results= @old_character_set_results; # MDEV-9711 NO PAD Collatons # SET character_set_connection=cp932; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -178,7 +178,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -316,8 +316,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -455,7 +455,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -593,7 +593,65 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; # # End of 10.2 tests # +# +# Start of 10.5 tests +# +# +# MDEV-22625 SIGSEGV in intern_find_sys_var (optimized builds) +# +SET NAMES cp932; +SET @seq=_cp932 0x81AD; +# +# SET STATEMENT (bad|good.bad|bad.good)=1 +# +EXECUTE IMMEDIATE CONCAT('SET STATEMENT ',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid cp932 character string: '\x81\xAD' +EXECUTE IMMEDIATE CONCAT('SET STATEMENT ',@seq, '.a=1 SELECT 1'); +ERROR HY000: Invalid cp932 character string: '\x81\xAD' +EXECUTE IMMEDIATE CONCAT('SET STATEMENT a.',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid cp932 character string: '\x81\xAD' +# +# SET SESSION (bad|good.bad|bad.good)=1 +# +EXECUTE IMMEDIATE CONCAT('SET SESSION ',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid cp932 character string: '\x81\xAD' +EXECUTE IMMEDIATE CONCAT('SET SESSION ',@seq, '.a=1 SELECT 1'); +ERROR HY000: Invalid cp932 character string: '\x81\xAD' +EXECUTE IMMEDIATE CONCAT('SET SESSION a.',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid cp932 character string: '\x81\xAD' +# +# SET (bad|good.bad|bad.good)=1 +# +EXECUTE IMMEDIATE CONCAT('SET ', @seq, '=1'); +ERROR HY000: Invalid cp932 character string: '\x81\xAD' +EXECUTE IMMEDIATE CONCAT('SET ', @seq, '.a=1'); +ERROR HY000: Invalid cp932 character string: '\x81\xAD' +EXECUTE IMMEDIATE CONCAT('SET a.', @seq, '=1'); +ERROR HY000: Invalid cp932 character string: '\x81\xAD' +# +# Oracle SP call: BEGIN (bad|good.bad|bad.good)(params); END +# +SET sql_mode=ORACLE; +EXECUTE IMMEDIATE CONCAT('BEGIN ',@seq, '(1); END;'); +ERROR HY000: Invalid cp932 character string: '\x81\xAD' +EXECUTE IMMEDIATE CONCAT('BEGIN ',@seq, '.a(1); END;'); +ERROR HY000: Invalid cp932 character string: '\x81\xAD' +EXECUTE IMMEDIATE CONCAT('BEGIN a.',@seq, '(1); END;'); +ERROR HY000: Invalid cp932 character string: '\x81\xAD' +# +# Oracle assignment: (bad|good.bad|bad.good):= value +# +EXECUTE IMMEDIATE CONCAT(@seq, ':=1'); +ERROR HY000: Invalid cp932 character string: '\x81\xAD' +EXECUTE IMMEDIATE CONCAT(@seq, '.a:=1'); +ERROR HY000: Invalid cp932 character string: '\x81\xAD' +EXECUTE IMMEDIATE CONCAT('a.', @seq, ':=1'); +ERROR HY000: Invalid cp932 character string: '\x81\xAD' +SET sql_mode=DEFAULT; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/ctype_cp932.test b/mysql-test/main/ctype_cp932.test index 2486ca8a79e..0f5ff437d33 100644 --- a/mysql-test/main/ctype_cp932.test +++ b/mysql-test/main/ctype_cp932.test @@ -47,3 +47,20 @@ let $coll_pad='cp932_bin'; --echo # --echo # End of 10.2 tests --echo # + + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-22625 SIGSEGV in intern_find_sys_var (optimized builds) +--echo # + +SET NAMES cp932; +SET @seq=_cp932 0x81AD; +--source include/ctype_ident_sys.inc + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/ctype_dec8.result b/mysql-test/main/ctype_dec8.result new file mode 100644 index 00000000000..f0522494bb2 --- /dev/null +++ b/mysql-test/main/ctype_dec8.result @@ -0,0 +1,58 @@ +# +# Start of 10.5 tests +# +# +# MDEV-22625 SIGSEGV in intern_find_sys_var (optimized builds) +# +SET NAMES dec8; +SET @seq=_dec8 0xD0; +# +# SET STATEMENT (bad|good.bad|bad.good)=1 +# +EXECUTE IMMEDIATE CONCAT('SET STATEMENT ',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid dec8 character string: '\xD0' +EXECUTE IMMEDIATE CONCAT('SET STATEMENT ',@seq, '.a=1 SELECT 1'); +ERROR HY000: Invalid dec8 character string: '\xD0' +EXECUTE IMMEDIATE CONCAT('SET STATEMENT a.',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid dec8 character string: '\xD0' +# +# SET SESSION (bad|good.bad|bad.good)=1 +# +EXECUTE IMMEDIATE CONCAT('SET SESSION ',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid dec8 character string: '\xD0' +EXECUTE IMMEDIATE CONCAT('SET SESSION ',@seq, '.a=1 SELECT 1'); +ERROR HY000: Invalid dec8 character string: '\xD0' +EXECUTE IMMEDIATE CONCAT('SET SESSION a.',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid dec8 character string: '\xD0' +# +# SET (bad|good.bad|bad.good)=1 +# +EXECUTE IMMEDIATE CONCAT('SET ', @seq, '=1'); +ERROR HY000: Invalid dec8 character string: '\xD0' +EXECUTE IMMEDIATE CONCAT('SET ', @seq, '.a=1'); +ERROR HY000: Invalid dec8 character string: '\xD0' +EXECUTE IMMEDIATE CONCAT('SET a.', @seq, '=1'); +ERROR HY000: Invalid dec8 character string: '\xD0' +# +# Oracle SP call: BEGIN (bad|good.bad|bad.good)(params); END +# +SET sql_mode=ORACLE; +EXECUTE IMMEDIATE CONCAT('BEGIN ',@seq, '(1); END;'); +ERROR HY000: Invalid dec8 character string: '\xD0' +EXECUTE IMMEDIATE CONCAT('BEGIN ',@seq, '.a(1); END;'); +ERROR HY000: Invalid dec8 character string: '\xD0' +EXECUTE IMMEDIATE CONCAT('BEGIN a.',@seq, '(1); END;'); +ERROR HY000: Invalid dec8 character string: '\xD0' +# +# Oracle assignment: (bad|good.bad|bad.good):= value +# +EXECUTE IMMEDIATE CONCAT(@seq, ':=1'); +ERROR HY000: Invalid dec8 character string: '\xD0' +EXECUTE IMMEDIATE CONCAT(@seq, '.a:=1'); +ERROR HY000: Invalid dec8 character string: '\xD0' +EXECUTE IMMEDIATE CONCAT('a.', @seq, ':=1'); +ERROR HY000: Invalid dec8 character string: '\xD0' +SET sql_mode=DEFAULT; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/ctype_dec8.test b/mysql-test/main/ctype_dec8.test new file mode 100644 index 00000000000..869d6242225 --- /dev/null +++ b/mysql-test/main/ctype_dec8.test @@ -0,0 +1,15 @@ +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-22625 SIGSEGV in intern_find_sys_var (optimized builds) +--echo # + +SET NAMES dec8; +SET @seq=_dec8 0xD0; +--source include/ctype_ident_sys.inc + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/ctype_errors.result b/mysql-test/main/ctype_errors.result index 6f9e14a8942..9916fb7c9c4 100644 --- a/mysql-test/main/ctype_errors.result +++ b/mysql-test/main/ctype_errors.result @@ -49,3 +49,14 @@ ERROR 42000: \0423 \0432\0430\0441 \043E\0448\0438\0431\043A\0430 \0432 \0437\04 disconnect con1; connection default; End of 5.5 tests +# +# MDEV-22130 SHOW WARNINGS will SIGSEGV 10.5 optimized build after setting CHARACTER_SET_RESULTS to NULL and running any invalid SQL | Binary_string::copy_printable_hhhh +# +SET NAMES latin1; +SET @@CHARACTER_SET_RESULTS=NULL; +a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'a' at line 1 +SHOW WARNINGS; +Level Code Message +Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'a' at line 1 +SET NAMES latin1; diff --git a/mysql-test/main/ctype_errors.test b/mysql-test/main/ctype_errors.test index b228a3b9f19..9ede9933ca7 100644 --- a/mysql-test/main/ctype_errors.test +++ b/mysql-test/main/ctype_errors.test @@ -58,3 +58,14 @@ disconnect con1; connection default; --echo End of 5.5 tests + +--echo # +--echo # MDEV-22130 SHOW WARNINGS will SIGSEGV 10.5 optimized build after setting CHARACTER_SET_RESULTS to NULL and running any invalid SQL | Binary_string::copy_printable_hhhh +--echo # + +SET NAMES latin1; +SET @@CHARACTER_SET_RESULTS=NULL; +--error ER_PARSE_ERROR +a; +SHOW WARNINGS; +SET NAMES latin1; diff --git a/mysql-test/main/ctype_eucjpms.result b/mysql-test/main/ctype_eucjpms.result index be341cc7e68..ba91abca96f 100644 --- a/mysql-test/main/ctype_eucjpms.result +++ b/mysql-test/main/ctype_eucjpms.result @@ -33934,7 +33934,7 @@ DROP TABLE t1; # MDEV-9711 NO PAD Collatons # SET character_set_connection=eucjpms; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -34072,7 +34072,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -34210,8 +34210,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -34349,7 +34349,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -34487,7 +34487,65 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; # # End of 10.2 tests # +# +# Start of 10.5 tests +# +# +# MDEV-22625 SIGSEGV in intern_find_sys_var (optimized builds) +# +SET NAMES eucjpms; +SET @seq=_eucjpms 0x8FA1A1; +# +# SET STATEMENT (bad|good.bad|bad.good)=1 +# +EXECUTE IMMEDIATE CONCAT('SET STATEMENT ',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid eucjpms character string: '\x8F\xA1\xA1' +EXECUTE IMMEDIATE CONCAT('SET STATEMENT ',@seq, '.a=1 SELECT 1'); +ERROR HY000: Invalid eucjpms character string: '\x8F\xA1\xA1' +EXECUTE IMMEDIATE CONCAT('SET STATEMENT a.',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid eucjpms character string: '\x8F\xA1\xA1' +# +# SET SESSION (bad|good.bad|bad.good)=1 +# +EXECUTE IMMEDIATE CONCAT('SET SESSION ',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid eucjpms character string: '\x8F\xA1\xA1' +EXECUTE IMMEDIATE CONCAT('SET SESSION ',@seq, '.a=1 SELECT 1'); +ERROR HY000: Invalid eucjpms character string: '\x8F\xA1\xA1' +EXECUTE IMMEDIATE CONCAT('SET SESSION a.',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid eucjpms character string: '\x8F\xA1\xA1' +# +# SET (bad|good.bad|bad.good)=1 +# +EXECUTE IMMEDIATE CONCAT('SET ', @seq, '=1'); +ERROR HY000: Invalid eucjpms character string: '\x8F\xA1\xA1' +EXECUTE IMMEDIATE CONCAT('SET ', @seq, '.a=1'); +ERROR HY000: Invalid eucjpms character string: '\x8F\xA1\xA1' +EXECUTE IMMEDIATE CONCAT('SET a.', @seq, '=1'); +ERROR HY000: Invalid eucjpms character string: '\x8F\xA1\xA1' +# +# Oracle SP call: BEGIN (bad|good.bad|bad.good)(params); END +# +SET sql_mode=ORACLE; +EXECUTE IMMEDIATE CONCAT('BEGIN ',@seq, '(1); END;'); +ERROR HY000: Invalid eucjpms character string: '\x8F\xA1\xA1' +EXECUTE IMMEDIATE CONCAT('BEGIN ',@seq, '.a(1); END;'); +ERROR HY000: Invalid eucjpms character string: '\x8F\xA1\xA1' +EXECUTE IMMEDIATE CONCAT('BEGIN a.',@seq, '(1); END;'); +ERROR HY000: Invalid eucjpms character string: '\x8F\xA1\xA1' +# +# Oracle assignment: (bad|good.bad|bad.good):= value +# +EXECUTE IMMEDIATE CONCAT(@seq, ':=1'); +ERROR HY000: Invalid eucjpms character string: '\x8F\xA1\xA1' +EXECUTE IMMEDIATE CONCAT(@seq, '.a:=1'); +ERROR HY000: Invalid eucjpms character string: '\x8F\xA1\xA1' +EXECUTE IMMEDIATE CONCAT('a.', @seq, ':=1'); +ERROR HY000: Invalid eucjpms character string: '\x8F\xA1\xA1' +SET sql_mode=DEFAULT; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/ctype_eucjpms.test b/mysql-test/main/ctype_eucjpms.test index 867ca809dbf..6af72270853 100644 --- a/mysql-test/main/ctype_eucjpms.test +++ b/mysql-test/main/ctype_eucjpms.test @@ -596,3 +596,20 @@ let $coll_pad='eucjpms_bin'; --echo # --echo # End of 10.2 tests --echo # + + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-22625 SIGSEGV in intern_find_sys_var (optimized builds) +--echo # + +SET NAMES eucjpms; +SET @seq=_eucjpms 0x8FA1A1; +--source include/ctype_ident_sys.inc + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/ctype_euckr.result b/mysql-test/main/ctype_euckr.result index f8dab97ce1d..5bfcc7071f3 100644 --- a/mysql-test/main/ctype_euckr.result +++ b/mysql-test/main/ctype_euckr.result @@ -25452,7 +25452,7 @@ SET optimizer_switch=@save_optimizer_switch; # MDEV-9711 NO PAD Collatons # SET character_set_connection=euckr; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -25590,7 +25590,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -25728,8 +25728,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -25867,7 +25867,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -26005,7 +26005,65 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; # # End of 10.2 tests # +# +# Start of 10.5 tests +# +# +# MDEV-22625 SIGSEGV in intern_find_sys_var (optimized builds) +# +SET NAMES euckr; +SET @seq=_euckr 0xA2E8; +# +# SET STATEMENT (bad|good.bad|bad.good)=1 +# +EXECUTE IMMEDIATE CONCAT('SET STATEMENT ',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid euckr character string: '\xA2\xE8' +EXECUTE IMMEDIATE CONCAT('SET STATEMENT ',@seq, '.a=1 SELECT 1'); +ERROR HY000: Invalid euckr character string: '\xA2\xE8' +EXECUTE IMMEDIATE CONCAT('SET STATEMENT a.',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid euckr character string: '\xA2\xE8' +# +# SET SESSION (bad|good.bad|bad.good)=1 +# +EXECUTE IMMEDIATE CONCAT('SET SESSION ',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid euckr character string: '\xA2\xE8' +EXECUTE IMMEDIATE CONCAT('SET SESSION ',@seq, '.a=1 SELECT 1'); +ERROR HY000: Invalid euckr character string: '\xA2\xE8' +EXECUTE IMMEDIATE CONCAT('SET SESSION a.',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid euckr character string: '\xA2\xE8' +# +# SET (bad|good.bad|bad.good)=1 +# +EXECUTE IMMEDIATE CONCAT('SET ', @seq, '=1'); +ERROR HY000: Invalid euckr character string: '\xA2\xE8' +EXECUTE IMMEDIATE CONCAT('SET ', @seq, '.a=1'); +ERROR HY000: Invalid euckr character string: '\xA2\xE8' +EXECUTE IMMEDIATE CONCAT('SET a.', @seq, '=1'); +ERROR HY000: Invalid euckr character string: '\xA2\xE8' +# +# Oracle SP call: BEGIN (bad|good.bad|bad.good)(params); END +# +SET sql_mode=ORACLE; +EXECUTE IMMEDIATE CONCAT('BEGIN ',@seq, '(1); END;'); +ERROR HY000: Invalid euckr character string: '\xA2\xE8' +EXECUTE IMMEDIATE CONCAT('BEGIN ',@seq, '.a(1); END;'); +ERROR HY000: Invalid euckr character string: '\xA2\xE8' +EXECUTE IMMEDIATE CONCAT('BEGIN a.',@seq, '(1); END;'); +ERROR HY000: Invalid euckr character string: '\xA2\xE8' +# +# Oracle assignment: (bad|good.bad|bad.good):= value +# +EXECUTE IMMEDIATE CONCAT(@seq, ':=1'); +ERROR HY000: Invalid euckr character string: '\xA2\xE8' +EXECUTE IMMEDIATE CONCAT(@seq, '.a:=1'); +ERROR HY000: Invalid euckr character string: '\xA2\xE8' +EXECUTE IMMEDIATE CONCAT('a.', @seq, ':=1'); +ERROR HY000: Invalid euckr character string: '\xA2\xE8' +SET sql_mode=DEFAULT; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/ctype_euckr.test b/mysql-test/main/ctype_euckr.test index 46955360217..1154047fdb0 100644 --- a/mysql-test/main/ctype_euckr.test +++ b/mysql-test/main/ctype_euckr.test @@ -227,3 +227,20 @@ let $coll_pad='euckr_bin'; --echo # --echo # End of 10.2 tests --echo # + + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-22625 SIGSEGV in intern_find_sys_var (optimized builds) +--echo # + +SET NAMES euckr; +SET @seq=_euckr 0xA2E8; +--source include/ctype_ident_sys.inc + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/ctype_filename.result b/mysql-test/main/ctype_filename.result index 955e1ff8a8f..aaccea91793 100644 --- a/mysql-test/main/ctype_filename.result +++ b/mysql-test/main/ctype_filename.result @@ -59,3 +59,77 @@ SELECT doc.`Children`.0 FROM t1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '.0 FROM t1' at line 1 SET NAMES latin1; # End of 10.3 tests +# +# MDEV-22043 Special character leads to assertion in my_wc_to_printable_generic on 10.5.2 (debug) +# +SET NAMES filename; +ERROR 42000: Variable 'character_set_client' can't be set to the value of 'filename' +EXECUTE IMMEDIATE _latin1 0x01; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '\0001' at line 1 +SET NAMES utf8; +# +# MDEV-23435 Functions do not convert numbers to character_set_results +# +SET NAMES utf8, character_set_results=filename; +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000000'); +SELECT a, COALESCE(a) AS c FROM t1; +a c +2001@002d01@002d01@002000@003a00@003a00@002e000000 2001@002d01@002d01@002000@003a00@003a00@002e000000 +DROP TABLE t1; +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('00:00:00.000000'); +SELECT a, COALESCE(a) AS c FROM t1; +a c +00@003a00@003a00@002e000000 00@003a00@003a00@002e000000 +DROP TABLE t1; +CREATE TABLE t1 (a DATE); +INSERT INTO t1 VALUES ('2001-01-01'); +SELECT a, COALESCE(a) AS c FROM t1; +a c +2001@002d01@002d01 2001@002d01@002d01 +DROP TABLE t1; +CREATE TABLE t1 (a TINYINT); +INSERT INTO t1 VALUES (-1); +SELECT a, COALESCE(a) AS c FROM t1; +a c +@002d1 @002d1 +DROP TABLE t1; +CREATE TABLE t1 (a SMALLINT); +INSERT INTO t1 VALUES (-1); +SELECT a, COALESCE(a) AS c FROM t1; +a c +@002d1 @002d1 +DROP TABLE t1; +CREATE TABLE t1 (a MEDIUMINT); +INSERT INTO t1 VALUES (-1); +SELECT a, COALESCE(a) AS c FROM t1; +a c +@002d1 @002d1 +DROP TABLE t1; +CREATE TABLE t1 (a BIGINT); +INSERT INTO t1 VALUES (-1); +SELECT a, COALESCE(a) AS c FROM t1; +a c +@002d1 @002d1 +DROP TABLE t1; +CREATE TABLE t1 (a DECIMAL(10.2)); +INSERT INTO t1 VALUES (-1); +SELECT a, COALESCE(a) AS c FROM t1; +a c +@002d1 @002d1 +DROP TABLE t1; +CREATE TABLE t1 (a FLOAT); +INSERT INTO t1 VALUES (-1); +SELECT a, COALESCE(a) AS c FROM t1; +a c +@002d1 @002d1 +DROP TABLE t1; +CREATE TABLE t1 (a DOUBLE); +INSERT INTO t1 VALUES (-1); +SELECT a, COALESCE(a) AS c FROM t1; +a c +@002d1 @002d1 +DROP TABLE t1; +SET NAMES utf8; +# End of 10.5 tests diff --git a/mysql-test/main/ctype_filename.test b/mysql-test/main/ctype_filename.test index 0c38172a0ef..ba42d1a2807 100644 --- a/mysql-test/main/ctype_filename.test +++ b/mysql-test/main/ctype_filename.test @@ -65,3 +65,77 @@ SELECT doc.`Children`.0 FROM t1; SET NAMES latin1; --echo # End of 10.3 tests + +--echo # +--echo # MDEV-22043 Special character leads to assertion in my_wc_to_printable_generic on 10.5.2 (debug) +--echo # + +--error ER_WRONG_VALUE_FOR_VAR +SET NAMES filename; +--error ER_PARSE_ERROR +EXECUTE IMMEDIATE _latin1 0x01; +SET NAMES utf8; + +--echo # +--echo # MDEV-23435 Functions do not convert numbers to character_set_results +--echo # + +--disable_ps_protocol + +SET NAMES utf8, character_set_results=filename; + +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000000'); +SELECT a, COALESCE(a) AS c FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('00:00:00.000000'); +SELECT a, COALESCE(a) AS c FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a DATE); +INSERT INTO t1 VALUES ('2001-01-01'); +SELECT a, COALESCE(a) AS c FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a TINYINT); +INSERT INTO t1 VALUES (-1); +SELECT a, COALESCE(a) AS c FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a SMALLINT); +INSERT INTO t1 VALUES (-1); +SELECT a, COALESCE(a) AS c FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a MEDIUMINT); +INSERT INTO t1 VALUES (-1); +SELECT a, COALESCE(a) AS c FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a BIGINT); +INSERT INTO t1 VALUES (-1); +SELECT a, COALESCE(a) AS c FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a DECIMAL(10.2)); +INSERT INTO t1 VALUES (-1); +SELECT a, COALESCE(a) AS c FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a FLOAT); +INSERT INTO t1 VALUES (-1); +SELECT a, COALESCE(a) AS c FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a DOUBLE); +INSERT INTO t1 VALUES (-1); +SELECT a, COALESCE(a) AS c FROM t1; +DROP TABLE t1; + +SET NAMES utf8; + +--enable_ps_protocol + +--echo # End of 10.5 tests diff --git a/mysql-test/main/ctype_gb2312.result b/mysql-test/main/ctype_gb2312.result index 2998615b1cb..d6066f82db9 100644 --- a/mysql-test/main/ctype_gb2312.result +++ b/mysql-test/main/ctype_gb2312.result @@ -4522,7 +4522,7 @@ SET sql_mode = DEFAULT; # MDEV-9711 NO PAD Collatons # SET character_set_connection=gb2312; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -4660,7 +4660,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -4798,8 +4798,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -4937,7 +4937,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -5075,7 +5075,65 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; # # End of 10.2 tests # +# +# Start of 10.5 tests +# +# +# MDEV-22625 SIGSEGV in intern_find_sys_var (optimized builds) +# +SET NAMES gb2312; +SET @seq=_gb2312 0xA2A1; +# +# SET STATEMENT (bad|good.bad|bad.good)=1 +# +EXECUTE IMMEDIATE CONCAT('SET STATEMENT ',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid gb2312 character string: '\xA2\xA1' +EXECUTE IMMEDIATE CONCAT('SET STATEMENT ',@seq, '.a=1 SELECT 1'); +ERROR HY000: Invalid gb2312 character string: '\xA2\xA1' +EXECUTE IMMEDIATE CONCAT('SET STATEMENT a.',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid gb2312 character string: '\xA2\xA1' +# +# SET SESSION (bad|good.bad|bad.good)=1 +# +EXECUTE IMMEDIATE CONCAT('SET SESSION ',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid gb2312 character string: '\xA2\xA1' +EXECUTE IMMEDIATE CONCAT('SET SESSION ',@seq, '.a=1 SELECT 1'); +ERROR HY000: Invalid gb2312 character string: '\xA2\xA1' +EXECUTE IMMEDIATE CONCAT('SET SESSION a.',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid gb2312 character string: '\xA2\xA1' +# +# SET (bad|good.bad|bad.good)=1 +# +EXECUTE IMMEDIATE CONCAT('SET ', @seq, '=1'); +ERROR HY000: Invalid gb2312 character string: '\xA2\xA1' +EXECUTE IMMEDIATE CONCAT('SET ', @seq, '.a=1'); +ERROR HY000: Invalid gb2312 character string: '\xA2\xA1' +EXECUTE IMMEDIATE CONCAT('SET a.', @seq, '=1'); +ERROR HY000: Invalid gb2312 character string: '\xA2\xA1' +# +# Oracle SP call: BEGIN (bad|good.bad|bad.good)(params); END +# +SET sql_mode=ORACLE; +EXECUTE IMMEDIATE CONCAT('BEGIN ',@seq, '(1); END;'); +ERROR HY000: Invalid gb2312 character string: '\xA2\xA1' +EXECUTE IMMEDIATE CONCAT('BEGIN ',@seq, '.a(1); END;'); +ERROR HY000: Invalid gb2312 character string: '\xA2\xA1' +EXECUTE IMMEDIATE CONCAT('BEGIN a.',@seq, '(1); END;'); +ERROR HY000: Invalid gb2312 character string: '\xA2\xA1' +# +# Oracle assignment: (bad|good.bad|bad.good):= value +# +EXECUTE IMMEDIATE CONCAT(@seq, ':=1'); +ERROR HY000: Invalid gb2312 character string: '\xA2\xA1' +EXECUTE IMMEDIATE CONCAT(@seq, '.a:=1'); +ERROR HY000: Invalid gb2312 character string: '\xA2\xA1' +EXECUTE IMMEDIATE CONCAT('a.', @seq, ':=1'); +ERROR HY000: Invalid gb2312 character string: '\xA2\xA1' +SET sql_mode=DEFAULT; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/ctype_gb2312.test b/mysql-test/main/ctype_gb2312.test index 4489168a163..07460116ade 100644 --- a/mysql-test/main/ctype_gb2312.test +++ b/mysql-test/main/ctype_gb2312.test @@ -180,3 +180,20 @@ let $coll_pad='gb2312_bin'; --echo # --echo # End of 10.2 tests --echo # + + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-22625 SIGSEGV in intern_find_sys_var (optimized builds) +--echo # + +SET NAMES gb2312; +SET @seq=_gb2312 0xA2A1; +--source include/ctype_ident_sys.inc + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/ctype_gbk.result b/mysql-test/main/ctype_gbk.result index c2a84a7ea70..7b54794a884 100644 --- a/mysql-test/main/ctype_gbk.result +++ b/mysql-test/main/ctype_gbk.result @@ -5985,7 +5985,7 @@ DROP TABLE t1; # MDEV-9711 NO PAD Collatons # SET character_set_connection=gbk; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -6123,7 +6123,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -6261,8 +6261,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -6400,7 +6400,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -6538,7 +6538,65 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; # # End of 10.2 tests # +# +# Start of 10.5 tests +# +# +# MDEV-22625 SIGSEGV in intern_find_sys_var (optimized builds) +# +SET NAMES gbk; +SET @seq=_gbk 0xAAA1; +# +# SET STATEMENT (bad|good.bad|bad.good)=1 +# +EXECUTE IMMEDIATE CONCAT('SET STATEMENT ',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid gbk character string: '\xAA\xA1' +EXECUTE IMMEDIATE CONCAT('SET STATEMENT ',@seq, '.a=1 SELECT 1'); +ERROR HY000: Invalid gbk character string: '\xAA\xA1' +EXECUTE IMMEDIATE CONCAT('SET STATEMENT a.',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid gbk character string: '\xAA\xA1' +# +# SET SESSION (bad|good.bad|bad.good)=1 +# +EXECUTE IMMEDIATE CONCAT('SET SESSION ',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid gbk character string: '\xAA\xA1' +EXECUTE IMMEDIATE CONCAT('SET SESSION ',@seq, '.a=1 SELECT 1'); +ERROR HY000: Invalid gbk character string: '\xAA\xA1' +EXECUTE IMMEDIATE CONCAT('SET SESSION a.',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid gbk character string: '\xAA\xA1' +# +# SET (bad|good.bad|bad.good)=1 +# +EXECUTE IMMEDIATE CONCAT('SET ', @seq, '=1'); +ERROR HY000: Invalid gbk character string: '\xAA\xA1' +EXECUTE IMMEDIATE CONCAT('SET ', @seq, '.a=1'); +ERROR HY000: Invalid gbk character string: '\xAA\xA1' +EXECUTE IMMEDIATE CONCAT('SET a.', @seq, '=1'); +ERROR HY000: Invalid gbk character string: '\xAA\xA1' +# +# Oracle SP call: BEGIN (bad|good.bad|bad.good)(params); END +# +SET sql_mode=ORACLE; +EXECUTE IMMEDIATE CONCAT('BEGIN ',@seq, '(1); END;'); +ERROR HY000: Invalid gbk character string: '\xAA\xA1' +EXECUTE IMMEDIATE CONCAT('BEGIN ',@seq, '.a(1); END;'); +ERROR HY000: Invalid gbk character string: '\xAA\xA1' +EXECUTE IMMEDIATE CONCAT('BEGIN a.',@seq, '(1); END;'); +ERROR HY000: Invalid gbk character string: '\xAA\xA1' +# +# Oracle assignment: (bad|good.bad|bad.good):= value +# +EXECUTE IMMEDIATE CONCAT(@seq, ':=1'); +ERROR HY000: Invalid gbk character string: '\xAA\xA1' +EXECUTE IMMEDIATE CONCAT(@seq, '.a:=1'); +ERROR HY000: Invalid gbk character string: '\xAA\xA1' +EXECUTE IMMEDIATE CONCAT('a.', @seq, ':=1'); +ERROR HY000: Invalid gbk character string: '\xAA\xA1' +SET sql_mode=DEFAULT; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/ctype_gbk.test b/mysql-test/main/ctype_gbk.test index d9d0a4d0ee4..c63c331c643 100644 --- a/mysql-test/main/ctype_gbk.test +++ b/mysql-test/main/ctype_gbk.test @@ -484,3 +484,20 @@ let $coll_pad='gbk_bin'; --echo # --echo # End of 10.2 tests --echo # + + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-22625 SIGSEGV in intern_find_sys_var (optimized builds) +--echo # + +SET NAMES gbk; +SET @seq=_gbk 0xAAA1; +--source include/ctype_ident_sys.inc + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/ctype_latin1.result b/mysql-test/main/ctype_latin1.result index b4005a4a73b..68870bbeea8 100644 --- a/mysql-test/main/ctype_latin1.result +++ b/mysql-test/main/ctype_latin1.result @@ -1527,12 +1527,12 @@ create table t1 as select concat(uuid()) as c1; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `c1` varchar(36) CHARACTER SET utf8 DEFAULT NULL + `c1` varchar(36) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; select coercibility(uuid()), coercibility(cast('a' as char character set latin1)); coercibility(uuid()) coercibility(cast('a' as char character set latin1)) -4 2 +5 2 select charset(concat(uuid(), cast('a' as char character set latin1))); charset(concat(uuid(), cast('a' as char character set latin1))) latin1 @@ -8309,7 +8309,7 @@ CONVERT(1, CHAR) IN ('100', '10', '1') # MDEV-9711 NO PAD Collatons # SET character_set_connection=latin1; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -8447,7 +8447,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -8585,8 +8585,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -8724,7 +8724,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -8862,7 +8862,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; SET NAMES latin1; # # MDEV-14350 Index use with collation utf8mb4_unicode_nopad_ci on LIKE pattern with wrong results @@ -8891,3 +8891,62 @@ DROP TABLE t1; # # End of 10.2 tests # +# +# Start of 10.5 tests +# +# +# MDEV-20712 Wrong data type for CAST(@a AS BINARY) for a numeric variable +# +SET NAMES latin1; +SET @a=2; +CREATE OR REPLACE TABLE t1 AS SELECT CAST(1 AS BINARY), CAST(@a AS BINARY), CAST(@b:=3 AS BINARY); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `CAST(1 AS BINARY)` varbinary(1) DEFAULT NULL, + `CAST(@a AS BINARY)` varbinary(20) DEFAULT NULL, + `CAST(@b:=3 AS BINARY)` varbinary(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +# +# MDEV-8844 Unreadable control characters printed as is in warnings +# +SET NAMES latin1; +SELECT CAST(_latin1 0x610062 AS INT); +CAST(_latin1 0x610062 AS INT) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'a\0000b' +SELECT CAST(_latin1 0x610162 AS INT); +CAST(_latin1 0x610162 AS INT) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'a\0001b' +SELECT CAST(_latin1 0x611F62 AS INT); +CAST(_latin1 0x611F62 AS INT) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'a\001Fb' +SELECT CAST(_latin1 0x617F62 AS INT); +CAST(_latin1 0x617F62 AS INT) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'a\007Fb' +SELECT CAST(_latin1 0x612062 AS INT); +CAST(_latin1 0x612062 AS INT) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'a b' +SELECT CAST(_latin1 0x617E62 AS INT); +CAST(_latin1 0x617E62 AS INT) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'a~b' +SELECT CAST(_latin1 0x61FF62 AS INT); +CAST(_latin1 0x61FF62 AS INT) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'aÿb' +# +# End of 10.5 tests +# diff --git a/mysql-test/main/ctype_latin1.test b/mysql-test/main/ctype_latin1.test index a556c86c016..d5b62beb140 100644 --- a/mysql-test/main/ctype_latin1.test +++ b/mysql-test/main/ctype_latin1.test @@ -441,3 +441,37 @@ SET NAMES latin1; --echo # --echo # End of 10.2 tests --echo # + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-20712 Wrong data type for CAST(@a AS BINARY) for a numeric variable +--echo # + +SET NAMES latin1; +SET @a=2; +CREATE OR REPLACE TABLE t1 AS SELECT CAST(1 AS BINARY), CAST(@a AS BINARY), CAST(@b:=3 AS BINARY); +SHOW CREATE TABLE t1; +DROP TABLE t1; + + +--echo # +--echo # MDEV-8844 Unreadable control characters printed as is in warnings +--echo # +SET NAMES latin1; +# control +SELECT CAST(_latin1 0x610062 AS INT); +SELECT CAST(_latin1 0x610162 AS INT); +SELECT CAST(_latin1 0x611F62 AS INT); +SELECT CAST(_latin1 0x617F62 AS INT); +# normal characters +SELECT CAST(_latin1 0x612062 AS INT); +SELECT CAST(_latin1 0x617E62 AS INT); +SELECT CAST(_latin1 0x61FF62 AS INT); + + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/ctype_ldml.result b/mysql-test/main/ctype_ldml.result index 3ce50331ed0..22b7a316111 100644 --- a/mysql-test/main/ctype_ldml.result +++ b/mysql-test/main/ctype_ldml.result @@ -447,7 +447,7 @@ Bug#46448 trailing spaces are not ignored when user collation maps space != 0x20 set names latin1; show collation like 'latin1_test'; Collation Charset Id Default Compiled Sortlen -latin1_test latin1 99 Yes 1 +latin1_test latin1 331 1 select "foo" = "foo " collate latin1_test; "foo" = "foo " collate latin1_test 1 @@ -466,6 +466,7 @@ utf8mb4_test_ci utf8mb4 326 8 utf16_test_ci utf16 327 8 utf8mb4_test_400_ci utf8mb4 328 8 utf8mb4_test_520_nopad_ci utf8mb4 329 8 +latin1_test latin1 331 1 latin1_test2 latin1 332 1 latin1_test2_cs latin1 333 1 latin1_swedish_nopad2_ci latin1 334 1 @@ -490,7 +491,7 @@ utf32_test_ci utf32 391 8 utf8_maxuserid_ci utf8 2047 8 show collation like '%test%'; Collation Charset Id Default Compiled Sortlen -latin1_test latin1 99 Yes 1 +latin1_test latin1 331 1 latin1_test2 latin1 332 1 latin1_test2_cs latin1 333 1 utf8_test_ci utf8 353 8 @@ -3034,3 +3035,10 @@ SELECT 'chž'< 'i'; 1 SELECT 'a' COLLATE utf8_czech_test_bad_w2; ERROR HY000: Unknown collation: 'utf8_czech_test_bad_w2' +# +# MDEV-7947 my_charset_same: strcmp() takes 0.37% in OLTP RO +# +SHOW COLLATION LIKE 'latin1_test_replace'; +Collation Charset Id Default Compiled Sortlen +SELECT 'foo' = 'foo ' COLLATE latin1_test_replace; +ERROR HY000: Unknown collation: 'latin1_test_replace' diff --git a/mysql-test/main/ctype_ldml.test b/mysql-test/main/ctype_ldml.test index a6cba4b9780..8baabdf2bcb 100644 --- a/mysql-test/main/ctype_ldml.test +++ b/mysql-test/main/ctype_ldml.test @@ -3,6 +3,10 @@ --source include/have_utf16.inc --source include/have_utf32.inc +--disable_query_log +call mtr.add_suppression("Charset id.*trying to replace"); +--enable_query_log + --disable_warnings drop table if exists t1; --enable_warnings @@ -602,3 +606,12 @@ SELECT 'chž'< 'i'; --error ER_UNKNOWN_COLLATION SELECT 'a' COLLATE utf8_czech_test_bad_w2; + + +--echo # +--echo # MDEV-7947 my_charset_same: strcmp() takes 0.37% in OLTP RO +--echo # + +SHOW COLLATION LIKE 'latin1_test_replace'; +--error ER_UNKNOWN_COLLATION +SELECT 'foo' = 'foo ' COLLATE latin1_test_replace; diff --git a/mysql-test/main/ctype_nopad_8bit.result b/mysql-test/main/ctype_nopad_8bit.result index b5dadc2f5da..2b089ce2994 100644 --- a/mysql-test/main/ctype_nopad_8bit.result +++ b/mysql-test/main/ctype_nopad_8bit.result @@ -2,7 +2,7 @@ # MDEV-9711 NO PAD Collatons # SET character_set_connection=dec8; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -140,7 +140,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -278,8 +278,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -417,7 +417,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -555,9 +555,9 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; SET character_set_connection=cp850; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -695,7 +695,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -833,8 +833,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -972,7 +972,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -1110,9 +1110,9 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; SET character_set_connection=hp8; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -1250,7 +1250,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -1388,8 +1388,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -1527,7 +1527,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -1665,9 +1665,9 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; SET character_set_connection=koi8r; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -1805,7 +1805,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -1943,8 +1943,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -2082,7 +2082,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -2220,9 +2220,9 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; SET character_set_connection=latin2; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -2360,7 +2360,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -2498,8 +2498,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -2637,7 +2637,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -2775,9 +2775,9 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; SET character_set_connection=swe7; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -2915,7 +2915,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -3053,8 +3053,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -3192,7 +3192,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -3330,9 +3330,9 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; SET character_set_connection=ascii; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -3470,7 +3470,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -3608,8 +3608,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -3747,7 +3747,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -3885,9 +3885,9 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; SET character_set_connection=hebrew; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -4025,7 +4025,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -4163,8 +4163,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -4302,7 +4302,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -4440,9 +4440,9 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; SET character_set_connection=koi8u; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -4580,7 +4580,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -4718,8 +4718,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -4857,7 +4857,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -4995,9 +4995,9 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; SET character_set_connection=greek; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -5135,7 +5135,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -5273,8 +5273,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -5412,7 +5412,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -5550,9 +5550,9 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; SET character_set_connection=cp1250; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -5690,7 +5690,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -5828,8 +5828,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -5967,7 +5967,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -6105,9 +6105,9 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; SET character_set_connection=cp1257; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -6245,7 +6245,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -6383,8 +6383,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -6522,7 +6522,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -6660,9 +6660,9 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; SET character_set_connection=latin5; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -6800,7 +6800,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -6938,8 +6938,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -7077,7 +7077,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -7215,9 +7215,9 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; SET character_set_connection=armscii8; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -7355,7 +7355,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -7493,8 +7493,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -7632,7 +7632,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -7770,9 +7770,9 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; SET character_set_connection=cp866; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -7910,7 +7910,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -8048,8 +8048,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -8187,7 +8187,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -8325,9 +8325,9 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; SET character_set_connection=keybcs2; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -8465,7 +8465,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -8603,8 +8603,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -8742,7 +8742,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -8880,9 +8880,9 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; SET character_set_connection=macce; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -9020,7 +9020,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -9158,8 +9158,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -9297,7 +9297,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -9435,9 +9435,9 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; SET character_set_connection=macroman; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -9575,7 +9575,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -9713,8 +9713,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -9852,7 +9852,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -9990,9 +9990,9 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; SET character_set_connection=cp852; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -10130,7 +10130,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -10268,8 +10268,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -10407,7 +10407,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -10545,9 +10545,9 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; SET character_set_connection=latin7; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -10685,7 +10685,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -10823,8 +10823,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -10962,7 +10962,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -11100,9 +11100,9 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; SET character_set_connection=cp1251; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -11240,7 +11240,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -11378,8 +11378,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -11517,7 +11517,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -11655,9 +11655,9 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; SET character_set_connection=cp1256; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -11795,7 +11795,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -11933,8 +11933,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -12072,7 +12072,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -12210,9 +12210,9 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; SET character_set_connection=geostd8; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -12350,7 +12350,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -12488,8 +12488,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -12627,7 +12627,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -12765,7 +12765,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; # # End of 10.2 tests # diff --git a/mysql-test/main/ctype_sjis.result b/mysql-test/main/ctype_sjis.result index c897268b204..638f9bc21c7 100644 --- a/mysql-test/main/ctype_sjis.result +++ b/mysql-test/main/ctype_sjis.result @@ -18739,7 +18739,7 @@ DROP TABLE t1; # MDEV-9711 NO PAD Collatons # SET character_set_connection=sjis; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -18877,7 +18877,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -19015,8 +19015,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -19154,7 +19154,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -19292,7 +19292,87 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; # # End of 10.2 tests # +# +# Start of 10.5 tests +# +# +# MDEV-22043 Special character leads to assertion in my_wc_to_printable_generic on 10.5.2 (debug) +# +SET NAMES sjis; +SET @@CHARACTER_SET_CLIENT='cp1257'; +(a(b 'Ñ‚')); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'a(b '_0143_201A'))' at line 1 +SET NAMES sjis; +SET @@CHARACTER_SET_CLIENT='cp1257'; +'Ñ‚'; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''_0143_201A'' at line 1 +SET NAMES sjis; +SET @@CHARACTER_SET_CLIENT='cp1257'; +EXECUTE IMMEDIATE _cp1257 0xD182; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '_0143_201A' at line 1 +SET NAMES sjis; +# +# End of 10.5 tests +# +# +# Start of 10.5 tests +# +# +# MDEV-22625 SIGSEGV in intern_find_sys_var (optimized builds) +# +SET NAMES sjis; +SET @seq=_sjis 0x81AD; +# +# SET STATEMENT (bad|good.bad|bad.good)=1 +# +EXECUTE IMMEDIATE CONCAT('SET STATEMENT ',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid sjis character string: '_x81_xAD' +EXECUTE IMMEDIATE CONCAT('SET STATEMENT ',@seq, '.a=1 SELECT 1'); +ERROR HY000: Invalid sjis character string: '_x81_xAD' +EXECUTE IMMEDIATE CONCAT('SET STATEMENT a.',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid sjis character string: '_x81_xAD' +# +# SET SESSION (bad|good.bad|bad.good)=1 +# +EXECUTE IMMEDIATE CONCAT('SET SESSION ',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid sjis character string: '_x81_xAD' +EXECUTE IMMEDIATE CONCAT('SET SESSION ',@seq, '.a=1 SELECT 1'); +ERROR HY000: Invalid sjis character string: '_x81_xAD' +EXECUTE IMMEDIATE CONCAT('SET SESSION a.',@seq, '=1 SELECT 1'); +ERROR HY000: Invalid sjis character string: '_x81_xAD' +# +# SET (bad|good.bad|bad.good)=1 +# +EXECUTE IMMEDIATE CONCAT('SET ', @seq, '=1'); +ERROR HY000: Invalid sjis character string: '_x81_xAD' +EXECUTE IMMEDIATE CONCAT('SET ', @seq, '.a=1'); +ERROR HY000: Invalid sjis character string: '_x81_xAD' +EXECUTE IMMEDIATE CONCAT('SET a.', @seq, '=1'); +ERROR HY000: Invalid sjis character string: '_x81_xAD' +# +# Oracle SP call: BEGIN (bad|good.bad|bad.good)(params); END +# +SET sql_mode=ORACLE; +EXECUTE IMMEDIATE CONCAT('BEGIN ',@seq, '(1); END;'); +ERROR HY000: Invalid sjis character string: '_x81_xAD' +EXECUTE IMMEDIATE CONCAT('BEGIN ',@seq, '.a(1); END;'); +ERROR HY000: Invalid sjis character string: '_x81_xAD' +EXECUTE IMMEDIATE CONCAT('BEGIN a.',@seq, '(1); END;'); +ERROR HY000: Invalid sjis character string: '_x81_xAD' +# +# Oracle assignment: (bad|good.bad|bad.good):= value +# +EXECUTE IMMEDIATE CONCAT(@seq, ':=1'); +ERROR HY000: Invalid sjis character string: '_x81_xAD' +EXECUTE IMMEDIATE CONCAT(@seq, '.a:=1'); +ERROR HY000: Invalid sjis character string: '_x81_xAD' +EXECUTE IMMEDIATE CONCAT('a.', @seq, ':=1'); +ERROR HY000: Invalid sjis character string: '_x81_xAD' +SET sql_mode=DEFAULT; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/ctype_sjis.test b/mysql-test/main/ctype_sjis.test index 9a8ce414c14..8ca423bb7c1 100644 --- a/mysql-test/main/ctype_sjis.test +++ b/mysql-test/main/ctype_sjis.test @@ -260,3 +260,50 @@ let $coll_pad='sjis_bin'; --echo # --echo # End of 10.2 tests --echo # + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-22043 Special character leads to assertion in my_wc_to_printable_generic on 10.5.2 (debug) +--echo # + +SET NAMES sjis; +SET @@CHARACTER_SET_CLIENT='cp1257'; +--error ER_PARSE_ERROR +(a(b 'Ñ‚')); + +SET NAMES sjis; +SET @@CHARACTER_SET_CLIENT='cp1257'; +--error ER_PARSE_ERROR +'Ñ‚'; + +SET NAMES sjis; +SET @@CHARACTER_SET_CLIENT='cp1257'; +--error ER_PARSE_ERROR +EXECUTE IMMEDIATE _cp1257 0xD182; + +SET NAMES sjis; + + +--echo # +--echo # End of 10.5 tests +--echo # + + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-22625 SIGSEGV in intern_find_sys_var (optimized builds) +--echo # + +SET NAMES sjis; +SET @seq=_sjis 0x81AD; +--source include/ctype_ident_sys.inc + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/ctype_swe7.result b/mysql-test/main/ctype_swe7.result index 63da7d362ca..db65b6b8a1a 100644 --- a/mysql-test/main/ctype_swe7.result +++ b/mysql-test/main/ctype_swe7.result @@ -3078,7 +3078,7 @@ SET sql_mode = DEFAULT; # MDEV-9711 NO PAD Collatons # SET character_set_connection=swe7; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -3216,7 +3216,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -3354,8 +3354,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -3493,7 +3493,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -3631,7 +3631,25 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; # # End of 10.2 tests # +# +# Start of 10.5 tests +# +# +# MDEV-22043 Special character leads to assertion in my_wc_to_printable_generic on 10.5.2 (debug) +# +SET NAMES swe7; +SELECT `ï¼´`; +ERROR HY000: Invalid swe7 character string: '.xEF.xBC.xB4' +SET NAMES swe7; +SELECT `é¾”`; +ERROR HY000: Invalid swe7 character string: '.xE9.xBE.x94' +SET NAMES swe7; +EXECUTE IMMEDIATE _swe7 0x01; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '.0001' at line 1 +# +# End of 10.5 tests +# diff --git a/mysql-test/main/ctype_swe7.test b/mysql-test/main/ctype_swe7.test index 2e648a89406..a8d79935aa6 100644 --- a/mysql-test/main/ctype_swe7.test +++ b/mysql-test/main/ctype_swe7.test @@ -38,3 +38,29 @@ let $coll_pad='swe7_bin'; --echo # --echo # End of 10.2 tests --echo # + + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-22043 Special character leads to assertion in my_wc_to_printable_generic on 10.5.2 (debug) +--echo # + +SET NAMES swe7; +--error ER_INVALID_CHARACTER_STRING +SELECT `ï¼´`; + +SET NAMES swe7; +--error ER_INVALID_CHARACTER_STRING +SELECT `é¾”`; + +SET NAMES swe7; +--error ER_PARSE_ERROR +EXECUTE IMMEDIATE _swe7 0x01; + + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/ctype_tis620.result b/mysql-test/main/ctype_tis620.result index 9650c366d38..7e0c255c756 100644 --- a/mysql-test/main/ctype_tis620.result +++ b/mysql-test/main/ctype_tis620.result @@ -3866,7 +3866,7 @@ E0 # MDEV-9711 NO PAD Collatons # SET character_set_connection=tis620; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -4004,7 +4004,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -4142,8 +4142,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -4281,7 +4281,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -4419,7 +4419,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; # # End of 10.2 tests # diff --git a/mysql-test/main/ctype_uca.test b/mysql-test/main/ctype_uca.test index 82be0305f07..67ef7d7aa96 100644 --- a/mysql-test/main/ctype_uca.test +++ b/mysql-test/main/ctype_uca.test @@ -483,7 +483,7 @@ set names utf8; --echo # Start of 5.5 tests --echo # # -# Test my_like_range and contractions +# Test like_range and contractions # SET collation_connection=utf8_czech_ci; --source include/ctype_czech.inc diff --git a/mysql-test/main/ctype_ucs.result b/mysql-test/main/ctype_ucs.result index 6292ad2591e..dc3ed0cf7a9 100644 --- a/mysql-test/main/ctype_ucs.result +++ b/mysql-test/main/ctype_ucs.result @@ -1569,7 +1569,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range a a 23 NULL 1 Using where; Using index EXPLAIN SELECT * FROM t1 WHERE a LIKE 'c%'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index a a 23 NULL 31 Using where; Using index +1 SIMPLE t1 range a a 23 NULL 31 Using where; Using index SELECT * FROM t1 WHERE a LIKE 'c%'; a ca @@ -1585,7 +1585,7 @@ ch ALTER TABLE t1 MODIFY a VARCHAR(10) CHARACTER SET ucs2 COLLATE ucs2_croatian_ci; EXPLAIN SELECT * FROM t1 WHERE a LIKE 'd%'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index a a 23 NULL 31 Using where; Using index +1 SIMPLE t1 range a a 23 NULL 31 Using where; Using index SELECT hex(concat('d',_ucs2 0x017E,'%')); hex(concat('d',_ucs2 0x017E,'%')) 0064017E0025 @@ -2411,12 +2411,12 @@ create table t1 as select concat(uuid()) as c1; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `c1` varchar(36) CHARACTER SET utf8 DEFAULT NULL + `c1` varchar(36) CHARACTER SET ucs2 DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; select coercibility(uuid()), coercibility(cast('a' as char character set latin1)); coercibility(uuid()) coercibility(cast('a' as char character set latin1)) -4 2 +5 2 select charset(concat(uuid(), cast('a' as char character set latin1))); charset(concat(uuid(), cast('a' as char character set latin1))) latin1 @@ -5777,7 +5777,7 @@ Warning 1292 Truncated incorrect INTEGER value: '1IJ3' # MDEV-9711 NO PAD Collatons # SET character_set_connection=ucs2; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -5915,7 +5915,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -6053,8 +6053,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -6192,7 +6192,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -6330,7 +6330,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; # # MDEV-10585 EXECUTE IMMEDIATE statement # @@ -6433,3 +6433,45 @@ SET NAMES utf8; # # End of 10.4 tests # +# +# Start of 10.5 tests +# +# +# MDEV-8844 Unreadable control characters printed as is in warnings +# +# control +SELECT CAST(_ucs2 0x006100000062 AS INT); +CAST(_ucs2 0x006100000062 AS INT) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'a\0000b' +SELECT CAST(_ucs2 0x006100010062 AS INT); +CAST(_ucs2 0x006100010062 AS INT) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'a\0001b' +# surrogate halfs +SELECT CAST(_ucs2 0x0061D8000062 AS INT); +CAST(_ucs2 0x0061D8000062 AS INT) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'a\D800b' +SELECT CAST(_ucs2 0x0061DFFF0062 AS INT); +CAST(_ucs2 0x0061DFFF0062 AS INT) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'a\DFFFb' +# normal characters +SELECT CAST(_ucs2 0x0061D7000062 AS INT); +CAST(_ucs2 0x0061D7000062 AS INT) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'a휀b' +SELECT CAST(_ucs2 0x0061E0030062 AS INT); +CAST(_ucs2 0x0061E0030062 AS INT) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'ab' +# +# End of 10.5 tests +# diff --git a/mysql-test/main/ctype_ucs.test b/mysql-test/main/ctype_ucs.test index 7a772a092b1..cdc86fa3283 100644 --- a/mysql-test/main/ctype_ucs.test +++ b/mysql-test/main/ctype_ucs.test @@ -1124,3 +1124,28 @@ SET NAMES utf8; --echo # --echo # End of 10.4 tests --echo # + + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-8844 Unreadable control characters printed as is in warnings +--echo # + +--echo # control +SELECT CAST(_ucs2 0x006100000062 AS INT); +SELECT CAST(_ucs2 0x006100010062 AS INT); + +--echo # surrogate halfs +SELECT CAST(_ucs2 0x0061D8000062 AS INT); +SELECT CAST(_ucs2 0x0061DFFF0062 AS INT); + +--echo # normal characters +SELECT CAST(_ucs2 0x0061D7000062 AS INT); +SELECT CAST(_ucs2 0x0061E0030062 AS INT); + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/ctype_ucs2_uca.result b/mysql-test/main/ctype_ucs2_uca.result index 44a623842c6..24667ff6949 100644 --- a/mysql-test/main/ctype_ucs2_uca.result +++ b/mysql-test/main/ctype_ucs2_uca.result @@ -5,7 +5,7 @@ # MDEV-10877 xxx_unicode_nopad_ci collations # SET NAMES utf8, character_set_connection=ucs2; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -143,7 +143,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -281,8 +281,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -420,7 +420,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -558,7 +558,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; SET NAMES utf8, collation_connection=ucs2_unicode_520_nopad_ci; # # MDEV-14350 Index use with collation utf8mb4_unicode_nopad_ci on LIKE pattern with wrong results diff --git a/mysql-test/main/ctype_ujis.result b/mysql-test/main/ctype_ujis.result index 66175344615..c20455813d3 100644 --- a/mysql-test/main/ctype_ujis.result +++ b/mysql-test/main/ctype_ujis.result @@ -26253,7 +26253,7 @@ DROP TABLE t1; # MDEV-9711 NO PAD Collatons # SET character_set_connection=ujis; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -26391,7 +26391,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -26529,8 +26529,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -26668,7 +26668,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -26806,7 +26806,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; # # End of 10.2 tests # diff --git a/mysql-test/main/ctype_utf16.result b/mysql-test/main/ctype_utf16.result index 3643e170376..36dedc87321 100644 --- a/mysql-test/main/ctype_utf16.result +++ b/mysql-test/main/ctype_utf16.result @@ -1086,7 +1086,7 @@ select left('aaa','1'); left('aaa','1') a # -# Testing cs->cset->strtoll10() +# Testing strtoll10() # SELECT @@character_set_connection; @@character_set_connection @@ -2259,7 +2259,7 @@ Warning 1292 Truncated incorrect INTEGER value: '1IJ3' # MDEV-9711 NO PAD Collatons # SET character_set_connection=utf16; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -2397,7 +2397,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -2535,8 +2535,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -2674,7 +2674,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -2812,7 +2812,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; # # End of 10.2 tests # @@ -2841,3 +2841,18 @@ VALUES ('') UNION VALUES ( _utf16 0x0020 COLLATE utf16_bin); # # End of 10.3 tests # +# +# Start of 10.5 tests +# +# +# MDEV-8844 Unreadable control characters printed as is in warnings +# +SET NAMES utf8; +SELECT CAST(_utf16 0x0061D83DDE0E0062 AS INT); +CAST(_utf16 0x0061D83DDE0E0062 AS INT) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'a?b' +# +# End of 10.5 tests +# diff --git a/mysql-test/main/ctype_utf16.test b/mysql-test/main/ctype_utf16.test index 2267facd106..c2807a19215 100644 --- a/mysql-test/main/ctype_utf16.test +++ b/mysql-test/main/ctype_utf16.test @@ -511,12 +511,12 @@ drop table t1; set names latin1; set collation_connection=utf16_general_ci; # -# Testing cs->coll->instr() +# Testing instr() # select position('bb' in 'abba'); # -# Testing cs->coll->hash_sort() +# Testing hash_sort() # create table t1 (a varchar(10) character set utf16) engine=heap; insert into t1 values ('a'),('A'),('b'),('B'); @@ -525,21 +525,21 @@ select hex(min(binary a)),count(*) from t1 group by a; drop table t1; # -# Testing cs->cset->numchars() +# Testing numchars() # select char_length('abcd'), octet_length('abcd'); select char_length(_utf16 0xD800DC00), octet_length(_utf16 0xD800DC00); select char_length(_utf16 0xD87FDFFF), octet_length(_utf16 0xD87FDFFF); # -# Testing cs->cset->charpos() +# Testing charpos() # select left('abcd',2); select hex(left(_utf16 0xD800DC00D87FDFFF, 1)); select hex(right(_utf16 0xD800DC00D87FDFFF, 1)); # -# Testing cs->cset->well_formed_length() +# Testing well_formed_length() # create table t1 (a varchar(10) character set utf16); # Bad sequences @@ -564,7 +564,7 @@ drop table t1; # # Bug#32393 Character sets: illegal characters in utf16 columns # -# Tests that cs->cset->wc_mb() doesn't accept surrogate parts +# Tests that my_ci_wc_mb() doesn't accept surrogate parts # # via alter # @@ -586,7 +586,7 @@ drop table t1; # -# Testing cs->cset->lengthsp() +# Testing lengthsp() # create table t1 (a char(10)) character set utf16; insert into t1 values ('a '); @@ -594,13 +594,13 @@ select hex(a) from t1; drop table t1; # -# Testing cs->cset->caseup() and cs->cset->casedn() +# Testing caseup() and casedn() # select upper('abcd'), lower('ABCD'); # # TODO: str_to_datetime() is broken and doesn't work with ucs2 and utf16 -# Testing cs->cset->snprintf() +# Testing snprintf() # #create table t1 (a date); #insert into t1 values ('2007-09-16'); @@ -608,11 +608,11 @@ select upper('abcd'), lower('ABCD'); #drop table t1; # -# Testing cs->cset->l10tostr +# Testing l10tostr # !!! Not used in the code # -# Testing cs->cset->ll10tostr +# Testing ll10tostr # create table t1 (a varchar(10) character set utf16); insert into t1 values (123456); @@ -620,16 +620,16 @@ select a, hex(a) from t1; drop table t1; -# Testing cs->cset->fill +# Testing fill # SOUNDEX fills strings with DIGIT ZERO up to four characters select hex(soundex('a')); # -# Testing cs->cset->strntol +# Testing strntol # !!! Not used in the code # -# Testing cs->cset->strntoul +# Testing strntoul # create table t1 (a enum ('a','b','c')) character set utf16; insert into t1 values ('1'); @@ -637,14 +637,14 @@ select * from t1; drop table t1; # -# Testing cs->cset->strntoll and cs->cset->strntoull +# Testing strntoll and strntoull # set names latin1; select hex(conv(convert('123' using utf16), -10, 16)); select hex(conv(convert('123' using utf16), 10, 16)); # -# Testing cs->cset->strntod +# Testing strntod # set names latin1; set character_set_connection=utf16; @@ -652,12 +652,12 @@ select 1.1 + '1.2'; select 1.1 + '1.2xxx'; # Testing strntoll10_utf16 -# Testing cs->cset->strtoll10 +# Testing strtoll10 select left('aaa','1'); --source include/ctype_strtoll10.inc # -# Testing cs->cset->strntoull10rnd +# Testing strntoull10rnd # create table t1 (a int); insert into t1 values ('-1234.1e2'); @@ -667,7 +667,7 @@ select * from t1; drop table t1; # -# Testing cs->cset->scan +# Testing scan # create table t1 (a int); insert into t1 values ('1 '); @@ -955,3 +955,23 @@ VALUES ('') UNION VALUES ( _utf16 0x0020 COLLATE utf16_bin); --echo # --echo # End of 10.3 tests --echo # + + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-8844 Unreadable control characters printed as is in warnings +--echo # + +SET NAMES utf8; +# Make sure surrogate halfs (when a part of a full utf16 character) +# are not escaped and the entire utf16 character consisting of two +# surrogate pairs is replaced to a single question mark. +SELECT CAST(_utf16 0x0061D83DDE0E0062 AS INT); + + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/ctype_utf16_uca.result b/mysql-test/main/ctype_utf16_uca.result index d4f0a821168..d1dbd498064 100644 --- a/mysql-test/main/ctype_utf16_uca.result +++ b/mysql-test/main/ctype_utf16_uca.result @@ -7318,7 +7318,7 @@ DROP TABLE t1; # MDEV-10877 xxx_unicode_nopad_ci collations # SET NAMES utf8, character_set_connection=utf16; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -7456,7 +7456,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -7594,8 +7594,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -7733,7 +7733,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -7871,7 +7871,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; SET NAMES utf8, collation_connection=utf16_unicode_520_nopad_ci; # # MDEV-14350 Index use with collation utf8mb4_unicode_nopad_ci on LIKE pattern with wrong results diff --git a/mysql-test/main/ctype_utf16_uca.test b/mysql-test/main/ctype_utf16_uca.test index 93807232bab..cb00ccc0c61 100644 --- a/mysql-test/main/ctype_utf16_uca.test +++ b/mysql-test/main/ctype_utf16_uca.test @@ -143,7 +143,7 @@ set collation_connection=utf16_unicode_ci; --source include/ctype_regex.inc # -# Test my_like_range and contractions +# Test like_range and contractions # SET collation_connection=utf16_czech_ci; --source include/ctype_czech.inc diff --git a/mysql-test/main/ctype_utf16le.result b/mysql-test/main/ctype_utf16le.result index 415b6ed6251..aff755d95ae 100644 --- a/mysql-test/main/ctype_utf16le.result +++ b/mysql-test/main/ctype_utf16le.result @@ -1027,17 +1027,17 @@ text 65535 32767 DROP TABLE t1; SET NAMES utf8, collation_connection=utf16le_general_ci; # -# Testing cs->coll->instr() +# Testing instr() # SELECT POSITION('bb' IN 'abba'); POSITION('bb' IN 'abba') 2 # -# Testing cs->coll->hash_sort() +# Testing hash_sort() # SET NAMES utf8, collation_connection=utf16le_bin; # -# Test that cs->coll->hash_sort() ignores trailing spaces +# Test that hash_sort() ignores trailing spaces # SELECT @@collation_connection; @@collation_connection @@ -1056,7 +1056,7 @@ a 61002000 DROP TABLE t1; SET NAMES utf8, collation_connection=utf16le_general_ci; # -# Test that cs->coll->hash_sort() ignores trailing spaces +# Test that hash_sort() ignores trailing spaces # SELECT @@collation_connection; @@collation_connection @@ -1074,7 +1074,7 @@ a HEX(a) a 61002000 DROP TABLE t1; # -# Testing cs->cset->numchars() +# Testing numchars() # SELECT CHAR_LENGTH('abcd'), OCTET_LENGTH('abcd'); CHAR_LENGTH('abcd') OCTET_LENGTH('abcd') @@ -1086,7 +1086,7 @@ SELECT CHAR_LENGTH(_utf16le 0x7DD8FFDF), OCTET_LENGTH(_utf16le 0x7FD8DDDF); CHAR_LENGTH(_utf16le 0x7DD8FFDF) OCTET_LENGTH(_utf16le 0x7FD8DDDF) 1 4 # -# Testing cs->cset->charpos() +# Testing charpos() # SELECT LEFT('abcd',2); LEFT('abcd',2) @@ -1098,7 +1098,7 @@ SELECT HEX(RIGHT(_utf16le 0x00D800DC7FD8FFDF, 1)); HEX(RIGHT(_utf16le 0x00D800DC7FD8FFDF, 1)) 7FD8FFDF # -# Testing cs->cset->well_formed_length() +# Testing well_formed_length() # CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16le); # Bad sequences @@ -1127,7 +1127,7 @@ DROP TABLE t1; # # Bug#32393 Character sets: illegal characters in utf16le columns # -# Tests that cs->cset->wc_mb() doesn't accept surrogate parts +# Tests that my_ci_wc_mb() doesn't accept surrogate parts # # via ALTER # @@ -1154,7 +1154,7 @@ HEX(s2) 3F00 DROP TABLE t1; # -# Testing cs->cset->lengthsp() +# Testing lengthsp() # CREATE TABLE t1 (a CHAR(10)) CHARACTER SET utf16le; INSERT INTO t1 VALUES ('a '); @@ -1163,7 +1163,7 @@ HEX(a) 6100 DROP TABLE t1; # -# Testing cs->cset->caseup() and cs->cset->casedn() +# Testing caseup() and casedn() # SELECT UPPER('abcd'), LOWER('ABCD'); UPPER('abcd') LOWER('ABCD') @@ -1181,7 +1181,7 @@ a 2007-09-16 DROP TABLE t1; # -# Testing cs->cset->ll10tostr +# Testing ll10tostr # CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16le); INSERT INTO t1 VALUES (123456); @@ -1190,14 +1190,14 @@ a HEX(a) 123456 310032003300340035003600 DROP TABLE t1; # -# Testing cs->cset->fill +# Testing fill # SOUNDEX fills strings with DIGIT ZERO up to four characters # SELECT SOUNDEX('a'), HEX(SOUNDEX('a')); SOUNDEX('a') HEX(SOUNDEX('a')) A000 4100300030003000 # -# Testing cs->cset->strntoul +# Testing strntoul # CREATE TABLE t1 (a enum ('a','b','c')) CHARACTER SET utf16le; INSERT INTO t1 VALUES ('1'); @@ -1206,7 +1206,7 @@ a a DROP TABLE t1; # -# Testing cs->cset->strntoll and cs->cset->strntoull +# Testing strntoll and strntoull # SET NAMES latin1; SELECT HEX(CONV(CONVERT('123' USING utf16le), -10, 16)); @@ -1217,7 +1217,7 @@ HEX(CONV(CONVERT('123' USING utf16le), 10, 16)) 3742 SET NAMES utf8, collation_connection=utf16le_general_ci; # -# Testing cs->cset->strntod +# Testing strntod # SET NAMES utf8, collation_connection=utf16le_general_ci; SELECT 1.1 + '1.2'; @@ -1229,7 +1229,7 @@ SELECT 1.1 + '1.2xxx'; Warnings: Warning 1292 Truncated incorrect DOUBLE value: '1.2xxx' # -# Testing cs->cset->strtoll10 +# Testing strtoll10 # SELECT LEFT('aaa','1'); LEFT('aaa','1') @@ -1303,7 +1303,7 @@ Warning 1292 Truncated incorrect INTEGER value: '-18446744073709551614' Warning 1292 Truncated incorrect INTEGER value: '-18446744073709551615' DROP TABLE t1; # -# Testing cs->cset->strtoll10() +# Testing strtoll10() # SELECT @@character_set_connection; @@character_set_connection @@ -1479,7 +1479,7 @@ CAST('123456789123456789123x' AS UNSIGNED) Warnings: Warning 1292 Truncated incorrect INTEGER value: '123456789123456789123x' # -# Testing cs->cset->strntoull10rnd +# Testing strntoull10rnd # CREATE TABLE t1 (a int); INSERT INTO t1 VALUES ('-1234.1e2'); @@ -1531,7 +1531,7 @@ a 18446744073709551615 DROP TABLE t1; # -# Testing cs->cset->scan +# Testing scan # CREATE TABLE t1 (a int); INSERT INTO t1 VALUES ('1 '); @@ -2445,7 +2445,7 @@ Warning 1292 Truncated incorrect INTEGER value: '1IJ3' # MDEV-9711 NO PAD Collatons # SET character_set_connection=utf16le; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -2583,7 +2583,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -2721,8 +2721,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -2860,7 +2860,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -2998,7 +2998,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; # # MDEV-23408 Wrong result upon query from I_S and further Assertion `!alias_arg || strlen(alias_arg->str) == alias_arg->length' failed with certain connection charset # diff --git a/mysql-test/main/ctype_utf16le.test b/mysql-test/main/ctype_utf16le.test index c0cac7f5d67..e3163d2f73e 100644 --- a/mysql-test/main/ctype_utf16le.test +++ b/mysql-test/main/ctype_utf16le.test @@ -435,12 +435,12 @@ DROP TABLE t1; SET NAMES utf8, collation_connection=utf16le_general_ci; --echo # ---echo # Testing cs->coll->instr() +--echo # Testing instr() --echo # SELECT POSITION('bb' IN 'abba'); --echo # ---echo # Testing cs->coll->hash_sort() +--echo # Testing hash_sort() --echo # SET NAMES utf8, collation_connection=utf16le_bin; --source include/ctype_heap.inc @@ -448,21 +448,21 @@ SET NAMES utf8, collation_connection=utf16le_general_ci; --source include/ctype_heap.inc --echo # ---echo # Testing cs->cset->numchars() +--echo # Testing numchars() --echo # SELECT CHAR_LENGTH('abcd'), OCTET_LENGTH('abcd'); SELECT CHAR_LENGTH(_utf16le 0x00D800DC), OCTET_LENGTH(_utf16le 0x00D800DC); SELECT CHAR_LENGTH(_utf16le 0x7DD8FFDF), OCTET_LENGTH(_utf16le 0x7FD8DDDF); --echo # ---echo # Testing cs->cset->charpos() +--echo # Testing charpos() --echo # SELECT LEFT('abcd',2); SELECT HEX(LEFT(_utf16le 0x00D800DC7FD8FFDF, 1)); SELECT HEX(RIGHT(_utf16le 0x00D800DC7FD8FFDF, 1)); --echo # ---echo # Testing cs->cset->well_formed_length() +--echo # Testing well_formed_length() --echo # CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16le); --echo # Bad sequences @@ -487,7 +487,7 @@ DROP TABLE t1; --echo # --echo # Bug#32393 Character sets: illegal characters in utf16le columns --echo # ---echo # Tests that cs->cset->wc_mb() doesn't accept surrogate parts +--echo # Tests that my_ci_wc_mb() doesn't accept surrogate parts --echo # --echo # via ALTER --echo # @@ -509,7 +509,7 @@ DROP TABLE t1; --echo # ---echo # Testing cs->cset->lengthsp() +--echo # Testing lengthsp() --echo # CREATE TABLE t1 (a CHAR(10)) CHARACTER SET utf16le; INSERT INTO t1 VALUES ('a '); @@ -518,7 +518,7 @@ DROP TABLE t1; --echo # ---echo # Testing cs->cset->caseup() and cs->cset->casedn() +--echo # Testing caseup() and casedn() --echo # SELECT UPPER('abcd'), LOWER('ABCD'); @@ -533,7 +533,7 @@ DROP TABLE t1; --echo # ---echo # Testing cs->cset->ll10tostr +--echo # Testing ll10tostr --echo # CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16le); INSERT INTO t1 VALUES (123456); @@ -541,14 +541,14 @@ SELECT a, HEX(a) FROM t1; DROP TABLE t1; --echo # ---echo # Testing cs->cset->fill +--echo # Testing fill --echo # SOUNDEX fills strings with DIGIT ZERO up to four characters --echo # SELECT SOUNDEX('a'), HEX(SOUNDEX('a')); --echo # ---echo # Testing cs->cset->strntoul +--echo # Testing strntoul --echo # CREATE TABLE t1 (a enum ('a','b','c')) CHARACTER SET utf16le; INSERT INTO t1 VALUES ('1'); @@ -557,7 +557,7 @@ DROP TABLE t1; --echo # ---echo # Testing cs->cset->strntoll and cs->cset->strntoull +--echo # Testing strntoll and strntoull --echo # SET NAMES latin1; SELECT HEX(CONV(CONVERT('123' USING utf16le), -10, 16)); @@ -566,7 +566,7 @@ SET NAMES utf8, collation_connection=utf16le_general_ci; --echo # ---echo # Testing cs->cset->strntod +--echo # Testing strntod --echo # SET NAMES utf8, collation_connection=utf16le_general_ci; SELECT 1.1 + '1.2'; @@ -574,7 +574,7 @@ SELECT 1.1 + '1.2xxx'; --echo # ---echo # Testing cs->cset->strtoll10 +--echo # Testing strtoll10 --echo # SELECT LEFT('aaa','1'); CREATE TABLE t1 AS SELECT REPEAT('abcd', 128) AS a; @@ -601,7 +601,7 @@ DROP TABLE t1; --source include/ctype_strtoll10.inc --echo # ---echo # Testing cs->cset->strntoull10rnd +--echo # Testing strntoull10rnd --echo # CREATE TABLE t1 (a int); INSERT INTO t1 VALUES ('-1234.1e2'); @@ -627,7 +627,7 @@ DROP TABLE t1; --echo # ---echo # Testing cs->cset->scan +--echo # Testing scan --echo # CREATE TABLE t1 (a int); INSERT INTO t1 VALUES ('1 '); diff --git a/mysql-test/main/ctype_utf32.result b/mysql-test/main/ctype_utf32.result index da71f6eb59c..d7717ece210 100644 --- a/mysql-test/main/ctype_utf32.result +++ b/mysql-test/main/ctype_utf32.result @@ -1083,7 +1083,7 @@ select left('aaa','1'); left('aaa','1') a # -# Testing cs->cset->strtoll10() +# Testing strtoll10() # SELECT @@character_set_connection; @@character_set_connection @@ -2315,7 +2315,7 @@ Warning 1292 Truncated incorrect INTEGER value: '1IJ3' # MDEV-9711 NO PAD Collatons # SET character_set_connection=utf32; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -2453,7 +2453,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -2591,8 +2591,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -2730,7 +2730,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -2868,7 +2868,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; # # MDEV-22111 ERROR 1064 & 1033 and SIGSEGV on CREATE TABLE w/ various charsets on 10.4/5 optimized builds | Assertion `(uint) (table_check_constraints - share->check_constraints) == (uint) (share->table_check_constraints - share->field_check_constraints)' failed # 10.2 tests diff --git a/mysql-test/main/ctype_utf32.test b/mysql-test/main/ctype_utf32.test index 891fd14d15f..59cc13015af 100644 --- a/mysql-test/main/ctype_utf32.test +++ b/mysql-test/main/ctype_utf32.test @@ -554,12 +554,12 @@ drop table t1; set names latin1; set collation_connection=utf32_general_ci; # -# Testing cs->coll->instr() +# Testing instr() # select position('bb' in 'abba'); # -# Testing cs->coll->hash_sort() +# Testing hash_sort() # create table t1 (a varchar(10) character set utf32) engine=heap; insert into t1 values ('a'),('A'),('b'),('B'); @@ -568,17 +568,17 @@ select hex(min(binary a)),count(*) from t1 group by a; drop table t1; # -# Testing cs->cset->numchars() +# Testing numchars() # select char_length('abcd'), octet_length('abcd'); # -# Testing cs->cset->charpos() +# Testing charpos() # select left('abcd',2); # -# Testing cs->cset->well_formed_length() +# Testing well_formed_length() # create table t1 (a varchar(10) character set utf32); insert into t1 values (_utf32 0x0010FFFF); @@ -625,7 +625,7 @@ select hex(s1) from t1 where s1 = 0xfffd; drop table t1; # -# Testing cs->cset->lengthsp() +# Testing lengthsp() # create table t1 (a char(10)) character set utf32; insert into t1 values ('a '); @@ -633,13 +633,13 @@ select hex(a) from t1; drop table t1; # -# Testing cs->cset->caseup() and cs->cset->casedn() +# Testing caseup() and casedn() # select upper('abcd'), lower('ABCD'); # # TODO: str_to_datetime() is broken and doesn't work with ucs2 and utf32 -# Testing cs->cset->snprintf() +# Testing snprintf() # #create table t1 (a date); #insert into t1 values ('2007-09-16'); @@ -647,11 +647,11 @@ select upper('abcd'), lower('ABCD'); #drop table t1; # -# Testing cs->cset->l10tostr +# Testing l10tostr # !!! Not used in the code # -# Testing cs->cset->ll10tostr +# Testing ll10tostr # create table t1 (a varchar(10) character set utf32); insert into t1 values (123456); @@ -659,16 +659,16 @@ select a, hex(a) from t1; drop table t1; # -# Testing cs->cset->fill +# Testing fill # SOUNDEX fills strings with DIGIT ZERO up to four characters select hex(soundex('a')); # -# Testing cs->cset->strntol +# Testing strntol # !!! Not used in the code # -# Testing cs->cset->strntoul +# Testing strntoul # create table t1 (a enum ('a','b','c')) character set utf32; insert into t1 values ('1'); @@ -676,14 +676,14 @@ select * from t1; drop table t1; # -# Testing cs->cset->strntoll and cs->cset->strntoull +# Testing strntoll and strntoull # set names latin1; select hex(conv(convert('123' using utf32), -10, 16)); select hex(conv(convert('123' using utf32), 10, 16)); # -# Testing cs->cset->strntod +# Testing strntod # set names latin1; set character_set_connection=utf32; @@ -691,12 +691,12 @@ select 1.1 + '1.2'; select 1.1 + '1.2xxx'; # Testing strntoll10_utf32 -# Testing cs->cset->strtoll10 +# Testing strtoll10 select left('aaa','1'); --source include/ctype_strtoll10.inc # -# Testing cs->cset->strntoull10rnd +# Testing strntoull10rnd # create table t1 (a int); insert into t1 values ('-1234.1e2'); @@ -706,7 +706,7 @@ select * from t1; drop table t1; # -# Testing cs->cset->scan +# Testing scan # create table t1 (a int); insert into t1 values ('1 '); diff --git a/mysql-test/main/ctype_utf32_uca.result b/mysql-test/main/ctype_utf32_uca.result index 3f90bedd1c1..a344672579e 100644 --- a/mysql-test/main/ctype_utf32_uca.result +++ b/mysql-test/main/ctype_utf32_uca.result @@ -7338,7 +7338,7 @@ DROP TABLE t1; # MDEV-10877 xxx_unicode_nopad_ci collations # SET NAMES utf8, character_set_connection=utf32; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -7476,7 +7476,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -7614,8 +7614,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -7753,7 +7753,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -7891,7 +7891,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; SET NAMES utf8, collation_connection=utf32_unicode_520_nopad_ci; # # MDEV-14350 Index use with collation utf8mb4_unicode_nopad_ci on LIKE pattern with wrong results diff --git a/mysql-test/main/ctype_utf32_uca.test b/mysql-test/main/ctype_utf32_uca.test index 42635d1464d..f84093c4587 100644 --- a/mysql-test/main/ctype_utf32_uca.test +++ b/mysql-test/main/ctype_utf32_uca.test @@ -144,7 +144,7 @@ set collation_connection=utf32_unicode_ci; # -# Test my_like_range and contractions +# Test like_range and contractions # SET collation_connection=utf32_czech_ci; --source include/ctype_czech.inc diff --git a/mysql-test/main/ctype_utf8.result b/mysql-test/main/ctype_utf8.result index 532c332af2f..967cfdf8fbc 100644 --- a/mysql-test/main/ctype_utf8.result +++ b/mysql-test/main/ctype_utf8.result @@ -3283,7 +3283,7 @@ t1 CREATE TABLE `t1` ( drop table t1; select coercibility(uuid()), coercibility(cast('a' as char character set latin1)); coercibility(uuid()) coercibility(cast('a' as char character set latin1)) -4 2 +5 2 select charset(concat(uuid(), cast('a' as char character set latin1))); charset(concat(uuid(), cast('a' as char character set latin1))) latin1 @@ -5409,18 +5409,21 @@ DROP TABLE t1; # # Bug#11764503 (Bug#57341) Query in EXPLAIN EXTENDED shows wrong characters # +# Emulate utf8 client erroneously started with --default-character-set=latin1, +# # as in the bug report. EXPLAIN output should still be pretty readable SET NAMES latin1; EXPLAIN EXTENDED SELECT 'abcdÃÂÃÄÅ', _latin1'abcdÃÂÃÄÅ', _utf8'abcdÃÂÃÄÅ' AS u; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 select 'abcdÃÂÃÄÅ' AS `abcdÃÂÃÄÅ`,_latin1'abcd\xC3\x81\xC3\x82\xC3\x83\xC3\x84\xC3\x85' AS `abcdÃÂÃÄÅ`,_utf8'abcd\xC3\x81\xC3\x82\xC3\x83\xC3\x84\xC3\x85' AS `u` +Note 1003 select 'abcdÃ\0081ÂÃÄÅ' AS `abcdÃ\0081ÂÃÄÅ`,_latin1'abcd\xC3\x81\xC3\x82\xC3\x83\xC3\x84\xC3\x85' AS `abcdÃ\0081ÂÃÄÅ`,_utf8'abcd\xC3\x81\xC3\x82\xC3\x83\xC3\x84\xC3\x85' AS `u` +# Test normal utf8 SET NAMES utf8; EXPLAIN EXTENDED SELECT 'abcdÃÂÃÄÅ', _latin1'abcdÃÂÃÄÅ', _utf8'abcdÃÂÃÄÅ'; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 select 'abcdÃÂÃÄÅ' AS `abcdÃÂÃÄÅ`,_latin1'abcd\xC3\x81\xC3\x82\xC3\x83\xC3\x84\xC3\x85' AS `abcdÃÂÂÃÄÅ`,_utf8'abcd\xC3\x81\xC3\x82\xC3\x83\xC3\x84\xC3\x85' AS `abcdÃÂÃÄÅ` +Note 1003 select 'abcdÃÂÃÄÅ' AS `abcdÃÂÃÄÅ`,_latin1'abcd\xC3\x81\xC3\x82\xC3\x83\xC3\x84\xC3\x85' AS `abcdÃ\0081ÂÃÄÅ`,_utf8'abcd\xC3\x81\xC3\x82\xC3\x83\xC3\x84\xC3\x85' AS `abcdÃÂÃÄÅ` # # Bug#11750518 41090: ORDER BY TRUNCATES GROUP_CONCAT RESULT # @@ -10686,7 +10689,7 @@ DROP TABLE t1; # # MDEV-9711 NO PAD Collatons # -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -10824,7 +10827,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -10962,8 +10965,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -11101,7 +11104,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -11239,7 +11242,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; # # MDEV-23408 Wrong result upon query from I_S and further Assertion `!alias_arg || strlen(alias_arg->str) == alias_arg->length' failed with certain connection charset # @@ -11368,3 +11371,97 @@ a # # End of 10.3 tests # +# +# Start of 10.5 tests +# +# +# MDEV-20712 Wrong data type for CAST(@a AS BINARY) for a numeric variable +# +SET NAMES utf8; +SET @a=2; +CREATE OR REPLACE TABLE t1 AS SELECT CAST(1 AS BINARY), CAST(@a AS BINARY), CAST(@b:=3 AS BINARY); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `CAST(1 AS BINARY)` varbinary(1) DEFAULT NULL, + `CAST(@a AS BINARY)` varbinary(20) DEFAULT NULL, + `CAST(@b:=3 AS BINARY)` varbinary(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +# +# MDEV-20890 Illegal mix of collations with UUID() +# +SET NAMES utf8 COLLATE utf8_unicode_ci; +SELECT uuid()>''; +uuid()>'' +1 +# +# MDEV-8844 Unreadable control characters printed as is in warnings +# +SET NAMES utf8; +# control, part1 +SELECT CAST(_utf8 0x610062 AS INT); +CAST(_utf8 0x610062 AS INT) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'a\0000b' +SELECT CAST(_utf8 0x610162 AS INT); +CAST(_utf8 0x610162 AS INT) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'a\0001b' +SELECT CAST(_utf8 0x611F62 AS INT); +CAST(_utf8 0x611F62 AS INT) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'a\001Fb' +# control, part2: U+0080..U+009F +SELECT CAST(_utf8 0x617F62 AS INT); +CAST(_utf8 0x617F62 AS INT) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'a\007Fb' +SELECT CAST(_utf8 0x61C28062 AS INT); +CAST(_utf8 0x61C28062 AS INT) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'a\0080b' +SELECT CAST(_utf8 0x61C29F62 AS INT); +CAST(_utf8 0x61C29F62 AS INT) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'a\009Fb' +# normal characters +SELECT CAST(_utf8 0x612062 AS INT); +CAST(_utf8 0x612062 AS INT) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'a b' +SELECT CAST(_utf8 0x617E62 AS INT); +CAST(_utf8 0x617E62 AS INT) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'a~b' +SELECT CAST(_utf8 0x61C2BF62 AS INT); +CAST(_utf8 0x61C2BF62 AS INT) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'a¿b' +SELECT CAST(_utf8 'ëëë' AS INT); +CAST(_utf8 'ëëë' AS INT) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'ëëë' +SELECT CAST(_utf8 'Å“Å“Å“' AS INT); +CAST(_utf8 'Å“Å“Å“' AS INT) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'Å“Å“Å“' +SELECT CAST(_utf8 'ÑÑÑ' AS INT); +CAST(_utf8 'ÑÑÑ' AS INT) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'ÑÑÑ' +# +# End of 10.5 tests +# diff --git a/mysql-test/main/ctype_utf8.test b/mysql-test/main/ctype_utf8.test index 2e1f1e230f1..d01190b2049 100644 --- a/mysql-test/main/ctype_utf8.test +++ b/mysql-test/main/ctype_utf8.test @@ -1600,11 +1600,12 @@ DROP TABLE t1; --echo # --echo # Bug#11764503 (Bug#57341) Query in EXPLAIN EXTENDED shows wrong characters --echo # -# Emulate utf8 client erroneously started with --default-character-set=latin1, -# as in the bug report. EXPLAIN output should still be pretty readable + +--echo # Emulate utf8 client erroneously started with --default-character-set=latin1, +--echo # # as in the bug report. EXPLAIN output should still be pretty readable SET NAMES latin1; EXPLAIN EXTENDED SELECT 'abcdÃÂÃÄÅ', _latin1'abcdÃÂÃÄÅ', _utf8'abcdÃÂÃÄÅ' AS u; -# Test normal utf8 +--echo # Test normal utf8 SET NAMES utf8; EXPLAIN EXTENDED SELECT 'abcdÃÂÃÄÅ', _latin1'abcdÃÂÃÄÅ', _utf8'abcdÃÂÃÄÅ'; @@ -2297,3 +2298,53 @@ VALUES (_latin1 0xDF) UNION VALUES(_utf8'a' COLLATE utf8_bin); --echo # --echo # End of 10.3 tests --echo # + + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-20712 Wrong data type for CAST(@a AS BINARY) for a numeric variable +--echo # + +SET NAMES utf8; +SET @a=2; +CREATE OR REPLACE TABLE t1 AS SELECT CAST(1 AS BINARY), CAST(@a AS BINARY), CAST(@b:=3 AS BINARY); +SHOW CREATE TABLE t1; +DROP TABLE t1; + +--echo # +--echo # MDEV-20890 Illegal mix of collations with UUID() +--echo # + +SET NAMES utf8 COLLATE utf8_unicode_ci; +SELECT uuid()>''; + + +--echo # +--echo # MDEV-8844 Unreadable control characters printed as is in warnings +--echo # +SET NAMES utf8; +--echo # control, part1 +SELECT CAST(_utf8 0x610062 AS INT); +SELECT CAST(_utf8 0x610162 AS INT); +SELECT CAST(_utf8 0x611F62 AS INT); + +--echo # control, part2: U+0080..U+009F +SELECT CAST(_utf8 0x617F62 AS INT); +SELECT CAST(_utf8 0x61C28062 AS INT); +SELECT CAST(_utf8 0x61C29F62 AS INT); + +--echo # normal characters +SELECT CAST(_utf8 0x612062 AS INT); +SELECT CAST(_utf8 0x617E62 AS INT); +SELECT CAST(_utf8 0x61C2BF62 AS INT); +SELECT CAST(_utf8 'ëëë' AS INT); +SELECT CAST(_utf8 'Å“Å“Å“' AS INT); +SELECT CAST(_utf8 'ÑÑÑ' AS INT); + + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/ctype_utf8_def_upgrade.result b/mysql-test/main/ctype_utf8_def_upgrade.result index 921b5200aca..4f8a2b27db2 100644 --- a/mysql-test/main/ctype_utf8_def_upgrade.result +++ b/mysql-test/main/ctype_utf8_def_upgrade.result @@ -10,14 +10,14 @@ SELECT @@character_set_database; latin1 SET @@character_set_database="latin1"; SELECT COUNT(*) FROM t1; -ERROR HY000: Got error 190 "Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine. You have to dump an" from storage engine MyISAM +ERROR HY000: Got error 190 "Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine. You may have retry " from storage engine MyISAM CHECK TABLE t1; Table Op Msg_type Msg_text -test.t1 check Error Got error 190 "Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine. You have to dump an" from storage engine MyISAM +test.t1 check Error Got error 190 "Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine. You may have retry " from storage engine MyISAM test.t1 check error Corrupt REPAIR TABLE t1; Table Op Msg_type Msg_text -test.t1 repair Error Got error 190 "Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine. You have to dump an" from storage engine MyISAM +test.t1 repair Error Got error 190 "Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine. You may have retry " from storage engine MyISAM test.t1 repair error Corrupt REPAIR TABLE t1 USE_FRM; Table Op Msg_type Msg_text @@ -64,7 +64,7 @@ SELECT @@character_set_database, 'taken from db.opt' AS comment; @@character_set_database comment latin1 taken from db.opt SELECT COUNT(*) FROM t1; -ERROR HY000: Got error 190 "Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine. You have to dump an" from storage engine MyISAM +ERROR HY000: Got error 190 "Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine. You may have retry " from storage engine MyISAM REPAIR TABLE t1 USE_FRM; Table Op Msg_type Msg_text db1.t1 repair status OK diff --git a/mysql-test/main/ctype_utf8_uca.result b/mysql-test/main/ctype_utf8_uca.result index 23e9802b61a..ef64203bbbe 100644 --- a/mysql-test/main/ctype_utf8_uca.result +++ b/mysql-test/main/ctype_utf8_uca.result @@ -5,7 +5,7 @@ # MDEV-10877 xxx_unicode_nopad_ci collations # SET NAMES utf8; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -143,7 +143,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -281,8 +281,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -420,7 +420,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -558,7 +558,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; SET NAMES utf8 COLLATE utf8_unicode_nopad_ci; # # MDEV-14350 Index use with collation utf8mb4_unicode_nopad_ci on LIKE pattern with wrong results diff --git a/mysql-test/main/ctype_utf8mb4.result b/mysql-test/main/ctype_utf8mb4.result index 2762873b9c7..20ebfd255b2 100644 --- a/mysql-test/main/ctype_utf8mb4.result +++ b/mysql-test/main/ctype_utf8mb4.result @@ -3570,7 +3570,7 @@ DROP TABLE t1; # # MDEV-9711 NO PAD Collatons # -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -3708,7 +3708,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -3846,8 +3846,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -3985,7 +3985,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -4123,7 +4123,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; # # MDEV-10867 PREPARE..EXECUTE is not consistent about non-ASCII characters # diff --git a/mysql-test/main/ctype_utf8mb4_uca.result b/mysql-test/main/ctype_utf8mb4_uca.result index 0712ca63abd..34cc443e6f6 100644 --- a/mysql-test/main/ctype_utf8mb4_uca.result +++ b/mysql-test/main/ctype_utf8mb4_uca.result @@ -6022,7 +6022,7 @@ DROP TABLE t1; # MDEV-9711 NO PAD Collatons # SET NAMES utf8mb4; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -6160,7 +6160,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -6298,8 +6298,8 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; -SET STORAGE_ENGINE=MyISAM; +SET DEFAULT_STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=MyISAM; # # Start of ctype_pad.inc # @@ -6437,7 +6437,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=HEAP; +SET DEFAULT_STORAGE_ENGINE=HEAP; # # Start of ctype_pad.inc # @@ -6575,7 +6575,7 @@ DROP TABLE t1; # # End of ctype_pad.inc # -SET STORAGE_ENGINE=Default; +SET DEFAULT_STORAGE_ENGINE=Default; SET NAMES utf8mb4 COLLATE utf8mb4_unicode_520_nopad_ci; # # MDEV-14350 Index use with collation utf8mb4_unicode_nopad_ci on LIKE pattern with wrong results diff --git a/mysql-test/main/ctype_utf8mb4_uca.test b/mysql-test/main/ctype_utf8mb4_uca.test index 160cb48bad6..7a95da8468c 100644 --- a/mysql-test/main/ctype_utf8mb4_uca.test +++ b/mysql-test/main/ctype_utf8mb4_uca.test @@ -45,7 +45,7 @@ DROP TABLE t1; --echo # # # Bug#57737 Character sets: search fails with like, contraction, index -# Test my_like_range and contractions +# Test like_range and contractions # SET collation_connection=utf8mb4_czech_ci; --source include/ctype_czech.inc diff --git a/mysql-test/main/deadlock_innodb.result b/mysql-test/main/deadlock_innodb.result index fca0ff6be0c..09958bf0413 100644 --- a/mysql-test/main/deadlock_innodb.result +++ b/mysql-test/main/deadlock_innodb.result @@ -115,7 +115,7 @@ disconnect con1; disconnect con2; drop table t1, t2; End of 4.1 tests -set storage_engine=innodb; +set default_storage_engine=innodb; drop table if exists a; drop table if exists A; create table A (c int); @@ -123,5 +123,5 @@ insert into A (c) values (0); create table a as select * from A; drop table A; drop table if exists a; -set storage_engine=default; +set default_storage_engine=default; End of 5.0 tests. diff --git a/mysql-test/main/delayed.test b/mysql-test/main/delayed.test index 573985fec1f..a96ffdfcca9 100644 --- a/mysql-test/main/delayed.test +++ b/mysql-test/main/delayed.test @@ -15,9 +15,9 @@ # limit the test to engines which support INSERT DELAYED disable_query_log; --require include/true.require -select @@global.storage_engine in +select @@global.default_storage_engine in ("memory","myisam","archive","blackhole") and -@@session.storage_engine in +@@session.default_storage_engine in ("memory","myisam","archive","blackhole") as `TRUE`; enable_query_log; diff --git a/mysql-test/main/delete_innodb.result b/mysql-test/main/delete_innodb.result new file mode 100644 index 00000000000..b9f4c8bdaf5 --- /dev/null +++ b/mysql-test/main/delete_innodb.result @@ -0,0 +1,26 @@ +# Tests for delete with INNODB +# +# MDEV-22187: SIGSEGV in ha_innobase::cmp_ref on DELETE +# +SET @save_sort_buffer_size= @@sort_buffer_size; +SET sort_buffer_size=1024; +CREATE TABLE t1(c1 CHAR(255) PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (0), ('a'), ('b'); +ANALYZE TABLE t1 PERSISTENT FOR ALL; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +SELECT * FROM t1; +c1 +0 +a +b +EXPLAIN DELETE b FROM t1 AS a JOIN t1 AS b; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE a index NULL PRIMARY 255 NULL 3 Using index +1 SIMPLE b ALL NULL NULL NULL NULL 3 +DELETE b FROM t1 AS a JOIN t1 AS b; +SELECT * FROM t1; +c1 +SET sort_buffer_size=@save_sort_buffer_size; +DROP TABLE t1; diff --git a/mysql-test/main/delete_innodb.test b/mysql-test/main/delete_innodb.test new file mode 100644 index 00000000000..c5c5c5d0172 --- /dev/null +++ b/mysql-test/main/delete_innodb.test @@ -0,0 +1,22 @@ +--source include/have_innodb.inc +--source include/have_sequence.inc + +--echo # Tests for delete with INNODB + +--echo # +--echo # MDEV-22187: SIGSEGV in ha_innobase::cmp_ref on DELETE +--echo # + +SET @save_sort_buffer_size= @@sort_buffer_size; +SET sort_buffer_size=1024; +CREATE TABLE t1(c1 CHAR(255) PRIMARY KEY) ENGINE=InnoDB; + +INSERT INTO t1 VALUES (0), ('a'), ('b'); +ANALYZE TABLE t1 PERSISTENT FOR ALL; +SELECT * FROM t1; +EXPLAIN DELETE b FROM t1 AS a JOIN t1 AS b; +DELETE b FROM t1 AS a JOIN t1 AS b; +SELECT * FROM t1; + +SET sort_buffer_size=@save_sort_buffer_size; +DROP TABLE t1; diff --git a/mysql-test/main/derived.result b/mysql-test/main/derived.result index ac7d3b2d879..006f41236f5 100644 --- a/mysql-test/main/derived.result +++ b/mysql-test/main/derived.result @@ -324,11 +324,11 @@ create table t2 (a int, b int, primary key (a)); insert into t2 values (1,7),(2,7); explain select a from t2 where a>1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index +1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 1 Using where; Using index explain select a from (select a from t2 where a>1) tt; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 -2 DERIVED t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index +2 DERIVED t2 range PRIMARY PRIMARY 4 NULL 1 Using where; Using index drop table t2; CREATE TABLE `t1` ( `itemid` int(11) NOT NULL default '0', `grpid` varchar(15) NOT NULL default '', `vendor` int(11) NOT NULL default '0', `date_` date NOT NULL default '0000-00-00', `price` decimal(12,2) NOT NULL default '0.00', PRIMARY KEY (`itemid`,`grpid`,`vendor`,`date_`), KEY `itemid` (`itemid`,`vendor`), KEY `itemid_2` (`itemid`,`date_`)); insert into t1 values (128, 'rozn', 2, curdate(), 10), @@ -1064,16 +1064,19 @@ INSERT INTO t2 VALUES (NULL),(NULL); CREATE TABLE t3 (c VARCHAR(1024) CHARACTER SET utf8, d INT) ENGINE=MyISAM; CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v3 AS SELECT * FROM t3; INSERT INTO t3 VALUES ('abc',NULL),('def',4); +INSERT INTO t1 select seq from seq_1_to_1000; +INSERT INTO t2 select seq+1000 from seq_1_to_1000; +INSERT INTO t3 select 'qqq',seq+2000 from seq_1_to_1000; set @save_join_cache_level= @@join_cache_level; SET join_cache_level= 8; explain SELECT * FROM v1, t2, v3 WHERE a = c AND b = d; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 -1 PRIMARY <derived3> hash_ALL NULL #hash#$hj 3075 func 2 Using where; Using join buffer (flat, BNLH join) +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 1002 +1 PRIMARY <derived3> hash_ALL NULL #hash#$hj 3075 func 1002 Using where; Using join buffer (flat, BNLH join) 1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 v3.d 1 Using index -3 DERIVED t3 ALL NULL NULL NULL NULL 2 -2 DERIVED t1 ALL NULL NULL NULL NULL 2 +3 DERIVED t3 ALL NULL NULL NULL NULL 1002 +2 DERIVED t1 ALL NULL NULL NULL NULL 1002 SELECT * FROM v1, t2, v3 WHERE a = c AND b = d; a b c d DROP VIEW v1, v3; diff --git a/mysql-test/main/derived.test b/mysql-test/main/derived.test index f4477ce8550..8c41f80ffbd 100644 --- a/mysql-test/main/derived.test +++ b/mysql-test/main/derived.test @@ -1,5 +1,6 @@ # Initialize --source include/default_optimizer_switch.inc +--source include/have_sequence.inc --disable_warnings drop table if exists t1,t2,t3; @@ -919,6 +920,9 @@ INSERT INTO t2 VALUES (NULL),(NULL); CREATE TABLE t3 (c VARCHAR(1024) CHARACTER SET utf8, d INT) ENGINE=MyISAM; CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v3 AS SELECT * FROM t3; INSERT INTO t3 VALUES ('abc',NULL),('def',4); +INSERT INTO t1 select seq from seq_1_to_1000; +INSERT INTO t2 select seq+1000 from seq_1_to_1000; +INSERT INTO t3 select 'qqq',seq+2000 from seq_1_to_1000; set @save_join_cache_level= @@join_cache_level; SET join_cache_level= 8; diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result index 01a863ccb8b..b3a4dc4c253 100644 --- a/mysql-test/main/derived_cond_pushdown.result +++ b/mysql-test/main/derived_cond_pushdown.result @@ -8828,9 +8828,21 @@ EXPLAIN "query_block": { "select_id": 1, "table": { - "table_name": "<derived2>", + "table_name": "t1", "access_type": "ALL", - "rows": 3, + "rows": 4, + "filtered": 100, + "attached_condition": "t1.id2 is not null" + }, + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["id2"], + "ref": ["test.t1.id2"], + "rows": 2, "filtered": 100, "attached_condition": "vc.ct > 0", "materialized": { @@ -8850,18 +8862,6 @@ EXPLAIN } } } - }, - "block-nl-join": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 4, - "filtered": 100 - }, - "buffer_type": "flat", - "buffer_size": "163", - "join_type": "BNL", - "attached_condition": "t1.id2 = vc.id2" } } } @@ -9078,9 +9078,8 @@ WHERE d_tab.e>1 ) ; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 5 -1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func,func 1 -2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 5 Using where +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where +1 PRIMARY <derived3> ref key0 key0 10 test.t1.a,test.t1.b 2 FirstMatch(t1) 3 DERIVED t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE (t1.a,t1.b) IN @@ -9103,44 +9102,33 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, - "filtered": 100 + "filtered": 100, + "attached_condition": "t1.a > 1 and t1.a is not null and t1.b is not null" }, "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "8", + "table_name": "<derived3>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "10", "used_key_parts": ["e", "max_f"], - "ref": ["func", "func"], - "rows": 1, + "ref": ["test.t1.a", "test.t1.b"], + "rows": 2, "filtered": 100, + "first_match": "t1", "materialized": { - "unique": 1, "query_block": { - "select_id": 2, - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "d_tab.e > 1", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_f > 18", - "filesort": { - "sort_key": "t2.e", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t2.e > 1" - } - } - } + "select_id": 3, + "having_condition": "max_f > 18", + "filesort": { + "sort_key": "t2.e", + "temporary_table": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t2.e > 1" } } } @@ -9179,9 +9167,8 @@ WHERE d_tab.max_f<25 ) ; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 5 -1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func,func 1 -2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 5 Using where +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where +1 PRIMARY <derived3> ref key0 key0 10 test.t1.a,test.t1.b 2 FirstMatch(t1) 3 DERIVED t2 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE (t1.a,t1.b) IN @@ -9204,43 +9191,32 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, - "filtered": 100 + "filtered": 100, + "attached_condition": "t1.b < 25 and t1.a is not null and t1.b is not null" }, "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "8", + "table_name": "<derived3>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "10", "used_key_parts": ["e", "max_f"], - "ref": ["func", "func"], - "rows": 1, + "ref": ["test.t1.a", "test.t1.b"], + "rows": 2, "filtered": 100, + "first_match": "t1", "materialized": { - "unique": 1, "query_block": { - "select_id": 2, - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "d_tab.max_f < 25", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_f > 18 and max_f < 25", - "filesort": { - "sort_key": "t2.e", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 5, - "filtered": 100 - } - } - } + "select_id": 3, + "having_condition": "max_f > 18 and max_f < 25", + "filesort": { + "sort_key": "t2.e", + "temporary_table": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 5, + "filtered": 100 } } } @@ -14339,16 +14315,16 @@ a b max_c a b c 1 21 345 3 21 231 select * from v1,t2 where (v1.b=t2.b) and (v1.a<5); a b max_c a b c -2 33 7 5 33 207 4 33 123 5 33 207 -2 33 7 8 33 117 +2 33 7 5 33 207 4 33 123 8 33 117 -1 21 345 3 21 231 +2 33 7 8 33 117 3 21 500 3 21 231 +1 21 345 3 21 231 explain select * from v1,t2 where (v1.b=t2.b) and (v1.a<5); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY <derived2> ALL NULL NULL NULL NULL 5 Using where -1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t2.b 2 Using where 2 DERIVED t3 range i1 i1 5 NULL 5 Using index condition explain format=json select * from v1,t2 where (v1.b=t2.b) and (v1.a<5); EXPLAIN @@ -14356,9 +14332,21 @@ EXPLAIN "query_block": { "select_id": 1, "table": { - "table_name": "<derived2>", + "table_name": "t2", "access_type": "ALL", - "rows": 5, + "rows": 9, + "filtered": 100, + "attached_condition": "t2.b is not null" + }, + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["b"], + "ref": ["test.t2.b"], + "rows": 2, "filtered": 100, "attached_condition": "v1.a < 5", "materialized": { @@ -14377,18 +14365,6 @@ EXPLAIN } } } - }, - "block-nl-join": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "buffer_type": "flat", - "buffer_size": "173", - "join_type": "BNL", - "attached_condition": "t2.b = v1.b" } } } @@ -15472,7 +15448,7 @@ EXPLAIN "access_type": "ALL", "possible_keys": ["idx_b"], "rows": 12, - "filtered": 83.333, + "filtered": 83.33333588, "attached_condition": "t1.b <= 5 and t1.a is not null" }, "table": { @@ -15747,7 +15723,7 @@ EXPLAIN "access_type": "ALL", "possible_keys": ["idx_b"], "rows": 12, - "filtered": 83.333, + "filtered": 83.33333588, "attached_condition": "t3.b <= 15 and t3.a is not null and t3.c is not null" }, "table": { @@ -15900,7 +15876,7 @@ EXPLAIN "access_type": "ALL", "possible_keys": ["idx_b"], "rows": 12, - "filtered": 83.333, + "filtered": 83.33333588, "attached_condition": "t3.b <= 15 and t3.a is not null and t3.c is not null" }, "table": { @@ -16132,7 +16108,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 90, - "filtered": 63.281, + "filtered": 63.28125, "attached_condition": "t2.b < 40 and t2.a is not null" }, "table": { @@ -16629,7 +16605,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 90, - "filtered": 63.281, + "filtered": 63.28125, "attached_condition": "t2.b < 40 and t2.a is not null" }, "table": { @@ -17318,7 +17294,8 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 2, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 50, "attached_condition": "v1.a = 3", @@ -17341,7 +17318,8 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 50, "attached_condition": "t1.a = 3" @@ -17401,7 +17379,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1 1 PRIMARY <derived2> ref key0 key0 5 test.t3.id 2 3 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 -2 DERIVED cp2 index NULL a 5 NULL 7 Using index +2 DERIVED cp2 range NULL a 5 NULL 8 Using index for group-by explain format=json select * from t1, (select a from t1 cp2 group by a) dt, t3 where dt.a = t1.a and t1.a = t3.id and t1.a in (select a from t2); EXPLAIN @@ -17464,13 +17442,13 @@ EXPLAIN "select_id": 2, "table": { "table_name": "cp2", - "access_type": "index", + "access_type": "range", "key": "a", "key_length": "5", "used_key_parts": ["a"], - "rows": 7, + "rows": 8, "filtered": 100, - "using_index": true + "using_index_for_group_by": true } } } diff --git a/mysql-test/main/derived_opt.result b/mysql-test/main/derived_opt.result index 907c97e92d4..cf0c1cb617f 100644 --- a/mysql-test/main/derived_opt.result +++ b/mysql-test/main/derived_opt.result @@ -137,10 +137,10 @@ create table t2 (a int, b int, primary key (a)); insert into t2 values (1,7),(2,7); explain select a from t2 where a>1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index +1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 1 Using where; Using index explain select a from (select a from t2 where a>1) tt; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index +1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 1 Using where; Using index drop table t2; create table t1 ( diff --git a/mysql-test/main/derived_split_innodb.result b/mysql-test/main/derived_split_innodb.result index 63db8c94dde..9edf9a1f2ae 100644 --- a/mysql-test/main/derived_split_innodb.result +++ b/mysql-test/main/derived_split_innodb.result @@ -9,6 +9,7 @@ KEY c1 (c1), KEY n1_c1_n2 (n1,c1,n2) ) ENGINE=InnoDB; INSERT INTO t1 VALUES (0, 2, 'a'), (1, 3, 'a'); +insert into t1 select seq+1,seq+2,'c' from seq_1_to_1000; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected @@ -16,7 +17,7 @@ test.t1 analyze status OK EXPLAIN SELECT t1.n1 FROM t1, (SELECT n1, n2 FROM t1 WHERE c1 = 'a' GROUP BY n1) as t WHERE t.n1 = t1.n1 AND t.n2 = t1.n2 AND c1 = 'a' GROUP BY n1; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index c1,n1_c1_n2 n1_c1_n2 9 NULL 2 Using where; Using index +1 PRIMARY t1 ref c1,n1_c1_n2 c1 1 const 2 Using index condition; Using where; Using temporary; Using filesort 1 PRIMARY <derived2> ref key0 key0 8 test.t1.n1,test.t1.n2 2 2 LATERAL DERIVED t1 ref c1,n1_c1_n2 n1_c1_n2 4 test.t1.n1 1 Using where; Using index SELECT t1.n1 FROM t1, (SELECT n1, n2 FROM t1 WHERE c1 = 'a' GROUP BY n1) as t @@ -205,8 +206,8 @@ t2 where t1.id = dt.id and t1.itemid = dt.itemid and t2.id=t1.itemid; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 1 -1 PRIMARY t1 ref idx idx 4 test.t2.id 1 -1 PRIMARY <derived2> ref key0 key0 9 test.t2.id,test.t1.id 2 +1 PRIMARY <derived2> ref key1 key1 4 test.t2.id 2 +1 PRIMARY t1 ALL idx NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join) 2 DERIVED t3 ref idx1,idx2 idx1 4 const 5 Using where; Using index select t1.id, t1.itemid, dt.id, t2.id from t1, @@ -224,8 +225,8 @@ t2 where t1.id = dt.id and t1.itemid = dt.itemid and t2.id=t1.itemid; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 1 -1 PRIMARY t1 ref idx idx 4 test.t2.id 1 -1 PRIMARY <derived2> ref key0 key0 9 test.t2.id,test.t1.id 2 +1 PRIMARY <derived2> ref key1 key1 4 test.t2.id 2 +1 PRIMARY t1 ALL idx NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join) 2 DERIVED t3 ref idx1 idx1 4 const 5 Using where; Using index select t1.id, t1.itemid, dt.id, t2.id from t1, diff --git a/mysql-test/main/derived_split_innodb.test b/mysql-test/main/derived_split_innodb.test index 22793b448da..bee9ef497b6 100644 --- a/mysql-test/main/derived_split_innodb.test +++ b/mysql-test/main/derived_split_innodb.test @@ -1,5 +1,6 @@ --source include/have_innodb.inc --source include/default_optimizer_switch.inc +--source include/have_sequence.inc --echo # --echo # MDEV-16917: do not use splitting for derived with join cache @@ -13,6 +14,7 @@ CREATE TABLE t1 ( KEY n1_c1_n2 (n1,c1,n2) ) ENGINE=InnoDB; INSERT INTO t1 VALUES (0, 2, 'a'), (1, 3, 'a'); +insert into t1 select seq+1,seq+2,'c' from seq_1_to_1000; ANALYZE TABLE t1; diff --git a/mysql-test/main/disabled.def b/mysql-test/main/disabled.def index 8ba5b271c2b..d3366587ee5 100644 --- a/mysql-test/main/disabled.def +++ b/mysql-test/main/disabled.def @@ -17,3 +17,6 @@ mysql_embedded : Bug#12561297 2011-05-14 Anitha Dependent on PB2 chang file_contents : MDEV-6526 these files are not installed anymore max_statement_time : cannot possibly work, depends on timing partition_open_files_limit : open_files_limit check broken by MDEV-18360 +partition_innodb : Waiting for fix MDEV-20169 +type_enum : Waiting for fix MDEV-6978 +type_set : Waiting for fix MDEV-6978 diff --git a/mysql-test/main/distinct.result b/mysql-test/main/distinct.result index 8fcc45e740a..2062ff0091d 100644 --- a/mysql-test/main/distinct.result +++ b/mysql-test/main/distinct.result @@ -538,10 +538,10 @@ PRIMARY KEY (a,b)); INSERT INTO t2 VALUES (1,1,1,50), (1,2,3,40), (2,1,3,4); EXPLAIN SELECT DISTINCT a FROM t2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 index NULL PRIMARY 8 NULL 3 Using index +1 SIMPLE t2 range NULL PRIMARY 4 NULL 4 Using index for group-by EXPLAIN SELECT DISTINCT a,a FROM t2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 index NULL PRIMARY 8 NULL 3 Using index +1 SIMPLE t2 range NULL PRIMARY 4 NULL 4 Using index for group-by EXPLAIN SELECT DISTINCT b,a FROM t2; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 index NULL PRIMARY 8 NULL 3 Using index @@ -756,7 +756,7 @@ INSERT INTO t1(a, b, c) VALUES (1, 1, 1), (1, 2, 3); EXPLAIN SELECT DISTINCT a, b, d, c FROM t1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL a 16 NULL 6 Using index +1 SIMPLE t1 range NULL PRIMARY 16 NULL 7 Using index for group-by; Using temporary SELECT DISTINCT a, b, d, c FROM t1; a b d c 1 1 0 1 diff --git a/mysql-test/main/drop-no_root.result b/mysql-test/main/drop-no_root.result deleted file mode 100644 index 3e1f2fe2cf0..00000000000 --- a/mysql-test/main/drop-no_root.result +++ /dev/null @@ -1,28 +0,0 @@ - -# -- -# -- Bug#26704: Failing DROP DATABASE brings mysql-client out of sync. -# -- - -DROP DATABASE IF EXISTS mysql_test; - -CREATE DATABASE mysql_test; -CREATE TABLE mysql_test.t1(c INT); -use mysql_test; - -chmod 000 mysql_test/t1.frm - -DROP DATABASE mysql_test; - -SELECT DATABASE(); -DATABASE() -mysql_test - -rm -f mysql_test/t1.MYD mysql_test/t1.MYI -chmod 666 mysql_test/t1.frm -rm -f mysql_test/t1.frm - -DROP DATABASE mysql_test; - -use test; - -# -- End of Bug#26704. diff --git a/mysql-test/main/drop-no_root.test b/mysql-test/main/drop-no_root.test deleted file mode 100644 index 8fb5b3f74a8..00000000000 --- a/mysql-test/main/drop-no_root.test +++ /dev/null @@ -1,85 +0,0 @@ -# This test uses chmod, can't be run with root permissions ---source include/not_as_root.inc - -########################################################################### - ---echo ---echo # -- ---echo # -- Bug#26704: Failing DROP DATABASE brings mysql-client out of sync. ---echo # -- - ---echo ---disable_warnings -DROP DATABASE IF EXISTS mysql_test; ---enable_warnings - ---echo -CREATE DATABASE mysql_test; -CREATE TABLE mysql_test.t1(c INT); - -use mysql_test; - -let $MYSQLD_DATADIR= `select @@datadir`; - ---echo ---echo chmod 000 mysql_test/t1.frm ---chmod 0000 $MYSQLD_DATADIR/mysql_test/t1.frm - -# NOTE: For the DROP DATABASE below we need: -# - disable result log because ER_DB_DROP_RMDIR contains errno, which can be -# different on different platforms. -# - expect different error codes, because Windows and UNIX behaves -# differently (see below). -# -# NOTE: Windows and UNIX behaves differently in this test case: -# -# - on UNIX when t1.frm is chmoded to 000, it is perfectly deleted -# by the first DROP DATABASE, but some other files (t1.MYI and t1.MYD) left -# in the directory. So, we have to explicitly removes them before the -# second DROP DATABASE. -# -# - on Windows when t1.frm is chmoded to 000, it is not deleted by the first -# DROP DATABASE, but all other files in the database directory are deleted. -# Thus, we have to change the t1.frm permissions again and delete it -# explicitly before the second DROP DATABASE. -# -# All those differences do not really matter for the idea of this test case: -# checking that if DROP DATABASE failed, the client is Ok. - ---echo ---disable_result_log ---error ER_DB_DROP_RMDIR,6 -DROP DATABASE mysql_test; ---enable_result_log - ---echo -SELECT DATABASE(); - -# Remove t1.MYI and t1.MYD. On UNIX it should succeed. On Windows, it fails. ---echo ---echo rm -f mysql_test/t1.MYD mysql_test/t1.MYI ---error 0, 1 ---remove_file $MYSQLD_DATADIR/mysql_test/t1.MYD ---error 0, 1 ---remove_file $MYSQLD_DATADIR/mysql_test/t1.MYI - -# Make t1.frm removable: fail on UNIX, succeed on Windows. ---echo chmod 666 mysql_test/t1.frm ---error 0, 1 ---chmod 0666 $MYSQLD_DATADIR/mysql_test/t1.frm - -# Remove t1.frm: fail on UNIX, succeed on Windows. ---echo rm -f mysql_test/t1.frm ---error 0, 1 ---remove_file $MYSQLD_DATADIR/mysql_test/t1.frm - ---echo -DROP DATABASE mysql_test; - ---echo -use test; - ---echo ---echo # -- End of Bug#26704. - -########################################################################### diff --git a/mysql-test/main/drop.result b/mysql-test/main/drop.result index f55888ad1bd..d50ffabc9fa 100644 --- a/mysql-test/main/drop.result +++ b/mysql-test/main/drop.result @@ -131,6 +131,19 @@ create table mysql_test.`#sql-347f_7` (f1 int); create table mysql_test.`#sql-347f_8` (f1 int); drop table mysql_test.`#sql-347f_8`; drop database mysql_test; +create database mysql_test; +use mysql_test; +create table t1(c int); +drop database mysql_test; +ERROR HY000: Error dropping database (can't rmdir './mysql_test', errno: 39 "Directory not empty") +select database(); +database() +mysql_test +drop database mysql_test; +select database(); +database() +NULL +use test; # -- # -- Bug#29958: Weird message on DROP DATABASE if mysql.proc does not @@ -205,14 +218,10 @@ Warnings: Note 1051 Unknown table 'test.table1' DROP TABLE IF EXISTS table1,table2; Warnings: -Note 1051 Unknown table 'test.table1' -Note 1051 Unknown table 'test.table2' +Note 1051 Unknown table 'test.table1,test.table2' DROP VIEW IF EXISTS view1,view2,view3,view4; Warnings: -Note 4092 Unknown VIEW: 'test.view1' -Note 4092 Unknown VIEW: 'test.view2' -Note 4092 Unknown VIEW: 'test.view3' -Note 4092 Unknown VIEW: 'test.view4' +Note 4092 Unknown VIEW: 'test.view1,test.view2,test.view3,test.view4' # Test error message when trigger does not find table CREATE TABLE table1(a int); @@ -230,3 +239,20 @@ DROP TABLE table1,table2; CREATE DATABASE mysqltest; CREATE TABLE mysqltest.db(id INT); DROP DATABASE mysqltest; +# +# Verify sql_if_exists +# +DROP DATABASE mysqltest; +ERROR HY000: Can't drop database 'mysqltest'; database doesn't exist +CREATE DATABASE mysqltest; +drop table mysqltest.does_not_exists; +ERROR 42S02: Unknown table 'mysqltest.does_not_exists' +set @@session.sql_if_exists=1; +drop table mysqltest.does_not_exists; +Warnings: +Note 1051 Unknown table 'mysqltest.does_not_exists' +drop database mysqltest; +drop database mysqltest; +Warnings: +Note 1008 Can't drop database 'mysqltest'; database doesn't exist +set @@session.sql_if_exists=0; diff --git a/mysql-test/main/drop.test b/mysql-test/main/drop.test index fe8d39c0d7e..45ff7f364f4 100644 --- a/mysql-test/main/drop.test +++ b/mysql-test/main/drop.test @@ -1,3 +1,5 @@ +--source include/have_innodb.inc + call mtr.add_suppression("table or database name 'abc`def'"); # Initialise @@ -173,6 +175,27 @@ let $MYSQLD_DATADIR= `select @@datadir`; copy_file $MYSQLD_DATADIR/mysql_test/t1.frm $MYSQLD_DATADIR/mysql_test/#sql-347f_6.frm; drop database mysql_test; +# +# Bug#26704: Failing DROP DATABASE brings mysql-client out of sync. +# + +create database mysql_test; +use mysql_test; +create table t1(c int); + +write_file $MYSQLD_DATADIR/mysql_test/do_not_delete; +do_not_delete +EOF + +replace_result $MYSQLD_DATADIR ./ \\ / 66 39 93 39 17 39 247 39 41 39 "File exists" "Directory not empty"; +error ER_DB_DROP_RMDIR; +drop database mysql_test; +select database(); +remove_file $MYSQLD_DATADIR/mysql_test/do_not_delete; +drop database mysql_test; +select database(); +use test; + ########################################################################### --echo @@ -322,3 +345,17 @@ CREATE DATABASE mysqltest; CREATE TABLE mysqltest.db(id INT); DROP DATABASE mysqltest; +--echo # +--echo # Verify sql_if_exists +--echo # + +--error ER_DB_DROP_EXISTS +DROP DATABASE mysqltest; +CREATE DATABASE mysqltest; +--error ER_BAD_TABLE_ERROR +drop table mysqltest.does_not_exists; +set @@session.sql_if_exists=1; +drop table mysqltest.does_not_exists; +drop database mysqltest; +drop database mysqltest; +set @@session.sql_if_exists=0; diff --git a/mysql-test/main/drop_combinations.inc b/mysql-test/main/drop_combinations.inc new file mode 100644 index 00000000000..f1d8627f04f --- /dev/null +++ b/mysql-test/main/drop_combinations.inc @@ -0,0 +1,24 @@ +# +# Create all tables, sequences and views needed for drop combinations; +# + +if ($create_option != 'temporary') +{ + show tables; +} + +--echo # Generating test tables +--disable_query_log +--disable_warnings +eval create $create_option table if not exists t1 (a int); +eval create $create_option table if not exists t2 (a int); +eval create $create_option sequence if not exists s1; +eval create $create_option sequence if not exists s2; +if ($create_option != 'temporary') +{ + eval create view if not exists v1 as SELECT * from t1; + eval create view if not exists v2 as SELECT * from t2; +} + +--enable_warnings +--enable_query_log diff --git a/mysql-test/main/drop_combinations.result b/mysql-test/main/drop_combinations.result new file mode 100644 index 00000000000..a939bcd2b51 --- /dev/null +++ b/mysql-test/main/drop_combinations.result @@ -0,0 +1,878 @@ +SET @save_default_engine= @@DEFAULT_STORAGE_ENGINE; +SET default_storage_engine=myisam; +show tables; +Tables_in_test +# Generating test tables +# +# DROP TABLE +# +drop table t1,t2,t3; +ERROR 42S02: Unknown table 'test.t3' +show warnings; +Level Code Message +Error 1051 Unknown table 'test.t3' +show tables; +Tables_in_test +s1 +s2 +v1 +v2 +# Generating test tables +drop table t1,t3,t2; +ERROR 42S02: Unknown table 'test.t3' +show warnings; +Level Code Message +Error 1051 Unknown table 'test.t3' +show tables; +Tables_in_test +s1 +s2 +v1 +v2 +# Generating test tables +drop table t1,t4,t2,t3; +ERROR 42S02: Unknown table 'test.t4,test.t3' +show warnings; +Level Code Message +Error 1051 Unknown table 'test.t4,test.t3' +show tables; +Tables_in_test +s1 +s2 +v1 +v2 +# Generating test tables +drop table t1,s1,s2,t2; +show tables; +Tables_in_test +v1 +v2 +# Generating test tables +drop table t1,v1,v2,t2; +ERROR 42S02: 'test.v1' is a view +show warnings; +Level Code Message +Error 1965 'test.v1' is a view +Error 1965 'test.v2' is a view +show tables; +Tables_in_test +s1 +s2 +v1 +v2 +# Generating test tables +drop table v1,s1,s2,v2,t2; +ERROR 42S02: 'test.v1' is a view +show warnings; +Level Code Message +Error 1965 'test.v1' is a view +Error 1965 'test.v2' is a view +show tables; +Tables_in_test +t1 +v1 +v2 +# Generating test tables +drop table t1,s1,v1,t3,t4; +ERROR 42S02: 'test.v1' is a view +show warnings; +Level Code Message +Warning 1017 Can't find file: './test/t1.MYI' (errno: 2 "No such file or directory") +Error 1965 'test.v1' is a view +Error 1051 Unknown table 'test.t3,test.t4' +drop table s2,v2,t2,t1; +ERROR 42S02: 'test.v2' is a view +show warnings; +Level Code Message +Error 1965 'test.v2' is a view +Error 1051 Unknown table 'test.t1' +show tables; +Tables_in_test +v1 +v2 +# Generating test tables +drop table s1,v1,s2,v2; +ERROR 42S02: 'test.v1' is a view +show warnings; +Level Code Message +Error 1965 'test.v1' is a view +Error 1965 'test.v2' is a view +show tables; +Tables_in_test +t1 +t2 +v1 +v2 +# Generating test tables +# +# DROP TABLE with if exists +# +drop table if exists t1,t2,t3; +Warnings: +Note 1051 Unknown table 'test.t3' +show tables; +Tables_in_test +s1 +s2 +v1 +v2 +# Generating test tables +drop table if exists t1,t3,t2; +Warnings: +Note 1051 Unknown table 'test.t3' +show tables; +Tables_in_test +s1 +s2 +v1 +v2 +# Generating test tables +drop table if exists t1,t4,t2,t3; +Warnings: +Note 1051 Unknown table 'test.t4,test.t3' +show tables; +Tables_in_test +s1 +s2 +v1 +v2 +# Generating test tables +drop table if exists t1,s1,s2,t2; +show tables; +Tables_in_test +v1 +v2 +# Generating test tables +drop table if exists t1,v1,v2,t2; +Warnings: +Note 1965 'test.v1' is a view +Note 1965 'test.v2' is a view +show tables; +Tables_in_test +s1 +s2 +v1 +v2 +# Generating test tables +drop table if exists v1,s1,s2,v2,t2; +Warnings: +Note 1965 'test.v1' is a view +Note 1965 'test.v2' is a view +show tables; +Tables_in_test +t1 +v1 +v2 +# Generating test tables +drop table if exists t1,s1,v1,t3,t4; +Warnings: +Warning 1017 Can't find file: './test/t1.MYI' (errno: 2 "No such file or directory") +Note 1965 'test.v1' is a view +Note 1051 Unknown table 'test.t3,test.t4' +drop table if exists s2,v2,t2,t1; +Warnings: +Note 1965 'test.v2' is a view +Note 1051 Unknown table 'test.t1' +show tables; +Tables_in_test +v1 +v2 +# Generating test tables +drop table if exists s1,v1,s2,v2; +Warnings: +Note 1965 'test.v1' is a view +Note 1965 'test.v2' is a view +show tables; +Tables_in_test +t1 +t2 +v1 +v2 +# Generating test tables +# +# DROP TEMPORARY TABLE +# +drop table if exists t1,t2; +drop temporary table if exists tt1,tt2; +drop sequence if exists s1,s2; +drop temporary sequence if exists ss1,ss2; +drop view if exists v1,v2; +drop temporary table t1,t2,t3; +ERROR 42S02: Unknown table 'test.t1,test.t2,test.t3' +show warnings; +Level Code Message +Error 1051 Unknown table 'test.t1,test.t2,test.t3' +# Generating test tables +drop temporary table t1,t3,t2; +ERROR 42S02: Unknown table 'test.t3' +show warnings; +Level Code Message +Error 1051 Unknown table 'test.t3' +# Generating test tables +drop temporary table t1,t4,t2,t3; +ERROR 42S02: Unknown table 'test.t4,test.t3' +show warnings; +Level Code Message +Error 1051 Unknown table 'test.t4,test.t3' +# Generating test tables +drop temporary table t1,s1,s2,t2; +# Generating test tables +drop temporary table t1,v1,v2,t2; +ERROR 42S02: Unknown table 'test.v1,test.v2' +show warnings; +Level Code Message +Error 1051 Unknown table 'test.v1,test.v2' +# Generating test tables +drop temporary table v1,s1,s2,v2,t2; +ERROR 42S02: Unknown table 'test.v1,test.v2' +show warnings; +Level Code Message +Error 1051 Unknown table 'test.v1,test.v2' +# Generating test tables +drop temporary table t1,s1,v1,t3,t4; +ERROR 42S02: Unknown table 'test.v1,test.t3,test.t4' +show warnings; +Level Code Message +Error 1051 Unknown table 'test.v1,test.t3,test.t4' +# Generating test tables +drop temporary table s2,v2,t2,t1; +ERROR 42S02: Unknown table 'test.v2' +show warnings; +Level Code Message +Error 1051 Unknown table 'test.v2' +# Generating test tables +drop temporary table s1,v1,s2,v2; +ERROR 42S02: Unknown table 'test.v1,test.v2' +show warnings; +Level Code Message +Error 1051 Unknown table 'test.v1,test.v2' +# Generating test tables +# +# DROP TEMPORARY TABLE with if exists +# +drop temporary table if exists t1,t2,t3; +Warnings: +Note 1051 Unknown table 'test.t3' +# Generating test tables +drop temporary table if exists t1,t3,t2; +Warnings: +Note 1051 Unknown table 'test.t3' +# Generating test tables +drop temporary table if exists t1,t4,t2,t3; +Warnings: +Note 1051 Unknown table 'test.t4,test.t3' +# Generating test tables +drop temporary table if exists t1,s1,s2,t2; +# Generating test tables +drop temporary table if exists t1,v1,v2,t2; +Warnings: +Note 1051 Unknown table 'test.v1,test.v2' +# Generating test tables +drop temporary table if exists v1,s1,s2,v2,t2; +Warnings: +Note 1051 Unknown table 'test.v1,test.v2' +# Generating test tables +drop temporary table if exists t1,s1,v1,t3,t4; +Warnings: +Note 1051 Unknown table 'test.v1,test.t3,test.t4' +drop temporary table if exists s2,v2,t2,t1; +Warnings: +Note 1051 Unknown table 'test.v2,test.t1' +# Generating test tables +drop temporary table if exists s1,v1,s2,v2; +Warnings: +Note 1051 Unknown table 'test.v1,test.v2' +# Generating test tables +drop temporary table t1,t2; +drop temporary sequence s1,s2; +show tables; +Tables_in_test +# Generating test tables +# +# DROP SEQUENCE +# +drop sequence s1,s2,s3; +ERROR 42S02: Unknown SEQUENCE: 'test.s3' +show warnings; +Level Code Message +Error 4091 Unknown SEQUENCE: 'test.s3' +show tables; +Tables_in_test +t1 +t2 +v1 +v2 +# Generating test tables +drop sequence s1,s3,s2; +ERROR 42S02: Unknown SEQUENCE: 'test.s3' +show warnings; +Level Code Message +Error 4091 Unknown SEQUENCE: 'test.s3' +show tables; +Tables_in_test +t1 +t2 +v1 +v2 +# Generating test tables +drop sequence s1,s4,s2,s3; +ERROR 42S02: Unknown SEQUENCE: 'test.s4,test.s3' +show warnings; +Level Code Message +Error 4091 Unknown SEQUENCE: 'test.s4,test.s3' +show tables; +Tables_in_test +t1 +t2 +v1 +v2 +# Generating test tables +drop sequence s1,t1,t2,s2,s3,s4; +ERROR 42S02: 'test.t1' is not a SEQUENCE +show warnings; +Level Code Message +Error 4090 'test.t1' is not a SEQUENCE +Error 4090 'test.t2' is not a SEQUENCE +Error 4091 Unknown SEQUENCE: 'test.s3,test.s4' +show tables; +Tables_in_test +t1 +t2 +v1 +v2 +# Generating test tables +drop sequence s1,v1,v2,s2; +ERROR 42S02: 'test.v1' is a view +show warnings; +Level Code Message +Error 1965 'test.v1' is a view +Error 1965 'test.v2' is a view +show tables; +Tables_in_test +t1 +t2 +v1 +v2 +# Generating test tables +drop sequence v1,t1,t2,v2,s2; +ERROR 42S02: 'test.v1' is a view +show warnings; +Level Code Message +Error 1965 'test.v1' is a view +Error 4090 'test.t1' is not a SEQUENCE +Error 4090 'test.t2' is not a SEQUENCE +Error 1965 'test.v2' is a view +drop sequence t1,v1,t2,v2,s2; +ERROR 42S02: 'test.t1' is not a SEQUENCE +show warnings; +Level Code Message +Error 4090 'test.t1' is not a SEQUENCE +Error 1965 'test.v1' is a view +Error 4090 'test.t2' is not a SEQUENCE +Error 1965 'test.v2' is a view +Error 4091 Unknown SEQUENCE: 'test.s2' +show tables; +Tables_in_test +s1 +t1 +t2 +v1 +v2 +# Generating test tables +drop sequence s1,t1,v1,t3,s4; +ERROR 42S02: 'test.t1' is not a SEQUENCE +show warnings; +Level Code Message +Warning 1017 Can't find file: './test/s1.MYI' (errno: 2 "No such file or directory") +Error 4090 'test.t1' is not a SEQUENCE +Error 1965 'test.v1' is a view +Error 4091 Unknown SEQUENCE: 'test.t3,test.s4' +drop sequence t2,v2,s2,s1; +ERROR 42S02: 'test.t2' is not a SEQUENCE +show warnings; +Level Code Message +Error 4090 'test.t2' is not a SEQUENCE +Error 1965 'test.v2' is a view +Error 4091 Unknown SEQUENCE: 'test.s1' +show tables; +Tables_in_test +t1 +t2 +v1 +v2 +# Generating test tables +drop sequence t1,v1,t2,v2; +ERROR 42S02: 'test.t1' is not a SEQUENCE +show warnings; +Level Code Message +Error 4090 'test.t1' is not a SEQUENCE +Error 1965 'test.v1' is a view +Error 4090 'test.t2' is not a SEQUENCE +Error 1965 'test.v2' is a view +show tables; +Tables_in_test +s1 +s2 +t1 +t2 +v1 +v2 +# Generating test tables +# +# DROP SEQUENCE with if exists +# +drop sequence if exists s1,s2,s3; +Warnings: +Note 4091 Unknown SEQUENCE: 'test.s3' +show tables; +Tables_in_test +t1 +t2 +v1 +v2 +# Generating test tables +drop sequence if exists s1,s3,s2; +Warnings: +Note 4091 Unknown SEQUENCE: 'test.s3' +show tables; +Tables_in_test +t1 +t2 +v1 +v2 +# Generating test tables +drop sequence if exists s1,s4,s2,s3; +Warnings: +Note 4091 Unknown SEQUENCE: 'test.s4,test.s3' +show tables; +Tables_in_test +t1 +t2 +v1 +v2 +# Generating test tables +drop sequence if exists s1,t1,t2,s2; +Warnings: +Note 4090 'test.t1' is not a SEQUENCE +Note 4090 'test.t2' is not a SEQUENCE +show tables; +Tables_in_test +t1 +t2 +v1 +v2 +# Generating test tables +drop sequence if exists s1,v1,v2,s2; +Warnings: +Note 1965 'test.v1' is a view +Note 1965 'test.v2' is a view +show tables; +Tables_in_test +t1 +t2 +v1 +v2 +# Generating test tables +drop sequence if exists v1,t1,t2,v2,s2; +Warnings: +Note 1965 'test.v1' is a view +Note 4090 'test.t1' is not a SEQUENCE +Note 4090 'test.t2' is not a SEQUENCE +Note 1965 'test.v2' is a view +show tables; +Tables_in_test +s1 +t1 +t2 +v1 +v2 +# Generating test tables +drop sequence if exists s1,t1,v1,t3,s4; +Warnings: +Warning 1017 Can't find file: './test/s1.MYI' (errno: 2 "No such file or directory") +Note 4090 'test.t1' is not a SEQUENCE +Note 1965 'test.v1' is a view +Note 4091 Unknown SEQUENCE: 'test.t3,test.s4' +drop sequence if exists t2,v2,s2,s1; +Warnings: +Note 4090 'test.t2' is not a SEQUENCE +Note 1965 'test.v2' is a view +Note 4091 Unknown SEQUENCE: 'test.s1' +show tables; +Tables_in_test +t1 +t2 +v1 +v2 +# Generating test tables +drop sequence if exists t1,v1,t2,v2; +Warnings: +Note 4090 'test.t1' is not a SEQUENCE +Note 1965 'test.v1' is a view +Note 4090 'test.t2' is not a SEQUENCE +Note 1965 'test.v2' is a view +show tables; +Tables_in_test +s1 +s2 +t1 +t2 +v1 +v2 +# Generating test tables +# +# DROP TEMPORARY SEQUENCE +# +drop table if exists t1,t2; +drop temporary table if exists tt1,tt2; +drop sequence if exists s1,s2; +drop temporary sequence if exists ss1,ss2; +drop view if exists v1,v2; +# Generating test tables +drop temporary sequence s1,s2,s3; +ERROR 42S02: Unknown SEQUENCE: 'test.s3' +show warnings; +Level Code Message +Error 4091 Unknown SEQUENCE: 'test.s3' +# Generating test tables +drop temporary sequence s1,s3,s2; +ERROR 42S02: Unknown SEQUENCE: 'test.s3' +show warnings; +Level Code Message +Error 4091 Unknown SEQUENCE: 'test.s3' +# Generating test tables +drop temporary sequence s1,s4,s2,s3; +ERROR 42S02: Unknown SEQUENCE: 'test.s4,test.s3' +show warnings; +Level Code Message +Error 4091 Unknown SEQUENCE: 'test.s4,test.s3' +# Generating test tables +drop temporary sequence s1,t1,t2,s2; +ERROR 42S02: Unknown SEQUENCE: 'test.t1,test.t2' +show warnings; +Level Code Message +Error 4091 Unknown SEQUENCE: 'test.t1,test.t2' +# Generating test tables +drop temporary sequence s1,v1,v2,s2; +ERROR 42S02: Unknown SEQUENCE: 'test.v1,test.v2' +show warnings; +Level Code Message +Error 4091 Unknown SEQUENCE: 'test.v1,test.v2' +# Generating test tables +drop temporary sequence v1,t1,t2,v2,s2; +ERROR 42S02: Unknown SEQUENCE: 'test.v1,test.t1,test.t2,test.v2' +show warnings; +Level Code Message +Error 4091 Unknown SEQUENCE: 'test.v1,test.t1,test.t2,test.v2' +# Generating test tables +drop temporary sequence s1,t1,v1,t3,s4; +ERROR 42S02: Unknown SEQUENCE: 'test.t1,test.v1,test.t3,test.s4' +show warnings; +Level Code Message +Error 4091 Unknown SEQUENCE: 'test.t1,test.v1,test.t3,test.s4' +drop temporary sequence t2,v2,s2,s1; +ERROR 42S02: Unknown SEQUENCE: 'test.t2,test.v2,test.s1' +show warnings; +Level Code Message +Error 4091 Unknown SEQUENCE: 'test.t2,test.v2,test.s1' +# Generating test tables +drop temporary sequence t1,v1,t2,v2; +ERROR 42S02: Unknown SEQUENCE: 'test.t1,test.v1,test.t2,test.v2' +show warnings; +Level Code Message +Error 4091 Unknown SEQUENCE: 'test.t1,test.v1,test.t2,test.v2' +# Generating test tables +# +# DROP TEMPORARY SEQUENCE with if exists +# +drop temporary sequence if exists s1,s2,s3; +Warnings: +Note 4091 Unknown SEQUENCE: 'test.s3' +# Generating test tables +drop temporary sequence if exists s1,s3,s2; +Warnings: +Note 4091 Unknown SEQUENCE: 'test.s3' +# Generating test tables +drop temporary sequence if exists s1,s4,s2,s3; +Warnings: +Note 4091 Unknown SEQUENCE: 'test.s4,test.s3' +# Generating test tables +drop temporary sequence if exists s1,t1,t2,s2; +Warnings: +Note 4090 'test.t1' is not a SEQUENCE +Note 4090 'test.t2' is not a SEQUENCE +# Generating test tables +drop temporary sequence if exists s1,v1,v2,s2; +Warnings: +Note 4091 Unknown SEQUENCE: 'test.v1,test.v2' +# Generating test tables +drop temporary sequence if exists v1,t1,t2,v2,s2; +Warnings: +Note 4090 'test.t1' is not a SEQUENCE +Note 4090 'test.t2' is not a SEQUENCE +Note 4091 Unknown SEQUENCE: 'test.v1,test.v2' +# Generating test tables +drop temporary sequence if exists s1,t1,v1,t3,s4; +Warnings: +Note 4090 'test.t1' is not a SEQUENCE +Note 4091 Unknown SEQUENCE: 'test.v1,test.t3,test.s4' +drop temporary sequence if exists t2,v2,s2,s1; +Warnings: +Note 4090 'test.t2' is not a SEQUENCE +Note 4091 Unknown SEQUENCE: 'test.v2,test.s1' +# Generating test tables +drop temporary sequence if exists t1,v1,t2,v2; +Warnings: +Note 4090 'test.t1' is not a SEQUENCE +Note 4090 'test.t2' is not a SEQUENCE +Note 4091 Unknown SEQUENCE: 'test.v1,test.v2' +# Generating test tables +drop temporary table t1,t2; +drop temporary sequence s1,s2; +show tables; +Tables_in_test +# Generating test tables +# +# DROP VIEW +# +drop view v1,v2,v3; +ERROR 42S02: Unknown VIEW: 'test.v3' +show warnings; +Level Code Message +Error 4092 Unknown VIEW: 'test.v3' +show tables; +Tables_in_test +s1 +s2 +t1 +t2 +# Generating test tables +drop view v1,v3,v2; +ERROR 42S02: Unknown VIEW: 'test.v3' +show warnings; +Level Code Message +Error 4092 Unknown VIEW: 'test.v3' +show tables; +Tables_in_test +s1 +s2 +t1 +t2 +# Generating test tables +drop view v1,v4,v2,v3; +ERROR 42S02: Unknown VIEW: 'test.v4,test.v3' +show warnings; +Level Code Message +Error 4092 Unknown VIEW: 'test.v4,test.v3' +show tables; +Tables_in_test +s1 +s2 +t1 +t2 +# Generating test tables +drop view v1,t1,t2,v2; +ERROR 42S02: Unknown VIEW: 'test.t1,test.t2' +show warnings; +Level Code Message +Warning 1347 'test.t1' is not of type 'VIEW' +Warning 1347 'test.t2' is not of type 'VIEW' +Error 4092 Unknown VIEW: 'test.t1,test.t2' +show tables; +Tables_in_test +s1 +s2 +t1 +t2 +# Generating test tables +drop view v1,s1,s2,v2; +ERROR 42S02: Unknown VIEW: 'test.s1,test.s2' +show warnings; +Level Code Message +Warning 1347 'test.s1' is not of type 'VIEW' +Warning 1347 'test.s2' is not of type 'VIEW' +Error 4092 Unknown VIEW: 'test.s1,test.s2' +show tables; +Tables_in_test +s1 +s2 +t1 +t2 +# Generating test tables +drop view s1,t1,t2,s2,v2; +ERROR 42S02: Unknown VIEW: 'test.s1,test.t1,test.t2,test.s2' +show warnings; +Level Code Message +Warning 1347 'test.s1' is not of type 'VIEW' +Warning 1347 'test.t1' is not of type 'VIEW' +Warning 1347 'test.t2' is not of type 'VIEW' +Warning 1347 'test.s2' is not of type 'VIEW' +Error 4092 Unknown VIEW: 'test.s1,test.t1,test.t2,test.s2' +drop table t1; +Warnings: +Warning 1017 Can't find file: './test/t1.MYI' (errno: 2 "No such file or directory") +show warnings; +Level Code Message +Warning 1017 Can't find file: './test/t1.MYI' (errno: 2 "No such file or directory") +drop view v1,t1; +ERROR 42S02: Unknown VIEW: 'test.t1' +show warnings; +Level Code Message +Error 4092 Unknown VIEW: 'test.t1' +show tables; +Tables_in_test +s1 +s2 +t2 +# Generating test tables +drop view v1,t1,s1,t3,v4; +ERROR 42S02: Unknown VIEW: 'test.t1,test.s1,test.t3,test.v4' +show warnings; +Level Code Message +Warning 1347 'test.t1' is not of type 'VIEW' +Warning 1347 'test.s1' is not of type 'VIEW' +Error 4092 Unknown VIEW: 'test.t1,test.s1,test.t3,test.v4' +drop view t2,s2,v2,v1; +ERROR 42S02: Unknown VIEW: 'test.t2,test.s2,test.v1' +show warnings; +Level Code Message +Warning 1347 'test.t2' is not of type 'VIEW' +Warning 1347 'test.s2' is not of type 'VIEW' +Error 4092 Unknown VIEW: 'test.t2,test.s2,test.v1' +show tables; +Tables_in_test +s1 +s2 +t1 +t2 +# Generating test tables +drop view t1,s1,t2,s2; +ERROR 42S02: Unknown VIEW: 'test.t1,test.s1,test.t2,test.s2' +show warnings; +Level Code Message +Warning 1347 'test.t1' is not of type 'VIEW' +Warning 1347 'test.s1' is not of type 'VIEW' +Warning 1347 'test.t2' is not of type 'VIEW' +Warning 1347 'test.s2' is not of type 'VIEW' +Error 4092 Unknown VIEW: 'test.t1,test.s1,test.t2,test.s2' +show tables; +Tables_in_test +s1 +s2 +t1 +t2 +v1 +v2 +# Generating test tables +# +# DROP VIEW with if exists +# +drop view if exists v1,v2,v3; +Warnings: +Note 4092 Unknown VIEW: 'test.v3' +show tables; +Tables_in_test +s1 +s2 +t1 +t2 +# Generating test tables +drop view if exists v1,v3,v2; +Warnings: +Note 4092 Unknown VIEW: 'test.v3' +show tables; +Tables_in_test +s1 +s2 +t1 +t2 +# Generating test tables +drop view if exists v1,v4,v2,v3; +Warnings: +Note 4092 Unknown VIEW: 'test.v4,test.v3' +show tables; +Tables_in_test +s1 +s2 +t1 +t2 +# Generating test tables +drop view if exists v1,t1,t2,v2; +Warnings: +Warning 1347 'test.t1' is not of type 'VIEW' +Warning 1347 'test.t2' is not of type 'VIEW' +Note 4092 Unknown VIEW: 'test.t1,test.t2' +show tables; +Tables_in_test +s1 +s2 +t1 +t2 +# Generating test tables +drop view if exists v1,s1,s2,v2; +Warnings: +Warning 1347 'test.s1' is not of type 'VIEW' +Warning 1347 'test.s2' is not of type 'VIEW' +Note 4092 Unknown VIEW: 'test.s1,test.s2' +show tables; +Tables_in_test +s1 +s2 +t1 +t2 +# Generating test tables +drop view if exists s1,t1,t2,s2,v2; +Warnings: +Warning 1347 'test.s1' is not of type 'VIEW' +Warning 1347 'test.t1' is not of type 'VIEW' +Warning 1347 'test.t2' is not of type 'VIEW' +Warning 1347 'test.s2' is not of type 'VIEW' +Note 4092 Unknown VIEW: 'test.s1,test.t1,test.t2,test.s2' +drop table t1; +drop view if exists v1,t1; +Warnings: +Note 4092 Unknown VIEW: 'test.t1' +show tables; +Tables_in_test +s1 +s2 +t2 +# Generating test tables +drop view if exists v1,t1,s1,t3,v4; +Warnings: +Warning 1347 'test.t1' is not of type 'VIEW' +Warning 1347 'test.s1' is not of type 'VIEW' +Note 4092 Unknown VIEW: 'test.t1,test.s1,test.t3,test.v4' +drop view if exists t2,s2,v2,v1; +Warnings: +Warning 1347 'test.t2' is not of type 'VIEW' +Warning 1347 'test.s2' is not of type 'VIEW' +Note 4092 Unknown VIEW: 'test.t2,test.s2,test.v1' +show tables; +Tables_in_test +s1 +s2 +t1 +t2 +# Generating test tables +drop view if exists t1,s1,t2,s2; +Warnings: +Warning 1347 'test.t1' is not of type 'VIEW' +Warning 1347 'test.s1' is not of type 'VIEW' +Warning 1347 'test.t2' is not of type 'VIEW' +Warning 1347 'test.s2' is not of type 'VIEW' +Note 4092 Unknown VIEW: 'test.t1,test.s1,test.t2,test.s2' +show tables; +Tables_in_test +s1 +s2 +t1 +t2 +v1 +v2 +# Generating test tables +# cleanup +drop table if exists t1,t2; +drop sequence if exists s1,s2; +drop view if exists v1,v2; +SET default_storage_engine=@save_default_engine; diff --git a/mysql-test/main/drop_combinations.test b/mysql-test/main/drop_combinations.test new file mode 100644 index 00000000000..8b3ad43793b --- /dev/null +++ b/mysql-test/main/drop_combinations.test @@ -0,0 +1,425 @@ +# +# Test different combinations of doing DROP TABLE/SEQUENCE/VIEW +# + +SET @save_default_engine= @@DEFAULT_STORAGE_ENGINE; +SET default_storage_engine=myisam; +let $DATADIR= `select @@datadir`; + +# Create tables t1,t2, sequences s1,s2 and views v1,v2 +let $create_option=; +--source drop_combinations.inc + +--echo # +--echo # DROP TABLE +--echo # + +--error ER_BAD_TABLE_ERROR +drop table t1,t2,t3; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--error ER_BAD_TABLE_ERROR +drop table t1,t3,t2; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--error ER_BAD_TABLE_ERROR +drop table t1,t4,t2,t3; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +drop table t1,s1,s2,t2; +--source drop_combinations.inc +--error ER_IT_IS_A_VIEW +drop table t1,v1,v2,t2; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--error ER_IT_IS_A_VIEW +drop table v1,s1,s2,v2,t2; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--remove_file $DATADIR/test/t1.MYD +--replace_result $DATADIR ./ +--error ER_IT_IS_A_VIEW +drop table t1,s1,v1,t3,t4; +--replace_result $DATADIR ./ +show warnings; +--error ER_IT_IS_A_VIEW +drop table s2,v2,t2,t1; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--replace_result $DATADIR ./ +--error ER_IT_IS_A_VIEW +drop table s1,v1,s2,v2; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc + +--echo # +--echo # DROP TABLE with if exists +--echo # + +drop table if exists t1,t2,t3; +--source drop_combinations.inc +drop table if exists t1,t3,t2; +--source drop_combinations.inc +drop table if exists t1,t4,t2,t3; +--source drop_combinations.inc +drop table if exists t1,s1,s2,t2; +--source drop_combinations.inc +drop table if exists t1,v1,v2,t2; +--source drop_combinations.inc +drop table if exists v1,s1,s2,v2,t2; +--source drop_combinations.inc +--remove_file $DATADIR/test/t1.MYD +--replace_result \\ / +--replace_result $DATADIR ./ +drop table if exists t1,s1,v1,t3,t4; +drop table if exists s2,v2,t2,t1; +--source drop_combinations.inc +--replace_result $DATADIR ./ +drop table if exists s1,v1,s2,v2; +--source drop_combinations.inc + +--echo # +--echo # DROP TEMPORARY TABLE +--echo # + +--disable_warnings +drop table if exists t1,t2; +drop temporary table if exists tt1,tt2; +drop sequence if exists s1,s2; +drop temporary sequence if exists ss1,ss2; +drop view if exists v1,v2; +--enable_warnings +let $create_option=temporary; + +--error ER_BAD_TABLE_ERROR +drop temporary table t1,t2,t3; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--error ER_BAD_TABLE_ERROR +drop temporary table t1,t3,t2; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--error ER_BAD_TABLE_ERROR +drop temporary table t1,t4,t2,t3; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +drop temporary table t1,s1,s2,t2; +--source drop_combinations.inc +--error ER_BAD_TABLE_ERROR +drop temporary table t1,v1,v2,t2; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--error ER_BAD_TABLE_ERROR +drop temporary table v1,s1,s2,v2,t2; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--error ER_BAD_TABLE_ERROR +drop temporary table t1,s1,v1,t3,t4; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--error ER_BAD_TABLE_ERROR +drop temporary table s2,v2,t2,t1; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--error ER_BAD_TABLE_ERROR +drop temporary table s1,v1,s2,v2; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc + +--echo # +--echo # DROP TEMPORARY TABLE with if exists +--echo # + +drop temporary table if exists t1,t2,t3; +--source drop_combinations.inc +drop temporary table if exists t1,t3,t2; +--source drop_combinations.inc +drop temporary table if exists t1,t4,t2,t3; +--source drop_combinations.inc +drop temporary table if exists t1,s1,s2,t2; +--source drop_combinations.inc +drop temporary table if exists t1,v1,v2,t2; +--source drop_combinations.inc +drop temporary table if exists v1,s1,s2,v2,t2; +--source drop_combinations.inc +drop temporary table if exists t1,s1,v1,t3,t4; +drop temporary table if exists s2,v2,t2,t1; +--source drop_combinations.inc +drop temporary table if exists s1,v1,s2,v2; +--source drop_combinations.inc + +let $create_option=; +drop temporary table t1,t2; +drop temporary sequence s1,s2; +--source drop_combinations.inc + +--echo # +--echo # DROP SEQUENCE +--echo # + +--error ER_UNKNOWN_SEQUENCES +drop sequence s1,s2,s3; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--error ER_UNKNOWN_SEQUENCES +drop sequence s1,s3,s2; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--error ER_UNKNOWN_SEQUENCES +drop sequence s1,s4,s2,s3; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--error ER_NOT_SEQUENCE2 +drop sequence s1,t1,t2,s2,s3,s4; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--error ER_IT_IS_A_VIEW +drop sequence s1,v1,v2,s2; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--error ER_IT_IS_A_VIEW +drop sequence v1,t1,t2,v2,s2; +--replace_result $DATADIR ./ +show warnings; +--error ER_NOT_SEQUENCE2 +drop sequence t1,v1,t2,v2,s2; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--remove_file $DATADIR/test/s1.MYD +--replace_result \\ / +--error ER_NOT_SEQUENCE2 +drop sequence s1,t1,v1,t3,s4; +--replace_result $DATADIR ./ +show warnings; +--error ER_NOT_SEQUENCE2 +drop sequence t2,v2,s2,s1; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--error ER_NOT_SEQUENCE2 +drop sequence t1,v1,t2,v2; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc + +--echo # +--echo # DROP SEQUENCE with if exists +--echo # + +drop sequence if exists s1,s2,s3; +--source drop_combinations.inc +drop sequence if exists s1,s3,s2; +--source drop_combinations.inc +drop sequence if exists s1,s4,s2,s3; +--source drop_combinations.inc +drop sequence if exists s1,t1,t2,s2; +--source drop_combinations.inc +drop sequence if exists s1,v1,v2,s2; +--source drop_combinations.inc +drop sequence if exists v1,t1,t2,v2,s2; +--source drop_combinations.inc +--remove_file $DATADIR/test/s1.MYD +--replace_result \\ / +--replace_result $DATADIR ./ +drop sequence if exists s1,t1,v1,t3,s4; +drop sequence if exists t2,v2,s2,s1; +--source drop_combinations.inc +drop sequence if exists t1,v1,t2,v2; +--source drop_combinations.inc + +--echo # +--echo # DROP TEMPORARY SEQUENCE +--echo # + +--disable_warnings +drop table if exists t1,t2; +drop temporary table if exists tt1,tt2; +drop sequence if exists s1,s2; +drop temporary sequence if exists ss1,ss2; +drop view if exists v1,v2; +--enable_warnings +let $create_option=temporary; +--source drop_combinations.inc + +--error ER_UNKNOWN_SEQUENCES +drop temporary sequence s1,s2,s3; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--error ER_UNKNOWN_SEQUENCES +drop temporary sequence s1,s3,s2; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--error ER_UNKNOWN_SEQUENCES +drop temporary sequence s1,s4,s2,s3; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--error ER_UNKNOWN_SEQUENCES +drop temporary sequence s1,t1,t2,s2; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--error ER_UNKNOWN_SEQUENCES +drop temporary sequence s1,v1,v2,s2; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--error ER_UNKNOWN_SEQUENCES +drop temporary sequence v1,t1,t2,v2,s2; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--error ER_UNKNOWN_SEQUENCES +drop temporary sequence s1,t1,v1,t3,s4; +--replace_result $DATADIR ./ +show warnings; +--error ER_UNKNOWN_SEQUENCES +drop temporary sequence t2,v2,s2,s1; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--error ER_UNKNOWN_SEQUENCES +drop temporary sequence t1,v1,t2,v2; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc + +--echo # +--echo # DROP TEMPORARY SEQUENCE with if exists +--echo # + +drop temporary sequence if exists s1,s2,s3; +--source drop_combinations.inc +drop temporary sequence if exists s1,s3,s2; +--source drop_combinations.inc +drop temporary sequence if exists s1,s4,s2,s3; +--source drop_combinations.inc +drop temporary sequence if exists s1,t1,t2,s2; +--source drop_combinations.inc +drop temporary sequence if exists s1,v1,v2,s2; +--source drop_combinations.inc +drop temporary sequence if exists v1,t1,t2,v2,s2; +--source drop_combinations.inc +drop temporary sequence if exists s1,t1,v1,t3,s4; +drop temporary sequence if exists t2,v2,s2,s1; +--source drop_combinations.inc +drop temporary sequence if exists t1,v1,t2,v2; +--source drop_combinations.inc + +let $create_option=; +drop temporary table t1,t2; +drop temporary sequence s1,s2; +--source drop_combinations.inc + +--echo # +--echo # DROP VIEW +--echo # + +--error ER_UNKNOWN_VIEW +drop view v1,v2,v3; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--error ER_UNKNOWN_VIEW +drop view v1,v3,v2; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--error ER_UNKNOWN_VIEW +drop view v1,v4,v2,v3; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--error ER_UNKNOWN_VIEW +drop view v1,t1,t2,v2; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--error ER_UNKNOWN_VIEW +drop view v1,s1,s2,v2; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--remove_file $DATADIR/test/t1.MYD +--replace_result \\ / +--error ER_UNKNOWN_VIEW +drop view s1,t1,t2,s2,v2; +--replace_result $DATADIR ./ +show warnings; +--replace_result $DATADIR ./ +drop table t1; +--replace_result $DATADIR ./ +show warnings; +--error ER_UNKNOWN_VIEW +drop view v1,t1; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--error ER_UNKNOWN_VIEW +drop view v1,t1,s1,t3,v4; +--replace_result $DATADIR ./ +show warnings; +--error ER_UNKNOWN_VIEW +drop view t2,s2,v2,v1; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc +--error ER_UNKNOWN_VIEW +drop view t1,s1,t2,s2; +--replace_result $DATADIR ./ +show warnings; +--source drop_combinations.inc + +--echo # +--echo # DROP VIEW with if exists +--echo # + +drop view if exists v1,v2,v3; +--source drop_combinations.inc +drop view if exists v1,v3,v2; +--source drop_combinations.inc +drop view if exists v1,v4,v2,v3; +--source drop_combinations.inc +drop view if exists v1,t1,t2,v2; +--source drop_combinations.inc +drop view if exists v1,s1,s2,v2; +--source drop_combinations.inc +drop view if exists s1,t1,t2,s2,v2; +drop table t1; +drop view if exists v1,t1; +--source drop_combinations.inc +drop view if exists v1,t1,s1,t3,v4; +drop view if exists t2,s2,v2,v1; +--source drop_combinations.inc +drop view if exists t1,s1,t2,s2; +--source drop_combinations.inc + +--echo # cleanup +drop table if exists t1,t2; +drop sequence if exists s1,s2; +drop view if exists v1,v2; + +SET default_storage_engine=@save_default_engine; diff --git a/mysql-test/main/drop_table_force.result b/mysql-test/main/drop_table_force.result new file mode 100644 index 00000000000..622589eb3b9 --- /dev/null +++ b/mysql-test/main/drop_table_force.result @@ -0,0 +1,131 @@ +CALL mtr.add_suppression("Operating system error number"); +CALL mtr.add_suppression("The error means the system cannot"); +CALL mtr.add_suppression("returned OS error 71"); +#Test1: table with missing .ibd can be dropped directly +create table t1(a int)engine=innodb; +drop table t1; +db.opt +# Test droping table without frm without super privilege +create table t1(a int) engine=innodb; +create user test identified by '123456'; +grant all privileges on test.t1 to 'test'@'%'identified by '123456'; +connect con_test, localhost, test,'123456', ; +connection con_test; +drop table t1; +drop table t1; +ERROR 42S02: Unknown table 'test.t1' +connection default; +disconnect con_test; +drop user test; +db.opt +#Test5: drop table with triger, and with missing frm +create table t1(a int)engine=innodb; +create trigger t1_trg before insert on t1 for each row begin end; +drop table t1; +drop table t1; +ERROR 42S02: Unknown table 'test.t1' +db.opt +#Test6: table with foreign key references can not be dropped +CREATE TABLE parent (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB; +CREATE TABLE child (id INT, parent_id INT, INDEX par_ind (parent_id), FOREIGN KEY (parent_id) REFERENCES parent(id) ON DELETE CASCADE) ENGINE=INNODB; +drop table parent; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails +drop table child; +drop table parent; +db.opt +#Test7: drop table twice +create table t1(a int)engine=innodb; +drop table t1; +db.opt +drop table if exists t1; +Warnings: +Note 1051 Unknown table 'test.t1' +db.opt +#Test9: check compatibility with restrict/cascade +CREATE TABLE parent (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB; +CREATE TABLE child (id INT, parent_id INT, INDEX par_ind (parent_id), FOREIGN KEY (parent_id) REFERENCES parent(id) ON DELETE CASCADE) ENGINE=INNODB; +drop table parent; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails +drop table parent restrict; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails +drop table parent cascade; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails +drop table parent; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails +drop table parent restrict; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails +drop table parent cascade; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails +drop table child; +drop table parent; +#Test10: drop non-innodb engine table returns ok +create table t1(a int) engine=myisam; +drop table t1; +create table t1(a int) engine=myisam; +drop table t1; +Warnings: +Warning 1017 Can't find file: './test/t1.MYI' (errno: 2 "No such file or directory") +create table t1(a int) engine=myisam; +drop table t1; +Warnings: +Warning 1017 Can't find file: './test/t1.MYI' (errno: 2 "No such file or directory") +db.opt +create table t1(a int) engine=aria; +db.opt +t1.MAI +drop table t1; +ERROR 42S02: Unknown table 'test.t1' +show warnings; +Level Code Message +Error 29 File './test/t1.MAD' not found (Errcode: 2 "No such file or directory") +Error 1051 Unknown table 'test.t1' +db.opt +create table t2(a int) engine=aria; +flush tables; +db.opt +t2.MAD +drop table t2; +ERROR 42S02: Unknown table 'test.t2' +show warnings; +Level Code Message +Error 1051 Unknown table 'test.t2' +db.opt +create table t2(a int) engine=aria; +flush tables; +db.opt +t2.frm +drop table t2; +Warnings: +Warning 1017 Can't find file: './test/t2.MAI' (errno: 2 "No such file or directory") +create table t2(a int not null) engine=CSV; +flush tables; +drop table t2; +db.opt +create table t2(a int not null) engine=CSV; +flush tables; +drop table t2; +db.opt +create table t2(a int not null) engine=archive; +flush tables; +select * from t2; +a +flush tables; +select * from t2; +ERROR 42S02: Table 'test.t2' doesn't exist +db.opt +drop table t2; +ERROR 42S02: Unknown table 'test.t2' +create table t2(a int not null) engine=archive; +flush tables; +drop table t2; +ERROR 42S02: Unknown table 'test.t2' +db.opt +# +# MDEV-23549 CREATE fails after DROP without FRM +# +create table t1 (a int); +select * from t1; +a +drop table t1; +create table t1 (a int); +drop table t1; diff --git a/mysql-test/main/drop_table_force.test b/mysql-test/main/drop_table_force.test new file mode 100644 index 00000000000..f3073e3b67d --- /dev/null +++ b/mysql-test/main/drop_table_force.test @@ -0,0 +1,226 @@ +--source include/have_log_bin.inc +--source include/have_innodb.inc +--source include/have_archive.inc +# +# This test is based on the orginal test from Tencent for DROP TABLE ... FORCE +# In MariaDB we did reuse the code but MariaDB does not require the FORCE +# keyword to drop a table even if the .frm file or some engine files are +# missing. +# To make it easy to see the differences between the orginal code and +# the new one, we have left some references to the original test case +# + +CALL mtr.add_suppression("Operating system error number"); +CALL mtr.add_suppression("The error means the system cannot"); +CALL mtr.add_suppression("returned OS error 71"); + +let $DATADIR= `select @@datadir`; + +--echo #Test1: table with missing .ibd can be dropped directly +# drop table without ibd +create table t1(a int)engine=innodb; +--remove_file $DATADIR/test/t1.ibd +drop table t1; +--list_files $DATADIR/test/ + +# Original DROP TABLE .. FORCE required SUPER privilege. MariaDB doesn't +--echo # Test droping table without frm without super privilege + +# create table t1 and rm frm +create table t1(a int) engine=innodb; +--remove_file $DATADIR/test/t1.frm + +# create test user +create user test identified by '123456'; +grant all privileges on test.t1 to 'test'@'%'identified by '123456'; + +# connect as test +connect (con_test, localhost, test,'123456', ); +--connection con_test + +# drop table with user test +drop table t1; +--error ER_BAD_TABLE_ERROR +drop table t1; + +# connect as root +--connection default + +--disconnect con_test +drop user test; + +# check files in datadir about t1 +--list_files $DATADIR/test/ + +--echo #Test5: drop table with triger, and with missing frm +# create table t1 with triger and rm frm +create table t1(a int)engine=innodb; +create trigger t1_trg before insert on t1 for each row begin end; + +let $DATADIR= `select @@datadir`; +--remove_file $DATADIR/test/t1.frm + +drop table t1; +--error ER_BAD_TABLE_ERROR +drop table t1; + +# check files in datadir about t1 +--list_files $DATADIR/test/ + +--echo #Test6: table with foreign key references can not be dropped +# create table with foreign key reference and rm frm +CREATE TABLE parent (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB; +CREATE TABLE child (id INT, parent_id INT, INDEX par_ind (parent_id), FOREIGN KEY (parent_id) REFERENCES parent(id) ON DELETE CASCADE) ENGINE=INNODB; +--remove_file $DATADIR/test/parent.frm + +# parent can not be dropped when there are foreign key references +--error ER_ROW_IS_REFERENCED_2 +drop table parent; + +# parent can be dropped when there are no foreign key references +drop table child; +drop table parent; + +# check files in datadir about child and parent +--list_files $DATADIR/test/ + +--echo #Test7: drop table twice +create table t1(a int)engine=innodb; +--remove_file $DATADIR/test/t1.frm + +# first drop table will success +drop table t1; + +# check files in datadir about t1 +--list_files $DATADIR/test/ + +# second drop with if exists will also ok +drop table if exists t1; + +# check files in datadir about t1 +--list_files $DATADIR/test/ + +--echo #Test9: check compatibility with restrict/cascade +# create table with foreign key reference and rm frm +CREATE TABLE parent (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB; +CREATE TABLE child (id INT, parent_id INT, INDEX par_ind (parent_id), FOREIGN KEY (parent_id) REFERENCES parent(id) ON DELETE CASCADE) ENGINE=INNODB; + +# parent can not be dropped when there are foreign key references +--error ER_ROW_IS_REFERENCED_2 +drop table parent; +--error ER_ROW_IS_REFERENCED_2 +drop table parent restrict; +--error ER_ROW_IS_REFERENCED_2 +drop table parent cascade; +--error ER_ROW_IS_REFERENCED_2 +drop table parent; +--error ER_ROW_IS_REFERENCED_2 +drop table parent restrict; +--error ER_ROW_IS_REFERENCED_2 +drop table parent cascade; + +# parent can be dropped when there are no foreign key references +drop table child; +drop table parent; + +--echo #Test10: drop non-innodb engine table returns ok +# create myisam table t1 and rm .frm +create table t1(a int) engine=myisam; +--remove_file $DATADIR/test/t1.frm +--replace_result \\ / +drop table t1; + +# create myisam table t1 and rm .MYD +create table t1(a int) engine=myisam; +--remove_file $DATADIR/test/t1.MYD +--replace_result \\ / +drop table t1; + +# create myisam table t1 and rm .MYI +create table t1(a int) engine=myisam; +--remove_file $DATADIR/test/t1.MYI +--replace_result \\ / +drop table t1; +--list_files $DATADIR/test/ + +# create Aria table t1 and rm .frm and .MAD +create table t1(a int) engine=aria; +--remove_file $DATADIR/test/t1.frm +--remove_file $DATADIR/test/t1.MAD +--list_files $DATADIR/test/ +--error ER_BAD_TABLE_ERROR +drop table t1; +--replace_result \\ / +show warnings; +--list_files $DATADIR/test/ + +# create Aria table t2 and rm .frm and .MAI +create table t2(a int) engine=aria; +flush tables; +--remove_file $DATADIR/test/t2.frm +--remove_file $DATADIR/test/t2.MAI +--list_files $DATADIR/test/ +--error ER_BAD_TABLE_ERROR +drop table t2; +--replace_result \\ / +show warnings; +--list_files $DATADIR/test/ + +# create Aria table t2 and rm .MAI and .MAD +create table t2(a int) engine=aria; +flush tables; +--remove_file $DATADIR/test/t2.MAD +--remove_file $DATADIR/test/t2.MAI +--list_files $DATADIR/test/ +--replace_result \\ / +drop table t2; + +# create CVS table t2 and rm .frm +create table t2(a int not null) engine=CSV; +flush tables; +--remove_file $DATADIR/test/t2.frm +drop table t2; +--list_files $DATADIR/test/ + +# create CVS table t2 and rm .frm +create table t2(a int not null) engine=CSV; +flush tables; +--remove_file $DATADIR/test/t2.CSV +drop table t2; +--list_files $DATADIR/test/ + +# create Archive table t2 and rm +# Note that as Archive has discovery, removing the +# ARZ will automatically remove the .frm + +create table t2(a int not null) engine=archive; +flush tables; +--error 1 +--remove_file $DATADIR/test/t2.frm +select * from t2; +flush tables; +--remove_file $DATADIR/test/t2.ARZ +--error ER_NO_SUCH_TABLE +select * from t2; +--list_files $DATADIR/test/ +--replace_result \\ / +--error ER_BAD_TABLE_ERROR +drop table t2; + +create table t2(a int not null) engine=archive; +flush tables; +--remove_file $DATADIR/test/t2.ARZ +--error ER_BAD_TABLE_ERROR +drop table t2; +--list_files $DATADIR/test/ + +--echo # +--echo # MDEV-23549 CREATE fails after DROP without FRM +--echo # +create table t1 (a int); +select * from t1; +--remove_file $datadir/test/t1.frm + +drop table t1; +create table t1 (a int); +drop table t1; diff --git a/mysql-test/main/events_bugs.result b/mysql-test/main/events_bugs.result index 666361188b9..e3984bcd67a 100644 --- a/mysql-test/main/events_bugs.result +++ b/mysql-test/main/events_bugs.result @@ -405,7 +405,7 @@ SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; event_name definer e1 mysqltest_u1@localhost ALTER DEFINER=root@localhost EVENT e1 ON SCHEDULE EVERY 1 HOUR; -ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation +ERROR 42000: Access denied; you need (at least one of) the SUPER, SET USER privilege(s) for this operation SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; event_name definer e1 mysqltest_u1@localhost @@ -418,7 +418,7 @@ event_name definer e1 mysqltest_u1@localhost DROP EVENT e1; CREATE DEFINER=root@localhost EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; -ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation +ERROR 42000: Access denied; you need (at least one of) the SUPER, SET USER privilege(s) for this operation DROP EVENT e1; ERROR HY000: Unknown event 'e1' disconnect conn1; diff --git a/mysql-test/main/except.result b/mysql-test/main/except.result index f48a25f93bd..96efeb03c5e 100644 --- a/mysql-test/main/except.result +++ b/mysql-test/main/except.result @@ -82,7 +82,8 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 } @@ -100,7 +101,8 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 } @@ -123,7 +125,8 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 1, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "materialized": { @@ -145,7 +148,8 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 } @@ -163,7 +167,8 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 } @@ -309,7 +314,8 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 }, @@ -320,7 +326,8 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 }, @@ -343,7 +350,8 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 }, @@ -354,7 +362,8 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 }, @@ -383,7 +392,8 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 3, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "materialized": { @@ -405,7 +415,8 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 }, @@ -416,7 +427,8 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 }, @@ -439,7 +451,8 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 }, @@ -450,7 +463,8 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 }, @@ -508,8 +522,6 @@ select 1 as a from dual union all select 1 from dual; a 1 1 -select 1 from dual except all select 1 from dual; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'all select 1 from dual' at line 1 create table t1 (a int, b blob, a1 int, b1 blob) engine=MyISAM; create table t2 (c int, d blob, c1 int, d1 blob) engine=MyISAM; insert into t1 values (1,"ddd", 1, "sdfrrwwww"),(2, "fgh", 2, "dffggtt"); diff --git a/mysql-test/main/except.test b/mysql-test/main/except.test index 4eaae1a3888..090826ce94d 100644 --- a/mysql-test/main/except.test +++ b/mysql-test/main/except.test @@ -13,9 +13,9 @@ EXPLAIN extended (select a,b from t1) except (select c,d from t2); EXPLAIN extended select * from ((select a,b from t1) except (select c,d from t2)) a; EXPLAIN format=json (select a,b from t1) except (select c,d from t2); ---replace_regex /"r_total_time_ms": [0-9e\.\-+]*,/"r_total_time_ms": "REPLACED",/ +--source include/analyze-format.inc ANALYZE format=json (select a,b from t1) except (select c,d from t2); ---replace_regex /"r_total_time_ms": [0-9e\.\-+]*,/"r_total_time_ms": "REPLACED",/ +--source include/analyze-format.inc ANALYZE format=json select * from ((select a,b from t1) except (select c,d from t2)) a; select * from ((select a,b from t1) except (select c,d from t2)) a; @@ -45,9 +45,9 @@ EXPLAIN (select a,b,e,f from t1,t3) except (select c,d,g,h from t2,t4); EXPLAIN extended select * from ((select a,b,e,f from t1,t3) except (select c,d,g,h from t2,t4)) a; EXPLAIN format=json (select a,b,e,f from t1,t3) except (select c,d,g,h from t2,t4); ---replace_regex /"r_total_time_ms": [0-9e\.\-+]*,/"r_total_time_ms": "REPLACED",/ +--source include/analyze-format.inc ANALYZE format=json (select a,b,e,f from t1,t3) except (select c,d,g,h from t2,t4); ---replace_regex /"r_total_time_ms": [0-9e\.\-+]*,/"r_total_time_ms": "REPLACED",/ +--source include/analyze-format.inc ANALYZE format=json select * from ((select a,b,e,f from t1,t3) except (select c,d,g,h from t2,t4)) a; select * from ((select a,b,e,f from t1,t3) except (select c,d,g,h from t2,t4)) a; @@ -70,8 +70,6 @@ select 1 as a from dual except select 1 from dual; select 1 from dual ORDER BY 1 except select 1 from dual; select 1 as a from dual union all select 1 from dual; ---error ER_PARSE_ERROR -select 1 from dual except all select 1 from dual; create table t1 (a int, b blob, a1 int, b1 blob) engine=MyISAM; diff --git a/mysql-test/main/except_all.result b/mysql-test/main/except_all.result new file mode 100644 index 00000000000..2903ec857c3 --- /dev/null +++ b/mysql-test/main/except_all.result @@ -0,0 +1,675 @@ +create table t1 (a int, b int) engine=MyISAM; +create table t2 (c int, d int) engine=MyISAM; +insert into t1 values (1,1),(2,2),(3,3),(2,2),(4,4),(4,4),(4,4); +insert into t2 values (1,1),(1,1),(1,1),(2,2),(3,3),(3,3),(5,5); +select * from t1 except select * from t2; +a b +4 4 +select * from t1 except all select * from t2; +a b +4 4 +2 2 +4 4 +4 4 +select * from t1 except all select c+1,d+1 from t2; +a b +1 1 +4 4 +(select * from t1) except all (select * from t2); +a b +4 4 +2 2 +4 4 +4 4 +select * from ((select * from t1) except all (select * from t2)) a; +a b +4 4 +2 2 +4 4 +4 4 +select * from ((select a from t1) except all (select c from t2)) a; +a +4 +2 +4 +4 +select * from t1 except all select * from t1 union all select * from t1 union all select * from t1 except select * from t2; +a b +4 4 +select * from t1 except all select * from t1 union all select * from t1 union all select * from t1 except all select * from t2; +a b +4 4 +2 2 +4 4 +4 4 +4 4 +4 4 +4 4 +2 2 +2 2 +select * from (select * from t1 except all select * from t2) q1 except all select * from (select * from t1 except all select * from t2) q2; +a b +EXPLAIN select * from t1 except all select * from t2; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 7 +2 EXCEPT t2 ALL NULL NULL NULL NULL 7 +NULL EXCEPT RESULT <except1,2> ALL NULL NULL NULL NULL NULL +EXPLAIN format=json select * from t1 except all select * from t2; +EXPLAIN +{ + "query_block": { + "union_result": { + "table_name": "<except1,2>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 1, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 7, + "filtered": 100 + } + } + }, + { + "query_block": { + "select_id": 2, + "operation": "EXCEPT", + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 7, + "filtered": 100 + } + } + } + ] + } + } +} +EXPLAIN extended (select * from t1) except all (select * from t2); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 7 100.00 +2 EXCEPT t2 ALL NULL NULL NULL NULL 7 100.00 +NULL EXCEPT RESULT <except1,2> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 (/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) except all (/* select#2 */ select `test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2`) +EXPLAIN extended select * from ((select * from t1) except all (select * from t2)) a; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 7 100.00 +2 DERIVED t1 ALL NULL NULL NULL NULL 7 100.00 +3 EXCEPT t2 ALL NULL NULL NULL NULL 7 100.00 +NULL EXCEPT RESULT <except2,3> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `a`.`a` AS `a`,`a`.`b` AS `b` from ((/* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) except all (/* select#3 */ select `test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2`)) `a` +ANALYZE format=json select * from ((select a,b from t1) except all (select c,d from t2)) a; +ANALYZE +{ + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "r_loops": 1, + "rows": 7, + "r_rows": 4, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "materialized": { + "query_block": { + "union_result": { + "table_name": "<except2,3>", + "access_type": "ALL", + "r_loops": 1, + "r_rows": 4, + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 7, + "r_rows": 7, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + }, + { + "query_block": { + "select_id": 3, + "operation": "EXCEPT", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "t2", + "access_type": "ALL", + "r_loops": 1, + "rows": 7, + "r_rows": 7, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + } + ] + } + } + } + } + } +} +ANALYZE format=json select * from ((select a from t1) except all (select c from t2)) a; +ANALYZE +{ + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "r_loops": 1, + "rows": 7, + "r_rows": 4, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "materialized": { + "query_block": { + "union_result": { + "table_name": "<except2,3>", + "access_type": "ALL", + "r_loops": 1, + "r_rows": 4, + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 7, + "r_rows": 7, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + }, + { + "query_block": { + "select_id": 3, + "operation": "EXCEPT", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "t2", + "access_type": "ALL", + "r_loops": 1, + "rows": 7, + "r_rows": 7, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + } + ] + } + } + } + } + } +} +select * from ((select a from t1) except all (select c from t2)) a; +a +4 +2 +4 +4 +prepare stmt from "(select a,b from t1) except all (select c,d from t2)"; +execute stmt; +a b +4 4 +2 2 +4 4 +4 4 +execute stmt; +a b +4 4 +2 2 +4 4 +4 4 +prepare stmt from "select * from ((select a,b from t1) except all (select c,d from t2)) a"; +execute stmt; +a b +4 4 +2 2 +4 4 +4 4 +execute stmt; +a b +4 4 +2 2 +4 4 +4 4 +drop tables t1,t2; +create table t1 (a int, b int) engine=MyISAM; +create table t2 (c int, d int) engine=MyISAM; +create table t3 (e int, f int) engine=MyISAM; +create table t4 (g int, h int) engine=MyISAM; +insert into t1 values (1,1),(2,2),(2,2); +insert into t2 values (2,2),(3,3); +insert into t3 values (4,4),(5,5),(4,4); +insert into t4 values (4,4),(7,7),(4,4); +(select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4); +a b e f +1 1 4 4 +2 2 4 4 +1 1 5 5 +2 2 5 5 +1 1 4 4 +2 2 4 4 +2 2 5 5 +select * from ((select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4)) t; +a b e f +1 1 4 4 +2 2 4 4 +1 1 5 5 +2 2 5 5 +1 1 4 4 +2 2 4 4 +2 2 5 5 +(select * from t1,t3) except all (select * from t2,t4); +a b e f +1 1 4 4 +2 2 4 4 +1 1 5 5 +2 2 5 5 +1 1 4 4 +2 2 4 4 +2 2 5 5 +(select a,b,e from t1,t3) except all (select c,d,g from t2,t4); +a b e +1 1 4 +2 2 4 +1 1 5 +2 2 5 +1 1 4 +2 2 4 +2 2 5 +EXPLAIN (select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 +1 PRIMARY t3 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) +2 EXCEPT t2 ALL NULL NULL NULL NULL 2 +2 EXCEPT t4 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) +NULL EXCEPT RESULT <except1,2> ALL NULL NULL NULL NULL NULL +EXPLAIN select * from ((select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4)) t; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 9 +2 DERIVED t1 ALL NULL NULL NULL NULL 3 +2 DERIVED t3 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) +3 EXCEPT t2 ALL NULL NULL NULL NULL 2 +3 EXCEPT t4 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) +NULL EXCEPT RESULT <except2,3> ALL NULL NULL NULL NULL NULL +EXPLAIN extended select * from ((select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4)) t; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 9 100.00 +2 DERIVED t1 ALL NULL NULL NULL NULL 3 100.00 +2 DERIVED t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join) +3 EXCEPT t2 ALL NULL NULL NULL NULL 2 100.00 +3 EXCEPT t4 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join) +NULL EXCEPT RESULT <except2,3> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `t`.`a` AS `a`,`t`.`b` AS `b`,`t`.`e` AS `e`,`t`.`f` AS `f` from ((/* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t1` join `test`.`t3`) except all (/* select#3 */ select `test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t4`.`g` AS `g`,`test`.`t4`.`h` AS `h` from `test`.`t2` join `test`.`t4`)) `t` +EXPLAIN format=json select * from ((select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4)) t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "materialized": { + "query_block": { + "union_result": { + "table_name": "<except2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + }, + "block-nl-join": { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "119", + "join_type": "BNL" + } + } + }, + { + "query_block": { + "select_id": 3, + "operation": "EXCEPT", + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 2, + "filtered": 100 + }, + "block-nl-join": { + "table": { + "table_name": "t4", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "119", + "join_type": "BNL" + } + } + } + ] + } + } + } + } + } +} +ANALYZE format=json (select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4); +ANALYZE +{ + "query_block": { + "union_result": { + "table_name": "<except1,2>", + "access_type": "ALL", + "r_loops": 1, + "r_rows": 7, + "query_specifications": [ + { + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 3, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + }, + "block-nl-join": { + "table": { + "table_name": "t3", + "access_type": "ALL", + "r_loops": 1, + "rows": 3, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "119", + "join_type": "BNL", + "r_filtered": 100 + } + } + }, + { + "query_block": { + "select_id": 2, + "operation": "EXCEPT", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "t2", + "access_type": "ALL", + "r_loops": 1, + "rows": 2, + "r_rows": 2, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + }, + "block-nl-join": { + "table": { + "table_name": "t4", + "access_type": "ALL", + "r_loops": 1, + "rows": 3, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "119", + "join_type": "BNL", + "r_filtered": 100 + } + } + } + ] + } + } +} +ANALYZE format=json select * from ((select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4)) t; +ANALYZE +{ + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "r_loops": 1, + "rows": 9, + "r_rows": 7, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "materialized": { + "query_block": { + "union_result": { + "table_name": "<except2,3>", + "access_type": "ALL", + "r_loops": 1, + "r_rows": 7, + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 3, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + }, + "block-nl-join": { + "table": { + "table_name": "t3", + "access_type": "ALL", + "r_loops": 1, + "rows": 3, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "119", + "join_type": "BNL", + "r_filtered": 100 + } + } + }, + { + "query_block": { + "select_id": 3, + "operation": "EXCEPT", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "t2", + "access_type": "ALL", + "r_loops": 1, + "rows": 2, + "r_rows": 2, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + }, + "block-nl-join": { + "table": { + "table_name": "t4", + "access_type": "ALL", + "r_loops": 1, + "rows": 3, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "119", + "join_type": "BNL", + "r_filtered": 100 + } + } + } + ] + } + } + } + } + } +} +prepare stmt from "(select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4)"; +execute stmt; +a b e f +1 1 4 4 +2 2 4 4 +1 1 5 5 +2 2 5 5 +1 1 4 4 +2 2 4 4 +2 2 5 5 +execute stmt; +a b e f +1 1 4 4 +2 2 4 4 +1 1 5 5 +2 2 5 5 +1 1 4 4 +2 2 4 4 +2 2 5 5 +prepare stmt from "select * from ((select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4)) a"; +execute stmt; +a b e f +1 1 4 4 +2 2 4 4 +1 1 5 5 +2 2 5 5 +1 1 4 4 +2 2 4 4 +2 2 5 5 +execute stmt; +a b e f +1 1 4 4 +2 2 4 4 +1 1 5 5 +2 2 5 5 +1 1 4 4 +2 2 4 4 +2 2 5 5 +drop tables t1,t2,t3,t4; +select 1 as a from dual except all select 1 from dual; +a +(select 1 from dual) except all (select 1 from dual); +1 +(select 1 from dual into @v) except all (select 1 from dual); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'into @v) except all (select 1 from dual)' at line 1 +select 1 from dual ORDER BY 1 except all select 1 from dual; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'except all select 1 from dual' at line 1 +select 1 as a from dual union all select 1 from dual; +a +1 +1 +create table t1 (a int, b blob, a1 int, b1 blob) engine=MyISAM; +create table t2 (c int, d blob, c1 int, d1 blob) engine=MyISAM; +insert into t1 values (1,"ddd", 1, "sdfrrwwww"),(2, "fgh", 2, "dffggtt"),(2, "fgh", 2, "dffggtt"); +insert into t2 values (2, "fgh", 2, "dffggtt"),(3, "ffggddd", 3, "dfgg"); +(select a,b,b1 from t1) except all (select c,d,d1 from t2); +a b b1 +1 ddd sdfrrwwww +2 fgh dffggtt +create table t3 (select a,b,b1 from t1) except all (select c,d,d1 from t2); +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `a` int(11) DEFAULT NULL, + `b` blob DEFAULT NULL, + `b1` blob DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop tables t1,t2,t3; +CREATE TABLE t (i INT); +INSERT INTO t VALUES (1),(2); +SELECT * FROM t WHERE i != ANY ( SELECT 3 EXCEPT ALL SELECT 3 ); +i +drop table t; diff --git a/mysql-test/main/except_all.test b/mysql-test/main/except_all.test new file mode 100644 index 00000000000..f873b220126 --- /dev/null +++ b/mysql-test/main/except_all.test @@ -0,0 +1,99 @@ +create table t1 (a int, b int) engine=MyISAM; +create table t2 (c int, d int) engine=MyISAM; +insert into t1 values (1,1),(2,2),(3,3),(2,2),(4,4),(4,4),(4,4); +insert into t2 values (1,1),(1,1),(1,1),(2,2),(3,3),(3,3),(5,5); + +select * from t1 except select * from t2; +select * from t1 except all select * from t2; +select * from t1 except all select c+1,d+1 from t2; +(select * from t1) except all (select * from t2); +select * from ((select * from t1) except all (select * from t2)) a; +select * from ((select a from t1) except all (select c from t2)) a; +select * from t1 except all select * from t1 union all select * from t1 union all select * from t1 except select * from t2; + +select * from t1 except all select * from t1 union all select * from t1 union all select * from t1 except all select * from t2; + +select * from (select * from t1 except all select * from t2) q1 except all select * from (select * from t1 except all select * from t2) q2; + +EXPLAIN select * from t1 except all select * from t2; +EXPLAIN format=json select * from t1 except all select * from t2; +EXPLAIN extended (select * from t1) except all (select * from t2); +EXPLAIN extended select * from ((select * from t1) except all (select * from t2)) a; + +--source include/analyze-format.inc +ANALYZE format=json select * from ((select a,b from t1) except all (select c,d from t2)) a; +--source include/analyze-format.inc +ANALYZE format=json select * from ((select a from t1) except all (select c from t2)) a; +select * from ((select a from t1) except all (select c from t2)) a; + +prepare stmt from "(select a,b from t1) except all (select c,d from t2)"; +execute stmt; +execute stmt; + +prepare stmt from "select * from ((select a,b from t1) except all (select c,d from t2)) a"; +execute stmt; +execute stmt; + +drop tables t1,t2; + +create table t1 (a int, b int) engine=MyISAM; +create table t2 (c int, d int) engine=MyISAM; +create table t3 (e int, f int) engine=MyISAM; +create table t4 (g int, h int) engine=MyISAM; +insert into t1 values (1,1),(2,2),(2,2); +insert into t2 values (2,2),(3,3); +insert into t3 values (4,4),(5,5),(4,4); +insert into t4 values (4,4),(7,7),(4,4); + +(select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4); +select * from ((select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4)) t; +(select * from t1,t3) except all (select * from t2,t4); +(select a,b,e from t1,t3) except all (select c,d,g from t2,t4); + +EXPLAIN (select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4); +EXPLAIN select * from ((select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4)) t; +EXPLAIN extended select * from ((select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4)) t; +EXPLAIN format=json select * from ((select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4)) t; + +--source include/analyze-format.inc +ANALYZE format=json (select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4); +--source include/analyze-format.inc +ANALYZE format=json select * from ((select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4)) t; + +prepare stmt from "(select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4)"; +execute stmt; +execute stmt; + +prepare stmt from "select * from ((select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4)) a"; +execute stmt; +execute stmt; + +drop tables t1,t2,t3,t4; + +select 1 as a from dual except all select 1 from dual; +(select 1 from dual) except all (select 1 from dual); +--error ER_PARSE_ERROR +(select 1 from dual into @v) except all (select 1 from dual); +--error ER_PARSE_ERROR +select 1 from dual ORDER BY 1 except all select 1 from dual; +select 1 as a from dual union all select 1 from dual; + +create table t1 (a int, b blob, a1 int, b1 blob) engine=MyISAM; +create table t2 (c int, d blob, c1 int, d1 blob) engine=MyISAM; +insert into t1 values (1,"ddd", 1, "sdfrrwwww"),(2, "fgh", 2, "dffggtt"),(2, "fgh", 2, "dffggtt"); +insert into t2 values (2, "fgh", 2, "dffggtt"),(3, "ffggddd", 3, "dfgg"); + + +(select a,b,b1 from t1) except all (select c,d,d1 from t2); +# make sure that blob is used +create table t3 (select a,b,b1 from t1) except all (select c,d,d1 from t2); +show create table t3; + +drop tables t1,t2,t3; + +CREATE TABLE t (i INT); +INSERT INTO t VALUES (1),(2); + +SELECT * FROM t WHERE i != ANY ( SELECT 3 EXCEPT ALL SELECT 3 ); + +drop table t;
\ No newline at end of file diff --git a/mysql-test/main/explain.test b/mysql-test/main/explain.test index cf9f6be09ed..0fa4a5af215 100644 --- a/mysql-test/main/explain.test +++ b/mysql-test/main/explain.test @@ -130,7 +130,7 @@ DROP TABLE t1,t2; CREATE TABLE t1 (a INT PRIMARY KEY); ---error ER_KEY_DOES_NOT_EXITS +--error ER_KEY_DOES_NOT_EXISTS EXPLAIN EXTENDED SELECT COUNT(a) FROM t1 USE KEY(a); DROP TABLE t1; diff --git a/mysql-test/main/explain_json.result b/mysql-test/main/explain_json.result index b918e7614af..18a15795aab 100644 --- a/mysql-test/main/explain_json.result +++ b/mysql-test/main/explain_json.result @@ -977,7 +977,8 @@ ANALYZE "r_loops": 1, "rows": 101, "r_rows": 100, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "using_index_for_group_by": true @@ -1036,7 +1037,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by explain select count(distinct a1,a2,b,c) from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121'); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL idx_t1_1 163 NULL 65 Using where; Using index for group-by (scanning) +1 SIMPLE t1 range NULL idx_t1_1 163 NULL 65 Using where; Using index for group-by explain format=json select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a'); EXPLAIN { @@ -1069,7 +1070,7 @@ EXPLAIN "rows": 65, "filtered": 100, "attached_condition": "t1.b = 'a' and t1.c = 'i121' and t1.a2 >= 'b'", - "using_index_for_group_by": "scanning" + "using_index_for_group_by": true } } } @@ -1292,7 +1293,8 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 } @@ -1346,7 +1348,8 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 }, @@ -1361,7 +1364,8 @@ ANALYZE "r_loops": 2, "rows": 1, "r_rows": 1, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "attached_condition": "trigcond(t2.pk is null) and trigcond(trigcond(t1.a is not null))", @@ -1421,7 +1425,8 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "attached_condition": "t1.a is not null" @@ -1437,7 +1442,8 @@ ANALYZE "r_loops": 2, "rows": 1, "r_rows": 1, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "using_index": true, @@ -1512,7 +1518,8 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "attached_condition": "t3.a is not null" @@ -1529,7 +1536,8 @@ ANALYZE "r_loops": 1, "rows": 1, "r_rows": 10, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "index_condition_bka": "t4.b + 1 <= t3.b + 1" diff --git a/mysql-test/main/explain_json_format_partitions.result b/mysql-test/main/explain_json_format_partitions.result index 5d7fdbc4864..0c7d9e93105 100644 --- a/mysql-test/main/explain_json_format_partitions.result +++ b/mysql-test/main/explain_json_format_partitions.result @@ -36,7 +36,8 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 30, "attached_condition": "t1.a in (2,3,4)" diff --git a/mysql-test/main/features.result b/mysql-test/main/features.result index beab7fb946f..0da2e5fe986 100644 --- a/mysql-test/main/features.result +++ b/mysql-test/main/features.result @@ -10,6 +10,7 @@ Feature_delay_key_write 0 Feature_dynamic_columns 0 Feature_fulltext 0 Feature_gis 0 +Feature_insert_returning 0 Feature_invisible_columns 0 Feature_json 0 Feature_locale 0 @@ -165,9 +166,24 @@ drop table t1; show status like "feature_delay_key_write"; Variable_name Value Feature_delay_key_write 2 +# +# Feature CHECK CONSTRAINT +# create table t1 (a int check (a > 5)); create table t2 (b int, constraint foo check (b < 10)); drop table t1, t2; show status like "feature_check_constraint"; Variable_name Value Feature_check_constraint 2 +# +# Feature insert...returning +# +create table t1(id1 int); +insert into t1 values (1),(2) returning *; +id1 +1 +2 +drop table t1; +show status like "feature_insert_returning"; +Variable_name Value +Feature_insert_returning 1 diff --git a/mysql-test/main/features.test b/mysql-test/main/features.test index 1241bd50bdd..d0f5263c5c3 100644 --- a/mysql-test/main/features.test +++ b/mysql-test/main/features.test @@ -132,10 +132,18 @@ drop table t1; show status like "feature_delay_key_write"; -# -# Feature CHECK CONSTRAINT -# +--echo # +--echo # Feature CHECK CONSTRAINT +--echo # create table t1 (a int check (a > 5)); create table t2 (b int, constraint foo check (b < 10)); drop table t1, t2; show status like "feature_check_constraint"; + +--echo # +--echo # Feature insert...returning +--echo # +create table t1(id1 int); +insert into t1 values (1),(2) returning *; +drop table t1; +show status like "feature_insert_returning"; diff --git a/mysql-test/main/flush.result b/mysql-test/main/flush.result index 8149ce29dec..39e0b9432fe 100644 --- a/mysql-test/main/flush.result +++ b/mysql-test/main/flush.result @@ -329,12 +329,9 @@ flush tables t1 with read lock; handler t1 read a next; ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction unlock tables; -# -# Sic: lost handler position. -# handler t1 read a next; a -1 +3 handler t1 close; drop table t1; # @@ -558,3 +555,10 @@ ERROR HY000: Table 'v1' was not locked with LOCK TABLES UNLOCK TABLES; DROP VIEW v1; DROP TABLE t1; +# +# Test FLUSH THREADS +# +flush threads; +show status like "Threads_cached"; +Variable_name Value +Threads_cached 0 diff --git a/mysql-test/main/flush.test b/mysql-test/main/flush.test index 17f9241a122..6d76196bf54 100644 --- a/mysql-test/main/flush.test +++ b/mysql-test/main/flush.test @@ -412,9 +412,6 @@ flush tables t1 with read lock; --error ER_LOCK_OR_ACTIVE_TRANSACTION handler t1 read a next; unlock tables; ---echo # ---echo # Sic: lost handler position. ---echo # handler t1 read a next; handler t1 close; drop table t1; @@ -672,3 +669,9 @@ UNLOCK TABLES; DROP VIEW v1; DROP TABLE t1; +--echo # +--echo # Test FLUSH THREADS +--echo # + +flush threads; +show status like "Threads_cached"; diff --git a/mysql-test/main/flush_read_lock.result b/mysql-test/main/flush_read_lock.result index 0f8c2ce9fb9..62a94c38124 100644 --- a/mysql-test/main/flush_read_lock.result +++ b/mysql-test/main/flush_read_lock.result @@ -49,6 +49,7 @@ set local sql_mode=""; # used in this test in order to be able to # check that DDL statements on temporary tables # are compatible with FTRWL. +call mtr.add_suppression("BINLOG_BASE64_EVENT: Error executing row event.*error code: 1223"); drop tables if exists t1_base, t2_base, t3_trans; drop tables if exists tm_base, tm_base_temp; drop database if exists mysqltest1; @@ -438,7 +439,6 @@ Success: Was able to run 'execute stmt1' under FTWRL. Success: Was able to run 'execute stmt1' with FTWRL active in another connection. Success: Was able to run FTWRL while 'execute stmt1' was active in another connection. deallocate prepare stmt1; -call mtr.add_suppression("Slave SQL.*Can.t execute the query because you have a conflicting read lock., error.* 1223"); # # 9.2.b) EXECUTE for statement which is incompatible with FTWRL # should be also incompatible. @@ -1310,6 +1310,8 @@ unlock tables; # Check that XA non-COMMIT statements are not and COMMIT is # blocked by active FTWRL in another connection # +# XA COMMIT, XA ROLLBACK and XA PREPARE does take COMMIT lock to ensure +# that nothing is written to bin log and redo log under FTWRL mode. connection con1; flush tables with read lock; connection default; @@ -1322,11 +1324,25 @@ connection con1; flush tables with read lock; connection default; xa end 'test1'; -xa prepare 'test1'; +xa prepare 'test1';; +connection con1; +unlock tables; +# Switching to connection 'default'. +connection default; +# Reap XA PREPARE. +# Switching to connection 'con1'. +connection con1; +flush tables with read lock; +# Switching to connection 'default'. +connection default; +# Send XA ROLLBACK 'test1' xa rollback 'test1'; +# Switching to connection 'con1'. connection con1; +# Wait until XA ROLLBACK is blocked. unlock tables; connection default; +# Reap XA ROLLBACK xa start 'test1'; insert into t3_trans values (1); connection con1; @@ -1334,7 +1350,20 @@ flush tables with read lock; connection default; connection default; xa end 'test1'; +# Send XA PREPARE 'test1' xa prepare 'test1'; +# Switching to connection 'con1'. +connection con1; +# Wait until XA PREPARE is blocked. +unlock tables; +# Switching to connection 'default'. +connection default; +# Reap XA PREPARE. +# Switching to connection 'con1'. +connection con1; +flush tables with read lock; +# Switching to connection 'default'. +connection default; # Send: xa commit 'test1';; connection con1; @@ -1344,6 +1373,56 @@ connection default; # Reap XA COMMIT. delete from t3_trans; # +# Check that XA COMMIT / ROLLBACK for prepared transaction from a +# disconnected session is blocked by active FTWRL in another connection. +# +# Create temporary connection for XA transaction. +connect con_tmp,localhost,root,,; +xa start 'test1'; +insert into t3_trans values (1); +xa end 'test1'; +xa prepare 'test1'; +# Disconnect temporary connection +set debug_sync='thread_end SIGNAL test1_prepare'; +disconnect con_tmp; +connection con1; +set debug_sync='now WAIT_FOR test1_prepare'; +# Create temporary connection for XA transaction. +connect con_tmp1,localhost,root,,; +xa start 'test2'; +insert into t3_trans values (2); +xa end 'test2'; +xa prepare 'test2'; +# Disconnect temporary connection +set debug_sync='thread_end SIGNAL test2_prepare'; +disconnect con_tmp1; +# Switching to connection 'con1'. +connection con1; +set debug_sync='now WAIT_FOR test2_prepare'; +flush tables with read lock; +# Switching to connection 'default'. +connection default; +# Send XA ROLLBACK 'test1' +xa rollback 'test1'; +# Switching to connection 'con1'. +connection con1; +# Wait until XA ROLLBACK is blocked. +unlock tables; +flush tables with read lock; +# Switching to connection 'default'. +connection default; +# Reap XA ROLLBACK +# Send XA COMMIT +xa commit 'test2';; +# Switching to connection 'con1'. +connection con1; +# Wait until XA COMMIT is blocked. +unlock tables; +# Switching to connection 'default'. +connection default; +# Reap XA COMMIT. +delete from t3_trans; +# # Check that XA COMMIT blocks FTWRL in another connection. xa start 'test1'; insert into t3_trans values (1); diff --git a/mysql-test/main/flush_read_lock.test b/mysql-test/main/flush_read_lock.test index 80512deac4e..d73820425d2 100644 --- a/mysql-test/main/flush_read_lock.test +++ b/mysql-test/main/flush_read_lock.test @@ -65,6 +65,9 @@ set local sql_mode=""; --echo # used in this test in order to be able to --echo # check that DDL statements on temporary tables --echo # are compatible with FTRWL. + +call mtr.add_suppression("BINLOG_BASE64_EVENT: Error executing row event.*error code: 1223"); + --disable_warnings drop tables if exists t1_base, t2_base, t3_trans; drop tables if exists tm_base, tm_base_temp; @@ -300,7 +303,6 @@ set debug_sync= "RESET"; --echo # We don't run similar test for BEGIN and ROLLBACK as --echo # they release metadata locks in non-standard place. - --echo # --echo # 4) BINLOG statement should be incompatible with FTWRL. --echo # @@ -544,8 +546,6 @@ let $cleanup_stmt= ; --source include/check_ftwrl_compatible.inc deallocate prepare stmt1; -call mtr.add_suppression("Slave SQL.*Can.t execute the query because you have a conflicting read lock., error.* 1223"); - --echo # --echo # 9.2.b) EXECUTE for statement which is incompatible with FTWRL --echo # should be also incompatible. @@ -1592,6 +1592,8 @@ unlock tables; --echo # Check that XA non-COMMIT statements are not and COMMIT is --echo # blocked by active FTWRL in another connection --echo # +--echo # XA COMMIT, XA ROLLBACK and XA PREPARE does take COMMIT lock to ensure +--echo # that nothing is written to bin log and redo log under FTWRL mode. connection $con_aux1; flush tables with read lock; connection default; @@ -1604,11 +1606,37 @@ connection $con_aux1; flush tables with read lock; connection default; xa end 'test1'; -xa prepare 'test1'; -xa rollback 'test1'; +--send xa prepare 'test1'; connection $con_aux1; +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for backup lock" and + info = "xa prepare 'test1'"; +--source include/wait_condition.inc unlock tables; +--echo # Switching to connection 'default'. connection default; +--echo # Reap XA PREPARE. +--reap +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +--echo # Send XA ROLLBACK 'test1' +--send xa rollback 'test1' +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +--echo # Wait until XA ROLLBACK is blocked. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for backup lock" and + info = "xa rollback 'test1'"; +--source include/wait_condition.inc +unlock tables; +connection default; +--echo # Reap XA ROLLBACK +--reap xa start 'test1'; insert into t3_trans values (1); connection $con_aux1; @@ -1616,7 +1644,27 @@ flush tables with read lock; connection default; connection default; xa end 'test1'; -xa prepare 'test1'; +--echo # Send XA PREPARE 'test1' +--send xa prepare 'test1' +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +--echo # Wait until XA PREPARE is blocked. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for backup lock" and + info = "xa prepare 'test1'"; +--source include/wait_condition.inc +unlock tables; +--echo # Switching to connection 'default'. +connection default; +--echo # Reap XA PREPARE. +--reap +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; + --echo # Send: --send xa commit 'test1'; connection $con_aux1; @@ -1632,6 +1680,75 @@ connection default; --reap delete from t3_trans; --echo # +--echo # Check that XA COMMIT / ROLLBACK for prepared transaction from a +--echo # disconnected session is blocked by active FTWRL in another connection. +--echo # +--echo # Create temporary connection for XA transaction. +connect (con_tmp,localhost,root,,); +xa start 'test1'; +insert into t3_trans values (1); +xa end 'test1'; +xa prepare 'test1'; +--echo # Disconnect temporary connection +set debug_sync='thread_end SIGNAL test1_prepare'; +disconnect con_tmp; +connection $con_aux1; +set debug_sync='now WAIT_FOR test1_prepare'; + + +--echo # Create temporary connection for XA transaction. +connect (con_tmp1,localhost,root,,); +xa start 'test2'; +insert into t3_trans values (2); +xa end 'test2'; +xa prepare 'test2'; +--echo # Disconnect temporary connection +set debug_sync='thread_end SIGNAL test2_prepare'; +disconnect con_tmp1; + + +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +set debug_sync='now WAIT_FOR test2_prepare'; +flush tables with read lock; + +--echo # Switching to connection 'default'. +connection default; +--echo # Send XA ROLLBACK 'test1' +--send xa rollback 'test1' +--echo # Switching to connection '$con_aux1'. + +connection $con_aux1; +--echo # Wait until XA ROLLBACK is blocked. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for backup lock" and + info = "xa rollback 'test1'"; +--source include/wait_condition.inc +unlock tables; +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +--echo # Reap XA ROLLBACK +--reap +--echo # Send XA COMMIT +--send xa commit 'test2'; +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +--echo # Wait until XA COMMIT is blocked. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for backup lock" and + info = "xa commit 'test2'"; +--source include/wait_condition.inc +unlock tables; +--echo # Switching to connection 'default'. +connection default; +--echo # Reap XA COMMIT. +--reap +delete from t3_trans; + +--echo # --echo # Check that XA COMMIT blocks FTWRL in another connection. xa start 'test1'; insert into t3_trans values (1); diff --git a/mysql-test/main/foreign_key.result b/mysql-test/main/foreign_key.result index c412be6bbdb..46c8d3b7fee 100644 --- a/mysql-test/main/foreign_key.result +++ b/mysql-test/main/foreign_key.result @@ -1,7 +1,7 @@ drop table if exists t1,t2; create table t1 ( a int not null references t2, -b int not null references t2 (c), +b int not null constraint t2_c references t2 (c), primary key (a,b), foreign key (a) references t3 match full, foreign key (a) references t3 match partial, diff --git a/mysql-test/main/foreign_key.test b/mysql-test/main/foreign_key.test index 3a09a544532..8f42d43718e 100644 --- a/mysql-test/main/foreign_key.test +++ b/mysql-test/main/foreign_key.test @@ -10,7 +10,7 @@ drop table if exists t1,t2; create table t1 ( a int not null references t2, - b int not null references t2 (c), + b int not null constraint t2_c references t2 (c), primary key (a,b), foreign key (a) references t3 match full, foreign key (a) references t3 match partial, diff --git a/mysql-test/main/frm-debug.result b/mysql-test/main/frm-debug.result new file mode 100644 index 00000000000..332d7e00a8f --- /dev/null +++ b/mysql-test/main/frm-debug.result @@ -0,0 +1,24 @@ +# +# MDEV-20042 Implement EXTRA2_FIELD_DATA_TYPE_INFO in FRM +# +SET SESSION debug_dbug="+d,frm_data_type_info"; +CREATE TABLE t1 (c01 INT, c02 CHAR(20), c03 TEXT, c04 DOUBLE); +Warnings: +Note 1105 build_frm_image: Field data type info length: 0 +DROP TABLE t1; +SET SESSION debug_dbug="-d,frm_data_type_info"; +SET SESSION debug_dbug="+d,frm_data_type_info"; +SET SESSION debug_dbug="+d,frm_data_type_info_emulate"; +CREATE TABLE t1 (c01 INT, c02 CHAR(20), c03 TEXT, c04 DOUBLE); +Warnings: +Note 1105 build_frm_image: Field data type info length: 14 +Note 1105 DBUG: [0] name='c01' type_info='' +Note 1105 DBUG: [1] name='c02' type_info='xchar' +Note 1105 DBUG: [2] name='c03' type_info='xblob' +Note 1105 DBUG: [3] name='c04' type_info='' +SET SESSION debug_dbug="-d,frm_data_type_info_emulate"; +SET SESSION debug_dbug="-d,frm_data_type_info"; +FLUSH TABLES; +SHOW CREATE TABLE t1; +ERROR HY000: Unknown data type: 'xchar' +DROP TABLE t1; diff --git a/mysql-test/main/frm-debug.test b/mysql-test/main/frm-debug.test new file mode 100644 index 00000000000..d86acdbc7e3 --- /dev/null +++ b/mysql-test/main/frm-debug.test @@ -0,0 +1,22 @@ +--source include/have_debug.inc + +--echo # +--echo # MDEV-20042 Implement EXTRA2_FIELD_DATA_TYPE_INFO in FRM +--echo # + +# This should have empty EXTRA2_FIELD_DATA_TYPE_INFO +SET SESSION debug_dbug="+d,frm_data_type_info"; +CREATE TABLE t1 (c01 INT, c02 CHAR(20), c03 TEXT, c04 DOUBLE); +DROP TABLE t1; +SET SESSION debug_dbug="-d,frm_data_type_info"; + +# This should have non-empty EXTRA2_FIELD_DATA_TYPE_INFO +SET SESSION debug_dbug="+d,frm_data_type_info"; +SET SESSION debug_dbug="+d,frm_data_type_info_emulate"; +CREATE TABLE t1 (c01 INT, c02 CHAR(20), c03 TEXT, c04 DOUBLE); +SET SESSION debug_dbug="-d,frm_data_type_info_emulate"; +SET SESSION debug_dbug="-d,frm_data_type_info"; +FLUSH TABLES; +--error ER_UNKNOWN_DATA_TYPE +SHOW CREATE TABLE t1; +DROP TABLE t1; diff --git a/mysql-test/main/func_bit.result b/mysql-test/main/func_bit.result new file mode 100644 index 00000000000..4eb44f76ef3 --- /dev/null +++ b/mysql-test/main/func_bit.result @@ -0,0 +1,367 @@ +# +# Start of 10.5 tests +# +# +# MDEV-20305 Data loss on DOUBLE and DECIMAL conversion to INT +# +CREATE PROCEDURE p1(type VARCHAR(64), val VARCHAR(64)) +BEGIN +EXECUTE IMMEDIATE CONCAT('CREATE TABLE t1 (a ', type, ')'); +SHOW CREATE TABLE t1; +EXECUTE IMMEDIATE CONCAT('INSERT INTO t1 VALUES (', val, ')'); +SELECT +a, +~a, +a & 18446744073709551615, +18446744073709551615 & a, +0 | a, +a | 0, +a << 0, +a >> 0, +a ^ 1, +1 ^ a, +BIT_COUNT(a) +FROM t1; +SHOW WARNINGS; +DROP TABLE t1; +END; +$$ +CALL p1('BIGINT UNSIGNED', 18446744073709551615); +Table t1 +Create Table CREATE TABLE `t1` ( + `a` bigint(20) unsigned DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +a 18446744073709551615 +~a 0 +a & 18446744073709551615 18446744073709551615 +18446744073709551615 & a 18446744073709551615 +0 | a 18446744073709551615 +a | 0 18446744073709551615 +a << 0 18446744073709551615 +a >> 0 18446744073709551615 +a ^ 1 18446744073709551614 +1 ^ a 18446744073709551614 +BIT_COUNT(a) 64 +CALL p1('DOUBLE', 18446744073709551615); +Table t1 +Create Table CREATE TABLE `t1` ( + `a` double DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +a 1.8446744073709552e19 +~a 0 +a & 18446744073709551615 18446744073709551615 +18446744073709551615 & a 18446744073709551615 +0 | a 18446744073709551615 +a | 0 18446744073709551615 +a << 0 18446744073709551615 +a >> 0 18446744073709551615 +a ^ 1 18446744073709551614 +1 ^ a 18446744073709551614 +BIT_COUNT(a) 64 +Level Warning +Code 1916 +Message Got overflow when converting '18446744073709552000' to UNSIGNED INT. Value truncated +Level Warning +Code 1916 +Message Got overflow when converting '18446744073709552000' to UNSIGNED INT. Value truncated +Level Warning +Code 1916 +Message Got overflow when converting '18446744073709552000' to UNSIGNED INT. Value truncated +Level Warning +Code 1916 +Message Got overflow when converting '18446744073709552000' to UNSIGNED INT. Value truncated +Level Warning +Code 1916 +Message Got overflow when converting '18446744073709552000' to UNSIGNED INT. Value truncated +Level Warning +Code 1916 +Message Got overflow when converting '18446744073709552000' to UNSIGNED INT. Value truncated +Level Warning +Code 1916 +Message Got overflow when converting '18446744073709552000' to UNSIGNED INT. Value truncated +Level Warning +Code 1916 +Message Got overflow when converting '18446744073709552000' to UNSIGNED INT. Value truncated +Level Warning +Code 1916 +Message Got overflow when converting '18446744073709552000' to UNSIGNED INT. Value truncated +Level Warning +Code 1916 +Message Got overflow when converting '18446744073709552000' to UNSIGNED INT. Value truncated +CALL p1('DECIMAL(30,0)', 18446744073709551615); +Table t1 +Create Table CREATE TABLE `t1` ( + `a` decimal(30,0) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +a 18446744073709551615 +~a 0 +a & 18446744073709551615 18446744073709551615 +18446744073709551615 & a 18446744073709551615 +0 | a 18446744073709551615 +a | 0 18446744073709551615 +a << 0 18446744073709551615 +a >> 0 18446744073709551615 +a ^ 1 18446744073709551614 +1 ^ a 18446744073709551614 +BIT_COUNT(a) 64 +CALL p1('BIGINT', -1); +Table t1 +Create Table CREATE TABLE `t1` ( + `a` bigint(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +a -1 +~a 0 +a & 18446744073709551615 18446744073709551615 +18446744073709551615 & a 18446744073709551615 +0 | a 18446744073709551615 +a | 0 18446744073709551615 +a << 0 18446744073709551615 +a >> 0 18446744073709551615 +a ^ 1 18446744073709551614 +1 ^ a 18446744073709551614 +BIT_COUNT(a) 64 +CALL p1('DOUBLE', -1); +Table t1 +Create Table CREATE TABLE `t1` ( + `a` double DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +a -1 +~a 0 +a & 18446744073709551615 18446744073709551615 +18446744073709551615 & a 18446744073709551615 +0 | a 18446744073709551615 +a | 0 18446744073709551615 +a << 0 18446744073709551615 +a >> 0 18446744073709551615 +a ^ 1 18446744073709551614 +1 ^ a 18446744073709551614 +BIT_COUNT(a) 64 +CALL p1('DECIMAL(30,0)', -1); +Table t1 +Create Table CREATE TABLE `t1` ( + `a` decimal(30,0) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +a -1 +~a 0 +a & 18446744073709551615 18446744073709551615 +18446744073709551615 & a 18446744073709551615 +0 | a 18446744073709551615 +a | 0 18446744073709551615 +a << 0 18446744073709551615 +a >> 0 18446744073709551615 +a ^ 1 18446744073709551614 +1 ^ a 18446744073709551614 +BIT_COUNT(a) 64 +CALL p1('BIGINT', -9223372036854775808); +Table t1 +Create Table CREATE TABLE `t1` ( + `a` bigint(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +a -9223372036854775808 +~a 9223372036854775807 +a & 18446744073709551615 9223372036854775808 +18446744073709551615 & a 9223372036854775808 +0 | a 9223372036854775808 +a | 0 9223372036854775808 +a << 0 9223372036854775808 +a >> 0 9223372036854775808 +a ^ 1 9223372036854775809 +1 ^ a 9223372036854775809 +BIT_COUNT(a) 1 +CALL p1('DOUBLE', -9223372036854775808); +Table t1 +Create Table CREATE TABLE `t1` ( + `a` double DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +a -9.223372036854776e18 +~a 9223372036854775807 +a & 18446744073709551615 9223372036854775808 +18446744073709551615 & a 9223372036854775808 +0 | a 9223372036854775808 +a | 0 9223372036854775808 +a << 0 9223372036854775808 +a >> 0 9223372036854775808 +a ^ 1 9223372036854775809 +1 ^ a 9223372036854775809 +BIT_COUNT(a) 1 +Level Warning +Code 1916 +Message Got overflow when converting '-9223372036854776000' to INT. Value truncated +Level Warning +Code 1916 +Message Got overflow when converting '-9223372036854776000' to INT. Value truncated +Level Warning +Code 1916 +Message Got overflow when converting '-9223372036854776000' to INT. Value truncated +Level Warning +Code 1916 +Message Got overflow when converting '-9223372036854776000' to INT. Value truncated +Level Warning +Code 1916 +Message Got overflow when converting '-9223372036854776000' to INT. Value truncated +Level Warning +Code 1916 +Message Got overflow when converting '-9223372036854776000' to INT. Value truncated +Level Warning +Code 1916 +Message Got overflow when converting '-9223372036854776000' to INT. Value truncated +Level Warning +Code 1916 +Message Got overflow when converting '-9223372036854776000' to INT. Value truncated +Level Warning +Code 1916 +Message Got overflow when converting '-9223372036854776000' to INT. Value truncated +Level Warning +Code 1916 +Message Got overflow when converting '-9223372036854776000' to INT. Value truncated +CALL p1('DECIMAL(30,0)', -9223372036854775808); +Table t1 +Create Table CREATE TABLE `t1` ( + `a` decimal(30,0) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +a -9223372036854775808 +~a 9223372036854775807 +a & 18446744073709551615 9223372036854775808 +18446744073709551615 & a 9223372036854775808 +0 | a 9223372036854775808 +a | 0 9223372036854775808 +a << 0 9223372036854775808 +a >> 0 9223372036854775808 +a ^ 1 9223372036854775809 +1 ^ a 9223372036854775809 +BIT_COUNT(a) 1 +DROP PROCEDURE p1; +SELECT CAST(CAST(18446744073709551615 AS UNSIGNED) AS DECIMAL(32))<<0 AS c1; +c1 +18446744073709551615 +SELECT CAST(CAST(18446744073709551615 AS UNSIGNED) AS DOUBLE)<<0 AS c1; +c1 +18446744073709551615 +Warnings: +Warning 1916 Got overflow when converting '18446744073709552000' to UNSIGNED INT. Value truncated +SELECT COALESCE(CAST(CAST(0xFFFFFFFFFFFFFFFF AS UNSIGNED) AS DECIMAL(32))) << 0 AS c1; +c1 +18446744073709551615 +SELECT COALESCE(CAST(CAST(0xFFFFFFFFFFFFFFFF AS UNSIGNED) AS DOUBLE)) << 0 AS c1; +c1 +18446744073709551615 +Warnings: +Warning 1916 Got overflow when converting '18446744073709552000' to UNSIGNED INT. Value truncated +SELECT 18446744073709551615 ^ 1 AS c1; +c1 +18446744073709551614 +SELECT 18446744073709551615.0 ^ 1 AS c1; +c1 +18446744073709551614 +SELECT 18446744073709551615e0 ^ 1 AS c1; +c1 +18446744073709551614 +Warnings: +Warning 1916 Got overflow when converting '18446744073709552000' to UNSIGNED INT. Value truncated +SELECT LAST_VALUE(18446744073709551615) ^ 1 AS c1; +c1 +18446744073709551614 +SELECT LAST_VALUE(18446744073709551615.0) ^ 1 AS c1; +c1 +18446744073709551614 +SELECT LAST_VALUE(18446744073709551615e0) ^ 1 AS c1; +c1 +18446744073709551614 +Warnings: +Warning 1916 Got overflow when converting '18446744073709552000' to UNSIGNED INT. Value truncated +SELECT 18446744073709551615 & 18446744073709551615 AS c1; +c1 +18446744073709551615 +SELECT 18446744073709551615 & 18446744073709551615.0 AS c1; +c1 +18446744073709551615 +SELECT 18446744073709551615 & 18446744073709551615e0 AS c1; +c1 +18446744073709551615 +Warnings: +Warning 1916 Got overflow when converting '18446744073709552000' to UNSIGNED INT. Value truncated +SELECT 18446744073709551615.0 & 18446744073709551615 AS c1; +c1 +18446744073709551615 +SELECT 18446744073709551615.0 & 18446744073709551615.0 AS c1; +c1 +18446744073709551615 +SELECT 18446744073709551615.0 & 18446744073709551615e0 AS c1; +c1 +18446744073709551615 +Warnings: +Warning 1916 Got overflow when converting '18446744073709552000' to UNSIGNED INT. Value truncated +SELECT 18446744073709551615e0 & 18446744073709551615 AS c1; +c1 +18446744073709551615 +Warnings: +Warning 1916 Got overflow when converting '18446744073709552000' to UNSIGNED INT. Value truncated +SELECT 18446744073709551615e0 & 18446744073709551615.0 AS c1; +c1 +18446744073709551615 +Warnings: +Warning 1916 Got overflow when converting '18446744073709552000' to UNSIGNED INT. Value truncated +SELECT 18446744073709551615e0 & 18446744073709551615e0 AS c1; +c1 +18446744073709551615 +Warnings: +Warning 1916 Got overflow when converting '18446744073709552000' to UNSIGNED INT. Value truncated +Warning 1916 Got overflow when converting '18446744073709552000' to UNSIGNED INT. Value truncated +SELECT 0 | 18446744073709551615 AS c1; +c1 +18446744073709551615 +SELECT 0 | 18446744073709551615.0 AS c1; +c1 +18446744073709551615 +SELECT 0 | 18446744073709551615e0 AS c1; +c1 +18446744073709551615 +Warnings: +Warning 1916 Got overflow when converting '18446744073709552000' to UNSIGNED INT. Value truncated +SELECT 18446744073709551615 | 0 AS c1; +c1 +18446744073709551615 +SELECT 18446744073709551615.0 | 0 AS c1; +c1 +18446744073709551615 +SELECT 18446744073709551615e0 | 0 AS c1; +c1 +18446744073709551615 +Warnings: +Warning 1916 Got overflow when converting '18446744073709552000' to UNSIGNED INT. Value truncated +SELECT ~18446744073709551615 AS c1; +c1 +0 +SELECT ~18446744073709551615.0 AS c1; +c1 +0 +SELECT ~18446744073709551615e0 AS c1; +c1 +0 +Warnings: +Warning 1916 Got overflow when converting '18446744073709552000' to UNSIGNED INT. Value truncated +SELECT BIT_COUNT(18446744073709551615) AS c1; +c1 +64 +SELECT BIT_COUNT(18446744073709551615.0) AS c1; +c1 +64 +SELECT BIT_COUNT(18446744073709551615e0) AS c1; +c1 +64 +Warnings: +Warning 1916 Got overflow when converting '18446744073709552000' to UNSIGNED INT. Value truncated +SELECT BIT_COUNT(-9223372036854775808) AS c1; +c1 +1 +SELECT BIT_COUNT(-9223372036854775808.0) AS c1; +c1 +1 +SELECT BIT_COUNT(-9223372036854775808e0) AS c1; +c1 +1 +Warnings: +Warning 1916 Got overflow when converting '-9223372036854776000' to INT. Value truncated +# +# End of 10.5 tests +# diff --git a/mysql-test/main/func_bit.test b/mysql-test/main/func_bit.test new file mode 100644 index 00000000000..e4f3189eafc --- /dev/null +++ b/mysql-test/main/func_bit.test @@ -0,0 +1,97 @@ +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-20305 Data loss on DOUBLE and DECIMAL conversion to INT +--echo # + +DELIMITER $$; +CREATE PROCEDURE p1(type VARCHAR(64), val VARCHAR(64)) +BEGIN + EXECUTE IMMEDIATE CONCAT('CREATE TABLE t1 (a ', type, ')'); + SHOW CREATE TABLE t1; + EXECUTE IMMEDIATE CONCAT('INSERT INTO t1 VALUES (', val, ')'); + SELECT + a, + ~a, + a & 18446744073709551615, + 18446744073709551615 & a, + 0 | a, + a | 0, + a << 0, + a >> 0, + a ^ 1, + 1 ^ a, + BIT_COUNT(a) + FROM t1; + SHOW WARNINGS; + DROP TABLE t1; +END; +$$ +DELIMITER ;$$ + +--vertical_results +CALL p1('BIGINT UNSIGNED', 18446744073709551615); +CALL p1('DOUBLE', 18446744073709551615); +CALL p1('DECIMAL(30,0)', 18446744073709551615); + +CALL p1('BIGINT', -1); +CALL p1('DOUBLE', -1); +CALL p1('DECIMAL(30,0)', -1); + +CALL p1('BIGINT', -9223372036854775808); +CALL p1('DOUBLE', -9223372036854775808); +CALL p1('DECIMAL(30,0)', -9223372036854775808); +--horizontal_results + +DROP PROCEDURE p1; + + +SELECT CAST(CAST(18446744073709551615 AS UNSIGNED) AS DECIMAL(32))<<0 AS c1; +SELECT CAST(CAST(18446744073709551615 AS UNSIGNED) AS DOUBLE)<<0 AS c1; + +SELECT COALESCE(CAST(CAST(0xFFFFFFFFFFFFFFFF AS UNSIGNED) AS DECIMAL(32))) << 0 AS c1; +SELECT COALESCE(CAST(CAST(0xFFFFFFFFFFFFFFFF AS UNSIGNED) AS DOUBLE)) << 0 AS c1; + +SELECT 18446744073709551615 ^ 1 AS c1; +SELECT 18446744073709551615.0 ^ 1 AS c1; +SELECT 18446744073709551615e0 ^ 1 AS c1; + +SELECT LAST_VALUE(18446744073709551615) ^ 1 AS c1; +SELECT LAST_VALUE(18446744073709551615.0) ^ 1 AS c1; +SELECT LAST_VALUE(18446744073709551615e0) ^ 1 AS c1; + +SELECT 18446744073709551615 & 18446744073709551615 AS c1; +SELECT 18446744073709551615 & 18446744073709551615.0 AS c1; +SELECT 18446744073709551615 & 18446744073709551615e0 AS c1; +SELECT 18446744073709551615.0 & 18446744073709551615 AS c1; +SELECT 18446744073709551615.0 & 18446744073709551615.0 AS c1; +SELECT 18446744073709551615.0 & 18446744073709551615e0 AS c1; +SELECT 18446744073709551615e0 & 18446744073709551615 AS c1; +SELECT 18446744073709551615e0 & 18446744073709551615.0 AS c1; +SELECT 18446744073709551615e0 & 18446744073709551615e0 AS c1; + + +SELECT 0 | 18446744073709551615 AS c1; +SELECT 0 | 18446744073709551615.0 AS c1; +SELECT 0 | 18446744073709551615e0 AS c1; +SELECT 18446744073709551615 | 0 AS c1; +SELECT 18446744073709551615.0 | 0 AS c1; +SELECT 18446744073709551615e0 | 0 AS c1; + +SELECT ~18446744073709551615 AS c1; +SELECT ~18446744073709551615.0 AS c1; +SELECT ~18446744073709551615e0 AS c1; + +SELECT BIT_COUNT(18446744073709551615) AS c1; +SELECT BIT_COUNT(18446744073709551615.0) AS c1; +SELECT BIT_COUNT(18446744073709551615e0) AS c1; + +SELECT BIT_COUNT(-9223372036854775808) AS c1; +SELECT BIT_COUNT(-9223372036854775808.0) AS c1; +SELECT BIT_COUNT(-9223372036854775808e0) AS c1; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/func_crypt.result b/mysql-test/main/func_crypt.result index aaa6aa61eae..2c42d3dc845 100644 --- a/mysql-test/main/func_crypt.result +++ b/mysql-test/main/func_crypt.result @@ -214,3 +214,4 @@ SELECT * FROM t1; a b hello 12NKz5XM5JeKI DROP TABLE t1; +# End of 10.2 tests diff --git a/mysql-test/main/func_crypt.test b/mysql-test/main/func_crypt.test index d091aa4ae86..118a7023669 100644 --- a/mysql-test/main/func_crypt.test +++ b/mysql-test/main/func_crypt.test @@ -120,3 +120,5 @@ SHOW CREATE TABLE t1; INSERT INTO t1 (a) VALUES ('hello'); SELECT * FROM t1; DROP TABLE t1; + +--echo # End of 10.2 tests diff --git a/mysql-test/main/func_debug.result b/mysql-test/main/func_debug.result index 47bbced730b..08650fdd3c3 100644 --- a/mysql-test/main/func_debug.result +++ b/mysql-test/main/func_debug.result @@ -1723,7 +1723,7 @@ a 2 3 Warnings: -Note 1105 bin_eq=0 a=(int)-1 b=(bigint)18446744073709551615 +Note 1105 bin_eq=0 a=(int)-1 b=(bigint unsigned)18446744073709551615 SELECT * FROM t1 WHERE a BETWEEN -1 AND 18446744073709551616; a 1 @@ -1746,7 +1746,7 @@ a 2 3 Warnings: -Note 1105 bin_eq=0 a=(int)-1 b=(bigint)18446744073709551615 +Note 1105 bin_eq=0 a=(int)-1 b=(bigint unsigned)18446744073709551615 EXECUTE IMMEDIATE 'SELECT * FROM t1 WHERE a BETWEEN -1 AND ?' USING 18446744073709551616; a 1 @@ -1863,8 +1863,8 @@ Warnings: Note 1105 DBUG: [0] arg=1 handler=0 (row) Note 1105 DBUG: [1] arg=2 handler=0 (row) Note 1105 DBUG: ROW(3 args) level=0 -Note 1105 DBUG: [0,0] handler=bigint -Note 1105 DBUG: [0,1] handler=bigint +Note 1105 DBUG: [0,0] handler=bigint unsigned +Note 1105 DBUG: [0,1] handler=bigint unsigned Note 1105 DBUG: [0,2] handler=int Note 1105 DBUG: => handler=decimal Note 1105 DBUG: [1,0] handler=int diff --git a/mysql-test/main/func_des_encrypt.result b/mysql-test/main/func_des_encrypt.result index b81f96f6ef7..540596589b6 100644 --- a/mysql-test/main/func_des_encrypt.result +++ b/mysql-test/main/func_des_encrypt.result @@ -35,3 +35,41 @@ DES_DECRYPT(DES_ENCRYPT('1234')) DES_DECRYPT(DES_ENCRYPT('12345')) DES_DECRYPT(D 1234 12345 123456 1234567 DROP TABLE t1; End of 5.0 tests +# +# MDEV-23330 Server crash or ASAN negative-size-param in +# my_strnncollsp_binary / SORT_FIELD_ATTR::compare_packed_varstrings +# +CREATE TABLE t1 (a CHAR(240), b BIT(48)); +INSERT INTO t1 VALUES ('a',b'0001'),('b',b'0010'),('c',b'0011'),('d',b'0100'),('e',b'0001'),('f',b'0101'),('g',b'0110'),('h',b'0111'),('i',b'1000'),('j',b'1001'); +SELECT DES_DECRYPT(a, 'x'), HEX(BINARY b) FROM t1 GROUP BY 1, 2 WITH ROLLUP; +DES_DECRYPT(a, 'x') HEX(BINARY b) +a 000000000001 +a NULL +b 000000000002 +b NULL +c 000000000003 +c NULL +d 000000000004 +d NULL +e 000000000001 +e NULL +f 000000000005 +f NULL +g 000000000006 +g NULL +h 000000000007 +h NULL +i 000000000008 +i NULL +j 000000000009 +j NULL +NULL NULL +DROP TABLE t1; +CREATE TABLE t1 (a INT); +INSERT t1 VALUES (1),(2); +SELECT CHAR_LENGTH(a), DES_DECRYPT(a) FROM (SELECT _utf8 0xC2A2 AS a FROM t1) AS t2; +CHAR_LENGTH(a) DES_DECRYPT(a) +1 ¢ +1 ¢ +DROP TABLE t1; +End of 10.5 tests diff --git a/mysql-test/main/func_des_encrypt.test b/mysql-test/main/func_des_encrypt.test index c9661b81cc0..44fc30ff00f 100644 --- a/mysql-test/main/func_des_encrypt.test +++ b/mysql-test/main/func_des_encrypt.test @@ -37,3 +37,24 @@ SELECT DROP TABLE t1; --Echo End of 5.0 tests + +--echo # +--echo # MDEV-23330 Server crash or ASAN negative-size-param in +--echo # my_strnncollsp_binary / SORT_FIELD_ATTR::compare_packed_varstrings +--echo # + +CREATE TABLE t1 (a CHAR(240), b BIT(48)); +INSERT INTO t1 VALUES ('a',b'0001'),('b',b'0010'),('c',b'0011'),('d',b'0100'),('e',b'0001'),('f',b'0101'),('g',b'0110'),('h',b'0111'),('i',b'1000'),('j',b'1001'); +SELECT DES_DECRYPT(a, 'x'), HEX(BINARY b) FROM t1 GROUP BY 1, 2 WITH ROLLUP; +DROP TABLE t1; + +# +# don't change the charset of a literal Item_string +# + +CREATE TABLE t1 (a INT); +INSERT t1 VALUES (1),(2); +SELECT CHAR_LENGTH(a), DES_DECRYPT(a) FROM (SELECT _utf8 0xC2A2 AS a FROM t1) AS t2; +DROP TABLE t1; + +--Echo End of 10.5 tests diff --git a/mysql-test/main/func_gconcat.result b/mysql-test/main/func_gconcat.result index a7517e98134..328bbc953ab 100644 --- a/mysql-test/main/func_gconcat.result +++ b/mysql-test/main/func_gconcat.result @@ -1043,7 +1043,7 @@ DROP TABLE t1; CREATE TABLE t1(f1 int); INSERT INTO t1 values (0),(0); SELECT POLYGON((SELECT 1 FROM (SELECT 1 IN (GROUP_CONCAT(t1.f1)) FROM t1, t1 t GROUP BY t.f1 ) d)); -ERROR HY000: Illegal parameter data type int for operation 'geometrycollection' +ERROR HY000: Illegal parameter data type int for operation 'polygon' DROP TABLE t1; # # Bug#58396 group_concat and explain extended are still crashy diff --git a/mysql-test/main/func_group.result b/mysql-test/main/func_group.result index 071c155cd6b..177f0950a77 100644 --- a/mysql-test/main/func_group.result +++ b/mysql-test/main/func_group.result @@ -604,11 +604,11 @@ AME AME explain select min(a1) from t1 where a1 > 'KKK' or a1 < 'XXX'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index PRIMARY PRIMARY 3 NULL 15 Using where; Using index +1 SIMPLE t1 range PRIMARY PRIMARY 0 NULL 15 Using where; Using index explain select min(a1) from t1 where (a1 < 'KKK' or a1 > 'KKK'); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index PRIMARY PRIMARY 3 NULL 15 Using where; Using index +1 SIMPLE t1 range PRIMARY PRIMARY 3 NULL 14 Using where; Using index explain select max(a3) from t1 where a2 < 2 and a3 < 'SEA'; id select_type table type possible_keys key key_len ref rows Extra @@ -653,7 +653,7 @@ id select_type table type possible_keys key key_len ref rows Extra explain select concat(min(t1.a1),min(t2.a4)) from t1, t2 where t2.a4 <> 'AME'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 index k2 k2 4 NULL 7 Using where; Using index +1 SIMPLE t2 range k2 k2 4 NULL 6 Using where; Using index 1 SIMPLE t1 index NULL PRIMARY 3 NULL 15 Using index; Using join buffer (flat, BNL join) drop table t1, t2; create table t1 (a char(10)); @@ -1927,7 +1927,7 @@ b EXPLAIN SELECT MIN(f2) FROM t1 WHERE f2 >= 'abc'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index f2 f2 4 NULL 2 Using where; Using index +1 SIMPLE t1 range f2 f2 4 NULL 1 Using where; Using index SELECT MIN(f2) FROM t1 WHERE f2 >= 'abc'; MIN(f2) b @@ -1941,7 +1941,7 @@ b EXPLAIN SELECT MIN(f2) FROM t1 WHERE f2 BETWEEN 'abc' AND 'b' ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index f2 f2 4 NULL 2 Using where; Using index +1 SIMPLE t1 range f2 f2 4 NULL 1 Using where; Using index SELECT MIN(f2) FROM t1 WHERE f2 BETWEEN 'abc' AND 'b' ; MIN(f2) b @@ -2326,7 +2326,7 @@ SELECT MAX('x') << 1, CAST(MAX('x') AS DOUBLE), CAST(MAX('x') AS DECIMAL); MAX('x') << 1 CAST(MAX('x') AS DOUBLE) CAST(MAX('x') AS DECIMAL) 0 0 0 Warnings: -Warning 1292 Truncated incorrect INTEGER value: 'x' +Warning 1292 Truncated incorrect DECIMAL value: 'x' Warning 1292 Truncated incorrect DOUBLE value: 'x' Warning 1292 Truncated incorrect DECIMAL value: 'x' # diff --git a/mysql-test/main/func_group_innodb.result b/mysql-test/main/func_group_innodb.result index a4c9b574585..f5a823e4638 100644 --- a/mysql-test/main/func_group_innodb.result +++ b/mysql-test/main/func_group_innodb.result @@ -225,8 +225,8 @@ DROP TABLE t1; # # MDEV-4269: crash when grouping by values() # -SELECT @@storage_engine INTO @old_engine; -set storage_engine=innodb; +SELECT @@default_storage_engine INTO @old_engine; +set default_storage_engine=innodb; create table y select 1 b; select 1 from y group by b; 1 @@ -235,7 +235,7 @@ select 1 from y group by value(b); 1 1 drop table y; -SET storage_engine=@old_engine; +SET default_storage_engine=@old_engine; # # Bug#13723054 CRASH WITH MIN/MAX AFTER QUICK_GROUP_MIN_MAX_SELECT::NEXT_MIN # diff --git a/mysql-test/main/func_group_innodb.test b/mysql-test/main/func_group_innodb.test index 6141b4d85ed..748c64a43c6 100644 --- a/mysql-test/main/func_group_innodb.test +++ b/mysql-test/main/func_group_innodb.test @@ -170,14 +170,14 @@ DROP TABLE t1; --echo # MDEV-4269: crash when grouping by values() --echo # -SELECT @@storage_engine INTO @old_engine; -set storage_engine=innodb; +SELECT @@default_storage_engine INTO @old_engine; +set default_storage_engine=innodb; create table y select 1 b; select 1 from y group by b; select 1 from y group by value(b); drop table y; -SET storage_engine=@old_engine; +SET default_storage_engine=@old_engine; ### End of 5.1 tests diff --git a/mysql-test/main/func_hybrid_type.result b/mysql-test/main/func_hybrid_type.result index 83965bc6db5..4be42cee523 100644 --- a/mysql-test/main/func_hybrid_type.result +++ b/mysql-test/main/func_hybrid_type.result @@ -4119,3 +4119,199 @@ c # # End of 10.4 tests # +# +# Start of 10.5 tests +# +# +# MDEV-20332 Wrong UNSIGNED metadata flag returned for COALESCE(unsigned_field,timestamp_field) +# +CREATE TABLE t1 (a INT UNSIGNED, b TIMESTAMP); +SELECT COALESCE(a,b) FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def COALESCE(a,b) 253 19 0 Y 0 39 8 +COALESCE(a,b) +DROP TABLE t1; +# +# MDEV-20353 Add separate type handlers for unsigned integer data types +# +# Constant +SELECT 1=ROW(1,1); +ERROR HY000: Illegal parameter data types int and row for operation '=' +SELECT -1=ROW(1,1); +ERROR HY000: Illegal parameter data types int and row for operation '=' +SELECT 9223372036854775807=ROW(1,1); +ERROR HY000: Illegal parameter data types bigint and row for operation '=' +SELECT 9223372036854775808=ROW(1,1); +ERROR HY000: Illegal parameter data types bigint unsigned and row for operation '=' +SELECT 18446744073709551615=ROW(1,1); +ERROR HY000: Illegal parameter data types bigint unsigned and row for operation '=' +# COALESCE +CREATE TABLE t1 (a TINYINT UNSIGNED, b TINYINT); +SELECT COALESCE(a,a)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types tiny unsigned and row for operation '=' +SELECT COALESCE(b,b)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types tinyint and row for operation '=' +DROP TABLE t1; +CREATE TABLE t1 (a SMALLINT UNSIGNED, b SMALLINT); +SELECT COALESCE(a,a)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types smallint unsigned and row for operation '=' +SELECT COALESCE(b,b)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types smallint and row for operation '=' +DROP TABLE t1; +CREATE TABLE t1 (a MEDIUMINT UNSIGNED, b MEDIUMINT); +SELECT COALESCE(a,a)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types mediumint unsigned and row for operation '=' +SELECT COALESCE(b,b)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types mediumint and row for operation '=' +DROP TABLE t1; +CREATE TABLE t1 (a INT UNSIGNED, b INT); +SELECT COALESCE(a,a)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types int unsigned and row for operation '=' +SELECT COALESCE(b,b)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types int and row for operation '=' +DROP TABLE t1; +CREATE TABLE t1 (a BIGINT UNSIGNED, b BIGINT); +SELECT COALESCE(a,a)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types bigint unsigned and row for operation '=' +SELECT COALESCE(b,b)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types bigint and row for operation '=' +DROP TABLE t1; +# COALESCE for different types integer types, with the UNSIGNED flag +CREATE TABLE t1 (a1 TINYINT UNSIGNED, a2 SMALLINT UNSIGNED); +SELECT COALESCE(a1,a2)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types smallint unsigned and row for operation '=' +DROP TABLE t1; +CREATE TABLE t1 (a1 SMALLINT UNSIGNED, a2 MEDIUMINT UNSIGNED); +SELECT COALESCE(a1,a2)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types mediumint unsigned and row for operation '=' +DROP TABLE t1; +CREATE TABLE t1 (a1 MEDIUMINT UNSIGNED, a2 INT UNSIGNED); +SELECT COALESCE(a1,a2)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types int unsigned and row for operation '=' +DROP TABLE t1; +CREATE TABLE t1 (a1 INT UNSIGNED, a2 BIGINT UNSIGNED); +SELECT COALESCE(a1,a2)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types bigint unsigned and row for operation '=' +DROP TABLE t1; +# COALESCE for different types integer types, without the UNSIGNED flag +CREATE TABLE t1 (a1 TINYINT, a2 SMALLINT); +SELECT COALESCE(a1,a2)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types smallint and row for operation '=' +DROP TABLE t1; +CREATE TABLE t1 (a1 SMALLINT, a2 MEDIUMINT); +SELECT COALESCE(a1,a2)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types mediumint and row for operation '=' +DROP TABLE t1; +CREATE TABLE t1 (a1 MEDIUMINT, a2 INT); +SELECT COALESCE(a1,a2)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types int and row for operation '=' +DROP TABLE t1; +CREATE TABLE t1 (a1 INT, a2 BIGINT); +SELECT COALESCE(a1,a2)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types bigint and row for operation '=' +DROP TABLE t1; +# Operator + +CREATE TABLE t1 (a TINYINT UNSIGNED, b TINYINT); +SELECT (a+a)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types int unsigned and row for operation '=' +SELECT (b+b)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types int and row for operation '=' +DROP TABLE t1; +CREATE TABLE t1 (a SMALLINT UNSIGNED, b SMALLINT); +SELECT (a+a)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types int unsigned and row for operation '=' +SELECT (b+b)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types int and row for operation '=' +DROP TABLE t1; +CREATE TABLE t1 (a MEDIUMINT UNSIGNED, b MEDIUMINT); +SELECT (a+a)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types int unsigned and row for operation '=' +SELECT (b+b)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types bigint and row for operation '=' +DROP TABLE t1; +CREATE TABLE t1 (a INT UNSIGNED, b INT); +SELECT (a+a)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types bigint unsigned and row for operation '=' +SELECT (b+b)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types bigint and row for operation '=' +DROP TABLE t1; +CREATE TABLE t1 (a BIGINT UNSIGNED, b BIGINT); +SELECT (a+a)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types bigint unsigned and row for operation '=' +SELECT (b+b)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types bigint and row for operation '=' +DROP TABLE t1; +# Opetator + for different types integer types, with the UNSIGNED flag +CREATE TABLE t1 (a1 TINYINT UNSIGNED, a2 SMALLINT UNSIGNED); +SELECT (a1+a2)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types int unsigned and row for operation '=' +DROP TABLE t1; +CREATE TABLE t1 (a1 SMALLINT UNSIGNED, a2 MEDIUMINT UNSIGNED); +SELECT (a1+a2)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types int unsigned and row for operation '=' +DROP TABLE t1; +CREATE TABLE t1 (a1 MEDIUMINT UNSIGNED, a2 INT UNSIGNED); +SELECT (a1+a2)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types bigint unsigned and row for operation '=' +DROP TABLE t1; +CREATE TABLE t1 (a1 INT UNSIGNED, a2 BIGINT UNSIGNED); +SELECT (a1+a2)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types bigint unsigned and row for operation '=' +DROP TABLE t1; +# Operator + for different types integer types, without the UNSIGNED flag +CREATE TABLE t1 (a1 TINYINT, a2 SMALLINT); +SELECT (a1+a2)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types int and row for operation '=' +DROP TABLE t1; +CREATE TABLE t1 (a1 SMALLINT, a2 MEDIUMINT); +SELECT (a1+a2)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types bigint and row for operation '=' +DROP TABLE t1; +CREATE TABLE t1 (a1 MEDIUMINT, a2 INT); +SELECT (a1+a2)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types bigint and row for operation '=' +DROP TABLE t1; +CREATE TABLE t1 (a1 INT, a2 BIGINT); +SELECT (a1+a2)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types bigint and row for operation '=' +DROP TABLE t1; +# SUM +CREATE TABLE t1 (a TINYINT UNSIGNED, b TINYINT); +SELECT MAX(a)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types tiny unsigned and row for operation '=' +SELECT MAX(b)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types tinyint and row for operation '=' +DROP TABLE t1; +CREATE TABLE t1 (a SMALLINT UNSIGNED, b SMALLINT); +SELECT MAX(a)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types smallint unsigned and row for operation '=' +SELECT MAX(b)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types smallint and row for operation '=' +DROP TABLE t1; +CREATE TABLE t1 (a MEDIUMINT UNSIGNED, b MEDIUMINT); +SELECT MAX(a)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types mediumint unsigned and row for operation '=' +SELECT MAX(b)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types mediumint and row for operation '=' +DROP TABLE t1; +CREATE TABLE t1 (a INT UNSIGNED, b INT); +SELECT MAX(a)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types int unsigned and row for operation '=' +SELECT MAX(b)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types int and row for operation '=' +DROP TABLE t1; +CREATE TABLE t1 (a BIGINT UNSIGNED, b BIGINT); +SELECT MAX(a)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types bigint unsigned and row for operation '=' +SELECT MAX(b)=ROW(1,1) FROM t1; +ERROR HY000: Illegal parameter data types bigint and row for operation '=' +DROP TABLE t1; +# HEX hybrid +SELECT 0x20+ROW(1,1); +ERROR HY000: Illegal parameter data types bigint unsigned and row for operation '+' +# System variables +SELECT @@max_allowed_packet=ROW(1,1); +ERROR HY000: Illegal parameter data types bigint unsigned and row for operation '=' +# +# End of 10.5 tests +# diff --git a/mysql-test/main/func_hybrid_type.test b/mysql-test/main/func_hybrid_type.test index 31a096c3305..cf41d92b01f 100644 --- a/mysql-test/main/func_hybrid_type.test +++ b/mysql-test/main/func_hybrid_type.test @@ -825,3 +825,256 @@ SELECT 0 + LEAST(TIME'-10:00:00',TIME'10:00:00') AS c; --echo # --echo # End of 10.4 tests --echo # + + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-20332 Wrong UNSIGNED metadata flag returned for COALESCE(unsigned_field,timestamp_field) +--echo # + +CREATE TABLE t1 (a INT UNSIGNED, b TIMESTAMP); +--disable_ps_protocol +--enable_metadata +SELECT COALESCE(a,b) FROM t1; +--disable_metadata +--enable_ps_protocol +DROP TABLE t1; + +--echo # +--echo # MDEV-20353 Add separate type handlers for unsigned integer data types +--echo # + +--echo # Constant + +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT 1=ROW(1,1); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT -1=ROW(1,1); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT 9223372036854775807=ROW(1,1); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT 9223372036854775808=ROW(1,1); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT 18446744073709551615=ROW(1,1); + + +--echo # COALESCE + +CREATE TABLE t1 (a TINYINT UNSIGNED, b TINYINT); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT COALESCE(a,a)=ROW(1,1) FROM t1; +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT COALESCE(b,b)=ROW(1,1) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a SMALLINT UNSIGNED, b SMALLINT); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT COALESCE(a,a)=ROW(1,1) FROM t1; +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT COALESCE(b,b)=ROW(1,1) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a MEDIUMINT UNSIGNED, b MEDIUMINT); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT COALESCE(a,a)=ROW(1,1) FROM t1; +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT COALESCE(b,b)=ROW(1,1) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a INT UNSIGNED, b INT); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT COALESCE(a,a)=ROW(1,1) FROM t1; +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT COALESCE(b,b)=ROW(1,1) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a BIGINT UNSIGNED, b BIGINT); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT COALESCE(a,a)=ROW(1,1) FROM t1; +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT COALESCE(b,b)=ROW(1,1) FROM t1; +DROP TABLE t1; + + +--echo # COALESCE for different types integer types, with the UNSIGNED flag + +CREATE TABLE t1 (a1 TINYINT UNSIGNED, a2 SMALLINT UNSIGNED); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT COALESCE(a1,a2)=ROW(1,1) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a1 SMALLINT UNSIGNED, a2 MEDIUMINT UNSIGNED); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT COALESCE(a1,a2)=ROW(1,1) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a1 MEDIUMINT UNSIGNED, a2 INT UNSIGNED); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT COALESCE(a1,a2)=ROW(1,1) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a1 INT UNSIGNED, a2 BIGINT UNSIGNED); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT COALESCE(a1,a2)=ROW(1,1) FROM t1; +DROP TABLE t1; + + +--echo # COALESCE for different types integer types, without the UNSIGNED flag + +CREATE TABLE t1 (a1 TINYINT, a2 SMALLINT); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT COALESCE(a1,a2)=ROW(1,1) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a1 SMALLINT, a2 MEDIUMINT); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT COALESCE(a1,a2)=ROW(1,1) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a1 MEDIUMINT, a2 INT); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT COALESCE(a1,a2)=ROW(1,1) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a1 INT, a2 BIGINT); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT COALESCE(a1,a2)=ROW(1,1) FROM t1; +DROP TABLE t1; + + +--echo # Operator + + +CREATE TABLE t1 (a TINYINT UNSIGNED, b TINYINT); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT (a+a)=ROW(1,1) FROM t1; +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT (b+b)=ROW(1,1) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a SMALLINT UNSIGNED, b SMALLINT); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT (a+a)=ROW(1,1) FROM t1; +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT (b+b)=ROW(1,1) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a MEDIUMINT UNSIGNED, b MEDIUMINT); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT (a+a)=ROW(1,1) FROM t1; +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT (b+b)=ROW(1,1) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a INT UNSIGNED, b INT); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT (a+a)=ROW(1,1) FROM t1; +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT (b+b)=ROW(1,1) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a BIGINT UNSIGNED, b BIGINT); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT (a+a)=ROW(1,1) FROM t1; +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT (b+b)=ROW(1,1) FROM t1; +DROP TABLE t1; + + +--echo # Opetator + for different types integer types, with the UNSIGNED flag + +CREATE TABLE t1 (a1 TINYINT UNSIGNED, a2 SMALLINT UNSIGNED); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT (a1+a2)=ROW(1,1) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a1 SMALLINT UNSIGNED, a2 MEDIUMINT UNSIGNED); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT (a1+a2)=ROW(1,1) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a1 MEDIUMINT UNSIGNED, a2 INT UNSIGNED); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT (a1+a2)=ROW(1,1) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a1 INT UNSIGNED, a2 BIGINT UNSIGNED); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT (a1+a2)=ROW(1,1) FROM t1; +DROP TABLE t1; + + +--echo # Operator + for different types integer types, without the UNSIGNED flag + +CREATE TABLE t1 (a1 TINYINT, a2 SMALLINT); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT (a1+a2)=ROW(1,1) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a1 SMALLINT, a2 MEDIUMINT); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT (a1+a2)=ROW(1,1) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a1 MEDIUMINT, a2 INT); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT (a1+a2)=ROW(1,1) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a1 INT, a2 BIGINT); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT (a1+a2)=ROW(1,1) FROM t1; +DROP TABLE t1; + +--echo # SUM + +CREATE TABLE t1 (a TINYINT UNSIGNED, b TINYINT); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT MAX(a)=ROW(1,1) FROM t1; +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT MAX(b)=ROW(1,1) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a SMALLINT UNSIGNED, b SMALLINT); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT MAX(a)=ROW(1,1) FROM t1; +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT MAX(b)=ROW(1,1) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a MEDIUMINT UNSIGNED, b MEDIUMINT); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT MAX(a)=ROW(1,1) FROM t1; +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT MAX(b)=ROW(1,1) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a INT UNSIGNED, b INT); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT MAX(a)=ROW(1,1) FROM t1; +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT MAX(b)=ROW(1,1) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a BIGINT UNSIGNED, b BIGINT); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT MAX(a)=ROW(1,1) FROM t1; +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT MAX(b)=ROW(1,1) FROM t1; +DROP TABLE t1; + +--echo # HEX hybrid + +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT 0x20+ROW(1,1); + +--echo # System variables + +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT @@max_allowed_packet=ROW(1,1); + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/func_in.result b/mysql-test/main/func_in.result index 9a3c1dba045..51074650d29 100644 --- a/mysql-test/main/func_in.result +++ b/mysql-test/main/func_in.result @@ -522,7 +522,7 @@ a b explain select f1 from t1 where f1 in ('a','b'); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index t1f1_idx t1f1_idx 2 NULL 3 Using where; Using index +1 SIMPLE t1 range t1f1_idx t1f1_idx 2 NULL 2 Using where; Using index select f1 from t1 where f1 in (2,1); f1 1 @@ -553,7 +553,7 @@ Warning 1292 Truncated incorrect DOUBLE value: 'a' Warning 1292 Truncated incorrect DOUBLE value: 'b' explain select f2 from t2 where f2 in ('a','b'); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 index t2f2 t2f2 5 NULL 3 Using where; Using index +1 SIMPLE t2 range t2f2 t2f2 5 NULL 1 Using where; Using index Warnings: Warning 1292 Truncated incorrect DOUBLE value: 'a' Warning 1292 Truncated incorrect DOUBLE value: 'b' diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result index 1e0c542d02f..74d301abf7a 100644 --- a/mysql-test/main/func_json.result +++ b/mysql-test/main/func_json.result @@ -1075,5 +1075,318 @@ SELECT * FROM t1 WHERE CASE WHEN JSON_OBJECT('x', (SELECT MAX(a=2) FROM t1))='{" a DROP TABLE t1; # +# MDEV-16620 JSON_ARRAYAGG +# +# +# Integer aggregation +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1, 1),(2, 1), (1, 1),(2, 1), (3, 2),(2, 2),(2, 2),(2, 2); +SELECT JSON_VALID(JSON_ARRAYAGG(a)) FROM t1; +JSON_VALID(JSON_ARRAYAGG(a)) +1 +SELECT JSON_ARRAYAGG(a), JSON_ARRAYAGG(b) FROM t1; +JSON_ARRAYAGG(a) JSON_ARRAYAGG(b) +[1,2,1,2,3,2,2,2] [1,1,1,1,2,2,2,2] +SELECT JSON_ARRAYAGG(a), JSON_ARRAYAGG(b) FROM t1 GROUP BY b; +JSON_ARRAYAGG(a) JSON_ARRAYAGG(b) +[1,2,1,2] [1,1,1,1] +[3,2,2,2] [2,2,2,2] +DROP TABLE t1; +# +# Real aggregation +# +CREATE TABLE t1 (a FLOAT, b DOUBLE, c DECIMAL(10, 2)); +INSERT INTO t1 VALUES (1.0, 2.0, 3.0),(1.0, 3.0, 9.0),(1.0, 4.0, 16.0),(1.0, 5.0, 25.0); +SELECT JSON_VALID(JSON_ARRAYAGG(a)) FROM t1; +JSON_VALID(JSON_ARRAYAGG(a)) +1 +SELECT JSON_ARRAYAGG(a), JSON_ARRAYAGG(b), JSON_ARRAYAGG(c) FROM t1; +JSON_ARRAYAGG(a) JSON_ARRAYAGG(b) JSON_ARRAYAGG(c) +[1,1,1,1] [2,3,4,5] [3.00,9.00,16.00,25.00] +DROP TABLE t1; +# +# Boolean aggregation +# +CREATE TABLE t1 (a BOOLEAN, b BOOLEAN); +INSERT INTO t1 VALUES (TRUE, TRUE), (TRUE, FALSE), (FALSE, TRUE), (FALSE, FALSE); +SELECT JSON_VALID(JSON_ARRAYAGG(a)) FROM t1; +JSON_VALID(JSON_ARRAYAGG(a)) +1 +SELECT JSON_ARRAYAGG(a), JSON_ARRAYAGG(b) FROM t1; +JSON_ARRAYAGG(a) JSON_ARRAYAGG(b) +[1,1,0,0] [1,0,1,0] +SELECT JSON_ARRAYAGG(a), JSON_ARRAYAGG(b) FROM t1 GROUP BY b; +JSON_ARRAYAGG(a) JSON_ARRAYAGG(b) +[1,0] [0,0] +[1,0] [1,1] +SELECT JSON_ARRAYAGG(TRUE), JSON_ARRAYAGG(FALSE) FROM t1; +JSON_ARRAYAGG(TRUE) JSON_ARRAYAGG(FALSE) +[true,true,true,true] [false,false,false,false] +DROP TABLE t1; +# +# Aggregation of strings with quoted +# +CREATE TABLE t1 (a VARCHAR(80)); +INSERT INTO t1 VALUES +('"double_quoted_value"'), ("'single_quoted_value'"), +('"double_quoted_value"'), ("'single_quoted_value'"); +SELECT JSON_VALID(JSON_ARRAYAGG(a)) FROM t1; +JSON_VALID(JSON_ARRAYAGG(a)) +1 +SELECT JSON_ARRAYAGG(a) FROM t1; +JSON_ARRAYAGG(a) +["\"double_quoted_value\"","'single_quoted_value'","\"double_quoted_value\"","'single_quoted_value'"] +DROP TABLE t1; +# +# Strings and NULLs +# +CREATE TABLE t1 (a INT, b VARCHAR(80)); +INSERT INTO t1 VALUES +(1, "Hello"),(1, "World"), (2, "This"),(2, "Will"), (2, "Work"),(2, "!"), (3, NULL), +(1, "Hello"),(1, "World"), (2, "This"),(2, "Will"), (2, "Work"),(2, "!"), (3, NULL); +SELECT JSON_VALID(JSON_ARRAYAGG(b)) FROM t1; +JSON_VALID(JSON_ARRAYAGG(b)) +1 +SELECT JSON_ARRAYAGG(a), JSON_ARRAYAGG(b) FROM t1; +JSON_ARRAYAGG(a) JSON_ARRAYAGG(b) +[1,1,2,2,2,2,3,1,1,2,2,2,2,3] ["Hello","World","This","Will","Work","!",null,"Hello","World","This","Will","Work","!",null] +SELECT JSON_ARRAYAGG(a), JSON_ARRAYAGG(b) FROM t1 GROUP BY a; +JSON_ARRAYAGG(a) JSON_ARRAYAGG(b) +[1,1,1,1] ["Hello","World","Hello","World"] +[2,2,2,2,2,2,2,2] ["!","Work","Will","This","Will","This","!","Work"] +[3,3] [null,null] +# +# DISTINCT and LIMIT +# +SELECT JSON_ARRAYAGG(b LIMIT 1) FROM t1; +JSON_ARRAYAGG(b LIMIT 1) +["Hello"] +SELECT JSON_ARRAYAGG(b LIMIT 2) FROM t1; +JSON_ARRAYAGG(b LIMIT 2) +["Hello","World"] +SELECT JSON_ARRAYAGG(b LIMIT 1) FROM t1 GROUP BY b; +JSON_ARRAYAGG(b LIMIT 1) +[null] +["!"] +["Hello"] +["This"] +["Will"] +["Work"] +["World"] +SELECT JSON_ARRAYAGG(b LIMIT 2) FROM t1 GROUP BY a; +JSON_ARRAYAGG(b LIMIT 2) +["Hello","World"] +["!","Work"] +[null,null] +SELECT JSON_ARRAYAGG(DISTINCT a) FROM t1; +JSON_ARRAYAGG(DISTINCT a) +[1,2,3] +SELECT JSON_ARRAYAGG(DISTINCT b) FROM t1; +JSON_ARRAYAGG(DISTINCT b) +[null,"!","Hello","This","Will","Work","World"] +SELECT JSON_ARRAYAGG(DISTINCT a LIMIT 2) FROM t1; +JSON_ARRAYAGG(DISTINCT a LIMIT 2) +[1,2] +SELECT JSON_ARRAYAGG(DISTINCT b LIMIT 2) FROM t1; +JSON_ARRAYAGG(DISTINCT b LIMIT 2) +[null,"!"] +# +# JSON aggregation +# +SELECT JSON_VALID(JSON_ARRAYAGG(JSON_ARRAY(a, b))) FROM t1; +JSON_VALID(JSON_ARRAYAGG(JSON_ARRAY(a, b))) +1 +SELECT JSON_ARRAYAGG(JSON_ARRAY(a, b)) FROM t1; +JSON_ARRAYAGG(JSON_ARRAY(a, b)) +[[1, "Hello"],[1, "World"],[2, "This"],[2, "Will"],[2, "Work"],[2, "!"],[3, null],[1, "Hello"],[1, "World"],[2, "This"],[2, "Will"],[2, "Work"],[2, "!"],[3, null]] +SELECT JSON_ARRAYAGG(JSON_ARRAY(a, b)) FROM t1 GROUP BY a; +JSON_ARRAYAGG(JSON_ARRAY(a, b)) +[[1, "Hello"],[1, "World"],[1, "Hello"],[1, "World"]] +[[2, "!"],[2, "Work"],[2, "Will"],[2, "This"],[2, "Will"],[2, "This"],[2, "!"],[2, "Work"]] +[[3, null],[3, null]] +SELECT JSON_VALID(JSON_ARRAYAGG(JSON_OBJECT('a', a, 'b', b))) FROM t1; +JSON_VALID(JSON_ARRAYAGG(JSON_OBJECT('a', a, 'b', b))) +1 +SELECT JSON_ARRAYAGG(JSON_OBJECT('a', a, 'b', b)) FROM t1; +JSON_ARRAYAGG(JSON_OBJECT('a', a, 'b', b)) +[{"a": 1, "b": "Hello"},{"a": 1, "b": "World"},{"a": 2, "b": "This"},{"a": 2, "b": "Will"},{"a": 2, "b": "Work"},{"a": 2, "b": "!"},{"a": 3, "b": null},{"a": 1, "b": "Hello"},{"a": 1, "b": "World"},{"a": 2, "b": "This"},{"a": 2, "b": "Will"},{"a": 2, "b": "Work"},{"a": 2, "b": "!"},{"a": 3, "b": null}] +SELECT JSON_ARRAYAGG(JSON_OBJECT('a', a, 'b', b)) FROM t1 GROUP BY a; +JSON_ARRAYAGG(JSON_OBJECT('a', a, 'b', b)) +[{"a": 1, "b": "Hello"},{"a": 1, "b": "World"},{"a": 1, "b": "Hello"},{"a": 1, "b": "World"}] +[{"a": 2, "b": "!"},{"a": 2, "b": "Work"},{"a": 2, "b": "Will"},{"a": 2, "b": "This"},{"a": 2, "b": "Will"},{"a": 2, "b": "This"},{"a": 2, "b": "!"},{"a": 2, "b": "Work"}] +[{"a": 3, "b": null},{"a": 3, "b": null}] +# +# Error checks +# +SELECT JSON_ARRAYAGG(a, b) FROM t1; +ERROR 42000: Incorrect parameter count in the call to native function 'JSON_ARRAYAGG' +SELECT JSON_ARRAYAGG(JSON_ARRAYAGG(a, b)) FROM t1; +ERROR 42000: Incorrect parameter count in the call to native function 'JSON_ARRAYAGG' +SELECT JSON_ARRAYAGG(JSON_ARRAYAGG(a)) FROM t1; +ERROR HY000: Invalid use of group function +# +# MDEV-16620 JSON_OBJECTAGG +# +SELECT JSON_OBJECTAGG(a, b) FROM t1; +JSON_OBJECTAGG(a, b) +{"1":"Hello", "1":"World", "2":"This", "2":"Will", "2":"Work", "2":"!", "3":null, "1":"Hello", "1":"World", "2":"This", "2":"Will", "2":"Work", "2":"!", "3":null} +SELECT JSON_OBJECTAGG(a) FROM t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') FROM t1' at line 1 +DROP TABLE t1; +# # End of 10.4 tests # +# +# MDEV-16620 JSON_ARRAYAGG +# +CREATE TABLE t1 (a INT); +SELECT JSON_ARRAYAGG(a) FROM t1; +JSON_ARRAYAGG(a) +NULL +DROP TABLE t1; +# +# MDEV-21915 Server crashes in copy_fields,Item_func_group_concat::add +while using json_arrayagg() as a window function +# +select json_arrayagg(a) over () from (select 1 a) t; +ERROR 42000: This version of MariaDB doesn't yet support 'JSON_ARRAYAGG() aggregate as window function' +select json_objectagg(a, b) over () from (select 1 a, 2 b) t; +ERROR 42000: This version of MariaDB doesn't yet support 'JSON_OBJECTAGG() aggregate as window function' +SELECT JSON_ARRAYAGG(NULL) FROM (SELECT 1 AS t) AS A; +JSON_ARRAYAGG(NULL) +[null] +SELECT JSON_ARRAYAGG("null") FROM (SELECT 1 AS t) AS A; +JSON_ARRAYAGG("null") +["null"] +create view v as (select json_arrayagg(json_object("type", "permPeriod", "id", "asd")) as JSON_DATA); +select * from v; +JSON_DATA +[{"type": "permPeriod", "id": "asd"}] +drop view v; +select json_arrayagg(a order by a asc) from (select 1 a union select 2 a) t; +json_arrayagg(a order by a asc) +[1,2] +select json_object('x', json_arrayagg(json_object('a', 1))); +json_object('x', json_arrayagg(json_object('a', 1))) +{"x": [{"a": 1}]} +# +# MDEV-22011: DISTINCT with JSON_ARRAYAGG gives wrong results +# +CREATE TABLE t1(a INT, b INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +SELECT JSON_ARRAYAGG(a) FROM t1; +JSON_ARRAYAGG(a) +[1,2,3,1,2,3] +SELECT JSON_ARRAYAGG(DISTINCT a) FROM t1; +JSON_ARRAYAGG(DISTINCT a) +[1,2,3] +INSERT INTO t1 VALUES (NULL,NULL), (NULL,NULL); +SELECT JSON_ARRAYAGG(a) FROM t1; +JSON_ARRAYAGG(a) +[1,2,3,1,2,3,null,null] +SELECT JSON_ARRAYAGG(DISTINCT a) FROM t1; +JSON_ARRAYAGG(DISTINCT a) +[null,1,2,3] +DROP TABLE t1; +CREATE TABLE t1(a VARCHAR(10), b INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +SELECT JSON_ARRAYAGG(a) FROM t1; +JSON_ARRAYAGG(a) +["1","2","3","1","2","3"] +SELECT JSON_ARRAYAGG(DISTINCT a) FROM t1; +JSON_ARRAYAGG(DISTINCT a) +["1","2","3"] +INSERT INTO t1 VALUES (NULL,NULL), (NULL,NULL); +SELECT JSON_ARRAYAGG(a) FROM t1; +JSON_ARRAYAGG(a) +["1","2","3","1","2","3",null,null] +SELECT JSON_ARRAYAGG(DISTINCT a) FROM t1; +JSON_ARRAYAGG(DISTINCT a) +[null,"1","2","3"] +DROP TABLE t1; +# +# MDEV-22840: JSON_ARRAYAGG gives wrong results with NULL values and ORDER by clause +# +CREATE TABLE t1(a VARCHAR(255)); +INSERT INTO t1 VALUES ('red'),('blue'); +SELECT JSON_ARRAYAGG(a) FROM t1; +JSON_ARRAYAGG(a) +["red","blue"] +SELECT JSON_ARRAYAGG(a ORDER BY a DESC) FROM t1; +JSON_ARRAYAGG(a ORDER BY a DESC) +["red","blue"] +SELECT JSON_ARRAYAGG(a ORDER BY a ASC) FROM t1; +JSON_ARRAYAGG(a ORDER BY a ASC) +["blue","red"] +INSERT INTO t1 VALUES (NULL); +SELECT JSON_ARRAYAGG(a) FROM t1; +JSON_ARRAYAGG(a) +["red","blue",null] +SELECT JSON_ARRAYAGG(a ORDER BY a DESC) FROM t1; +JSON_ARRAYAGG(a ORDER BY a DESC) +["red","blue",null] +SELECT JSON_ARRAYAGG(a ORDER BY a ASC) FROM t1; +JSON_ARRAYAGG(a ORDER BY a ASC) +[null,"blue","red"] +DROP TABLE t1; +set group_concat_max_len=64; +create table t1 (a varchar(254)); +insert into t1 values (concat('x64-', repeat('a', 60))); +insert into t1 values (concat('x64-', repeat('b', 60))); +insert into t1 values (concat('x64-', repeat('c', 60))); +select json_arrayagg(a) from t1; +json_arrayagg(a) +["x64-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"] +Warnings: +Warning 1260 Row 1 was cut by JSON_ARRAYAGG() +drop table t1; +SET group_concat_max_len= default; +create table t1 (col1 json); +insert into t1 values('{"color":"red", "size":1}' ); +insert into t1 values('{"color":"blue", "size":2}' ); +select JSON_ARRAYAGG(col1) from t1; +JSON_ARRAYAGG(col1) +[{"color":"red", "size":1},{"color":"blue", "size":2}] +drop table t1; +# +# MDEV-23029: JSON_OBJECTAGG returns NULL when used together with GROUP BY +# +CREATE TABLE t1 (e INT, a VARCHAR(255), v VARCHAR(255)); +INSERT INTO t1 VALUES (0, 'a1', '1') , (0, 'a2', '2') , (1, 'b1', '3'); +EXPLAIN SELECT B.e, JSON_OBJECTAGG(B.a, B.v) FROM t1 A, t1 B GROUP BY B.e, B.a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE A ALL NULL NULL NULL NULL 3 Using temporary; Using filesort +1 SIMPLE B ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) +SELECT B.e, JSON_OBJECTAGG(B.a, B.v) FROM t1 A, t1 B GROUP BY B.e, B.a; +e JSON_OBJECTAGG(B.a, B.v) +0 {"a1":"1", "a1":"1", "a1":"1"} +0 {"a2":"2", "a2":"2", "a2":"2"} +1 {"b1":"3", "b1":"3", "b1":"3"} +CREATE VIEW v AS SELECT JSON_OBJECTAGG(a, e) FROM t1; +SELECT * FROM v; +JSON_OBJECTAGG(a, e) +{"a1":0, "a2":0, "b1":1} +DROP VIEW v; +DROP TABLE t1; +# +# MDEV-23004 When using GROUP BY with JSON_ARRAYAGG with joint table, the square brackets are not included. +# +CREATE TABLE t1(id int primary key, name varchar(50)); +CREATE TABLE t2(id int, owner_id int); +INSERT INTO t1 VALUES (1, "name1"), (2, "name2"), (3, "name3"); +INSERT INTO t2 VALUES (1, 1), (2, 1), (3, 2), (4, 3); +SELECT t1.id, JSON_ARRAYAGG(JSON_OBJECT('id',t2.id) ORDER BY t2.id) as materials +from t1 LEFT JOIN t2 on t1.id = t2.owner_id +GROUP BY t1.id ORDER BY id; +id materials +1 ["{\"id\": 1}","{\"id\": 2}"] +2 ["{\"id\": 3}"] +3 ["{\"id\": 4}"] +DROP TABLE t1; +DROP TABLE t2; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index bbee8c28a8b..668675551f6 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -648,6 +648,238 @@ SELECT * FROM t1 WHERE CASE WHEN JSON_OBJECT('x', (SELECT MAX(a=2) FROM t1))='{" DROP TABLE t1; +-- echo # +-- echo # MDEV-16620 JSON_ARRAYAGG +-- echo # + +-- echo # +-- echo # Integer aggregation +-- echo # +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1, 1),(2, 1), (1, 1),(2, 1), (3, 2),(2, 2),(2, 2),(2, 2); +SELECT JSON_VALID(JSON_ARRAYAGG(a)) FROM t1; +SELECT JSON_ARRAYAGG(a), JSON_ARRAYAGG(b) FROM t1; +SELECT JSON_ARRAYAGG(a), JSON_ARRAYAGG(b) FROM t1 GROUP BY b; +DROP TABLE t1; + +-- echo # +-- echo # Real aggregation +-- echo # +CREATE TABLE t1 (a FLOAT, b DOUBLE, c DECIMAL(10, 2)); +INSERT INTO t1 VALUES (1.0, 2.0, 3.0),(1.0, 3.0, 9.0),(1.0, 4.0, 16.0),(1.0, 5.0, 25.0); +SELECT JSON_VALID(JSON_ARRAYAGG(a)) FROM t1; +SELECT JSON_ARRAYAGG(a), JSON_ARRAYAGG(b), JSON_ARRAYAGG(c) FROM t1; +DROP TABLE t1; + +-- echo # +-- echo # Boolean aggregation +-- echo # +CREATE TABLE t1 (a BOOLEAN, b BOOLEAN); +INSERT INTO t1 VALUES (TRUE, TRUE), (TRUE, FALSE), (FALSE, TRUE), (FALSE, FALSE); +SELECT JSON_VALID(JSON_ARRAYAGG(a)) FROM t1; +SELECT JSON_ARRAYAGG(a), JSON_ARRAYAGG(b) FROM t1; +SELECT JSON_ARRAYAGG(a), JSON_ARRAYAGG(b) FROM t1 GROUP BY b; +SELECT JSON_ARRAYAGG(TRUE), JSON_ARRAYAGG(FALSE) FROM t1; +DROP TABLE t1; + +-- echo # +-- echo # Aggregation of strings with quoted +-- echo # +CREATE TABLE t1 (a VARCHAR(80)); +INSERT INTO t1 VALUES + ('"double_quoted_value"'), ("'single_quoted_value'"), + ('"double_quoted_value"'), ("'single_quoted_value'"); +SELECT JSON_VALID(JSON_ARRAYAGG(a)) FROM t1; +SELECT JSON_ARRAYAGG(a) FROM t1; +DROP TABLE t1; + +-- echo # +-- echo # Strings and NULLs +-- echo # +CREATE TABLE t1 (a INT, b VARCHAR(80)); +INSERT INTO t1 VALUES + (1, "Hello"),(1, "World"), (2, "This"),(2, "Will"), (2, "Work"),(2, "!"), (3, NULL), + (1, "Hello"),(1, "World"), (2, "This"),(2, "Will"), (2, "Work"),(2, "!"), (3, NULL); +SELECT JSON_VALID(JSON_ARRAYAGG(b)) FROM t1; +SELECT JSON_ARRAYAGG(a), JSON_ARRAYAGG(b) FROM t1; +SELECT JSON_ARRAYAGG(a), JSON_ARRAYAGG(b) FROM t1 GROUP BY a; + +-- echo # +-- echo # DISTINCT and LIMIT +-- echo # +SELECT JSON_ARRAYAGG(b LIMIT 1) FROM t1; +SELECT JSON_ARRAYAGG(b LIMIT 2) FROM t1; +SELECT JSON_ARRAYAGG(b LIMIT 1) FROM t1 GROUP BY b; +SELECT JSON_ARRAYAGG(b LIMIT 2) FROM t1 GROUP BY a; +SELECT JSON_ARRAYAGG(DISTINCT a) FROM t1; +SELECT JSON_ARRAYAGG(DISTINCT b) FROM t1; +SELECT JSON_ARRAYAGG(DISTINCT a LIMIT 2) FROM t1; +SELECT JSON_ARRAYAGG(DISTINCT b LIMIT 2) FROM t1; + +-- echo # +-- echo # JSON aggregation +-- echo # +SELECT JSON_VALID(JSON_ARRAYAGG(JSON_ARRAY(a, b))) FROM t1; +SELECT JSON_ARRAYAGG(JSON_ARRAY(a, b)) FROM t1; +SELECT JSON_ARRAYAGG(JSON_ARRAY(a, b)) FROM t1 GROUP BY a; + +SELECT JSON_VALID(JSON_ARRAYAGG(JSON_OBJECT('a', a, 'b', b))) FROM t1; +SELECT JSON_ARRAYAGG(JSON_OBJECT('a', a, 'b', b)) FROM t1; +SELECT JSON_ARRAYAGG(JSON_OBJECT('a', a, 'b', b)) FROM t1 GROUP BY a; + +-- echo # +-- echo # Error checks +-- echo # +--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +SELECT JSON_ARRAYAGG(a, b) FROM t1; + +--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +SELECT JSON_ARRAYAGG(JSON_ARRAYAGG(a, b)) FROM t1; + +--error ER_INVALID_GROUP_FUNC_USE +SELECT JSON_ARRAYAGG(JSON_ARRAYAGG(a)) FROM t1; + +-- echo # +-- echo # MDEV-16620 JSON_OBJECTAGG +-- echo # + +SELECT JSON_OBJECTAGG(a, b) FROM t1; +--error ER_PARSE_ERROR +SELECT JSON_OBJECTAGG(a) FROM t1; + +DROP TABLE t1; + --echo # --echo # End of 10.4 tests --echo # + +-- echo # +-- echo # MDEV-16620 JSON_ARRAYAGG +-- echo # + +CREATE TABLE t1 (a INT); +SELECT JSON_ARRAYAGG(a) FROM t1; +DROP TABLE t1; + +-- echo # +-- echo # MDEV-21915 Server crashes in copy_fields,Item_func_group_concat::add +-- echo while using json_arrayagg() as a window function +-- echo # + +--error ER_NOT_SUPPORTED_YET +select json_arrayagg(a) over () from (select 1 a) t; + +--error ER_NOT_SUPPORTED_YET +select json_objectagg(a, b) over () from (select 1 a, 2 b) t; + +SELECT JSON_ARRAYAGG(NULL) FROM (SELECT 1 AS t) AS A; +SELECT JSON_ARRAYAGG("null") FROM (SELECT 1 AS t) AS A; + +create view v as (select json_arrayagg(json_object("type", "permPeriod", "id", "asd")) as JSON_DATA); +select * from v; +drop view v; + +select json_arrayagg(a order by a asc) from (select 1 a union select 2 a) t; + +select json_object('x', json_arrayagg(json_object('a', 1))); + +--echo # +--echo # MDEV-22011: DISTINCT with JSON_ARRAYAGG gives wrong results +--echo # + +CREATE TABLE t1(a INT, b INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); + +SELECT JSON_ARRAYAGG(a) FROM t1; +SELECT JSON_ARRAYAGG(DISTINCT a) FROM t1; + +INSERT INTO t1 VALUES (NULL,NULL), (NULL,NULL); + +SELECT JSON_ARRAYAGG(a) FROM t1; +SELECT JSON_ARRAYAGG(DISTINCT a) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1(a VARCHAR(10), b INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); + +SELECT JSON_ARRAYAGG(a) FROM t1; +SELECT JSON_ARRAYAGG(DISTINCT a) FROM t1; + +INSERT INTO t1 VALUES (NULL,NULL), (NULL,NULL); + +SELECT JSON_ARRAYAGG(a) FROM t1; +SELECT JSON_ARRAYAGG(DISTINCT a) FROM t1; + +DROP TABLE t1; + +--echo # +--echo # MDEV-22840: JSON_ARRAYAGG gives wrong results with NULL values and ORDER by clause +--echo # + +CREATE TABLE t1(a VARCHAR(255)); +INSERT INTO t1 VALUES ('red'),('blue'); + +SELECT JSON_ARRAYAGG(a) FROM t1; +SELECT JSON_ARRAYAGG(a ORDER BY a DESC) FROM t1; +SELECT JSON_ARRAYAGG(a ORDER BY a ASC) FROM t1; + +INSERT INTO t1 VALUES (NULL); + +SELECT JSON_ARRAYAGG(a) FROM t1; +SELECT JSON_ARRAYAGG(a ORDER BY a DESC) FROM t1; +SELECT JSON_ARRAYAGG(a ORDER BY a ASC) FROM t1; +DROP TABLE t1; + +set group_concat_max_len=64; +create table t1 (a varchar(254)); +insert into t1 values (concat('x64-', repeat('a', 60))); +insert into t1 values (concat('x64-', repeat('b', 60))); insert into t1 values (concat('x64-', repeat('c', 60))); +select json_arrayagg(a) from t1; +drop table t1; +SET group_concat_max_len= default; + +create table t1 (col1 json); +insert into t1 values('{"color":"red", "size":1}' ); +insert into t1 values('{"color":"blue", "size":2}' ); +select JSON_ARRAYAGG(col1) from t1; +drop table t1; + +--echo # +--echo # MDEV-23029: JSON_OBJECTAGG returns NULL when used together with GROUP BY +--echo # + +CREATE TABLE t1 (e INT, a VARCHAR(255), v VARCHAR(255)); +INSERT INTO t1 VALUES (0, 'a1', '1') , (0, 'a2', '2') , (1, 'b1', '3'); + +EXPLAIN SELECT B.e, JSON_OBJECTAGG(B.a, B.v) FROM t1 A, t1 B GROUP BY B.e, B.a; +SELECT B.e, JSON_OBJECTAGG(B.a, B.v) FROM t1 A, t1 B GROUP BY B.e, B.a; + +CREATE VIEW v AS SELECT JSON_OBJECTAGG(a, e) FROM t1; +SELECT * FROM v; + +DROP VIEW v; +DROP TABLE t1; + +--echo # +--echo # MDEV-23004 When using GROUP BY with JSON_ARRAYAGG with joint table, the square brackets are not included. +--echo # + +CREATE TABLE t1(id int primary key, name varchar(50)); +CREATE TABLE t2(id int, owner_id int); + +INSERT INTO t1 VALUES (1, "name1"), (2, "name2"), (3, "name3"); +INSERT INTO t2 VALUES (1, 1), (2, 1), (3, 2), (4, 3); + +SELECT t1.id, JSON_ARRAYAGG(JSON_OBJECT('id',t2.id) ORDER BY t2.id) as materials + from t1 LEFT JOIN t2 on t1.id = t2.owner_id + GROUP BY t1.id ORDER BY id; + +DROP TABLE t1; +DROP TABLE t2; + +--echo # +--echo # End of 10.5 tests +--echo # + diff --git a/mysql-test/main/func_like.result b/mysql-test/main/func_like.result index fc306c42067..200cb20c4de 100644 --- a/mysql-test/main/func_like.result +++ b/mysql-test/main/func_like.result @@ -3,12 +3,12 @@ create table t1 (a varchar(10), key(a)); insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test"); explain extended select * from t1 where a like 'abc%'; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 index a a 13 NULL 5 40.00 Using where; Using index +1 SIMPLE t1 range a a 13 NULL 2 100.00 Using where; Using index Warnings: Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` like 'abc%' explain extended select * from t1 where a like concat('abc','%'); id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 index a a 13 NULL 5 40.00 Using where; Using index +1 SIMPLE t1 range a a 13 NULL 2 100.00 Using where; Using index Warnings: Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` like <cache>(concat('abc','%')) select * from t1 where a like "abc%"; diff --git a/mysql-test/main/func_math.result b/mysql-test/main/func_math.result index c3037ab769a..ec2521bcfd7 100644 --- a/mysql-test/main/func_math.result +++ b/mysql-test/main/func_math.result @@ -3550,3 +3550,47 @@ DROP TABLE t1,t2; # # End of 10.4 tests # +# +# Start of 10.5 tests +# +# +# MDEV-21278 Assertion `is_unsigned() == attr.unsigned_flag' or Assertion `field.is_sane()' failed +# +CREATE TABLE t1 (a TIMESTAMP); +INSERT INTO t1 VALUES (NULL),(NULL); +SET SESSION SQL_MODE= 'NO_UNSIGNED_SUBTRACTION'; +SELECT DISTINCT UUID_SHORT() - a FROM t1; +UUID_SHORT() - a +xxx +xxx +CREATE TABLE t2 AS SELECT DISTINCT UUID_SHORT() - a FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `UUID_SHORT() - a` bigint(22) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t2, t1; +SET sql_mode=DEFAULT; +CREATE TABLE t1 (a TIMESTAMP); +INSERT INTO t1 VALUES (NULL),(NULL); +SET SESSION SQL_MODE= 'NO_UNSIGNED_SUBTRACTION'; +SELECT UUID_SHORT() - a FROM t1; +UUID_SHORT() - a +xxx +xxx +CREATE TABLE t2 AS SELECT UUID_SHORT() - a FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `UUID_SHORT() - a` bigint(22) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t2, t1; +# +# MDEV-23680 Assertion `data' failed in crcr32_calc_pclmulqdq +# +SELECT CRC32(ExtractValue('<a><b/></a>', '/a/b')) AS f; +f +0 +# +# End of 10.5 tests +# diff --git a/mysql-test/main/func_math.test b/mysql-test/main/func_math.test index 9398cde7f89..572e0fd0f6b 100644 --- a/mysql-test/main/func_math.test +++ b/mysql-test/main/func_math.test @@ -1849,3 +1849,41 @@ DROP TABLE t1,t2; --echo # --echo # End of 10.4 tests --echo # + + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-21278 Assertion `is_unsigned() == attr.unsigned_flag' or Assertion `field.is_sane()' failed +--echo # + +CREATE TABLE t1 (a TIMESTAMP); +INSERT INTO t1 VALUES (NULL),(NULL); +SET SESSION SQL_MODE= 'NO_UNSIGNED_SUBTRACTION'; +--replace_column 1 xxx +SELECT DISTINCT UUID_SHORT() - a FROM t1; +CREATE TABLE t2 AS SELECT DISTINCT UUID_SHORT() - a FROM t1; +SHOW CREATE TABLE t2; +DROP TABLE t2, t1; +SET sql_mode=DEFAULT; + +CREATE TABLE t1 (a TIMESTAMP); +INSERT INTO t1 VALUES (NULL),(NULL); +SET SESSION SQL_MODE= 'NO_UNSIGNED_SUBTRACTION'; +--replace_column 1 xxx +SELECT UUID_SHORT() - a FROM t1; +CREATE TABLE t2 AS SELECT UUID_SHORT() - a FROM t1; +SHOW CREATE TABLE t2; +DROP TABLE t2, t1; + +--echo # +--echo # MDEV-23680 Assertion `data' failed in crcr32_calc_pclmulqdq +--echo # +SELECT CRC32(ExtractValue('<a><b/></a>', '/a/b')) AS f; + + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/func_misc.result b/mysql-test/main/func_misc.result index 483338c405a..260fcaa9116 100644 --- a/mysql-test/main/func_misc.result +++ b/mysql-test/main/func_misc.result @@ -22,7 +22,7 @@ hex(inet_aton('127.1.1')) 7F010001 select length(uuid()), charset(uuid()), length(unhex(replace(uuid(),_utf8'-',_utf8''))); length(uuid()) charset(uuid()) length(unhex(replace(uuid(),_utf8'-',_utf8''))) -36 utf8 16 +36 latin1 16 set @a= uuid_short(); set @b= uuid_short(); select @b - @a; @@ -107,7 +107,7 @@ create table t1 as select uuid(), length(uuid()); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `uuid()` varchar(36) CHARACTER SET utf8 DEFAULT NULL, + `uuid()` varchar(36) DEFAULT NULL, `length(uuid())` int(10) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; @@ -1345,6 +1345,9 @@ SELECT IS_IPV4_MAPPED(INET6_ATON('1.2.3.4')), IS_IPV4_COMPAT(INET6_ATON('1.2.3.4')); IS_IPV4_MAPPED(INET6_ATON('1.2.3.4')) IS_IPV4_COMPAT(INET6_ATON('1.2.3.4')) 0 0 +Warnings: +Warning 1292 Incorrect inet6 value: '\x01\x02\x03\x04' +Warning 1292 Incorrect inet6 value: '\x01\x02\x03\x04' SELECT IS_IPV4_MAPPED(INET6_ATON('::1.2.3.4')), IS_IPV4_COMPAT(INET6_ATON('::1.2.3.4')); IS_IPV4_MAPPED(INET6_ATON('::1.2.3.4')) IS_IPV4_COMPAT(INET6_ATON('::1.2.3.4')) @@ -1638,3 +1641,94 @@ DROP TABLE t1; # # End of 10.4 tests # +# +# MDEV-10569 Add RELEASE_ALL_LOCKS SQL-function +# +# Test function without any locks +SELECT RELEASE_ALL_LOCKS(); +RELEASE_ALL_LOCKS() +0 +# Test function with one lock only +SELECT GET_LOCK('l1',10); +GET_LOCK('l1',10) +1 +SELECT RELEASE_ALL_LOCKS(); +RELEASE_ALL_LOCKS() +1 +SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA +FROM information_schema.metadata_lock_info WHERE thread_id>0 ORDER BY TABLE_SCHEMA; +LOCK_MODE LOCK_TYPE TABLE_SCHEMA +# Test function with multiple locks +SELECT GET_LOCK('l01',10), +GET_LOCK('l02',10), +GET_LOCK('l03',10), +GET_LOCK('l04',10), +GET_LOCK('l05',10), +GET_LOCK('l06',10), +GET_LOCK('l07',10), +GET_LOCK('l08',10), +GET_LOCK('l09',10), +GET_LOCK('l10',10), +GET_LOCK('l11',10), +GET_LOCK('l12',10), +GET_LOCK('l13',10), +GET_LOCK('l14',10), +GET_LOCK('l15',10); +GET_LOCK('l01',10) GET_LOCK('l02',10) GET_LOCK('l03',10) GET_LOCK('l04',10) GET_LOCK('l05',10) GET_LOCK('l06',10) GET_LOCK('l07',10) GET_LOCK('l08',10) GET_LOCK('l09',10) GET_LOCK('l10',10) GET_LOCK('l11',10) GET_LOCK('l12',10) GET_LOCK('l13',10) GET_LOCK('l14',10) GET_LOCK('l15',10) +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 +SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA +FROM information_schema.metadata_lock_info WHERE thread_id>0 ORDER BY TABLE_SCHEMA; +LOCK_MODE LOCK_TYPE TABLE_SCHEMA +MDL_SHARED_NO_WRITE User lock l01 +MDL_SHARED_NO_WRITE User lock l02 +MDL_SHARED_NO_WRITE User lock l03 +MDL_SHARED_NO_WRITE User lock l04 +MDL_SHARED_NO_WRITE User lock l05 +MDL_SHARED_NO_WRITE User lock l06 +MDL_SHARED_NO_WRITE User lock l07 +MDL_SHARED_NO_WRITE User lock l08 +MDL_SHARED_NO_WRITE User lock l09 +MDL_SHARED_NO_WRITE User lock l10 +MDL_SHARED_NO_WRITE User lock l11 +MDL_SHARED_NO_WRITE User lock l12 +MDL_SHARED_NO_WRITE User lock l13 +MDL_SHARED_NO_WRITE User lock l14 +MDL_SHARED_NO_WRITE User lock l15 +SELECT RELEASE_ALL_LOCKS(); +RELEASE_ALL_LOCKS() +15 +SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA +FROM information_schema.metadata_lock_info WHERE thread_id>0 ORDER BY TABLE_SCHEMA; +LOCK_MODE LOCK_TYPE TABLE_SCHEMA +# Test function with recursive locks +SELECT GET_LOCK('l1',10), +GET_LOCK('l2',10), +GET_LOCK('l2',10), +GET_LOCK('l3',10), +GET_LOCK('l3',10), +GET_LOCK('l3',10), +GET_LOCK('l4',10), +GET_LOCK('l4',10), +GET_LOCK('l4',10), +GET_LOCK('l4',10), +GET_LOCK('l5',10), +GET_LOCK('l5',10), +GET_LOCK('l5',10), +GET_LOCK('l5',10), +GET_LOCK('l5',10); +GET_LOCK('l1',10) GET_LOCK('l2',10) GET_LOCK('l2',10) GET_LOCK('l3',10) GET_LOCK('l3',10) GET_LOCK('l3',10) GET_LOCK('l4',10) GET_LOCK('l4',10) GET_LOCK('l4',10) GET_LOCK('l4',10) GET_LOCK('l5',10) GET_LOCK('l5',10) GET_LOCK('l5',10) GET_LOCK('l5',10) GET_LOCK('l5',10) +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 +SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA +FROM information_schema.metadata_lock_info WHERE thread_id>0 ORDER BY TABLE_SCHEMA; +LOCK_MODE LOCK_TYPE TABLE_SCHEMA +MDL_SHARED_NO_WRITE User lock l1 +MDL_SHARED_NO_WRITE User lock l2 +MDL_SHARED_NO_WRITE User lock l3 +MDL_SHARED_NO_WRITE User lock l4 +MDL_SHARED_NO_WRITE User lock l5 +SELECT RELEASE_ALL_LOCKS(); +RELEASE_ALL_LOCKS() +15 +SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA +FROM information_schema.metadata_lock_info WHERE thread_id>0 ORDER BY TABLE_SCHEMA; +LOCK_MODE LOCK_TYPE TABLE_SCHEMA diff --git a/mysql-test/main/func_misc.test b/mysql-test/main/func_misc.test index 7d19c9e58af..a471d224677 100644 --- a/mysql-test/main/func_misc.test +++ b/mysql-test/main/func_misc.test @@ -1,7 +1,7 @@ # # Testing of misc functions # - +--source include/have_metadata_lock_info.inc --source include/default_optimizer_switch.inc --disable_warnings DROP TABLE IF EXISTS t1, t2; @@ -1278,3 +1278,60 @@ DROP TABLE t1; --echo # --echo # End of 10.4 tests --echo # + +--echo # +--echo # MDEV-10569 Add RELEASE_ALL_LOCKS SQL-function +--echo # + +--echo # Test function without any locks +SELECT RELEASE_ALL_LOCKS(); + +--echo # Test function with one lock only +SELECT GET_LOCK('l1',10); +SELECT RELEASE_ALL_LOCKS(); +SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA +FROM information_schema.metadata_lock_info WHERE thread_id>0 ORDER BY TABLE_SCHEMA; + +--echo # Test function with multiple locks +SELECT GET_LOCK('l01',10), + GET_LOCK('l02',10), + GET_LOCK('l03',10), + GET_LOCK('l04',10), + GET_LOCK('l05',10), + GET_LOCK('l06',10), + GET_LOCK('l07',10), + GET_LOCK('l08',10), + GET_LOCK('l09',10), + GET_LOCK('l10',10), + GET_LOCK('l11',10), + GET_LOCK('l12',10), + GET_LOCK('l13',10), + GET_LOCK('l14',10), + GET_LOCK('l15',10); +SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA +FROM information_schema.metadata_lock_info WHERE thread_id>0 ORDER BY TABLE_SCHEMA; +SELECT RELEASE_ALL_LOCKS(); +SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA +FROM information_schema.metadata_lock_info WHERE thread_id>0 ORDER BY TABLE_SCHEMA; + +--echo # Test function with recursive locks +SELECT GET_LOCK('l1',10), + GET_LOCK('l2',10), + GET_LOCK('l2',10), + GET_LOCK('l3',10), + GET_LOCK('l3',10), + GET_LOCK('l3',10), + GET_LOCK('l4',10), + GET_LOCK('l4',10), + GET_LOCK('l4',10), + GET_LOCK('l4',10), + GET_LOCK('l5',10), + GET_LOCK('l5',10), + GET_LOCK('l5',10), + GET_LOCK('l5',10), + GET_LOCK('l5',10); +SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA +FROM information_schema.metadata_lock_info WHERE thread_id>0 ORDER BY TABLE_SCHEMA; +SELECT RELEASE_ALL_LOCKS(); +SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA +FROM information_schema.metadata_lock_info WHERE thread_id>0 ORDER BY TABLE_SCHEMA; diff --git a/mysql-test/main/func_regexp_pcre.result b/mysql-test/main/func_regexp_pcre.result index 494fe917dc6..3b0688fc70e 100644 --- a/mysql-test/main/func_regexp_pcre.result +++ b/mysql-test/main/func_regexp_pcre.result @@ -793,7 +793,7 @@ SELECT 'a\nb' RLIKE '(?-s)a.b'; 0 SET default_regex_flags=DEFAULT; SELECT REGEXP_SUBSTR('Monday Mon','^((?<DN>Mon|Fri|Sun)day|(?<DN>Tue)sday).*(?P=DN)$'); -ERROR 42000: Got error 'two named subpatterns have the same name at offset 29' from regexp +ERROR 42000: Regex error 'two named subpatterns have the same name (PCRE2_DUPNAMES not set) at offset 30' SET default_regex_flags='DUPNAMES'; SELECT REGEXP_SUBSTR('Monday Mon','^((?<DN>Mon|Fri|Sun)day|(?<DN>Tue)sday).*(?P=DN)$'); REGEXP_SUBSTR('Monday Mon','^((?<DN>Mon|Fri|Sun)day|(?<DN>Tue)sday).*(?P=DN)$') @@ -817,11 +817,13 @@ SELECT 'AB' RLIKE 'A# this is a comment\nB'; 1 SET default_regex_flags=DEFAULT; SELECT 'Aq' RLIKE 'A\\q'; -'Aq' RLIKE 'A\\q' -1 +ERROR 42000: Regex error 'unrecognized character follows \ at offset 2' SET default_regex_flags='EXTRA'; -SELECT 'Aq' RLIKE 'A\\q'; -ERROR 42000: Got error 'unrecognized character follows \ at offset 2' from regexp +SELECT 'A' RLIKE 'B'; +'A' RLIKE 'B' +0 +Warnings: +Warning 1105 PCRE2 doesn't support the EXTRA flag. Ignored. SET default_regex_flags=DEFAULT; SELECT 'a\nb\nc' RLIKE '^b$'; 'a\nb\nc' RLIKE '^b$' @@ -861,7 +863,7 @@ SELECT 0xE001 REGEXP @regCheck; 0xE001 REGEXP @regCheck 0 Warnings: -Warning 1139 Got error 'pcre_exec: Invalid utf8 byte sequence in the subject string' from regexp +Warning 1139 Regex error 'UTF-8 error: 1 byte missing at end' # Testing workaround N1: This makes the pattern to be a binary string: SET NAMES latin1; SET @regCheck= X'E001'; @@ -882,41 +884,6 @@ CAST(0xE001 AS BINARY) REGEXP @regCheck 1 # MDEV-12420: Testing recursion overflow SELECT 1 FROM dual WHERE ('Alpha,Bravo,Charlie,Delta,Echo,Foxtrot,StrataCentral,Golf,Hotel,India,Juliet,Kilo,Lima,Mike,StrataL3,November,Oscar,StrataL2,Sand,P3,P4SwitchTest,Arsys,Poppa,ExtensionMgr,Arp,Quebec,Romeo,StrataApiV2,PtReyes,Sierra,SandAcl,Arrow,Artools,BridgeTest,Tango,SandT,PAlaska,Namespace,Agent,Qos,PatchPanel,ProjectReport,Ark,Gimp,Agent,SliceAgent,Arnet,Bgp,Ale,Tommy,Central,AsicPktTestLib,Hsc,SandL3,Abuild,Pca9555,Standby,ControllerDut,CalSys,SandLib,Sb820,PointV2,BfnLib,Evpn,BfnSdk,Sflow,ManagementActive,AutoTest,GatedTest,Bgp,Sand,xinetd,BfnAgentLib,bf-utils,Hello,BfnState,Eos,Artest,Qos,Scd,ThermoMgr,Uniform,EosUtils,Eb,FanController,Central,BfnL3,BfnL2,tcp_wrappers,Victor,Environment,Route,Failover,Whiskey,Xray,Gimp,BfnFixed,Strata,SoCal,XApi,Msrp,XpProfile,tcpdump,PatchPanel,ArosTest,FhTest,Arbus,XpAcl,MacConc,XpApi,telnet,QosTest,Alpha2,BfnVlan,Stp,VxlanControllerTest,MplsAgent,Bravo2,Lanz,BfnMbb,Intf,XCtrl,Unicast,SandTunnel,L3Unicast,Ipsec,MplsTest,Rsvp,EthIntf,StageMgr,Sol,MplsUtils,Nat,Ira,P4NamespaceDut,Counters,Charlie2,Aqlc,Mlag,Power,OpenFlow,Lag,RestApi,BfdTest,strongs,Sfa,CEosUtils,Adt746,MaintenanceMode,MlagDut,EosImage,IpEth,MultiProtocol,Launcher,Max3179,Snmp,Acl,IpEthTest,PhyEee,bf-syslibs,tacc,XpL2,p4-ar-switch,p4-bf-switch,LdpTest,BfnPhy,Mirroring,Phy6,Ptp' REGEXP '^((?!\b(Strata|StrataApi|StrataApiV2)\b).)*$'); -1 -Warnings: -Warning 1139 Got error 'pcre_exec: recursion limit of NUM exceeded' from regexp -SELECT CONCAT(REPEAT('100,',60),'101') RLIKE '^(([1-9][0-9]*),)*[1-9][0-9]*$'; -CONCAT(REPEAT('100,',60),'101') RLIKE '^(([1-9][0-9]*),)*[1-9][0-9]*$' -1 -SELECT CONCAT(REPEAT('100,',400),'101') RLIKE '^(([1-9][0-9]*),)*[1-9][0-9]*$'; -CONCAT(REPEAT('100,',400),'101') RLIKE '^(([1-9][0-9]*),)*[1-9][0-9]*$' -0 -Warnings: -Warning 1139 Got error 'pcre_exec: recursion limit of NUM exceeded' from regexp -SELECT REGEXP_INSTR(CONCAT(REPEAT('100,',60),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$'); -REGEXP_INSTR(CONCAT(REPEAT('100,',60),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$') -1 -SELECT REGEXP_INSTR(CONCAT(REPEAT('100,',400),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$'); -REGEXP_INSTR(CONCAT(REPEAT('100,',400),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$') -0 -Warnings: -Warning 1139 Got error 'pcre_exec: recursion limit of NUM exceeded' from regexp -SELECT LENGTH(REGEXP_SUBSTR(CONCAT(REPEAT('100,',60),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$')); -LENGTH(REGEXP_SUBSTR(CONCAT(REPEAT('100,',60),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$')) -243 -SELECT LENGTH(REGEXP_SUBSTR(CONCAT(REPEAT('100,',400),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$')); -LENGTH(REGEXP_SUBSTR(CONCAT(REPEAT('100,',400),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$')) -0 -Warnings: -Warning 1139 Got error 'pcre_exec: recursion limit of NUM exceeded' from regexp -SELECT LENGTH(REGEXP_REPLACE(CONCAT(REPEAT('100,',60),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$', '')); -LENGTH(REGEXP_REPLACE(CONCAT(REPEAT('100,',60),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$', '')) -0 -SELECT LENGTH(REGEXP_REPLACE(CONCAT(REPEAT('100,',400),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$', '')); -LENGTH(REGEXP_REPLACE(CONCAT(REPEAT('100,',400),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$', '')) -1603 -Warnings: -Warning 1139 Got error 'pcre_exec: recursion limit of NUM exceeded' from regexp SELECT REGEXP_INSTR('a_kollision', 'oll'); REGEXP_INSTR('a_kollision', 'oll') 4 diff --git a/mysql-test/main/func_regexp_pcre.test b/mysql-test/main/func_regexp_pcre.test index de0fe94b7c1..3851caf8917 100644 --- a/mysql-test/main/func_regexp_pcre.test +++ b/mysql-test/main/func_regexp_pcre.test @@ -368,6 +368,8 @@ SELECT 'a\nb' RLIKE 'a.b'; SELECT 'a\nb' RLIKE '(?-s)a.b'; SET default_regex_flags=DEFAULT; +# note that old pcre2 reports a different offset +--replace_result 29 30 --error ER_REGEXP_ERROR SELECT REGEXP_SUBSTR('Monday Mon','^((?<DN>Mon|Fri|Sun)day|(?<DN>Tue)sday).*(?P=DN)$'); SET default_regex_flags='DUPNAMES'; @@ -382,10 +384,12 @@ SELECT 'AB' RLIKE 'A B'; SELECT 'AB' RLIKE 'A# this is a comment\nB'; SET default_regex_flags=DEFAULT; -SELECT 'Aq' RLIKE 'A\\q'; -SET default_regex_flags='EXTRA'; --error ER_REGEXP_ERROR SELECT 'Aq' RLIKE 'A\\q'; + +SET default_regex_flags='EXTRA'; +SELECT 'A' RLIKE 'B'; + SET default_regex_flags=DEFAULT; SELECT 'a\nb\nc' RLIKE '^b$'; @@ -430,27 +434,14 @@ SET @regCheck= '\\xE0\\x01'; SELECT CAST(0xE001 AS BINARY) REGEXP @regCheck; --echo # MDEV-12420: Testing recursion overflow ---replace_regex /[0-9]+ exceeded/NUM exceeded/ +# pcre2 < 10.30 relies on stack, we limit recursion depth, REGEXP fails +# newer pcre2 uses heap, no need (and no way) to limit recursion, REGEXP succeeds +# we just test that it doesn't crash with a stack overflow +--disable_warnings +--disable_result_log SELECT 1 FROM dual WHERE ('Alpha,Bravo,Charlie,Delta,Echo,Foxtrot,StrataCentral,Golf,Hotel,India,Juliet,Kilo,Lima,Mike,StrataL3,November,Oscar,StrataL2,Sand,P3,P4SwitchTest,Arsys,Poppa,ExtensionMgr,Arp,Quebec,Romeo,StrataApiV2,PtReyes,Sierra,SandAcl,Arrow,Artools,BridgeTest,Tango,SandT,PAlaska,Namespace,Agent,Qos,PatchPanel,ProjectReport,Ark,Gimp,Agent,SliceAgent,Arnet,Bgp,Ale,Tommy,Central,AsicPktTestLib,Hsc,SandL3,Abuild,Pca9555,Standby,ControllerDut,CalSys,SandLib,Sb820,PointV2,BfnLib,Evpn,BfnSdk,Sflow,ManagementActive,AutoTest,GatedTest,Bgp,Sand,xinetd,BfnAgentLib,bf-utils,Hello,BfnState,Eos,Artest,Qos,Scd,ThermoMgr,Uniform,EosUtils,Eb,FanController,Central,BfnL3,BfnL2,tcp_wrappers,Victor,Environment,Route,Failover,Whiskey,Xray,Gimp,BfnFixed,Strata,SoCal,XApi,Msrp,XpProfile,tcpdump,PatchPanel,ArosTest,FhTest,Arbus,XpAcl,MacConc,XpApi,telnet,QosTest,Alpha2,BfnVlan,Stp,VxlanControllerTest,MplsAgent,Bravo2,Lanz,BfnMbb,Intf,XCtrl,Unicast,SandTunnel,L3Unicast,Ipsec,MplsTest,Rsvp,EthIntf,StageMgr,Sol,MplsUtils,Nat,Ira,P4NamespaceDut,Counters,Charlie2,Aqlc,Mlag,Power,OpenFlow,Lag,RestApi,BfdTest,strongs,Sfa,CEosUtils,Adt746,MaintenanceMode,MlagDut,EosImage,IpEth,MultiProtocol,Launcher,Max3179,Snmp,Acl,IpEthTest,PhyEee,bf-syslibs,tacc,XpL2,p4-ar-switch,p4-bf-switch,LdpTest,BfnPhy,Mirroring,Phy6,Ptp' REGEXP '^((?!\b(Strata|StrataApi|StrataApiV2)\b).)*$'); - -# -# MDEV-13173 An RLIKE that previously worked on 10.0 now returns "Got error 'pcre_exec: recursion limit of 100 exceeded' from regexp" -# -SELECT CONCAT(REPEAT('100,',60),'101') RLIKE '^(([1-9][0-9]*),)*[1-9][0-9]*$'; ---replace_regex /[0-9]+ exceeded/NUM exceeded/ -SELECT CONCAT(REPEAT('100,',400),'101') RLIKE '^(([1-9][0-9]*),)*[1-9][0-9]*$'; - -SELECT REGEXP_INSTR(CONCAT(REPEAT('100,',60),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$'); ---replace_regex /[0-9]+ exceeded/NUM exceeded/ -SELECT REGEXP_INSTR(CONCAT(REPEAT('100,',400),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$'); - -SELECT LENGTH(REGEXP_SUBSTR(CONCAT(REPEAT('100,',60),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$')); ---replace_regex /[0-9]+ exceeded/NUM exceeded/ -SELECT LENGTH(REGEXP_SUBSTR(CONCAT(REPEAT('100,',400),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$')); - -SELECT LENGTH(REGEXP_REPLACE(CONCAT(REPEAT('100,',60),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$', '')); ---replace_regex /[0-9]+ exceeded/NUM exceeded/ -SELECT LENGTH(REGEXP_REPLACE(CONCAT(REPEAT('100,',400),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$', '')); +--enable_result_log +--enable_warnings # # MDEV-12942 REGEXP_INSTR returns 1 when using brackets diff --git a/mysql-test/main/func_regexp_pcre_debug.result b/mysql-test/main/func_regexp_pcre_debug.result index 40a379a077d..61bf9cfe98b 100644 --- a/mysql-test/main/func_regexp_pcre_debug.result +++ b/mysql-test/main/func_regexp_pcre_debug.result @@ -3,7 +3,7 @@ SELECT 'a' RLIKE 'a'; 'a' RLIKE 'a' 0 Warnings: -Warning 1139 Got error 'pcre_exec: Internal error (-123)' from regexp +Warning 1139 Regex error 'pcre_exec: Internal error (-123)' SELECT 'a' RLIKE 'a'; 'a' RLIKE 'a' 1 diff --git a/mysql-test/main/func_str.result b/mysql-test/main/func_str.result index d50a77544f3..5d9aff6f6ad 100644 --- a/mysql-test/main/func_str.result +++ b/mysql-test/main/func_str.result @@ -211,6 +211,11 @@ this is test select replace('aaaa','a','b'),replace('aaaa','aa','b'),replace('aaaa','a','bb'),replace('aaaa','','b'),replace('bbbb','a','c'); replace('aaaa','a','b') replace('aaaa','aa','b') replace('aaaa','a','bb') replace('aaaa','','b') replace('bbbb','a','c') bbbb bb bbbbbbbb aaaa bbbb +select replace('aaaa','a','bbbb'); +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def replace('aaaa','a','bbbb') 253 16 16 Y 0 39 8 +replace('aaaa','a','bbbb') +bbbbbbbbbbbbbbbb select replace(concat(lcase(concat('THIS',' ','IS',' ','A',' ')),ucase('false'),' ','test'),'FALSE','REAL') ; replace(concat(lcase(concat('THIS',' ','IS',' ','A',' ')),ucase('false'),' ','test'),'FALSE','REAL') this is a REAL test @@ -967,17 +972,17 @@ explain extended select length('\n\t\r\b\0\_\%\\'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 select octet_length('\n \r\0\\_\\%\\') AS `length('\n\t\r\b\0\_\%\\')` +Note 1003 select octet_length('\n \r\0008\0\\_\\%\\') AS `length('\n\t\r\b\0\_\%\\')` explain extended select bit_length('\n\t\r\b\0\_\%\\'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 select bit_length('\n \r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')` +Note 1003 select bit_length('\n \r\0008\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')` explain extended select bit_length('\n\t\r\b\0\_\%\\'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 select bit_length('\n \r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')` +Note 1003 select bit_length('\n \r\0008\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')` explain extended select concat('monty',' was here ','again'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used @@ -3071,7 +3076,7 @@ SELECT ((rpad(1.0,2048,1)) = ('4(') ^ (0.1)); ((rpad(1.0,2048,1)) = ('4(') ^ (0.1)) 0 Warnings: -Warning 1292 Truncated incorrect INTEGER value: '4(' +Warning 1292 Truncated incorrect DECIMAL value: '4(' SELECT pow((rpad(10.0,2048,1)),(b'1111111111111111111111111111111111111111111')); ERROR 22003: DOUBLE value is out of range in 'pow(rpad(10.0,2048,1),0x07ffffffffff)' @@ -3079,7 +3084,7 @@ SELECT ((rpad(1.0,2048,1)) + (0) ^ ('../')); ((rpad(1.0,2048,1)) + (0) ^ ('../')) 1.011111111111111 Warnings: -Warning 1292 Truncated incorrect INTEGER value: '../' +Warning 1292 Truncated incorrect DECIMAL value: '../' SELECT stddev_samp(rpad(1.0,2048,1)); stddev_samp(rpad(1.0,2048,1)) NULL @@ -5174,12 +5179,9 @@ DATA_VALUE CHAR(10) NULL, HAS_DATA BIT NOT NULL, TEST_COLUMN CHAR(10) AS (RPAD(CASE WHEN HAS_DATA = 1 THEN DATA_VALUE ELSE NULL END, 10)) STORED); -Warnings: -Warning 1901 Function or expression 'rpad(case when `HAS_DATA` = 1 then `DATA_VALUE` else NULL end,10)' cannot be used in the GENERATED ALWAYS AS clause of `TEST_COLUMN` -Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH +ERROR HY000: Function or expression 'rpad(case when `HAS_DATA` = 1 then `DATA_VALUE` else NULL end,10)' cannot be used in the GENERATED ALWAYS AS clause of `TEST_COLUMN` # Cleanup DROP TABLE t1; -DROP TABLE crash_test_2; # # End of 10.3 tests # diff --git a/mysql-test/main/func_str.test b/mysql-test/main/func_str.test index 6a9fbc71371..432bc64f769 100644 --- a/mysql-test/main/func_str.test +++ b/mysql-test/main/func_str.test @@ -91,6 +91,9 @@ SELECT CONCAT('"',CONCAT_WS('";"',repeat('a',60),repeat('b',60),repeat('c',60),r select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es'); select replace('aaaa','a','b'),replace('aaaa','aa','b'),replace('aaaa','a','bb'),replace('aaaa','','b'),replace('bbbb','a','c'); +--enable_metadata +select replace('aaaa','a','bbbb'); +--disable_metadata select replace(concat(lcase(concat('THIS',' ','IS',' ','A',' ')),ucase('false'),' ','test'),'FALSE','REAL') ; select soundex(''),soundex('he'),soundex('hello all folks'),soundex('#3556 in bugdb'); select 'mood' sounds like 'mud'; @@ -2113,6 +2116,7 @@ DROP TABLE t1, t2; CREATE TABLE t1 (i int, b int AS (RPAD(123,1)) stored); --echo # Original case from the reporter +--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED CREATE TABLE crash_test_2 ( DATA_VALUE CHAR(10) NULL, HAS_DATA BIT NOT NULL, @@ -2121,7 +2125,6 @@ CREATE TABLE crash_test_2 ( --echo # Cleanup DROP TABLE t1; -DROP TABLE crash_test_2; --echo # diff --git a/mysql-test/main/func_time.result b/mysql-test/main/func_time.result index 725e156ddd4..d44f634db08 100644 --- a/mysql-test/main/func_time.result +++ b/mysql-test/main/func_time.result @@ -1699,8 +1699,8 @@ NULL SELECT MONTHNAME(0), MONTHNAME(0) IS NULL, MONTHNAME(0) + 1; MONTHNAME(0) MONTHNAME(0) IS NULL MONTHNAME(0) + 1 NULL 1 NULL -SET storage_engine=NULL; -ERROR 42000: Variable 'storage_engine' can't be set to the value of 'NULL' +SET default_storage_engine=NULL; +ERROR 42000: Variable 'default_storage_engine' can't be set to the value of 'NULL' # # BUG#13354387 - CRASH IN IN MY_DECIMAL::OPERATOR FOR VIEW AND FUNCTION UNIX_TIMESTAMP # Part1 (5.5) @@ -2795,7 +2795,7 @@ SET sql_mode=DEFAULT; DO TO_DAYS(SEC_TO_TIME(TIME(CEILING(UUID())))); DO TO_DAYS(SEC_TO_TIME(MAKEDATE('',RAND(~(''))))); Warnings: -Warning 1292 Truncated incorrect INTEGER value: '' +Warning 1292 Truncated incorrect DECIMAL value: '' Warning 1292 Truncated incorrect INTEGER value: '' Warning 1292 Truncated incorrect seconds value: '20000101' SELECT SEC_TO_TIME(MAKEDATE(0,RAND(~0))); @@ -3701,15 +3701,15 @@ SET TIMESTAMP=DEFAULT; # MDEV-15702 Remove the use of STRING_ITEM from Item_func_date_format::fix_length_and_dec() # SELECT DATE_FORMAT('2001-01-01',POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'date_format' +ERROR HY000: Illegal parameter data type point for operation 'date_format' SELECT DATE_FORMAT(POINT(1,1),'10'); -ERROR HY000: Illegal parameter data type geometry for operation 'date_format' +ERROR HY000: Illegal parameter data type point for operation 'date_format' SELECT DATE_FORMAT('2001-01-01',ROW(1,1)); ERROR HY000: Illegal parameter data type row for operation 'date_format' SELECT DATE_FORMAT(ROW(1,1),'10'); ERROR HY000: Illegal parameter data type row for operation 'date_format' SELECT DATE_FORMAT('2001-01-01','%Y',POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'date_format' +ERROR HY000: Illegal parameter data type point for operation 'date_format' SELECT DATE_FORMAT('2001-01-01','%Y',ROW(1,1)); ERROR HY000: Illegal parameter data type row for operation 'date_format' SELECT DATE_FORMAT('2001-01-01','%Y',@unknown_user_variable); diff --git a/mysql-test/main/func_time.test b/mysql-test/main/func_time.test index 71f82ddba7b..970d3e44a77 100644 --- a/mysql-test/main/func_time.test +++ b/mysql-test/main/func_time.test @@ -1016,7 +1016,7 @@ SELECT SUBDATE(STR_TO_DATE(NULL,0), INTERVAL 1 HOUR); --echo # SELECT MONTHNAME(0), MONTHNAME(0) IS NULL, MONTHNAME(0) + 1; --error ER_WRONG_VALUE_FOR_VAR -SET storage_engine=NULL; +SET default_storage_engine=NULL; --echo # diff --git a/mysql-test/main/function_defaults.result b/mysql-test/main/function_defaults.result index 4a8f64df352..1f9b324e30c 100644 --- a/mysql-test/main/function_defaults.result +++ b/mysql-test/main/function_defaults.result @@ -6,7 +6,7 @@ # SET TIME_ZONE = "+00:00"; # -# Test of errors for column data types that dont support function +# Test of errors for column data types that don't support function # defaults. # CREATE OR REPLACE TABLE t1( a BIT DEFAULT CURRENT_TIMESTAMP ); @@ -1552,7 +1552,7 @@ DROP TABLE t1; # SET TIME_ZONE = "+00:00"; # -# Test of errors for column data types that dont support function +# Test of errors for column data types that don't support function # defaults. # CREATE OR REPLACE TABLE t1( a BIT DEFAULT CURRENT_TIMESTAMP(6) ); diff --git a/mysql-test/main/function_defaults_innodb.result b/mysql-test/main/function_defaults_innodb.result index dd769f8577a..c73dda735d5 100644 --- a/mysql-test/main/function_defaults_innodb.result +++ b/mysql-test/main/function_defaults_innodb.result @@ -7,7 +7,7 @@ set default_storage_engine=innodb; # SET TIME_ZONE = "+00:00"; # -# Test of errors for column data types that dont support function +# Test of errors for column data types that don't support function # defaults. # CREATE OR REPLACE TABLE t1( a BIT DEFAULT CURRENT_TIMESTAMP ); @@ -1553,7 +1553,7 @@ DROP TABLE t1; # SET TIME_ZONE = "+00:00"; # -# Test of errors for column data types that dont support function +# Test of errors for column data types that don't support function # defaults. # CREATE OR REPLACE TABLE t1( a BIT DEFAULT CURRENT_TIMESTAMP(6) ); diff --git a/mysql-test/main/get_diagnostics.result b/mysql-test/main/get_diagnostics.result index 6944103c805..ca495d6954d 100644 --- a/mysql-test/main/get_diagnostics.result +++ b/mysql-test/main/get_diagnostics.result @@ -1,3 +1,4 @@ +SET NAMES utf8; # # WL#2111: GET DIAGNOSTICS tests # diff --git a/mysql-test/main/get_diagnostics.test b/mysql-test/main/get_diagnostics.test index 1553eb500b7..4667ec727dd 100644 --- a/mysql-test/main/get_diagnostics.test +++ b/mysql-test/main/get_diagnostics.test @@ -1,3 +1,5 @@ +SET NAMES utf8; + --echo # --echo # WL#2111: GET DIAGNOSTICS tests --echo # diff --git a/mysql-test/main/gis-debug.result b/mysql-test/main/gis-debug.result index 2daa810db0d..f490a720ecf 100644 --- a/mysql-test/main/gis-debug.result +++ b/mysql-test/main/gis-debug.result @@ -356,22 +356,16 @@ SET SESSION debug_dbug="-d,Item_func_in"; # MDEV-12238 Add Type_handler::Item_func_{plus|minus|mul|div|mod}_fix_length_and_dec() # SET debug_dbug='+d,num_op'; -CREATE TABLE t1 AS SELECT -POINT(0,0)+POINT(0,0), -POINT(0,0)-POINT(0,0), -POINT(0,0)*POINT(0,0), -POINT(0,0)/POINT(0,0), -POINT(0,0) MOD POINT(0,0) LIMIT 0; -SHOW CREATE TABLE t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `POINT(0,0)+POINT(0,0)` geometry DEFAULT NULL, - `POINT(0,0)-POINT(0,0)` geometry DEFAULT NULL, - `POINT(0,0)*POINT(0,0)` geometry DEFAULT NULL, - `POINT(0,0)/POINT(0,0)` geometry DEFAULT NULL, - `POINT(0,0) MOD POINT(0,0)` geometry DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -DROP TABLE t1; +SELECT POINT(0,0)+POINT(0,0); +ERROR HY000: Illegal parameter data types point and point for operation '+' +SELECT POINT(0,0)-POINT(0,0); +ERROR HY000: Illegal parameter data types point and point for operation '-' +SELECT POINT(0,0)*POINT(0,0); +ERROR HY000: Illegal parameter data types point and point for operation '*' +SELECT POINT(0,0)/POINT(0,0); +ERROR HY000: Illegal parameter data types point and point for operation '/' +SELECT POINT(0,0) MOD POINT(0,0); +ERROR HY000: Illegal parameter data types point and point for operation 'MOD' CREATE TABLE t1 AS SELECT POINT(0,0)+'0', POINT(0,0)-'0', @@ -399,11 +393,11 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; CREATE TABLE t1 AS SELECT '0'-POINT(0,0) LIMIT 0; -ERROR HY000: Illegal parameter data types varchar and geometry for operation '-' +ERROR HY000: Illegal parameter data types varchar and point for operation '-' CREATE TABLE t1 AS SELECT '0'/POINT(0,0) LIMIT 0; -ERROR HY000: Illegal parameter data types varchar and geometry for operation '/' +ERROR HY000: Illegal parameter data types varchar and point for operation '/' CREATE TABLE t1 AS SELECT '0' MOD POINT(0,0) LIMIT 0; -ERROR HY000: Illegal parameter data types varchar and geometry for operation 'MOD' +ERROR HY000: Illegal parameter data types varchar and point for operation 'MOD' SET debug_dbug='-d,num_op'; # # End of 10.3 tests @@ -424,9 +418,9 @@ Warnings: Note 1105 DBUG: [0] arg=1 handler=0 (row) Note 1105 DBUG: [1] arg=2 handler=0 (row) Note 1105 DBUG: ROW(3 args) level=0 -Note 1105 DBUG: [0,0] handler=geometry -Note 1105 DBUG: [0,1] handler=geometry -Note 1105 DBUG: [0,2] handler=geometry +Note 1105 DBUG: [0,0] handler=point +Note 1105 DBUG: [0,1] handler=point +Note 1105 DBUG: [0,2] handler=point Note 1105 DBUG: => handler=geometry Note 1105 DBUG: [1,0] handler=int Note 1105 DBUG: [1,1] handler=int @@ -449,9 +443,9 @@ Note 1105 DBUG: [1,1] handler=row Note 1105 DBUG: [1,2] handler=row Note 1105 DBUG: => handler=row Note 1105 DBUG: ROW(3 args) level=1 -Note 1105 DBUG: [0,0] handler=geometry -Note 1105 DBUG: [0,1] handler=geometry -Note 1105 DBUG: [0,2] handler=geometry +Note 1105 DBUG: [0,0] handler=point +Note 1105 DBUG: [0,1] handler=point +Note 1105 DBUG: [0,2] handler=point Note 1105 DBUG: => handler=geometry Note 1105 DBUG: [1,0] handler=int Note 1105 DBUG: [1,1] handler=int @@ -459,18 +453,18 @@ Note 1105 DBUG: [1,2] handler=int Note 1105 DBUG: => handler=bigint Note 1105 DBUG: types_compatible=yes bisect=no SELECT (1,0) IN ((POINT(1,1),0),(0,0)); -ERROR HY000: Illegal parameter data types int and geometry for operation 'in' +ERROR HY000: Illegal parameter data types int and point for operation 'in' SHOW WARNINGS; Level Code Message Note 1105 DBUG: [0] arg=1 handler=0 (row) Note 1105 DBUG: [1] arg=2 handler=0 (row) Note 1105 DBUG: ROW(3 args) level=0 Note 1105 DBUG: [0,0] handler=int -Note 1105 DBUG: [0,1] handler=geometry +Note 1105 DBUG: [0,1] handler=point Note 1105 DBUG: [0,2] handler=int -Error 4078 Illegal parameter data types int and geometry for operation 'in' +Error 4078 Illegal parameter data types int and point for operation 'in' SELECT (1,(0,0)) IN ((1,(POINT(1,1),0)),(0,(0,0))); -ERROR HY000: Illegal parameter data types int and geometry for operation 'in' +ERROR HY000: Illegal parameter data types int and point for operation 'in' SHOW WARNINGS; Level Code Message Note 1105 DBUG: [0] arg=1 handler=0 (row) @@ -486,12 +480,35 @@ Note 1105 DBUG: [1,2] handler=row Note 1105 DBUG: => handler=row Note 1105 DBUG: ROW(3 args) level=1 Note 1105 DBUG: [0,0] handler=int -Note 1105 DBUG: [0,1] handler=geometry +Note 1105 DBUG: [0,1] handler=point Note 1105 DBUG: [0,2] handler=int -Error 4078 Illegal parameter data types int and geometry for operation 'in' +Error 4078 Illegal parameter data types int and point for operation 'in' SET SESSION debug_dbug="-d,Predicant_to_list_comparator"; SET SESSION debug_dbug="-d,Item_func_in"; SET SESSION debug_dbug="-d,cmp_item"; # # End of 10.4 tests # +# +# Start of 10.5 tests +# +# +# MDEV-19994 Add class Function_collection +# +SET SESSION debug_dbug="+d,make_item_func_call_native_simulate_not_found"; +SELECT CONTAINS(POINT(1,1),POINT(1,1)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(POINT(1,1),POINT(1,1))' at line 1 +SELECT WITHIN(POINT(1,1),POINT(1,1)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(POINT(1,1),POINT(1,1))' at line 1 +SET SESSION debug_dbug="-d,make_item_func_call_native_simulate_not_found"; +# +# MDEV-20009 Add CAST(expr AS pluggable_type) +# +SET SESSION debug_dbug="+d,emulate_geometry_create_typecast_item"; +SELECT AsText(CAST('POINT(0 0)' AS GEOMETRY)); +AsText(CAST('POINT(0 0)' AS GEOMETRY)) +POINT(0 0) +SET SESSION debug_dbug="-d,emulate_geometry_create_typecast_item"; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/gis-debug.test b/mysql-test/main/gis-debug.test index dd64ce0f04c..0e11c11e5b5 100644 --- a/mysql-test/main/gis-debug.test +++ b/mysql-test/main/gis-debug.test @@ -73,15 +73,19 @@ SET SESSION debug_dbug="-d,Item_func_in"; SET debug_dbug='+d,num_op'; -# (GEOMETRY,GEOMETRY) gives GEOMETRY for all operators -CREATE TABLE t1 AS SELECT - POINT(0,0)+POINT(0,0), - POINT(0,0)-POINT(0,0), - POINT(0,0)*POINT(0,0), - POINT(0,0)/POINT(0,0), - POINT(0,0) MOD POINT(0,0) LIMIT 0; -SHOW CREATE TABLE t1; -DROP TABLE t1; +# (GEOMETRY,GEOMETRY) goes through +# Type_collection_geometry::aggregate_for_num_op() which fails. + +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT POINT(0,0)+POINT(0,0); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT POINT(0,0)-POINT(0,0); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT POINT(0,0)*POINT(0,0); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT POINT(0,0)/POINT(0,0); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT POINT(0,0) MOD POINT(0,0); # (GEOMETRY,VARCHAR) gives GEOMETRY for all operators CREATE TABLE t1 AS SELECT @@ -147,3 +151,32 @@ SET SESSION debug_dbug="-d,cmp_item"; --echo # --echo # End of 10.4 tests --echo # + + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-19994 Add class Function_collection +--echo # + +SET SESSION debug_dbug="+d,make_item_func_call_native_simulate_not_found"; +--error ER_PARSE_ERROR +SELECT CONTAINS(POINT(1,1),POINT(1,1)); +--error ER_PARSE_ERROR +SELECT WITHIN(POINT(1,1),POINT(1,1)); +SET SESSION debug_dbug="-d,make_item_func_call_native_simulate_not_found"; + +--echo # +--echo # MDEV-20009 Add CAST(expr AS pluggable_type) +--echo # + +SET SESSION debug_dbug="+d,emulate_geometry_create_typecast_item"; +SELECT AsText(CAST('POINT(0 0)' AS GEOMETRY)); +SET SESSION debug_dbug="-d,emulate_geometry_create_typecast_item"; + + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/gis.result b/mysql-test/main/gis.result index 655649b85ff..8bcb98143a2 100644 --- a/mysql-test/main/gis.result +++ b/mysql-test/main/gis.result @@ -488,7 +488,7 @@ explain extended select issimple(MultiPoint(Point(3, 6), Point(4, 10))), issimpl id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 select st_issimple(geometrycollection(point(3,6),point(4,10))) AS `issimple(MultiPoint(Point(3, 6), Point(4, 10)))`,st_issimple(point(3,6)) AS `issimple(Point(3, 6))` +Note 1003 select st_issimple(multipoint(point(3,6),point(4,10))) AS `issimple(MultiPoint(Point(3, 6), Point(4, 10)))`,st_issimple(point(3,6)) AS `issimple(Point(3, 6))` create table t1 (a geometry not null); insert into t1 values (GeomFromText('Point(1 2)')); insert into t1 values ('Garbage'); @@ -1049,7 +1049,7 @@ f5 datetime YES NULL drop view v1; drop table t1; SELECT MultiPoint(12345,''); -ERROR HY000: Illegal parameter data type int for operation 'geometrycollection' +ERROR HY000: Illegal parameter data type int for operation 'multipoint' SELECT 1 FROM (SELECT GREATEST(1,GEOMETRYCOLLECTION('00000','00000')) b FROM DUAL) AS d WHERE (LINESTRING(d.b)); ERROR HY000: Illegal parameter data type varchar for operation 'geometrycollection' # @@ -1889,10 +1889,10 @@ DROP TABLE t1; create view v1 as select AsWKT(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9)))); show create view v1; View Create View character_set_client collation_connection -v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select st_astext(geometrycollection(point(44,6),geometrycollection(point(3,6),point(7,9)))) AS `Name_exp_1` latin1 latin1_swedish_ci +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select st_astext(geometrycollection(point(44,6),linestring(point(3,6),point(7,9)))) AS `Name_exp_1` latin1 latin1_swedish_ci select * from v1; Name_exp_1 -GEOMETRYCOLLECTION(POINT(44 6),GEOMETRYCOLLECTION(POINT(3 6),POINT(7 9))) +GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9)) drop view v1; # # MDEV-10134 Add full support for DEFAULT @@ -2505,309 +2505,309 @@ CREATE TABLE t1 (a TINYINT, b Point) CREATE TABLE t2 AS SELECT CASE WHEN TRUE THEN a ELSE b END FROM t1 ERROR: -Illegal parameter data types tinyint and geometry for operation 'case' +Illegal parameter data types tinyint and point for operation 'case' CREATE TABLE t2 AS SELECT COALESCE(a,b) FROM t1 ERROR: -Illegal parameter data types tinyint and geometry for operation 'coalesce' +Illegal parameter data types tinyint and point for operation 'coalesce' CREATE TABLE t2 AS SELECT IF(TRUE,a,b) FROM t1 ERROR: -Illegal parameter data types tinyint and geometry for operation 'if' +Illegal parameter data types tinyint and point for operation 'if' CREATE TABLE t2 AS SELECT IFNULL(a,b) FROM t1 ERROR: -Illegal parameter data types tinyint and geometry for operation 'ifnull' +Illegal parameter data types tinyint and point for operation 'ifnull' CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT b FROM t1 ERROR: -Illegal parameter data types tinyint and geometry for operation 'UNION' +Illegal parameter data types tinyint and point for operation 'UNION' ------------------------------------- CREATE TABLE t1 (a SMALLINT, b Point) CREATE TABLE t2 AS SELECT CASE WHEN TRUE THEN a ELSE b END FROM t1 ERROR: -Illegal parameter data types smallint and geometry for operation 'case' +Illegal parameter data types smallint and point for operation 'case' CREATE TABLE t2 AS SELECT COALESCE(a,b) FROM t1 ERROR: -Illegal parameter data types smallint and geometry for operation 'coalesce' +Illegal parameter data types smallint and point for operation 'coalesce' CREATE TABLE t2 AS SELECT IF(TRUE,a,b) FROM t1 ERROR: -Illegal parameter data types smallint and geometry for operation 'if' +Illegal parameter data types smallint and point for operation 'if' CREATE TABLE t2 AS SELECT IFNULL(a,b) FROM t1 ERROR: -Illegal parameter data types smallint and geometry for operation 'ifnull' +Illegal parameter data types smallint and point for operation 'ifnull' CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT b FROM t1 ERROR: -Illegal parameter data types smallint and geometry for operation 'UNION' +Illegal parameter data types smallint and point for operation 'UNION' ------------------------------------- CREATE TABLE t1 (a MEDIUMINT, b Point) CREATE TABLE t2 AS SELECT CASE WHEN TRUE THEN a ELSE b END FROM t1 ERROR: -Illegal parameter data types mediumint and geometry for operation 'case' +Illegal parameter data types mediumint and point for operation 'case' CREATE TABLE t2 AS SELECT COALESCE(a,b) FROM t1 ERROR: -Illegal parameter data types mediumint and geometry for operation 'coalesce' +Illegal parameter data types mediumint and point for operation 'coalesce' CREATE TABLE t2 AS SELECT IF(TRUE,a,b) FROM t1 ERROR: -Illegal parameter data types mediumint and geometry for operation 'if' +Illegal parameter data types mediumint and point for operation 'if' CREATE TABLE t2 AS SELECT IFNULL(a,b) FROM t1 ERROR: -Illegal parameter data types mediumint and geometry for operation 'ifnull' +Illegal parameter data types mediumint and point for operation 'ifnull' CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT b FROM t1 ERROR: -Illegal parameter data types mediumint and geometry for operation 'UNION' +Illegal parameter data types mediumint and point for operation 'UNION' ------------------------------------- CREATE TABLE t1 (a INT, b Point) CREATE TABLE t2 AS SELECT CASE WHEN TRUE THEN a ELSE b END FROM t1 ERROR: -Illegal parameter data types int and geometry for operation 'case' +Illegal parameter data types int and point for operation 'case' CREATE TABLE t2 AS SELECT COALESCE(a,b) FROM t1 ERROR: -Illegal parameter data types int and geometry for operation 'coalesce' +Illegal parameter data types int and point for operation 'coalesce' CREATE TABLE t2 AS SELECT IF(TRUE,a,b) FROM t1 ERROR: -Illegal parameter data types int and geometry for operation 'if' +Illegal parameter data types int and point for operation 'if' CREATE TABLE t2 AS SELECT IFNULL(a,b) FROM t1 ERROR: -Illegal parameter data types int and geometry for operation 'ifnull' +Illegal parameter data types int and point for operation 'ifnull' CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT b FROM t1 ERROR: -Illegal parameter data types int and geometry for operation 'UNION' +Illegal parameter data types int and point for operation 'UNION' ------------------------------------- CREATE TABLE t1 (a BIGINT, b Point) CREATE TABLE t2 AS SELECT CASE WHEN TRUE THEN a ELSE b END FROM t1 ERROR: -Illegal parameter data types bigint and geometry for operation 'case' +Illegal parameter data types bigint and point for operation 'case' CREATE TABLE t2 AS SELECT COALESCE(a,b) FROM t1 ERROR: -Illegal parameter data types bigint and geometry for operation 'coalesce' +Illegal parameter data types bigint and point for operation 'coalesce' CREATE TABLE t2 AS SELECT IF(TRUE,a,b) FROM t1 ERROR: -Illegal parameter data types bigint and geometry for operation 'if' +Illegal parameter data types bigint and point for operation 'if' CREATE TABLE t2 AS SELECT IFNULL(a,b) FROM t1 ERROR: -Illegal parameter data types bigint and geometry for operation 'ifnull' +Illegal parameter data types bigint and point for operation 'ifnull' CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT b FROM t1 ERROR: -Illegal parameter data types bigint and geometry for operation 'UNION' +Illegal parameter data types bigint and point for operation 'UNION' ------------------------------------- CREATE TABLE t1 (a FLOAT, b Point) CREATE TABLE t2 AS SELECT CASE WHEN TRUE THEN a ELSE b END FROM t1 ERROR: -Illegal parameter data types float and geometry for operation 'case' +Illegal parameter data types float and point for operation 'case' CREATE TABLE t2 AS SELECT COALESCE(a,b) FROM t1 ERROR: -Illegal parameter data types float and geometry for operation 'coalesce' +Illegal parameter data types float and point for operation 'coalesce' CREATE TABLE t2 AS SELECT IF(TRUE,a,b) FROM t1 ERROR: -Illegal parameter data types float and geometry for operation 'if' +Illegal parameter data types float and point for operation 'if' CREATE TABLE t2 AS SELECT IFNULL(a,b) FROM t1 ERROR: -Illegal parameter data types float and geometry for operation 'ifnull' +Illegal parameter data types float and point for operation 'ifnull' CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT b FROM t1 ERROR: -Illegal parameter data types float and geometry for operation 'UNION' +Illegal parameter data types float and point for operation 'UNION' ------------------------------------- CREATE TABLE t1 (a DOUBLE, b Point) CREATE TABLE t2 AS SELECT CASE WHEN TRUE THEN a ELSE b END FROM t1 ERROR: -Illegal parameter data types double and geometry for operation 'case' +Illegal parameter data types double and point for operation 'case' CREATE TABLE t2 AS SELECT COALESCE(a,b) FROM t1 ERROR: -Illegal parameter data types double and geometry for operation 'coalesce' +Illegal parameter data types double and point for operation 'coalesce' CREATE TABLE t2 AS SELECT IF(TRUE,a,b) FROM t1 ERROR: -Illegal parameter data types double and geometry for operation 'if' +Illegal parameter data types double and point for operation 'if' CREATE TABLE t2 AS SELECT IFNULL(a,b) FROM t1 ERROR: -Illegal parameter data types double and geometry for operation 'ifnull' +Illegal parameter data types double and point for operation 'ifnull' CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT b FROM t1 ERROR: -Illegal parameter data types double and geometry for operation 'UNION' +Illegal parameter data types double and point for operation 'UNION' ------------------------------------- CREATE TABLE t1 (a DECIMAL(10,2), b Point) CREATE TABLE t2 AS SELECT CASE WHEN TRUE THEN a ELSE b END FROM t1 ERROR: -Illegal parameter data types decimal and geometry for operation 'case' +Illegal parameter data types decimal and point for operation 'case' CREATE TABLE t2 AS SELECT COALESCE(a,b) FROM t1 ERROR: -Illegal parameter data types decimal and geometry for operation 'coalesce' +Illegal parameter data types decimal and point for operation 'coalesce' CREATE TABLE t2 AS SELECT IF(TRUE,a,b) FROM t1 ERROR: -Illegal parameter data types decimal and geometry for operation 'if' +Illegal parameter data types decimal and point for operation 'if' CREATE TABLE t2 AS SELECT IFNULL(a,b) FROM t1 ERROR: -Illegal parameter data types decimal and geometry for operation 'ifnull' +Illegal parameter data types decimal and point for operation 'ifnull' CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT b FROM t1 ERROR: -Illegal parameter data types decimal and geometry for operation 'UNION' +Illegal parameter data types decimal and point for operation 'UNION' ------------------------------------- CREATE TABLE t1 (a BIT(8), b Point) CREATE TABLE t2 AS SELECT CASE WHEN TRUE THEN a ELSE b END FROM t1 ERROR: -Illegal parameter data types bigint and geometry for operation 'case' +Illegal parameter data types bigint and point for operation 'case' CREATE TABLE t2 AS SELECT COALESCE(a,b) FROM t1 ERROR: -Illegal parameter data types bigint and geometry for operation 'coalesce' +Illegal parameter data types bigint and point for operation 'coalesce' CREATE TABLE t2 AS SELECT IF(TRUE,a,b) FROM t1 ERROR: -Illegal parameter data types bigint and geometry for operation 'if' +Illegal parameter data types bigint and point for operation 'if' CREATE TABLE t2 AS SELECT IFNULL(a,b) FROM t1 ERROR: -Illegal parameter data types bigint and geometry for operation 'ifnull' +Illegal parameter data types bigint and point for operation 'ifnull' CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT b FROM t1 ERROR: -Illegal parameter data types bit and geometry for operation 'UNION' +Illegal parameter data types bit and point for operation 'UNION' ------------------------------------- CREATE TABLE t1 (a TIME, b Point) CREATE TABLE t2 AS SELECT CASE WHEN TRUE THEN a ELSE b END FROM t1 ERROR: -Illegal parameter data types time and geometry for operation 'case' +Illegal parameter data types time and point for operation 'case' CREATE TABLE t2 AS SELECT COALESCE(a,b) FROM t1 ERROR: -Illegal parameter data types time and geometry for operation 'coalesce' +Illegal parameter data types time and point for operation 'coalesce' CREATE TABLE t2 AS SELECT IF(TRUE,a,b) FROM t1 ERROR: -Illegal parameter data types time and geometry for operation 'if' +Illegal parameter data types time and point for operation 'if' CREATE TABLE t2 AS SELECT IFNULL(a,b) FROM t1 ERROR: -Illegal parameter data types time and geometry for operation 'ifnull' +Illegal parameter data types time and point for operation 'ifnull' CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT b FROM t1 ERROR: -Illegal parameter data types time and geometry for operation 'UNION' +Illegal parameter data types time and point for operation 'UNION' ------------------------------------- CREATE TABLE t1 (a DATE, b Point) CREATE TABLE t2 AS SELECT CASE WHEN TRUE THEN a ELSE b END FROM t1 ERROR: -Illegal parameter data types date and geometry for operation 'case' +Illegal parameter data types date and point for operation 'case' CREATE TABLE t2 AS SELECT COALESCE(a,b) FROM t1 ERROR: -Illegal parameter data types date and geometry for operation 'coalesce' +Illegal parameter data types date and point for operation 'coalesce' CREATE TABLE t2 AS SELECT IF(TRUE,a,b) FROM t1 ERROR: -Illegal parameter data types date and geometry for operation 'if' +Illegal parameter data types date and point for operation 'if' CREATE TABLE t2 AS SELECT IFNULL(a,b) FROM t1 ERROR: -Illegal parameter data types date and geometry for operation 'ifnull' +Illegal parameter data types date and point for operation 'ifnull' CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT b FROM t1 ERROR: -Illegal parameter data types date and geometry for operation 'UNION' +Illegal parameter data types date and point for operation 'UNION' ------------------------------------- CREATE TABLE t1 (a DATETIME, b Point) CREATE TABLE t2 AS SELECT CASE WHEN TRUE THEN a ELSE b END FROM t1 ERROR: -Illegal parameter data types datetime and geometry for operation 'case' +Illegal parameter data types datetime and point for operation 'case' CREATE TABLE t2 AS SELECT COALESCE(a,b) FROM t1 ERROR: -Illegal parameter data types datetime and geometry for operation 'coalesce' +Illegal parameter data types datetime and point for operation 'coalesce' CREATE TABLE t2 AS SELECT IF(TRUE,a,b) FROM t1 ERROR: -Illegal parameter data types datetime and geometry for operation 'if' +Illegal parameter data types datetime and point for operation 'if' CREATE TABLE t2 AS SELECT IFNULL(a,b) FROM t1 ERROR: -Illegal parameter data types datetime and geometry for operation 'ifnull' +Illegal parameter data types datetime and point for operation 'ifnull' CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT b FROM t1 ERROR: -Illegal parameter data types datetime and geometry for operation 'UNION' +Illegal parameter data types datetime and point for operation 'UNION' ------------------------------------- CREATE TABLE t1 (a TIMESTAMP, b Point) CREATE TABLE t2 AS SELECT CASE WHEN TRUE THEN a ELSE b END FROM t1 ERROR: -Illegal parameter data types timestamp and geometry for operation 'case' +Illegal parameter data types timestamp and point for operation 'case' CREATE TABLE t2 AS SELECT COALESCE(a,b) FROM t1 ERROR: -Illegal parameter data types timestamp and geometry for operation 'coalesce' +Illegal parameter data types timestamp and point for operation 'coalesce' CREATE TABLE t2 AS SELECT IF(TRUE,a,b) FROM t1 ERROR: -Illegal parameter data types timestamp and geometry for operation 'if' +Illegal parameter data types timestamp and point for operation 'if' CREATE TABLE t2 AS SELECT IFNULL(a,b) FROM t1 ERROR: -Illegal parameter data types timestamp and geometry for operation 'ifnull' +Illegal parameter data types timestamp and point for operation 'ifnull' CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT b FROM t1 ERROR: -Illegal parameter data types timestamp and geometry for operation 'UNION' +Illegal parameter data types timestamp and point for operation 'UNION' ------------------------------------- CREATE TABLE t1 (a YEAR, b Point) CREATE TABLE t2 AS SELECT CASE WHEN TRUE THEN a ELSE b END FROM t1 ERROR: -Illegal parameter data types year and geometry for operation 'case' +Illegal parameter data types year and point for operation 'case' CREATE TABLE t2 AS SELECT COALESCE(a,b) FROM t1 ERROR: -Illegal parameter data types year and geometry for operation 'coalesce' +Illegal parameter data types year and point for operation 'coalesce' CREATE TABLE t2 AS SELECT IF(TRUE,a,b) FROM t1 ERROR: -Illegal parameter data types year and geometry for operation 'if' +Illegal parameter data types year and point for operation 'if' CREATE TABLE t2 AS SELECT IFNULL(a,b) FROM t1 ERROR: -Illegal parameter data types year and geometry for operation 'ifnull' +Illegal parameter data types year and point for operation 'ifnull' CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT b FROM t1 ERROR: -Illegal parameter data types year and geometry for operation 'UNION' +Illegal parameter data types year and point for operation 'UNION' # This creates BLOB with hybrid functions, but fails on error with UNION (MDEV-11458) ------------------------------------- CREATE TABLE t1 (a ENUM(0x61), b Point) @@ -2838,7 +2838,7 @@ t2 CREATE TABLE `t2` ( CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT b FROM t1 ERROR: -Illegal parameter data types enum and geometry for operation 'UNION' +Illegal parameter data types enum and point for operation 'UNION' ------------------------------------- CREATE TABLE t1 (a SET(0x61), b Point) @@ -2868,7 +2868,7 @@ t2 CREATE TABLE `t2` ( CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT b FROM t1 ERROR: -Illegal parameter data types set and geometry for operation 'UNION' +Illegal parameter data types set and point for operation 'UNION' CREATE TABLE t1 AS SELECT COALESCE(NULL, Point(1,1)); SHOW CREATE TABLE t1; Table Create Table @@ -3155,602 +3155,602 @@ CREATE TABLE t1 (a TINYINT, b Point, c Point) SELECT a=b FROM t1 ERROR: -Illegal parameter data types tinyint and geometry for operation '=' +Illegal parameter data types tinyint and point for operation '=' SELECT b=a FROM t1 ERROR: -Illegal parameter data types geometry and tinyint for operation '=' +Illegal parameter data types point and tinyint for operation '=' SELECT a BETWEEN b AND c FROM t1 ERROR: -Illegal parameter data types tinyint and geometry for operation 'between' +Illegal parameter data types tinyint and point for operation 'between' SELECT a IN (b,c) FROM t1 ERROR: -Illegal parameter data types tinyint and geometry for operation 'in' +Illegal parameter data types tinyint and point for operation 'in' SELECT CASE a WHEN b THEN "a" WHEN c THEN "b" END FROM t1 ERROR: -Illegal parameter data types tinyint and geometry for operation 'case..when' +Illegal parameter data types tinyint and point for operation 'case..when' SELECT a=POINT(1,1) FROM t1 ERROR: -Illegal parameter data types tinyint and geometry for operation '=' +Illegal parameter data types tinyint and point for operation '=' SELECT POINT(1,1)=a FROM t1 ERROR: -Illegal parameter data types geometry and tinyint for operation '=' +Illegal parameter data types point and tinyint for operation '=' SELECT a BETWEEN POINT(1,1) AND POINT(1,2) FROM t1 ERROR: -Illegal parameter data types tinyint and geometry for operation 'between' +Illegal parameter data types tinyint and point for operation 'between' SELECT a IN (POINT(1,1),POINT(1,2)) FROM t1 ERROR: -Illegal parameter data types tinyint and geometry for operation 'in' +Illegal parameter data types tinyint and point for operation 'in' SELECT CASE a WHEN POINT(1,1) THEN "a" WHEN POINT(1,2) THEN "b" END FROM t1 ERROR: -Illegal parameter data types tinyint and geometry for operation 'case..when' +Illegal parameter data types tinyint and point for operation 'case..when' CALL p1('CREATE TABLE t1 (a SMALLINT, b Point, c Point)'); ------------------------------------- CREATE TABLE t1 (a SMALLINT, b Point, c Point) SELECT a=b FROM t1 ERROR: -Illegal parameter data types smallint and geometry for operation '=' +Illegal parameter data types smallint and point for operation '=' SELECT b=a FROM t1 ERROR: -Illegal parameter data types geometry and smallint for operation '=' +Illegal parameter data types point and smallint for operation '=' SELECT a BETWEEN b AND c FROM t1 ERROR: -Illegal parameter data types smallint and geometry for operation 'between' +Illegal parameter data types smallint and point for operation 'between' SELECT a IN (b,c) FROM t1 ERROR: -Illegal parameter data types smallint and geometry for operation 'in' +Illegal parameter data types smallint and point for operation 'in' SELECT CASE a WHEN b THEN "a" WHEN c THEN "b" END FROM t1 ERROR: -Illegal parameter data types smallint and geometry for operation 'case..when' +Illegal parameter data types smallint and point for operation 'case..when' SELECT a=POINT(1,1) FROM t1 ERROR: -Illegal parameter data types smallint and geometry for operation '=' +Illegal parameter data types smallint and point for operation '=' SELECT POINT(1,1)=a FROM t1 ERROR: -Illegal parameter data types geometry and smallint for operation '=' +Illegal parameter data types point and smallint for operation '=' SELECT a BETWEEN POINT(1,1) AND POINT(1,2) FROM t1 ERROR: -Illegal parameter data types smallint and geometry for operation 'between' +Illegal parameter data types smallint and point for operation 'between' SELECT a IN (POINT(1,1),POINT(1,2)) FROM t1 ERROR: -Illegal parameter data types smallint and geometry for operation 'in' +Illegal parameter data types smallint and point for operation 'in' SELECT CASE a WHEN POINT(1,1) THEN "a" WHEN POINT(1,2) THEN "b" END FROM t1 ERROR: -Illegal parameter data types smallint and geometry for operation 'case..when' +Illegal parameter data types smallint and point for operation 'case..when' CALL p1('CREATE TABLE t1 (a MEDIUMINT, b Point, c Point)'); ------------------------------------- CREATE TABLE t1 (a MEDIUMINT, b Point, c Point) SELECT a=b FROM t1 ERROR: -Illegal parameter data types mediumint and geometry for operation '=' +Illegal parameter data types mediumint and point for operation '=' SELECT b=a FROM t1 ERROR: -Illegal parameter data types geometry and mediumint for operation '=' +Illegal parameter data types point and mediumint for operation '=' SELECT a BETWEEN b AND c FROM t1 ERROR: -Illegal parameter data types mediumint and geometry for operation 'between' +Illegal parameter data types mediumint and point for operation 'between' SELECT a IN (b,c) FROM t1 ERROR: -Illegal parameter data types mediumint and geometry for operation 'in' +Illegal parameter data types mediumint and point for operation 'in' SELECT CASE a WHEN b THEN "a" WHEN c THEN "b" END FROM t1 ERROR: -Illegal parameter data types mediumint and geometry for operation 'case..when' +Illegal parameter data types mediumint and point for operation 'case..when' SELECT a=POINT(1,1) FROM t1 ERROR: -Illegal parameter data types mediumint and geometry for operation '=' +Illegal parameter data types mediumint and point for operation '=' SELECT POINT(1,1)=a FROM t1 ERROR: -Illegal parameter data types geometry and mediumint for operation '=' +Illegal parameter data types point and mediumint for operation '=' SELECT a BETWEEN POINT(1,1) AND POINT(1,2) FROM t1 ERROR: -Illegal parameter data types mediumint and geometry for operation 'between' +Illegal parameter data types mediumint and point for operation 'between' SELECT a IN (POINT(1,1),POINT(1,2)) FROM t1 ERROR: -Illegal parameter data types mediumint and geometry for operation 'in' +Illegal parameter data types mediumint and point for operation 'in' SELECT CASE a WHEN POINT(1,1) THEN "a" WHEN POINT(1,2) THEN "b" END FROM t1 ERROR: -Illegal parameter data types mediumint and geometry for operation 'case..when' +Illegal parameter data types mediumint and point for operation 'case..when' CALL p1('CREATE TABLE t1 (a INT, b Point, c Point)'); ------------------------------------- CREATE TABLE t1 (a INT, b Point, c Point) SELECT a=b FROM t1 ERROR: -Illegal parameter data types int and geometry for operation '=' +Illegal parameter data types int and point for operation '=' SELECT b=a FROM t1 ERROR: -Illegal parameter data types geometry and int for operation '=' +Illegal parameter data types point and int for operation '=' SELECT a BETWEEN b AND c FROM t1 ERROR: -Illegal parameter data types int and geometry for operation 'between' +Illegal parameter data types int and point for operation 'between' SELECT a IN (b,c) FROM t1 ERROR: -Illegal parameter data types int and geometry for operation 'in' +Illegal parameter data types int and point for operation 'in' SELECT CASE a WHEN b THEN "a" WHEN c THEN "b" END FROM t1 ERROR: -Illegal parameter data types int and geometry for operation 'case..when' +Illegal parameter data types int and point for operation 'case..when' SELECT a=POINT(1,1) FROM t1 ERROR: -Illegal parameter data types int and geometry for operation '=' +Illegal parameter data types int and point for operation '=' SELECT POINT(1,1)=a FROM t1 ERROR: -Illegal parameter data types geometry and int for operation '=' +Illegal parameter data types point and int for operation '=' SELECT a BETWEEN POINT(1,1) AND POINT(1,2) FROM t1 ERROR: -Illegal parameter data types int and geometry for operation 'between' +Illegal parameter data types int and point for operation 'between' SELECT a IN (POINT(1,1),POINT(1,2)) FROM t1 ERROR: -Illegal parameter data types int and geometry for operation 'in' +Illegal parameter data types int and point for operation 'in' SELECT CASE a WHEN POINT(1,1) THEN "a" WHEN POINT(1,2) THEN "b" END FROM t1 ERROR: -Illegal parameter data types int and geometry for operation 'case..when' +Illegal parameter data types int and point for operation 'case..when' CALL p1('CREATE TABLE t1 (a BIGINT, b Point, c Point)'); ------------------------------------- CREATE TABLE t1 (a BIGINT, b Point, c Point) SELECT a=b FROM t1 ERROR: -Illegal parameter data types bigint and geometry for operation '=' +Illegal parameter data types bigint and point for operation '=' SELECT b=a FROM t1 ERROR: -Illegal parameter data types geometry and bigint for operation '=' +Illegal parameter data types point and bigint for operation '=' SELECT a BETWEEN b AND c FROM t1 ERROR: -Illegal parameter data types bigint and geometry for operation 'between' +Illegal parameter data types bigint and point for operation 'between' SELECT a IN (b,c) FROM t1 ERROR: -Illegal parameter data types bigint and geometry for operation 'in' +Illegal parameter data types bigint and point for operation 'in' SELECT CASE a WHEN b THEN "a" WHEN c THEN "b" END FROM t1 ERROR: -Illegal parameter data types bigint and geometry for operation 'case..when' +Illegal parameter data types bigint and point for operation 'case..when' SELECT a=POINT(1,1) FROM t1 ERROR: -Illegal parameter data types bigint and geometry for operation '=' +Illegal parameter data types bigint and point for operation '=' SELECT POINT(1,1)=a FROM t1 ERROR: -Illegal parameter data types geometry and bigint for operation '=' +Illegal parameter data types point and bigint for operation '=' SELECT a BETWEEN POINT(1,1) AND POINT(1,2) FROM t1 ERROR: -Illegal parameter data types bigint and geometry for operation 'between' +Illegal parameter data types bigint and point for operation 'between' SELECT a IN (POINT(1,1),POINT(1,2)) FROM t1 ERROR: -Illegal parameter data types bigint and geometry for operation 'in' +Illegal parameter data types bigint and point for operation 'in' SELECT CASE a WHEN POINT(1,1) THEN "a" WHEN POINT(1,2) THEN "b" END FROM t1 ERROR: -Illegal parameter data types bigint and geometry for operation 'case..when' +Illegal parameter data types bigint and point for operation 'case..when' CALL p1('CREATE TABLE t1 (a FLOAT, b Point, c Point)'); ------------------------------------- CREATE TABLE t1 (a FLOAT, b Point, c Point) SELECT a=b FROM t1 ERROR: -Illegal parameter data types float and geometry for operation '=' +Illegal parameter data types float and point for operation '=' SELECT b=a FROM t1 ERROR: -Illegal parameter data types geometry and float for operation '=' +Illegal parameter data types point and float for operation '=' SELECT a BETWEEN b AND c FROM t1 ERROR: -Illegal parameter data types float and geometry for operation 'between' +Illegal parameter data types float and point for operation 'between' SELECT a IN (b,c) FROM t1 ERROR: -Illegal parameter data types float and geometry for operation 'in' +Illegal parameter data types float and point for operation 'in' SELECT CASE a WHEN b THEN "a" WHEN c THEN "b" END FROM t1 ERROR: -Illegal parameter data types float and geometry for operation 'case..when' +Illegal parameter data types float and point for operation 'case..when' SELECT a=POINT(1,1) FROM t1 ERROR: -Illegal parameter data types float and geometry for operation '=' +Illegal parameter data types float and point for operation '=' SELECT POINT(1,1)=a FROM t1 ERROR: -Illegal parameter data types geometry and float for operation '=' +Illegal parameter data types point and float for operation '=' SELECT a BETWEEN POINT(1,1) AND POINT(1,2) FROM t1 ERROR: -Illegal parameter data types float and geometry for operation 'between' +Illegal parameter data types float and point for operation 'between' SELECT a IN (POINT(1,1),POINT(1,2)) FROM t1 ERROR: -Illegal parameter data types float and geometry for operation 'in' +Illegal parameter data types float and point for operation 'in' SELECT CASE a WHEN POINT(1,1) THEN "a" WHEN POINT(1,2) THEN "b" END FROM t1 ERROR: -Illegal parameter data types float and geometry for operation 'case..when' +Illegal parameter data types float and point for operation 'case..when' CALL p1('CREATE TABLE t1 (a DOUBLE, b Point, c Point)'); ------------------------------------- CREATE TABLE t1 (a DOUBLE, b Point, c Point) SELECT a=b FROM t1 ERROR: -Illegal parameter data types double and geometry for operation '=' +Illegal parameter data types double and point for operation '=' SELECT b=a FROM t1 ERROR: -Illegal parameter data types geometry and double for operation '=' +Illegal parameter data types point and double for operation '=' SELECT a BETWEEN b AND c FROM t1 ERROR: -Illegal parameter data types double and geometry for operation 'between' +Illegal parameter data types double and point for operation 'between' SELECT a IN (b,c) FROM t1 ERROR: -Illegal parameter data types double and geometry for operation 'in' +Illegal parameter data types double and point for operation 'in' SELECT CASE a WHEN b THEN "a" WHEN c THEN "b" END FROM t1 ERROR: -Illegal parameter data types double and geometry for operation 'case..when' +Illegal parameter data types double and point for operation 'case..when' SELECT a=POINT(1,1) FROM t1 ERROR: -Illegal parameter data types double and geometry for operation '=' +Illegal parameter data types double and point for operation '=' SELECT POINT(1,1)=a FROM t1 ERROR: -Illegal parameter data types geometry and double for operation '=' +Illegal parameter data types point and double for operation '=' SELECT a BETWEEN POINT(1,1) AND POINT(1,2) FROM t1 ERROR: -Illegal parameter data types double and geometry for operation 'between' +Illegal parameter data types double and point for operation 'between' SELECT a IN (POINT(1,1),POINT(1,2)) FROM t1 ERROR: -Illegal parameter data types double and geometry for operation 'in' +Illegal parameter data types double and point for operation 'in' SELECT CASE a WHEN POINT(1,1) THEN "a" WHEN POINT(1,2) THEN "b" END FROM t1 ERROR: -Illegal parameter data types double and geometry for operation 'case..when' +Illegal parameter data types double and point for operation 'case..when' CALL p1('CREATE TABLE t1 (a DECIMAL(10,2), b Point, c Point)'); ------------------------------------- CREATE TABLE t1 (a DECIMAL(10,2), b Point, c Point) SELECT a=b FROM t1 ERROR: -Illegal parameter data types decimal and geometry for operation '=' +Illegal parameter data types decimal and point for operation '=' SELECT b=a FROM t1 ERROR: -Illegal parameter data types geometry and decimal for operation '=' +Illegal parameter data types point and decimal for operation '=' SELECT a BETWEEN b AND c FROM t1 ERROR: -Illegal parameter data types decimal and geometry for operation 'between' +Illegal parameter data types decimal and point for operation 'between' SELECT a IN (b,c) FROM t1 ERROR: -Illegal parameter data types decimal and geometry for operation 'in' +Illegal parameter data types decimal and point for operation 'in' SELECT CASE a WHEN b THEN "a" WHEN c THEN "b" END FROM t1 ERROR: -Illegal parameter data types decimal and geometry for operation 'case..when' +Illegal parameter data types decimal and point for operation 'case..when' SELECT a=POINT(1,1) FROM t1 ERROR: -Illegal parameter data types decimal and geometry for operation '=' +Illegal parameter data types decimal and point for operation '=' SELECT POINT(1,1)=a FROM t1 ERROR: -Illegal parameter data types geometry and decimal for operation '=' +Illegal parameter data types point and decimal for operation '=' SELECT a BETWEEN POINT(1,1) AND POINT(1,2) FROM t1 ERROR: -Illegal parameter data types decimal and geometry for operation 'between' +Illegal parameter data types decimal and point for operation 'between' SELECT a IN (POINT(1,1),POINT(1,2)) FROM t1 ERROR: -Illegal parameter data types decimal and geometry for operation 'in' +Illegal parameter data types decimal and point for operation 'in' SELECT CASE a WHEN POINT(1,1) THEN "a" WHEN POINT(1,2) THEN "b" END FROM t1 ERROR: -Illegal parameter data types decimal and geometry for operation 'case..when' +Illegal parameter data types decimal and point for operation 'case..when' CALL p1('CREATE TABLE t1 (a BIT(8), b Point, c Point)'); ------------------------------------- CREATE TABLE t1 (a BIT(8), b Point, c Point) SELECT a=b FROM t1 ERROR: -Illegal parameter data types bit and geometry for operation '=' +Illegal parameter data types bit and point for operation '=' SELECT b=a FROM t1 ERROR: -Illegal parameter data types geometry and bit for operation '=' +Illegal parameter data types point and bit for operation '=' SELECT a BETWEEN b AND c FROM t1 ERROR: -Illegal parameter data types bit and geometry for operation 'between' +Illegal parameter data types bit and point for operation 'between' SELECT a IN (b,c) FROM t1 ERROR: -Illegal parameter data types bit and geometry for operation 'in' +Illegal parameter data types bit and point for operation 'in' SELECT CASE a WHEN b THEN "a" WHEN c THEN "b" END FROM t1 ERROR: -Illegal parameter data types bit and geometry for operation 'case..when' +Illegal parameter data types bit and point for operation 'case..when' SELECT a=POINT(1,1) FROM t1 ERROR: -Illegal parameter data types bit and geometry for operation '=' +Illegal parameter data types bit and point for operation '=' SELECT POINT(1,1)=a FROM t1 ERROR: -Illegal parameter data types geometry and bit for operation '=' +Illegal parameter data types point and bit for operation '=' SELECT a BETWEEN POINT(1,1) AND POINT(1,2) FROM t1 ERROR: -Illegal parameter data types bit and geometry for operation 'between' +Illegal parameter data types bit and point for operation 'between' SELECT a IN (POINT(1,1),POINT(1,2)) FROM t1 ERROR: -Illegal parameter data types bit and geometry for operation 'in' +Illegal parameter data types bit and point for operation 'in' SELECT CASE a WHEN POINT(1,1) THEN "a" WHEN POINT(1,2) THEN "b" END FROM t1 ERROR: -Illegal parameter data types bit and geometry for operation 'case..when' +Illegal parameter data types bit and point for operation 'case..when' CALL p1('CREATE TABLE t1 (a TIME, b Point, c Point)'); ------------------------------------- CREATE TABLE t1 (a TIME, b Point, c Point) SELECT a=b FROM t1 ERROR: -Illegal parameter data types time and geometry for operation '=' +Illegal parameter data types time and point for operation '=' SELECT b=a FROM t1 ERROR: -Illegal parameter data types geometry and time for operation '=' +Illegal parameter data types point and time for operation '=' SELECT a BETWEEN b AND c FROM t1 ERROR: -Illegal parameter data types time and geometry for operation 'between' +Illegal parameter data types time and point for operation 'between' SELECT a IN (b,c) FROM t1 ERROR: -Illegal parameter data types time and geometry for operation 'in' +Illegal parameter data types time and point for operation 'in' SELECT CASE a WHEN b THEN "a" WHEN c THEN "b" END FROM t1 ERROR: -Illegal parameter data types time and geometry for operation 'case..when' +Illegal parameter data types time and point for operation 'case..when' SELECT a=POINT(1,1) FROM t1 ERROR: -Illegal parameter data types time and geometry for operation '=' +Illegal parameter data types time and point for operation '=' SELECT POINT(1,1)=a FROM t1 ERROR: -Illegal parameter data types geometry and time for operation '=' +Illegal parameter data types point and time for operation '=' SELECT a BETWEEN POINT(1,1) AND POINT(1,2) FROM t1 ERROR: -Illegal parameter data types time and geometry for operation 'between' +Illegal parameter data types time and point for operation 'between' SELECT a IN (POINT(1,1),POINT(1,2)) FROM t1 ERROR: -Illegal parameter data types time and geometry for operation 'in' +Illegal parameter data types time and point for operation 'in' SELECT CASE a WHEN POINT(1,1) THEN "a" WHEN POINT(1,2) THEN "b" END FROM t1 ERROR: -Illegal parameter data types time and geometry for operation 'case..when' +Illegal parameter data types time and point for operation 'case..when' CALL p1('CREATE TABLE t1 (a DATE, b Point, c Point)'); ------------------------------------- CREATE TABLE t1 (a DATE, b Point, c Point) SELECT a=b FROM t1 ERROR: -Illegal parameter data types date and geometry for operation '=' +Illegal parameter data types date and point for operation '=' SELECT b=a FROM t1 ERROR: -Illegal parameter data types geometry and date for operation '=' +Illegal parameter data types point and date for operation '=' SELECT a BETWEEN b AND c FROM t1 ERROR: -Illegal parameter data types date and geometry for operation 'between' +Illegal parameter data types date and point for operation 'between' SELECT a IN (b,c) FROM t1 ERROR: -Illegal parameter data types date and geometry for operation 'in' +Illegal parameter data types date and point for operation 'in' SELECT CASE a WHEN b THEN "a" WHEN c THEN "b" END FROM t1 ERROR: -Illegal parameter data types date and geometry for operation 'case..when' +Illegal parameter data types date and point for operation 'case..when' SELECT a=POINT(1,1) FROM t1 ERROR: -Illegal parameter data types date and geometry for operation '=' +Illegal parameter data types date and point for operation '=' SELECT POINT(1,1)=a FROM t1 ERROR: -Illegal parameter data types geometry and date for operation '=' +Illegal parameter data types point and date for operation '=' SELECT a BETWEEN POINT(1,1) AND POINT(1,2) FROM t1 ERROR: -Illegal parameter data types date and geometry for operation 'between' +Illegal parameter data types date and point for operation 'between' SELECT a IN (POINT(1,1),POINT(1,2)) FROM t1 ERROR: -Illegal parameter data types date and geometry for operation 'in' +Illegal parameter data types date and point for operation 'in' SELECT CASE a WHEN POINT(1,1) THEN "a" WHEN POINT(1,2) THEN "b" END FROM t1 ERROR: -Illegal parameter data types date and geometry for operation 'case..when' +Illegal parameter data types date and point for operation 'case..when' CALL p1('CREATE TABLE t1 (a DATETIME, b Point, c Point)'); ------------------------------------- CREATE TABLE t1 (a DATETIME, b Point, c Point) SELECT a=b FROM t1 ERROR: -Illegal parameter data types datetime and geometry for operation '=' +Illegal parameter data types datetime and point for operation '=' SELECT b=a FROM t1 ERROR: -Illegal parameter data types geometry and datetime for operation '=' +Illegal parameter data types point and datetime for operation '=' SELECT a BETWEEN b AND c FROM t1 ERROR: -Illegal parameter data types datetime and geometry for operation 'between' +Illegal parameter data types datetime and point for operation 'between' SELECT a IN (b,c) FROM t1 ERROR: -Illegal parameter data types datetime and geometry for operation 'in' +Illegal parameter data types datetime and point for operation 'in' SELECT CASE a WHEN b THEN "a" WHEN c THEN "b" END FROM t1 ERROR: -Illegal parameter data types datetime and geometry for operation 'case..when' +Illegal parameter data types datetime and point for operation 'case..when' SELECT a=POINT(1,1) FROM t1 ERROR: -Illegal parameter data types datetime and geometry for operation '=' +Illegal parameter data types datetime and point for operation '=' SELECT POINT(1,1)=a FROM t1 ERROR: -Illegal parameter data types geometry and datetime for operation '=' +Illegal parameter data types point and datetime for operation '=' SELECT a BETWEEN POINT(1,1) AND POINT(1,2) FROM t1 ERROR: -Illegal parameter data types datetime and geometry for operation 'between' +Illegal parameter data types datetime and point for operation 'between' SELECT a IN (POINT(1,1),POINT(1,2)) FROM t1 ERROR: -Illegal parameter data types datetime and geometry for operation 'in' +Illegal parameter data types datetime and point for operation 'in' SELECT CASE a WHEN POINT(1,1) THEN "a" WHEN POINT(1,2) THEN "b" END FROM t1 ERROR: -Illegal parameter data types datetime and geometry for operation 'case..when' +Illegal parameter data types datetime and point for operation 'case..when' CALL p1('CREATE TABLE t1 (a TIMESTAMP, b Point, c Point)'); ------------------------------------- CREATE TABLE t1 (a TIMESTAMP, b Point, c Point) SELECT a=b FROM t1 ERROR: -Illegal parameter data types timestamp and geometry for operation '=' +Illegal parameter data types timestamp and point for operation '=' SELECT b=a FROM t1 ERROR: -Illegal parameter data types geometry and timestamp for operation '=' +Illegal parameter data types point and timestamp for operation '=' SELECT a BETWEEN b AND c FROM t1 ERROR: -Illegal parameter data types timestamp and geometry for operation 'between' +Illegal parameter data types timestamp and point for operation 'between' SELECT a IN (b,c) FROM t1 ERROR: -Illegal parameter data types timestamp and geometry for operation 'in' +Illegal parameter data types timestamp and point for operation 'in' SELECT CASE a WHEN b THEN "a" WHEN c THEN "b" END FROM t1 ERROR: -Illegal parameter data types timestamp and geometry for operation 'case..when' +Illegal parameter data types timestamp and point for operation 'case..when' SELECT a=POINT(1,1) FROM t1 ERROR: -Illegal parameter data types timestamp and geometry for operation '=' +Illegal parameter data types timestamp and point for operation '=' SELECT POINT(1,1)=a FROM t1 ERROR: -Illegal parameter data types geometry and timestamp for operation '=' +Illegal parameter data types point and timestamp for operation '=' SELECT a BETWEEN POINT(1,1) AND POINT(1,2) FROM t1 ERROR: -Illegal parameter data types timestamp and geometry for operation 'between' +Illegal parameter data types timestamp and point for operation 'between' SELECT a IN (POINT(1,1),POINT(1,2)) FROM t1 ERROR: -Illegal parameter data types timestamp and geometry for operation 'in' +Illegal parameter data types timestamp and point for operation 'in' SELECT CASE a WHEN POINT(1,1) THEN "a" WHEN POINT(1,2) THEN "b" END FROM t1 ERROR: -Illegal parameter data types timestamp and geometry for operation 'case..when' +Illegal parameter data types timestamp and point for operation 'case..when' CALL p1('CREATE TABLE t1 (a YEAR, b Point, c Point)'); ------------------------------------- CREATE TABLE t1 (a YEAR, b Point, c Point) SELECT a=b FROM t1 ERROR: -Illegal parameter data types year and geometry for operation '=' +Illegal parameter data types year and point for operation '=' SELECT b=a FROM t1 ERROR: -Illegal parameter data types geometry and year for operation '=' +Illegal parameter data types point and year for operation '=' SELECT a BETWEEN b AND c FROM t1 ERROR: -Illegal parameter data types year and geometry for operation 'between' +Illegal parameter data types year and point for operation 'between' SELECT a IN (b,c) FROM t1 ERROR: -Illegal parameter data types year and geometry for operation 'in' +Illegal parameter data types year and point for operation 'in' SELECT CASE a WHEN b THEN "a" WHEN c THEN "b" END FROM t1 ERROR: -Illegal parameter data types year and geometry for operation 'case..when' +Illegal parameter data types year and point for operation 'case..when' SELECT a=POINT(1,1) FROM t1 ERROR: -Illegal parameter data types year and geometry for operation '=' +Illegal parameter data types year and point for operation '=' SELECT POINT(1,1)=a FROM t1 ERROR: -Illegal parameter data types geometry and year for operation '=' +Illegal parameter data types point and year for operation '=' SELECT a BETWEEN POINT(1,1) AND POINT(1,2) FROM t1 ERROR: -Illegal parameter data types year and geometry for operation 'between' +Illegal parameter data types year and point for operation 'between' SELECT a IN (POINT(1,1),POINT(1,2)) FROM t1 ERROR: -Illegal parameter data types year and geometry for operation 'in' +Illegal parameter data types year and point for operation 'in' SELECT CASE a WHEN POINT(1,1) THEN "a" WHEN POINT(1,2) THEN "b" END FROM t1 ERROR: -Illegal parameter data types year and geometry for operation 'case..when' +Illegal parameter data types year and point for operation 'case..when' CALL p1('CREATE TABLE t1 (a Point, b Point, c Point)'); ------------------------------------- CREATE TABLE t1 (a Point, b Point, c Point) @@ -3869,85 +3869,85 @@ CREATE TABLE t1 (a TINYINT, b Point) CREATE TABLE t2 AS SELECT LEAST(a,b) FROM t1 ERROR: -Illegal parameter data types tinyint and geometry for operation 'least' +Illegal parameter data types tinyint and point for operation 'least' ------------------------------------- CREATE TABLE t1 (a SMALLINT, b Point) CREATE TABLE t2 AS SELECT LEAST(a,b) FROM t1 ERROR: -Illegal parameter data types smallint and geometry for operation 'least' +Illegal parameter data types smallint and point for operation 'least' ------------------------------------- CREATE TABLE t1 (a MEDIUMINT, b Point) CREATE TABLE t2 AS SELECT LEAST(a,b) FROM t1 ERROR: -Illegal parameter data types mediumint and geometry for operation 'least' +Illegal parameter data types mediumint and point for operation 'least' ------------------------------------- CREATE TABLE t1 (a INT, b Point) CREATE TABLE t2 AS SELECT LEAST(a,b) FROM t1 ERROR: -Illegal parameter data types int and geometry for operation 'least' +Illegal parameter data types int and point for operation 'least' ------------------------------------- CREATE TABLE t1 (a BIGINT, b Point) CREATE TABLE t2 AS SELECT LEAST(a,b) FROM t1 ERROR: -Illegal parameter data types bigint and geometry for operation 'least' +Illegal parameter data types bigint and point for operation 'least' ------------------------------------- CREATE TABLE t1 (a FLOAT, b Point) CREATE TABLE t2 AS SELECT LEAST(a,b) FROM t1 ERROR: -Illegal parameter data types float and geometry for operation 'least' +Illegal parameter data types float and point for operation 'least' ------------------------------------- CREATE TABLE t1 (a DOUBLE, b Point) CREATE TABLE t2 AS SELECT LEAST(a,b) FROM t1 ERROR: -Illegal parameter data types double and geometry for operation 'least' +Illegal parameter data types double and point for operation 'least' ------------------------------------- CREATE TABLE t1 (a DECIMAL(10,2), b Point) CREATE TABLE t2 AS SELECT LEAST(a,b) FROM t1 ERROR: -Illegal parameter data types decimal and geometry for operation 'least' +Illegal parameter data types decimal and point for operation 'least' ------------------------------------- CREATE TABLE t1 (a BIT(8), b Point) CREATE TABLE t2 AS SELECT LEAST(a,b) FROM t1 ERROR: -Illegal parameter data types bit and geometry for operation 'least' +Illegal parameter data types bit and point for operation 'least' ------------------------------------- CREATE TABLE t1 (a TIME, b Point) CREATE TABLE t2 AS SELECT LEAST(a,b) FROM t1 ERROR: -Illegal parameter data types time and geometry for operation 'least' +Illegal parameter data types time and point for operation 'least' ------------------------------------- CREATE TABLE t1 (a DATE, b Point) CREATE TABLE t2 AS SELECT LEAST(a,b) FROM t1 ERROR: -Illegal parameter data types date and geometry for operation 'least' +Illegal parameter data types date and point for operation 'least' ------------------------------------- CREATE TABLE t1 (a DATETIME, b Point) CREATE TABLE t2 AS SELECT LEAST(a,b) FROM t1 ERROR: -Illegal parameter data types datetime and geometry for operation 'least' +Illegal parameter data types datetime and point for operation 'least' ------------------------------------- CREATE TABLE t1 (a TIMESTAMP, b Point) CREATE TABLE t2 AS SELECT LEAST(a,b) FROM t1 ERROR: -Illegal parameter data types timestamp and geometry for operation 'least' +Illegal parameter data types timestamp and point for operation 'least' ------------------------------------- CREATE TABLE t1 (a YEAR, b Point) CREATE TABLE t2 AS SELECT LEAST(a,b) FROM t1 ERROR: -Illegal parameter data types year and geometry for operation 'least' +Illegal parameter data types year and point for operation 'least' # This LEAST(ENUM,GEOMETRY) creates BLOB, but fails on error with UNION (see MDEV-12503) ------------------------------------- CREATE TABLE t1 (a ENUM(0x61), b Point) @@ -3982,7 +3982,7 @@ SELECT ROUND(a) FROM t1; ERROR HY000: Illegal parameter data type geometry for operation 'round' DROP TABLE t1; SELECT ROUND(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'round' +ERROR HY000: Illegal parameter data type point for operation 'round' # # MDEV-12199 Split Item_func_{abs|neg|int_val}::fix_length_and_dec() into methods in Type_handler # @@ -4005,37 +4005,37 @@ SELECT FLOOR(COALESCE(a)) FROM t1; ERROR HY000: Illegal parameter data type geometry for operation 'floor' DROP TABLE t1; SELECT -POINT(1,1); -ERROR HY000: Illegal parameter data type geometry for operation '-' +ERROR HY000: Illegal parameter data type point for operation '-' SELECT ABS(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'abs' +ERROR HY000: Illegal parameter data type point for operation 'abs' SELECT CEILING(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'ceiling' +ERROR HY000: Illegal parameter data type point for operation 'ceiling' SELECT FLOOR(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'floor' +ERROR HY000: Illegal parameter data type point for operation 'floor' # # MDEV-12239 Add Type_handler::Item_sum_{sum|avg|variance}_fix_length_and_dec() # CREATE TABLE t1 (a GEOMETRY); SELECT SUM(POINT(1,1)) FROM t1; -ERROR HY000: Illegal parameter data type geometry for operation 'sum' +ERROR HY000: Illegal parameter data type point for operation 'sum' SELECT SUM(a) FROM t1; ERROR HY000: Illegal parameter data type geometry for operation 'sum' SELECT SUM(COALESCE(a)) FROM t1; ERROR HY000: Illegal parameter data type geometry for operation 'sum' SELECT AVG(POINT(1,1)) FROM t1; -ERROR HY000: Illegal parameter data type geometry for operation 'avg' +ERROR HY000: Illegal parameter data type point for operation 'avg' SELECT AVG(a) FROM t1; ERROR HY000: Illegal parameter data type geometry for operation 'avg' SELECT AVG(COALESCE(a)) FROM t1; ERROR HY000: Illegal parameter data type geometry for operation 'avg' SELECT VARIANCE(POINT(1,1)) FROM t1; -ERROR HY000: Illegal parameter data type geometry for operation 'variance(' +ERROR HY000: Illegal parameter data type point for operation 'variance(' SELECT VARIANCE(a) FROM t1; ERROR HY000: Illegal parameter data type geometry for operation 'variance(' SELECT VARIANCE(COALESCE(a)) FROM t1; ERROR HY000: Illegal parameter data type geometry for operation 'variance(' SELECT STDDEV(POINT(1,1)) FROM t1; -ERROR HY000: Illegal parameter data type geometry for operation 'std(' +ERROR HY000: Illegal parameter data type point for operation 'std(' SELECT STDDEV(a) FROM t1; ERROR HY000: Illegal parameter data type geometry for operation 'std(' SELECT STDDEV(COALESCE(a)) FROM t1; @@ -4046,23 +4046,23 @@ DROP TABLE t1; # CREATE TABLE t1 (a GEOMETRY); SELECT CAST(POINT(1,1) AS SIGNED) FROM t1; -ERROR HY000: Illegal parameter data type geometry for operation 'cast_as_signed' +ERROR HY000: Illegal parameter data type point for operation 'cast_as_signed' SELECT CAST(POINT(1,1) AS UNSIGNED) FROM t1; -ERROR HY000: Illegal parameter data type geometry for operation 'cast_as_unsigned' +ERROR HY000: Illegal parameter data type point for operation 'cast_as_unsigned' SELECT CAST(POINT(1,1) AS FLOAT) FROM t1; -ERROR HY000: Illegal parameter data type geometry for operation 'float_typecast' +ERROR HY000: Illegal parameter data type point for operation 'float_typecast' SELECT CAST(POINT(1,1) AS DOUBLE) FROM t1; -ERROR HY000: Illegal parameter data type geometry for operation 'double_typecast' +ERROR HY000: Illegal parameter data type point for operation 'double_typecast' SELECT CAST(POINT(1,1) AS DECIMAL(10,1)) FROM t1; -ERROR HY000: Illegal parameter data type geometry for operation 'decimal_typecast' +ERROR HY000: Illegal parameter data type point for operation 'decimal_typecast' SELECT CAST(POINT(1,1) AS CHAR) FROM t1; -ERROR HY000: Illegal parameter data type geometry for operation 'cast_as_char' +ERROR HY000: Illegal parameter data type point for operation 'cast_as_char' SELECT CAST(POINT(1,1) AS TIME) FROM t1; -ERROR HY000: Illegal parameter data type geometry for operation 'cast_as_time' +ERROR HY000: Illegal parameter data type point for operation 'cast_as_time' SELECT CAST(POINT(1,1) AS DATE) FROM t1; -ERROR HY000: Illegal parameter data type geometry for operation 'cast_as_date' +ERROR HY000: Illegal parameter data type point for operation 'cast_as_date' SELECT CAST(POINT(1,1) AS DATETIME) FROM t1; -ERROR HY000: Illegal parameter data type geometry for operation 'cast_as_datetime' +ERROR HY000: Illegal parameter data type point for operation 'cast_as_datetime' SELECT CAST(a AS SIGNED) FROM t1; ERROR HY000: Illegal parameter data type geometry for operation 'cast_as_signed' SELECT CAST(a AS UNSIGNED) FROM t1; @@ -4111,25 +4111,25 @@ DROP TABLE t1; # CREATE TABLE t1 (a GEOMETRY); SELECT POINT(1,1) + 1; -ERROR HY000: Illegal parameter data types geometry and int for operation '+' +ERROR HY000: Illegal parameter data types point and int for operation '+' SELECT POINT(1,1) - 1; -ERROR HY000: Illegal parameter data types geometry and int for operation '-' +ERROR HY000: Illegal parameter data types point and int for operation '-' SELECT POINT(1,1) * 1; -ERROR HY000: Illegal parameter data types geometry and int for operation '*' +ERROR HY000: Illegal parameter data types point and int for operation '*' SELECT POINT(1,1) / 1; -ERROR HY000: Illegal parameter data types geometry and int for operation '/' +ERROR HY000: Illegal parameter data types point and int for operation '/' SELECT POINT(1,1) MOD 1; -ERROR HY000: Illegal parameter data types geometry and int for operation 'MOD' +ERROR HY000: Illegal parameter data types point and int for operation 'MOD' SELECT 1 + POINT(1,1); -ERROR HY000: Illegal parameter data types int and geometry for operation '+' +ERROR HY000: Illegal parameter data types int and point for operation '+' SELECT 1 - POINT(1,1); -ERROR HY000: Illegal parameter data types int and geometry for operation '-' +ERROR HY000: Illegal parameter data types int and point for operation '-' SELECT 1 * POINT(1,1); -ERROR HY000: Illegal parameter data types int and geometry for operation '*' +ERROR HY000: Illegal parameter data types int and point for operation '*' SELECT 1 / POINT(1,1); -ERROR HY000: Illegal parameter data types int and geometry for operation '/' +ERROR HY000: Illegal parameter data types int and point for operation '/' SELECT 1 MOD POINT(1,1); -ERROR HY000: Illegal parameter data types int and geometry for operation 'MOD' +ERROR HY000: Illegal parameter data types int and point for operation 'MOD' SELECT a + 1 FROM t1; ERROR HY000: Illegal parameter data types geometry and int for operation '+' SELECT a - 1 FROM t1; @@ -4175,33 +4175,33 @@ DROP TABLE t1; # MDEV-12514 Split Item_temporal_func::fix_length_and_dec() # SELECT DATE_ADD(POINT(1,1), INTERVAL 10 DAY); -ERROR HY000: Illegal parameter data types geometry and interval for operation 'date_add_interval' +ERROR HY000: Illegal parameter data types point and interval for operation 'date_add_interval' SELECT DATE_SUB(POINT(1,1), INTERVAL 10 DAY); -ERROR HY000: Illegal parameter data types geometry and interval for operation 'date_add_interval' +ERROR HY000: Illegal parameter data types point and interval for operation 'date_add_interval' SELECT POINT(1,1) + INTERVAL 10 DAY; -ERROR HY000: Illegal parameter data types geometry and interval for operation 'date_add_interval' +ERROR HY000: Illegal parameter data types point and interval for operation 'date_add_interval' SELECT POINT(1,1) - INTERVAL 10 DAY; -ERROR HY000: Illegal parameter data types geometry and interval for operation 'date_add_interval' +ERROR HY000: Illegal parameter data types point and interval for operation 'date_add_interval' SELECT INTERVAL 10 DAY + POINT(1,1); -ERROR HY000: Illegal parameter data types geometry and interval for operation 'date_add_interval' +ERROR HY000: Illegal parameter data types point and interval for operation 'date_add_interval' SELECT INTERVAL 10 DAY + POINT(1,1); -ERROR HY000: Illegal parameter data types geometry and interval for operation 'date_add_interval' +ERROR HY000: Illegal parameter data types point and interval for operation 'date_add_interval' SELECT ADDTIME(POINT(1,1), '10:10:10'); -ERROR HY000: Illegal parameter data types geometry and varchar for operation 'addtime' +ERROR HY000: Illegal parameter data types point and varchar for operation 'addtime' SELECT ADDTIME('10:10:10', POINT(1,1)); -ERROR HY000: Illegal parameter data types varchar and geometry for operation 'addtime' +ERROR HY000: Illegal parameter data types varchar and point for operation 'addtime' SELECT ADDTIME(POINT(1,1), TIME'10:10:10'); -ERROR HY000: Illegal parameter data types geometry and time for operation 'addtime' +ERROR HY000: Illegal parameter data types point and time for operation 'addtime' SELECT ADDTIME(TIME'10:10:10', POINT(1,1)); -ERROR HY000: Illegal parameter data types time and geometry for operation 'addtime' +ERROR HY000: Illegal parameter data types time and point for operation 'addtime' SELECT ADDTIME(POINT(1,1), TIMESTAMP'2001-01-01 10:10:10'); -ERROR HY000: Illegal parameter data types geometry and datetime for operation 'addtime' +ERROR HY000: Illegal parameter data types point and datetime for operation 'addtime' SELECT ADDTIME(TIMESTAMP'2001-01-01 10:10:10', POINT(1,1)); -ERROR HY000: Illegal parameter data types datetime and geometry for operation 'addtime' +ERROR HY000: Illegal parameter data types datetime and point for operation 'addtime' SELECT STR_TO_DATE(POINT(1,1),'%M %d,%Y'); -ERROR HY000: Illegal parameter data types geometry and varchar for operation 'str_to_date' +ERROR HY000: Illegal parameter data types point and varchar for operation 'str_to_date' SELECT STR_TO_DATE('2001-01-01', POINT(1,1)); -ERROR HY000: Illegal parameter data types varchar and geometry for operation 'str_to_date' +ERROR HY000: Illegal parameter data types varchar and point for operation 'str_to_date' # # MDEV-12665 Hybrid functions do not preserve geometry type # @@ -4442,11 +4442,11 @@ ERROR HY000: Illegal parameter data type int for operation 'st_pointonsurface' SELECT ST_POINTN(1,1); ERROR HY000: Illegal parameter data type int for operation 'st_pointn' SELECT ST_POINTN(LineString(Point(1,1)),Point(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'st_pointn' +ERROR HY000: Illegal parameter data type point for operation 'st_pointn' SELECT ST_BUFFER(1, 1); ERROR HY000: Illegal parameter data type int for operation 'st_buffer' SELECT ST_BUFFER(Point(1,1), Point(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'st_buffer' +ERROR HY000: Illegal parameter data type point for operation 'st_buffer' PREPARE stmt FROM 'CREATE TABLE t1 AS SELECT ST_ENVELOPE(?) AS g'; EXECUTE stmt USING 1; ERROR HY000: Illegal parameter data type int for operation 'st_envelope' @@ -4465,7 +4465,7 @@ PREPARE stmt FROM 'CREATE TABLE t1 AS SELECT ST_BUFFER(?,?) AS g'; EXECUTE stmt USING 1,1; ERROR HY000: Illegal parameter data type int for operation 'st_buffer' EXECUTE stmt USING POINT(1,1),POINT(1,1); -ERROR HY000: Illegal parameter data type geometry for operation 'st_buffer' +ERROR HY000: Illegal parameter data type point for operation 'st_buffer' EXECUTE stmt USING POINT(1,1),0; SHOW CREATE TABLE t1; Table Create Table @@ -4483,11 +4483,11 @@ DEALLOCATE PREPARE stmt; SELECT ST_GEOMETRYFROMTEXT(ROW(1,1)); ERROR HY000: Illegal parameter data type row for operation 'st_geometryfromtext' SELECT ST_GEOMETRYFROMTEXT(Point(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'st_geometryfromtext' +ERROR HY000: Illegal parameter data type point for operation 'st_geometryfromtext' SELECT ST_GEOMETRYFROMTEXT(Point(1,1), 1); -ERROR HY000: Illegal parameter data type geometry for operation 'st_geometryfromtext' +ERROR HY000: Illegal parameter data type point for operation 'st_geometryfromtext' SELECT ST_GEOMETRYFROMTEXT('test', Point(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'st_geometryfromtext' +ERROR HY000: Illegal parameter data type point for operation 'st_geometryfromtext' SELECT ST_GEOMETRYFROMWKB(ROW(1,1)); ERROR HY000: Illegal parameter data type row for operation 'st_geometryfromwkb' SELECT ST_GEOMETRYFROMWKB(1); @@ -4495,7 +4495,7 @@ ERROR HY000: Illegal parameter data type int for operation 'st_geometryfromwkb' SELECT ST_GEOMETRYFROMWKB(1, 1); ERROR HY000: Illegal parameter data type int for operation 'st_geometryfromwkb' SELECT ST_GEOMETRYFROMWKB(Point(1,1), Point(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'st_geometryfromwkb' +ERROR HY000: Illegal parameter data type point for operation 'st_geometryfromwkb' SELECT ST_GEOMFROMGEOJSON(ROW(1,1)); ERROR HY000: Illegal parameter data type row for operation 'st_geomfromgeojson' SELECT ST_GEOMFROMGEOJSON(1); @@ -4503,20 +4503,20 @@ ERROR HY000: Illegal parameter data type int for operation 'st_geomfromgeojson' SELECT ST_GEOMFROMGEOJSON(1,1); ERROR HY000: Illegal parameter data type int for operation 'st_geomfromgeojson' SELECT ST_GEOMFROMGEOJSON(Point(1,1), Point(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'st_geomfromgeojson' +ERROR HY000: Illegal parameter data type point for operation 'st_geomfromgeojson' SELECT POINT(ROW(1,1),1); ERROR HY000: Illegal parameter data type row for operation 'point' SELECT POINT(POINT(1,1),1); -ERROR HY000: Illegal parameter data type geometry for operation 'point' +ERROR HY000: Illegal parameter data type point for operation 'point' SELECT POINT(1,ROW(1,1)); ERROR HY000: Illegal parameter data type row for operation 'point' SELECT POINT(1,POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'point' +ERROR HY000: Illegal parameter data type point for operation 'point' PREPARE stmt FROM 'CREATE TABLE t1 AS SELECT ST_GEOMFROMTEXT(?,?) AS g'; EXECUTE stmt USING 1,1; ERROR HY000: Illegal parameter data type int for operation 'st_geometryfromtext' EXECUTE stmt USING POINT(1,1),POINT(1,1); -ERROR HY000: Illegal parameter data type geometry for operation 'st_geometryfromtext' +ERROR HY000: Illegal parameter data type point for operation 'st_geometryfromtext' EXECUTE stmt USING 'POINT(1 1)',1; SHOW CREATE TABLE t1; Table Create Table @@ -4677,7 +4677,7 @@ ERROR HY000: Illegal parameter data type date for operation 'st_relate' SELECT ST_RELATE(Point(1,1),Point(1,1),TIMESTAMP'2010-01-01 10:10:10'); ERROR HY000: Illegal parameter data type datetime for operation 'st_relate' SELECT ST_RELATE(Point(1,1),Point(1,1),Point(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'st_relate' +ERROR HY000: Illegal parameter data type point for operation 'st_relate' # Item_str_ascii_func_args_geometry SELECT ST_ASTEXT(ROW(1,1)); ERROR HY000: Illegal parameter data type row for operation 'st_astext' @@ -4698,9 +4698,9 @@ ERROR HY000: Illegal parameter data type int for operation 'st_asgeojson' SELECT ST_ASGEOJSON('test'); ERROR HY000: Illegal parameter data type varchar for operation 'st_asgeojson' SELECT ST_ASGEOJSON(POINT(1,1), POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'st_asgeojson' +ERROR HY000: Illegal parameter data type point for operation 'st_asgeojson' SELECT ST_ASGEOJSON(POINT(1,1), 1, POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'st_asgeojson' +ERROR HY000: Illegal parameter data type point for operation 'st_asgeojson' # Item_func_spatial_rel SELECT ST_TOUCHES(ROW(1,1), POINT(1,1)); ERROR HY000: Illegal parameter data type row for operation 'st_touches' @@ -4730,47 +4730,47 @@ ERROR HY000: Illegal parameter data type varchar for operation 'st_touches' # MDEV-13964 Parameter data type control for Item_real_func # SELECT EXP(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'exp' +ERROR HY000: Illegal parameter data type point for operation 'exp' SELECT LN(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'ln' +ERROR HY000: Illegal parameter data type point for operation 'ln' SELECT LOG2(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'log2' +ERROR HY000: Illegal parameter data type point for operation 'log2' SELECT LOG10(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'log10' +ERROR HY000: Illegal parameter data type point for operation 'log10' SELECT SQRT(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'sqrt' +ERROR HY000: Illegal parameter data type point for operation 'sqrt' SELECT ACOS(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'acos' +ERROR HY000: Illegal parameter data type point for operation 'acos' SELECT ASIN(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'asin' +ERROR HY000: Illegal parameter data type point for operation 'asin' SELECT COS(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'cos' +ERROR HY000: Illegal parameter data type point for operation 'cos' SELECT SIN(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'sin' +ERROR HY000: Illegal parameter data type point for operation 'sin' SELECT TAN(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'tan' +ERROR HY000: Illegal parameter data type point for operation 'tan' SELECT COT(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'cot' +ERROR HY000: Illegal parameter data type point for operation 'cot' SELECT LOG(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'log' +ERROR HY000: Illegal parameter data type point for operation 'log' SELECT LOG(POINT(1,1),POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'log' +ERROR HY000: Illegal parameter data type point for operation 'log' SELECT LOG(1, POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'log' +ERROR HY000: Illegal parameter data type point for operation 'log' SELECT ATAN(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'atan' +ERROR HY000: Illegal parameter data type point for operation 'atan' SELECT ATAN(POINT(1,1),POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'atan' +ERROR HY000: Illegal parameter data type point for operation 'atan' SELECT ATAN(1, POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'atan' +ERROR HY000: Illegal parameter data type point for operation 'atan' SELECT POW(POINT(1,1),POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'pow' +ERROR HY000: Illegal parameter data type point for operation 'pow' SELECT RAND(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'rand' +ERROR HY000: Illegal parameter data type point for operation 'rand' SELECT RADIANS(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'radians' +ERROR HY000: Illegal parameter data type point for operation 'radians' SELECT DEGREES(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'degrees' +ERROR HY000: Illegal parameter data type point for operation 'degrees' SELECT EXP(ROW(1,1)); ERROR HY000: Illegal parameter data type row for operation 'exp' SELECT LN(ROW(1,1)); @@ -4817,64 +4817,64 @@ ERROR HY000: Illegal parameter data type row for operation 'degrees' # MDEV-13965 Parameter data type control for Item_longlong_func # SELECT POINT(1,1) | 1; -ERROR HY000: Illegal parameter data type geometry for operation '|' +ERROR HY000: Illegal parameter data type point for operation '|' SELECT 1 | POINT(1,1); -ERROR HY000: Illegal parameter data type geometry for operation '|' +ERROR HY000: Illegal parameter data type point for operation '|' SELECT POINT(1,1) & 1; -ERROR HY000: Illegal parameter data type geometry for operation '&' +ERROR HY000: Illegal parameter data type point for operation '&' SELECT 1 & POINT(1,1); -ERROR HY000: Illegal parameter data type geometry for operation '&' +ERROR HY000: Illegal parameter data type point for operation '&' SELECT POINT(1,1) << 1; -ERROR HY000: Illegal parameter data type geometry for operation '<<' +ERROR HY000: Illegal parameter data type point for operation '<<' SELECT 1 << POINT(1,1); -ERROR HY000: Illegal parameter data type geometry for operation '<<' +ERROR HY000: Illegal parameter data type point for operation '<<' SELECT POINT(1,1) >> 1; -ERROR HY000: Illegal parameter data type geometry for operation '>>' +ERROR HY000: Illegal parameter data type point for operation '>>' SELECT 1 >> POINT(1,1); -ERROR HY000: Illegal parameter data type geometry for operation '>>' +ERROR HY000: Illegal parameter data type point for operation '>>' SELECT ~POINT(1,1); -ERROR HY000: Illegal parameter data type geometry for operation '~' +ERROR HY000: Illegal parameter data type point for operation '~' SELECT TO_SECONDS(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'to_seconds' +ERROR HY000: Illegal parameter data type point for operation 'to_seconds' SELECT TIMESTAMPDIFF(SECOND,POINT(1,1), 1); -ERROR HY000: Illegal parameter data type geometry for operation 'timestampdiff' +ERROR HY000: Illegal parameter data type point for operation 'timestampdiff' SELECT TIMESTAMPDIFF(SECOND,1, POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'timestampdiff' +ERROR HY000: Illegal parameter data type point for operation 'timestampdiff' SELECT INET_ATON(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'inet_aton' +ERROR HY000: Illegal parameter data type point for operation 'inet_aton' SELECT LAST_INSERT_ID(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'last_insert_id' +ERROR HY000: Illegal parameter data type point for operation 'last_insert_id' # # MDEV-13966 Parameter data type control for Item_temporal_func # SELECT FROM_DAYS(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'from_days' +ERROR HY000: Illegal parameter data type point for operation 'from_days' SELECT MAKEDATE(POINT(1,1),1); -ERROR HY000: Illegal parameter data type geometry for operation 'makedate' +ERROR HY000: Illegal parameter data type point for operation 'makedate' SELECT MAKEDATE(1, POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'makedate' +ERROR HY000: Illegal parameter data type point for operation 'makedate' SELECT LAST_DAY(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'last_day' +ERROR HY000: Illegal parameter data type point for operation 'last_day' SELECT SEC_TO_TIME(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'sec_to_time' +ERROR HY000: Illegal parameter data type point for operation 'sec_to_time' SELECT TIMEDIFF(POINT(1,1),1); -ERROR HY000: Illegal parameter data type geometry for operation 'timediff' +ERROR HY000: Illegal parameter data type point for operation 'timediff' SELECT TIMEDIFF(1, POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'timediff' +ERROR HY000: Illegal parameter data type point for operation 'timediff' SELECT MAKETIME(POINT(1,1),1,1); -ERROR HY000: Illegal parameter data type geometry for operation 'maketime' +ERROR HY000: Illegal parameter data type point for operation 'maketime' SELECT MAKETIME(1, POINT(1,1), 1); -ERROR HY000: Illegal parameter data type geometry for operation 'maketime' +ERROR HY000: Illegal parameter data type point for operation 'maketime' SELECT MAKETIME(1, 1, POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'maketime' +ERROR HY000: Illegal parameter data type point for operation 'maketime' SELECT FROM_UNIXTIME(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'from_unixtime' +ERROR HY000: Illegal parameter data type point for operation 'from_unixtime' SELECT CONVERT_TZ(POINT(1,1),1,1); -ERROR HY000: Illegal parameter data type geometry for operation 'convert_tz' +ERROR HY000: Illegal parameter data type point for operation 'convert_tz' SELECT CONVERT_TZ(1, POINT(1,1), 1); -ERROR HY000: Illegal parameter data type geometry for operation 'convert_tz' +ERROR HY000: Illegal parameter data type point for operation 'convert_tz' SELECT CONVERT_TZ(1, 1, POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'convert_tz' +ERROR HY000: Illegal parameter data type point for operation 'convert_tz' # # MDEV-13967 Parameter data type control for Item_long_func # @@ -4903,67 +4903,67 @@ SELECT ORD(POINT(1,1)); ORD(POINT(1,1)) 0 SELECT SIGN(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'sign' +ERROR HY000: Illegal parameter data type point for operation 'sign' SELECT LOCATE('a','a',POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'locate' +ERROR HY000: Illegal parameter data type point for operation 'locate' SELECT LOCATE(POINT(1,1),POINT(1,1)); LOCATE(POINT(1,1),POINT(1,1)) 1 SELECT BIT_COUNT(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'bit_count' +ERROR HY000: Illegal parameter data type point for operation 'bit_count' SELECT BENCHMARK(POINT(1,1),''); -ERROR HY000: Illegal parameter data type geometry for operation 'benchmark' +ERROR HY000: Illegal parameter data type point for operation 'benchmark' SELECT SLEEP(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'sleep' +ERROR HY000: Illegal parameter data type point for operation 'sleep' SELECT GET_LOCK('x', POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'get_lock' +ERROR HY000: Illegal parameter data type point for operation 'get_lock' SELECT PERIOD_ADD(POINT(1,1),1); -ERROR HY000: Illegal parameter data type geometry for operation 'period_add' +ERROR HY000: Illegal parameter data type point for operation 'period_add' SELECT PERIOD_ADD(1,POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'period_add' +ERROR HY000: Illegal parameter data type point for operation 'period_add' SELECT PERIOD_DIFF(POINT(1,1),1); -ERROR HY000: Illegal parameter data type geometry for operation 'period_diff' +ERROR HY000: Illegal parameter data type point for operation 'period_diff' SELECT PERIOD_DIFF(1,POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'period_diff' +ERROR HY000: Illegal parameter data type point for operation 'period_diff' SELECT TO_DAYS(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'to_days' +ERROR HY000: Illegal parameter data type point for operation 'to_days' SELECT DAYOFMONTH(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'dayofmonth' +ERROR HY000: Illegal parameter data type point for operation 'dayofmonth' SELECT DAYOFYEAR(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'dayofyear' +ERROR HY000: Illegal parameter data type point for operation 'dayofyear' SELECT QUARTER(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'quarter' +ERROR HY000: Illegal parameter data type point for operation 'quarter' SELECT YEAR(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'year' +ERROR HY000: Illegal parameter data type point for operation 'year' SELECT YEARWEEK(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'yearweek' +ERROR HY000: Illegal parameter data type point for operation 'yearweek' SELECT WEEK(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'week' +ERROR HY000: Illegal parameter data type point for operation 'week' SELECT WEEK(POINT(1,1),1); -ERROR HY000: Illegal parameter data type geometry for operation 'week' +ERROR HY000: Illegal parameter data type point for operation 'week' SELECT WEEK(1,POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'week' +ERROR HY000: Illegal parameter data type point for operation 'week' SELECT HOUR(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'hour' +ERROR HY000: Illegal parameter data type point for operation 'hour' SELECT MINUTE(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'minute' +ERROR HY000: Illegal parameter data type point for operation 'minute' SELECT SECOND(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'second' +ERROR HY000: Illegal parameter data type point for operation 'second' SELECT MICROSECOND(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'microsecond' +ERROR HY000: Illegal parameter data type point for operation 'microsecond' SELECT JSON_DEPTH(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'json_depth' +ERROR HY000: Illegal parameter data type point for operation 'json_depth' SELECT JSON_LENGTH(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'json_length' +ERROR HY000: Illegal parameter data type point for operation 'json_length' SELECT JSON_LENGTH('json', POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'json_length' +ERROR HY000: Illegal parameter data type point for operation 'json_length' SELECT JSON_LENGTH(POINT(1,1), POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'json_length' +ERROR HY000: Illegal parameter data type point for operation 'json_length' SELECT REGEXP_INSTR(POINT(1,1),''); REGEXP_INSTR(POINT(1,1),'') 1 SELECT REGEXP_INSTR('',POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'regexp_instr' +ERROR HY000: Illegal parameter data type point for operation 'regexp_instr' SELECT FIND_IN_SET(POINT(1,1),''); FIND_IN_SET(POINT(1,1),'') 0 @@ -4971,11 +4971,11 @@ SELECT FIND_IN_SET('',POINT(1,1)); FIND_IN_SET('',POINT(1,1)) 0 SELECT RELEASE_LOCK(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'release_lock' +ERROR HY000: Illegal parameter data type point for operation 'release_lock' SELECT IS_FREE_LOCK(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'is_free_lock' +ERROR HY000: Illegal parameter data type point for operation 'is_free_lock' SELECT IS_USED_LOCK(POINT(1,1)); -ERROR HY000: Illegal parameter data type geometry for operation 'is_used_lock' +ERROR HY000: Illegal parameter data type point for operation 'is_used_lock' # # End of 10.3 tests # @@ -5019,16 +5019,16 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; SELECT 0x60+POINT(1,1); -ERROR HY000: Illegal parameter data types bigint and geometry for operation '+' +ERROR HY000: Illegal parameter data types bigint unsigned and point for operation '+' SELECT POINT(1,1)+0x60; -ERROR HY000: Illegal parameter data types geometry and bigint for operation '+' +ERROR HY000: Illegal parameter data types point and bigint unsigned for operation '+' # # MDEV-16454 Bad results for IN with ROW # SELECT (1,0) IN ((POINT(1,1),0),(0,0)); -ERROR HY000: Illegal parameter data types int and geometry for operation 'in' +ERROR HY000: Illegal parameter data types int and point for operation 'in' SELECT (1,(0,0)) IN ((1,(POINT(1,1),0)),(0,(0,0))); -ERROR HY000: Illegal parameter data types int and geometry for operation 'in' +ERROR HY000: Illegal parameter data types int and point for operation 'in' # # MDEV-19819 ALTER from POINT to LINESTRING erroneously preserves POINT values # @@ -5048,3 +5048,283 @@ DROP TABLE t1, t2; # # End of 10.4 tests # +# +# Start of 10.5 tests +# +# +# MDEV-19994 Add class Function_collection +# +SELECT CONTAINS(); +ERROR 42000: Incorrect parameter count in the call to native function 'CONTAINS()' +SELECT CONTAINS(POINT(1,1)); +ERROR 42000: Incorrect parameter count in the call to native function 'CONTAINS(POINT(1,1))' +SELECT CONTAINS(POINT(1,1), POINT(1,1), POINT(1,1)); +ERROR 42000: Incorrect parameter count in the call to native function 'CONTAINS(POINT(1,1), POINT(1,1), POINT(1,1))' +SELECT WITHIN(); +ERROR 42000: Incorrect parameter count in the call to native function 'WITHIN()' +SELECT WITHIN(POINT(1,1)); +ERROR 42000: Incorrect parameter count in the call to native function 'WITHIN(POINT(1,1))' +SELECT WITHIN(POINT(1,1), POINT(1,1), POINT(1,1)); +ERROR 42000: Incorrect parameter count in the call to native function 'WITHIN(POINT(1,1), POINT(1,1), POINT(1,1))' +# +# MDEV-20009 Add CAST(expr AS pluggable_type) +# +SELECT CAST(1 AS GEOMETRY); +ERROR HY000: Operator does not exists: 'CAST(expr AS geometry)' +SELECT CAST(1 AS GEOMETRYCOLLECTION); +ERROR HY000: Operator does not exists: 'CAST(expr AS geometrycollection)' +SELECT CAST(1 AS POINT); +ERROR HY000: Operator does not exists: 'CAST(expr AS point)' +SELECT CAST(1 AS LINESTRING); +ERROR HY000: Operator does not exists: 'CAST(expr AS linestring)' +SELECT CAST(1 AS POLYGON); +ERROR HY000: Operator does not exists: 'CAST(expr AS polygon)' +SELECT CAST(1 AS MULTIPOINT); +ERROR HY000: Operator does not exists: 'CAST(expr AS multipoint)' +SELECT CAST(1 AS MULTILINESTRING); +ERROR HY000: Operator does not exists: 'CAST(expr AS multilinestring)' +SELECT CAST(1 AS MULTIPOLYGON); +ERROR HY000: Operator does not exists: 'CAST(expr AS multipolygon)' +SELECT CONVERT(1, GEOMETRY); +ERROR HY000: Operator does not exists: 'CAST(expr AS geometry)' +SELECT CONVERT(1, GEOMETRYCOLLECTION); +ERROR HY000: Operator does not exists: 'CAST(expr AS geometrycollection)' +SELECT CONVERT(1, POINT); +ERROR HY000: Operator does not exists: 'CAST(expr AS point)' +SELECT CONVERT(1, LINESTRING); +ERROR HY000: Operator does not exists: 'CAST(expr AS linestring)' +SELECT CONVERT(1, POLYGON); +ERROR HY000: Operator does not exists: 'CAST(expr AS polygon)' +SELECT CONVERT(1, MULTIPOINT); +ERROR HY000: Operator does not exists: 'CAST(expr AS multipoint)' +SELECT CONVERT(1, MULTILINESTRING); +ERROR HY000: Operator does not exists: 'CAST(expr AS multilinestring)' +SELECT CONVERT(1, MULTIPOLYGON); +ERROR HY000: Operator does not exists: 'CAST(expr AS multipolygon)' +# +# MDEV-17832 Protocol: extensions for Pluggable types and JSON, GEOMETRY +# +SET NAMES utf8; +CREATE TABLE t1 ( +p POINT, +ls LINESTRING, +pl POLYGON, +mp MULTIPOINT, +mls MULTILINESTRING, +mpl MULTIPOLYGON, +gc GEOMETRYCOLLECTION, +g GEOMETRY +) CHARACTER SET utf8; +SELECT * FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 t1 p p 255 (type=point) 4294967295 0 Y 144 0 63 +def test t1 t1 ls ls 255 (type=linestring) 4294967295 0 Y 144 0 63 +def test t1 t1 pl pl 255 (type=polygon) 4294967295 0 Y 144 0 63 +def test t1 t1 mp mp 255 (type=multipoint) 4294967295 0 Y 144 0 63 +def test t1 t1 mls mls 255 (type=multilinestring) 4294967295 0 Y 144 0 63 +def test t1 t1 mpl mpl 255 (type=multipolygon) 4294967295 0 Y 144 0 63 +def test t1 t1 gc gc 255 (type=geometrycollection) 4294967295 0 Y 144 0 63 +def test t1 t1 g g 255 4294967295 0 Y 144 0 63 +p ls pl mp mls mpl gc g +SELECT +COALESCE(p) AS p, +COALESCE(ls) AS ls, +COALESCE(pl) AS pl, +COALESCE(mp) AS mp, +COALESCE(mls) AS mls, +COALESCE(mpl) AS mpl, +COALESCE(gc) AS gc, +COALESCE(g) AS g +FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def p 255 (type=point) 4294967295 0 Y 128 0 63 +def ls 255 (type=linestring) 4294967295 0 Y 128 0 63 +def pl 255 (type=polygon) 4294967295 0 Y 128 0 63 +def mp 255 (type=multipoint) 4294967295 0 Y 128 0 63 +def mls 255 (type=multilinestring) 4294967295 0 Y 128 0 63 +def mpl 255 (type=multipolygon) 4294967295 0 Y 128 0 63 +def gc 255 (type=geometrycollection) 4294967295 0 Y 128 0 63 +def g 255 4294967295 0 Y 128 0 63 +p ls pl mp mls mpl gc g +SELECT +COALESCE(p,p), +COALESCE(p,ls), +COALESCE(p,pl), +COALESCE(p,mp), +COALESCE(p,mls), +COALESCE(p,mpl), +COALESCE(p,g), +COALESCE(p,gc) +FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def COALESCE(p,p) 255 (type=point) 4294967295 0 Y 128 0 63 +def COALESCE(p,ls) 255 4294967295 0 Y 128 0 63 +def COALESCE(p,pl) 255 4294967295 0 Y 128 0 63 +def COALESCE(p,mp) 255 4294967295 0 Y 128 0 63 +def COALESCE(p,mls) 255 4294967295 0 Y 128 0 63 +def COALESCE(p,mpl) 255 4294967295 0 Y 128 0 63 +def COALESCE(p,g) 255 4294967295 0 Y 128 0 63 +def COALESCE(p,gc) 255 4294967295 0 Y 128 0 63 +COALESCE(p,p) COALESCE(p,ls) COALESCE(p,pl) COALESCE(p,mp) COALESCE(p,mls) COALESCE(p,mpl) COALESCE(p,g) COALESCE(p,gc) +SELECT +COALESCE(ls,p), +COALESCE(ls,ls), +COALESCE(ls,pl), +COALESCE(ls,mp), +COALESCE(ls,mls), +COALESCE(ls,mpl), +COALESCE(ls,g), +COALESCE(ls,gc) +FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def COALESCE(ls,p) 255 4294967295 0 Y 128 0 63 +def COALESCE(ls,ls) 255 (type=linestring) 4294967295 0 Y 128 0 63 +def COALESCE(ls,pl) 255 4294967295 0 Y 128 0 63 +def COALESCE(ls,mp) 255 4294967295 0 Y 128 0 63 +def COALESCE(ls,mls) 255 4294967295 0 Y 128 0 63 +def COALESCE(ls,mpl) 255 4294967295 0 Y 128 0 63 +def COALESCE(ls,g) 255 4294967295 0 Y 128 0 63 +def COALESCE(ls,gc) 255 4294967295 0 Y 128 0 63 +COALESCE(ls,p) COALESCE(ls,ls) COALESCE(ls,pl) COALESCE(ls,mp) COALESCE(ls,mls) COALESCE(ls,mpl) COALESCE(ls,g) COALESCE(ls,gc) +SELECT +COALESCE(pl,p), +COALESCE(pl,ls), +COALESCE(pl,pl), +COALESCE(pl,mp), +COALESCE(pl,mls), +COALESCE(pl,mpl), +COALESCE(pl,g), +COALESCE(pl,gc) +FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def COALESCE(pl,p) 255 4294967295 0 Y 128 0 63 +def COALESCE(pl,ls) 255 4294967295 0 Y 128 0 63 +def COALESCE(pl,pl) 255 (type=polygon) 4294967295 0 Y 128 0 63 +def COALESCE(pl,mp) 255 4294967295 0 Y 128 0 63 +def COALESCE(pl,mls) 255 4294967295 0 Y 128 0 63 +def COALESCE(pl,mpl) 255 4294967295 0 Y 128 0 63 +def COALESCE(pl,g) 255 4294967295 0 Y 128 0 63 +def COALESCE(pl,gc) 255 4294967295 0 Y 128 0 63 +COALESCE(pl,p) COALESCE(pl,ls) COALESCE(pl,pl) COALESCE(pl,mp) COALESCE(pl,mls) COALESCE(pl,mpl) COALESCE(pl,g) COALESCE(pl,gc) +SELECT +COALESCE(mp,p), +COALESCE(mp,ls), +COALESCE(mp,pl), +COALESCE(mp,mp), +COALESCE(mp,mls), +COALESCE(mp,mpl), +COALESCE(mp,g), +COALESCE(mp,gc) +FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def COALESCE(mp,p) 255 4294967295 0 Y 128 0 63 +def COALESCE(mp,ls) 255 4294967295 0 Y 128 0 63 +def COALESCE(mp,pl) 255 4294967295 0 Y 128 0 63 +def COALESCE(mp,mp) 255 (type=multipoint) 4294967295 0 Y 128 0 63 +def COALESCE(mp,mls) 255 4294967295 0 Y 128 0 63 +def COALESCE(mp,mpl) 255 4294967295 0 Y 128 0 63 +def COALESCE(mp,g) 255 4294967295 0 Y 128 0 63 +def COALESCE(mp,gc) 255 4294967295 0 Y 128 0 63 +COALESCE(mp,p) COALESCE(mp,ls) COALESCE(mp,pl) COALESCE(mp,mp) COALESCE(mp,mls) COALESCE(mp,mpl) COALESCE(mp,g) COALESCE(mp,gc) +SELECT +COALESCE(mls,p), +COALESCE(mls,ls), +COALESCE(mls,pl), +COALESCE(mls,mp), +COALESCE(mls,mls), +COALESCE(mls,mpl), +COALESCE(mls,g), +COALESCE(mls,gc) +FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def COALESCE(mls,p) 255 4294967295 0 Y 128 0 63 +def COALESCE(mls,ls) 255 4294967295 0 Y 128 0 63 +def COALESCE(mls,pl) 255 4294967295 0 Y 128 0 63 +def COALESCE(mls,mp) 255 4294967295 0 Y 128 0 63 +def COALESCE(mls,mls) 255 (type=multilinestring) 4294967295 0 Y 128 0 63 +def COALESCE(mls,mpl) 255 4294967295 0 Y 128 0 63 +def COALESCE(mls,g) 255 4294967295 0 Y 128 0 63 +def COALESCE(mls,gc) 255 4294967295 0 Y 128 0 63 +COALESCE(mls,p) COALESCE(mls,ls) COALESCE(mls,pl) COALESCE(mls,mp) COALESCE(mls,mls) COALESCE(mls,mpl) COALESCE(mls,g) COALESCE(mls,gc) +SELECT +COALESCE(mpl,p), +COALESCE(mpl,ls), +COALESCE(mpl,pl), +COALESCE(mpl,mp), +COALESCE(mpl,mls), +COALESCE(mpl,mpl), +COALESCE(mpl,g), +COALESCE(mpl,gc) +FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def COALESCE(mpl,p) 255 4294967295 0 Y 128 0 63 +def COALESCE(mpl,ls) 255 4294967295 0 Y 128 0 63 +def COALESCE(mpl,pl) 255 4294967295 0 Y 128 0 63 +def COALESCE(mpl,mp) 255 4294967295 0 Y 128 0 63 +def COALESCE(mpl,mls) 255 4294967295 0 Y 128 0 63 +def COALESCE(mpl,mpl) 255 (type=multipolygon) 4294967295 0 Y 128 0 63 +def COALESCE(mpl,g) 255 4294967295 0 Y 128 0 63 +def COALESCE(mpl,gc) 255 4294967295 0 Y 128 0 63 +COALESCE(mpl,p) COALESCE(mpl,ls) COALESCE(mpl,pl) COALESCE(mpl,mp) COALESCE(mpl,mls) COALESCE(mpl,mpl) COALESCE(mpl,g) COALESCE(mpl,gc) +SELECT +COALESCE(g,p), +COALESCE(g,ls), +COALESCE(g,pl), +COALESCE(g,mp), +COALESCE(g,mls), +COALESCE(g,mpl), +COALESCE(g,g), +COALESCE(g,gc) +FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def COALESCE(g,p) 255 4294967295 0 Y 128 0 63 +def COALESCE(g,ls) 255 4294967295 0 Y 128 0 63 +def COALESCE(g,pl) 255 4294967295 0 Y 128 0 63 +def COALESCE(g,mp) 255 4294967295 0 Y 128 0 63 +def COALESCE(g,mls) 255 4294967295 0 Y 128 0 63 +def COALESCE(g,mpl) 255 4294967295 0 Y 128 0 63 +def COALESCE(g,g) 255 4294967295 0 Y 128 0 63 +def COALESCE(g,gc) 255 4294967295 0 Y 128 0 63 +COALESCE(g,p) COALESCE(g,ls) COALESCE(g,pl) COALESCE(g,mp) COALESCE(g,mls) COALESCE(g,mpl) COALESCE(g,g) COALESCE(g,gc) +SELECT +COALESCE(gc,p), +COALESCE(gc,ls), +COALESCE(gc,pl), +COALESCE(gc,mp), +COALESCE(gc,mls), +COALESCE(gc,mpl), +COALESCE(gc,g), +COALESCE(gc,gc) +FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def COALESCE(gc,p) 255 4294967295 0 Y 128 0 63 +def COALESCE(gc,ls) 255 4294967295 0 Y 128 0 63 +def COALESCE(gc,pl) 255 4294967295 0 Y 128 0 63 +def COALESCE(gc,mp) 255 4294967295 0 Y 128 0 63 +def COALESCE(gc,mls) 255 4294967295 0 Y 128 0 63 +def COALESCE(gc,mpl) 255 4294967295 0 Y 128 0 63 +def COALESCE(gc,g) 255 4294967295 0 Y 128 0 63 +def COALESCE(gc,gc) 255 (type=geometrycollection) 4294967295 0 Y 128 0 63 +COALESCE(gc,p) COALESCE(gc,ls) COALESCE(gc,pl) COALESCE(gc,mp) COALESCE(gc,mls) COALESCE(gc,mpl) COALESCE(gc,g) COALESCE(gc,gc) +DROP TABLE t1; +# +# MDEV-20809 EXTRACT from INET6 value does not produce any warnings +# +CREATE TABLE t1 (a GEOMETRY); +SELECT EXTRACT(DAY FROM a) FROM t1; +ERROR HY000: Illegal parameter data type geometry for operation 'extract(day)' +DROP TABLE t1; +# +# MDEV-21765 Possibly inconsistent behavior of BIT_xx functions with INET6 field +# +CREATE TABLE t1 (a GEOMETRY); +SELECT BIT_AND(a) FROM t1; +ERROR HY000: Illegal parameter data type geometry for operation 'bit_and(' +SELECT BIT_OR(a) FROM t1; +ERROR HY000: Illegal parameter data type geometry for operation 'bit_or(' +SELECT BIT_XOR(a) FROM t1; +ERROR HY000: Illegal parameter data type geometry for operation 'bit_xor(' +DROP TABLE t1; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/gis.test b/mysql-test/main/gis.test index 4ec5eb99d62..17a93291b77 100644 --- a/mysql-test/main/gis.test +++ b/mysql-test/main/gis.test @@ -3124,3 +3124,214 @@ DROP TABLE t1, t2; --echo # --echo # End of 10.4 tests --echo # + + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-19994 Add class Function_collection +--echo # + +--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +SELECT CONTAINS(); +--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +SELECT CONTAINS(POINT(1,1)); +--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +SELECT CONTAINS(POINT(1,1), POINT(1,1), POINT(1,1)); + +--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +SELECT WITHIN(); +--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +SELECT WITHIN(POINT(1,1)); +--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +SELECT WITHIN(POINT(1,1), POINT(1,1), POINT(1,1)); + +--echo # +--echo # MDEV-20009 Add CAST(expr AS pluggable_type) +--echo # + +--error ER_UNKNOWN_OPERATOR +SELECT CAST(1 AS GEOMETRY); +--error ER_UNKNOWN_OPERATOR +SELECT CAST(1 AS GEOMETRYCOLLECTION); +--error ER_UNKNOWN_OPERATOR +SELECT CAST(1 AS POINT); +--error ER_UNKNOWN_OPERATOR +SELECT CAST(1 AS LINESTRING); +--error ER_UNKNOWN_OPERATOR +SELECT CAST(1 AS POLYGON); +--error ER_UNKNOWN_OPERATOR +SELECT CAST(1 AS MULTIPOINT); +--error ER_UNKNOWN_OPERATOR +SELECT CAST(1 AS MULTILINESTRING); +--error ER_UNKNOWN_OPERATOR +SELECT CAST(1 AS MULTIPOLYGON); + + +--error ER_UNKNOWN_OPERATOR +SELECT CONVERT(1, GEOMETRY); +--error ER_UNKNOWN_OPERATOR +SELECT CONVERT(1, GEOMETRYCOLLECTION); +--error ER_UNKNOWN_OPERATOR +SELECT CONVERT(1, POINT); +--error ER_UNKNOWN_OPERATOR +SELECT CONVERT(1, LINESTRING); +--error ER_UNKNOWN_OPERATOR +SELECT CONVERT(1, POLYGON); +--error ER_UNKNOWN_OPERATOR +SELECT CONVERT(1, MULTIPOINT); +--error ER_UNKNOWN_OPERATOR +SELECT CONVERT(1, MULTILINESTRING); +--error ER_UNKNOWN_OPERATOR +SELECT CONVERT(1, MULTIPOLYGON); + + +--echo # +--echo # MDEV-17832 Protocol: extensions for Pluggable types and JSON, GEOMETRY +--echo # + +SET NAMES utf8; +CREATE TABLE t1 ( + p POINT, + ls LINESTRING, + pl POLYGON, + mp MULTIPOINT, + mls MULTILINESTRING, + mpl MULTIPOLYGON, + gc GEOMETRYCOLLECTION, + g GEOMETRY +) CHARACTER SET utf8; + +--enable_metadata +SELECT * FROM t1; + +SELECT + COALESCE(p) AS p, + COALESCE(ls) AS ls, + COALESCE(pl) AS pl, + COALESCE(mp) AS mp, + COALESCE(mls) AS mls, + COALESCE(mpl) AS mpl, + COALESCE(gc) AS gc, + COALESCE(g) AS g +FROM t1; + +SELECT + COALESCE(p,p), + COALESCE(p,ls), + COALESCE(p,pl), + COALESCE(p,mp), + COALESCE(p,mls), + COALESCE(p,mpl), + COALESCE(p,g), + COALESCE(p,gc) +FROM t1; + +SELECT + COALESCE(ls,p), + COALESCE(ls,ls), + COALESCE(ls,pl), + COALESCE(ls,mp), + COALESCE(ls,mls), + COALESCE(ls,mpl), + COALESCE(ls,g), + COALESCE(ls,gc) +FROM t1; + +SELECT + COALESCE(pl,p), + COALESCE(pl,ls), + COALESCE(pl,pl), + COALESCE(pl,mp), + COALESCE(pl,mls), + COALESCE(pl,mpl), + COALESCE(pl,g), + COALESCE(pl,gc) +FROM t1; + +SELECT + COALESCE(mp,p), + COALESCE(mp,ls), + COALESCE(mp,pl), + COALESCE(mp,mp), + COALESCE(mp,mls), + COALESCE(mp,mpl), + COALESCE(mp,g), + COALESCE(mp,gc) +FROM t1; + +SELECT + COALESCE(mls,p), + COALESCE(mls,ls), + COALESCE(mls,pl), + COALESCE(mls,mp), + COALESCE(mls,mls), + COALESCE(mls,mpl), + COALESCE(mls,g), + COALESCE(mls,gc) +FROM t1; + +SELECT + COALESCE(mpl,p), + COALESCE(mpl,ls), + COALESCE(mpl,pl), + COALESCE(mpl,mp), + COALESCE(mpl,mls), + COALESCE(mpl,mpl), + COALESCE(mpl,g), + COALESCE(mpl,gc) +FROM t1; + +SELECT + COALESCE(g,p), + COALESCE(g,ls), + COALESCE(g,pl), + COALESCE(g,mp), + COALESCE(g,mls), + COALESCE(g,mpl), + COALESCE(g,g), + COALESCE(g,gc) +FROM t1; + +SELECT + COALESCE(gc,p), + COALESCE(gc,ls), + COALESCE(gc,pl), + COALESCE(gc,mp), + COALESCE(gc,mls), + COALESCE(gc,mpl), + COALESCE(gc,g), + COALESCE(gc,gc) +FROM t1; + +--disable_metadata +DROP TABLE t1; + +--echo # +--echo # MDEV-20809 EXTRACT from INET6 value does not produce any warnings +--echo # + +CREATE TABLE t1 (a GEOMETRY); +--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION +SELECT EXTRACT(DAY FROM a) FROM t1; +DROP TABLE t1; + +--echo # +--echo # MDEV-21765 Possibly inconsistent behavior of BIT_xx functions with INET6 field +--echo # + +CREATE TABLE t1 (a GEOMETRY); +--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION +SELECT BIT_AND(a) FROM t1; +--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION +SELECT BIT_OR(a) FROM t1; +--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION +SELECT BIT_XOR(a) FROM t1; +DROP TABLE t1; + + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/grant.result b/mysql-test/main/grant.result index 8cb2ebd551f..92073388b69 100644 --- a/mysql-test/main/grant.result +++ b/mysql-test/main/grant.result @@ -621,7 +621,12 @@ Process Server Admin To view the plain text of currently executing queries Proxy Server Admin To make proxy user possible References Databases,Tables To have references on tables Reload Server Admin To reload or refresh tables, logs and privileges -Replication client Server Admin To ask where the slave or master servers are +Binlog admin Server To purge binary logs +Binlog monitor Server To use SHOW BINLOG STATUS and SHOW BINARY LOG +Binlog replay Server To use BINLOG (generated by mariadb-binlog) +Replication master admin Server To monitor connected slaves +Replication slave admin Server To start/stop slave and apply binlog events +Slave monitor Server To use SHOW SLAVE STATUS and SHOW RELAYLOG EVENTS Replication slave Server Admin To read binary log events from the master Select Tables To retrieve rows from table Show databases Server Admin To see all databases with SHOW DATABASES @@ -631,6 +636,10 @@ Super Server Admin To use KILL thread, SET GLOBAL, CHANGE MASTER, etc. Trigger Tables To use triggers Create tablespace Server Admin To create/alter/drop tablespaces Update Tables To update existing rows +Set user Server To create views and stored routines with a different definer +Federated admin Server To execute the CREATE SERVER, ALTER SERVER, DROP SERVER statements +Connection admin Server To bypass connection limits and kill other users' connections +Read_only admin Server To perform write operations even if @@read_only=ON Usage Server Admin No privileges - allow connect only connect root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK; connection root; @@ -1959,10 +1968,11 @@ GRANT REPLICATION SLAVE ON *.* TO mysqltest_u1@localhost; GRANT SHOW DATABASES ON *.* TO mysqltest_u1@localhost; GRANT SHUTDOWN ON *.* TO mysqltest_u1@localhost; GRANT USAGE ON *.* TO mysqltest_u1@localhost; +GRANT SLAVE MONITOR ON *.* TO mysqltest_u1@localhost; SHOW GRANTS FOR mysqltest_u1@localhost; Grants for mysqltest_u1@localhost -GRANT RELOAD, SHUTDOWN, PROCESS, FILE, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT, CREATE USER ON *.* TO `mysqltest_u1`@`localhost` +GRANT RELOAD, SHUTDOWN, PROCESS, FILE, SHOW DATABASES, REPLICATION SLAVE, BINLOG MONITOR, CREATE USER, SLAVE MONITOR ON *.* TO `mysqltest_u1`@`localhost` GRANT CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE ROUTINE, ALTER ROUTINE, EVENT ON `mysqltest_db1`.* TO `mysqltest_u1`@`localhost` connect con1,localhost,mysqltest_u1,,mysqltest_db1; connection con1; diff --git a/mysql-test/main/grant.test b/mysql-test/main/grant.test index 38baf673825..a81e77567b5 100644 --- a/mysql-test/main/grant.test +++ b/mysql-test/main/grant.test @@ -1833,6 +1833,7 @@ GRANT REPLICATION SLAVE ON *.* TO mysqltest_u1@localhost; GRANT SHOW DATABASES ON *.* TO mysqltest_u1@localhost; GRANT SHUTDOWN ON *.* TO mysqltest_u1@localhost; GRANT USAGE ON *.* TO mysqltest_u1@localhost; +GRANT SLAVE MONITOR ON *.* TO mysqltest_u1@localhost; --echo SHOW GRANTS FOR mysqltest_u1@localhost; diff --git a/mysql-test/main/grant2.result b/mysql-test/main/grant2.result index 0eb8dee026e..3f2b1d48c55 100644 --- a/mysql-test/main/grant2.result +++ b/mysql-test/main/grant2.result @@ -162,7 +162,7 @@ connection con10; set sql_log_off = 1; ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation set sql_log_bin = 0; -ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation +ERROR 42000: Access denied; you need (at least one of) the SUPER, BINLOG ADMIN privilege(s) for this operation disconnect con10; connection default; delete from mysql.user where user like 'mysqltest\_1'; diff --git a/mysql-test/main/grant_binlog_replay.result b/mysql-test/main/grant_binlog_replay.result new file mode 100644 index 00000000000..2c71e70e59b --- /dev/null +++ b/mysql-test/main/grant_binlog_replay.result @@ -0,0 +1,52 @@ +# +# Start of 10.5 tests +# +# +# MDEV-21975 Add BINLOG REPLAY privilege and bind new privileges to gtid_seq_no, preudo_thread_id, server_id, gtid_domain_id +# +# +# Test that binlog replay statements are not allowed without BINLOG REPLAY or SUPER +# +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT ALL PRIVILEGES ON *.* TO user1@localhost; +REVOKE BINLOG REPLAY, SUPER ON *.* FROM user1@localhost; +connect con1,localhost,user1,,; +connection con1; +BINLOG ''; +ERROR 42000: Access denied; you need (at least one of) the SUPER, BINLOG REPLAY privilege(s) for this operation +disconnect con1; +connection default; +DROP USER user1@localhost; +# +# Test that binlog replay statements are allowed with BINLOG REPLAY +# +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT BINLOG REPLAY ON *.* TO user1@localhost; +SHOW GRANTS FOR user1@localhost; +Grants for user1@localhost +GRANT BINLOG REPLAY ON *.* TO `user1`@`localhost` +connect con1,localhost,user1,,; +connection con1; +BINLOG ''; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use +disconnect con1; +connection default; +DROP USER user1@localhost; +# +# Test that binlog replay statements are allowed with SUPER +# +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT SUPER ON *.* TO user1@localhost; +SHOW GRANTS FOR user1@localhost; +Grants for user1@localhost +GRANT SUPER ON *.* TO `user1`@`localhost` +connect con1,localhost,user1,,; +connection con1; +BINLOG ''; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use +disconnect con1; +connection default; +DROP USER user1@localhost; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/grant_binlog_replay.test b/mysql-test/main/grant_binlog_replay.test new file mode 100644 index 00000000000..a3078e5023c --- /dev/null +++ b/mysql-test/main/grant_binlog_replay.test @@ -0,0 +1,73 @@ +-- source include/not_embedded.inc + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-21975 Add BINLOG REPLAY privilege and bind new privileges to gtid_seq_no, preudo_thread_id, server_id, gtid_domain_id +--echo # + +--echo # +--echo # Test that binlog replay statements are not allowed without BINLOG REPLAY or SUPER +--echo # + +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT ALL PRIVILEGES ON *.* TO user1@localhost; +REVOKE BINLOG REPLAY, SUPER ON *.* FROM user1@localhost; + +connect (con1,localhost,user1,,); +connection con1; +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +BINLOG ''; +disconnect con1; + +connection default; +DROP USER user1@localhost; + + +--echo # +--echo # Test that binlog replay statements are allowed with BINLOG REPLAY +--echo # + +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT BINLOG REPLAY ON *.* TO user1@localhost; +SHOW GRANTS FOR user1@localhost; + +connect (con1,localhost,user1,,); +connection con1; +# The below fails with a syntax error. +# This is fine. It's only important that it does not fail on "access denied". +--error ER_SYNTAX_ERROR +BINLOG ''; +--enable_result_log +disconnect con1; + +connection default; +DROP USER user1@localhost; + + +--echo # +--echo # Test that binlog replay statements are allowed with SUPER +--echo # + +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT SUPER ON *.* TO user1@localhost; +SHOW GRANTS FOR user1@localhost; + +connect (con1,localhost,user1,,); +connection con1; +--error ER_BAD_SLAVE +# The below fails with a syntax error. +# This is fine. It's only important that it does not fail on "access denied". +--error ER_SYNTAX_ERROR +BINLOG ''; +--enable_result_log +disconnect con1; + +connection default; +DROP USER user1@localhost; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/grant_kill.result b/mysql-test/main/grant_kill.result new file mode 100644 index 00000000000..e1243a39a70 --- /dev/null +++ b/mysql-test/main/grant_kill.result @@ -0,0 +1,71 @@ +# +# Start of 10.5 tests +# +# +# MDEV-21743 Split up SUPER privilege to smaller privileges +# +# +# Test that KILL is not allowed without CONNECTION ADMIN or SUPER +# +CREATE USER foo@localhost; +GRANT SELECT ON *.* TO foo@localhost; +CREATE USER bar@localhost; +GRANT ALL PRIVILEGES ON *.* TO bar@localhost; +REVOKE CONNECTION ADMIN, SUPER ON *.* FROM bar@localhost; +connect foo,localhost,foo,,; +connect bar,localhost,bar,,; +SELECT user FROM information_schema.processlist ORDER BY user; +user +bar +foo +root +KILL ID; +ERROR HY000: You are not owner of thread ID +disconnect foo; +disconnect bar; +connection default; +DROP USER foo@localhost; +DROP USER bar@localhost; +# +# Test that KILL is allowed with CONNECTION ADMIN +# +CREATE USER foo@localhost; +GRANT SELECT ON *.* TO foo@localhost; +CREATE USER bar@localhost; +GRANT PROCESS, CONNECTION ADMIN ON *.* TO bar@localhost; +connect foo,localhost,foo,,; +connect bar,localhost,bar,,; +SELECT user FROM information_schema.processlist ORDER BY user; +user +bar +foo +root +KILL ID; +connection default; +disconnect foo; +disconnect bar; +DROP USER foo@localhost; +DROP USER bar@localhost; +# +# Test that KILL is allowed with SUPER +# +CREATE USER foo@localhost; +GRANT SELECT ON *.* TO foo@localhost; +CREATE USER bar@localhost; +GRANT PROCESS, SUPER ON *.* TO bar@localhost; +connect foo,localhost,foo,,; +connect bar,localhost,bar,,; +SELECT user FROM information_schema.processlist ORDER BY user; +user +bar +foo +root +KILL ID; +connection default; +disconnect foo; +disconnect bar; +DROP USER foo@localhost; +DROP USER bar@localhost; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/grant_kill.test b/mysql-test/main/grant_kill.test new file mode 100644 index 00000000000..b29dfb32917 --- /dev/null +++ b/mysql-test/main/grant_kill.test @@ -0,0 +1,88 @@ +-- source include/not_embedded.inc + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-21743 Split up SUPER privilege to smaller privileges +--echo # + +--let $count_sessions=1 + +--echo # +--echo # Test that KILL is not allowed without CONNECTION ADMIN or SUPER +--echo # + +CREATE USER foo@localhost; +GRANT SELECT ON *.* TO foo@localhost; +CREATE USER bar@localhost; +GRANT ALL PRIVILEGES ON *.* TO bar@localhost; +REVOKE CONNECTION ADMIN, SUPER ON *.* FROM bar@localhost; +--connect (foo,localhost,foo,,) +let $id=`(SELECT id FROM INFORMATION_SCHEMA.PROCESSLIST WHERE user='foo')`; +--connect (bar,localhost,bar,,) +SELECT user FROM information_schema.processlist ORDER BY user; +--replace_result $id ID +--error ER_KILL_DENIED_ERROR +--eval KILL $id +--disconnect foo +--disconnect bar +--connection default +--source include/wait_until_count_sessions.inc +DROP USER foo@localhost; +DROP USER bar@localhost; + +--echo # +--echo # Test that KILL is allowed with CONNECTION ADMIN +--echo # + +CREATE USER foo@localhost; +GRANT SELECT ON *.* TO foo@localhost; +CREATE USER bar@localhost; +GRANT PROCESS, CONNECTION ADMIN ON *.* TO bar@localhost; +--connect (foo,localhost,foo,,) +let $id=`(SELECT id FROM INFORMATION_SCHEMA.PROCESSLIST WHERE user='foo')`; +--connect (bar,localhost,bar,,) +SELECT user FROM information_schema.processlist ORDER BY user; +--replace_result $id ID +--eval KILL $id +--connection default +let $wait_condition= + select count(*) = 0 from information_schema.processlist + where user = "foo"; +--source include/wait_condition.inc +--disconnect foo +--disconnect bar +--source include/wait_until_count_sessions.inc +DROP USER foo@localhost; +DROP USER bar@localhost; + +--echo # +--echo # Test that KILL is allowed with SUPER +--echo # + +CREATE USER foo@localhost; +GRANT SELECT ON *.* TO foo@localhost; +CREATE USER bar@localhost; +GRANT PROCESS, SUPER ON *.* TO bar@localhost; +--connect (foo,localhost,foo,,) +let $id=`(SELECT id FROM INFORMATION_SCHEMA.PROCESSLIST WHERE user='foo')`; +--connect (bar,localhost,bar,,) +SELECT user FROM information_schema.processlist ORDER BY user; +--replace_result $id ID +--eval KILL $id +--connection default +let $wait_condition= + select count(*) = 0 from information_schema.processlist + where user = "foo"; +--source include/wait_condition.inc +--disconnect foo +--disconnect bar +--source include/wait_until_count_sessions.inc +DROP USER foo@localhost; +DROP USER bar@localhost; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/grant_master_admin.result b/mysql-test/main/grant_master_admin.result new file mode 100644 index 00000000000..bd08ade940c --- /dev/null +++ b/mysql-test/main/grant_master_admin.result @@ -0,0 +1,36 @@ +# +# Start of 10.5 tests +# +# +# MDEV-21743 Split up SUPER privilege to smaller privileges +# +# +# Test that master admin statements are not allowed without REPLICATION MASTER ADMIN +# +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT ALL PRIVILEGES ON *.* TO user1@localhost; +REVOKE REPLICATION MASTER ADMIN ON *.* FROM user1@localhost; +connect con1,localhost,user1,,; +connection con1; +SHOW SLAVE HOSTS; +ERROR 42000: Access denied; you need (at least one of) the REPLICATION MASTER ADMIN privilege(s) for this operation +disconnect con1; +connection default; +DROP USER user1@localhost; +# +# Test that master admin statements are allowed with REPLICATION MASTER ADMIN +# +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT REPLICATION MASTER ADMIN ON *.* TO user1@localhost; +SHOW GRANTS FOR user1@localhost; +Grants for user1@localhost +GRANT REPLICATION MASTER ADMIN ON *.* TO `user1`@`localhost` +connect con1,localhost,user1,,; +connection con1; +SHOW SLAVE HOSTS; +Server_id Host Port Master_id +connection default; +DROP USER user1@localhost; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/grant_master_admin.test b/mysql-test/main/grant_master_admin.test new file mode 100644 index 00000000000..c98c374f7e9 --- /dev/null +++ b/mysql-test/main/grant_master_admin.test @@ -0,0 +1,47 @@ +-- source include/not_embedded.inc + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-21743 Split up SUPER privilege to smaller privileges +--echo # + +--echo # +--echo # Test that master admin statements are not allowed without REPLICATION MASTER ADMIN +--echo # + +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT ALL PRIVILEGES ON *.* TO user1@localhost; +REVOKE REPLICATION MASTER ADMIN ON *.* FROM user1@localhost; + +connect (con1,localhost,user1,,); +connection con1; +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +SHOW SLAVE HOSTS; +disconnect con1; + +connection default; +DROP USER user1@localhost; + + +--echo # +--echo # Test that master admin statements are allowed with REPLICATION MASTER ADMIN +--echo # + +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT REPLICATION MASTER ADMIN ON *.* TO user1@localhost; +SHOW GRANTS FOR user1@localhost; + +connect (con1,localhost,user1,,); +connection con1; +SHOW SLAVE HOSTS; + +connection default; +DROP USER user1@localhost; + + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/grant_read_only.result b/mysql-test/main/grant_read_only.result new file mode 100644 index 00000000000..185325f03a6 --- /dev/null +++ b/mysql-test/main/grant_read_only.result @@ -0,0 +1,73 @@ +# +# Start of 10.5 tests +# +# +# Test that @@read_only is not ignored without READ_ONLY ADMIN or SUPER +# +CREATE TABLE t1 (a INT); +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT ALL PRIVILEGES ON *.* TO user1@localhost; +REVOKE READ_ONLY ADMIN, SUPER ON *.* FROM user1@localhost; +SET @@GLOBAL.read_only=1; +connect con1,localhost,user1,,; +connection con1; +UPDATE t1 SET a=11 WHERE a=10; +ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement +DELETE FROM t1 WHERE a=11; +ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement +INSERT INTO t1 VALUES (20); +ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement +disconnect con1; +connection default; +SET @@GLOBAL.read_only=0; +DROP USER user1@localhost; +DROP TABLE t1; +# +# Test that @@read_only is ignored with READ_ONLY ADMIN +# +CREATE TABLE t1 (a INT); +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT INSERT, UPDATE, DELETE, READ_ONLY ADMIN ON *.* TO user1@localhost; +SHOW GRANTS FOR user1@localhost; +Grants for user1@localhost +GRANT INSERT, UPDATE, DELETE, READ_ONLY ADMIN ON *.* TO `user1`@`localhost` +SET @@GLOBAL.read_only=1; +connect con1,localhost,user1,,; +connection con1; +SELECT @@read_only; +@@read_only +1 +UPDATE t1 SET a=11 WHERE a=10; +DELETE FROM t1 WHERE a=11; +INSERT INTO t1 VALUES (20); +disconnect con1; +connection default; +SET @@GLOBAL.read_only=0; +DROP USER user1@localhost; +DROP TABLE t1; +# +# Test that @@read_only is ignored with SUPER +# +CREATE TABLE t1 (a INT); +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT INSERT, UPDATE, DELETE, SUPER ON *.* TO user1@localhost; +SHOW GRANTS FOR user1@localhost; +Grants for user1@localhost +GRANT INSERT, UPDATE, DELETE, SUPER ON *.* TO `user1`@`localhost` +SET @@GLOBAL.read_only=1; +connect con1,localhost,user1,,; +connection con1; +SELECT @@read_only; +@@read_only +1 +UPDATE t1 SET a=11 WHERE a=10; +DELETE FROM t1 WHERE a=11; +INSERT INTO t1 VALUES (20); +disconnect con1; +connection default; +SET @@GLOBAL.read_only=0; +DROP USER user1@localhost; +DROP TABLE t1; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/grant_read_only.test b/mysql-test/main/grant_read_only.test new file mode 100644 index 00000000000..25ffa3767ba --- /dev/null +++ b/mysql-test/main/grant_read_only.test @@ -0,0 +1,83 @@ +-- source include/not_embedded.inc + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # Test that @@read_only is not ignored without READ_ONLY ADMIN or SUPER +--echo # + +CREATE TABLE t1 (a INT); +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT ALL PRIVILEGES ON *.* TO user1@localhost; +REVOKE READ_ONLY ADMIN, SUPER ON *.* FROM user1@localhost; +SET @@GLOBAL.read_only=1; + +connect (con1,localhost,user1,,); +connection con1; +--error ER_OPTION_PREVENTS_STATEMENT +UPDATE t1 SET a=11 WHERE a=10; +--error ER_OPTION_PREVENTS_STATEMENT +DELETE FROM t1 WHERE a=11; +--error ER_OPTION_PREVENTS_STATEMENT +INSERT INTO t1 VALUES (20); +disconnect con1; + +connection default; +SET @@GLOBAL.read_only=0; +DROP USER user1@localhost; +DROP TABLE t1; + +--echo # +--echo # Test that @@read_only is ignored with READ_ONLY ADMIN +--echo # + +CREATE TABLE t1 (a INT); +CREATE USER user1@localhost IDENTIFIED BY ''; +## TODO: it works even without INSERT/UPDATE/DELETE: file a bug report! +GRANT INSERT, UPDATE, DELETE, READ_ONLY ADMIN ON *.* TO user1@localhost; +SHOW GRANTS FOR user1@localhost; +SET @@GLOBAL.read_only=1; + +connect (con1,localhost,user1,,); +connection con1; +SELECT @@read_only; +UPDATE t1 SET a=11 WHERE a=10; +DELETE FROM t1 WHERE a=11; +INSERT INTO t1 VALUES (20); +disconnect con1; + +connection default; +SET @@GLOBAL.read_only=0; +DROP USER user1@localhost; +DROP TABLE t1; + + +--echo # +--echo # Test that @@read_only is ignored with SUPER +--echo # + +CREATE TABLE t1 (a INT); +CREATE USER user1@localhost IDENTIFIED BY ''; +## TODO: it works even without INSERT/UPDATE/DELETE: file a bug report! +GRANT INSERT, UPDATE, DELETE, SUPER ON *.* TO user1@localhost; +SHOW GRANTS FOR user1@localhost; +SET @@GLOBAL.read_only=1; + +connect (con1,localhost,user1,,); +connection con1; +SELECT @@read_only; +UPDATE t1 SET a=11 WHERE a=10; +DELETE FROM t1 WHERE a=11; +INSERT INTO t1 VALUES (20); +disconnect con1; + +connection default; +SET @@GLOBAL.read_only=0; +DROP USER user1@localhost; +DROP TABLE t1; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/grant_server.result b/mysql-test/main/grant_server.result new file mode 100644 index 00000000000..37b5f67ba4b --- /dev/null +++ b/mysql-test/main/grant_server.result @@ -0,0 +1,61 @@ +# +# Start of 10.5 tests +# +# +# Test that SERVER DDL statements are not allowed without FEDERATED ADMIN or SUPER +# +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT ALL PRIVILEGES ON *.* TO user1@localhost; +REVOKE FEDERATED ADMIN, SUPER ON *.* FROM user1@localhost; +connect con1,localhost,user1,,; +connection con1; +CREATE SERVER IF NOT EXISTS server_1 +FOREIGN DATA WRAPPER mysql +OPTIONS (USER 'mysqltest_1', HOST 'localhost', DATABASE 'test2'); +ERROR 42000: Access denied; you need (at least one of) the SUPER, FEDERATED ADMIN privilege(s) for this operation +ALTER SERVER server_1 OPTIONS(HOST 'Server.Example.Org'); +ERROR 42000: Access denied; you need (at least one of) the SUPER, FEDERATED ADMIN privilege(s) for this operation +DROP SERVER server_1; +ERROR 42000: Access denied; you need (at least one of) the SUPER, FEDERATED ADMIN privilege(s) for this operation +disconnect con1; +connection default; +DROP USER user1@localhost; +# +# Test that SERVER DDL statements are allowed with FEDERATED ADMIN +# +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT FEDERATED ADMIN ON *.* TO user1@localhost; +SHOW GRANTS FOR user1@localhost; +Grants for user1@localhost +GRANT FEDERATED ADMIN ON *.* TO `user1`@`localhost` +connect con1,localhost,user1,,; +connection con1; +CREATE SERVER IF NOT EXISTS server_1 +FOREIGN DATA WRAPPER mysql +OPTIONS (USER 'mysqltest_1', HOST 'localhost', DATABASE 'test2'); +ALTER SERVER server_1 OPTIONS(HOST 'Server.Example.Org'); +DROP SERVER server_1; +disconnect con1; +connection default; +DROP USER user1@localhost; +# +# Test that SERVER DDL statements are allowed with SUPER +# +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT SUPER ON *.* TO user1@localhost; +SHOW GRANTS FOR user1@localhost; +Grants for user1@localhost +GRANT SUPER ON *.* TO `user1`@`localhost` +connect con1,localhost,user1,,; +connection con1; +CREATE SERVER IF NOT EXISTS server_1 +FOREIGN DATA WRAPPER mysql +OPTIONS (USER 'mysqltest_1', HOST 'localhost', DATABASE 'test2'); +ALTER SERVER server_1 OPTIONS(HOST 'Server.Example.Org'); +DROP SERVER server_1; +disconnect con1; +connection default; +DROP USER user1@localhost; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/grant_server.test b/mysql-test/main/grant_server.test new file mode 100644 index 00000000000..58c6b4e9ab6 --- /dev/null +++ b/mysql-test/main/grant_server.test @@ -0,0 +1,75 @@ +-- source include/not_embedded.inc + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # Test that SERVER DDL statements are not allowed without FEDERATED ADMIN or SUPER +--echo # + +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT ALL PRIVILEGES ON *.* TO user1@localhost; +REVOKE FEDERATED ADMIN, SUPER ON *.* FROM user1@localhost; + +connect (con1,localhost,user1,,); +connection con1; +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +CREATE SERVER IF NOT EXISTS server_1 + FOREIGN DATA WRAPPER mysql + OPTIONS (USER 'mysqltest_1', HOST 'localhost', DATABASE 'test2'); +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +ALTER SERVER server_1 OPTIONS(HOST 'Server.Example.Org'); +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +DROP SERVER server_1; +disconnect con1; + +connection default; +DROP USER user1@localhost; + + +--echo # +--echo # Test that SERVER DDL statements are allowed with FEDERATED ADMIN +--echo # + +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT FEDERATED ADMIN ON *.* TO user1@localhost; +SHOW GRANTS FOR user1@localhost; + +connect (con1,localhost,user1,,); +connection con1; +CREATE SERVER IF NOT EXISTS server_1 + FOREIGN DATA WRAPPER mysql + OPTIONS (USER 'mysqltest_1', HOST 'localhost', DATABASE 'test2'); +ALTER SERVER server_1 OPTIONS(HOST 'Server.Example.Org'); +DROP SERVER server_1; +disconnect con1; + +connection default; +DROP USER user1@localhost; + + +--echo # +--echo # Test that SERVER DDL statements are allowed with SUPER +--echo # + +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT SUPER ON *.* TO user1@localhost; +SHOW GRANTS FOR user1@localhost; + +connect (con1,localhost,user1,,); +connection con1; +CREATE SERVER IF NOT EXISTS server_1 + FOREIGN DATA WRAPPER mysql + OPTIONS (USER 'mysqltest_1', HOST 'localhost', DATABASE 'test2'); +ALTER SERVER server_1 OPTIONS(HOST 'Server.Example.Org'); +DROP SERVER server_1; +disconnect con1; + +connection default; +DROP USER user1@localhost; + + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/grant_slave_admin.result b/mysql-test/main/grant_slave_admin.result new file mode 100644 index 00000000000..0f1f2c9985f --- /dev/null +++ b/mysql-test/main/grant_slave_admin.result @@ -0,0 +1,64 @@ +# +# Start of 10.5 tests +# +# +# MDEV-21743 Split up SUPER privilege to smaller privileges +# +# +# Test that slave admin statements are not allowed without REPLICATION SLAVE ADMIN or SUPER +# +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT ALL PRIVILEGES ON *.* TO user1@localhost; +REVOKE REPLICATION SLAVE ADMIN, SUPER ON *.* FROM user1@localhost; +connect con1,localhost,user1,,; +connection con1; +START SLAVE; +ERROR 42000: Access denied; you need (at least one of) the SUPER, REPLICATION SLAVE ADMIN privilege(s) for this operation +CHANGE MASTER TO MASTER_HOST='127.0.0.1'; +ERROR 42000: Access denied; you need (at least one of) the SUPER, REPLICATION SLAVE ADMIN privilege(s) for this operation +STOP SLAVE; +ERROR 42000: Access denied; you need (at least one of) the SUPER, REPLICATION SLAVE ADMIN privilege(s) for this operation +disconnect con1; +connection default; +DROP USER user1@localhost; +# +# Test that slave admin statements are allowed with REPLICATION SLAVE ADMIN +# +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT REPLICATION SLAVE ADMIN ON *.* TO user1@localhost; +SHOW GRANTS FOR user1@localhost; +Grants for user1@localhost +GRANT REPLICATION SLAVE ADMIN ON *.* TO `user1`@`localhost` +connect con1,localhost,user1,,; +connection con1; +START SLAVE; +ERROR HY000: Misconfigured slave: MASTER_HOST was not set; Fix in config file or with CHANGE MASTER TO +CHANGE MASTER TO MASTER_USER='root'; +STOP SLAVE; +Warnings: +Note 1255 Slave already has been stopped +disconnect con1; +connection default; +DROP USER user1@localhost; +# +# Test that slave admin statements are allowed with SUPER +# +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT SUPER ON *.* TO user1@localhost; +SHOW GRANTS FOR user1@localhost; +Grants for user1@localhost +GRANT SUPER ON *.* TO `user1`@`localhost` +connect con1,localhost,user1,,; +connection con1; +START SLAVE; +ERROR HY000: Misconfigured slave: MASTER_HOST was not set; Fix in config file or with CHANGE MASTER TO +CHANGE MASTER TO MASTER_USER='root'; +STOP SLAVE; +Warnings: +Note 1255 Slave already has been stopped +disconnect con1; +connection default; +DROP USER user1@localhost; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/grant_slave_admin.test b/mysql-test/main/grant_slave_admin.test new file mode 100644 index 00000000000..d73c31e0cf2 --- /dev/null +++ b/mysql-test/main/grant_slave_admin.test @@ -0,0 +1,74 @@ +-- source include/not_embedded.inc + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-21743 Split up SUPER privilege to smaller privileges +--echo # + +--echo # +--echo # Test that slave admin statements are not allowed without REPLICATION SLAVE ADMIN or SUPER +--echo # + +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT ALL PRIVILEGES ON *.* TO user1@localhost; +REVOKE REPLICATION SLAVE ADMIN, SUPER ON *.* FROM user1@localhost; + +connect (con1,localhost,user1,,); +connection con1; +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +START SLAVE; +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +CHANGE MASTER TO MASTER_HOST='127.0.0.1'; +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +STOP SLAVE; +disconnect con1; + +connection default; +DROP USER user1@localhost; + + +--echo # +--echo # Test that slave admin statements are allowed with REPLICATION SLAVE ADMIN +--echo # + +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT REPLICATION SLAVE ADMIN ON *.* TO user1@localhost; +SHOW GRANTS FOR user1@localhost; + +connect (con1,localhost,user1,,); +connection con1; +--error ER_BAD_SLAVE +START SLAVE; +CHANGE MASTER TO MASTER_USER='root'; +STOP SLAVE; +disconnect con1; + +connection default; +DROP USER user1@localhost; + + +--echo # +--echo # Test that slave admin statements are allowed with SUPER +--echo # + +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT SUPER ON *.* TO user1@localhost; +SHOW GRANTS FOR user1@localhost; + +connect (con1,localhost,user1,,); +connection con1; +--error ER_BAD_SLAVE +START SLAVE; +CHANGE MASTER TO MASTER_USER='root'; +STOP SLAVE; +disconnect con1; + +connection default; +DROP USER user1@localhost; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/grant_slave_monitor.result b/mysql-test/main/grant_slave_monitor.result new file mode 100644 index 00000000000..68df790074a --- /dev/null +++ b/mysql-test/main/grant_slave_monitor.result @@ -0,0 +1,75 @@ +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT ALL PRIVILEGES ON *.* TO user1@localhost; +REVOKE SLAVE MONITOR, SUPER ON *.* FROM user1@localhost; +FLUSH PRIVILEGES; +connect con1,localhost,user1,,; +connection con1; +SHOW GRANTS; +Grants for user1@localhost +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, BINLOG MONITOR, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, DELETE HISTORY, SET USER, FEDERATED ADMIN, CONNECTION ADMIN, READ_ONLY ADMIN, REPLICATION SLAVE ADMIN, REPLICATION MASTER ADMIN, BINLOG ADMIN, BINLOG REPLAY ON *.* TO `user1`@`localhost` +# +# Verify that having REPLICATION SLAVE ADMIN doesn't allow SHOW SLAVE STATUS +# Expected error: Access denied; you need (at least one of) the SUPER, SLAVE +# MONITOR privilege(s) for this operation +# +SHOW SLAVE STATUS; +ERROR 42000: Access denied; you need (at least one of) the SUPER, SLAVE MONITOR privilege(s) for this operation +# +# Verify that having REPLICATION SLAVE ADMIN doesn't allow SHOW RELAYLOG EVENTS +# Expected error: Access denied; you need (at least one of) the REPLICA MONITOR +# privilege(s) for this operation +# +SHOW RELAYLOG EVENTS; +ERROR 42000: Access denied; you need (at least one of) the SLAVE MONITOR privilege(s) for this operation +disconnect con1; +# +# SHOW SLAVE STATUS and SHOW RELAYLOG EVENTS are allowed with SLAVE MONITOR privilege +# +connection default; +GRANT SLAVE MONITOR ON *.* TO user1@localhost; +FLUSH PRIVILEGES; +connect con1,localhost,user1,,; +connection con1; +SHOW GRANTS; +Grants for user1@localhost +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, BINLOG MONITOR, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, DELETE HISTORY, SET USER, FEDERATED ADMIN, CONNECTION ADMIN, READ_ONLY ADMIN, REPLICATION SLAVE ADMIN, REPLICATION MASTER ADMIN, BINLOG ADMIN, BINLOG REPLAY, SLAVE MONITOR ON *.* TO `user1`@`localhost` +SHOW SLAVE STATUS; +SHOW RELAYLOG EVENTS; +disconnect con1; +connection default; +DROP USER user1@localhost; +# +# SHOW SLAVE STATUS command is allowed with SUPER privilege +# +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT SUPER ON *.* TO user1@localhost; +connect con1,localhost,user1,,; +SHOW SLAVE STATUS; +# +# SHOW RELAYLOG EVENTS is not allowed with SUPER privilege, it requires SLAVE MONITOR +# +SHOW RELAYLOG EVENTS; +ERROR 42000: Access denied; you need (at least one of) the SLAVE MONITOR privilege(s) for this operation +disconnect con1; +connection default; +DROP USER user1@localhost; +# +# MDEV-25030 Upgrade to 10.5.9 breaks root's ability to grant +# +insert mysql.global_priv values ('bar', 'foo7', '{"access":274877906943,"version_id":100507,"plugin":"mysql_native_password","authentication_string":""}'), +('bar', 'foo8', '{"access":274877906943,"version_id":100508,"plugin":"mysql_native_password","authentication_string":""}'), +('bar', 'foo9', '{"access":274877906943,"version_id":100509,"plugin":"mysql_native_password","authentication_string":""}'); +flush privileges; +show grants for foo7@bar; +Grants for foo7@bar +GRANT ALL PRIVILEGES ON *.* TO `foo7`@`bar` WITH GRANT OPTION +show grants for foo8@bar; +Grants for foo8@bar +GRANT ALL PRIVILEGES ON *.* TO `foo8`@`bar` WITH GRANT OPTION +show grants for foo9@bar; +Grants for foo9@bar +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, BINLOG MONITOR, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, DELETE HISTORY, SET USER, FEDERATED ADMIN, CONNECTION ADMIN, READ_ONLY ADMIN, REPLICATION SLAVE ADMIN, REPLICATION MASTER ADMIN, BINLOG ADMIN, BINLOG REPLAY ON *.* TO `foo9`@`bar` WITH GRANT OPTION +drop user foo7@bar, foo8@bar, foo9@bar; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/grant_slave_monitor.test b/mysql-test/main/grant_slave_monitor.test new file mode 100644 index 00000000000..af4399b7150 --- /dev/null +++ b/mysql-test/main/grant_slave_monitor.test @@ -0,0 +1,117 @@ +# ==== Purpose ==== +# +# SLAVE MONITOR privilege is required to execute following commands. +# SHOW SLAVE STATUS +# SHOW RELAYLOG EVENTS +# +# ==== Implementation ==== +# +# Step1: GRANT ALL privileges for a new user 'user1' and then REVOKE +# SLAVE MONITOR and SUPER privileges. +# Step2: Execute SHOW SLAVE STAUTS/SHOW RELAYLOG EVENTS commands and expect +# ER_SPECIFIC_ACCESS_DENIED_ERROR. This also verifies that REPLICATION +# SLAVE ADMIN privilege is not required for these two commands. +# Step3: GRANT SLAVE MONITOR privilege and observe that both commands are +# allowd to execute. +# Step4: GRANT SUPER privilege and observe that only SHOW SLAVE STATUS command +# is allowed. +# +# ==== References ==== +# +# MDEV-23610: Slave user can't run "SHOW SLAVE STATUS" anymore after upgrade +# to 10.5, mysql_upgrade should take of that +# MDEV-23918: admin privlege required to view contents of relay logs in 10.5 +# + +--source include/not_embedded.inc + +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT ALL PRIVILEGES ON *.* TO user1@localhost; +REVOKE SLAVE MONITOR, SUPER ON *.* FROM user1@localhost; +FLUSH PRIVILEGES; + +--connect(con1,localhost,user1,,) +--connection con1 +SHOW GRANTS; + +--echo # +--echo # Verify that having REPLICATION SLAVE ADMIN doesn't allow SHOW SLAVE STATUS +--echo # Expected error: Access denied; you need (at least one of) the SUPER, SLAVE +--echo # MONITOR privilege(s) for this operation +--echo # +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +SHOW SLAVE STATUS; + +--echo # +--echo # Verify that having REPLICATION SLAVE ADMIN doesn't allow SHOW RELAYLOG EVENTS +--echo # Expected error: Access denied; you need (at least one of) the REPLICA MONITOR +--echo # privilege(s) for this operation +--echo # +--disable_ps_protocol +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +SHOW RELAYLOG EVENTS; +--enable_ps_protocol +--disconnect con1 + +--echo # +--echo # SHOW SLAVE STATUS and SHOW RELAYLOG EVENTS are allowed with SLAVE MONITOR privilege +--echo # + +--connection default +GRANT SLAVE MONITOR ON *.* TO user1@localhost; +FLUSH PRIVILEGES; + +--connect(con1,localhost,user1,,) +--connection con1 +SHOW GRANTS; + +--disable_result_log +SHOW SLAVE STATUS; +--disable_ps_protocol +SHOW RELAYLOG EVENTS; +--enable_ps_protocol +--enable_result_log +--disconnect con1 + +--connection default +DROP USER user1@localhost; + +--echo # +--echo # SHOW SLAVE STATUS command is allowed with SUPER privilege +--echo # +CREATE USER user1@localhost IDENTIFIED BY ''; +GRANT SUPER ON *.* TO user1@localhost; + +--connect(con1,localhost,user1,,) +--disable_result_log +SHOW SLAVE STATUS; +--enable_result_log + +--echo # +--echo # SHOW RELAYLOG EVENTS is not allowed with SUPER privilege, it requires SLAVE MONITOR +--echo # + +--disable_ps_protocol +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +SHOW RELAYLOG EVENTS; +--enable_ps_protocol +--disconnect con1 + +--connection default +DROP USER user1@localhost; + +--echo # +--echo # MDEV-25030 Upgrade to 10.5.9 breaks root's ability to grant +--echo # +insert mysql.global_priv values ('bar', 'foo7', '{"access":274877906943,"version_id":100507,"plugin":"mysql_native_password","authentication_string":""}'), + ('bar', 'foo8', '{"access":274877906943,"version_id":100508,"plugin":"mysql_native_password","authentication_string":""}'), + ('bar', 'foo9', '{"access":274877906943,"version_id":100509,"plugin":"mysql_native_password","authentication_string":""}'); +flush privileges; +show grants for foo7@bar; +show grants for foo8@bar; +show grants for foo9@bar; +drop user foo7@bar, foo8@bar, foo9@bar; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/group_by.result b/mysql-test/main/group_by.result index db75287c61c..8c1ba102e8f 100644 --- a/mysql-test/main/group_by.result +++ b/mysql-test/main/group_by.result @@ -321,6 +321,7 @@ a c count(distinct rand()) drop table t1; CREATE TABLE t1 (a char(1)); INSERT INTO t1 VALUES ('A'),('B'),('A'),('B'),('A'),('B'),(NULL),('a'),('b'),(NULL),('A'),('B'),(NULL); +flush status; SELECT a FROM t1 GROUP BY a; a NULL @@ -359,7 +360,11 @@ A 4 B 4 a 1 b 1 -SET BIG_TABLES=1; +show status like 'Created%tables'; +Variable_name Value +Created_tmp_disk_tables 0 +Created_tmp_tables 6 +set tmp_memory_table_size=0; SELECT a FROM t1 GROUP BY a; a NULL @@ -398,7 +403,11 @@ A 4 B 4 a 1 b 1 -SET BIG_TABLES=0; +show status like 'Created%tables'; +Variable_name Value +Created_tmp_disk_tables 6 +Created_tmp_tables 12 +set tmp_memory_table_size=default; drop table t1; CREATE TABLE t1 ( `a` char(193) default NULL, @@ -515,14 +524,14 @@ a count(*) NULL 9 3 b 1 -set big_tables=1; +set tmp_memory_table_size=0; select a,count(*) from t1 group by a; a count(*) NULL 9 3 b 1 drop table t1; -set big_tables=0; +set tmp_memory_table_size=default; SET @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity,@save_optimizer_switch=@@optimizer_switch; SET optimizer_switch='outer_join_with_cache=off',@@optimizer_use_condition_selectivity=4; create table t1 (a int not null, b int not null); @@ -1569,7 +1578,7 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN SELECT a FROM t1 FORCE INDEX FOR JOIN (i2) FORCE INDEX FOR GROUP BY (i2) GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL i2 9 NULL 144 Using index +1 SIMPLE t1 range NULL i2 4 NULL 145 Using index for group-by EXPLAIN SELECT a FROM t1 USE INDEX () IGNORE INDEX (i2); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 144 @@ -1692,7 +1701,7 @@ NULL 1 1 2 EXPLAIN SELECT a from t2 GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 index NULL a 10 NULL 6 Using index +1 SIMPLE t2 range NULL a 5 NULL 7 Using index for group-by SELECT a from t2 GROUP BY a; a NULL @@ -1964,7 +1973,7 @@ DROP TABLE t1; # Bug#11765254 (58200): Assertion failed: param.sort_length when grouping # by functions # -SET BIG_TABLES=1; +set tmp_memory_table_size=0; CREATE TABLE t1(a INT); INSERT INTO t1 VALUES (0),(0); SELECT 1 FROM t1 GROUP BY IF(`a`,'',''); @@ -1991,7 +2000,7 @@ Warning 1292 Truncated incorrect INTEGER value: 'jxW<' Warning 1292 Truncated incorrect INTEGER value: 'K' Warning 1292 Truncated incorrect INTEGER value: 'jxW<' DROP TABLE t1; -SET BIG_TABLES=0; +set tmp_memory_table_size=default; # # MDEV-641 LP:1002108 - Wrong result (or crash) from a query with duplicated field in the group list and a limit clause # Bug#11761078: 53534: INCORRECT 'SELECT SQL_BIG_RESULT...' @@ -2603,6 +2612,14 @@ v 2v,2v NULL 1c,2v,2v DROP TABLE t1,t2; # +# MDEV-24855 ER_CRASHED_ON_USAGE or Assertion `length <= column->length' +# failed in ma_blockrec.c +# +CREATE TABLE t1 (a BIT(5), c BINARY(179)); +INSERT INTO t1 VALUES (b'1100','foo'),(b'0','bar'); +SELECT c, GROUP_CONCAT(CASE NULL WHEN 0 THEN a END, CASE 'foo' WHEN c THEN 1 END) AS f FROM t1 GROUP BY ExtractValue('<a></a>', '/a'), UUID(); +DROP TABLE t1; +# # MDEV-6129: Server crashes during UNION with ORDER BY field IS NULL # SET sql_mode='ONLY_FULL_GROUP_BY'; diff --git a/mysql-test/main/group_by.test b/mysql-test/main/group_by.test index 3ca518420a0..97209b50cda 100644 --- a/mysql-test/main/group_by.test +++ b/mysql-test/main/group_by.test @@ -280,21 +280,28 @@ drop table t1; CREATE TABLE t1 (a char(1)); INSERT INTO t1 VALUES ('A'),('B'),('A'),('B'),('A'),('B'),(NULL),('a'),('b'),(NULL),('A'),('B'),(NULL); +flush status; SELECT a FROM t1 GROUP BY a; SELECT a,count(*) FROM t1 GROUP BY a; SELECT a FROM t1 GROUP BY binary a; SELECT a,count(*) FROM t1 GROUP BY binary a; SELECT binary a FROM t1 GROUP BY 1; SELECT binary a,count(*) FROM t1 GROUP BY 1; -# Do the same tests with MyISAM temporary tables -SET BIG_TABLES=1; +--disable_ps_protocol +show status like 'Created%tables'; +--enable_ps_protocol +# Do the same tests with on-disk temporary tables +set tmp_memory_table_size=0; SELECT a FROM t1 GROUP BY a; SELECT a,count(*) FROM t1 GROUP BY a; SELECT a FROM t1 GROUP BY binary a; SELECT a,count(*) FROM t1 GROUP BY binary a; SELECT binary a FROM t1 GROUP BY 1; SELECT binary a,count(*) FROM t1 GROUP BY 1; -SET BIG_TABLES=0; +--disable_ps_protocol +show status like 'Created%tables'; +--enable_ps_protocol +set tmp_memory_table_size=default; drop table t1; # @@ -391,10 +398,10 @@ drop table t1,t2,t3; create table t1 (a blob null); insert into t1 values (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(""),(""),(""),("b"); select a,count(*) from t1 group by a; -set big_tables=1; +set tmp_memory_table_size=0; select a,count(*) from t1 group by a; drop table t1; -set big_tables=0; +set tmp_memory_table_size=default; # # Test of GROUP BY ... ORDER BY NULL optimization @@ -1344,7 +1351,7 @@ DROP TABLE t1; --echo # by functions --echo # -SET BIG_TABLES=1; +set tmp_memory_table_size=0; CREATE TABLE t1(a INT); INSERT INTO t1 VALUES (0),(0); SELECT 1 FROM t1 GROUP BY IF(`a`,'',''); @@ -1352,7 +1359,7 @@ SELECT 1 FROM t1 GROUP BY TRIM(LEADING RAND() FROM ''); SELECT 1 FROM t1 GROUP BY SUBSTRING('',SLEEP(0),''); SELECT 1 FROM t1 GROUP BY SUBSTRING(SYSDATE() FROM 'K' FOR 'jxW<'); DROP TABLE t1; -SET BIG_TABLES=0; +set tmp_memory_table_size=default; --echo # --echo # MDEV-641 LP:1002108 - Wrong result (or crash) from a query with duplicated field in the group list and a limit clause @@ -1710,6 +1717,18 @@ FROM t1 JOIN t2 ON c = b GROUP BY b WITH ROLLUP; DROP TABLE t1,t2; --echo # +--echo # MDEV-24855 ER_CRASHED_ON_USAGE or Assertion `length <= column->length' +--echo # failed in ma_blockrec.c +--echo # + +CREATE TABLE t1 (a BIT(5), c BINARY(179)); +INSERT INTO t1 VALUES (b'1100','foo'),(b'0','bar'); +--disable_result_log +SELECT c, GROUP_CONCAT(CASE NULL WHEN 0 THEN a END, CASE 'foo' WHEN c THEN 1 END) AS f FROM t1 GROUP BY ExtractValue('<a></a>', '/a'), UUID(); +--enable_result_log +DROP TABLE t1; + +--echo # --echo # MDEV-6129: Server crashes during UNION with ORDER BY field IS NULL --echo # diff --git a/mysql-test/main/group_min_max.result b/mysql-test/main/group_min_max.result index 8d240f9f36d..a17f3f09c3b 100644 --- a/mysql-test/main/group_min_max.result +++ b/mysql-test/main/group_min_max.result @@ -35,6 +35,8 @@ insert into t1 (a1, a2, b, c, d) values ('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'), ('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'), ('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'); +insert into t1 select * from t1; +insert into t1 select * from t1; create index idx_t1_0 on t1 (a1); create index idx_t1_1 on t1 (a1,a2,b,c); create index idx_t1_2 on t1 (a1,a2,b); @@ -290,34 +292,34 @@ b i421 l421 b m422 p422 explain select a1,a2,b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 12 Using where; Using index for group-by explain select a1,a2,b,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 13 Using where; Using index for group-by explain select a1,a2,b, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 13 Using where; Using index for group-by explain select a1, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 13 Using where; Using index for group-by explain select a1,a2,b,min(c),max(c) from t1 where a1 >= 'c' or a2 < 'b' group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by explain select a1,a2,b, max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 9 Using where; Using index for group-by explain select a1,a2,b,min(c),max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 9 Using where; Using index for group-by explain select a1,a2,b, max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 9 Using where; Using index for group-by explain select a1,a2,b,min(c),max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 9 Using where; Using index for group-by explain select a1,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 13 Using where; Using index for group-by explain select a1, max(c) from t1 where a1 in ('a','b','d') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 13 Using where; Using index for group-by @@ -1361,9 +1363,9 @@ explain select a1,a2,b,min(c),max(c) from t1 where exists ( select * from t2 where t2.c = t1.c ) group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using index +1 PRIMARY t1 index NULL idx_t1_1 163 NULL 512 Using index 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 16 func 1 -2 MATERIALIZED t2 index NULL idx_t2_1 163 NULL 164 Using index +2 MATERIALIZED t2 index NULL idx_t2_1 163 NULL 548 Using index select a1,a2,b,min(c),max(c) from t1 where exists ( select * from t2 where t2.c = t1.c ) group by a1,a2,b; @@ -1388,8 +1390,8 @@ explain select a1,a2,b,min(c),max(c) from t1 where exists ( select * from t2 where t2.c > 'b1' ) group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using index -2 SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index +1 PRIMARY t1 index NULL idx_t1_1 163 NULL 512 Using index +2 SUBQUERY t2 index NULL idx_t2_1 163 NULL 548 Using where; Using index select a1,a2,b,min(c),max(c) from t1 where exists ( select * from t2 where t2.c > 'b1' ) group by a1,a2,b; @@ -1414,8 +1416,8 @@ explain select a1,a2,b,c,min(c), max(c) from t1 where exists ( select * from t2 where t1.b > 'a' and t2.c > 'b1' ) group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index -2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index +1 PRIMARY t1 index NULL idx_t1_1 163 NULL 512 Using where; Using index +2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 548 Using where; Using index select a1,a2,b,c,min(c), max(c) from t1 where exists ( select * from t2 where t1.b > 'a' and t2.c > 'b1' ) group by a1,a2,b; @@ -1436,8 +1438,8 @@ where t2.c in (select c from t3 where t3.c > t1.b) and t2.c > 'b1' ) group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index -2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index +1 PRIMARY t1 index NULL idx_t1_1 163 NULL 512 Using where; Using index +2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 548 Using where; Using index 2 DEPENDENT SUBQUERY t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index; FirstMatch(t2) select a1,a2,b,c,min(c), max(c) from t1 where exists ( select * from t2 @@ -1466,8 +1468,8 @@ explain select a1,a2,b,c,min(c), max(c) from t1 where exists ( select * from t2 where t1.c > 'a' and t2.c > 'b1' ) group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index -2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index +1 PRIMARY t1 index NULL idx_t1_1 163 NULL 512 Using where; Using index +2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 548 Using where; Using index select a1,a2,b,c,min(c), max(c) from t1 where exists ( select * from t2 where t1.c > 'a' and t2.c > 'b1' ) group by a1,a2,b; @@ -1496,8 +1498,8 @@ where t2.c in (select c from t3 where t3.c > t1.c) and t2.c > 'b1' ) group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index -2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index +1 PRIMARY t1 index NULL idx_t1_1 163 NULL 512 Using where; Using index +2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 548 Using where; Using index 2 DEPENDENT SUBQUERY t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index; FirstMatch(t2) select a1,a2,b,c,min(c), max(c) from t1 where exists ( select * from t2 @@ -1533,13 +1535,13 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by explain select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 14 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 13 Using where; Using index for group-by explain select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 14 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 13 Using where; Using index for group-by explain select a1,a2,b,min(c) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 13 Using where; Using index for group-by explain select a1,a2,b,min(c) from t1 where (ord(a1) > 97) and (ord(a2) + ord(a1) > 194) and (b = 'c') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by @@ -1656,7 +1658,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by explain select a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 13 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 13 Using where; Using index for group-by explain select a1,a2,b from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by @@ -1716,15 +1718,15 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by explain extended select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121'); id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 0.38 Using where; Using index +1 SIMPLE t1 range NULL idx_t1_1 163 NULL 65 100.00 Using where; Using index for group-by Warnings: Note 1003 select distinct `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where `test`.`t1`.`b` = 'a' and `test`.`t1`.`c` = 'i121' and `test`.`t1`.`a2` >= 'b' explain select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c'); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 13 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 13 Using where; Using index for group-by explain select distinct b from t1 where (a2 >= 'b') and (b = 'a'); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index +1 SIMPLE t1 index NULL idx_t1_2 147 NULL 512 Using where; Using index explain select distinct a1,a2,b from t2; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using index for group-by @@ -1733,7 +1735,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using where; Using index for group-by explain extended select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121'); id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 0.30 Using where; Using index +1 SIMPLE t2 range NULL idx_t2_1 163 NULL 69 100.00 Using where; Using index for group-by Warnings: Note 1003 select distinct `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where `test`.`t2`.`b` = 'a' and `test`.`t2`.`c` = 'i121' and `test`.`t2`.`a2` >= 'b' explain select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c'); @@ -1741,7 +1743,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by explain select distinct b from t2 where (a2 >= 'b') and (b = 'a'); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 index NULL idx_t2_2 146 NULL 164 Using where; Using index +1 SIMPLE t2 index NULL idx_t2_2 146 NULL 548 Using where; Using index select distinct a1,a2,b from t1; a1 a2 b a a a @@ -1867,7 +1869,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by explain select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 13 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 13 Using where; Using index for group-by explain select distinct b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by; Using temporary; Using filesort @@ -1959,18 +1961,18 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by explain select count(distinct a1,a2,b,c) from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121'); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL idx_t1_1 163 NULL 65 Using where; Using index for group-by (scanning) +1 SIMPLE t1 range NULL idx_t1_1 163 NULL 65 Using where; Using index for group-by explain extended select count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c'); id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 13 100.00 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 13 100.00 Using where; Using index for group-by Warnings: Note 1003 select count(distinct `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`) AS `count(distinct a1,a2,b)` from `test`.`t1` where `test`.`t1`.`b` = 'c' and `test`.`t1`.`a1` > 'a' and `test`.`t1`.`a2` > 'a' explain select count(distinct b) from t1 where (a2 >= 'b') and (b = 'a'); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index +1 SIMPLE t1 index NULL idx_t1_2 147 NULL 512 Using where; Using index explain extended select 98 + count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a'); id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 13 100.00 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 13 100.00 Using where; Using index for group-by Warnings: Note 1003 select 98 + count(distinct `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`) AS `98 + count(distinct a1,a2,b)` from `test`.`t1` where `test`.`t1`.`a1` > 'a' and `test`.`t1`.`a2` > 'a' select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a'); @@ -1990,16 +1992,16 @@ select 98 + count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a'); 104 explain select a1,a2,b, concat(min(c), max(c)) from t1 where a1 < 'd' group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 12 Using where; Using index for group-by explain select concat(a1,min(c)),b from t1 where a1 < 'd' group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 12 Using where; Using index for group-by explain select concat(a1,min(c)),b,max(c) from t1 where a1 < 'd' group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 12 Using where; Using index for group-by explain select concat(a1,a2),b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 12 Using where; Using index for group-by explain select concat(ord(min(b)),ord(max(b))),min(b),max(b) from t1 group by a1,a2; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 9 Using index for group-by @@ -2071,63 +2073,63 @@ concat(ord(min(b)),ord(max(b))) min(b) max(b) 9798 a b explain select a1,a2,b,d,min(c),max(c) from t1 group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 128 Using temporary; Using filesort +1 SIMPLE t1 ALL NULL NULL NULL NULL 512 Using temporary; Using filesort explain select a1,a2,b,d from t1 group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 128 Using temporary; Using filesort +1 SIMPLE t1 ALL NULL NULL NULL NULL 512 Using temporary; Using filesort explain extended select a1,a2,min(b),max(b) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 77 99.22 Using where; Using index +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 276 99.22 Using where; Using index Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,min(`test`.`t1`.`b`) AS `min(b)`,max(`test`.`t1`.`b`) AS `max(b)` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`c` > 'a111' group by `test`.`t1`.`a1`,`test`.`t1`.`a2` explain extended select a1,a2,b,min(c),max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 128 45.12 Using where; Using temporary; Using filesort +1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 512 40.43 Using where; Using temporary; Using filesort Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`d` > 'xy2' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` explain extended select a1,a2,b,c from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b,c; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 128 45.12 Using where; Using temporary; Using filesort +1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 512 40.43 Using where; Using temporary; Using filesort Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`d` > 'xy2' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`,`test`.`t1`.`c` explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b < 'b') group by a1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index +1 SIMPLE t2 index NULL idx_t2_1 163 NULL 548 Using where; Using index explain extended select a1,a2,b from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 77 99.22 Using where; Using index +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 276 99.22 Using where; Using index Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`c` > 'a111' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` explain select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index +1 SIMPLE t2 index NULL idx_t2_1 163 NULL 548 Using where; Using index select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1; a1 a2 min(b) c a a a a111 explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b = 'a') group by a1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index +1 SIMPLE t2 index NULL idx_t2_1 163 NULL 548 Using where; Using index explain select a1,a2,b,min(c),max(c) from t2 where (c > 'a000') and (c <= 'd999') and (c like '_8__') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index +1 SIMPLE t2 index NULL idx_t2_1 163 NULL 548 Using where; Using index explain select a1, a2, b, c, min(d), max(d) from t1 group by a1,a2,b,c; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 128 Using temporary; Using filesort +1 SIMPLE t1 ALL NULL NULL NULL NULL 512 Using temporary; Using filesort explain select a1,a2,count(a2) from t1 group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using index +1 SIMPLE t1 index NULL idx_t1_2 147 NULL 512 Using index explain extended select a1,a2,count(a2) from t1 where (a1 > 'a') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 65 NULL 101 95.05 Using where; Using index +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 65 NULL 392 100.00 Using where; Using index Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,count(`test`.`t1`.`a2`) AS `count(a2)` from `test`.`t1` where `test`.`t1`.`a1` > 'a' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` explain extended select sum(ord(a1)) from t1 where (a1 > 'a') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 65 NULL 101 95.05 Using where; Using index +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 65 NULL 392 100.00 Using where; Using index Warnings: Note 1003 select sum(ord(`test`.`t1`.`a1`)) AS `sum(ord(a1))` from `test`.`t1` where `test`.`t1`.`a1` > 'a' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` create table t4 as select distinct a1, a2, b, c from t1; @@ -2158,7 +2160,7 @@ d b b m422 drop table t4; explain select distinct(a1) from t1 where ord(a2) = 98; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index +1 SIMPLE t1 index NULL idx_t1_2 147 NULL 512 Using where; Using index select distinct(a1) from t1 where ord(a2) = 98; a1 a @@ -2372,7 +2374,7 @@ CREATE TABLE t2 (a int, b int, c int, PRIMARY KEY (a,b,c)); INSERT INTO t2 SELECT a,b,b FROM t1; explain SELECT MIN(c) FROM t2 WHERE b = 2 and a = 1 and c > 1 GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range PRIMARY PRIMARY 12 NULL 1 Using where; Using index for group-by +1 SIMPLE t2 range PRIMARY PRIMARY 12 NULL 1 Using where; Using index SELECT MIN(c) FROM t2 WHERE b = 2 and a = 1 and c > 1 GROUP BY a; MIN(c) 2 @@ -2386,7 +2388,7 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK EXPLAIN SELECT max(b), a FROM t1 GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL a 10 NULL 15 Using index +1 SIMPLE t1 range NULL a 5 NULL 6 Using index for group-by FLUSH STATUS; SELECT max(b), a FROM t1 GROUP BY a; max(b) a @@ -2396,18 +2398,18 @@ max(b) a 6 4 SHOW STATUS LIKE 'handler_read__e%'; Variable_name Value -Handler_read_key 0 -Handler_read_next 15 +Handler_read_key 8 +Handler_read_next 0 Handler_read_retry 0 EXPLAIN SELECT max(b), a FROM t1 GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL a 10 NULL 15 Using index +1 SIMPLE t1 range NULL a 5 NULL 6 Using index for group-by FLUSH STATUS; CREATE TABLE t2 SELECT max(b), a FROM t1 GROUP BY a; SHOW STATUS LIKE 'handler_read__e%'; Variable_name Value -Handler_read_key 0 -Handler_read_next 15 +Handler_read_key 8 +Handler_read_next 0 Handler_read_retry 0 FLUSH STATUS; SELECT * FROM (SELECT max(b), a FROM t1 GROUP BY a) b; @@ -2418,8 +2420,8 @@ max(b) a 6 4 SHOW STATUS LIKE 'handler_read__e%'; Variable_name Value -Handler_read_key 0 -Handler_read_next 15 +Handler_read_key 8 +Handler_read_next 0 Handler_read_retry 0 FLUSH STATUS; (SELECT max(b), a FROM t1 GROUP BY a) UNION @@ -2431,20 +2433,20 @@ max(b) a 6 4 SHOW STATUS LIKE 'handler_read__e%'; Variable_name Value -Handler_read_key 0 -Handler_read_next 30 +Handler_read_key 16 +Handler_read_next 0 Handler_read_retry 0 EXPLAIN (SELECT max(b), a FROM t1 GROUP BY a) UNION (SELECT max(b), a FROM t1 GROUP BY a); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index NULL a 10 NULL 15 Using index -2 UNION t1 index NULL a 10 NULL 15 Using index +1 PRIMARY t1 range NULL a 5 NULL 6 Using index for group-by +2 UNION t1 range NULL a 5 NULL 6 Using index for group-by NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL EXPLAIN SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x FROM t1 AS t1_outer; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index -2 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index for group-by +2 SUBQUERY t1 range a a 5 NULL 5 Using where; Using index EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE EXISTS (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); id select_type table type possible_keys key key_len ref rows Extra @@ -2454,38 +2456,38 @@ EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE -2 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index for group-by +2 SUBQUERY t1 range a a 5 NULL 5 Using where; Using index EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE a IN (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2 -1 PRIMARY t1_outer ref a a 5 <subquery2>.max(b) 3 Using index -2 MATERIALIZED t1 range a a 5 NULL 2 Using where; Using index for group-by +1 PRIMARY t1_outer index a a 10 NULL 15 Using where; Using index +1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 test.t1_outer.a 1 +2 MATERIALIZED t1 range a a 5 NULL 5 Using where; Using index EXPLAIN SELECT 1 FROM t1 AS t1_outer GROUP BY a HAVING a > (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index -2 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index for group-by +1 PRIMARY t1_outer range NULL a 5 NULL 6 Using index for group-by +2 SUBQUERY t1 range a a 5 NULL 5 Using where; Using index EXPLAIN SELECT 1 FROM t1 AS t1_outer1 JOIN t1 AS t1_outer2 ON t1_outer1.a = (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) AND t1_outer1.b = t1_outer2.b; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1_outer1 ref a a 5 const 1 Using where; Using index 1 PRIMARY t1_outer2 index NULL a 10 NULL 15 Using where; Using index; Using join buffer (flat, BNL join) -2 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index for group-by +2 SUBQUERY t1 range a a 5 NULL 5 Using where; Using index EXPLAIN SELECT (SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x FROM t1 AS t1_outer) x2 FROM t1 AS t1_outer2; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1_outer2 index NULL a 10 NULL 15 Using index 2 SUBQUERY t1_outer index NULL a 10 NULL 15 Using index -3 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index for group-by +3 SUBQUERY t1 range a a 5 NULL 5 Using where; Using index CREATE TABLE t3 LIKE t1; FLUSH STATUS; INSERT INTO t3 SELECT a,MAX(b) FROM t1 GROUP BY a; SHOW STATUS LIKE 'handler_read__e%'; Variable_name Value -Handler_read_key 5 -Handler_read_next 15 +Handler_read_key 13 +Handler_read_next 0 Handler_read_retry 0 DELETE FROM t3; FLUSH STATUS; @@ -2493,15 +2495,15 @@ INSERT INTO t3 SELECT 1, (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) FROM t1 LIMIT 1; SHOW STATUS LIKE 'handler_read__e%'; Variable_name Value -Handler_read_key 0 -Handler_read_next 15 +Handler_read_key 8 +Handler_read_next 0 Handler_read_retry 0 FLUSH STATUS; DELETE FROM t3 WHERE (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) > 10000; SHOW STATUS LIKE 'handler_read__e%'; Variable_name Value -Handler_read_key 0 -Handler_read_next 15 +Handler_read_key 8 +Handler_read_next 0 Handler_read_retry 0 FLUSH STATUS; DELETE FROM t3 WHERE (SELECT (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) x @@ -2509,8 +2511,8 @@ FROM t1) > 10000; ERROR 21000: Subquery returns more than 1 row SHOW STATUS LIKE 'handler_read__e%'; Variable_name Value -Handler_read_key 0 -Handler_read_next 16 +Handler_read_key 8 +Handler_read_next 1 Handler_read_retry 0 DROP TABLE t1,t2,t3; CREATE TABLE t1 (a int, INDEX idx(a)); @@ -2662,7 +2664,7 @@ a b 3 13 explain extended select sql_buffer_result a, max(b)+1 from t1 where a = 0 group by a; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ref a,index a 5 const 15 100.00 Using index; Using temporary +1 SIMPLE t1 ref a,index a 5 const 15 20.00 Using index; Using temporary Warnings: Note 1003 select sql_buffer_result `test`.`t1`.`a` AS `a`,max(`test`.`t1`.`b`) + 1 AS `max(b)+1` from `test`.`t1` where `test`.`t1`.`a` = 0 group by `test`.`t1`.`a` drop table t1; @@ -3662,7 +3664,7 @@ f1 COUNT(DISTINCT f2) 3 4 explain SELECT f1, COUNT(DISTINCT f2) FROM t1 GROUP BY f1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL f1 5 NULL 9 Using index for group-by (scanning) +1 SIMPLE t1 range NULL f1 5 NULL 9 Using index for group-by drop table t1; # End of test#50539. # @@ -4000,10 +4002,10 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away explain select min(a) from t1 where a between "a" and "Cafeeeeeeeeeeeeeeeeeeeeeeeeee"; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index a a 13 NULL 2 Using where; Using index +1 SIMPLE t1 range a a 13 NULL 2 Using where; Using index explain select min(a) from t1 where a between "abbbbbbbbbbbbbbbbbbbb" and "Cafe2"; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index a a 13 NULL 2 Using where; Using index +1 SIMPLE t1 range a a 13 NULL 2 Using where; Using index drop table t1; # # MDEV-15433: Optimizer does not use group by optimization with distinct diff --git a/mysql-test/main/group_min_max.test b/mysql-test/main/group_min_max.test index 0dc7ea2fee7..526552dda92 100644 --- a/mysql-test/main/group_min_max.test +++ b/mysql-test/main/group_min_max.test @@ -53,6 +53,8 @@ insert into t1 (a1, a2, b, c, d) values ('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'), ('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'), ('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'); +insert into t1 select * from t1; +insert into t1 select * from t1; create index idx_t1_0 on t1 (a1); create index idx_t1_1 on t1 (a1,a2,b,c); diff --git a/mysql-test/main/index_intersect.result b/mysql-test/main/index_intersect.result index bb2478c8c46..3ec98216479 100644 --- a/mysql-test/main/index_intersect.result +++ b/mysql-test/main/index_intersect.result @@ -80,7 +80,7 @@ EXPLAIN SELECT * FROM City WHERE Name LIKE 'M%' AND Population > 7000000; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City range Population,Name Population 4 NULL # Using index condition; Using where +1 SIMPLE City index_merge Population,Name Population,Name 4,35 NULL # Using sort_intersect(Population,Name); Using where SELECT * FROM City USE INDEX () WHERE Name LIKE 'C%' AND Population > 1000000; ID Name Country Population @@ -335,8 +335,8 @@ ID Name Country Population SELECT * FROM City WHERE Name LIKE 'M%' AND Population > 7000000; ID Name Country Population -3580 Moscow RUS 8389200 1024 Mumbai (Bombay) IND 10500000 +3580 Moscow RUS 8389200 SELECT COUNT(*) FROM City WHERE Name BETWEEN 'M' AND 'N'; COUNT(*) 301 @@ -368,14 +368,14 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE City index_merge Population,Country,Name Name,Population 35,4 NULL # Using sort_intersect(Name,Population); Using where EXPLAIN SELECT * FROM City -WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%'; +WHERE Name BETWEEN 'G' AND 'K' AND Population > 1000000 AND Country LIKE 'J%'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City index_merge Population,Country,Name Population,Country 4,3 NULL # Using sort_intersect(Population,Country); Using where +1 SIMPLE City index_merge Population,Country,Name Population,Country,Name 4,3,35 NULL # Using sort_intersect(Population,Country,Name); Using where EXPLAIN SELECT * FROM City WHERE Name BETWEEN 'G' AND 'K' AND Population > 500000 AND Country LIKE 'C%'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City range Population,Name,Country Name # NULL # Using index condition; Using where +1 SIMPLE City index_merge Population,Name,Country Name,Country,Population # NULL # Using sort_intersect(Name,Country,Population); Using where SELECT * FROM City USE INDEX () WHERE Name BETWEEN 'M' AND 'N' AND Population > 1000000 AND Country LIKE 'C%'; ID Name Country Population @@ -387,12 +387,14 @@ ID Name Country Population 1810 Montréal CAN 1016376 2259 MedellÃn COL 1861265 SELECT * FROM City USE INDEX () -WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%'; +WHERE Name BETWEEN 'G' AND 'K' AND Population > 1000000 AND Country LIKE 'J%'; ID Name Country Population +1533 Jokohama [Yokohama] JPN 3339594 1541 Hiroshima JPN 1119117 SELECT * FROM City -WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%'; +WHERE Name BETWEEN 'G' AND 'K' AND Population > 1000000 AND Country LIKE 'J%'; ID Name Country Population +1533 Jokohama [Yokohama] JPN 3339594 1541 Hiroshima JPN 1119117 SELECT * FROM City USE INDEX () WHERE Name BETWEEN 'G' AND 'K' AND Population > 500000 AND Country LIKE 'C%'; @@ -464,17 +466,17 @@ EXPLAIN SELECT * FROM City WHERE ID BETWEEN 501 AND 1000 AND Population > 700000 AND Country LIKE 'C%'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City range PRIMARY,Population,Country Population 4 NULL # Using index condition; Using where +1 SIMPLE City index_merge PRIMARY,Population,Country Population,PRIMARY,Country 4,4,3 NULL # Using sort_intersect(Population,PRIMARY,Country); Using where EXPLAIN SELECT * FROM City WHERE ID BETWEEN 1 AND 500 AND Population > 700000 AND Country LIKE 'C%'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City range PRIMARY,Population,Country Population 4 NULL # Using index condition; Using where +1 SIMPLE City index_merge PRIMARY,Population,Country Population,PRIMARY,Country 4,4,3 NULL # Using sort_intersect(Population,PRIMARY,Country); Using where EXPLAIN SELECT * FROM City WHERE ID BETWEEN 2001 AND 2500 AND Population > 300000 AND Country LIKE 'H%'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City range PRIMARY,Population,Country Country 3 NULL # Using index condition; Using where +1 SIMPLE City index_merge PRIMARY,Population,Country Country,PRIMARY 3,4 NULL # Using sort_intersect(Country,PRIMARY); Using where EXPLAIN SELECT * FROM City WHERE ID BETWEEN 3701 AND 4000 AND Population > 1000000 @@ -693,7 +695,7 @@ ID Name Country Population 3808 Austin USA 656562 3809 Baltimore USA 651154 3810 Memphis USA 650100 -SET SESSION sort_buffer_size = 2048; +SET SESSION sort_buffer_size = IF(@@version_compile_machine like '%64%', 2048, 1536); EXPLAIN SELECT * FROM City WHERE Name LIKE 'C%' AND Population > 1000000; @@ -706,7 +708,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE City index_merge Population,Name Population,Name 4,35 NULL # Using sort_intersect(Population,Name); Using where EXPLAIN SELECT * FROM City -WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%'; +WHERE Name BETWEEN 'G' AND 'K' AND Population > 1000000 AND Country LIKE 'J%'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE City index_merge Population,Country,Name Population,Country 4,3 NULL # Using sort_intersect(Population,Country); Using where EXPLAIN diff --git a/mysql-test/main/index_intersect.test b/mysql-test/main/index_intersect.test index a3fbe0de8b9..26937fd5eef 100644 --- a/mysql-test/main/index_intersect.test +++ b/mysql-test/main/index_intersect.test @@ -139,7 +139,7 @@ SELECT * FROM City --replace_column 9 # EXPLAIN SELECT * FROM City - WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%'; + WHERE Name BETWEEN 'G' AND 'K' AND Population > 1000000 AND Country LIKE 'J%'; --replace_column 7 # 9 # --replace_result Population,Country,Name Population,Name,Country @@ -161,11 +161,11 @@ SELECT * FROM City SELECT * FROM City USE INDEX () - WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%'; + WHERE Name BETWEEN 'G' AND 'K' AND Population > 1000000 AND Country LIKE 'J%'; --sorted_result SELECT * FROM City - WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%'; + WHERE Name BETWEEN 'G' AND 'K' AND Population > 1000000 AND Country LIKE 'J%'; SELECT * FROM City USE INDEX () @@ -275,10 +275,22 @@ SELECT * FROM City USE INDEX () SELECT * FROM City WHERE ID BETWEEN 3001 AND 4000 AND Population > 600000 AND Country BETWEEN 'S' AND 'Z' ; + +# Originally this was just sort_buffer_size=2048. Then, it started +# failing on 32bit due to different cost number in +# Unique::get_use_cost() because of sizeof(sizeof(TREE_ELEMENT)+key_size) +# On 64 bit: Unique object element_size=32, which gives 2048/32= 64 elements +# in the tree. +# On 32 bit: Unique object element_size=24. +# If we want 64 elements in the tree, we need 64*24=1536 as sort_buffer_size. -SET SESSION sort_buffer_size = 2048; +# The purpose of setting sort_buffer_size is to show that some of the following +# explains should use 'index_merge' while others should use range +# If the following code causes future problems, the other option would be +# to create a separate result-.diff file for 32 bit. +SET SESSION sort_buffer_size = IF(@@version_compile_machine like '%64%', 2048, 1536); # The following EXPLAIN command demonstrate that the execution plans # may be different if sort_buffer_size is set to a small value @@ -298,7 +310,7 @@ SELECT * FROM City WHERE --replace_column 9 # EXPLAIN SELECT * FROM City - WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%'; + WHERE Name BETWEEN 'G' AND 'K' AND Population > 1000000 AND Country LIKE 'J%'; --replace_column 9 # EXPLAIN diff --git a/mysql-test/main/index_intersect_innodb.result b/mysql-test/main/index_intersect_innodb.result index fed33b3d9bd..44407dbcd30 100644 --- a/mysql-test/main/index_intersect_innodb.result +++ b/mysql-test/main/index_intersect_innodb.result @@ -1,4 +1,4 @@ -SET SESSION STORAGE_ENGINE='InnoDB'; +SET SESSION DEFAULT_STORAGE_ENGINE='InnoDB'; set @innodb_stats_persistent_save= @@innodb_stats_persistent; set @innodb_stats_persistent_sample_pages_save= @@innodb_stats_persistent_sample_pages; @@ -86,7 +86,7 @@ EXPLAIN SELECT * FROM City WHERE Name LIKE 'M%' AND Population > 7000000; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City range Population,Name Population 4 NULL # Using index condition; Using where +1 SIMPLE City index_merge Population,Name Population,Name 4,35 NULL # Using sort_intersect(Population,Name); Using where SELECT * FROM City USE INDEX () WHERE Name LIKE 'C%' AND Population > 1000000; ID Name Country Population @@ -341,8 +341,8 @@ ID Name Country Population SELECT * FROM City WHERE Name LIKE 'M%' AND Population > 7000000; ID Name Country Population -3580 Moscow RUS 8389200 1024 Mumbai (Bombay) IND 10500000 +3580 Moscow RUS 8389200 SELECT COUNT(*) FROM City WHERE Name BETWEEN 'M' AND 'N'; COUNT(*) 301 @@ -371,12 +371,12 @@ EXPLAIN SELECT * FROM City WHERE Name BETWEEN 'M' AND 'N' AND Population > 1000000 AND Country LIKE 'C%'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City index_merge Population,Country,Name Population,Name 4,35 NULL # Using sort_intersect(Population,Name); Using where +1 SIMPLE City index_merge Population,Country,Name Population,Name,Country 4,35,3 NULL # Using sort_intersect(Population,Name,Country); Using where EXPLAIN SELECT * FROM City -WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%'; +WHERE Name BETWEEN 'G' AND 'K' AND Population > 1000000 AND Country LIKE 'J%'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City index_merge Population,Country,Name Population,Country 4,3 NULL # Using sort_intersect(Population,Country); Using where +1 SIMPLE City index_merge Population,Country,Name Population,Country,Name 4,3,35 NULL # Using sort_intersect(Population,Country,Name); Using where EXPLAIN SELECT * FROM City WHERE Name BETWEEN 'G' AND 'K' AND Population > 500000 AND Country LIKE 'C%'; @@ -393,12 +393,14 @@ ID Name Country Population 1810 Montréal CAN 1016376 2259 MedellÃn COL 1861265 SELECT * FROM City USE INDEX () -WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%'; +WHERE Name BETWEEN 'G' AND 'K' AND Population > 1000000 AND Country LIKE 'J%'; ID Name Country Population +1533 Jokohama [Yokohama] JPN 3339594 1541 Hiroshima JPN 1119117 SELECT * FROM City -WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%'; +WHERE Name BETWEEN 'G' AND 'K' AND Population > 1000000 AND Country LIKE 'J%'; ID Name Country Population +1533 Jokohama [Yokohama] JPN 3339594 1541 Hiroshima JPN 1119117 SELECT * FROM City USE INDEX () WHERE Name BETWEEN 'G' AND 'K' AND Population > 500000 AND Country LIKE 'C%'; @@ -480,19 +482,19 @@ EXPLAIN SELECT * FROM City WHERE ID BETWEEN 2001 AND 2500 AND Population > 300000 AND Country LIKE 'H%'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City range PRIMARY,Population,Country Country 7 NULL # Using index condition; Using where +1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Population,Country 4,4,7 NULL # Using sort_intersect(PRIMARY,Population,Country); Using where EXPLAIN SELECT * FROM City WHERE ID BETWEEN 3701 AND 4000 AND Population > 1000000 AND Country BETWEEN 'S' AND 'Z'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Population 4,4 NULL # Using sort_intersect(PRIMARY,Population); Using where +1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Population,Country 4,4,7 NULL # Using sort_intersect(PRIMARY,Population,Country); Using where EXPLAIN SELECT * FROM City WHERE ID BETWEEN 3001 AND 4000 AND Population > 600000 AND Country BETWEEN 'S' AND 'Z' ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City range PRIMARY,Population,Country PRIMARY 4 NULL # Using where +1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Population,Country 4,4,7 NULL # Using sort_intersect(PRIMARY,Population,Country); Using where SELECT * FROM City USE INDEX () WHERE ID BETWEEN 501 AND 1000 AND Population > 700000 AND Country LIKE 'C%'; ID Name Country Population @@ -699,7 +701,7 @@ ID Name Country Population 3808 Austin USA 656562 3809 Baltimore USA 651154 3810 Memphis USA 650100 -SET SESSION sort_buffer_size = 2048; +SET SESSION sort_buffer_size = IF(@@version_compile_machine like '%64%', 2048, 1536); EXPLAIN SELECT * FROM City WHERE Name LIKE 'C%' AND Population > 1000000; @@ -712,7 +714,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE City index_merge Population,Name Population,Name 4,35 NULL # Using sort_intersect(Population,Name); Using where EXPLAIN SELECT * FROM City -WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%'; +WHERE Name BETWEEN 'G' AND 'K' AND Population > 1000000 AND Country LIKE 'J%'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE City index_merge Population,Country,Name Population,Country 4,3 NULL # Using sort_intersect(Population,Country); Using where EXPLAIN @@ -983,4 +985,4 @@ SET SESSION optimizer_switch='rowid_filter=default'; set global innodb_stats_persistent= @innodb_stats_persistent_save; set global innodb_stats_persistent_sample_pages= @innodb_stats_persistent_sample_pages_save; -SET SESSION STORAGE_ENGINE=DEFAULT; +SET SESSION DEFAULT_STORAGE_ENGINE=DEFAULT; diff --git a/mysql-test/main/index_intersect_innodb.test b/mysql-test/main/index_intersect_innodb.test index 637056ad795..d1c6ac7fa16 100644 --- a/mysql-test/main/index_intersect_innodb.test +++ b/mysql-test/main/index_intersect_innodb.test @@ -1,6 +1,6 @@ --source include/have_innodb.inc -SET SESSION STORAGE_ENGINE='InnoDB'; +SET SESSION DEFAULT_STORAGE_ENGINE='InnoDB'; set @innodb_stats_persistent_save= @@innodb_stats_persistent; set @innodb_stats_persistent_sample_pages_save= @@ -13,4 +13,4 @@ set global innodb_stats_persistent= @innodb_stats_persistent_save; set global innodb_stats_persistent_sample_pages= @innodb_stats_persistent_sample_pages_save; -SET SESSION STORAGE_ENGINE=DEFAULT; +SET SESSION DEFAULT_STORAGE_ENGINE=DEFAULT; diff --git a/mysql-test/main/index_merge_innodb.result b/mysql-test/main/index_merge_innodb.result index e72e2c78d98..775ef3d01e5 100644 --- a/mysql-test/main/index_merge_innodb.result +++ b/mysql-test/main/index_merge_innodb.result @@ -2,7 +2,7 @@ connect disable_purge,localhost,root,,; # Disable the purge of InnoDB history, to make the test run faster. START TRANSACTION WITH CONSISTENT SNAPSHOT; connection default; -SET STORAGE_ENGINE = InnoDB; +SET DEFAULT_STORAGE_ENGINE = InnoDB; set @optimizer_switch_save= @@optimizer_switch; set optimizer_switch='index_merge_sort_intersection=off'; set optimizer_switch='rowid_filter=off'; diff --git a/mysql-test/main/index_merge_innodb.test b/mysql-test/main/index_merge_innodb.test index 4bdcb17760e..c0918fec79f 100644 --- a/mysql-test/main/index_merge_innodb.test +++ b/mysql-test/main/index_merge_innodb.test @@ -19,7 +19,7 @@ connect disable_purge,localhost,root,,; START TRANSACTION WITH CONSISTENT SNAPSHOT; connection default; -SET STORAGE_ENGINE = InnoDB; +SET DEFAULT_STORAGE_ENGINE = InnoDB; # InnoDB does not support Merge tables (affects include/index_merge1.inc) let $merge_table_support= 0; diff --git a/mysql-test/main/index_merge_myisam.result b/mysql-test/main/index_merge_myisam.result index 55caf051720..053239b7fb1 100644 --- a/mysql-test/main/index_merge_myisam.result +++ b/mysql-test/main/index_merge_myisam.result @@ -1,4 +1,4 @@ -SET STORAGE_ENGINE = MyISAM; +SET DEFAULT_STORAGE_ENGINE = MyISAM; set @optimizer_switch_save= @@optimizer_switch; set optimizer_switch='rowid_filter=off'; set optimizer_switch='index_merge_sort_intersection=off'; @@ -215,7 +215,7 @@ alter table t2 add index i321(key3, key2, key1); explain select key3 from t2 where key1 = 100 or key2 = 100; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 index_merge i1_3,i2_3 i1_3,i2_3 4,4 NULL 2 Using sort_union(i1_3,i2_3); Using where -explain select key3 from t2 where key1 < 500 or key2 < 500; +explain select key3 from t2 where key1 < 600 or key2 < 600; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 index i1_3,i2_3 i321 12 NULL 1024 Using where; Using index explain select key7 from t2 where key1 <100 or key2 < 100; @@ -1475,7 +1475,7 @@ EXPLAIN SELECT t1.f1 FROM t1 WHERE (SELECT COUNT(*) FROM t2 WHERE t2.f3 = 'h' AND t2.f2 = t1.f1) = 0 AND t1.f1 = 2; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system PRIMARY NULL NULL NULL 1 -2 SUBQUERY t2 ref f2,f3 f2 5 const 2 Using where +2 SUBQUERY t2 ref f2,f3 f3 2 const 2 Using index condition; Using where DROP TABLE t1,t2; create table t0 (a int); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); diff --git a/mysql-test/main/index_merge_myisam.test b/mysql-test/main/index_merge_myisam.test index b77c9bc1ca2..10ddbee36b2 100644 --- a/mysql-test/main/index_merge_myisam.test +++ b/mysql-test/main/index_merge_myisam.test @@ -10,7 +10,7 @@ # include/index_merge*.inc files # -SET STORAGE_ENGINE = MyISAM; +SET DEFAULT_STORAGE_ENGINE = MyISAM; # MyISAM supports Merge tables let $merge_table_support= 1; diff --git a/mysql-test/main/information_schema.result b/mysql-test/main/information_schema.result index cc7f10a32fd..be209d1435c 100644 --- a/mysql-test/main/information_schema.result +++ b/mysql-test/main/information_schema.result @@ -10,11 +10,11 @@ grant select, update on test.* to mysqltest_1@localhost; create user mysqltest_3@localhost; create user mysqltest_3; select * from information_schema.SCHEMATA where schema_name > 'm'; -CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME SQL_PATH -def mtr latin1 latin1_swedish_ci NULL -def mysql latin1 latin1_swedish_ci NULL -def performance_schema utf8 utf8_general_ci NULL -def test latin1 latin1_swedish_ci NULL +CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME SQL_PATH SCHEMA_COMMENT +def mtr latin1 latin1_swedish_ci NULL +def mysql latin1 latin1_swedish_ci NULL +def performance_schema utf8 utf8_general_ci NULL +def test latin1 latin1_swedish_ci NULL select schema_name from information_schema.schemata; schema_name information_schema @@ -1580,14 +1580,14 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE b ALL NULL NULL NULL NULL NULL Using where; Open_frm_only; Scanned all databases; Using join buffer (flat, BNL join) SELECT * FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'mysqltest'; -CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME SQL_PATH +CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME SQL_PATH SCHEMA_COMMENT SELECT * FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = ''; -CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME SQL_PATH +CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME SQL_PATH SCHEMA_COMMENT SELECT * FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'test'; -CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME SQL_PATH -def test latin1 latin1_swedish_ci NULL +CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME SQL_PATH SCHEMA_COMMENT +def test latin1 latin1_swedish_ci NULL select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='mysql' AND TABLE_NAME='nonexisting'; count(*) 0 @@ -1632,7 +1632,7 @@ CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME UNIQUE_CONSTRAINT_CATALOG U select * from `information_schema`.`REFERENTIAL_CONSTRAINTS` where `TABLE_NAME` = NULL; CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME UNIQUE_CONSTRAINT_CATALOG UNIQUE_CONSTRAINT_SCHEMA UNIQUE_CONSTRAINT_NAME MATCH_OPTION UPDATE_RULE DELETE_RULE TABLE_NAME REFERENCED_TABLE_NAME select * from information_schema.schemata where schema_name = NULL; -CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME SQL_PATH +CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME SQL_PATH SCHEMA_COMMENT select * from `information_schema`.`STATISTICS` where `TABLE_SCHEMA` = NULL; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT select * from `information_schema`.`STATISTICS` where `TABLE_NAME` = NULL; diff --git a/mysql-test/main/information_schema.test b/mysql-test/main/information_schema.test index 360717a2685..284ecdfdf49 100644 --- a/mysql-test/main/information_schema.test +++ b/mysql-test/main/information_schema.test @@ -1,9 +1,6 @@ # This test uses grants, which can't get tested for embedded server -- source include/not_embedded.inc -#Don't run this test when thread_pool active ---source include/not_threadpool.inc - # check that CSV engine was compiled in, as the result of the test depends # on the presence of the log tables (which are CSV-based). --source include/have_csv.inc diff --git a/mysql-test/main/information_schema_all_engines-master.opt b/mysql-test/main/information_schema_all_engines-master.opt index 43411c5033a..7ba5aa5b8b3 100644 --- a/mysql-test/main/information_schema_all_engines-master.opt +++ b/mysql-test/main/information_schema_all_engines-master.opt @@ -15,4 +15,3 @@ --loose-innodb-sys-tablestats --loose-innodb-mutexes --loose-innodb-tablespaces-encryption ---loose-innodb-tablespaces-scrubbing diff --git a/mysql-test/main/information_schema_all_engines.result b/mysql-test/main/information_schema_all_engines.result index 1269972d127..2e377b254e4 100644 --- a/mysql-test/main/information_schema_all_engines.result +++ b/mysql-test/main/information_schema_all_engines.result @@ -39,7 +39,6 @@ INNODB_SYS_TABLES INNODB_SYS_TABLESTATS INNODB_SYS_VIRTUAL INNODB_TABLESPACES_ENCRYPTION -INNODB_TABLESPACES_SCRUBBING INNODB_TRX KEYWORDS KEY_CACHES @@ -122,7 +121,6 @@ INNODB_SYS_TABLES TABLE_ID INNODB_SYS_TABLESTATS TABLE_ID INNODB_SYS_VIRTUAL TABLE_ID INNODB_TABLESPACES_ENCRYPTION SPACE -INNODB_TABLESPACES_SCRUBBING SPACE INNODB_TRX trx_id KEYWORDS WORD KEY_CACHES KEY_CACHE_NAME @@ -205,7 +203,6 @@ INNODB_SYS_TABLES TABLE_ID INNODB_SYS_TABLESTATS TABLE_ID INNODB_SYS_VIRTUAL TABLE_ID INNODB_TABLESPACES_ENCRYPTION SPACE -INNODB_TABLESPACES_SCRUBBING SPACE INNODB_TRX trx_id KEYWORDS WORD KEY_CACHES KEY_CACHE_NAME @@ -293,7 +290,6 @@ INNODB_SYS_TABLES information_schema.INNODB_SYS_TABLES 1 INNODB_SYS_TABLESTATS information_schema.INNODB_SYS_TABLESTATS 1 INNODB_SYS_VIRTUAL information_schema.INNODB_SYS_VIRTUAL 1 INNODB_TABLESPACES_ENCRYPTION information_schema.INNODB_TABLESPACES_ENCRYPTION 1 -INNODB_TABLESPACES_SCRUBBING information_schema.INNODB_TABLESPACES_SCRUBBING 1 INNODB_TRX information_schema.INNODB_TRX 1 KEY_CACHES information_schema.KEY_CACHES 1 KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1 @@ -364,7 +360,6 @@ Database: information_schema | INNODB_SYS_TABLESTATS | | INNODB_SYS_VIRTUAL | | INNODB_TABLESPACES_ENCRYPTION | -| INNODB_TABLESPACES_SCRUBBING | | INNODB_TRX | | KEYWORDS | | KEY_CACHES | @@ -437,7 +432,6 @@ Database: INFORMATION_SCHEMA | INNODB_SYS_TABLESTATS | | INNODB_SYS_VIRTUAL | | INNODB_TABLESPACES_ENCRYPTION | -| INNODB_TABLESPACES_SCRUBBING | | INNODB_TRX | | KEYWORDS | | KEY_CACHES | @@ -475,5 +469,5 @@ Wildcard: inf_rmation_schema | information_schema | SELECT table_schema, count(*) FROM information_schema.TABLES WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') GROUP BY TABLE_SCHEMA; table_schema count(*) -information_schema 68 +information_schema 67 mysql 31 diff --git a/mysql-test/main/information_schema_db.result b/mysql-test/main/information_schema_db.result index bf665da4542..b8a18179e75 100644 --- a/mysql-test/main/information_schema_db.result +++ b/mysql-test/main/information_schema_db.result @@ -101,7 +101,7 @@ grant insert on v1 to testdb_2@localhost; create view v5 as select f1 from t1; grant select, show view on v5 to testdb_2@localhost; create definer=`no_such_user`@`no_such_host` view v6 as select f1 from t1; -ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation +ERROR 42000: Access denied; you need (at least one of) the SUPER, SET USER privilege(s) for this operation connection default; use testdb_1; create view v6 as select f1 from t1; diff --git a/mysql-test/main/information_schema_db.test b/mysql-test/main/information_schema_db.test index b244662a28c..7cf8c0801e6 100644 --- a/mysql-test/main/information_schema_db.test +++ b/mysql-test/main/information_schema_db.test @@ -2,9 +2,6 @@ # in the embedded server by default). So skip the test in embedded-server mode. -- source include/not_embedded.inc -#Don't run this test when thread_pool active ---source include/not_threadpool.inc - -- source include/testdb_only.inc set local sql_mode=""; diff --git a/mysql-test/main/information_schema_stats.result b/mysql-test/main/information_schema_stats.result index 8e044bc9f96..352bcbab823 100644 --- a/mysql-test/main/information_schema_stats.result +++ b/mysql-test/main/information_schema_stats.result @@ -57,12 +57,12 @@ count(*) 3 select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test'; TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ -test just_a_test PRIMARY 5 +test just_a_test PRIMARY 4 test just_a_test first_name 1 test just_a_test state 2 select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test'; TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES -test just_a_test 8 5 15 +test just_a_test 7 5 15 drop table just_a_test; select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test'; TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ diff --git a/mysql-test/main/innodb_ext_key,off.rdiff b/mysql-test/main/innodb_ext_key,off.rdiff index f4eaa4b112c..4d6c65c9971 100644 --- a/mysql-test/main/innodb_ext_key,off.rdiff +++ b/mysql-test/main/innodb_ext_key,off.rdiff @@ -249,7 +249,7 @@ drop table t1,t2,t3; # # Bug mdev-4340: performance regression with extended_keys=on -@@ -710,13 +710,13 @@ +@@ -714,13 +714,13 @@ select * from t1 force index(index_date_updated) where index_date_updated= 10 and index_id < 800; id select_type table type possible_keys key key_len ref rows Extra @@ -265,7 +265,7 @@ drop table t0,t1,t2; # # MDEV-11196: Error:Run-Time Check Failure #2 - Stack around the variable 'key_buff' -@@ -751,13 +751,14 @@ +@@ -755,11 +755,12 @@ "select_id": 1, "table": { "table_name": "t1", @@ -279,12 +279,9 @@ + "used_key_parts": ["f2"], + "ref": ["const"], "rows": 1, -- "filtered": 50, -+ "filtered": 100, + "filtered": 100, "index_condition": "t1.pk1 <= 5 and t1.pk2 <= 5 and t1.f2 = 'abc'", - "attached_condition": "t1.f1 <= '3'" - } -@@ -784,8 +785,8 @@ +@@ -788,8 +789,8 @@ "access_type": "range", "possible_keys": ["k1"], "key": "k1", @@ -293,5 +290,5 @@ + "key_length": "3007", + "used_key_parts": ["pk1", "f2"], "rows": 1, - "filtered": 50, + "filtered": 100, "index_condition": "t1.f2 <= 5 and t1.pk2 <= 5 and t1.pk1 = 'abc'", diff --git a/mysql-test/main/innodb_ext_key.result b/mysql-test/main/innodb_ext_key.result index 6fba116d35d..0d3e27e5bf0 100644 --- a/mysql-test/main/innodb_ext_key.result +++ b/mysql-test/main/innodb_ext_key.result @@ -1,4 +1,4 @@ -SET SESSION STORAGE_ENGINE='InnoDB'; +SET SESSION DEFAULT_STORAGE_ENGINE='InnoDB'; set @innodb_stats_persistent_save= @@innodb_stats_persistent; set @innodb_stats_persistent_sample_pages_save= @@innodb_stats_persistent_sample_pages; @@ -561,6 +561,10 @@ INSERT INTO t2 VALUES (547118223,998,0,NULL,4,'','',0,0,NULL,NULL,''),(547119246,998,0,NULL,5,'','',0,0,NULL,NULL,''), (547115155,999,0,NULL,1,'','',0,0,NULL,NULL,''),(547116178,999,0,NULL,2,'','',0,0,NULL,NULL,''), (547117201,999,0,NULL,3,'','',0,0,NULL,NULL,''),(547118224,999,0,NULL,4,'','',0,0,NULL,NULL,''), +(547117213,999,0,NULL,3,'','',0,0,NULL,NULL,''),(547117217,999,0,NULL,4,'','',0,0,NULL,NULL,''), +(547117214,999,0,NULL,3,'','',0,0,NULL,NULL,''),(547117218,999,0,NULL,4,'','',0,0,NULL,NULL,''), +(547117215,999,0,NULL,3,'','',0,0,NULL,NULL,''),(547117219,999,0,NULL,4,'','',0,0,NULL,NULL,''), +(547117216,999,0,NULL,3,'','',0,0,NULL,NULL,''),(547117220,999,0,NULL,4,'','',0,0,NULL,NULL,''), (547119271,38928081,0,NULL,10,'','',0,0,NULL,NULL,''),(547119272,38928081,0,NULL,11,'','',0,0,NULL,NULL,''), (547119273,38928081,0,NULL,12,'','',0,0,NULL,NULL,''),(547119274,38928081,0,NULL,13,'','',0,0,NULL,NULL,''), (547119275,38928081,0,NULL,14,'','',0,0,NULL,NULL,''),(547119276,38928081,0,NULL,15,'','',0,0,NULL,NULL,''), @@ -757,7 +761,7 @@ EXPLAIN "key_length": "3070", "used_key_parts": ["f2", "pk1"], "rows": 1, - "filtered": 50, + "filtered": 100, "index_condition": "t1.pk1 <= 5 and t1.pk2 <= 5 and t1.f2 = 'abc'", "attached_condition": "t1.f1 <= '3'" } @@ -787,7 +791,7 @@ EXPLAIN "key_length": "3011", "used_key_parts": ["pk1", "f2", "pk2"], "rows": 1, - "filtered": 50, + "filtered": 100, "index_condition": "t1.f2 <= 5 and t1.pk2 <= 5 and t1.pk1 = 'abc'", "attached_condition": "t1.f1 <= '3'" } diff --git a/mysql-test/main/innodb_ext_key.test b/mysql-test/main/innodb_ext_key.test index 1ff0ea51990..77eda0df6f6 100644 --- a/mysql-test/main/innodb_ext_key.test +++ b/mysql-test/main/innodb_ext_key.test @@ -1,6 +1,6 @@ --source include/innodb_prefix_index_cluster_optimization.inc -SET SESSION STORAGE_ENGINE='InnoDB'; +SET SESSION DEFAULT_STORAGE_ENGINE='InnoDB'; set @innodb_stats_persistent_save= @@innodb_stats_persistent; set @innodb_stats_persistent_sample_pages_save= @@ -414,6 +414,10 @@ INSERT INTO t2 VALUES (547118223,998,0,NULL,4,'','',0,0,NULL,NULL,''),(547119246,998,0,NULL,5,'','',0,0,NULL,NULL,''), (547115155,999,0,NULL,1,'','',0,0,NULL,NULL,''),(547116178,999,0,NULL,2,'','',0,0,NULL,NULL,''), (547117201,999,0,NULL,3,'','',0,0,NULL,NULL,''),(547118224,999,0,NULL,4,'','',0,0,NULL,NULL,''), +(547117213,999,0,NULL,3,'','',0,0,NULL,NULL,''),(547117217,999,0,NULL,4,'','',0,0,NULL,NULL,''), +(547117214,999,0,NULL,3,'','',0,0,NULL,NULL,''),(547117218,999,0,NULL,4,'','',0,0,NULL,NULL,''), +(547117215,999,0,NULL,3,'','',0,0,NULL,NULL,''),(547117219,999,0,NULL,4,'','',0,0,NULL,NULL,''), +(547117216,999,0,NULL,3,'','',0,0,NULL,NULL,''),(547117220,999,0,NULL,4,'','',0,0,NULL,NULL,''), (547119271,38928081,0,NULL,10,'','',0,0,NULL,NULL,''),(547119272,38928081,0,NULL,11,'','',0,0,NULL,NULL,''), (547119273,38928081,0,NULL,12,'','',0,0,NULL,NULL,''),(547119274,38928081,0,NULL,13,'','',0,0,NULL,NULL,''), (547119275,38928081,0,NULL,14,'','',0,0,NULL,NULL,''),(547119276,38928081,0,NULL,15,'','',0,0,NULL,NULL,''), diff --git a/mysql-test/main/innodb_icp.result b/mysql-test/main/innodb_icp.result index 96ff1964ac1..c89d49cad0c 100644 --- a/mysql-test/main/innodb_icp.result +++ b/mysql-test/main/innodb_icp.result @@ -1,5 +1,5 @@ -set @save_storage_engine= @@storage_engine; -set storage_engine=InnoDB; +set @save_storage_engine= @@default_storage_engine; +set default_storage_engine=InnoDB; set @innodb_stats_persistent_save= @@innodb_stats_persistent; set @innodb_stats_persistent_sample_pages_save= @@innodb_stats_persistent_sample_pages; @@ -435,9 +435,9 @@ EXPLAIN SELECT * FROM t1 WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON it.i=it.i WHERE it.pk-t1.i<10); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where -2 DEPENDENT SUBQUERY it eq_ref PRIMARY PRIMARY 4 func 1 Using where -2 DEPENDENT SUBQUERY t2 index NULL PRIMARY 4 NULL 3 Using index; Using join buffer (flat, BNL join) +1 PRIMARY t1 ALL NULL NULL NULL NULL # Using where +2 DEPENDENT SUBQUERY it eq_ref PRIMARY PRIMARY 4 func # Using where +2 DEPENDENT SUBQUERY t2 index NULL PRIMARY 4 NULL # Using index; Using join buffer (flat, BNL join) SELECT * FROM t1 WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON it.i=it.i WHERE it.pk-t1.i<10); pk i @@ -658,7 +658,7 @@ SELECT * FROM t1 WHERE NOT(b = 'Texas') AND b BETWEEN 'wy' AND 'y' OR b = 'Pennsylvania' ORDER BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL b NULL NULL NULL # Using where; Using filesort +1 SIMPLE t1 range b b 13 NULL # Using where; Rowid-ordered scan; Using filesort SELECT * FROM t1 WHERE NOT(b = 'Texas') AND b BETWEEN 'wy' AND 'y' OR b = 'Pennsylvania' ORDER BY a; @@ -670,7 +670,7 @@ SELECT * FROM t1 WHERE NOT(b = 'Texas') AND b BETWEEN 'wy' AND 'y' OR b = 'Pennsylvania' ORDER BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL b NULL NULL NULL # Using where; Using filesort +1 SIMPLE t1 range b b 13 NULL # Using index condition; Rowid-ordered scan; Using filesort SELECT * FROM t1 WHERE NOT(b = 'Texas') AND b BETWEEN 'wy' AND 'y' OR b = 'Pennsylvania' ORDER BY a; @@ -682,16 +682,18 @@ DROP TABLE t1; # CREATE TABLE t1 (b int NOT NULL, c int, a varchar(1024), PRIMARY KEY (b)); INSERT INTO t1 VALUES (1,4,'Ill'); +insert into t1 select seq+100,5,seq from seq_1_to_100; CREATE TABLE t2 (a varchar(1024), KEY (a(512))); INSERT INTO t2 VALUES ('Ill'), ('eckqzsflbzaffti'), ('w'), ('she'), ('gxbwypqtjzwywwer'), ('w'); +insert into t2 select seq from seq_1_to_100; SET SESSION optimizer_switch='index_condition_pushdown=off'; EXPLAIN SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND (t1.b<0 OR t1.b>0) HAVING t1.c != 5 ORDER BY t1.c; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 Using where; Using filesort -1 SIMPLE t2 ref a a 515 test.t1.a 1 Using where +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL # Using where; Using filesort +1 SIMPLE t2 ref a a 515 test.t1.a # Using where SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND (t1.b<0 OR t1.b>0) HAVING t1.c != 5 ORDER BY t1.c; b c @@ -701,8 +703,8 @@ EXPLAIN SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND (t1.b<0 OR t1.b>0) HAVING t1.c != 5 ORDER BY t1.c; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 Using where; Using filesort -1 SIMPLE t2 ref a a 515 test.t1.a 1 Using where +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL # Using where; Using filesort +1 SIMPLE t2 ref a a 515 test.t1.a # Using where SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND (t1.b<0 OR t1.b>0) HAVING t1.c != 5 ORDER BY t1.c; b c @@ -963,7 +965,7 @@ pk key1 key2 142 frequent-val rare-42 drop table t1, t2; set optimizer_switch=@innodb_icp_tmp; -set storage_engine= @save_storage_engine; +set default_storage_engine= @save_storage_engine; set global innodb_stats_persistent= @innodb_stats_persistent_save; set global innodb_stats_persistent_sample_pages= @innodb_stats_persistent_sample_pages_save; diff --git a/mysql-test/main/innodb_icp.test b/mysql-test/main/innodb_icp.test index 9081b886224..d1f188afd64 100644 --- a/mysql-test/main/innodb_icp.test +++ b/mysql-test/main/innodb_icp.test @@ -5,8 +5,8 @@ --source include/have_innodb.inc --source include/default_optimizer_switch.inc -set @save_storage_engine= @@storage_engine; -set storage_engine=InnoDB; +set @save_storage_engine= @@default_storage_engine; +set default_storage_engine=InnoDB; set @innodb_stats_persistent_save= @@innodb_stats_persistent; set @innodb_stats_persistent_sample_pages_save= @@ -82,7 +82,7 @@ drop table t1, t2; set optimizer_switch=@innodb_icp_tmp; -set storage_engine= @save_storage_engine; +set default_storage_engine= @save_storage_engine; set global innodb_stats_persistent= @innodb_stats_persistent_save; set global innodb_stats_persistent_sample_pages= diff --git a/mysql-test/main/innodb_mrr_cpk.result b/mysql-test/main/innodb_mrr_cpk.result index a2e43d7d127..8b9260f4596 100644 --- a/mysql-test/main/innodb_mrr_cpk.result +++ b/mysql-test/main/innodb_mrr_cpk.result @@ -3,8 +3,8 @@ set @innodb_mrr_cpk_tmp=@@optimizer_switch; set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; set @save_join_cache_level=@@join_cache_level; set join_cache_level=6; -set @save_storage_engine=@@storage_engine; -set storage_engine=innodb; +set @save_storage_engine=@@default_storage_engine; +set default_storage_engine=innodb; create table t0(a int); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); create table t1(a char(8), b char(8), filler char(100), primary key(a)); @@ -234,5 +234,5 @@ drop table t0,t1,t2; # This must be at the end: # set @@join_cache_level= @save_join_cache_level; -set storage_engine=@save_storage_engine; +set default_storage_engine=@save_storage_engine; set optimizer_switch=@innodb_mrr_cpk_tmp; diff --git a/mysql-test/main/innodb_mrr_cpk.test b/mysql-test/main/innodb_mrr_cpk.test index cb79c238f2b..cbebafd3053 100644 --- a/mysql-test/main/innodb_mrr_cpk.test +++ b/mysql-test/main/innodb_mrr_cpk.test @@ -23,8 +23,8 @@ set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; set @save_join_cache_level=@@join_cache_level; set join_cache_level=6; -set @save_storage_engine=@@storage_engine; -set storage_engine=innodb; +set @save_storage_engine=@@default_storage_engine; +set default_storage_engine=innodb; create table t0(a int); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); @@ -225,5 +225,5 @@ drop table t0,t1,t2; --echo # set @@join_cache_level= @save_join_cache_level; -set storage_engine=@save_storage_engine; +set default_storage_engine=@save_storage_engine; set optimizer_switch=@innodb_mrr_cpk_tmp; diff --git a/mysql-test/main/innodb_mysql_lock2.result b/mysql-test/main/innodb_mysql_lock2.result index 608cbec88c5..ffbe3f8a406 100644 --- a/mysql-test/main/innodb_mysql_lock2.result +++ b/mysql-test/main/innodb_mysql_lock2.result @@ -238,8 +238,7 @@ Success: 'show keys from t1' doesn't take row locks on 't1'. # statement-by-statement) and thanks to MVCC we can always get # versions of rows prior to the update that has locked them. # But in practice InnoDB does locking reads for all statements -# other than SELECT (unless it is a READ-COMITTED mode or -# innodb_locks_unsafe_for_binlog is ON). +# other than SELECT (unless READ UNCOMMITTED or READ COMMITTED). connection default; Success: 'call p1((select i + 5 from t1 where i = 1))' takes shared row locks on 't1'. # diff --git a/mysql-test/main/innodb_mysql_lock2.test b/mysql-test/main/innodb_mysql_lock2.test index f319fe23568..b983fd8dc7a 100644 --- a/mysql-test/main/innodb_mysql_lock2.test +++ b/mysql-test/main/innodb_mysql_lock2.test @@ -261,8 +261,7 @@ let $statement= show keys from t1; --echo # statement-by-statement) and thanks to MVCC we can always get --echo # versions of rows prior to the update that has locked them. --echo # But in practice InnoDB does locking reads for all statements ---echo # other than SELECT (unless it is a READ-COMITTED mode or ---echo # innodb_locks_unsafe_for_binlog is ON). +--echo # other than SELECT (unless READ UNCOMMITTED or READ COMMITTED). let $statement= call p1((select i + 5 from t1 where i = 1)); let $wait_statement= $statement; --source include/check_shared_row_lock.inc diff --git a/mysql-test/main/innodb_mysql_sync.result b/mysql-test/main/innodb_mysql_sync.result index 3f284edde86..46ed7d43830 100644 --- a/mysql-test/main/innodb_mysql_sync.result +++ b/mysql-test/main/innodb_mysql_sync.result @@ -450,6 +450,8 @@ info: Records: 0 Duplicates: 0 Warnings: 0 #table copy when the old_alter_table enabled. SET SESSION old_alter_table= TRUE; affected rows: 0 +Warnings: +Warning 1287 '@@old_alter_table' is deprecated and will be removed in a future release. Please use '@@alter_algorithm' instead ALTER TABLE t1 FORCE; affected rows: 1 info: Records: 1 Duplicates: 0 Warnings: 0 @@ -474,6 +476,8 @@ SET DEBUG_SYNC= 'RESET'; affected rows: 0 SET SESSION old_alter_table= FALSE; affected rows: 0 +Warnings: +Warning 1287 '@@old_alter_table' is deprecated and will be removed in a future release. Please use '@@alter_algorithm' instead #ALTER TABLE FORCE and ALTER TABLE ENGINE uses table copy #when ALGORITHM COPY is used. ALTER TABLE t1 FORCE, ALGORITHM= COPY; diff --git a/mysql-test/main/insert.result b/mysql-test/main/insert.result index 4aea81262d2..d8f40b7383a 100644 --- a/mysql-test/main/insert.result +++ b/mysql-test/main/insert.result @@ -751,3 +751,19 @@ REPLACE INTO v1 SET f = NULL; ERROR 22007: Truncated incorrect DOUBLE value: 'foo' DROP VIEW v1; DROP TABLE t1; +create table t1 (a int default 5); +insert t1 values (1); +insert t1 values (a); +insert t1 values ((select a+1)); +insert t1 set a=2; +insert t1 set a=a+2; +insert t1 set a=(select a+3); +select * from t1; +a +1 +5 +6 +2 +7 +8 +drop table t1; diff --git a/mysql-test/main/insert.test b/mysql-test/main/insert.test index e00c9cd7a0d..4ccaa20ece8 100644 --- a/mysql-test/main/insert.test +++ b/mysql-test/main/insert.test @@ -612,3 +612,16 @@ CREATE VIEW v1 AS SELECT * FROM t1 WHERE f <=> 'foo' WITH CHECK OPTION; REPLACE INTO v1 SET f = NULL; DROP VIEW v1; DROP TABLE t1; + +# +# outer referencesin subqueries in INSERT +# +create table t1 (a int default 5); +insert t1 values (1); +insert t1 values (a); +insert t1 values ((select a+1)); +insert t1 set a=2; +insert t1 set a=a+2; +insert t1 set a=(select a+3); +select * from t1; +drop table t1; diff --git a/mysql-test/main/insert_returning.result b/mysql-test/main/insert_returning.result new file mode 100644 index 00000000000..a3cde7b1270 --- /dev/null +++ b/mysql-test/main/insert_returning.result @@ -0,0 +1,617 @@ +# Test for INSERT...RETURNING +CREATE TABLE t1(id1 INT PRIMARY KEY AUTO_INCREMENT, val1 VARCHAR(1)); +CREATE TABLE t2(id2 INT PRIMARY KEY AUTO_INCREMENT, val2 VARCHAR(1)); +CREATE VIEW v1 AS SELECT id1, val1 FROM t1; +CREATE VIEW v2 AS SELECT id2,val2 FROM t2; +INSERT INTO t2 VALUES (1,'a'),(2,'b'),(3,'c'); +CREATE FUNCTION f(arg INT) RETURNS TEXT +BEGIN +RETURN (SELECT arg+arg); +END| +# +# Simple insert statement...RETURNING +# +INSERT INTO t1 (id1, val1) VALUES (1, 'a'); +INSERT INTO t1 (id1, val1) VALUES (2, 'b') RETURNING *; +id1 val1 +2 b +INSERT INTO t1 (id1, val1) VALUES (3, 'c') RETURNING id1+id1 as total,val1, +id1 && id1, id1 | id1, UPPER(val1),f(id1); +total val1 id1 && id1 id1 | id1 UPPER(val1) f(id1) +6 c 1 3 C 6 +INSERT INTO t1(id1,val1) VALUES (4,'d') RETURNING(SELECT GROUP_CONCAT(val2) +FROM t2 WHERE id2=1); +(SELECT GROUP_CONCAT(val2) +FROM t2 WHERE id2=1) +a +INSERT INTO t1(id1,val1) VALUES(5,'e') RETURNING(SELECT GROUP_CONCAT(val2) +FROM t2 GROUP BY id2 HAVING id2=id1-2); +(SELECT GROUP_CONCAT(val2) +FROM t2 GROUP BY id2 HAVING id2=id1-2) +c +PREPARE stmt FROM "INSERT INTO t1 (id1,val1) VALUES (6,'f') RETURNING (SELECT id2 FROM t2 WHERE val2='b')"; +EXECUTE stmt; +(SELECT id2 FROM t2 WHERE val2='b') +2 +DELETE FROM t1 WHERE id1=6; +SELECT * FROM t1; +id1 val1 +1 a +2 b +3 c +4 d +5 e +EXECUTE stmt; +(SELECT id2 FROM t2 WHERE val2='b') +2 +DEALLOCATE PREPARE stmt; +INSERT IGNORE INTO t1(id1,val1) VALUES (7,'h') RETURNING *; +id1 val1 +7 h +SELECT * FROM t1; +id1 val1 +1 a +2 b +3 c +4 d +5 e +6 f +7 h +EXPLAIN INSERT INTO t1(id1,val1) VALUES (8,'i') RETURNING *; +id select_type table type possible_keys key key_len ref rows Extra +1 INSERT t1 ALL NULL NULL NULL NULL NULL NULL +EXPLAIN EXTENDED INSERT INTO t1(id1,val1) VALUES(9,'j') RETURNING id1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 ALL NULL NULL NULL NULL NULL 100.00 NULL +EXPLAIN FORMAT="json" INSERT INTO t1(id1,val1) VALUES (10,'k') RETURNING id1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "table_name": "t1" + } + } +} +SELECT * FROM t1; +id1 val1 +1 a +2 b +3 c +4 d +5 e +6 f +7 h +INSERT INTO v1(id1, val1) VALUES (12, 'a') RETURNING id1+id1 as total,val1, +id1 && id1, id1 id1, UPPER(val1),f(id1); +total val1 id1 && id1 id1 UPPER(val1) f(id1) +24 a 1 12 A 24 +ANALYZE INSERT INTO t1(id1,val1) VALUES(13,'l') RETURNING *; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 INSERT t1 ALL NULL NULL NULL NULL NULL NULL 100.00 100.00 NULL +INSERT INTO t1(id1,val1) VALUES(14,'m') RETURNING t1.*; +id1 val1 +14 m +TRUNCATE TABLE t1; +# +# Multiple values in one insert statement...RETURNING +# +INSERT INTO t1 VALUES (1,'a'),(2,'b'); +INSERT INTO t1 VALUES (3,'c'),(4,'d') RETURNING *; +id1 val1 +3 c +4 d +INSERT INTO t1 VALUES (5,'e'),(6,'f') RETURNING id1 as id,val1, +id1 && id1, id1|id1, UPPER(val1),f(id1); +id val1 id1 && id1 id1|id1 UPPER(val1) f(id1) +5 e 1 5 E 10 +6 f 1 6 F 12 +INSERT INTO t1 VALUES (7,'g'),(8,'h') RETURNING(SELECT GROUP_CONCAT(val2) +FROM t2 WHERE id2=1); +(SELECT GROUP_CONCAT(val2) +FROM t2 WHERE id2=1) +a +a +INSERT INTO t1 VALUES (9,'i'),(10,'j') RETURNING(SELECT GROUP_CONCAT(val2) +FROM t2 GROUP BY id2 HAVING id2=id1-8); +(SELECT GROUP_CONCAT(val2) +FROM t2 GROUP BY id2 HAVING id2=id1-8) +a +b +PREPARE stmt FROM "INSERT INTO t1 VALUES (11,'k'),(12,'l') RETURNING (SELECT id2 FROM t2 WHERE val2='b')"; +EXECUTE stmt; +(SELECT id2 FROM t2 WHERE val2='b') +2 +2 +DELETE FROM t1 WHERE val1 IN ('k','l'); +SELECT * FROM t1; +id1 val1 +1 a +2 b +3 c +4 d +5 e +6 f +7 g +8 h +9 i +10 j +EXECUTE stmt; +(SELECT id2 FROM t2 WHERE val2='b') +2 +2 +DEALLOCATE PREPARE stmt; +INSERT IGNORE INTO t1 VALUES(13,'o'),(14,'p') RETURNING *; +id1 val1 +13 o +14 p +EXPLAIN INSERT INTO t1 VALUES(15,'q'),(16,'r') RETURNING *; +id select_type table type possible_keys key key_len ref rows Extra +1 INSERT t1 ALL NULL NULL NULL NULL NULL NULL +EXPLAIN EXTENDED INSERT INTO t1 VALUES (17,'s'),(18,'t') RETURNING *; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 ALL NULL NULL NULL NULL NULL 100.00 NULL +EXPLAIN FORMAT="json" INSERT INTO t1 VALUES(19,'u'),(20,'v') RETURNING id1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "table_name": "t1" + } + } +} +SELECT * FROM t1; +id1 val1 +1 a +2 b +3 c +4 d +5 e +6 f +7 g +8 h +9 i +10 j +12 l +11 k +13 o +14 p +INSERT INTO v1 VALUES(23,'y'),(24,'z') RETURNING id1 as id,val1, +id1 && id1, id1|id1, UPPER(val1),f(id1); +id val1 id1 && id1 id1|id1 UPPER(val1) f(id1) +23 y 1 23 Y 46 +24 z 1 24 Z 48 +ANALYZE INSERT INTO t1 VALUES(25,'a'),(26,'b') RETURNING *; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 INSERT t1 ALL NULL NULL NULL NULL NULL NULL 100.00 100.00 NULL +ANALYZE INSERT INTO t1 VALUES(27,'c'),(28,'d') RETURNING t1.*; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 INSERT t1 ALL NULL NULL NULL NULL NULL NULL 100.00 100.00 NULL +# +# INSERT...ON DUPLICATE KEY UPDATE...RETURNING +# +CREATE TABLE ins_duplicate (id INT PRIMARY KEY AUTO_INCREMENT, val VARCHAR(1)); +INSERT INTO ins_duplicate VALUES (1,'a'); +INSERT INTO ins_duplicate VALUES (2,'b') ON DUPLICATE KEY UPDATE val='b' +RETURNING *; +id val +2 b +INSERT INTO ins_duplicate VALUES (2,'b') ON DUPLICATE KEY UPDATE val='c' +RETURNING id+id AS total, val, id && id, id|id, UPPER(val),f(id); +total val id && id id|id UPPER(val) f(id) +4 c 1 2 C 4 +INSERT INTO ins_duplicate VALUES (2,'b') ON DUPLICATE KEY UPDATE val='d' +RETURNING (SELECT GROUP_CONCAT(val2) FROM t2 WHERE id2=1); +(SELECT GROUP_CONCAT(val2) FROM t2 WHERE id2=1) +a +INSERT INTO ins_duplicate VALUES (2,'b') ON DUPLICATE KEY UPDATE val='e' +RETURNING (SELECT GROUP_CONCAT(val2) FROM t2 GROUP BY id2 HAVING id2=id); +(SELECT GROUP_CONCAT(val2) FROM t2 GROUP BY id2 HAVING id2=id) +b +PREPARE stmt FROM "INSERT INTO ins_duplicate VALUES (2,'b') ON DUPLICATE +KEY UPDATE val='f' RETURNING (SELECT id2 FROM t2 WHERE val2='b')"; +EXECUTE stmt; +(SELECT id2 FROM t2 WHERE val2='b') +2 +SELECT * FROM t2; +id2 val2 +1 a +2 b +3 c +EXECUTE stmt; +(SELECT id2 FROM t2 WHERE val2='b') +2 +DEALLOCATE PREPARE stmt; +INSERT IGNORE INTO ins_duplicate(id,val) VALUES (3,'c'),(4,'d') ON DUPLICATE +KEY UPDATE val='g' RETURNING id; +id +3 +4 +EXPLAIN INSERT INTO ins_duplicate(id,val) VALUES (2,'b') ON DUPLICATE KEY +UPDATE val='h' RETURNING val; +id select_type table type possible_keys key key_len ref rows Extra +1 INSERT ins_duplicate ALL NULL NULL NULL NULL NULL NULL +EXPLAIN EXTENDED INSERT INTO ins_duplicate(id,val) VALUES (2,'b') +ON DUPLICATE KEY UPDATE val='i' RETURNING val; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 INSERT ins_duplicate ALL NULL NULL NULL NULL NULL 100.00 NULL +EXPLAIN FORMAT="json" INSERT INTO ins_duplicate(id,val) VALUES (2,'b') +ON DUPLICATE KEY UPDATE val='j' RETURNING val; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "table_name": "ins_duplicate" + } + } +} +INSERT INTO v1(id1, val1) VALUES (2,'d') ON DUPLICATE KEY UPDATE +val1='d' RETURNING id1+id1 AS total, val1, id1 && id1, id1|id1, UPPER(val1), +f(id1); +total val1 id1 && id1 id1|id1 UPPER(val1) f(id1) +4 d 1 2 D 4 +ANALYZE INSERT INTO ins_duplicate(id,val) VALUES(2,'b') ON DUPLICATE KEY UPDATE +val='k' RETURNING *; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 INSERT ins_duplicate ALL NULL NULL NULL NULL NULL NULL 100.00 100.00 NULL +INSERT INTO ins_duplicate(id,val) VALUES(2,'b') ON DUPLICATE KEY UPDATE +val='l' RETURNING ins_duplicate.*; +id val +2 l +SELECT * FROM ins_duplicate; +id val +1 a +2 l +3 c +4 d +# +# INSERT...SET...RETURNING +# +TRUNCATE TABLE t1; +INSERT INTO t1 SET id1= 1, val1= 'a'; +INSERT INTO t1 SET id1= 2, val1= 'b' RETURNING *; +id1 val1 +2 b +INSERT INTO t1 SET id1= 3, val1= 'c' RETURNING id1+id1 AS total,val1, +id1 && id1, id1|id1, UPPER(val1),f(id1); +total val1 id1 && id1 id1|id1 UPPER(val1) f(id1) +6 c 1 3 C 6 +INSERT INTO t1 SET id1= 4, val1= 'd' RETURNING (SELECT GROUP_CONCAT(val2) +FROM t2 WHERE id2=1); +(SELECT GROUP_CONCAT(val2) +FROM t2 WHERE id2=1) +a +INSERT INTO t1 SET id1= 5, val1='e' RETURNING (SELECT GROUP_CONCAT(val2) +FROM t2 GROUP BY id2 HAVING id2=id1-3); +(SELECT GROUP_CONCAT(val2) +FROM t2 GROUP BY id2 HAVING id2=id1-3) +b +PREPARE stmt FROM "INSERT INTO t1 SET id1= 6, val1='f' RETURNING (SELECT id2 FROM t2 WHERE val2='b')"; +EXECUTE stmt; +(SELECT id2 FROM t2 WHERE val2='b') +2 +DELETE FROM t1 WHERE val1='f'; +SELECT * FROM t1; +id1 val1 +1 a +2 b +3 c +4 d +5 e +EXECUTE stmt; +(SELECT id2 FROM t2 WHERE val2='b') +2 +DEALLOCATE PREPARE stmt; +INSERT INTO t1 SET id1= 7, val1= 'g' RETURNING f(id1); +f(id1) +14 +INSERT INTO t1 SET val1= 'n' RETURNING *; +id1 val1 +8 n +INSERT IGNORE INTO t1 SET id1= 8, val1= 'h' RETURNING *; +id1 val1 +Warnings: +Warning 1062 Duplicate entry '8' for key 'PRIMARY' +EXPLAIN INSERT INTO t1 SET id1=9, val1='i' RETURNING id1; +id select_type table type possible_keys key key_len ref rows Extra +1 INSERT t1 ALL NULL NULL NULL NULL NULL NULL +EXPLAIN EXTENDED INSERT INTO t1 SET id1=10, val1='j' RETURNING val1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 ALL NULL NULL NULL NULL NULL 100.00 NULL +EXPLAIN FORMAT="json" INSERT INTO t1 SET id1=11, val1='k' RETURNING val1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "table_name": "t1" + } + } +} +INSERT INTO v1 SET id1=26, val1='Z' RETURNING id1+id1 AS total,val1, +id1 && id1, id1|id1, UPPER(val1),f(id1); +total val1 id1 && id1 id1|id1 UPPER(val1) f(id1) +52 Z 1 26 Z 52 +ANALYZE INSERT INTO t1 SET id1=12, val1='l' RETURNING *; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 INSERT t1 ALL NULL NULL NULL NULL NULL NULL 100.00 100.00 NULL +INSERT INTO t1 SET id1= 13, val1= 'm' RETURNING t1.*; +id1 val1 +13 m +SELECT * FROM t1; +id1 val1 +1 a +2 b +3 c +4 d +5 e +6 f +7 g +8 n +26 Z +12 l +13 m +# +# INSERT...SELECT...RETURNING +# +TRUNCATE TABLE t2; +INSERT INTO t2(id2,val2) SELECT * FROM t1; +TRUNCATE TABLE t2; +INSERT INTO t2 SELECT * FROM t1 WHERE id1=1 RETURNING *; +id2 val2 +1 a +INSERT INTO t2 SELECT * FROM t1 WHERE id1=2 RETURNING id2+id2 AS total, +val2,id2 && id2, id2|id2, UPPER(val2),f(id2); +total val2 id2 && id2 id2|id2 UPPER(val2) f(id2) +4 b 1 2 B 4 +INSERT INTO t2 SELECT * FROM t1 WHERE id1=3 RETURNING (SELECT GROUP_CONCAT(val1) FROM t1 GROUP BY id1 HAVING id1=id1+1); +(SELECT GROUP_CONCAT(val1) FROM t1 GROUP BY id1 HAVING id1=id1+1) +NULL +PREPARE stmt FROM "INSERT INTO t2 SELECT * FROM t1 WHERE id1=4 RETURNING (SELECT id1 FROM t1 WHERE val1='b')"; +EXECUTE stmt; +(SELECT id1 FROM t1 WHERE val1='b') +2 +DELETE FROM t2 WHERE id2=4; +SELECT * FROM t1; +id1 val1 +1 a +2 b +3 c +4 d +5 e +6 f +7 g +8 n +26 Z +12 l +13 m +EXECUTE stmt; +(SELECT id1 FROM t1 WHERE val1='b') +2 +DEALLOCATE PREPARE stmt; +INSERT INTO t2 SELECT * FROM t1 WHERE id1=6 RETURNING +(SELECT id1+id2 FROM t1 WHERE id1=1); +(SELECT id1+id2 FROM t1 WHERE id1=1) +7 +INSERT INTO t2 SELECT * FROM t1 WHERE id1=7 RETURNING f(id2); +f(id2) +14 +EXPLAIN INSERT INTO t2 SELECT * FROM t1 WHERE id1=8 RETURNING id2; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 const PRIMARY PRIMARY 4 const 1 +EXPLAIN EXTENDED INSERT INTO t1 SELECT * FROM t1 WHERE id1=9 RETURNING val1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +EXPLAIN FORMAT="json" INSERT INTO t1 SELECT * FROM t1 WHERE id1=10 RETURNING val1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "message": "Impossible WHERE noticed after reading const tables" + } + } +} +INSERT IGNORE INTO t2 SELECT * FROM t1 WHERE id1=8 RETURNING *; +id2 val2 +8 n +INSERT IGNORE INTO v2 SELECT * FROM v1 RETURNING *; +id2 val2 +5 e +26 Z +12 l +13 m +Warnings: +Warning 1062 Duplicate entry '1' for key 'PRIMARY' +Warning 1062 Duplicate entry '2' for key 'PRIMARY' +Warning 1062 Duplicate entry '3' for key 'PRIMARY' +Warning 1062 Duplicate entry '4' for key 'PRIMARY' +Warning 1062 Duplicate entry '6' for key 'PRIMARY' +Warning 1062 Duplicate entry '7' for key 'PRIMARY' +Warning 1062 Duplicate entry '8' for key 'PRIMARY' +ANALYZE INSERT INTO t2 SELECT * FROM t1 WHERE id1=11 RETURNING *; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +SELECT * FROM t2; +id2 val2 +1 a +2 b +3 c +4 d +6 f +7 g +8 n +5 e +26 Z +12 l +13 m +TRUNCATE TABLE t2; +INSERT INTO t2 SELECT * FROM t1 WHERE id1=1 RETURNING t2.*; +id2 val2 +1 a +INSERT INTO t2 SELECT t1.* FROM t1 WHERE id1=2 RETURNING t2.*; +id2 val2 +2 b +SELECT * FROM t2; +id2 val2 +1 a +2 b +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE ins_duplicate; +# +# Error message test +# +CREATE TABLE t1(id1 INT,val1 VARCHAR(1)); +CREATE TABLE t2(id2 INT,val2 VARCHAR(1)); +CREATE TABLE ins_duplicate (id INT PRIMARY KEY, val VARCHAR(1)); +INSERT INTO t1 VALUES(1,'a'),(2,'b'),(3,'c'); +# +# SIMLPE INSERT STATEMENT +# +INSERT INTO t2(id2,val2) VALUES(1,'a') RETURNING id1; +ERROR 42S22: Unknown column 'id1' in 'field list' +INSERT INTO t2(id2,val2) values(2,'b') RETURNING SUM(id2); +ERROR HY000: Invalid use of group function +INSERT INTO t2(id2,val2) VALUES(3,'c') RETURNING (SELECT id1 FROM t1); +ERROR 21000: Subquery returns more than 1 row +INSERT INTO t2(id2,val2) VALUES(4,'d') RETURNING (SELECT * FROM t1); +ERROR 21000: Operand should contain 1 column(s) +INSERT INTO t2(id2,val2) VALUES(4,'d') RETURNING (SELECT * FROM t2); +ERROR 21000: Operand should contain 1 column(s) +INSERT INTO t2(id2,val2) VALUES(5,'e') RETURNING id2, (SELECT id1+id2 FROM +t1 WHERE id1=1); +id2 (SELECT id1+id2 FROM +t1 WHERE id1=1) +5 6 +INSERT INTO t2(id2,val2) VALUES(5,'f') RETURNING (SELECT id2 FROM t2); +ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data +INSERT INTO t2 (id2, val2) VALUES (6,'f') RETURNING t1.*; +ERROR 42S02: Unknown table 'test.t1' +# +# Multiple rows in single insert statement +# +INSERT INTO t2 VALUES(1,'a'),(2,'b') RETURNING id1; +ERROR 42S22: Unknown column 'id1' in 'field list' +INSERT INTO t2 VALUES(3,'c'),(4,'d') RETURNING MAX(id2); +ERROR HY000: Invalid use of group function +INSERT INTO t2 VALUES(5,'c'),(6,'f') RETURNING (SELECT id1 FROM t1); +ERROR 21000: Subquery returns more than 1 row +INSERT INTO t2 VALUES(7,'g'),(8,'h') RETURNING (SELECT * FROM t1); +ERROR 21000: Operand should contain 1 column(s) +INSERT INTO t2 VALUES(9,'g'),(10,'h') RETURNING (SELECT * FROM t2); +ERROR 21000: Operand should contain 1 column(s) +INSERT INTO t2 VALUES(11,'e'),(12,'f') RETURNING id2, (SELECT id1+id2 FROM +t1 WHERE id1=1); +id2 (SELECT id1+id2 FROM +t1 WHERE id1=1) +11 12 +12 13 +INSERT INTO t2 VALUES(13,'f'),(14,'g') RETURNING (SELECT id2 FROM t2); +ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data +INSERT INTO t2 VALUES(13,'f'),(14,'g') RETURNING t1.*; +ERROR 42S02: Unknown table 'test.t1' +# +# INSERT ... SET +# +INSERT INTO t2 SET id2=1, val2='a' RETURNING id1; +ERROR 42S22: Unknown column 'id1' in 'field list' +INSERT INTO t2 SET id2=2, val2='b' RETURNING COUNT(id2); +ERROR HY000: Invalid use of group function +INSERT INTO t2 SET id2=3, val2='c' RETURNING (SELECT id1 FROM t1); +ERROR 21000: Subquery returns more than 1 row +INSERT INTO t2 SET id2=4, val2='d' RETURNING (SELECT * FROM t1); +ERROR 21000: Operand should contain 1 column(s) +INSERT INTO t2 SET id2=4, val2='d' RETURNING (SELECT * FROM t2); +ERROR 21000: Operand should contain 1 column(s) +INSERT INTO t2 SET id2=5, val2='e' RETURNING id2, (SELECT id1+id2 FROM t1 +WHERE id1=1); +id2 (SELECT id1+id2 FROM t1 +WHERE id1=1) +5 6 +INSERT INTO t2 SET id2=5, val2='f' RETURNING (SELECT id2 FROM t2); +ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data +INSERT INTO t2 SET id2=5, val2='f' RETURNING t1.*; +ERROR 42S02: Unknown table 'test.t1' +# +# INSERT...ON DUPLICATE KEY UPDATE +# +INSERT INTO ins_duplicate VALUES (2,'b') ON DUPLICATE KEY UPDATE val='b' +RETURNING id1; +ERROR 42S22: Unknown column 'id1' in 'field list' +INSERT INTO ins_duplicate VALUES (2,'b') ON DUPLICATE KEY UPDATE val='b' +RETURNING MAX(id); +ERROR HY000: Invalid use of group function +INSERT INTO ins_duplicate VALUES (2,'b') ON DUPLICATE KEY UPDATE val='b' +RETURNING (SELECT id1 FROM t1); +ERROR 21000: Subquery returns more than 1 row +INSERT INTO ins_duplicate VALUES (2,'b') ON DUPLICATE KEY UPDATE val='b' +RETURNING (SELECT * FROM t1); +ERROR 21000: Operand should contain 1 column(s) +INSERT INTO ins_duplicate VALUES (2,'b') ON DUPLICATE KEY UPDATE val='b' +RETURNING (SELECT * FROM ins_duplicate); +ERROR 21000: Operand should contain 1 column(s) +INSERT INTO ins_duplicate VALUES(2,'b') ON DUPLICATE KEY UPDATE val='b' +RETURNING id2, (SELECT id1+id FROM t1 WHERE id1=1); +ERROR 42S22: Unknown column 'id2' in 'field list' +INSERT INTO ins_duplicate VALUES(2,'b') ON DUPLICATE KEY UPDATE val='b' +RETURNING (SELECT id FROM ins_duplicate); +ERROR HY000: Table 'ins_duplicate' is specified twice, both as a target for 'INSERT' and as a separate source for data +INSERT INTO ins_duplicate VALUES(2,'b') ON DUPLICATE KEY UPDATE val='b' +RETURNING t1.*; +ERROR 42S02: Unknown table 'test.t1' +# +# INSERT...SELECT +# +INSERT INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=1 RETURNING id1; +ERROR 42S22: Unknown column 'id1' in 'field list' +INSERT INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=2 RETURNING MAX(id2); +ERROR HY000: Invalid use of group function +INSERT INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=2 RETURNING (SELECT +id1 FROM t1); +ERROR 21000: Subquery returns more than 1 row +INSERT INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=2 RETURNING (SELECT +* FROM t1); +ERROR 21000: Operand should contain 1 column(s) +INSERT INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=2 RETURNING(SELECT +* FROM t2); +ERROR 21000: Operand should contain 1 column(s) +INSERT INTO t2(id2,val2) SELECT * FROM t1 WHERE id1=2 RETURNING (SELECT +id2 FROM t2); +ERROR 21000: Subquery returns more than 1 row +INSERT INTO t2(id2,val2) SELECT t1.* FROM t1 WHERE id1=2 RETURNING t1.*; +ERROR 42S02: Unknown table 'test.t1' +# +# TRIGGER +# +CREATE TRIGGER bi1 before insert on t1 for each row set NEW.val1= 'z'; +INSERT INTO t1 VALUES (4, 'd'), (5, 'e') RETURNING *; +id1 val1 +4 z +5 z +CREATE TRIGGER bi2 before insert on t2 for each row +INSERT INTO t1 VALUES (NEW.id2, NEW.val2) RETURNING *; +ERROR 0A000: Not allowed to return a result set from a trigger +# +# SP +# +CREATE FUNCTION f1(arg INT) RETURNS TEXT +BEGIN +INSERT INTO t1 VALUES (arg, arg) RETURNING *; +RETURN arg; +END| +ERROR 0A000: Not allowed to return a result set from a function +CREATE PROCEDURE sp1(arg INT) +INSERT INTO t1 VALUES (arg, arg) RETURNING *; +CALL sp1(0); +id1 val1 +0 z +DROP PROCEDURE sp1; +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE ins_duplicate; +DROP VIEW v1; +DROP VIEW v2; +DROP FUNCTION f; diff --git a/mysql-test/main/insert_returning.test b/mysql-test/main/insert_returning.test new file mode 100644 index 00000000000..6c8e71a4617 --- /dev/null +++ b/mysql-test/main/insert_returning.test @@ -0,0 +1,328 @@ +--echo # Test for INSERT...RETURNING + +CREATE TABLE t1(id1 INT PRIMARY KEY AUTO_INCREMENT, val1 VARCHAR(1)); +CREATE TABLE t2(id2 INT PRIMARY KEY AUTO_INCREMENT, val2 VARCHAR(1)); +CREATE VIEW v1 AS SELECT id1, val1 FROM t1; +CREATE VIEW v2 AS SELECT id2,val2 FROM t2; +INSERT INTO t2 VALUES (1,'a'),(2,'b'),(3,'c'); + +DELIMITER |; + +CREATE FUNCTION f(arg INT) RETURNS TEXT +BEGIN + RETURN (SELECT arg+arg); +END| + +DELIMITER ;| + +--echo # +--echo # Simple insert statement...RETURNING +--echo # +INSERT INTO t1 (id1, val1) VALUES (1, 'a'); +INSERT INTO t1 (id1, val1) VALUES (2, 'b') RETURNING *; +INSERT INTO t1 (id1, val1) VALUES (3, 'c') RETURNING id1+id1 as total,val1, +id1 && id1, id1 | id1, UPPER(val1),f(id1); +INSERT INTO t1(id1,val1) VALUES (4,'d') RETURNING(SELECT GROUP_CONCAT(val2) +FROM t2 WHERE id2=1); +INSERT INTO t1(id1,val1) VALUES(5,'e') RETURNING(SELECT GROUP_CONCAT(val2) +FROM t2 GROUP BY id2 HAVING id2=id1-2); +PREPARE stmt FROM "INSERT INTO t1 (id1,val1) VALUES (6,'f') RETURNING (SELECT id2 FROM t2 WHERE val2='b')"; +EXECUTE stmt; +DELETE FROM t1 WHERE id1=6; +SELECT * FROM t1; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +INSERT IGNORE INTO t1(id1,val1) VALUES (7,'h') RETURNING *; +SELECT * FROM t1; +EXPLAIN INSERT INTO t1(id1,val1) VALUES (8,'i') RETURNING *; +EXPLAIN EXTENDED INSERT INTO t1(id1,val1) VALUES(9,'j') RETURNING id1; +EXPLAIN FORMAT="json" INSERT INTO t1(id1,val1) VALUES (10,'k') RETURNING id1; +SELECT * FROM t1; +INSERT INTO v1(id1, val1) VALUES (12, 'a') RETURNING id1+id1 as total,val1, +id1 && id1, id1 id1, UPPER(val1),f(id1); +ANALYZE INSERT INTO t1(id1,val1) VALUES(13,'l') RETURNING *; +INSERT INTO t1(id1,val1) VALUES(14,'m') RETURNING t1.*; +TRUNCATE TABLE t1; + +--echo # +--echo # Multiple values in one insert statement...RETURNING +--echo # +INSERT INTO t1 VALUES (1,'a'),(2,'b'); +INSERT INTO t1 VALUES (3,'c'),(4,'d') RETURNING *; +INSERT INTO t1 VALUES (5,'e'),(6,'f') RETURNING id1 as id,val1, +id1 && id1, id1|id1, UPPER(val1),f(id1); +INSERT INTO t1 VALUES (7,'g'),(8,'h') RETURNING(SELECT GROUP_CONCAT(val2) +FROM t2 WHERE id2=1); +INSERT INTO t1 VALUES (9,'i'),(10,'j') RETURNING(SELECT GROUP_CONCAT(val2) +FROM t2 GROUP BY id2 HAVING id2=id1-8); +PREPARE stmt FROM "INSERT INTO t1 VALUES (11,'k'),(12,'l') RETURNING (SELECT id2 FROM t2 WHERE val2='b')"; +EXECUTE stmt; +DELETE FROM t1 WHERE val1 IN ('k','l'); +SELECT * FROM t1; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +INSERT IGNORE INTO t1 VALUES(13,'o'),(14,'p') RETURNING *; +EXPLAIN INSERT INTO t1 VALUES(15,'q'),(16,'r') RETURNING *; +EXPLAIN EXTENDED INSERT INTO t1 VALUES (17,'s'),(18,'t') RETURNING *; +EXPLAIN FORMAT="json" INSERT INTO t1 VALUES(19,'u'),(20,'v') RETURNING id1; +SELECT * FROM t1; +INSERT INTO v1 VALUES(23,'y'),(24,'z') RETURNING id1 as id,val1, +id1 && id1, id1|id1, UPPER(val1),f(id1); +ANALYZE INSERT INTO t1 VALUES(25,'a'),(26,'b') RETURNING *; +ANALYZE INSERT INTO t1 VALUES(27,'c'),(28,'d') RETURNING t1.*; + +--echo # +--echo # INSERT...ON DUPLICATE KEY UPDATE...RETURNING +--echo # +CREATE TABLE ins_duplicate (id INT PRIMARY KEY AUTO_INCREMENT, val VARCHAR(1)); +INSERT INTO ins_duplicate VALUES (1,'a'); +INSERT INTO ins_duplicate VALUES (2,'b') ON DUPLICATE KEY UPDATE val='b' +RETURNING *; +INSERT INTO ins_duplicate VALUES (2,'b') ON DUPLICATE KEY UPDATE val='c' +RETURNING id+id AS total, val, id && id, id|id, UPPER(val),f(id); +INSERT INTO ins_duplicate VALUES (2,'b') ON DUPLICATE KEY UPDATE val='d' +RETURNING (SELECT GROUP_CONCAT(val2) FROM t2 WHERE id2=1); +INSERT INTO ins_duplicate VALUES (2,'b') ON DUPLICATE KEY UPDATE val='e' +RETURNING (SELECT GROUP_CONCAT(val2) FROM t2 GROUP BY id2 HAVING id2=id); +PREPARE stmt FROM "INSERT INTO ins_duplicate VALUES (2,'b') ON DUPLICATE +KEY UPDATE val='f' RETURNING (SELECT id2 FROM t2 WHERE val2='b')"; +EXECUTE stmt; +SELECT * FROM t2; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +INSERT IGNORE INTO ins_duplicate(id,val) VALUES (3,'c'),(4,'d') ON DUPLICATE +KEY UPDATE val='g' RETURNING id; +EXPLAIN INSERT INTO ins_duplicate(id,val) VALUES (2,'b') ON DUPLICATE KEY +UPDATE val='h' RETURNING val; +EXPLAIN EXTENDED INSERT INTO ins_duplicate(id,val) VALUES (2,'b') +ON DUPLICATE KEY UPDATE val='i' RETURNING val; +EXPLAIN FORMAT="json" INSERT INTO ins_duplicate(id,val) VALUES (2,'b') +ON DUPLICATE KEY UPDATE val='j' RETURNING val; +INSERT INTO v1(id1, val1) VALUES (2,'d') ON DUPLICATE KEY UPDATE +val1='d' RETURNING id1+id1 AS total, val1, id1 && id1, id1|id1, UPPER(val1), +f(id1); +ANALYZE INSERT INTO ins_duplicate(id,val) VALUES(2,'b') ON DUPLICATE KEY UPDATE +val='k' RETURNING *; +INSERT INTO ins_duplicate(id,val) VALUES(2,'b') ON DUPLICATE KEY UPDATE +val='l' RETURNING ins_duplicate.*; +SELECT * FROM ins_duplicate; + +--echo # +--echo # INSERT...SET...RETURNING +--echo # +TRUNCATE TABLE t1; +INSERT INTO t1 SET id1= 1, val1= 'a'; +INSERT INTO t1 SET id1= 2, val1= 'b' RETURNING *; +INSERT INTO t1 SET id1= 3, val1= 'c' RETURNING id1+id1 AS total,val1, +id1 && id1, id1|id1, UPPER(val1),f(id1); +INSERT INTO t1 SET id1= 4, val1= 'd' RETURNING (SELECT GROUP_CONCAT(val2) +FROM t2 WHERE id2=1); +INSERT INTO t1 SET id1= 5, val1='e' RETURNING (SELECT GROUP_CONCAT(val2) +FROM t2 GROUP BY id2 HAVING id2=id1-3); +PREPARE stmt FROM "INSERT INTO t1 SET id1= 6, val1='f' RETURNING (SELECT id2 FROM t2 WHERE val2='b')"; +EXECUTE stmt; +DELETE FROM t1 WHERE val1='f'; +SELECT * FROM t1; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +INSERT INTO t1 SET id1= 7, val1= 'g' RETURNING f(id1); +INSERT INTO t1 SET val1= 'n' RETURNING *; +INSERT IGNORE INTO t1 SET id1= 8, val1= 'h' RETURNING *; +EXPLAIN INSERT INTO t1 SET id1=9, val1='i' RETURNING id1; +EXPLAIN EXTENDED INSERT INTO t1 SET id1=10, val1='j' RETURNING val1; +EXPLAIN FORMAT="json" INSERT INTO t1 SET id1=11, val1='k' RETURNING val1; +INSERT INTO v1 SET id1=26, val1='Z' RETURNING id1+id1 AS total,val1, +id1 && id1, id1|id1, UPPER(val1),f(id1); +ANALYZE INSERT INTO t1 SET id1=12, val1='l' RETURNING *; +INSERT INTO t1 SET id1= 13, val1= 'm' RETURNING t1.*; +SELECT * FROM t1; + +--echo # +--echo # INSERT...SELECT...RETURNING +--echo # +TRUNCATE TABLE t2; +INSERT INTO t2(id2,val2) SELECT * FROM t1; +TRUNCATE TABLE t2; +INSERT INTO t2 SELECT * FROM t1 WHERE id1=1 RETURNING *; +INSERT INTO t2 SELECT * FROM t1 WHERE id1=2 RETURNING id2+id2 AS total, +val2,id2 && id2, id2|id2, UPPER(val2),f(id2); +INSERT INTO t2 SELECT * FROM t1 WHERE id1=3 RETURNING (SELECT GROUP_CONCAT(val1) FROM t1 GROUP BY id1 HAVING id1=id1+1); +PREPARE stmt FROM "INSERT INTO t2 SELECT * FROM t1 WHERE id1=4 RETURNING (SELECT id1 FROM t1 WHERE val1='b')"; +EXECUTE stmt; +DELETE FROM t2 WHERE id2=4; +SELECT * FROM t1; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +INSERT INTO t2 SELECT * FROM t1 WHERE id1=6 RETURNING +(SELECT id1+id2 FROM t1 WHERE id1=1); +INSERT INTO t2 SELECT * FROM t1 WHERE id1=7 RETURNING f(id2); +EXPLAIN INSERT INTO t2 SELECT * FROM t1 WHERE id1=8 RETURNING id2; +EXPLAIN EXTENDED INSERT INTO t1 SELECT * FROM t1 WHERE id1=9 RETURNING val1; +EXPLAIN FORMAT="json" INSERT INTO t1 SELECT * FROM t1 WHERE id1=10 RETURNING val1; +INSERT IGNORE INTO t2 SELECT * FROM t1 WHERE id1=8 RETURNING *; +INSERT IGNORE INTO v2 SELECT * FROM v1 RETURNING *; +ANALYZE INSERT INTO t2 SELECT * FROM t1 WHERE id1=11 RETURNING *; +SELECT * FROM t2; +TRUNCATE TABLE t2; +INSERT INTO t2 SELECT * FROM t1 WHERE id1=1 RETURNING t2.*; +INSERT INTO t2 SELECT t1.* FROM t1 WHERE id1=2 RETURNING t2.*; +SELECT * FROM t2; + +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE ins_duplicate; + +--echo # +--echo # Error message test +--echo # + +CREATE TABLE t1(id1 INT,val1 VARCHAR(1)); +CREATE TABLE t2(id2 INT,val2 VARCHAR(1)); +CREATE TABLE ins_duplicate (id INT PRIMARY KEY, val VARCHAR(1)); + +INSERT INTO t1 VALUES(1,'a'),(2,'b'),(3,'c'); + +--echo # +--echo # SIMLPE INSERT STATEMENT +--echo # +--error ER_BAD_FIELD_ERROR +INSERT INTO t2(id2,val2) VALUES(1,'a') RETURNING id1; +--error ER_INVALID_GROUP_FUNC_USE +INSERT INTO t2(id2,val2) values(2,'b') RETURNING SUM(id2); +--error ER_SUBQUERY_NO_1_ROW +INSERT INTO t2(id2,val2) VALUES(3,'c') RETURNING (SELECT id1 FROM t1); +--error ER_OPERAND_COLUMNS +INSERT INTO t2(id2,val2) VALUES(4,'d') RETURNING (SELECT * FROM t1); +--error ER_OPERAND_COLUMNS +INSERT INTO t2(id2,val2) VALUES(4,'d') RETURNING (SELECT * FROM t2); +INSERT INTO t2(id2,val2) VALUES(5,'e') RETURNING id2, (SELECT id1+id2 FROM +t1 WHERE id1=1); +--error ER_UPDATE_TABLE_USED +INSERT INTO t2(id2,val2) VALUES(5,'f') RETURNING (SELECT id2 FROM t2); +--error ER_BAD_TABLE_ERROR +INSERT INTO t2 (id2, val2) VALUES (6,'f') RETURNING t1.*; + +--echo # +--echo # Multiple rows in single insert statement +--echo # +--error ER_BAD_FIELD_ERROR +INSERT INTO t2 VALUES(1,'a'),(2,'b') RETURNING id1; +--error ER_INVALID_GROUP_FUNC_USE +INSERT INTO t2 VALUES(3,'c'),(4,'d') RETURNING MAX(id2); +--error ER_SUBQUERY_NO_1_ROW +INSERT INTO t2 VALUES(5,'c'),(6,'f') RETURNING (SELECT id1 FROM t1); +--error ER_OPERAND_COLUMNS +INSERT INTO t2 VALUES(7,'g'),(8,'h') RETURNING (SELECT * FROM t1); +--error ER_OPERAND_COLUMNS +INSERT INTO t2 VALUES(9,'g'),(10,'h') RETURNING (SELECT * FROM t2); +INSERT INTO t2 VALUES(11,'e'),(12,'f') RETURNING id2, (SELECT id1+id2 FROM +t1 WHERE id1=1); +--error ER_UPDATE_TABLE_USED +INSERT INTO t2 VALUES(13,'f'),(14,'g') RETURNING (SELECT id2 FROM t2); +--error ER_BAD_TABLE_ERROR +INSERT INTO t2 VALUES(13,'f'),(14,'g') RETURNING t1.*; + +--echo # +--echo # INSERT ... SET +--echo # +--error ER_BAD_FIELD_ERROR +INSERT INTO t2 SET id2=1, val2='a' RETURNING id1; +--error ER_INVALID_GROUP_FUNC_USE +INSERT INTO t2 SET id2=2, val2='b' RETURNING COUNT(id2); +--error ER_SUBQUERY_NO_1_ROW +INSERT INTO t2 SET id2=3, val2='c' RETURNING (SELECT id1 FROM t1); +--error ER_OPERAND_COLUMNS +INSERT INTO t2 SET id2=4, val2='d' RETURNING (SELECT * FROM t1); +--error ER_OPERAND_COLUMNS +INSERT INTO t2 SET id2=4, val2='d' RETURNING (SELECT * FROM t2); +INSERT INTO t2 SET id2=5, val2='e' RETURNING id2, (SELECT id1+id2 FROM t1 +WHERE id1=1); +--error ER_UPDATE_TABLE_USED +INSERT INTO t2 SET id2=5, val2='f' RETURNING (SELECT id2 FROM t2); +--error ER_BAD_TABLE_ERROR +INSERT INTO t2 SET id2=5, val2='f' RETURNING t1.*; + +--echo # +--echo # INSERT...ON DUPLICATE KEY UPDATE +--echo # +--error ER_BAD_FIELD_ERROR +INSERT INTO ins_duplicate VALUES (2,'b') ON DUPLICATE KEY UPDATE val='b' +RETURNING id1; +--error ER_INVALID_GROUP_FUNC_USE +INSERT INTO ins_duplicate VALUES (2,'b') ON DUPLICATE KEY UPDATE val='b' +RETURNING MAX(id); +--error ER_SUBQUERY_NO_1_ROW +INSERT INTO ins_duplicate VALUES (2,'b') ON DUPLICATE KEY UPDATE val='b' +RETURNING (SELECT id1 FROM t1); +--error ER_OPERAND_COLUMNS +INSERT INTO ins_duplicate VALUES (2,'b') ON DUPLICATE KEY UPDATE val='b' +RETURNING (SELECT * FROM t1); +--error ER_OPERAND_COLUMNS +INSERT INTO ins_duplicate VALUES (2,'b') ON DUPLICATE KEY UPDATE val='b' +RETURNING (SELECT * FROM ins_duplicate); +--error ER_BAD_FIELD_ERROR +INSERT INTO ins_duplicate VALUES(2,'b') ON DUPLICATE KEY UPDATE val='b' +RETURNING id2, (SELECT id1+id FROM t1 WHERE id1=1); +--error ER_UPDATE_TABLE_USED +INSERT INTO ins_duplicate VALUES(2,'b') ON DUPLICATE KEY UPDATE val='b' +RETURNING (SELECT id FROM ins_duplicate); +--error ER_BAD_TABLE_ERROR +INSERT INTO ins_duplicate VALUES(2,'b') ON DUPLICATE KEY UPDATE val='b' +RETURNING t1.*; + +--echo # +--echo # INSERT...SELECT +--echo # +--error ER_BAD_FIELD_ERROR +INSERT INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=1 RETURNING id1; +--error ER_INVALID_GROUP_FUNC_USE +INSERT INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=2 RETURNING MAX(id2); +--error ER_SUBQUERY_NO_1_ROW +INSERT INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=2 RETURNING (SELECT +id1 FROM t1); +--error ER_OPERAND_COLUMNS +INSERT INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=2 RETURNING (SELECT +* FROM t1); +--error ER_OPERAND_COLUMNS +INSERT INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=2 RETURNING(SELECT +* FROM t2); +--error ER_SUBQUERY_NO_1_ROW +INSERT INTO t2(id2,val2) SELECT * FROM t1 WHERE id1=2 RETURNING (SELECT +id2 FROM t2); +--error ER_BAD_TABLE_ERROR +INSERT INTO t2(id2,val2) SELECT t1.* FROM t1 WHERE id1=2 RETURNING t1.*; + +--echo # +--echo # TRIGGER +--echo # +CREATE TRIGGER bi1 before insert on t1 for each row set NEW.val1= 'z'; +INSERT INTO t1 VALUES (4, 'd'), (5, 'e') RETURNING *; + +--error ER_SP_NO_RETSET +CREATE TRIGGER bi2 before insert on t2 for each row + INSERT INTO t1 VALUES (NEW.id2, NEW.val2) RETURNING *; + +--echo # +--echo # SP +--echo # +delimiter |; +--error ER_SP_NO_RETSET +CREATE FUNCTION f1(arg INT) RETURNS TEXT +BEGIN + INSERT INTO t1 VALUES (arg, arg) RETURNING *; + RETURN arg; +END| +delimiter ;| + +CREATE PROCEDURE sp1(arg INT) + INSERT INTO t1 VALUES (arg, arg) RETURNING *; + +CALL sp1(0); + +DROP PROCEDURE sp1; +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE ins_duplicate; +DROP VIEW v1; +DROP VIEW v2; +DROP FUNCTION f; diff --git a/mysql-test/main/insert_returning_datatypes.result b/mysql-test/main/insert_returning_datatypes.result new file mode 100644 index 00000000000..d0516d172f8 --- /dev/null +++ b/mysql-test/main/insert_returning_datatypes.result @@ -0,0 +1,72 @@ +CREATE TABLE t1(num_int1 INT(2) PRIMARY KEY, +num_bit1 BIT(8), +num_float1 FLOAT(5,2), +num_double1 DOUBLE(5,2), +char_enum1 ENUM('A','B','C','D'), +char_set1 SET('a','b','c','d','e'), +str_varchar1 VARCHAR(2), +d1 DATE, +dt1 DATETIME, +ts1 TIMESTAMP, +y1 YEAR, +b1 BOOL); +CREATE TABLE t2(num_int2 INT(2) PRIMARY KEY, +num_bit2 BIT(8), +num_float2 FLOAT(5,2), +num_double2 DOUBLE(5,2), +char_enum2 ENUM('A','B','C','D'), +char_set2 SET('a','b','c','d','e'), +str_varchar2 VARCHAR(2), +d2 DATE, +dt2 DATETIME, +ts2 TIMESTAMP, +y2 YEAR, +b2 BOOL); +# +# SIMLPE INSERT STATEMENT +# +INSERT INTO t1(num_int1,num_bit1,num_float1,num_double1,char_enum1,char_set1, +str_varchar1, d1,dt1,ts1,y1,b1) VALUES(1,b'1000011', 123.45, 123.55, +'A','b,e', 'V','120314',"2012-04-19 13:08:22", '2001-07-22 12:12:12', +2012,0) RETURNING *; +num_int1 num_bit1 num_float1 num_double1 char_enum1 char_set1 str_varchar1 d1 dt1 ts1 y1 b1 +1 C 123.45 123.55 A b,e V 2012-03-14 2012-04-19 13:08:22 2001-07-22 12:12:12 2012 0 +# +# MULTIPLE ROWS IN SINGLE STATEMENT +# +INSERT INTO t1 VALUES(2,b'1000011', 123.45, 123.55, 'A','b,e', 'V', +'120314',"2012-04-19 13:08:22", '2001-07-22 12:12:12',2012,0),(3,b'1000011', +123.45, 123.55, 'A','b,e', 'V','120314',"2012-04-19 13:08:22", +'2001-07-22 12:12:12',2012,1) RETURNING *; +num_int1 num_bit1 num_float1 num_double1 char_enum1 char_set1 str_varchar1 d1 dt1 ts1 y1 b1 +2 C 123.45 123.55 A b,e V 2012-03-14 2012-04-19 13:08:22 2001-07-22 12:12:12 2012 0 +3 C 123.45 123.55 A b,e V 2012-03-14 2012-04-19 13:08:22 2001-07-22 12:12:12 2012 1 +# +# INSERT...SET...RETURNING +# +INSERT INTO t1 SET num_int1=4,num_bit1=b'1000011',num_float1=124.67, +num_double1=231.12,char_enum1='B',char_set1='a,d,e', +str_varchar1='AB',d1='120314',dt1="2012-04-19 13:08:22", +ts1='2001-07-22 12:12:1',y1=2014,b1=1 RETURNING *; +num_int1 num_bit1 num_float1 num_double1 char_enum1 char_set1 str_varchar1 d1 dt1 ts1 y1 b1 +4 C 124.67 231.12 B a,d,e AB 2012-03-14 2012-04-19 13:08:22 2001-07-22 12:12:01 2014 1 +# +# INSERT...ON DUPLICATE KEY UPDATE +# +INSERT INTO t1 VALUES (5,b'1000011', 123.45, 123.55,'C','b,e', 'V', +'120314',"2012-04-19 13:08:22", '2001-07-22 12:12:12',2012,0) +ON DUPLICATE KEY UPDATE num_float1=111.111 RETURNING *; +num_int1 num_bit1 num_float1 num_double1 char_enum1 char_set1 str_varchar1 d1 dt1 ts1 y1 b1 +5 C 123.45 123.55 C b,e V 2012-03-14 2012-04-19 13:08:22 2001-07-22 12:12:12 2012 0 +# +# INSERT...SELECT...RETURNING +# +INSERT INTO t2 SELECT * FROM t1 RETURNING *; +num_int2 num_bit2 num_float2 num_double2 char_enum2 char_set2 str_varchar2 d2 dt2 ts2 y2 b2 +1 C 123.45 123.55 A b,e V 2012-03-14 2012-04-19 13:08:22 2001-07-22 12:12:12 2012 0 +2 C 123.45 123.55 A b,e V 2012-03-14 2012-04-19 13:08:22 2001-07-22 12:12:12 2012 0 +3 C 123.45 123.55 A b,e V 2012-03-14 2012-04-19 13:08:22 2001-07-22 12:12:12 2012 1 +4 C 124.67 231.12 B a,d,e AB 2012-03-14 2012-04-19 13:08:22 2001-07-22 12:12:01 2014 1 +5 C 123.45 123.55 C b,e V 2012-03-14 2012-04-19 13:08:22 2001-07-22 12:12:12 2012 0 +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/main/insert_returning_datatypes.test b/mysql-test/main/insert_returning_datatypes.test new file mode 100644 index 00000000000..6591e91cb4d --- /dev/null +++ b/mysql-test/main/insert_returning_datatypes.test @@ -0,0 +1,74 @@ +#Test for checking all dataypes are returned + +CREATE TABLE t1(num_int1 INT(2) PRIMARY KEY, +num_bit1 BIT(8), +num_float1 FLOAT(5,2), +num_double1 DOUBLE(5,2), +char_enum1 ENUM('A','B','C','D'), +char_set1 SET('a','b','c','d','e'), +str_varchar1 VARCHAR(2), +d1 DATE, +dt1 DATETIME, +ts1 TIMESTAMP, +y1 YEAR, +b1 BOOL); + +CREATE TABLE t2(num_int2 INT(2) PRIMARY KEY, +num_bit2 BIT(8), +num_float2 FLOAT(5,2), +num_double2 DOUBLE(5,2), +char_enum2 ENUM('A','B','C','D'), +char_set2 SET('a','b','c','d','e'), +str_varchar2 VARCHAR(2), +d2 DATE, +dt2 DATETIME, +ts2 TIMESTAMP, +y2 YEAR, +b2 BOOL); + + +--echo # +--echo # SIMLPE INSERT STATEMENT +--echo # +INSERT INTO t1(num_int1,num_bit1,num_float1,num_double1,char_enum1,char_set1, +str_varchar1, d1,dt1,ts1,y1,b1) VALUES(1,b'1000011', 123.45, 123.55, + 'A','b,e', 'V','120314',"2012-04-19 13:08:22", '2001-07-22 12:12:12', +2012,0) RETURNING *; + + +--echo # +--echo # MULTIPLE ROWS IN SINGLE STATEMENT +--echo # +INSERT INTO t1 VALUES(2,b'1000011', 123.45, 123.55, 'A','b,e', 'V', +'120314',"2012-04-19 13:08:22", '2001-07-22 12:12:12',2012,0),(3,b'1000011', +123.45, 123.55, 'A','b,e', 'V','120314',"2012-04-19 13:08:22", +'2001-07-22 12:12:12',2012,1) RETURNING *; + + + +--echo # +--echo # INSERT...SET...RETURNING +--echo # +INSERT INTO t1 SET num_int1=4,num_bit1=b'1000011',num_float1=124.67, +num_double1=231.12,char_enum1='B',char_set1='a,d,e', +str_varchar1='AB',d1='120314',dt1="2012-04-19 13:08:22", +ts1='2001-07-22 12:12:1',y1=2014,b1=1 RETURNING *; + + + +--echo # +--echo # INSERT...ON DUPLICATE KEY UPDATE +--echo # +INSERT INTO t1 VALUES (5,b'1000011', 123.45, 123.55,'C','b,e', 'V', +'120314',"2012-04-19 13:08:22", '2001-07-22 12:12:12',2012,0) +ON DUPLICATE KEY UPDATE num_float1=111.111 RETURNING *; + + +--echo # +--echo # INSERT...SELECT...RETURNING +--echo # +INSERT INTO t2 SELECT * FROM t1 RETURNING *; + + +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/main/intersect.result b/mysql-test/main/intersect.result index 5990fcce110..95a3c2f7db9 100644 --- a/mysql-test/main/intersect.result +++ b/mysql-test/main/intersect.result @@ -108,7 +108,8 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 } @@ -126,7 +127,8 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 } @@ -144,7 +146,8 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 } @@ -167,7 +170,8 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 1, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "materialized": { @@ -189,7 +193,8 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 } @@ -207,7 +212,8 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 } @@ -225,7 +231,8 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 } @@ -349,7 +356,8 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 } @@ -367,7 +375,8 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 }, @@ -378,7 +387,8 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 }, @@ -406,7 +416,8 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 1, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "materialized": { @@ -428,7 +439,8 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 } @@ -446,7 +458,8 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 }, @@ -457,7 +470,8 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 }, @@ -508,8 +522,6 @@ select 1 as a from dual union all select 1 from dual; a 1 1 -select 1 from dual intersect all select 1 from dual; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'all select 1 from dual' at line 1 create table t1 (a int, b blob, a1 int, b1 blob); create table t2 (c int, d blob, c1 int, d1 blob); insert into t1 values (1,"ddd", 1, "sdfrrwwww"),(2, "fgh", 2, "dffggtt"); @@ -611,22 +623,6 @@ NULL INTERSECT RESULT <intersect2,3> ALL NULL NULL NULL NULL NULL NULL NULL UNION RESULT <union1,5,4> ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1003 (/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) union /* select#5 */ select `__5`.`c` AS `c`,`__5`.`d` AS `d` from ((/* select#2 */ select `test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2`) intersect (/* select#3 */ select `test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t3`)) `__5` union (/* select#4 */ select 4 AS `4`,4 AS `4`) -set SQL_MODE=ORACLE; -(select a,b from t1) union (select c,d from t2) intersect (select e,f from t3) union (select 4,4); -a b -3 3 -4 4 -explain extended -(select a,b from t1) union (select c,d from t2) intersect (select e,f from t3) union (select 4,4); -id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 -2 UNION t2 ALL NULL NULL NULL NULL 2 100.00 -3 INTERSECT t3 ALL NULL NULL NULL NULL 2 100.00 -4 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used -NULL UNIT RESULT <unit1,2,3,4> ALL NULL NULL NULL NULL NULL NULL -Warnings: -Note 1003 (/* select#1 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1") union (/* select#2 */ select "test"."t2"."c" AS "c","test"."t2"."d" AS "d" from "test"."t2") intersect (/* select#3 */ select "test"."t3"."e" AS "e","test"."t3"."f" AS "f" from "test"."t3") union (/* select#4 */ select 4 AS "4",4 AS "4") -set SQL_MODE=default; (select e,f from t3) intersect (select c,d from t2) union (select a,b from t1) union (select 4,4); e f 3 3 @@ -643,24 +639,6 @@ id select_type table type possible_keys key key_len ref rows filtered Extra NULL UNIT RESULT <unit1,2,3,4> ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1003 (/* select#1 */ select `test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t3`) intersect (/* select#2 */ select `test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2`) union (/* select#3 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) union (/* select#4 */ select 4 AS `4`,4 AS `4`) -set SQL_MODE=ORACLE; -(select e,f from t3) intersect (select c,d from t2) union (select a,b from t1) union (select 4,4); -e f -3 3 -4 4 -5 5 -6 6 -explain extended -(select e,f from t3) intersect (select c,d from t2) union (select a,b from t1) union (select 4,4); -id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t3 ALL NULL NULL NULL NULL 2 100.00 -2 INTERSECT t2 ALL NULL NULL NULL NULL 2 100.00 -3 UNION t1 ALL NULL NULL NULL NULL 2 100.00 -4 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used -NULL UNIT RESULT <unit1,2,3,4> ALL NULL NULL NULL NULL NULL NULL -Warnings: -Note 1003 (/* select#1 */ select "test"."t3"."e" AS "e","test"."t3"."f" AS "f" from "test"."t3") intersect (/* select#2 */ select "test"."t2"."c" AS "c","test"."t2"."d" AS "d" from "test"."t2") union (/* select#3 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1") union (/* select#4 */ select 4 AS "4",4 AS "4") -set SQL_MODE=default; (/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) union /* select#3 */ select `__3`.`c` AS `c`,`__3`.`d` AS `d` from ((/* select#2 */ select `test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2`) intersect (/* select#4 */ select `test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t3`)) `__3` union (/* select#5 */ select 4 AS `4`,4 AS `4`); a b 3 3 @@ -824,12 +802,6 @@ create table t234(c1 int); insert into t234 values(2); insert into t234 values(3); insert into t234 values(4); -set SQL_MODE=oracle; -select * from t13 union select * from t234 intersect select * from t12; -c1 -1 -2 -set SQL_MODE=default; select * from t13 union select * from t234 intersect select * from t12; c1 1 @@ -852,9 +824,9 @@ select * from t2 where a < 5 intersect select * from t3 where a < 5; a +1 7 7 -1 explain extended select * from t1 where a > 4 union all diff --git a/mysql-test/main/intersect.test b/mysql-test/main/intersect.test index 18c95d62d44..5e811f1f56d 100644 --- a/mysql-test/main/intersect.test +++ b/mysql-test/main/intersect.test @@ -24,9 +24,9 @@ EXPLAIN (select a,b from t1) intersect (select c,d from t2) intersect (select e, EXPLAIN extended (select a,b from t1) intersect (select c,d from t2) intersect (select e,f from t3); EXPLAIN extended select * from ((select a,b from t1) intersect (select c,d from t2) intersect (select e,f from t3)) a; EXPLAIN format=json (select a,b from t1) intersect (select c,d from t2) intersect (select e,f from t3); ---replace_regex /"r_total_time_ms": [0-9e\.\-+]*,/"r_total_time_ms": "REPLACED",/ +--source include/analyze-format.inc ANALYZE format=json (select a,b from t1) intersect (select c,d from t2) intersect (select e,f from t3); ---replace_regex /"r_total_time_ms": [0-9e\.\-+]*,/"r_total_time_ms": "REPLACED",/ +--source include/analyze-format.inc ANALYZE format=json select * from ((select a,b from t1) intersect (select c,d from t2) intersect (select e,f from t3)) a; select * from ((select a,b from t1) intersect (select c,d from t2) intersect (select e,f from t3)) a; @@ -44,9 +44,9 @@ EXPLAIN extended (select a,b from t1) intersect (select c,e from t2,t3); EXPLAIN extended select * from ((select a,b from t1) intersect (select c,e from t2,t3)) a; set @@optimizer_switch='optimize_join_buffer_size=off'; EXPLAIN format=json (select a,b from t1) intersect (select c,e from t2,t3); ---replace_regex /"r_total_time_ms": [0-9e\.\-+]*,/"r_total_time_ms": "REPLACED",/ +--source include/analyze-format.inc ANALYZE format=json (select a,b from t1) intersect (select c,e from t2,t3); ---replace_regex /"r_total_time_ms": [0-9e\.\-+]*,/"r_total_time_ms": "REPLACED",/ +--source include/analyze-format.inc ANALYZE format=json select * from ((select a,b from t1) intersect (select c,e from t2,t3)) a; set @@optimizer_switch=@save_optimizer_switch; select * from ((select a,b from t1) intersect (select c,e from t2,t3)) a; @@ -71,8 +71,6 @@ select 1 as a from dual intersect select 1 from dual; select 1 from dual ORDER BY 1 intersect select 1 from dual; select 1 as a from dual union all select 1 from dual; ---error ER_PARSE_ERROR -select 1 from dual intersect all select 1 from dual; @@ -153,12 +151,6 @@ insert into t3 values (1,1),(3,3); (select a,b from t1) union (select c,d from t2) intersect (select e,f from t3) union (select 4,4); explain extended (select a,b from t1) union (select c,d from t2) intersect (select e,f from t3) union (select 4,4); -set SQL_MODE=ORACLE; ---sorted_result -(select a,b from t1) union (select c,d from t2) intersect (select e,f from t3) union (select 4,4); -explain extended -(select a,b from t1) union (select c,d from t2) intersect (select e,f from t3) union (select 4,4); -set SQL_MODE=default; # test result of linear mix operation @@ -166,12 +158,6 @@ set SQL_MODE=default; (select e,f from t3) intersect (select c,d from t2) union (select a,b from t1) union (select 4,4); explain extended (select e,f from t3) intersect (select c,d from t2) union (select a,b from t1) union (select 4,4); -set SQL_MODE=ORACLE; ---sorted_result -(select e,f from t3) intersect (select c,d from t2) union (select a,b from t1) union (select 4,4); -explain extended -(select e,f from t3) intersect (select c,d from t2) union (select a,b from t1) union (select 4,4); -set SQL_MODE=default; --sorted_result (/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) union /* select#3 */ select `__3`.`c` AS `c`,`__3`.`d` AS `d` from ((/* select#2 */ select `test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2`) intersect (/* select#4 */ select `test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t3`)) `__3` union (/* select#5 */ select 4 AS `4`,4 AS `4`); @@ -316,11 +302,7 @@ create table t234(c1 int); insert into t234 values(2); insert into t234 values(3); insert into t234 values(4); - -set SQL_MODE=oracle; ---sorted_result -select * from t13 union select * from t234 intersect select * from t12; -set SQL_MODE=default; + --sorted_result select * from t13 union select * from t234 intersect select * from t12; @@ -339,7 +321,7 @@ insert into t2 values (4), (5), (9), (1), (8), (9); create table t3 (a int); insert into t3 values (8), (1), (8), (2), (3), (7), (2); - +--sorted_result select * from t1 where a > 4 union all select * from t2 where a < 5 diff --git a/mysql-test/main/intersect_all.result b/mysql-test/main/intersect_all.result new file mode 100644 index 00000000000..7483e1df06e --- /dev/null +++ b/mysql-test/main/intersect_all.result @@ -0,0 +1,902 @@ +create table t1 (a int, b int) engine=MyISAM; +create table t2 (c int, d int) engine=MyISAM; +insert into t1 values (1,1),(2,2),(3,3),(2,2); +insert into t2 values (2,2),(2,2),(5,5); +select * from t1 intersect all select * from t2; +a b +2 2 +2 2 +(select a,b from t1) intersect all (select c,d from t2); +a b +2 2 +2 2 +select * from ((select a,b from t1) intersect all (select c,d from t2)) t; +a b +2 2 +2 2 +select * from ((select a from t1) intersect all (select c from t2)) t; +a +2 +2 +drop tables t1,t2; +create table t1 (a int, b int) engine=MyISAM; +create table t2 (c int, d int) engine=MyISAM; +create table t3 (e int, f int) engine=MyISAM; +insert into t1 values (1,1),(2,2),(3,3),(2,2); +insert into t2 values (2,2),(3,3),(4,4),(2,2); +insert into t3 values (1,1),(2,2),(5,5),(2,2); +(select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3); +a b +2 2 +2 2 +EXPLAIN (select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 +2 INTERSECT t2 ALL NULL NULL NULL NULL 4 +3 INTERSECT t3 ALL NULL NULL NULL NULL 4 +NULL INTERSECT RESULT <intersect1,2,3> ALL NULL NULL NULL NULL NULL +EXPLAIN extended (select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 100.00 +2 INTERSECT t2 ALL NULL NULL NULL NULL 4 100.00 +3 INTERSECT t3 ALL NULL NULL NULL NULL 4 100.00 +NULL INTERSECT RESULT <intersect1,2,3> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 (/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) intersect all (/* select#2 */ select `test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2`) intersect all (/* select#3 */ select `test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t3`) +EXPLAIN extended select * from ((select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3)) a; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4 100.00 +2 DERIVED t1 ALL NULL NULL NULL NULL 4 100.00 +3 INTERSECT t2 ALL NULL NULL NULL NULL 4 100.00 +4 INTERSECT t3 ALL NULL NULL NULL NULL 4 100.00 +NULL INTERSECT RESULT <intersect2,3,4> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `a`.`a` AS `a`,`a`.`b` AS `b` from ((/* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) intersect all (/* select#3 */ select `test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2`) intersect all (/* select#4 */ select `test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t3`)) `a` +EXPLAIN format=json (select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3); +EXPLAIN +{ + "query_block": { + "union_result": { + "table_name": "<intersect1,2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 1, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 4, + "filtered": 100 + } + } + }, + { + "query_block": { + "select_id": 2, + "operation": "INTERSECT", + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 4, + "filtered": 100 + } + } + }, + { + "query_block": { + "select_id": 3, + "operation": "INTERSECT", + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 4, + "filtered": 100 + } + } + } + ] + } + } +} +ANALYZE format=json (select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3); +ANALYZE +{ + "query_block": { + "union_result": { + "table_name": "<intersect1,2,3>", + "access_type": "ALL", + "r_loops": 1, + "r_rows": 2, + "query_specifications": [ + { + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 4, + "r_rows": 4, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + }, + { + "query_block": { + "select_id": 2, + "operation": "INTERSECT", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "t2", + "access_type": "ALL", + "r_loops": 1, + "rows": 4, + "r_rows": 4, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + }, + { + "query_block": { + "select_id": 3, + "operation": "INTERSECT", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "t3", + "access_type": "ALL", + "r_loops": 1, + "rows": 4, + "r_rows": 4, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + } + ] + } + } +} +ANALYZE format=json select * from ((select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3)) a; +ANALYZE +{ + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "r_loops": 1, + "rows": 4, + "r_rows": 2, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "materialized": { + "query_block": { + "union_result": { + "table_name": "<intersect2,3,4>", + "access_type": "ALL", + "r_loops": 1, + "r_rows": 2, + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 4, + "r_rows": 4, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + }, + { + "query_block": { + "select_id": 3, + "operation": "INTERSECT", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "t2", + "access_type": "ALL", + "r_loops": 1, + "rows": 4, + "r_rows": 4, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + }, + { + "query_block": { + "select_id": 4, + "operation": "INTERSECT", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "t3", + "access_type": "ALL", + "r_loops": 1, + "rows": 4, + "r_rows": 4, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + } + ] + } + } + } + } + } +} +select * from ((select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3)) a; +a b +2 2 +2 2 +prepare stmt from "(select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3);"; +execute stmt; +a b +2 2 +2 2 +execute stmt; +a b +2 2 +2 2 +prepare stmt from "select * from ((select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3)) a"; +execute stmt; +a b +2 2 +2 2 +execute stmt; +a b +2 2 +2 2 +insert into t1 values (2,2),(3,3); +insert into t2 values (2,2),(2,2),(2,2); +(select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3); +a b +2 2 +2 2 +(select a,b from t1) intersect (select c,d from t2) intersect all (select e,f from t3); +a b +2 2 +insert into t3 values (2,2); +(select a,b from t1) intersect all (select c,d from t2) intersect (select e,f from t3); +a b +2 2 +(select a,b from t1) intersect all (select c,e from t2,t3); +a b +2 2 +2 2 +2 2 +EXPLAIN (select a,b from t1) intersect all (select c,e from t2,t3); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 +2 INTERSECT t3 ALL NULL NULL NULL NULL 5 +2 INTERSECT t2 ALL NULL NULL NULL NULL 7 Using join buffer (flat, BNL join) +NULL INTERSECT RESULT <intersect1,2> ALL NULL NULL NULL NULL NULL +EXPLAIN extended (select a,b from t1) intersect all (select c,e from t2,t3); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 +2 INTERSECT t3 ALL NULL NULL NULL NULL 5 100.00 +2 INTERSECT t2 ALL NULL NULL NULL NULL 7 100.00 Using join buffer (flat, BNL join) +NULL INTERSECT RESULT <intersect1,2> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 (/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) intersect all (/* select#2 */ select `test`.`t2`.`c` AS `c`,`test`.`t3`.`e` AS `e` from `test`.`t2` join `test`.`t3`) +EXPLAIN extended select * from ((select a,b from t1) intersect all (select c,e from t2,t3)) a; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6 100.00 +2 DERIVED t1 ALL NULL NULL NULL NULL 6 100.00 +3 INTERSECT t3 ALL NULL NULL NULL NULL 5 100.00 +3 INTERSECT t2 ALL NULL NULL NULL NULL 7 100.00 Using join buffer (flat, BNL join) +NULL INTERSECT RESULT <intersect2,3> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `a`.`a` AS `a`,`a`.`b` AS `b` from ((/* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) intersect all (/* select#3 */ select `test`.`t2`.`c` AS `c`,`test`.`t3`.`e` AS `e` from `test`.`t2` join `test`.`t3`)) `a` +EXPLAIN format=json (select a,b from t1) intersect all (select c,e from t2,t3); +EXPLAIN +{ + "query_block": { + "union_result": { + "table_name": "<intersect1,2>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 1, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 6, + "filtered": 100 + } + } + }, + { + "query_block": { + "select_id": 2, + "operation": "INTERSECT", + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + }, + "block-nl-join": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 7, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "65", + "join_type": "BNL" + } + } + } + ] + } + } +} +ANALYZE format=json (select a,b from t1) intersect all (select c,e from t2,t3); +ANALYZE +{ + "query_block": { + "union_result": { + "table_name": "<intersect1,2>", + "access_type": "ALL", + "r_loops": 1, + "r_rows": 3, + "query_specifications": [ + { + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 6, + "r_rows": 6, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + }, + { + "query_block": { + "select_id": 2, + "operation": "INTERSECT", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "t3", + "access_type": "ALL", + "r_loops": 1, + "rows": 5, + "r_rows": 5, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + }, + "block-nl-join": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "r_loops": 1, + "rows": 7, + "r_rows": 7, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "65", + "join_type": "BNL", + "r_filtered": 100 + } + } + } + ] + } + } +} +ANALYZE format=json select * from ((select a,b from t1) intersect all (select c,e from t2,t3)) a; +ANALYZE +{ + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "r_loops": 1, + "rows": 6, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "materialized": { + "query_block": { + "union_result": { + "table_name": "<intersect2,3>", + "access_type": "ALL", + "r_loops": 1, + "r_rows": 3, + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 6, + "r_rows": 6, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + }, + { + "query_block": { + "select_id": 3, + "operation": "INTERSECT", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "t3", + "access_type": "ALL", + "r_loops": 1, + "rows": 5, + "r_rows": 5, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + }, + "block-nl-join": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "r_loops": 1, + "rows": 7, + "r_rows": 7, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "65", + "join_type": "BNL", + "r_filtered": 100 + } + } + } + ] + } + } + } + } + } +} +select * from ((select a,b from t1) intersect all (select c,e from t2,t3)) a; +a b +2 2 +2 2 +2 2 +prepare stmt from "(select a,b from t1) intersect all (select c,e from t2,t3);"; +execute stmt; +a b +2 2 +2 2 +2 2 +execute stmt; +a b +2 2 +2 2 +2 2 +prepare stmt from "select * from ((select a,b from t1) intersect all (select c,e from t2,t3)) a"; +execute stmt; +a b +2 2 +2 2 +2 2 +execute stmt; +a b +2 2 +2 2 +2 2 +drop tables t1,t2,t3; +select 1 as a from dual intersect all select 1 from dual; +a +1 +(select 1 from dual) intersect all (select 1 from dual); +1 +1 +(select 1 from dual into @v) intersect all (select 1 from dual); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'into @v) intersect all (select 1 from dual)' at line 1 +select 1 from dual ORDER BY 1 intersect all select 1 from dual; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'intersect all select 1 from dual' at line 1 +select 1 as a from dual union all select 1 from dual; +a +1 +1 +create table t1 (a int, b blob, a1 int, b1 blob); +create table t2 (c int, d blob, c1 int, d1 blob); +insert into t1 values (1,"ddd", 1, "sdfrrwwww"),(2, "fgh", 2, "dffggtt"),(2, "fgh", 2, "dffggtt"); +insert into t2 values (2, "fgh", 2, "dffggtt"),(3, "ffggddd", 3, "dfgg"),(2, "fgh", 2, "dffggtt"); +(select a,b,b1 from t1) intersect all (select c,d,d1 from t2); +a b b1 +2 fgh dffggtt +2 fgh dffggtt +drop tables t1,t2; +create table t1 (a int, b blob) engine=MyISAM; +create table t2 (c int, d blob) engine=MyISAM; +create table t3 (e int, f blob) engine=MyISAM; +insert into t1 values (1,1),(2,2),(3,3),(2,2),(3,3); +insert into t2 values (2,2),(3,3),(4,4),(2,2),(2,2),(2,2); +insert into t3 values (1,1),(2,2),(5,5),(2,2),(5,5); +(select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3); +a b +2 2 +2 2 +select * from ((select a,b from t1) intersect all (select c,d from t2) intersect (select e,f from t3)) a; +a b +2 2 +prepare stmt from "(select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3);"; +execute stmt; +a b +2 2 +2 2 +execute stmt; +a b +2 2 +2 2 +prepare stmt from "select * from ((select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3)) a"; +execute stmt; +a b +2 2 +2 2 +execute stmt; +a b +2 2 +2 2 +create table t4 (select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3); +show create table t4; +Table Create Table +t4 CREATE TABLE `t4` ( + `a` int(11) DEFAULT NULL, + `b` blob DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop tables t4; +(select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3) union all (select 4,4); +a b +4 4 +2 2 +2 2 +(select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3) union all (select 4,4) except all (select 2,2); +a b +4 4 +2 2 +drop tables t1,t2,t3; +create table t1 (a int, b int); +create table t2 (c int, d int); +create table t3 (e int, f int); +insert into t1 values (1,1),(2,2),(3,3),(2,2),(3,3); +insert into t2 values (2,2),(3,3),(4,4),(2,2),(2,2),(2,2); +insert into t3 values (1,1),(2,2),(5,5),(2,2),(5,5); +(select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3) union all (select 4,4); +a b +4 4 +2 2 +2 2 +(select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3) union all (select 4,4) except all (select 2,2); +a b +4 4 +2 2 +drop tables t1,t2,t3; +# +# INTERSECT precedence +# +create table t1 (a int, b blob) engine=MyISAM; +create table t2 (c int, d blob) engine=MyISAM; +create table t3 (e int, f blob) engine=MyISAM; +insert into t1 values (5,5),(6,6); +insert into t2 values (2,2),(3,3); +insert into t3 values (1,1),(3,3); +(select a,b from t1) union all (select c,d from t2) intersect (select e,f from t3) union all (select 4,4); +a b +5 5 +6 6 +3 3 +4 4 +(select a,b from t1) union all (select c,d from t2) intersect all (select e,f from t3) union all (select 4,4); +a b +5 5 +6 6 +3 3 +4 4 +explain extended (select a,b from t1) union all (select c,d from t2) intersect all (select e,f from t3) union all (select 4,4); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 +5 UNION <derived2> ALL NULL NULL NULL NULL 2 100.00 +2 DERIVED t2 ALL NULL NULL NULL NULL 2 100.00 +3 INTERSECT t3 ALL NULL NULL NULL NULL 2 100.00 +NULL INTERSECT RESULT <intersect2,3> ALL NULL NULL NULL NULL NULL NULL +4 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 (/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) union all /* select#5 */ select `__5`.`c` AS `c`,`__5`.`d` AS `d` from ((/* select#2 */ select `test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2`) intersect all (/* select#3 */ select `test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t3`)) `__5` union all (/* select#4 */ select 4 AS `4`,4 AS `4`) +insert into t2 values (3,3); +insert into t3 values (3,3); +(select e,f from t3) intersect all (select c,d from t2) union all (select a,b from t1) union all (select 4,4); +e f +3 3 +3 3 +5 5 +6 6 +4 4 +explain extended (select e,f from t3) intersect all (select c,d from t2) union all (select a,b from t1) union all (select 4,4); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 +2 INTERSECT t2 ALL NULL NULL NULL NULL 3 100.00 +3 UNION t1 ALL NULL NULL NULL NULL 2 100.00 +4 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNIT RESULT <unit1,2,3,4> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 (/* select#1 */ select `test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t3`) intersect all (/* select#2 */ select `test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2`) union all (/* select#3 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) union all (/* select#4 */ select 4 AS `4`,4 AS `4`) +(/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) union /* select#3 */ select `__3`.`c` AS `c`,`__3`.`d` AS `d` from ((/* select#2 */ select `test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2`) intersect all (/* select#4 */ select `test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t3`)) `__3` union (/* select#5 */ select 4 AS `4`,4 AS `4`); +a b +5 5 +6 6 +3 3 +4 4 +prepare stmt from "(select a,b from t1) union all (select c,d from t2) intersect all (select e,f from t3) union all (select 4,4)"; +execute stmt; +a b +5 5 +6 6 +3 3 +3 3 +4 4 +execute stmt; +a b +5 5 +6 6 +3 3 +3 3 +4 4 +create view v1 as (select a,b from t1) union all (select c,d from t2) intersect all (select e,f from t3) union all (select 4,4); +select b,a,b+1 from v1; +b a b+1 +5 5 6 +6 6 7 +3 3 4 +3 3 4 +4 4 5 +select b,a,b+1 from v1 where a > 3; +b a b+1 +5 5 6 +6 6 7 +4 4 5 +create procedure p1() +select * from v1; +call p1(); +a b +5 5 +6 6 +3 3 +3 3 +4 4 +call p1(); +a b +5 5 +6 6 +3 3 +3 3 +4 4 +drop procedure p1; +create procedure p1() +(select a,b from t1) union all (select c,d from t2) intersect all (select e,f from t3) union all (select 4,4); +call p1(); +a b +5 5 +6 6 +3 3 +3 3 +4 4 +call p1(); +a b +5 5 +6 6 +3 3 +3 3 +4 4 +drop procedure p1; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS (select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) union all select `__6`.`c` AS `c`,`__6`.`d` AS `d` from ((select `test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2`) intersect all (select `test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t3`)) `__6` union all (select 4 AS `4`,4 AS `4`) latin1 latin1_swedish_ci +drop view v1; +drop tables t1,t2,t3; +CREATE TABLE t (i INT); +INSERT INTO t VALUES (1),(2); +SELECT * FROM t WHERE i != ANY ( SELECT 6 INTERSECT ALL SELECT 3 ); +i +select i from t where +exists ((select 6 as r from dual having t.i <> 6) +intersect all +(select 3 from dual having t.i <> 3)); +i +drop table t; +CREATE TABLE t1 (a varchar(32)) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('Jakarta'),('Lisbon'),('Honolulu'),('Lusaka'),('Barcelona'),('Taipei'), +('Brussels'),('Orlando'),('Osaka'),('Quito'),('Lima'),('Tunis'), +('Unalaska'),('Rotterdam'),('Zagreb'),('Ufa'),('Ryazan'),('Xiamen'), +('London'),('Izmir'),('Samara'),('Bern'),('Zhengzhou'),('Vladivostok'), +('Yangon'),('Victoria'),('Warsaw'),('Luanda'),('Leon'),('Bangkok'), +('Wellington'),('Zibo'),('Qiqihar'),('Delhi'),('Hamburg'),('Ottawa'), +('Vaduz'); +CREATE TABLE t2 (b varchar(32)) ENGINE=MyISAM; +INSERT INTO t2 VALUES +('Gaza'),('Jeddah'),('Beirut'),('Incheon'),('Tbilisi'),('Izmir'), +('Quito'),('Riga'),('Freetown'),('Zagreb'),('Caracas'),('Orlando'), +('Kingston'),('Turin'),('Xinyang'),('Osaka'),('Albany'),('Geneva'), +('Omsk'),('Kazan'),('Quezon'),('Indore'),('Odessa'),('Xiamen'), +('Winnipeg'),('Yakutsk'),('Nairobi'),('Ufa'),('Helsinki'),('Vilnius'), +('Aden'),('Liverpool'),('Honolulu'),('Frankfurt'),('Glasgow'), +('Vienna'),('Jackson'),('Jakarta'),('Sydney'),('Oslo'),('Novgorod'), +('Norilsk'),('Izhevsk'),('Istanbul'),('Nice'); +CREATE TABLE t3 (c varchar(32)) ENGINE=MyISAM; +INSERT INTO t3 VALUES +('Nicosia'),('Istanbul'),('Richmond'),('Stockholm'),('Dublin'), +('Wichita'),('Warsaw'),('Glasgow'),('Winnipeg'),('Irkutsk'),('Quito'), +('Xiamen'),('Berlin'),('Rome'),('Denver'),('Dallas'),('Kabul'), +('Prague'),('Izhevsk'),('Tirana'),('Sofia'),('Detroit'),('Sorbonne'); +select count(*) from ( +SELECT * FROM t1 LEFT OUTER JOIN t2 LEFT OUTER JOIN t3 ON b < c ON a > b +INTERSECT +SELECT * FROM t1 LEFT OUTER JOIN t2 LEFT OUTER JOIN t3 ON b < c ON a > b +) a; +count(*) +14848 +select count(*) from ( +SELECT * FROM t1 LEFT OUTER JOIN t2 LEFT OUTER JOIN t3 ON b < c ON a > b +INTERSECT ALL +SELECT * FROM t1 LEFT OUTER JOIN t2 LEFT OUTER JOIN t3 ON b < c ON a > b +) a; +count(*) +14848 +insert into t1 values ('Xiamen'); +insert into t2 values ('Xiamen'),('Xiamen'); +insert into t3 values ('Xiamen'); +select count(*) from ( +SELECT * FROM t1 LEFT OUTER JOIN t2 LEFT OUTER JOIN t3 ON b < c ON a > b +INTERSECT ALL +SELECT * FROM t1 LEFT OUTER JOIN t2 LEFT OUTER JOIN t3 ON b < c ON a > b +) a; +count(*) +16430 +drop table t1,t2,t3; +CREATE TABLE t1 (a varchar(32) not null) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('Jakarta'),('Lisbon'),('Honolulu'),('Lusaka'),('Barcelona'),('Taipei'), +('Brussels'),('Orlando'),('Osaka'),('Quito'),('Lima'),('Tunis'), +('Unalaska'),('Rotterdam'),('Zagreb'),('Ufa'),('Ryazan'),('Xiamen'), +('London'),('Izmir'),('Samara'),('Bern'),('Zhengzhou'),('Vladivostok'), +('Yangon'),('Victoria'),('Warsaw'),('Luanda'),('Leon'),('Bangkok'), +('Wellington'),('Zibo'),('Qiqihar'),('Delhi'),('Hamburg'),('Ottawa'), +('Vaduz'),('Detroit'),('Detroit'); +CREATE TABLE t2 (b varchar(32) not null) ENGINE=MyISAM; +INSERT INTO t2 VALUES +('Gaza'),('Jeddah'),('Beirut'),('Incheon'),('Tbilisi'),('Izmir'), +('Quito'),('Riga'),('Freetown'),('Zagreb'),('Caracas'),('Orlando'), +('Kingston'),('Turin'),('Xinyang'),('Osaka'),('Albany'),('Geneva'), +('Omsk'),('Kazan'),('Quezon'),('Indore'),('Odessa'),('Xiamen'), +('Winnipeg'),('Yakutsk'),('Nairobi'),('Ufa'),('Helsinki'),('Vilnius'), +('Aden'),('Liverpool'),('Honolulu'),('Frankfurt'),('Glasgow'), +('Vienna'),('Jackson'),('Jakarta'),('Sydney'),('Oslo'),('Novgorod'), +('Norilsk'),('Izhevsk'),('Istanbul'),('Nice'),('Detroit'),('Detroit'); +CREATE TABLE t3 (c varchar(32) not null) ENGINE=MyISAM; +INSERT INTO t3 VALUES +('Nicosia'),('Istanbul'),('Richmond'),('Stockholm'),('Dublin'), +('Wichita'),('Warsaw'),('Glasgow'),('Winnipeg'),('Irkutsk'),('Quito'), +('Xiamen'),('Berlin'),('Rome'),('Denver'),('Dallas'),('Kabul'), +('Prague'),('Izhevsk'),('Tirana'),('Sofia'),('Detroit'),('Sorbonne'), +('Detroit'); +select count(*) from ( +SELECT * FROM t1 LEFT OUTER JOIN t2 LEFT OUTER JOIN t3 ON b < c ON a > b +INTERSECT +SELECT * FROM t1 LEFT OUTER JOIN t2 LEFT OUTER JOIN t3 ON b < c ON a > b +) a; +count(*) +15547 +drop table t1,t2,t3; +create table t12(c1 int); +insert into t12 values(1); +insert into t12 values(2); +create table t13(c1 int); +insert into t13 values(1); +insert into t13 values(3); +create table t234(c1 int); +insert into t234 values(2); +insert into t234 values(3); +insert into t234 values(4); +select * from t13 union select * from t234 intersect all select * from t12; +c1 +1 +3 +2 +drop table t12,t13,t234; +create table t1 (a int); +insert into t1 values (3), (1), (7), (3), (2), (7), (4); +create table t2 (a int); +insert into t2 values (4), (5), (9), (1), (8), (9), (2), (2); +create table t3 (a int); +insert into t3 values (8), (1), (8), (2), (3), (7), (2); +select * from t1 where a > 4 +union all +select * from t2 where a < 5 +intersect all +select * from t3 where a < 5; +a +7 +7 +2 +1 +2 +explain extended +select * from t1 where a > 4 +union all +select * from t2 where a < 5 +intersect all +select * from t3 where a < 5; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 7 100.00 Using where +4 UNION <derived2> ALL NULL NULL NULL NULL 7 100.00 +2 DERIVED t2 ALL NULL NULL NULL NULL 8 100.00 Using where +3 INTERSECT t3 ALL NULL NULL NULL NULL 7 100.00 Using where +NULL INTERSECT RESULT <intersect2,3> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` > 4 union all /* select#4 */ select `__4`.`a` AS `a` from (/* select#2 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where `test`.`t2`.`a` < 5 intersect all /* select#3 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` where `test`.`t3`.`a` < 5) `__4` +drop table t1,t2,t3; diff --git a/mysql-test/main/intersect_all.test b/mysql-test/main/intersect_all.test new file mode 100644 index 00000000000..5d2b038fde9 --- /dev/null +++ b/mysql-test/main/intersect_all.test @@ -0,0 +1,328 @@ +create table t1 (a int, b int) engine=MyISAM; +create table t2 (c int, d int) engine=MyISAM; +insert into t1 values (1,1),(2,2),(3,3),(2,2); +insert into t2 values (2,2),(2,2),(5,5); + +select * from t1 intersect all select * from t2; +(select a,b from t1) intersect all (select c,d from t2); +select * from ((select a,b from t1) intersect all (select c,d from t2)) t; +select * from ((select a from t1) intersect all (select c from t2)) t; + +drop tables t1,t2; + +create table t1 (a int, b int) engine=MyISAM; +create table t2 (c int, d int) engine=MyISAM; +create table t3 (e int, f int) engine=MyISAM; +insert into t1 values (1,1),(2,2),(3,3),(2,2); +insert into t2 values (2,2),(3,3),(4,4),(2,2); +insert into t3 values (1,1),(2,2),(5,5),(2,2); + +(select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3); + +EXPLAIN (select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3); +EXPLAIN extended (select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3); +EXPLAIN extended select * from ((select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3)) a; +EXPLAIN format=json (select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3); +--source include/analyze-format.inc +ANALYZE format=json (select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3); +--source include/analyze-format.inc +ANALYZE format=json select * from ((select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3)) a; +select * from ((select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3)) a; + +prepare stmt from "(select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3);"; +execute stmt; +execute stmt; + +prepare stmt from "select * from ((select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3)) a"; +execute stmt; +execute stmt; + +insert into t1 values (2,2),(3,3); +insert into t2 values (2,2),(2,2),(2,2); +(select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3); +(select a,b from t1) intersect (select c,d from t2) intersect all (select e,f from t3); + +insert into t3 values (2,2); +(select a,b from t1) intersect all (select c,d from t2) intersect (select e,f from t3); + +(select a,b from t1) intersect all (select c,e from t2,t3); + +EXPLAIN (select a,b from t1) intersect all (select c,e from t2,t3); +EXPLAIN extended (select a,b from t1) intersect all (select c,e from t2,t3); +EXPLAIN extended select * from ((select a,b from t1) intersect all (select c,e from t2,t3)) a; +EXPLAIN format=json (select a,b from t1) intersect all (select c,e from t2,t3); +--source include/analyze-format.inc +ANALYZE format=json (select a,b from t1) intersect all (select c,e from t2,t3); +--source include/analyze-format.inc +ANALYZE format=json select * from ((select a,b from t1) intersect all (select c,e from t2,t3)) a; +select * from ((select a,b from t1) intersect all (select c,e from t2,t3)) a; + +prepare stmt from "(select a,b from t1) intersect all (select c,e from t2,t3);"; +execute stmt; +execute stmt; + +prepare stmt from "select * from ((select a,b from t1) intersect all (select c,e from t2,t3)) a"; +execute stmt; +execute stmt; + +drop tables t1,t2,t3; + +select 1 as a from dual intersect all select 1 from dual; +(select 1 from dual) intersect all (select 1 from dual); +--error ER_PARSE_ERROR +(select 1 from dual into @v) intersect all (select 1 from dual); +--error ER_PARSE_ERROR +select 1 from dual ORDER BY 1 intersect all select 1 from dual; +select 1 as a from dual union all select 1 from dual; + +create table t1 (a int, b blob, a1 int, b1 blob); +create table t2 (c int, d blob, c1 int, d1 blob); +insert into t1 values (1,"ddd", 1, "sdfrrwwww"),(2, "fgh", 2, "dffggtt"),(2, "fgh", 2, "dffggtt"); +insert into t2 values (2, "fgh", 2, "dffggtt"),(3, "ffggddd", 3, "dfgg"),(2, "fgh", 2, "dffggtt"); + +(select a,b,b1 from t1) intersect all (select c,d,d1 from t2); + +drop tables t1,t2; + +create table t1 (a int, b blob) engine=MyISAM; +create table t2 (c int, d blob) engine=MyISAM; +create table t3 (e int, f blob) engine=MyISAM; +insert into t1 values (1,1),(2,2),(3,3),(2,2),(3,3); +insert into t2 values (2,2),(3,3),(4,4),(2,2),(2,2),(2,2); +insert into t3 values (1,1),(2,2),(5,5),(2,2),(5,5); + +(select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3); +select * from ((select a,b from t1) intersect all (select c,d from t2) intersect (select e,f from t3)) a; + +prepare stmt from "(select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3);"; +execute stmt; +execute stmt; + +prepare stmt from "select * from ((select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3)) a"; +execute stmt; +execute stmt; + +# make sure that blob is used +create table t4 (select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3); +show create table t4; +drop tables t4; + + +(select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3) union all (select 4,4); + +(select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3) union all (select 4,4) except all (select 2,2); + +drop tables t1,t2,t3; + +create table t1 (a int, b int); +create table t2 (c int, d int); +create table t3 (e int, f int); +insert into t1 values (1,1),(2,2),(3,3),(2,2),(3,3); +insert into t2 values (2,2),(3,3),(4,4),(2,2),(2,2),(2,2); +insert into t3 values (1,1),(2,2),(5,5),(2,2),(5,5); + + +(select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3) union all (select 4,4); + +(select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3) union all (select 4,4) except all (select 2,2); + +drop tables t1,t2,t3; + +--echo # +--echo # INTERSECT precedence +--echo # +create table t1 (a int, b blob) engine=MyISAM; +create table t2 (c int, d blob) engine=MyISAM; +create table t3 (e int, f blob) engine=MyISAM; +insert into t1 values (5,5),(6,6); +insert into t2 values (2,2),(3,3); +insert into t3 values (1,1),(3,3); + + + +(select a,b from t1) union all (select c,d from t2) intersect (select e,f from t3) union all (select 4,4); + +(select a,b from t1) union all (select c,d from t2) intersect all (select e,f from t3) union all (select 4,4); +explain extended (select a,b from t1) union all (select c,d from t2) intersect all (select e,f from t3) union all (select 4,4); + +# test result of linear mix operation +insert into t2 values (3,3); +insert into t3 values (3,3); + +(select e,f from t3) intersect all (select c,d from t2) union all (select a,b from t1) union all (select 4,4); +explain extended (select e,f from t3) intersect all (select c,d from t2) union all (select a,b from t1) union all (select 4,4); + + +(/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) union /* select#3 */ select `__3`.`c` AS `c`,`__3`.`d` AS `d` from ((/* select#2 */ select `test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2`) intersect all (/* select#4 */ select `test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t3`)) `__3` union (/* select#5 */ select 4 AS `4`,4 AS `4`); + +prepare stmt from "(select a,b from t1) union all (select c,d from t2) intersect all (select e,f from t3) union all (select 4,4)"; + +execute stmt; + +execute stmt; + +create view v1 as (select a,b from t1) union all (select c,d from t2) intersect all (select e,f from t3) union all (select 4,4); + + +select b,a,b+1 from v1; + +select b,a,b+1 from v1 where a > 3; + +create procedure p1() + select * from v1; + +call p1(); + +call p1(); +drop procedure p1; + +create procedure p1() + (select a,b from t1) union all (select c,d from t2) intersect all (select e,f from t3) union all (select 4,4); + +call p1(); + +call p1(); +drop procedure p1; + +show create view v1; + +drop view v1; +drop tables t1,t2,t3; + +CREATE TABLE t (i INT); +INSERT INTO t VALUES (1),(2); +SELECT * FROM t WHERE i != ANY ( SELECT 6 INTERSECT ALL SELECT 3 ); + +select i from t where + exists ((select 6 as r from dual having t.i <> 6) + intersect all + (select 3 from dual having t.i <> 3)); + +drop table t; + +CREATE TABLE t1 (a varchar(32)) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('Jakarta'),('Lisbon'),('Honolulu'),('Lusaka'),('Barcelona'),('Taipei'), +('Brussels'),('Orlando'),('Osaka'),('Quito'),('Lima'),('Tunis'), +('Unalaska'),('Rotterdam'),('Zagreb'),('Ufa'),('Ryazan'),('Xiamen'), +('London'),('Izmir'),('Samara'),('Bern'),('Zhengzhou'),('Vladivostok'), +('Yangon'),('Victoria'),('Warsaw'),('Luanda'),('Leon'),('Bangkok'), +('Wellington'),('Zibo'),('Qiqihar'),('Delhi'),('Hamburg'),('Ottawa'), +('Vaduz'); + +CREATE TABLE t2 (b varchar(32)) ENGINE=MyISAM; +INSERT INTO t2 VALUES +('Gaza'),('Jeddah'),('Beirut'),('Incheon'),('Tbilisi'),('Izmir'), +('Quito'),('Riga'),('Freetown'),('Zagreb'),('Caracas'),('Orlando'), +('Kingston'),('Turin'),('Xinyang'),('Osaka'),('Albany'),('Geneva'), +('Omsk'),('Kazan'),('Quezon'),('Indore'),('Odessa'),('Xiamen'), +('Winnipeg'),('Yakutsk'),('Nairobi'),('Ufa'),('Helsinki'),('Vilnius'), +('Aden'),('Liverpool'),('Honolulu'),('Frankfurt'),('Glasgow'), +('Vienna'),('Jackson'),('Jakarta'),('Sydney'),('Oslo'),('Novgorod'), +('Norilsk'),('Izhevsk'),('Istanbul'),('Nice'); + +CREATE TABLE t3 (c varchar(32)) ENGINE=MyISAM; +INSERT INTO t3 VALUES +('Nicosia'),('Istanbul'),('Richmond'),('Stockholm'),('Dublin'), +('Wichita'),('Warsaw'),('Glasgow'),('Winnipeg'),('Irkutsk'),('Quito'), +('Xiamen'),('Berlin'),('Rome'),('Denver'),('Dallas'),('Kabul'), +('Prague'),('Izhevsk'),('Tirana'),('Sofia'),('Detroit'),('Sorbonne'); + +select count(*) from ( + SELECT * FROM t1 LEFT OUTER JOIN t2 LEFT OUTER JOIN t3 ON b < c ON a > b + INTERSECT + SELECT * FROM t1 LEFT OUTER JOIN t2 LEFT OUTER JOIN t3 ON b < c ON a > b +) a; + +select count(*) from ( + SELECT * FROM t1 LEFT OUTER JOIN t2 LEFT OUTER JOIN t3 ON b < c ON a > b + INTERSECT ALL + SELECT * FROM t1 LEFT OUTER JOIN t2 LEFT OUTER JOIN t3 ON b < c ON a > b +) a; + +insert into t1 values ('Xiamen'); +insert into t2 values ('Xiamen'),('Xiamen'); +insert into t3 values ('Xiamen'); +select count(*) from ( + SELECT * FROM t1 LEFT OUTER JOIN t2 LEFT OUTER JOIN t3 ON b < c ON a > b + INTERSECT ALL + SELECT * FROM t1 LEFT OUTER JOIN t2 LEFT OUTER JOIN t3 ON b < c ON a > b +) a; + +drop table t1,t2,t3; + +CREATE TABLE t1 (a varchar(32) not null) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('Jakarta'),('Lisbon'),('Honolulu'),('Lusaka'),('Barcelona'),('Taipei'), +('Brussels'),('Orlando'),('Osaka'),('Quito'),('Lima'),('Tunis'), +('Unalaska'),('Rotterdam'),('Zagreb'),('Ufa'),('Ryazan'),('Xiamen'), +('London'),('Izmir'),('Samara'),('Bern'),('Zhengzhou'),('Vladivostok'), +('Yangon'),('Victoria'),('Warsaw'),('Luanda'),('Leon'),('Bangkok'), +('Wellington'),('Zibo'),('Qiqihar'),('Delhi'),('Hamburg'),('Ottawa'), +('Vaduz'),('Detroit'),('Detroit'); + +CREATE TABLE t2 (b varchar(32) not null) ENGINE=MyISAM; +INSERT INTO t2 VALUES +('Gaza'),('Jeddah'),('Beirut'),('Incheon'),('Tbilisi'),('Izmir'), +('Quito'),('Riga'),('Freetown'),('Zagreb'),('Caracas'),('Orlando'), +('Kingston'),('Turin'),('Xinyang'),('Osaka'),('Albany'),('Geneva'), +('Omsk'),('Kazan'),('Quezon'),('Indore'),('Odessa'),('Xiamen'), +('Winnipeg'),('Yakutsk'),('Nairobi'),('Ufa'),('Helsinki'),('Vilnius'), +('Aden'),('Liverpool'),('Honolulu'),('Frankfurt'),('Glasgow'), +('Vienna'),('Jackson'),('Jakarta'),('Sydney'),('Oslo'),('Novgorod'), +('Norilsk'),('Izhevsk'),('Istanbul'),('Nice'),('Detroit'),('Detroit'); + +CREATE TABLE t3 (c varchar(32) not null) ENGINE=MyISAM; +INSERT INTO t3 VALUES +('Nicosia'),('Istanbul'),('Richmond'),('Stockholm'),('Dublin'), +('Wichita'),('Warsaw'),('Glasgow'),('Winnipeg'),('Irkutsk'),('Quito'), +('Xiamen'),('Berlin'),('Rome'),('Denver'),('Dallas'),('Kabul'), +('Prague'),('Izhevsk'),('Tirana'),('Sofia'),('Detroit'),('Sorbonne'), +('Detroit'); + +select count(*) from ( + SELECT * FROM t1 LEFT OUTER JOIN t2 LEFT OUTER JOIN t3 ON b < c ON a > b + INTERSECT + SELECT * FROM t1 LEFT OUTER JOIN t2 LEFT OUTER JOIN t3 ON b < c ON a > b +) a; + +drop table t1,t2,t3; + +create table t12(c1 int); +insert into t12 values(1); +insert into t12 values(2); +create table t13(c1 int); +insert into t13 values(1); +insert into t13 values(3); +create table t234(c1 int); +insert into t234 values(2); +insert into t234 values(3); +insert into t234 values(4); + + +select * from t13 union select * from t234 intersect all select * from t12; + +drop table t12,t13,t234; + +create table t1 (a int); +insert into t1 values (3), (1), (7), (3), (2), (7), (4); +create table t2 (a int); +insert into t2 values (4), (5), (9), (1), (8), (9), (2), (2); +create table t3 (a int); +insert into t3 values (8), (1), (8), (2), (3), (7), (2); + + +select * from t1 where a > 4 +union all +select * from t2 where a < 5 +intersect all +select * from t3 where a < 5; + +explain extended +select * from t1 where a > 4 +union all +select * from t2 where a < 5 +intersect all +select * from t3 where a < 5; + +drop table t1,t2,t3;
\ No newline at end of file diff --git a/mysql-test/main/join.result b/mysql-test/main/join.result index 9bccf358fb7..d8eb9795b4e 100644 --- a/mysql-test/main/join.result +++ b/mysql-test/main/join.result @@ -1473,8 +1473,8 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE DU system dog_id NULL NULL NULL 1 1 SIMPLE D system PRIMARY NULL NULL NULL 1 1 SIMPLE DSAR system NULL NULL NULL NULL 1 -1 SIMPLE DT range t_id t_id 2 NULL 2 Using where -1 SIMPLE DSA ref PRIMARY PRIMARY 8 const,test.DT.t_id,func 1 Using index +1 SIMPLE DSA ref PRIMARY PRIMARY 4 const 3 Using where; Using index +1 SIMPLE DT ALL t_id NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) SELECT * FROM t5 DU, t1 D, t4 DT, t2 DSA, t3 DSAR WHERE DU.dog_id=D.dog_id AND D.dog_id=DT.dog_id AND D.birthday=DT.birthday AND DT.t_id=DSA.t_id AND DT.birthday=DSA.birthday AND DSA.dog_id=DSAR.dog_id; diff --git a/mysql-test/main/join_cache.result b/mysql-test/main/join_cache.result index e8fe3a10b18..79c5b7923bd 100644 --- a/mysql-test/main/join_cache.result +++ b/mysql-test/main/join_cache.result @@ -5060,8 +5060,8 @@ EXPLAIN SELECT * FROM t1,t2 WHERE t1.f1 = t2.f4 AND (t1.f3 = 1 AND t2.f3 = 4 OR t1.f3 = 2 AND t2.f3 = 6); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 2 Using where -1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where; Rowid-ordered scan +1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using where; Rowid-ordered scan; Using join buffer (flat, BNL join) SELECT * FROM t1,t2 WHERE t1.f1 = t2.f4 AND (t1.f3 = 1 AND t2.f3 = 4 OR t1.f3 = 2 AND t2.f3 = 6); f1 f3 f3 f2 f4 @@ -5070,8 +5070,8 @@ EXPLAIN SELECT * FROM t1,t2 WHERE t1.f1 = t2.f4 AND (t1.f3 = 1 AND t2.f3 = 4 OR t1.f3 = 2 AND t2.f3 = 6); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 2 Using where -1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Rowid-ordered scan +1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; Rowid-ordered scan; Using join buffer (flat, BNL join) SELECT * FROM t1,t2 WHERE t1.f1 = t2.f4 AND (t1.f3 = 1 AND t2.f3 = 4 OR t1.f3 = 2 AND t2.f3 = 6); f1 f3 f3 f2 f4 @@ -6197,7 +6197,7 @@ EXPLAIN "select_id": 1, "table": { "table_name": "a", - "access_type": "index", + "access_type": "range", "possible_keys": ["PRIMARY"], "key": "PRIMARY", "key_length": "4", @@ -6216,7 +6216,7 @@ EXPLAIN "key_length": "10", "used_key_parts": ["kp1", "kp2"], "rows": 836, - "filtered": 76.434, + "filtered": 76.43428802, "index_condition": "b.kp2 <= 10", "attached_condition": "b.kp2 <= 10 and b.col1 + 1 < 33333" }, diff --git a/mysql-test/main/join_nested.result b/mysql-test/main/join_nested.result index 4f6583b6fbc..b323190d8d5 100644 --- a/mysql-test/main/join_nested.result +++ b/mysql-test/main/join_nested.result @@ -1284,9 +1284,9 @@ NULL 2 2 DELETE FROM t3; EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 const c NULL NULL NULL 1 Impossible ON condition +1 SIMPLE t2 const b NULL NULL NULL 1 Impossible ON condition 1 SIMPLE t1 index NULL a 5 NULL 21 Using index -1 SIMPLE t3 index c c 5 NULL 0 Using where; Using index -1 SIMPLE t2 ref b b 5 test.t3.c 2 Using index SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; a b c NULL NULL NULL diff --git a/mysql-test/main/join_nested_jcl6.result b/mysql-test/main/join_nested_jcl6.result index 3293f20aa17..f7d0242244d 100644 --- a/mysql-test/main/join_nested_jcl6.result +++ b/mysql-test/main/join_nested_jcl6.result @@ -1293,9 +1293,9 @@ NULL 2 2 DELETE FROM t3; EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 const c NULL NULL NULL 1 Impossible ON condition +1 SIMPLE t2 const b NULL NULL NULL 1 Impossible ON condition 1 SIMPLE t1 index NULL a 5 NULL 21 Using index -1 SIMPLE t3 index c c 5 NULL 0 Using where; Using index -1 SIMPLE t2 ref b b 5 test.t3.c 2 Using index SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; a b c NULL NULL NULL @@ -2034,7 +2034,7 @@ ON t6.b >= 2 AND t5.b=t7.b AND id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t5 ALL NULL NULL NULL NULL 3 1 SIMPLE t7 ref|filter PRIMARY,b_i b_i|PRIMARY 5|4 test.t5.b 2 (29%) Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan; Using rowid filter -1 SIMPLE t6 range PRIMARY,b_i PRIMARY 4 NULL 3 Using where; Rowid-ordered scan; Using join buffer (incremental, BNL join) +1 SIMPLE t6 range|filter PRIMARY,b_i PRIMARY|b_i 4|5 NULL 3 (86%) Using where; Rowid-ordered scan; Using join buffer (incremental, BNL join); Using rowid filter 1 SIMPLE t8 ref b_i b_i 5 test.t5.b 2 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b FROM t5 diff --git a/mysql-test/main/join_outer.result b/mysql-test/main/join_outer.result index b7fcb55e4fe..fcffeb6d161 100644 --- a/mysql-test/main/join_outer.result +++ b/mysql-test/main/join_outer.result @@ -1740,7 +1740,7 @@ from t1,t2 where t2.pk=t1.pk+1000 and t1.pk>1000 group by t2.pk; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 index PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Using index; Using temporary; Using filesort +1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL 1 100.00 Using where; Using index; Using temporary; Using filesort 1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Using index 2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Using index 2 DEPENDENT SUBQUERY t4 eq_ref PRIMARY PRIMARY 4 test.t3.pk 1 100.00 Using index @@ -2272,11 +2272,11 @@ id select_type table type possible_keys key key_len ref rows Extra explain select * from t1 left join t2 on t2.b is null; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 9 -1 SIMPLE t2 ref b b 5 const 780 Using where +1 SIMPLE t2 ALL b NULL NULL NULL 1000 Using where explain select * from t1 left join t2 on t2.c is null; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 9 -1 SIMPLE t2 ref c c 5 const 393 Using where +1 SIMPLE t2 ALL c NULL NULL NULL 1000 Using where drop table t1,t2; # # MDEV-10006: optimizer doesn't convert outer join to inner on views with WHERE clause diff --git a/mysql-test/main/join_outer_innodb.result b/mysql-test/main/join_outer_innodb.result index a0358094baa..09a37a29702 100644 --- a/mysql-test/main/join_outer_innodb.result +++ b/mysql-test/main/join_outer_innodb.result @@ -8,13 +8,13 @@ EXPLAIN SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id WHERE t1.name LIKE 'A%'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index PRIMARY,name name 23 NULL 3 Using where; Using index +1 SIMPLE t1 range PRIMARY,name name 23 NULL 2 Using where; Using index 1 SIMPLE t2 ref fkey fkey 5 test.t1.id 1 Using index EXPLAIN SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id WHERE t1.name LIKE 'A%' OR FALSE; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index PRIMARY,name name 23 NULL 3 Using where; Using index +1 SIMPLE t1 range PRIMARY,name name 23 NULL 2 Using where; Using index 1 SIMPLE t2 ref fkey fkey 5 test.t1.id 1 Using index DROP TABLE t1,t2; # @@ -433,47 +433,47 @@ left join t16 on t15.o1 = t16.p1 where t1.a10 = 1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL a4,a6,a5,a7 NULL NULL NULL 3 Using where +1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a1 1 Using index +1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.b2 1 Using where; Using index +1 SIMPLE t4 eq_ref PRIMARY PRIMARY 4 test.t1.a2 1 Using index +1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.d1 1 Using where +1 SIMPLE t6 eq_ref PRIMARY PRIMARY 4 test.t1.a3 1 Using where; Using index 1 SIMPLE t8 eq_ref PRIMARY PRIMARY 1 test.t1.a4 1 Using index 1 SIMPLE t7 eq_ref PRIMARY PRIMARY 1 test.t1.a7 1 +1 SIMPLE t9 ref PRIMARY PRIMARY 1 test.t1.a4 1 1 SIMPLE t11 eq_ref PRIMARY PRIMARY 4 test.t1.a5 1 1 SIMPLE t12 eq_ref PRIMARY PRIMARY 4 test.t11.k3 1 Using where 1 SIMPLE l2 eq_ref PRIMARY PRIMARY 4 test.t11.k4 1 Using where -1 SIMPLE t13 ref PRIMARY,m3 PRIMARY 4 test.t1.a1 1 Using where; Using index -1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a1 1 Using index +1 SIMPLE t13 ref PRIMARY,m3 m3 8 const,test.t1.a1 1 Using index 1 SIMPLE l4 eq_ref PRIMARY PRIMARY 4 test.t13.m2 1 Using where; Using index -1 SIMPLE m2 ref PRIMARY,m3 PRIMARY 4 test.t1.a1 1 Using where; Using index -1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.b2 1 Using where; Using index -1 SIMPLE t9 ref PRIMARY PRIMARY 1 test.t1.a4 1 +1 SIMPLE m2 ref PRIMARY,m3 m3 8 const,test.t1.a1 1 Using index 1 SIMPLE l3 eq_ref PRIMARY PRIMARY 4 test.m2.m2 1 Using where -1 SIMPLE t14 ALL PRIMARY NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join) -1 SIMPLE t4 eq_ref PRIMARY PRIMARY 4 test.t1.a2 1 Using index +1 SIMPLE t14 eq_ref PRIMARY PRIMARY 2 test.t1.a8 1 Using where 1 SIMPLE t15 eq_ref PRIMARY PRIMARY 2 test.t1.a9 1 Using where; Using index 1 SIMPLE t16 ref PRIMARY PRIMARY 2 test.t15.o1 1 Using where 1 SIMPLE t10 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) -1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.d1 1 Using where -1 SIMPLE t6 eq_ref PRIMARY PRIMARY 4 test.t1.a3 1 Using where; Using index explain select * from v1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL a4,a6,a5,a7 NULL NULL NULL 3 Using where +1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a1 1 Using index +1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.b2 1 Using where; Using index +1 SIMPLE t4 eq_ref PRIMARY PRIMARY 4 test.t1.a2 1 Using index +1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.d1 1 Using where +1 SIMPLE t6 eq_ref PRIMARY PRIMARY 4 test.t1.a3 1 Using where; Using index 1 SIMPLE t8 eq_ref PRIMARY PRIMARY 1 test.t1.a4 1 Using index 1 SIMPLE t7 eq_ref PRIMARY PRIMARY 1 test.t1.a7 1 +1 SIMPLE t9 ref PRIMARY PRIMARY 1 test.t1.a4 1 1 SIMPLE t11 eq_ref PRIMARY PRIMARY 4 test.t1.a5 1 1 SIMPLE t12 eq_ref PRIMARY PRIMARY 4 test.t11.k3 1 Using where 1 SIMPLE l2 eq_ref PRIMARY PRIMARY 4 test.t11.k4 1 Using where -1 SIMPLE t13 ref PRIMARY,m3 PRIMARY 4 test.t1.a1 1 Using where; Using index -1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a1 1 Using index +1 SIMPLE t13 ref PRIMARY,m3 m3 8 const,test.t1.a1 1 Using index 1 SIMPLE l4 eq_ref PRIMARY PRIMARY 4 test.t13.m2 1 Using where; Using index -1 SIMPLE m2 ref PRIMARY,m3 PRIMARY 4 test.t1.a1 1 Using where; Using index -1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.b2 1 Using where; Using index -1 SIMPLE t9 ref PRIMARY PRIMARY 1 test.t1.a4 1 +1 SIMPLE m2 ref PRIMARY,m3 m3 8 const,test.t1.a1 1 Using index 1 SIMPLE l3 eq_ref PRIMARY PRIMARY 4 test.m2.m2 1 Using where -1 SIMPLE t14 ALL PRIMARY NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join) -1 SIMPLE t4 eq_ref PRIMARY PRIMARY 4 test.t1.a2 1 Using index +1 SIMPLE t14 eq_ref PRIMARY PRIMARY 2 test.t1.a8 1 Using where 1 SIMPLE t15 eq_ref PRIMARY PRIMARY 2 test.t1.a9 1 Using where; Using index 1 SIMPLE t16 ref PRIMARY PRIMARY 2 test.t15.o1 1 Using where 1 SIMPLE t10 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) -1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.d1 1 Using where -1 SIMPLE t6 eq_ref PRIMARY PRIMARY 4 test.t1.a3 1 Using where; Using index drop view v1; drop table t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16; # @@ -481,9 +481,7 @@ drop table t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16; # drop table if exists t1,t2,t3; Warnings: -Note 1051 Unknown table 'test.t1' -Note 1051 Unknown table 'test.t2' -Note 1051 Unknown table 'test.t3' +Note 1051 Unknown table 'test.t1,test.t2,test.t3' create table t2(a int,unique key (a)) engine=innodb; create table t3(b int) engine=innodb; create table t1(c int,b int)engine=innodb; @@ -498,3 +496,22 @@ natural right outer join t3; drop table t1,t2,t3; set optimizer_prune_level=@mdev4270_opl; set optimizer_search_depth=@mdev4270_osd; +# +# Bug #20939184:INNODB: UNLOCK ROW COULD NOT FIND A 2 MODE LOCK ON THE +# RECORD +# +CREATE TABLE t1 (c1 INT, c2 INT, c3 INT, PRIMARY KEY (c1,c2) ) engine=innodb; +CREATE TABLE t2 (c1 INT, c2 INT, c3 INT, PRIMARY KEY (c1), KEY (c2)) engine=innodb; +INSERT INTO t1 VALUES (1,2,3),(2,3,4),(3,4,5); +INSERT INTO t2 SELECT * FROM t1; +SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +START TRANSACTION; +SELECT * FROM t1 LEFT JOIN t2 ON t1.c2=t2.c2 AND t2.c1=1 FOR UPDATE; +c1 c2 c3 c1 c2 c3 +1 2 3 1 2 3 +2 3 4 NULL NULL NULL +3 4 5 NULL NULL NULL +UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c2 AND t2.c1 = 3 SET t1.c3 = RAND()*10; +COMMIT; +SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +DROP TABLE t1,t2; diff --git a/mysql-test/main/join_outer_innodb.test b/mysql-test/main/join_outer_innodb.test index c26cd62fbc7..6b332f3d155 100644 --- a/mysql-test/main/join_outer_innodb.test +++ b/mysql-test/main/join_outer_innodb.test @@ -374,3 +374,20 @@ drop table t1,t2,t3; set optimizer_prune_level=@mdev4270_opl; set optimizer_search_depth=@mdev4270_osd; +--echo # +--echo # Bug #20939184:INNODB: UNLOCK ROW COULD NOT FIND A 2 MODE LOCK ON THE +--echo # RECORD +--echo # +CREATE TABLE t1 (c1 INT, c2 INT, c3 INT, PRIMARY KEY (c1,c2) ) engine=innodb; +CREATE TABLE t2 (c1 INT, c2 INT, c3 INT, PRIMARY KEY (c1), KEY (c2)) engine=innodb; +INSERT INTO t1 VALUES (1,2,3),(2,3,4),(3,4,5); +INSERT INTO t2 SELECT * FROM t1; +SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +START TRANSACTION; +#unlocks rows in table t2 where c1 = 1 +SELECT * FROM t1 LEFT JOIN t2 ON t1.c2=t2.c2 AND t2.c1=1 FOR UPDATE; +UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c2 AND t2.c1 = 3 SET t1.c3 = RAND()*10; +COMMIT; +SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +DROP TABLE t1,t2; + diff --git a/mysql-test/main/join_outer_jcl6.result b/mysql-test/main/join_outer_jcl6.result index 3cb846426fe..721989c3368 100644 --- a/mysql-test/main/join_outer_jcl6.result +++ b/mysql-test/main/join_outer_jcl6.result @@ -1747,7 +1747,7 @@ from t1,t2 where t2.pk=t1.pk+1000 and t1.pk>1000 group by t2.pk; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 index PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Using index; Using temporary; Using filesort +1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL 1 100.00 Using where; Using index; Using temporary; Using filesort 1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Using index 2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Using index 2 DEPENDENT SUBQUERY t4 eq_ref PRIMARY PRIMARY 4 test.t3.pk 1 100.00 Using index @@ -2279,11 +2279,11 @@ id select_type table type possible_keys key key_len ref rows Extra explain select * from t1 left join t2 on t2.b is null; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 9 -1 SIMPLE t2 ref b b 5 const 780 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t2 ALL b NULL NULL NULL 1000 Using where; Using join buffer (flat, BNL join) explain select * from t1 left join t2 on t2.c is null; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 9 -1 SIMPLE t2 ref c c 5 const 393 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t2 ALL c NULL NULL NULL 1000 Using where; Using join buffer (flat, BNL join) drop table t1,t2; # # MDEV-10006: optimizer doesn't convert outer join to inner on views with WHERE clause diff --git a/mysql-test/main/key.result b/mysql-test/main/key.result index 3139caa9ae5..78a2f42c477 100644 --- a/mysql-test/main/key.result +++ b/mysql-test/main/key.result @@ -216,7 +216,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index explain select 1 from t1 where id =2 or id=3; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 7 Using where; Using index +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where; Using index explain select name from t1 where id =2; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 @@ -611,7 +611,7 @@ EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE -2 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index for group-by +2 SUBQUERY t1 range a a 5 NULL 5 Using where; Using index SELECT 1 as RES FROM t1 AS t1_outer WHERE (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12; RES diff --git a/mysql-test/main/key_cache.result b/mysql-test/main/key_cache.result index 322a2be6a4e..c8bdc979387 100644 --- a/mysql-test/main/key_cache.result +++ b/mysql-test/main/key_cache.result @@ -43,8 +43,8 @@ SELECT @@medium.key_buffer_size; SET @@global.key_buffer_size=@save_key_buffer_size; SELECT @@default.key_buffer_size; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'default.key_buffer_size' at line 1 -SELECT @@skr.storage_engine="test"; -ERROR HY000: Variable 'storage_engine' is not a variable component (can't be used as XXXX.variable_name) +SELECT @@skr.default_storage_engine="test"; +ERROR HY000: Variable 'default_storage_engine' is not a variable component (can't be used as XXXX.variable_name) select @@keycache1.key_cache_block_size; @@keycache1.key_cache_block_size 0 @@ -739,13 +739,13 @@ p 1019 explain select i from t2 where a='yyyy' and i=3; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ref k1,k2 k1 5 const 189 Using where +1 SIMPLE t2 index_merge k1,k2 k1,k2 5,11 NULL 50 Using intersect(k1,k2); Using where; Using index select i from t2 where a='yyyy' and i=3; i 3 explain select a from t2 where a='yyyy' and i=3; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ref k1,k2 k1 5 const 189 Using where +1 SIMPLE t2 index_merge k1,k2 k1,k2 5,11 NULL 50 Using intersect(k1,k2); Using where; Using index select a from t2 where a='yyyy' and i=3 ; a yyyy @@ -753,7 +753,7 @@ select * from information_schema.key_caches where segment_number is null; KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES default 2 NULL 32768 1024 # # 0 3172 24 1552 18 small NULL NULL 1048576 1024 # # 0 0 0 0 0 -keycache1 7 NULL 262143 2048 # # 0 3201 43 1594 30 +keycache1 7 NULL 262143 2048 # # 0 3229 43 1594 30 keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3 set global keycache1.key_cache_block_size=2*1024; insert into t2 values (7000, 3, 'yyyy'); diff --git a/mysql-test/main/key_cache.test b/mysql-test/main/key_cache.test index fb6ae497e74..50305d499b3 100644 --- a/mysql-test/main/key_cache.test +++ b/mysql-test/main/key_cache.test @@ -45,7 +45,7 @@ SET @@global.key_buffer_size=@save_key_buffer_size; --error 1064 SELECT @@default.key_buffer_size; --error ER_VARIABLE_IS_NOT_STRUCT -SELECT @@skr.storage_engine="test"; +SELECT @@skr.default_storage_engine="test"; select @@keycache1.key_cache_block_size; select @@keycache1.key_buffer_size; diff --git a/mysql-test/main/keyread.result b/mysql-test/main/keyread.result index d8e9659d4bb..19a22eedbdf 100644 --- a/mysql-test/main/keyread.result +++ b/mysql-test/main/keyread.result @@ -4,3 +4,13 @@ select distinct f1 from v1; f1 drop view v1; drop table t1; +CREATE TABLE t1 (a INT NOT NULL, UNIQUE(a)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1),(2); +DELETE FROM t1 ORDER BY a LIMIT 1; +SELECT * FROM t1; +a +2 +DROP TABLE t1; +CREATE TABLE t1 (a CHAR KEY,b BLOB) ENGINE=InnoDB; +DELETE FROM t1 ORDER BY a LIMIT 1; +DROP TABLE t1; diff --git a/mysql-test/main/keyread.test b/mysql-test/main/keyread.test index d9d3002d392..6500f840b66 100644 --- a/mysql-test/main/keyread.test +++ b/mysql-test/main/keyread.test @@ -8,3 +8,23 @@ create view v1 as select * from t1 where f2 = 1; select distinct f1 from v1; drop view v1; drop table t1; + +# +# MDEV-22062 Assertion `!table->file->keyread_enabled()' failed in +# close_thread_table +# + +CREATE TABLE t1 (a INT NOT NULL, UNIQUE(a)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1),(2); +DELETE FROM t1 ORDER BY a LIMIT 1; +SELECT * FROM t1; +DROP TABLE t1; + +# +# MDEV-22237 Assertion `!table->file->keyread_enabled()' failed in +# handler::ha_reset on DELETE +# + +CREATE TABLE t1 (a CHAR KEY,b BLOB) ENGINE=InnoDB; +DELETE FROM t1 ORDER BY a LIMIT 1; +DROP TABLE t1; diff --git a/mysql-test/main/kill-2.test b/mysql-test/main/kill-2.test index 0c1177722b4..3412e75b8d5 100644 --- a/mysql-test/main/kill-2.test +++ b/mysql-test/main/kill-2.test @@ -8,7 +8,6 @@ # -- source include/not_embedded.inc --- source include/not_threadpool.inc --echo # --echo # MDEV-6896 kill user command cause MariaDB crash! diff --git a/mysql-test/main/kill.test b/mysql-test/main/kill.test index 05e70ff8651..1bb31bc665d 100644 --- a/mysql-test/main/kill.test +++ b/mysql-test/main/kill.test @@ -9,7 +9,6 @@ -- source include/not_embedded.inc -- source include/have_debug_sync.inc --- source include/not_threadpool.inc set local sql_mode=""; set global sql_mode=""; diff --git a/mysql-test/main/large_pages.opt b/mysql-test/main/large_pages.opt new file mode 100644 index 00000000000..857c9c1ecee --- /dev/null +++ b/mysql-test/main/large_pages.opt @@ -0,0 +1 @@ +--large-pages diff --git a/mysql-test/main/large_pages.result b/mysql-test/main/large_pages.result new file mode 100644 index 00000000000..9d03e646ddf --- /dev/null +++ b/mysql-test/main/large_pages.result @@ -0,0 +1,43 @@ +call mtr.add_suppression("\\[Warning\\] (mysqld|mariadbd): Couldn't allocate [0-9]+ bytes \\((Large/HugeTLB memory|MEMLOCK) page size [0-9]+\\).*"); +create table t1 ( +a int not null auto_increment, +b char(16) not null, +primary key (a), +key (b) +); +create table t2( +a int not null auto_increment, +b char(16) not null, +primary key (a), +key (b) +); +insert into t1(b) values +('test0'), +('test1'), +('test2'), +('test3'), +('test4'), +('test5'), +('test6'), +('test7'); +insert into t2(b) select b from t1; +insert into t1(b) select b from t2; +select * from t1 join t2 using (b) ORDER BY t1.a, t2.a; +b a a +test0 1 1 +test1 2 2 +test2 3 3 +test3 4 4 +test4 5 5 +test5 6 6 +test6 7 7 +test7 8 8 +test0 9 1 +test1 10 2 +test2 11 3 +test3 12 4 +test4 13 5 +test5 14 6 +test6 15 7 +test7 16 8 +drop table t1, t2; diff --git a/mysql-test/main/large_pages.test b/mysql-test/main/large_pages.test new file mode 100644 index 00000000000..136273a2821 --- /dev/null +++ b/mysql-test/main/large_pages.test @@ -0,0 +1,38 @@ +# Test of large pages (or at least the fallback to conventional allocation) + +# Windows needs SeLockMemoryPrivilege +--source include/not_windows.inc +--source include/have_innodb.inc + +call mtr.add_suppression("\\[Warning\\] (mysqld|mariadbd): Couldn't allocate [0-9]+ bytes \\((Large/HugeTLB memory|MEMLOCK) page size [0-9]+\\).*"); + +create table t1 ( + a int not null auto_increment, + b char(16) not null, + primary key (a), + key (b) +); + +create table t2( + a int not null auto_increment, + b char(16) not null, + primary key (a), + key (b) +); + +insert into t1(b) values + ('test0'), + ('test1'), + ('test2'), + ('test3'), + ('test4'), + ('test5'), + ('test6'), + ('test7'); + +insert into t2(b) select b from t1; +insert into t1(b) select b from t2; + +select * from t1 join t2 using (b) ORDER BY t1.a, t2.a; + +drop table t1, t2; diff --git a/mysql-test/main/limit_rows_examined.result b/mysql-test/main/limit_rows_examined.result index e87dd25cac9..f0a22b8f3f2 100644 --- a/mysql-test/main/limit_rows_examined.result +++ b/mysql-test/main/limit_rows_examined.result @@ -255,7 +255,7 @@ select * from t1i where c1 IN (select * from t2i where c2 > ' ') LIMIT ROWS EXAMINED 6; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1i index PRIMARY PRIMARY 2 NULL 4 Using where; Using index +1 PRIMARY t1i range PRIMARY PRIMARY 2 NULL 4 Using where; Using index 1 PRIMARY t2i eq_ref PRIMARY PRIMARY 2 test.t1i.c1 1 Using index select * from t1i where c1 IN (select * from t2i where c2 > ' ') @@ -395,7 +395,7 @@ select * from t1i where c1 IN (select * from t2i where c2 > ' ') LIMIT ROWS EXAMINED 17; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1i index NULL PRIMARY 2 NULL 4 Using where; Using index -2 MATERIALIZED t2i index PRIMARY PRIMARY 2 NULL 4 Using where; Using index +2 MATERIALIZED t2i range PRIMARY PRIMARY 2 NULL 4 Using where; Using index select * from t1i where c1 IN (select * from t2i where c2 > ' ') LIMIT ROWS EXAMINED 17; c1 diff --git a/mysql-test/main/loaddata_autocom_innodb.result b/mysql-test/main/loaddata_autocom_innodb.result index 9f5a0809f2a..6967d4143bb 100644 --- a/mysql-test/main/loaddata_autocom_innodb.result +++ b/mysql-test/main/loaddata_autocom_innodb.result @@ -1,4 +1,4 @@ -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; drop table if exists t1; create table t1 (id int unsigned not null auto_increment primary key, a text, b text); start transaction; diff --git a/mysql-test/main/lock.result b/mysql-test/main/lock.result index e76c04520eb..7abeaf035ee 100644 --- a/mysql-test/main/lock.result +++ b/mysql-test/main/lock.result @@ -520,3 +520,18 @@ DROP TABLE t1; # # End of 10.2 tests # +# +# MDEV-24382 Assertion `thd->mdl_context.is_lock_owner(MDL_key::TABLE, db, table_name, MDL_EXCLUSIVE)' +# failed in tdc_remove_table +# +CREATE TABLE t (c INT); +LOCK TABLES t READ LOCAL; +CREATE TEMPORARY TABLE t (a INT) SELECT 1 AS a; +DROP SEQUENCE t; +ERROR 42S02: Unknown SEQUENCE: 'test.t' +DROP TEMPORARY TABLE t; +UNLOCK TABLES; +DROP TABLE t; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/lock.test b/mysql-test/main/lock.test index 32e4fd47664..8f2435160c3 100644 --- a/mysql-test/main/lock.test +++ b/mysql-test/main/lock.test @@ -633,3 +633,21 @@ DROP TABLE t1; --echo # --echo # End of 10.2 tests --echo # + +--echo # +--echo # MDEV-24382 Assertion `thd->mdl_context.is_lock_owner(MDL_key::TABLE, db, table_name, MDL_EXCLUSIVE)' +--echo # failed in tdc_remove_table +--echo # +CREATE TABLE t (c INT); +LOCK TABLES t READ LOCAL; +CREATE TEMPORARY TABLE t (a INT) SELECT 1 AS a; +--error ER_UNKNOWN_SEQUENCES +DROP SEQUENCE t; + +DROP TEMPORARY TABLE t; +UNLOCK TABLES; +DROP TABLE t; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/lock_user.result b/mysql-test/main/lock_user.result index 560ae6ce425..24fff2105ab 100644 --- a/mysql-test/main/lock_user.result +++ b/mysql-test/main/lock_user.result @@ -164,7 +164,7 @@ CREATE USER `user1`@`localhost` ACCOUNT LOCK PASSWORD EXPIRE alter user user1@localhost PASSWORD EXPIRE INTERVAL 60 DAY ACCOUNT UNLOCK; select * from mysql.global_priv where user='user1'; Host User Priv -localhost user1 {"access":0,"plugin":"mysql_native_password","authentication_string":"","account_locked":false,"password_last_changed":0,"password_lifetime":60} +localhost user1 {"access":0,"version_id":XXX,"plugin":"mysql_native_password","authentication_string":"","account_locked":false,"password_last_changed":0,"password_lifetime":60} show create user user1@localhost; CREATE USER for user1@localhost CREATE USER `user1`@`localhost` PASSWORD EXPIRE diff --git a/mysql-test/main/lock_user.test b/mysql-test/main/lock_user.test index 530883f33ef..4e480c19360 100644 --- a/mysql-test/main/lock_user.test +++ b/mysql-test/main/lock_user.test @@ -160,6 +160,7 @@ alter user user1@localhost ACCOUNT LOCK PASSWORD EXPIRE DEFAULT; show create user user1@localhost; # note output needs to be corrected by MDEV-24114: password expire users cannot be unexpired alter user user1@localhost PASSWORD EXPIRE INTERVAL 60 DAY ACCOUNT UNLOCK; +--replace_regex /"version_id":[0-9]*,/"version_id":XXX,/ select * from mysql.global_priv where user='user1'; show create user user1@localhost; diff --git a/mysql-test/main/log_tables.result b/mysql-test/main/log_tables.result index 84e43a6be00..914bc06748e 100644 --- a/mysql-test/main/log_tables.result +++ b/mysql-test/main/log_tables.result @@ -251,14 +251,14 @@ lock tables mysql.slow_log READ; ERROR HY000: You can't use locks with log tables set global general_log='OFF'; set global slow_query_log='OFF'; -set @save_storage_engine= @@session.storage_engine; -set storage_engine= MEMORY; +set @save_storage_engine= @@session.default_storage_engine; +set default_storage_engine= MEMORY; alter table mysql.slow_log engine=NonExistentEngine; Warnings: Warning 1286 Unknown storage engine 'NonExistentEngine' alter table mysql.slow_log engine=memory; ERROR HY000: Storage engine MEMORY cannot be used for log tables -set storage_engine= @save_storage_engine; +set default_storage_engine= @save_storage_engine; ALTER TABLE mysql.general_log ENGINE=Aria; ERROR HY000: Storage engine Aria cannot be used for log tables ALTER TABLE mysql.general_log ENGINE=Aria transactional = 0; diff --git a/mysql-test/main/log_tables.test b/mysql-test/main/log_tables.test index 97a143a8fa5..537bd843af8 100644 --- a/mysql-test/main/log_tables.test +++ b/mysql-test/main/log_tables.test @@ -252,8 +252,8 @@ set global general_log='OFF'; set global slow_query_log='OFF'; # check that alter table doesn't work for other engines -set @save_storage_engine= @@session.storage_engine; -set storage_engine= MEMORY; +set @save_storage_engine= @@session.default_storage_engine; +set default_storage_engine= MEMORY; # After fixing bug#35765 the error behaivor changed: # If compiled in/enabled ER_UNSUPORTED_LOG_ENGINE # If not (i.e. not existant) it will show a warning @@ -267,7 +267,7 @@ alter table mysql.slow_log engine=memory; #alter table mysql.slow_log engine=archive; #--error ER_UNSUPORTED_LOG_ENGINE #alter table mysql.slow_log engine=blackhole; -set storage_engine= @save_storage_engine; +set default_storage_engine= @save_storage_engine; # Make sure only non-transactional Aria table can be used for logging --error ER_UNSUPORTED_LOG_ENGINE diff --git a/mysql-test/main/long_unique.result b/mysql-test/main/long_unique.result index eb61a080c96..29cb1a881ca 100644 --- a/mysql-test/main/long_unique.result +++ b/mysql-test/main/long_unique.result @@ -1477,4 +1477,19 @@ id select_type table type possible_keys key key_len ref rows Extra SELECT t2.b FROM t1 JOIN t2 ON t1.d = t2.f WHERE t2.pk >= 20; b drop table t1,t2; +# +# MDEV-21470 MyISAM start_bulk_insert doesn't work with long unique +# +CREATE TABLE t1 (a INT, b BLOB) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,'foo'),(2,'bar'); +CREATE TABLE t2 (c BIT, d BLOB, UNIQUE(d)) ENGINE=MyISAM; +INSERT INTO t2 SELECT * FROM t1; +Warnings: +Warning 1264 Out of range value for column 'c' at row 2 +DROP TABLE t1, t2; +# +# MDEV-19338 Using AUTO_INCREMENT with long unique +# +CREATE TABLE t1 (pk INT, a TEXT NOT NULL DEFAULT '', PRIMARY KEY (pk), b INT AUTO_INCREMENT, UNIQUE(b), UNIQUE (a,b)) ENGINE=myisam; +ERROR HY000: AUTO_INCREMENT column `b` cannot be used in the UNIQUE index `a` set @@GLOBAL.max_allowed_packet= @allowed_packet; diff --git a/mysql-test/main/long_unique.test b/mysql-test/main/long_unique.test index c0bd77ca5c9..2146b4b4638 100644 --- a/mysql-test/main/long_unique.test +++ b/mysql-test/main/long_unique.test @@ -556,4 +556,22 @@ SELECT t2.b FROM t1 JOIN t2 ON t1.d = t2.f WHERE t2.pk >= 20; SELECT t2.b FROM t1 JOIN t2 ON t1.d = t2.f WHERE t2.pk >= 20; drop table t1,t2; +--echo # +--echo # MDEV-21470 MyISAM start_bulk_insert doesn't work with long unique +--echo # + +CREATE TABLE t1 (a INT, b BLOB) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,'foo'),(2,'bar'); +CREATE TABLE t2 (c BIT, d BLOB, UNIQUE(d)) ENGINE=MyISAM; +INSERT INTO t2 SELECT * FROM t1; +DROP TABLE t1, t2; + +--echo # +--echo # MDEV-19338 Using AUTO_INCREMENT with long unique +--echo # + +--error ER_NO_AUTOINCREMENT_WITH_UNIQUE +CREATE TABLE t1 (pk INT, a TEXT NOT NULL DEFAULT '', PRIMARY KEY (pk), b INT AUTO_INCREMENT, UNIQUE(b), UNIQUE (a,b)) ENGINE=myisam; + +# Cleanup set @@GLOBAL.max_allowed_packet= @allowed_packet; diff --git a/mysql-test/main/long_unique_bugs.result b/mysql-test/main/long_unique_bugs.result index 5d6c0562c8a..5f9715a14ee 100644 --- a/mysql-test/main/long_unique_bugs.result +++ b/mysql-test/main/long_unique_bugs.result @@ -10,6 +10,7 @@ create temporary table tmp (a varchar(1024), b int, c int, d int, e linestring, load data infile 'load.data' into table tmp; delete from tmp; drop table t1; +drop table tmp; create table t1 (b blob) engine=innodb; alter table t1 add unique (b); alter table t1 force; @@ -266,7 +267,7 @@ disconnect con1; connection default; DROP TABLE t1, t2; CREATE TABLE t1 (a TEXT, UNIQUE(a)) ENGINE=Aria; -ERROR 42000: Specified key was too long; max key length is 1000 bytes +ERROR 42000: Specified key was too long; max key length is 2000 bytes create table t1(a int, unique(a) using hash); #BULK insert > 100 rows (MI_MIN_ROWS_TO_DISABLE_INDEXES) drop table t1; @@ -288,3 +289,74 @@ Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_par t2 0 a 1 a A NULL NULL NULL YES HASH t2 0 a 2 b A NULL NULL NULL YES HASH DROP TABLE t1,t2; +create temporary table tmp ( a int, b int, c blob not null, d int, e int default 0, f int, unique key (c)) engine=innodb; +create table t2 (x int); +lock table t2 write; +update tmp set c = 'foo'; +start transaction; +alter table tmp alter column a set default 8; +unlock tables; +drop table t2; +create table t1 (pk int primary key, f blob, unique(f)) engine=innodb; +insert t1 values (1, null); +select * into outfile 't1.data' from t1; +load data infile 't1.data' replace into table t1; +select * from t1; +pk f +1 NULL +drop table t1; +create table t1 (a int, b blob) engine=myisam; +insert t1 values (1,'foo'),(2,'bar'), (3, 'bar'); +create table t2 (c int, d blob, unique(d)) engine=myisam; +insert t2 select * from t1; +ERROR 23000: Duplicate entry 'bar' for key 'd' +select * from t2; +c d +1 foo +2 bar +insert ignore t2 select * from t1; +Warnings: +Warning 1062 Duplicate entry 'foo' for key 'd' +Warning 1062 Duplicate entry 'bar' for key 'd' +Warning 1062 Duplicate entry 'bar' for key 'd' +select * from t2; +c d +1 foo +2 bar +replace t2 select * from t1; +select * from t2; +c d +1 foo +3 bar +update t1, t2 set t2.d='off' where t1.a=t2.c and t1.b='foo'; +select * from t2; +c d +1 off +3 bar +alter table t2 add system versioning; +delete from t2 using t1, t2 where t1.a=t2.c and t1.b='foo'; +select * from t2; +c d +3 bar +create or replace table t2 (a int, b blob, unique(b)) as select * from t1; +ERROR 23000: Duplicate entry 'bar' for key 'b' +select * from t2; +ERROR 42S02: Table 'test.t2' doesn't exist +create or replace table t2 (a int, b blob, unique(b)) ignore as select * from t1; +Warnings: +Warning 1062 Duplicate entry 'bar' for key 'b' +select * from t2; +a b +1 foo +2 bar +create or replace table t2 (a int, b blob, unique(b)) replace as select * from t1; +select * from t2; +a b +1 foo +3 bar +drop table if exists t1, t2; +create table t1 (a int, b int, unique (b) using hash) engine=innodb partition by key (a) partitions 2; +insert into t1 values (1,10),(2,20); +update t1 set b = 30 limit 1; +drop table t1; +# End of 10.5 tests diff --git a/mysql-test/main/long_unique_bugs.test b/mysql-test/main/long_unique_bugs.test index 34d02b1c8f4..3e0e35e6162 100644 --- a/mysql-test/main/long_unique_bugs.test +++ b/mysql-test/main/long_unique_bugs.test @@ -18,6 +18,7 @@ delete from tmp; drop table t1; --let $datadir= `SELECT @@datadir` --remove_file $datadir/test/load.data +drop table tmp; # # MDEV-18712 InnoDB indexes are inconsistent with what defined in .frm for table after rebuilding table with index on blob @@ -368,3 +369,74 @@ show index from t2; # Cleanup DROP TABLE t1,t2; + +# +# MDEV-22113 SIGSEGV, ASAN use-after-poison, Assertion `next_insert_id == 0' in handler::ha_external_lock +# +create temporary table tmp ( a int, b int, c blob not null, d int, e int default 0, f int, unique key (c)) engine=innodb; +create table t2 (x int); +lock table t2 write; +update tmp set c = 'foo'; +start transaction; +alter table tmp alter column a set default 8; +unlock tables; +drop table t2; +--source include/have_innodb.inc + +# +# MDEV-22218 InnoDB: Failing assertion: node->pcur->rel_pos == BTR_PCUR_ON upon LOAD DATA with NO_BACKSLASH_ESCAPES in SQL_MODE and unique blob in table +# +create table t1 (pk int primary key, f blob, unique(f)) engine=innodb; +insert t1 values (1, null); +select * into outfile 't1.data' from t1; +load data infile 't1.data' replace into table t1; +select * from t1; +drop table t1; +--let $datadir= `SELECT @@datadir` +--remove_file $datadir/test/t1.data + +# more tests: + +create table t1 (a int, b blob) engine=myisam; +insert t1 values (1,'foo'),(2,'bar'), (3, 'bar'); +create table t2 (c int, d blob, unique(d)) engine=myisam; + +# INSERT...SELECT +--error ER_DUP_ENTRY +insert t2 select * from t1; + select * from t2; +insert ignore t2 select * from t1; + select * from t2; +replace t2 select * from t1; + select * from t2; + +# multi-UPDATE +update t1, t2 set t2.d='off' where t1.a=t2.c and t1.b='foo'; + select * from t2; + +# multi-DELETE +alter table t2 add system versioning; +delete from t2 using t1, t2 where t1.a=t2.c and t1.b='foo'; + select * from t2; + +# CREATE...SELECT +--error ER_DUP_ENTRY +create or replace table t2 (a int, b blob, unique(b)) as select * from t1; +--error ER_NO_SUCH_TABLE + select * from t2; +create or replace table t2 (a int, b blob, unique(b)) ignore as select * from t1; + select * from t2; +create or replace table t2 (a int, b blob, unique(b)) replace as select * from t1; + select * from t2; + +drop table if exists t1, t2; + +# +# MDEV-22185 Failing assertion: node->pcur->rel_pos == BTR_PCUR_ON or ER_KEY_NOT_FOUND or Assertion `inited==NONE' failed in handler::ha_index_init +# +create table t1 (a int, b int, unique (b) using hash) engine=innodb partition by key (a) partitions 2; +insert into t1 values (1,10),(2,20); +update t1 set b = 30 limit 1; +drop table t1; + +--echo # End of 10.5 tests diff --git a/mysql-test/main/long_unique_bugs_replication.result b/mysql-test/main/long_unique_bugs_replication.result new file mode 100644 index 00000000000..af583d00cea --- /dev/null +++ b/mysql-test/main/long_unique_bugs_replication.result @@ -0,0 +1,12 @@ +include/master-slave.inc +[connection master] +create table t1 (i1 int, a1 text, unique key i1 (a1)) engine=myisam; +insert into t1 values (1,1); +insert into t1 values (2,2); +update t1 set a1 = 'd' limit 1; +update t1 set a1 = 'd2' where i1= 2; +connection slave; +connection slave; +connection master; +drop table t1; +include/rpl_end.inc diff --git a/mysql-test/main/long_unique_bugs_replication.test b/mysql-test/main/long_unique_bugs_replication.test new file mode 100644 index 00000000000..1cacd088bee --- /dev/null +++ b/mysql-test/main/long_unique_bugs_replication.test @@ -0,0 +1,24 @@ +# +# Long unique bugs related to master slave replication +# + +# +# MDEV-22722 Assertion "inited==NONE" failed in handler::ha_index_init on the slave during UPDATE +# + +--source include/have_binlog_format_row.inc +--source include/master-slave.inc + +create table t1 (i1 int, a1 text, unique key i1 (a1)) engine=myisam; +insert into t1 values (1,1); +insert into t1 values (2,2); +update t1 set a1 = 'd' limit 1; +update t1 set a1 = 'd2' where i1= 2; + +sync_slave_with_master; +connection slave; + +connection master; +drop table t1; + +--source include/rpl_end.inc diff --git a/mysql-test/main/long_unique_delayed.result b/mysql-test/main/long_unique_delayed.result new file mode 100644 index 00000000000..52365249097 --- /dev/null +++ b/mysql-test/main/long_unique_delayed.result @@ -0,0 +1,19 @@ +# +# Test insert delayed with long unique keys +# +create table t1(a blob unique) engine=myisam; +insert delayed into t1 values(1),(2),(3),(56),('sachin'),('maria'),(123456789034567891),(null),(null),(123456789034567890),('maria'); +insert delayed into t1 values(1),(9); +flush tables t1; +select count(*) from t1; +count(*) +11 +drop table t1; +# +# MDEV-19848 +# Server crashes in check_vcol_forward_refs upon INSERT DELAYED into +# table with long blob key +# +CREATE TABLE t1 (a BLOB, UNIQUE(a)) ENGINE=MyISAM; +INSERT DELAYED t1 () VALUES (); +DROP TABLE t1; diff --git a/mysql-test/main/long_unique_delayed.test b/mysql-test/main/long_unique_delayed.test new file mode 100644 index 00000000000..c0de4a74913 --- /dev/null +++ b/mysql-test/main/long_unique_delayed.test @@ -0,0 +1,22 @@ +--source include/not_embedded.inc + +--echo # +--echo # Test insert delayed with long unique keys +--echo # + +create table t1(a blob unique) engine=myisam; +insert delayed into t1 values(1),(2),(3),(56),('sachin'),('maria'),(123456789034567891),(null),(null),(123456789034567890),('maria'); +insert delayed into t1 values(1),(9); +flush tables t1; +select count(*) from t1; +drop table t1; + +--echo # +--echo # MDEV-19848 +--echo # Server crashes in check_vcol_forward_refs upon INSERT DELAYED into +--echo # table with long blob key +--echo # + +CREATE TABLE t1 (a BLOB, UNIQUE(a)) ENGINE=MyISAM; +INSERT DELAYED t1 () VALUES (); +DROP TABLE t1; diff --git a/mysql-test/main/lowercase_fs_off.test b/mysql-test/main/lowercase_fs_off.test index e8e8dafe584..879a1eabc25 100644 --- a/mysql-test/main/lowercase_fs_off.test +++ b/mysql-test/main/lowercase_fs_off.test @@ -138,9 +138,9 @@ set GLOBAL sql_mode=default; --echo # Compatibility schema names respect the filesystem case sensitivity ---error ER_UNKNOWN_ERROR +--error ER_UNKNOWN_DATA_TYPE CREATE TABLE t1 (a MARIADB_SCHEMA.date); ---error ER_UNKNOWN_ERROR +--error ER_UNKNOWN_DATA_TYPE CREATE TABLE t1 (a Mariadb_schema.date); CREATE TABLE t1 (a mariadb_schema.date); diff --git a/mysql-test/main/mdl.result b/mysql-test/main/mdl.result index 883f35674c0..fbf80312ac0 100644 --- a/mysql-test/main/mdl.result +++ b/mysql-test/main/mdl.result @@ -58,6 +58,8 @@ DROP TABLE t1,t3; # CREATE TABLE t1(a INT) ENGINE=InnoDB; CREATE TABLE t3(a INT) ENGINE=myisam; +connect purge_control,localhost,root,,; +START TRANSACTION WITH CONSISTENT SNAPSHOT; connect locker,localhost,root,,; connection default; FLUSH TABLES WITH READ LOCK; @@ -85,6 +87,7 @@ MDL_SHARED_WRITE Table metadata lock test t3 unlock tables; connection locker; unlock tables; +disconnect purge_control; connection default; disconnect locker; DROP TABLE t1,t3; diff --git a/mysql-test/main/mdl.test b/mysql-test/main/mdl.test index 23a862f5212..0c1b7a13a0c 100644 --- a/mysql-test/main/mdl.test +++ b/mysql-test/main/mdl.test @@ -40,6 +40,8 @@ DROP TABLE t1,t3; CREATE TABLE t1(a INT) ENGINE=InnoDB; CREATE TABLE t3(a INT) ENGINE=myisam; +connect(purge_control,localhost,root,,); +START TRANSACTION WITH CONSISTENT SNAPSHOT; connect (locker,localhost,root,,); connection default; @@ -75,6 +77,7 @@ unlock tables; connection locker; --reap unlock tables; +disconnect purge_control; connection default; disconnect locker; diff --git a/mysql-test/main/mdl_sync.result b/mysql-test/main/mdl_sync.result index 5203fdddb2d..0ffe2f745a0 100644 --- a/mysql-test/main/mdl_sync.result +++ b/mysql-test/main/mdl_sync.result @@ -2010,117 +2010,6 @@ connection deadlock_con1; connection default; # Reaping ALTER. It should succeed and not produce ER_LOCK_DEADLOCK. drop table t1; -# -# Now, test for a situation in which deadlock involves waiting not -# only in MDL subsystem but also for TDC. Such deadlocks should be -# successfully detected. If possible, they should be resolved without -# resorting to ER_LOCK_DEADLOCK error. -# -create table t1(i int); -create table t2(j int); -# -# First, let us check how we handle a simple scenario involving -# waits in MDL and TDC. -# -set debug_sync= 'RESET'; -connection deadlock_con1; -# Start a statement, which will acquire SR metadata lock on t1, open it -# and then stop, before trying to acquire SW lock on t2 and opening it. -set debug_sync='open_tables_after_open_and_process_table SIGNAL parked WAIT_FOR go'; -# Sending: -select * from t1 where i in (select j from t2 for update); -connection deadlock_con2; -# Wait till the above SELECT stops. -set debug_sync='now WAIT_FOR parked'; -# The below FLUSH TABLES WITH READ LOCK should acquire -# SNW locks on t1 and t2 and wait till SELECT closes t1. -# Sending: -flush tables t1, t2 with read lock; -connection deadlock_con3; -# Wait until FLUSH TABLES WITH t1, t2 READ LOCK starts waiting -# for SELECT to close t1. -# Resume SELECT, so it tries to acquire SW lock on t1 and blocks, -# creating a deadlock. This deadlock should be detected and resolved -# by backing-off SELECT. As a result FTWRL should be able to finish. -set debug_sync='now SIGNAL go'; -connection deadlock_con2; -# Reap FLUSH TABLES WITH READ LOCK. -unlock tables; -connection deadlock_con1; -# Reap SELECT. -i -# -# The same scenario with a slightly different order of events -# which emphasizes that setting correct deadlock detector weights -# for flush waits is important. -# -set debug_sync= 'RESET'; -connection deadlock_con2; -set debug_sync='flush_tables_with_read_lock_after_acquire_locks SIGNAL parked WAIT_FOR go'; -# The below FLUSH TABLES WITH READ LOCK should acquire -# SNW locks on t1 and t2 and wait on debug sync point. -# Sending: -flush tables t1, t2 with read lock; -connection deadlock_con1; -# Wait till FLUSH TABLE WITH READ LOCK stops. -set debug_sync='now WAIT_FOR parked'; -# Start statement which will acquire SR metadata lock on t1, open -# it and then will block while trying to acquire SW lock on t2. -# Sending: -select * from t1 where i in (select j from t2 for update); -connection deadlock_con3; -# Wait till the above SELECT blocks. -# Resume FLUSH TABLES, so it tries to flush t1, thus creating -# a deadlock. This deadlock should be detected and resolved by -# backing-off SELECT. As a result FTWRL should be able to finish. -set debug_sync='now SIGNAL go'; -connection deadlock_con2; -# Reap FLUSH TABLES WITH READ LOCK. -unlock tables; -connection deadlock_con1; -# Reap SELECT. -i -# -# Now a more complex scenario involving two connections -# waiting for MDL and one for TDC. -# -set debug_sync= 'RESET'; -connection deadlock_con1; -# Start a statement which will acquire SR metadata lock on t2, open it -# and then stop, before trying to acquire SR on t1 and opening it. -set debug_sync='open_tables_after_open_and_process_table SIGNAL parked WAIT_FOR go'; -# Sending: -select * from t2, t1; -connection deadlock_con2; -# Wait till the above SELECT stops. -set debug_sync='now WAIT_FOR parked'; -# The below FLUSH TABLES WITH READ LOCK should acquire -# SNW locks on t2 and wait till SELECT closes t2. -# Sending: -flush tables t2 with read lock; -connection deadlock_con3; -# Wait until FLUSH TABLES WITH READ LOCK starts waiting -# for SELECT to close t2. -# The below DROP TABLES should acquire X lock on t1 and start -# waiting for X lock on t2. -# Sending: -drop tables t1, t2; -connection default; -# Wait until DROP TABLES starts waiting for X lock on t2. -# Resume SELECT, so it tries to acquire SR lock on t1 and blocks, -# creating a deadlock. This deadlock should be detected and resolved -# by backing-off SELECT. As a result, FTWRL should be able to finish. -set debug_sync='now SIGNAL go'; -connection deadlock_con2; -# Reap FLUSH TABLES WITH READ LOCK. -# Unblock DROP TABLES. -unlock tables; -connection deadlock_con3; -# Reap DROP TABLES. -connection deadlock_con1; -# Reap SELECT. It should emit error about missing table. -ERROR 42S02: Table 'test.t2' doesn't exist -connection default; set debug_sync= 'RESET'; disconnect deadlock_con1; disconnect deadlock_con2; diff --git a/mysql-test/main/mdl_sync.test b/mysql-test/main/mdl_sync.test index 2a1e488ab44..557fbe261a2 100644 --- a/mysql-test/main/mdl_sync.test +++ b/mysql-test/main/mdl_sync.test @@ -2493,170 +2493,6 @@ connection default; drop table t1; ---echo # ---echo # Now, test for a situation in which deadlock involves waiting not ---echo # only in MDL subsystem but also for TDC. Such deadlocks should be ---echo # successfully detected. If possible, they should be resolved without ---echo # resorting to ER_LOCK_DEADLOCK error. ---echo # -create table t1(i int); -create table t2(j int); - ---echo # ---echo # First, let us check how we handle a simple scenario involving ---echo # waits in MDL and TDC. ---echo # -set debug_sync= 'RESET'; - -connection deadlock_con1; ---echo # Start a statement, which will acquire SR metadata lock on t1, open it ---echo # and then stop, before trying to acquire SW lock on t2 and opening it. -set debug_sync='open_tables_after_open_and_process_table SIGNAL parked WAIT_FOR go'; ---echo # Sending: ---send select * from t1 where i in (select j from t2 for update) - -connection deadlock_con2; ---echo # Wait till the above SELECT stops. -set debug_sync='now WAIT_FOR parked'; ---echo # The below FLUSH TABLES WITH READ LOCK should acquire ---echo # SNW locks on t1 and t2 and wait till SELECT closes t1. ---echo # Sending: -send flush tables t1, t2 with read lock; - -connection deadlock_con3; ---echo # Wait until FLUSH TABLES WITH t1, t2 READ LOCK starts waiting ---echo # for SELECT to close t1. -let $wait_condition= - select count(*) = 1 from information_schema.processlist - where state = "Waiting for table flush" and - info = "flush tables t1, t2 with read lock"; ---source include/wait_condition.inc - ---echo # Resume SELECT, so it tries to acquire SW lock on t1 and blocks, ---echo # creating a deadlock. This deadlock should be detected and resolved ---echo # by backing-off SELECT. As a result FTWRL should be able to finish. -set debug_sync='now SIGNAL go'; - -connection deadlock_con2; ---echo # Reap FLUSH TABLES WITH READ LOCK. -reap; -unlock tables; - -connection deadlock_con1; ---echo # Reap SELECT. -reap; - ---echo # ---echo # The same scenario with a slightly different order of events ---echo # which emphasizes that setting correct deadlock detector weights ---echo # for flush waits is important. ---echo # -set debug_sync= 'RESET'; - -connection deadlock_con2; -set debug_sync='flush_tables_with_read_lock_after_acquire_locks SIGNAL parked WAIT_FOR go'; - ---echo # The below FLUSH TABLES WITH READ LOCK should acquire ---echo # SNW locks on t1 and t2 and wait on debug sync point. ---echo # Sending: -send flush tables t1, t2 with read lock; - -connection deadlock_con1; ---echo # Wait till FLUSH TABLE WITH READ LOCK stops. -set debug_sync='now WAIT_FOR parked'; - ---echo # Start statement which will acquire SR metadata lock on t1, open ---echo # it and then will block while trying to acquire SW lock on t2. ---echo # Sending: -send select * from t1 where i in (select j from t2 for update); - -connection deadlock_con3; ---echo # Wait till the above SELECT blocks. -let $wait_condition= - select count(*) = 1 from information_schema.processlist - where state = "Waiting for table metadata lock" and - info = "select * from t1 where i in (select j from t2 for update)"; ---source include/wait_condition.inc - ---echo # Resume FLUSH TABLES, so it tries to flush t1, thus creating ---echo # a deadlock. This deadlock should be detected and resolved by ---echo # backing-off SELECT. As a result FTWRL should be able to finish. -set debug_sync='now SIGNAL go'; - -connection deadlock_con2; ---echo # Reap FLUSH TABLES WITH READ LOCK. -reap; -unlock tables; - -connection deadlock_con1; ---echo # Reap SELECT. -reap; - ---echo # ---echo # Now a more complex scenario involving two connections ---echo # waiting for MDL and one for TDC. ---echo # -set debug_sync= 'RESET'; - -connection deadlock_con1; ---echo # Start a statement which will acquire SR metadata lock on t2, open it ---echo # and then stop, before trying to acquire SR on t1 and opening it. -set debug_sync='open_tables_after_open_and_process_table SIGNAL parked WAIT_FOR go'; ---echo # Sending: -send select * from t2, t1; - -connection deadlock_con2; ---echo # Wait till the above SELECT stops. -set debug_sync='now WAIT_FOR parked'; ---echo # The below FLUSH TABLES WITH READ LOCK should acquire ---echo # SNW locks on t2 and wait till SELECT closes t2. ---echo # Sending: -send flush tables t2 with read lock; - -connection deadlock_con3; ---echo # Wait until FLUSH TABLES WITH READ LOCK starts waiting ---echo # for SELECT to close t2. -let $wait_condition= - select count(*) = 1 from information_schema.processlist - where state = "Waiting for table flush" and - info = "flush tables t2 with read lock"; ---source include/wait_condition.inc - ---echo # The below DROP TABLES should acquire X lock on t1 and start ---echo # waiting for X lock on t2. ---echo # Sending: -send drop tables t1, t2; - -connection default; ---echo # Wait until DROP TABLES starts waiting for X lock on t2. -let $wait_condition= - select count(*) = 1 from information_schema.processlist - where state = "Waiting for table metadata lock" and - info = "drop tables t1, t2"; ---source include/wait_condition.inc - ---echo # Resume SELECT, so it tries to acquire SR lock on t1 and blocks, ---echo # creating a deadlock. This deadlock should be detected and resolved ---echo # by backing-off SELECT. As a result, FTWRL should be able to finish. -set debug_sync='now SIGNAL go'; - -connection deadlock_con2; ---echo # Reap FLUSH TABLES WITH READ LOCK. -reap; ---echo # Unblock DROP TABLES. -unlock tables; - -connection deadlock_con3; ---echo # Reap DROP TABLES. -reap; - -connection deadlock_con1; ---echo # Reap SELECT. It should emit error about missing table. ---error ER_NO_SUCH_TABLE -reap; - -connection default; - set debug_sync= 'RESET'; disconnect deadlock_con1; diff --git a/mysql-test/main/merge.result b/mysql-test/main/merge.result index 075152da1c7..0d6f387a7bc 100644 --- a/mysql-test/main/merge.result +++ b/mysql-test/main/merge.result @@ -1,4 +1,4 @@ -set @save_default_storage_engine=@@global.storage_engine; +set @save_default_storage_engine=@@global.default_storage_engine; set global default_storage_engine=myisam; set session default_storage_engine=myisam; drop table if exists t1,t2,t3,t4,t5,t6; diff --git a/mysql-test/main/merge.test b/mysql-test/main/merge.test index c22cf3950c1..888b41b24bd 100644 --- a/mysql-test/main/merge.test +++ b/mysql-test/main/merge.test @@ -6,7 +6,7 @@ --source include/count_sessions.inc # MERGE tables require MyISAM tables -set @save_default_storage_engine=@@global.storage_engine; +set @save_default_storage_engine=@@global.default_storage_engine; set global default_storage_engine=myisam; set session default_storage_engine=myisam; diff --git a/mysql-test/main/merge_debug.result b/mysql-test/main/merge_debug.result index 29858810ff1..36cf254f87e 100644 --- a/mysql-test/main/merge_debug.result +++ b/mysql-test/main/merge_debug.result @@ -1,6 +1,6 @@ -set @default_storage_engine= @@global.storage_engine; -set global storage_engine=myisam; -set session storage_engine=myisam; +set @default_storage_engine= @@global.default_storage_engine; +set global default_storage_engine=myisam; +set session default_storage_engine=myisam; call mtr.add_suppression("Index for table .*crashed' is corrupt; try to repair it"); drop table if exists crashed,t2,t3,t4; SET @orig_debug=@@global.debug_dbug; @@ -24,4 +24,4 @@ INSERT INTO t3 VALUES (31); UNLOCK TABLES; DROP TRIGGER t1_ai; DROP TABLE t4,crashed,t2,t3; -set global storage_engine=@default_storage_engine; +set global default_storage_engine=@default_storage_engine; diff --git a/mysql-test/main/merge_debug.test b/mysql-test/main/merge_debug.test index 50017bc1331..4141042c261 100644 --- a/mysql-test/main/merge_debug.test +++ b/mysql-test/main/merge_debug.test @@ -4,9 +4,9 @@ --source include/have_debug.inc -set @default_storage_engine= @@global.storage_engine; -set global storage_engine=myisam; -set session storage_engine=myisam; +set @default_storage_engine= @@global.default_storage_engine; +set global default_storage_engine=myisam; +set session default_storage_engine=myisam; call mtr.add_suppression("Index for table .*crashed' is corrupt; try to repair it"); @@ -43,4 +43,4 @@ UNLOCK TABLES; DROP TRIGGER t1_ai; DROP TABLE t4,crashed,t2,t3; -set global storage_engine=@default_storage_engine; +set global default_storage_engine=@default_storage_engine; diff --git a/mysql-test/main/merge_mmap.result b/mysql-test/main/merge_mmap.result index e8014259a4a..8e655a0491b 100644 --- a/mysql-test/main/merge_mmap.result +++ b/mysql-test/main/merge_mmap.result @@ -1,5 +1,5 @@ -SET GLOBAL storage_engine = MyISAM; -SET SESSION storage_engine = MyISAM; +SET GLOBAL default_storage_engine = MyISAM; +SET SESSION default_storage_engine = MyISAM; DROP TABLE IF EXISTS t1, t2, m1, m2; CREATE TABLE t1 (c1 INT); CREATE TABLE t2 (c1 INT); diff --git a/mysql-test/main/merge_mmap.test b/mysql-test/main/merge_mmap.test index c97b029754d..f3fce257f06 100644 --- a/mysql-test/main/merge_mmap.test +++ b/mysql-test/main/merge_mmap.test @@ -3,9 +3,9 @@ # # MERGE tables require MyISAM tables ---let $default=`SELECT @@global.storage_engine` -SET GLOBAL storage_engine = MyISAM; -SET SESSION storage_engine = MyISAM; +--let $default=`SELECT @@global.default_storage_engine` +SET GLOBAL default_storage_engine = MyISAM; +SET SESSION default_storage_engine = MyISAM; # Clean up resources used in this test case. --disable_warnings @@ -146,6 +146,6 @@ DROP TABLE m2, m1, t2, t1; --disable_result_log --disable_query_log -eval SET GLOBAL storage_engine = $default; +eval SET GLOBAL default_storage_engine = $default; --enable_result_log --enable_query_log diff --git a/mysql-test/main/mix2_myisam.result b/mysql-test/main/mix2_myisam.result index 220d14f3b0e..5a228f63502 100644 --- a/mysql-test/main/mix2_myisam.result +++ b/mysql-test/main/mix2_myisam.result @@ -1,5 +1,5 @@ call mtr.add_suppression("Can't find record in .*"); -SET SESSION STORAGE_ENGINE = MEMORY; +SET SESSION DEFAULT_STORAGE_ENGINE = MEMORY; drop table if exists t1,t2,t3,t4; drop database if exists mysqltest; create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=MyISAM; @@ -1411,7 +1411,7 @@ select count(*) from t1 where x = 18446744073709551601; count(*) 1 drop table t1; -set storage_engine=MyISAM; +set default_storage_engine=MyISAM; drop table if exists t1,t2,t3; --- Testing varchar --- --- Testing varchar --- @@ -1552,7 +1552,7 @@ alter table t1 add unique(v); ERROR 23000: Duplicate entry '{ ' for key 'v_2' show warnings; Level Code Message -Error 1062 Duplicate entry 'a' for key 'v_2' +Error 1062 Duplicate entry 'a\0001' for key 'v_2' alter table t1 add key(v); Warnings: Note 1831 Duplicate index `v_2`. This is deprecated and will be disallowed in a future release @@ -2012,7 +2012,7 @@ t1 CREATE TABLE `t1` ( `v` mediumtext CHARACTER SET utf8 DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; -set storage_engine=MEMORY; +set default_storage_engine=MEMORY; create table t1 (v varchar(16384)) engine=MyISAM; drop table t1; create table t1 (a char(1), b char(1), key(a, b)) engine=MyISAM; diff --git a/mysql-test/main/mrr_icp_extra.result b/mysql-test/main/mrr_icp_extra.result index 176df5cf9d5..f0c284762c6 100644 --- a/mysql-test/main/mrr_icp_extra.result +++ b/mysql-test/main/mrr_icp_extra.result @@ -353,7 +353,7 @@ alter table t1 add unique(v); ERROR 23000: Duplicate entry '{ ' for key 'v_2' show warnings; Level Code Message -Error 1062 Duplicate entry 'a' for key 'v_2' +Error 1062 Duplicate entry 'a\0001' for key 'v_2' alter table t1 add key(v); Warnings: Note 1831 Duplicate index `v_2`. This is deprecated and will be disallowed in a future release diff --git a/mysql-test/main/my_print_defaults.result b/mysql-test/main/my_print_defaults.result new file mode 100644 index 00000000000..64aa7b45ca8 --- /dev/null +++ b/mysql-test/main/my_print_defaults.result @@ -0,0 +1,51 @@ +# MDEV-24248: my_print_defaults is not taking all the values when using +# -e option which is called from mysql.server (extra_args). +# +# checking for mysql.server +--key_buffer_size=20M +--max_allowed_packet=250M +--table_open_cache=1000 +--table_definition_cache=2000 +--read_buffer_size=1M +--thread_cache_size=8 +--max_connections=1024 +--long_query_time=60 +--slow_query_log=1 +# +# MDEV-25908: -e does not work for my_print_defaults +# +# Testing -e +--key_buffer_size=20M +--max_allowed_packet=250M +--table_open_cache=1000 +#Testing --defaults-extra-file +--key_buffer_size=20M +--max_allowed_packet=250M +--table_open_cache=1000 +# +# Testing other options +# +# Testing -c option +--key_buffer_size=20M +--max_allowed_packet=250M +--table_open_cache=1000 +# Testing --defaults-file +--key_buffer_size=20M +--max_allowed_packet=250M +--table_open_cache=1000 +# Testing -g option +--key_buffer_size=20M +--max_allowed_packet=250M +--table_open_cache=1000 +--table_definition_cache=2000 +--read_buffer_size=1M +--thread_cache_size=8 +# Testing --defaults-group-suffix +--key_buffer_size=20M +--max_allowed_packet=250M +--table_open_cache=1000 +--table_definition_cache=2000 +--read_buffer_size=1M +--thread_cache_size=8 +# Testing --no-defaults +# End of 10.5 Test diff --git a/mysql-test/main/my_print_defaults.test b/mysql-test/main/my_print_defaults.test new file mode 100644 index 00000000000..bfd4e563826 --- /dev/null +++ b/mysql-test/main/my_print_defaults.test @@ -0,0 +1,106 @@ +--echo # MDEV-24248: my_print_defaults is not taking all the values when using +--echo # -e option which is called from mysql.server (extra_args). +--echo # + +--echo # checking for mysql.server + +--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf +[mariadb] +key_buffer_size=20M +max_allowed_packet=250M +table_open_cache=1000 +table_definition_cache=2000 +read_buffer_size=1M +thread_cache_size=8 +max_connections=1024 +long_query_time=60 +slow_query_log=1 +EOF + +--write_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf +[mariadb] +key_buffer_size=20M +max_allowed_packet=250M +table_open_cache=1000 +table_definition_cache=2000 +read_buffer_size=1M +thread_cache_size=8 +max_connections=1024 +long_query_time=60 +slow_query_log=1 +EOF + +--exec $MYSQL_MY_PRINT_DEFAULTS --defaults-extra-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf -c $MYSQLTEST_VARDIR/tmp/tmp2.cnf --mysqld mysql.server +--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf +--remove_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf + + +--echo # +--echo # MDEV-25908: -e does not work for my_print_defaults +--echo # + +--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf + +[mariadb] +key_buffer_size=20M +max_allowed_packet=250M +table_open_cache=1000 +EOF + +--write_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf + +[mariadb] +key_buffer_size=20M +max_allowed_packet=250M +table_open_cache=1000 +EOF + +--echo # Testing -e +--exec $MYSQL_MY_PRINT_DEFAULTS -e $MYSQLTEST_VARDIR/tmp/tmp1.cnf -c $MYSQLTEST_VARDIR/tmp/tmp2.cnf --mysqld mysql.server +--echo #Testing --defaults-extra-file +--exec $MYSQL_MY_PRINT_DEFAULTS --defaults-extra-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf -c $MYSQLTEST_VARDIR/tmp/tmp2.cnf --mysqld mysql.server + +--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf +--remove_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf + +--echo # +--echo # Testing other options +--echo # + + +--write_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf +[mariadb] +key_buffer_size=20M +max_allowed_packet=250M +table_open_cache=1000 +EOF + +--write_file $MYSQLTEST_VARDIR/tmp/tmp3.cnf +[mariadb] +key_buffer_size=20M +max_allowed_packet=250M +table_open_cache=1000 + +[mariadb.1] +table_definition_cache=2000 +read_buffer_size=1M +thread_cache_size=8 +EOF + +--echo # Testing -c option +--exec $MYSQL_MY_PRINT_DEFAULTS -c $MYSQLTEST_VARDIR/tmp/tmp2.cnf --mysqld mysql.server +--echo # Testing --defaults-file +--exec $MYSQL_MY_PRINT_DEFAULTS --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp2.cnf --mysqld mysql.server + +--echo # Testing -g option +--exec $MYSQL_MY_PRINT_DEFAULTS -c $MYSQLTEST_VARDIR/tmp/tmp3.cnf --mysqld mysql.server -g .1 +--echo # Testing --defaults-group-suffix +--exec $MYSQL_MY_PRINT_DEFAULTS -c $MYSQLTEST_VARDIR/tmp/tmp3.cnf --mysqld mysql.server --defaults-group-suffix=.1 + +--echo # Testing --no-defaults +--exec $MYSQL_MY_PRINT_DEFAULTS --no-defaults + +--remove_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf +--remove_file $MYSQLTEST_VARDIR/tmp/tmp3.cnf + +--echo # End of 10.5 Test diff --git a/mysql-test/main/myisam.result b/mysql-test/main/myisam.result index 32737bd8399..a2a9d4854ee 100644 --- a/mysql-test/main/myisam.result +++ b/mysql-test/main/myisam.result @@ -1127,7 +1127,7 @@ length(c1) c1 2 B DROP TABLE t1; End of 4.1 tests -set storage_engine=MyISAM; +set default_storage_engine=MyISAM; drop table if exists t1,t2,t3; --- Testing varchar --- --- Testing varchar --- @@ -1268,7 +1268,7 @@ alter table t1 add unique(v); ERROR 23000: Duplicate entry '{ ' for key 'v_2' show warnings; Level Code Message -Error 1062 Duplicate entry 'a' for key 'v_2' +Error 1062 Duplicate entry 'a\0001' for key 'v_2' alter table t1 add key(v); Warnings: Note 1831 Duplicate index `v_2`. This is deprecated and will be disallowed in a future release @@ -1738,7 +1738,7 @@ t1 CREATE TABLE `t1` ( `v` text DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; -set storage_engine=MyISAM; +set default_storage_engine=MyISAM; set @save_concurrent_insert=@@concurrent_insert; set global concurrent_insert=1; create table t1 (a int); diff --git a/mysql-test/main/myisam.test b/mysql-test/main/myisam.test index 9b81ab197ae..5ed63f50f49 100644 --- a/mysql-test/main/myisam.test +++ b/mysql-test/main/myisam.test @@ -1023,8 +1023,8 @@ DROP TABLE t1; # Test varchar # -let $default=`select @@storage_engine`; -set storage_engine=MyISAM; +let $default=`select @@default_storage_engine`; +set default_storage_engine=MyISAM; source include/varchar.inc; # @@ -1048,7 +1048,7 @@ create table t1 (v varchar(65535)); show create table t1; drop table t1; -eval set storage_engine=$default; +eval set default_storage_engine=$default; # # Test concurrent insert diff --git a/mysql-test/main/myisam_crash_before_flush_keys-master.opt b/mysql-test/main/myisam_crash_before_flush_keys-master.opt index 425fda95086..590d44a6d12 100644 --- a/mysql-test/main/myisam_crash_before_flush_keys-master.opt +++ b/mysql-test/main/myisam_crash_before_flush_keys-master.opt @@ -1 +1 @@ ---skip-stack-trace --skip-core-file +--loose-skip-stack-trace --skip-core-file diff --git a/mysql-test/main/myisam_debug.result b/mysql-test/main/myisam_debug.result index 650a3bcb787..10208a936a0 100644 --- a/mysql-test/main/myisam_debug.result +++ b/mysql-test/main/myisam_debug.result @@ -38,7 +38,9 @@ insert t1 values (1),(2),(1); set @old_dbug=@@debug_dbug; SET debug_dbug='+d,mi_lock_database_failure'; unlock tables; -Warnings: +ERROR HY000: Index for table './test/t1.MYI' is corrupt; try to repair it +SHOW WARNINGS; +Level Code Message Error 126 Index for table './test/t1.MYI' is corrupt; try to repair it Error 1030 Got error 22 "Invalid argument" from storage engine MyISAM SET debug_dbug=@old_dbug; diff --git a/mysql-test/main/myisam_debug.test b/mysql-test/main/myisam_debug.test index 2861c344b10..fcb134c0400 100644 --- a/mysql-test/main/myisam_debug.test +++ b/mysql-test/main/myisam_debug.test @@ -67,6 +67,8 @@ lock tables t1 write; insert t1 values (1),(2),(1); set @old_dbug=@@debug_dbug; SET debug_dbug='+d,mi_lock_database_failure'; +--error HA_ERR_CRASHED unlock tables; +SHOW WARNINGS; SET debug_dbug=@old_dbug; drop table t1; diff --git a/mysql-test/main/myisam_explain_non_select_all.result b/mysql-test/main/myisam_explain_non_select_all.result index 7f24cb4896d..2ff966fdfd3 100644 --- a/mysql-test/main/myisam_explain_non_select_all.result +++ b/mysql-test/main/myisam_explain_non_select_all.result @@ -3091,12 +3091,11 @@ FLUSH STATUS; FLUSH TABLES; EXPLAIN EXTENDED SELECT * FROM t1 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 -1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 3 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY <derived3> ref key0 key0 5 test.t1.a 2 100.00 FirstMatch(t1) 3 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00 Using filesort Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) where 1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) where `x`.`b` = `test`.`t1`.`a` # Status of EXPLAIN EXTENDED "equivalent" SELECT query execution Variable_name Value Handler_read_key 4 @@ -3105,7 +3104,7 @@ Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be # Status of "equivalent" SELECT query execution: Variable_name Value Handler_read_key 7 -Handler_read_rnd_next 10 +Handler_read_rnd_next 8 Sort_priority_queue_sorts 1 Sort_rows 3 Sort_scan 1 @@ -3126,19 +3125,17 @@ Warnings: Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 -1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY <derived3> ref key0 key0 5 test.t1.a 2 FirstMatch(t1) 1 PRIMARY t2 ALL NULL NULL NULL NULL 3 -2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 3 3 DERIVED t2 ALL NULL NULL NULL NULL 3 Using filesort FLUSH STATUS; FLUSH TABLES; EXPLAIN EXTENDED UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 -1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY <derived3> ref key0 key0 5 test.t1.a 2 100.00 FirstMatch(t1) 1 PRIMARY t2 ALL NULL NULL NULL NULL 3 100.00 -2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 3 100.00 3 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00 Using filesort # Status of EXPLAIN EXTENDED query Variable_name Value @@ -3147,13 +3144,12 @@ FLUSH STATUS; FLUSH TABLES; EXPLAIN EXTENDED SELECT * FROM t1, t2 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 -1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY <derived3> ref key0 key0 5 test.t1.a 2 100.00 FirstMatch(t1) 1 PRIMARY t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join) -2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 3 100.00 3 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00 Using filesort Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) join `test`.`t2` where 1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) join `test`.`t2` where `x`.`b` = `test`.`t1`.`a` # Status of EXPLAIN EXTENDED "equivalent" SELECT query execution Variable_name Value Handler_read_key 4 @@ -3162,14 +3158,14 @@ Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be # Status of "equivalent" SELECT query execution: Variable_name Value Handler_read_key 7 -Handler_read_rnd_next 10 +Handler_read_rnd_next 8 Sort_priority_queue_sorts 1 Sort_rows 3 Sort_scan 1 # Status of testing query execution: Variable_name Value Handler_read_key 7 -Handler_read_rnd_next 10 +Handler_read_rnd_next 8 Sort_priority_queue_sorts 1 Sort_rows 3 Sort_scan 1 @@ -3182,20 +3178,18 @@ Warnings: Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead EXPLAIN UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 -1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1 +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY <derived4> ref key0 key0 5 test.t1.a 2 FirstMatch(t1) 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 -3 MATERIALIZED <derived4> ALL NULL NULL NULL NULL 3 4 DERIVED t2 ALL NULL NULL NULL NULL 3 Using filesort 2 DERIVED t2 ALL NULL NULL NULL NULL 3 FLUSH STATUS; FLUSH TABLES; EXPLAIN EXTENDED UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 -1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY <derived4> ref key0 key0 5 test.t1.a 2 100.00 FirstMatch(t1) 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 100.00 -3 MATERIALIZED <derived4> ALL NULL NULL NULL NULL 3 100.00 4 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00 Using filesort 2 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00 # Status of EXPLAIN EXTENDED query @@ -3205,13 +3199,12 @@ FLUSH STATUS; FLUSH TABLES; EXPLAIN EXTENDED SELECT * FROM t1, (SELECT * FROM t2) y WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 -1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY <derived4> ref key0 key0 5 test.t1.a 2 100.00 FirstMatch(t1) 1 PRIMARY t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join) -3 MATERIALIZED <derived4> ALL NULL NULL NULL NULL 3 100.00 4 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00 Using filesort Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` semi join ((/* select#4 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) join `test`.`t2` where 1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` semi join ((/* select#4 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) join `test`.`t2` where `x`.`b` = `test`.`t1`.`a` # Status of EXPLAIN EXTENDED "equivalent" SELECT query execution Variable_name Value Handler_read_key 4 @@ -3220,14 +3213,14 @@ Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be # Status of "equivalent" SELECT query execution: Variable_name Value Handler_read_key 7 -Handler_read_rnd_next 10 +Handler_read_rnd_next 8 Sort_priority_queue_sorts 1 Sort_rows 3 Sort_scan 1 # Status of testing query execution: Variable_name Value Handler_read_key 7 -Handler_read_rnd_next 10 +Handler_read_rnd_next 8 Sort_priority_queue_sorts 1 Sort_rows 3 Sort_scan 1 @@ -3283,7 +3276,7 @@ FLUSH STATUS; FLUSH TABLES; EXPLAIN EXTENDED SELECT a t1 FROM t1 WHERE a>10; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 5 20.00 Using where; Using index +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 100.00 Using where; Using index Warnings: Note 1003 select `test`.`t1`.`a` AS `t1` from `test`.`t1` where `test`.`t1`.`a` > 10 # Status of EXPLAIN EXTENDED "equivalent" SELECT query execution @@ -3293,9 +3286,7 @@ Warnings: Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead # Status of "equivalent" SELECT query execution: Variable_name Value -Handler_read_first 1 -Handler_read_key 3 -Handler_read_next 5 +Handler_read_key 4 # Status of testing query execution: Variable_name Value Handler_read_key 4 @@ -3322,7 +3313,7 @@ FLUSH STATUS; FLUSH TABLES; EXPLAIN EXTENDED SELECT a t1 FROM t1 WHERE a>10 ORDER BY a+20; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 5 20.00 Using where; Using index; Using filesort +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 100.00 Using where; Using index; Using filesort Warnings: Note 1003 select `test`.`t1`.`a` AS `t1` from `test`.`t1` where `test`.`t1`.`a` > 10 order by `test`.`t1`.`a` + 20 # Status of EXPLAIN EXTENDED "equivalent" SELECT query execution @@ -3332,9 +3323,8 @@ Warnings: Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead # Status of "equivalent" SELECT query execution: Variable_name Value -Handler_read_key 3 -Handler_read_rnd_next 6 -Sort_scan 1 +Handler_read_key 4 +Sort_range 1 # Status of testing query execution: Variable_name Value Handler_read_key 4 diff --git a/mysql-test/main/myisam_icp.result b/mysql-test/main/myisam_icp.result index 68770229926..d0614913480 100644 --- a/mysql-test/main/myisam_icp.result +++ b/mysql-test/main/myisam_icp.result @@ -407,7 +407,7 @@ WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240 ORDER BY c1 LIMIT 1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY,k1 PRIMARY 4 NULL 3 Using index condition; Using where; Rowid-ordered scan; Using filesort +1 SIMPLE t1 range|filter PRIMARY,k1 PRIMARY|k1 4|5 NULL 3 (50%) Using index condition; Using where; Rowid-ordered scan; Using filesort; Using rowid filter DROP TABLE t1; # # @@ -428,9 +428,9 @@ EXPLAIN SELECT * FROM t1 WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON it.i=it.i WHERE it.pk-t1.i<10); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where -2 DEPENDENT SUBQUERY it eq_ref PRIMARY PRIMARY 4 func 1 Using index condition -2 DEPENDENT SUBQUERY t2 index NULL PRIMARY 4 NULL 3 Using index; Using join buffer (flat, BNL join) +1 PRIMARY t1 ALL NULL NULL NULL NULL # Using where +2 DEPENDENT SUBQUERY it eq_ref PRIMARY PRIMARY 4 func # Using index condition +2 DEPENDENT SUBQUERY t2 index NULL PRIMARY 4 NULL # Using index; Using join buffer (flat, BNL join) SELECT * FROM t1 WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON it.i=it.i WHERE it.pk-t1.i<10); pk i @@ -506,7 +506,7 @@ WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR (t1.pk > 1 AND t2.pk BETWEEN 6 AND 6); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan -1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; Rowid-ordered scan; Using join buffer (flat, BNL join) SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1 WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR (t1.pk > 1 AND t2.pk BETWEEN 6 AND 6); @@ -675,16 +675,18 @@ DROP TABLE t1; # CREATE TABLE t1 (b int NOT NULL, c int, a varchar(1024), PRIMARY KEY (b)); INSERT INTO t1 VALUES (1,4,'Ill'); +insert into t1 select seq+100,5,seq from seq_1_to_100; CREATE TABLE t2 (a varchar(1024), KEY (a(512))); INSERT INTO t2 VALUES ('Ill'), ('eckqzsflbzaffti'), ('w'), ('she'), ('gxbwypqtjzwywwer'), ('w'); +insert into t2 select seq from seq_1_to_100; SET SESSION optimizer_switch='index_condition_pushdown=off'; EXPLAIN SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND (t1.b<0 OR t1.b>0) HAVING t1.c != 5 ORDER BY t1.c; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 system PRIMARY NULL NULL NULL 1 -1 SIMPLE t2 ref a a 515 const 1 Using where +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL # Using where; Using filesort +1 SIMPLE t2 ref a a 515 test.t1.a # Using where SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND (t1.b<0 OR t1.b>0) HAVING t1.c != 5 ORDER BY t1.c; b c @@ -694,8 +696,8 @@ EXPLAIN SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND (t1.b<0 OR t1.b>0) HAVING t1.c != 5 ORDER BY t1.c; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 system PRIMARY NULL NULL NULL 1 -1 SIMPLE t2 ref a a 515 const 1 Using where +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL # Using where; Using filesort +1 SIMPLE t2 ref a a 515 test.t1.a # Using where SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND (t1.b<0 OR t1.b>0) HAVING t1.c != 5 ORDER BY t1.c; b c diff --git a/mysql-test/main/myisam_repair.result b/mysql-test/main/myisam_repair.result deleted file mode 100644 index 50a9695c8c7..00000000000 --- a/mysql-test/main/myisam_repair.result +++ /dev/null @@ -1,51 +0,0 @@ -# -# MDEV-23318 Assertion `cache_empty(keycache)' failed in -# prepare_resize_simple_key_cache -# -SET @buffer_size.save= @@key_buffer_size; -SET GLOBAL key_buffer_size= 134217728; -SET myisam_repair_threads= 6; -CREATE TABLE t1 ( -pk INT AUTO_INCREMENT, -a INTEGER, -b DATE, -c VARCHAR(1), -d BLOB, -PRIMARY KEY (pk), -KEY (a), -KEY (b), -KEY (c, a), -UNIQUE (d) -) ENGINE=MyISAM; -INSERT INTO t1 (a,b,c) SELECT seq, '2020-12-12', 'x' FROM seq_1_to_20; -ALTER TABLE t1 DISABLE KEYS; -SET GLOBAL c.key_buffer_size= 13700864; -Warnings: -Warning 1292 Truncated incorrect key_buffer_size value: '13700864' -INSERT INTO t1 SELECT 1; -ERROR 21S01: Column count doesn't match value count at row 1 -SET GLOBAL c.key_buffer_size= 0; -DROP TABLE t1; -SET GLOBAL key_buffer_size= 134217728; -CREATE TABLE t1 ( -pk INT AUTO_INCREMENT, -a INTEGER, -b DATE, -c VARCHAR(1), -d VARBINARY(40982), -PRIMARY KEY (pk), -KEY (a), -KEY (b), -KEY (c, a), -UNIQUE (d) -) ENGINE=MyISAM; -INSERT INTO t1 (a,b,c) SELECT seq, '2020-12-12', 'x' FROM seq_1_to_20; -ALTER TABLE t1 DISABLE KEYS; -SET GLOBAL c.key_buffer_size= 13700864; -Warnings: -Warning 1292 Truncated incorrect key_buffer_size value: '13700864' -INSERT INTO t1 SELECT 1; -ERROR 21S01: Column count doesn't match value count at row 1 -SET GLOBAL c.key_buffer_size= 0; -DROP TABLE t1; -SET GLOBAL key_buffer_size= @buffer_size.save; diff --git a/mysql-test/main/myisam_repair.test b/mysql-test/main/myisam_repair.test deleted file mode 100644 index bcb69d59e2c..00000000000 --- a/mysql-test/main/myisam_repair.test +++ /dev/null @@ -1,57 +0,0 @@ ---source include/have_sequence.inc - - ---echo # ---echo # MDEV-23318 Assertion `cache_empty(keycache)' failed in ---echo # prepare_resize_simple_key_cache ---echo # - -SET @buffer_size.save= @@key_buffer_size; -SET GLOBAL key_buffer_size= 134217728; -SET myisam_repair_threads= 6; - -CREATE TABLE t1 ( - pk INT AUTO_INCREMENT, - a INTEGER, - b DATE, - c VARCHAR(1), - d BLOB, - PRIMARY KEY (pk), - KEY (a), - KEY (b), - KEY (c, a), - UNIQUE (d) -) ENGINE=MyISAM; - -INSERT INTO t1 (a,b,c) SELECT seq, '2020-12-12', 'x' FROM seq_1_to_20; - -ALTER TABLE t1 DISABLE KEYS; -SET GLOBAL c.key_buffer_size= 13700864; ---error ER_WRONG_VALUE_COUNT_ON_ROW -INSERT INTO t1 SELECT 1; -SET GLOBAL c.key_buffer_size= 0; -DROP TABLE t1; - -SET GLOBAL key_buffer_size= 134217728; - -CREATE TABLE t1 ( - pk INT AUTO_INCREMENT, - a INTEGER, - b DATE, - c VARCHAR(1), - d VARBINARY(40982), - PRIMARY KEY (pk), - KEY (a), - KEY (b), - KEY (c, a), - UNIQUE (d) -) ENGINE=MyISAM; -INSERT INTO t1 (a,b,c) SELECT seq, '2020-12-12', 'x' FROM seq_1_to_20; -ALTER TABLE t1 DISABLE KEYS; -SET GLOBAL c.key_buffer_size= 13700864; ---error ER_WRONG_VALUE_COUNT_ON_ROW -INSERT INTO t1 SELECT 1; -SET GLOBAL c.key_buffer_size= 0; - -DROP TABLE t1; -SET GLOBAL key_buffer_size= @buffer_size.save; diff --git a/mysql-test/main/myisampack.result b/mysql-test/main/myisampack.result index 13321695360..61ad21a6c9f 100644 --- a/mysql-test/main/myisampack.result +++ b/mysql-test/main/myisampack.result @@ -1,6 +1,6 @@ DROP TABLE IF EXISTS t1,t2,t3; CREATE TABLE t1(c1 DOUBLE, c2 DOUBLE, c3 DOUBLE, c4 DOUBLE, c5 DOUBLE, -c6 DOUBLE, c7 DOUBLE, c8 DOUBLE, c9 DOUBLE, a INT PRIMARY KEY); +c6 DOUBLE, c7 DOUBLE, c8 DOUBLE, c9 DOUBLE, a INT PRIMARY KEY) checksum=1; INSERT INTO t1 VALUES (-3.31168791059336e-06,-3.19054655887874e-06,-1.06528081684847e-05,-1.227278240089e-06,-1.66718069164799e-06,-2.59038972510885e-06,-2.83145227805303e-06,-4.09678491270648e-07,-2.22610091291797e-06,6), (0.0030743000272545,2.53222044316438e-05,2.78674650061845e-05,1.95914465544536e-05,1.7347572525984e-05,1.87513810069614e-05,1.69882826885005e-05,2.44449336987598e-05,1.89914629921774e-05,9), diff --git a/mysql-test/main/myisampack.test b/mysql-test/main/myisampack.test index 1f97a28e6fd..a63f0bcd484 100644 --- a/mysql-test/main/myisampack.test +++ b/mysql-test/main/myisampack.test @@ -5,7 +5,7 @@ DROP TABLE IF EXISTS t1,t2,t3; # BUG#31277 - myisamchk --unpack corrupts a table # CREATE TABLE t1(c1 DOUBLE, c2 DOUBLE, c3 DOUBLE, c4 DOUBLE, c5 DOUBLE, - c6 DOUBLE, c7 DOUBLE, c8 DOUBLE, c9 DOUBLE, a INT PRIMARY KEY); + c6 DOUBLE, c7 DOUBLE, c8 DOUBLE, c9 DOUBLE, a INT PRIMARY KEY) checksum=1; INSERT INTO t1 VALUES (-3.31168791059336e-06,-3.19054655887874e-06,-1.06528081684847e-05,-1.227278240089e-06,-1.66718069164799e-06,-2.59038972510885e-06,-2.83145227805303e-06,-4.09678491270648e-07,-2.22610091291797e-06,6), (0.0030743000272545,2.53222044316438e-05,2.78674650061845e-05,1.95914465544536e-05,1.7347572525984e-05,1.87513810069614e-05,1.69882826885005e-05,2.44449336987598e-05,1.89914629921774e-05,9), diff --git a/mysql-test/main/mysql-metadata.result b/mysql-test/main/mysql-metadata.result new file mode 100644 index 00000000000..1530465eaf8 --- /dev/null +++ b/mysql-test/main/mysql-metadata.result @@ -0,0 +1,92 @@ +# +# MDEV-17832 Protocol: extensions for Pluggable types and JSON, GEOMETRY +# +SET NAMES utf8; +CREATE TABLE t1 ( +js0 JSON, +js1 TEXT CHECK (JSON_VALID(js1)), +js2 TEXT CHECK (LENGTH(js2) > 0 AND JSON_VALID(js2)), +js3 TEXT CHECK (LENGTH(js2) > 0 OR JSON_VALID(js2)) +) CHARACTER SET utf8; +-------------- +SELECT * FROM t1 +-------------- + +Field 1: `js0` +Org_field: `js0` +Catalog: `def` +Database: `test` +Table: `t1` +Org_table: `t1` +Type: BLOB (format=json) +Collation: latin1_swedish_ci (8) +Length: 4294967295 +Max_length: 0 +Decimals: 0 +Flags: BLOB BINARY + +Field 2: `js1` +Org_field: `js1` +Catalog: `def` +Database: `test` +Table: `t1` +Org_table: `t1` +Type: BLOB (format=json) +Collation: latin1_swedish_ci (8) +Length: 65535 +Max_length: 0 +Decimals: 0 +Flags: BLOB + +Field 3: `js2` +Org_field: `js2` +Catalog: `def` +Database: `test` +Table: `t1` +Org_table: `t1` +Type: BLOB (format=json) +Collation: latin1_swedish_ci (8) +Length: 65535 +Max_length: 0 +Decimals: 0 +Flags: BLOB + +Field 4: `js3` +Org_field: `js3` +Catalog: `def` +Database: `test` +Table: `t1` +Org_table: `t1` +Type: BLOB +Collation: latin1_swedish_ci (8) +Length: 65535 +Max_length: 0 +Decimals: 0 +Flags: BLOB + + +0 rows in set (TIME) + +Bye +-------------- +SELECT JSON_COMPACT(js0) FROM t1 +-------------- + +Field 1: `JSON_COMPACT(js0)` +Org_field: `` +Catalog: `def` +Database: `` +Table: `` +Org_table: `` +Type: LONG_BLOB (format=json) +Collation: latin1_swedish_ci (8) +Length: 4294967295 +Max_length: 0 +Decimals: 0 +Flags: BINARY + + +0 rows in set (TIME) + +Bye +DROP TABLE t1; diff --git a/mysql-test/main/mysql-metadata.test b/mysql-test/main/mysql-metadata.test new file mode 100644 index 00000000000..bab44496f78 --- /dev/null +++ b/mysql-test/main/mysql-metadata.test @@ -0,0 +1,22 @@ +-- source include/have_working_dns.inc +-- source include/not_embedded.inc + +--echo # +--echo # MDEV-17832 Protocol: extensions for Pluggable types and JSON, GEOMETRY +--echo # + +SET NAMES utf8; +CREATE TABLE t1 ( + js0 JSON, + js1 TEXT CHECK (JSON_VALID(js1)), + js2 TEXT CHECK (LENGTH(js2) > 0 AND JSON_VALID(js2)), + js3 TEXT CHECK (LENGTH(js2) > 0 OR JSON_VALID(js2)) +) CHARACTER SET utf8; + +--replace_regex /0 rows in set [(].*[)]/0 rows in set (TIME)/ +--exec $MYSQL -vvv --column-type-info --database=test -e "SELECT * FROM t1;" + +--replace_regex /0 rows in set [(].*[)]/0 rows in set (TIME)/ +--exec $MYSQL -vvv --column-type-info --database=test -e "SELECT JSON_COMPACT(js0) FROM t1;" + +DROP TABLE t1; diff --git a/mysql-test/main/mysql_json_mysql_upgrade.result b/mysql-test/main/mysql_json_mysql_upgrade.result new file mode 100644 index 00000000000..05863bb3591 --- /dev/null +++ b/mysql-test/main/mysql_json_mysql_upgrade.result @@ -0,0 +1,198 @@ +# +# MDEV-24093: Detect during mysql_upgrade if type_mysql_json.so +# is needed and load it +# +SET NAMES utf8; +show create table mysql_json_test; +ERROR HY000: Unknown data type: 'MYSQL_JSON' +Phase 1/7: Checking and upgrading mysql database +Processing databases +mysql +mysql.column_stats OK +mysql.columns_priv OK +mysql.db OK +mysql.event OK +mysql.func OK +mysql.global_priv OK +mysql.gtid_slave_pos OK +mysql.help_category OK +mysql.help_keyword OK +mysql.help_relation OK +mysql.help_topic OK +mysql.index_stats OK +mysql.innodb_index_stats +Error : Unknown storage engine 'InnoDB' +error : Corrupt +mysql.innodb_table_stats +Error : Unknown storage engine 'InnoDB' +error : Corrupt +mysql.plugin OK +mysql.proc OK +mysql.procs_priv OK +mysql.proxies_priv OK +mysql.roles_mapping OK +mysql.servers OK +mysql.table_stats OK +mysql.tables_priv OK +mysql.time_zone OK +mysql.time_zone_leap_second OK +mysql.time_zone_name OK +mysql.time_zone_transition OK +mysql.time_zone_transition_type OK +mysql.transaction_registry +Error : Unknown storage engine 'InnoDB' +error : Corrupt + +Repairing tables +mysql.innodb_index_stats +Error : Unknown storage engine 'InnoDB' +error : Corrupt +mysql.innodb_table_stats +Error : Unknown storage engine 'InnoDB' +error : Corrupt +mysql.transaction_registry +Error : Unknown storage engine 'InnoDB' +error : Corrupt +Phase 2/7: Installing used storage engines... Skipped +installing plugin for MYSQL_JSON data type +Phase 3/7: Fixing views +mysql.user OK +Phase 4/7: Running 'mysql_fix_privilege_tables' +Phase 5/7: Fixing table and database names +Phase 6/7: Checking and upgrading tables +Processing databases +information_schema +mtr +mtr.global_suppressions OK +mtr.test_suppressions OK +performance_schema +test +test.mysql_json_test Needs upgrade +test.mysql_json_test_big Needs upgrade + +Repairing tables +test.mysql_json_test OK +test.mysql_json_test_big OK +uninstalling plugin for 'type_mysql_json' data type +Phase 7/7: Running 'FLUSH PRIVILEGES' +OK +show create table mysql_json_test; +Table Create Table +mysql_json_test CREATE TABLE `mysql_json_test` ( + `description` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `expected` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `actual` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci +select * from mysql_json_test; +description expected actual +Raw integers as JSON 0 0 +Raw integers as JSON -127 -127 +Raw integers as JSON 128 128 +Raw integers as JSON 32767 32767 +Raw integers as JSON -32768 -32768 +Raw integers as JSON 65535 65535 +Raw integers as JSON 65536 65536 +Raw integers as JSON -2147483648 -2147483648 +Raw integers as JSON 2147483647 2147483647 +Raw integers as JSON 4294967295 4294967295 +Raw integers as JSON -9223372036854775807 -9223372036854775807 +Raw integers as JSON 9223372036854775807 9223372036854775807 +Raw integers as JSON 18446744073709551615 18446744073709551615 +Raw doubles as JSON 3.14 3.14 +Raw doubles as JSON -5678.987 -5678.987 +Raw doubles as JSON -2.2250738585072014e-308 -2.2250738585072014e-308 +Raw doubles as JSON 2.2250738585072014e-308 2.2250738585072014e-308 +Simple JSON test {"key1": "val1", "key2": "val2"} {"key1": "val1", "key2": "val2"} +Raw doubles as JSON 0.0 0.0 +Simple Array as Value {"a": [1, 2], "b": ["x", "y"]} {"a": [1, 2], "b": ["x", "y"]} +Simple Array as Base Key [1, 2, 3, 4, 5, [], "a", "b", "c"] [1, 2, 3, 4, 5, [], "a", "b", "c"] +GeoJSON {"type": "MultiPoint", "coordinates": [[1, 1], [2, 2], [3, 3]]} {"type": "MultiPoint", "coordinates": [[1, 1], [2, 2], [3, 3]]} +GeoJSON {"type": "LineString", "coordinates": [[0, 5], [5, 10], [10, 15]]} {"type": "LineString", "coordinates": [[0, 5], [5, 10], [10, 15]]} +GeoJSON {"type": "GeometryCollection", "geometries": []} {"type": "GeometryCollection", "geometries": []} +GeoJSON {"type": "Point", "coordinates": [11.1111, 12.22222]} {"type": "Point", "coordinates": [11.1111, 12.22222]} +Opaque Types: opaque_mysql_type_set "b,c" "b,c" +Opaque Types: opaque_mysql_type_enum "b" "b" +Opaque Types: opaque_mysql_type_date "2015-01-15" "2015-01-15" +Opaque Types: opaque_mysql_type_time "23:24:25.000000" "23:24:25.000000" +Opaque Types: opaque_mysql_type_datetime "2015-01-15 23:24:25.000000" "2015-01-15 23:24:25.000000" +Opaque Types: opaque_mysql_type_geom {"type": "Point", "coordinates": [1, 1]} {"type": "Point", "coordinates": [1, 1]} +Opaque Types: opaque_mysql_type_bit "base64:type16:yv4=" "base64:type16:yv4=" +Opaque Types: opaque_mysql_type_year "base64:type13:MjAxOQ==" "base64:type13:MjAxOQ==" +Opaque Types: opaque_mysql_type_blob "base64:type252:yv66vg==" "base64:type252:yv66vg==" +Opaque Types: opaque_mysql_type_longblob "base64:type251:yv66vg==" "base64:type251:yv66vg==" +Opaque Types: opaque_mysql_type_mediumblob "base64:type250:yv66vg==" "base64:type250:yv66vg==" +Opaque Types: opaque_mysql_type_tinyblob "base64:type249:yv66vg==" "base64:type249:yv66vg==" +Opaque Types: opaque_mysql_type_varchar "base64:type15:Zm9v" "base64:type15:Zm9v" +DateTime as Raw Value: "2015-01-15 23:24:25.000000" "2015-01-15 23:24:25.000000" +Opaque Types: opaque_mysql_type_varbinary "base64:type15:YWJj" "base64:type15:YWJj" +Opaque Types: opaque_mysql_type_binary "base64:type254:YWJjAAAAAAAAAA==" "base64:type254:YWJjAAAAAAAAAA==" +DateTime as Raw Value: "23:24:25.000000" "23:24:25.000000" +DateTime as Raw Value: "2015-01-15" "2015-01-15" +DateTime as Raw Value: "2015-01-15 23:24:25.000000" "2015-01-15 23:24:25.000000" +UTF8 Characters: {"Person": "EMP", "details": {"Name": "Anel Husaković - test: đžšćÄ"}} {"Person": "EMP", "details": {"Name": "Anel Husaković - test: đžšćÄ"}} +UTF8 Characters: "Anel Husaković - test: đžšćÄ" "Anel Husaković - test: đžšćÄ" +UTF8 Characters: {"Name": "Anel Husaković - test: đžšćÄ"} {"Name": "Anel Husaković - test: đžšćÄ"} +UTF8 Characters: {"details": {"Name": "Anel Husaković - test: đžšćÄ"}, "\"Anel Husaković - test: đžšćÄ\"": "EMP"} {"details": {"Name": "Anel Husaković - test: đžšćÄ"}, "\"Anel Husaković - test: đžšćÄ\"": "EMP"} +Special Characters: {"{": "}"} {"{": "}"} +Special Characters: "key1 - with \" val " "key1 - with \" val " +Special Characters: {"key1 and \n\"key2\"": "val1\t val2"} {"key1 and \n\"key2\"": "val1\t val2"} +Special Characters: "'" "'" +Special Characters: "q" "q" +Special Characters: {"[": "]"} {"[": "]"} +Special Characters: {"{": "}"} {"{": "}"} +Empty JSON Object/Array: [] [] +Special Characters: "some_string" "some_string" +Special Characters: "'" "'" +Special Characters: "\"" "\"" +Special Characters: "" "" +Special Characters: "'" "'" +Special Characters: "''" "''" +Empty JSON Object/Array: {} {} +Special Characters: "f" "f" +Special Characters: "\\" "\\" +Special Characters: "\n" "\n" +Special Characters: "\f" "\f" +Special Characters: "\t" "\t" +Special Characters: "\r" "\r" +Special Characters: "\b" "\b" +Special Characters: "\\b" "\\b" +Special Characters: {"key \n key": "val \n val"} {"key \n key": "val \n val"} +Special Characters: {"key \f key": "val \f val"} {"key \f key": "val \f val"} +Special Characters: {"key \t key": "val \t val"} {"key \t key": "val \t val"} +Special Characters: {"key \r key": "val \r val"} {"key \r key": "val \r val"} +Special Characters: {"key \b key": "val \b val"} {"key \b key": "val \b val"} +Special Characters: {"key \\0 key": "val \n val"} {"key \\0 key": "val \n val"} +Special Characters: {"key \\ key": "val \\ val"} {"key \\ key": "val \\ val"} +Special Characters: {"key \" key": "val \" val"} {"key \" key": "val \" val"} +Special Characters: {"key ' key": "val ' val"} {"key ' key": "val ' val"} +Special Characters: {"key \\Z key": "val ' val"} {"key \\Z key": "val ' val"} +Special Characters: ["a \f b", "c \f d"] ["a \f b", "c \f d"] +Special Characters: ["a \t b", "c \t d"] ["a \t b", "c \t d"] +Special Characters: ["a \r b", "c \r d"] ["a \r b", "c \r d"] +Special Characters: ["a \b b", "c \b d"] ["a \b b", "c \b d"] +Special Characters: ["a \\ b", "c \\ d"] ["a \\ b", "c \\ d"] +Special Characters: ["a \" b", "c \" d"] ["a \" b", "c \" d"] +Special Characters: ["a ' b", "c ' d"] ["a ' b", "c ' d"] +Special String Cases: {"": ""} {"": ""} +Special String Cases: [""] [""] +Raw LITERALS: true true +Raw LITERALS: false false +Raw LITERALS: null null +JSON LITERALS: {"val": true} {"val": true} +JSON LITERALS: {"val": false} {"val": false} +JSON LITERALS: {"val": null} {"val": null} +Timestamp as RawValue "2019-12-26 19:56:03.000000" "2019-12-26 19:56:03.000000" +Array LITERALS: ["prefix", null, "suffix", 1] ["prefix", null, "suffix", 1] +Array LITERALS: ["prefix", false, "suffix", 1] ["prefix", false, "suffix", 1] +Array LITERALS: ["prefix", true, "suffix", 1] ["prefix", true, "suffix", 1] +show create table mysql_json_test_big; +Table Create Table +mysql_json_test_big CREATE TABLE `mysql_json_test_big` ( + `description` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `expected` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `actual` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci +select * from mysql.plugin; +name dl +drop table mysql_json_test; +drop table mysql_json_test_big; diff --git a/mysql-test/main/mysql_json_mysql_upgrade.test b/mysql-test/main/mysql_json_mysql_upgrade.test new file mode 100644 index 00000000000..4380b004c70 --- /dev/null +++ b/mysql-test/main/mysql_json_mysql_upgrade.test @@ -0,0 +1,36 @@ +--echo # +--echo # MDEV-24093: Detect during mysql_upgrade if type_mysql_json.so +--echo # is needed and load it +--echo # + +-- source include/have_utf8.inc +-- source include/mysql_upgrade_preparation.inc + +if (!$TYPE_MYSQL_JSON_SO) { + skip Need MYSQL_JSON plugin; +} + +SET NAMES utf8; + +let $MYSQLD_DATADIR= `select @@datadir`; + +--copy_file std_data/mysql_json/mysql_json_test.frm $MYSQLD_DATADIR/test/mysql_json_test.frm +--copy_file std_data/mysql_json/mysql_json_test.MYI $MYSQLD_DATADIR/test/mysql_json_test.MYI +--copy_file std_data/mysql_json/mysql_json_test.MYD $MYSQLD_DATADIR/test/mysql_json_test.MYD + +--copy_file std_data/mysql_json/mysql_json_test_big.frm $MYSQLD_DATADIR/test/mysql_json_test_big.frm +--copy_file std_data/mysql_json/mysql_json_test_big.MYI $MYSQLD_DATADIR/test/mysql_json_test_big.MYI +--copy_file std_data/mysql_json/mysql_json_test_big.MYD $MYSQLD_DATADIR/test/mysql_json_test_big.MYD + +--error ER_UNKNOWN_DATA_TYPE +show create table mysql_json_test; + +--exec $MYSQL_UPGRADE --force 2>&1 +--remove_file $MYSQLD_DATADIR/mysql_upgrade_info + +show create table mysql_json_test; +select * from mysql_json_test; +show create table mysql_json_test_big; +select * from mysql.plugin; +drop table mysql_json_test; +drop table mysql_json_test_big; diff --git a/mysql-test/main/mysql_json_mysql_upgrade_with_plugin_loaded.result b/mysql-test/main/mysql_json_mysql_upgrade_with_plugin_loaded.result new file mode 100644 index 00000000000..0b2e7af84eb --- /dev/null +++ b/mysql-test/main/mysql_json_mysql_upgrade_with_plugin_loaded.result @@ -0,0 +1,95 @@ +# +# MDEV-24093: Detect during mysql_upgrade if type_mysql_json.so +# is needed and load it +# +SET NAMES utf8; +call mtr.add_suppression("Table rebuild required"); +show create table mysql_json_test; +ERROR HY000: Table rebuild required. Please do "ALTER TABLE `test.mysql_json_test` FORCE" or dump/reload to fix it! +Phase 1/7: Checking and upgrading mysql database +Processing databases +mysql +mysql.column_stats OK +mysql.columns_priv OK +mysql.db OK +mysql.event OK +mysql.func OK +mysql.global_priv OK +mysql.gtid_slave_pos OK +mysql.help_category OK +mysql.help_keyword OK +mysql.help_relation OK +mysql.help_topic OK +mysql.index_stats OK +mysql.innodb_index_stats +Error : Unknown storage engine 'InnoDB' +error : Corrupt +mysql.innodb_table_stats +Error : Unknown storage engine 'InnoDB' +error : Corrupt +mysql.plugin OK +mysql.proc OK +mysql.procs_priv OK +mysql.proxies_priv OK +mysql.roles_mapping OK +mysql.servers OK +mysql.table_stats OK +mysql.tables_priv OK +mysql.time_zone OK +mysql.time_zone_leap_second OK +mysql.time_zone_name OK +mysql.time_zone_transition OK +mysql.time_zone_transition_type OK +mysql.transaction_registry +Error : Unknown storage engine 'InnoDB' +error : Corrupt + +Repairing tables +mysql.innodb_index_stats +Error : Unknown storage engine 'InnoDB' +error : Corrupt +mysql.innodb_table_stats +Error : Unknown storage engine 'InnoDB' +error : Corrupt +mysql.transaction_registry +Error : Unknown storage engine 'InnoDB' +error : Corrupt +Phase 2/7: Installing used storage engines... Skipped +Phase 3/7: Fixing views +mysql.user OK +Phase 4/7: Running 'mysql_fix_privilege_tables' +Phase 5/7: Fixing table and database names +Phase 6/7: Checking and upgrading tables +Processing databases +information_schema +mtr +mtr.global_suppressions OK +mtr.test_suppressions OK +performance_schema +test +test.mysql_json_test Needs upgrade +test.mysql_json_test_big Needs upgrade + +Repairing tables +test.mysql_json_test OK +test.mysql_json_test_big OK +Phase 7/7: Running 'FLUSH PRIVILEGES' +OK +show create table mysql_json_test; +Table Create Table +mysql_json_test CREATE TABLE `mysql_json_test` ( + `description` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `expected` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `actual` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci +show create table mysql_json_test_big; +Table Create Table +mysql_json_test_big CREATE TABLE `mysql_json_test_big` ( + `description` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `expected` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `actual` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci +select * from mysql.plugin; +name dl +drop table mysql_json_test; +drop table mysql_json_test_big; diff --git a/mysql-test/main/mysql_json_mysql_upgrade_with_plugin_loaded.test b/mysql-test/main/mysql_json_mysql_upgrade_with_plugin_loaded.test new file mode 100644 index 00000000000..f3e9c2e539a --- /dev/null +++ b/mysql-test/main/mysql_json_mysql_upgrade_with_plugin_loaded.test @@ -0,0 +1,35 @@ +--echo # +--echo # MDEV-24093: Detect during mysql_upgrade if type_mysql_json.so +--echo # is needed and load it +--echo # +# Let's now load plugin first +-- source include/have_utf8.inc +-- source include/have_type_mysql_json.inc +-- source include/mysql_upgrade_preparation.inc + +SET NAMES utf8; +call mtr.add_suppression("Table rebuild required"); + +let $MYSQLD_DATADIR= `select @@datadir`; + +--copy_file std_data/mysql_json/mysql_json_test.frm $MYSQLD_DATADIR/test/mysql_json_test.frm +--copy_file std_data/mysql_json/mysql_json_test.MYI $MYSQLD_DATADIR/test/mysql_json_test.MYI +--copy_file std_data/mysql_json/mysql_json_test.MYD $MYSQLD_DATADIR/test/mysql_json_test.MYD + +--copy_file std_data/mysql_json/mysql_json_test_big.frm $MYSQLD_DATADIR/test/mysql_json_test_big.frm +--copy_file std_data/mysql_json/mysql_json_test_big.MYI $MYSQLD_DATADIR/test/mysql_json_test_big.MYI +--copy_file std_data/mysql_json/mysql_json_test_big.MYD $MYSQLD_DATADIR/test/mysql_json_test_big.MYD + +# In the previous example (mysql_json_mysql_upgrade.test) +# instead of ER_TABLE_NEEDS_REBUILD we had ER_UNKNOWN_DATA_TYPE +--error ER_TABLE_NEEDS_REBUILD +show create table mysql_json_test; + +--exec $MYSQL_UPGRADE --force 2>&1 +--remove_file $MYSQLD_DATADIR/mysql_upgrade_info + +show create table mysql_json_test; +show create table mysql_json_test_big; +select * from mysql.plugin; +drop table mysql_json_test; +drop table mysql_json_test_big; diff --git a/mysql-test/main/mysql_json_table_recreate.opt b/mysql-test/main/mysql_json_table_recreate.opt new file mode 100644 index 00000000000..135fd2b77b8 --- /dev/null +++ b/mysql-test/main/mysql_json_table_recreate.opt @@ -0,0 +1 @@ +--plugin-load=$TYPE_MYSQL_JSON_SO diff --git a/mysql-test/main/mysql_json_table_recreate.result b/mysql-test/main/mysql_json_table_recreate.result new file mode 100644 index 00000000000..3dfc6d7a259 --- /dev/null +++ b/mysql-test/main/mysql_json_table_recreate.result @@ -0,0 +1,171 @@ +# +# The following test takes 2 tables containing a JSON column and attempts +# to repair them. +# +# The tables header is (Description, Expected, Actual), where description +# shows a brief description what the JSON value is testing in the MariaDB +# implementation. Expected is the longtext string and actual is the JSON +# column that needs to be converted to MariaDB's representation of +# LONGTEXT. +# +call mtr.add_suppression("Table rebuild required"); +call mtr.add_suppression("is marked as crashed"); +call mtr.add_suppression("Checking"); +SET NAMES utf8; +# +# Check that only ALTER TABLE ... FORCE is allowed on a MySQL 5.7 table +# with a JSON column. +# +show create table tempty; +ERROR HY000: Table rebuild required. Please do "ALTER TABLE `test.tempty` FORCE" or dump/reload to fix it! +select * from tempty; +ERROR HY000: Table rebuild required. Please do "ALTER TABLE `test.tempty` FORCE" or dump/reload to fix it! +alter table tempty force; +show create table tempty; +Table Create Table +tempty CREATE TABLE `tempty` ( + `t` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +show create table mysql_json_test; +ERROR HY000: Table rebuild required. Please do "ALTER TABLE `test.mysql_json_test` FORCE" or dump/reload to fix it! +select * from mysql_json_test; +ERROR HY000: Table rebuild required. Please do "ALTER TABLE `test.mysql_json_test` FORCE" or dump/reload to fix it! +LOCK TABLES mysql_json_test WRITE; +ERROR HY000: Table rebuild required. Please do "ALTER TABLE `test.mysql_json_test` FORCE" or dump/reload to fix it! +alter table mysql_json_test force; +select description, expected, actual, expected = actual from mysql_json_test; +description expected actual expected = actual +Array LITERALS: ["prefix", false, "suffix", 1] ["prefix", false, "suffix", 1] 1 +Array LITERALS: ["prefix", null, "suffix", 1] ["prefix", null, "suffix", 1] 1 +Array LITERALS: ["prefix", true, "suffix", 1] ["prefix", true, "suffix", 1] 1 +DateTime as Raw Value: "2015-01-15 23:24:25.000000" "2015-01-15 23:24:25.000000" 1 +DateTime as Raw Value: "2015-01-15 23:24:25.000000" "2015-01-15 23:24:25.000000" 1 +DateTime as Raw Value: "2015-01-15" "2015-01-15" 1 +DateTime as Raw Value: "23:24:25.000000" "23:24:25.000000" 1 +Empty JSON Object/Array: [] [] 1 +Empty JSON Object/Array: {} {} 1 +GeoJSON {"type": "GeometryCollection", "geometries": []} {"type": "GeometryCollection", "geometries": []} 1 +GeoJSON {"type": "LineString", "coordinates": [[0, 5], [5, 10], [10, 15]]} {"type": "LineString", "coordinates": [[0, 5], [5, 10], [10, 15]]} 1 +GeoJSON {"type": "MultiPoint", "coordinates": [[1, 1], [2, 2], [3, 3]]} {"type": "MultiPoint", "coordinates": [[1, 1], [2, 2], [3, 3]]} 1 +GeoJSON {"type": "Point", "coordinates": [11.1111, 12.22222]} {"type": "Point", "coordinates": [11.1111, 12.22222]} 1 +JSON LITERALS: {"val": false} {"val": false} 1 +JSON LITERALS: {"val": null} {"val": null} 1 +JSON LITERALS: {"val": true} {"val": true} 1 +Opaque Types: opaque_mysql_type_binary "base64:type254:YWJjAAAAAAAAAA==" "base64:type254:YWJjAAAAAAAAAA==" 1 +Opaque Types: opaque_mysql_type_bit "base64:type16:yv4=" "base64:type16:yv4=" 1 +Opaque Types: opaque_mysql_type_blob "base64:type252:yv66vg==" "base64:type252:yv66vg==" 1 +Opaque Types: opaque_mysql_type_date "2015-01-15" "2015-01-15" 1 +Opaque Types: opaque_mysql_type_datetime "2015-01-15 23:24:25.000000" "2015-01-15 23:24:25.000000" 1 +Opaque Types: opaque_mysql_type_enum "b" "b" 1 +Opaque Types: opaque_mysql_type_geom {"type": "Point", "coordinates": [1, 1]} {"type": "Point", "coordinates": [1, 1]} 1 +Opaque Types: opaque_mysql_type_longblob "base64:type251:yv66vg==" "base64:type251:yv66vg==" 1 +Opaque Types: opaque_mysql_type_mediumblob "base64:type250:yv66vg==" "base64:type250:yv66vg==" 1 +Opaque Types: opaque_mysql_type_set "b,c" "b,c" 1 +Opaque Types: opaque_mysql_type_time "23:24:25.000000" "23:24:25.000000" 1 +Opaque Types: opaque_mysql_type_tinyblob "base64:type249:yv66vg==" "base64:type249:yv66vg==" 1 +Opaque Types: opaque_mysql_type_varbinary "base64:type15:YWJj" "base64:type15:YWJj" 1 +Opaque Types: opaque_mysql_type_varchar "base64:type15:Zm9v" "base64:type15:Zm9v" 1 +Opaque Types: opaque_mysql_type_year "base64:type13:MjAxOQ==" "base64:type13:MjAxOQ==" 1 +Raw LITERALS: false false 1 +Raw LITERALS: null null 1 +Raw LITERALS: true true 1 +Raw doubles as JSON -2.2250738585072014e-308 -2.2250738585072014e-308 1 +Raw doubles as JSON -5678.987 -5678.987 1 +Raw doubles as JSON 0.0 0.0 1 +Raw doubles as JSON 2.2250738585072014e-308 2.2250738585072014e-308 1 +Raw doubles as JSON 3.14 3.14 1 +Raw integers as JSON -127 -127 1 +Raw integers as JSON -2147483648 -2147483648 1 +Raw integers as JSON -32768 -32768 1 +Raw integers as JSON -9223372036854775807 -9223372036854775807 1 +Raw integers as JSON 0 0 1 +Raw integers as JSON 128 128 1 +Raw integers as JSON 18446744073709551615 18446744073709551615 1 +Raw integers as JSON 2147483647 2147483647 1 +Raw integers as JSON 32767 32767 1 +Raw integers as JSON 4294967295 4294967295 1 +Raw integers as JSON 65535 65535 1 +Raw integers as JSON 65536 65536 1 +Raw integers as JSON 9223372036854775807 9223372036854775807 1 +Simple Array as Base Key [1, 2, 3, 4, 5, [], "a", "b", "c"] [1, 2, 3, 4, 5, [], "a", "b", "c"] 1 +Simple Array as Value {"a": [1, 2], "b": ["x", "y"]} {"a": [1, 2], "b": ["x", "y"]} 1 +Simple JSON test {"key1": "val1", "key2": "val2"} {"key1": "val1", "key2": "val2"} 1 +Special Characters: "" "" 1 +Special Characters: "'" "'" 1 +Special Characters: "'" "'" 1 +Special Characters: "'" "'" 1 +Special Characters: "''" "''" 1 +Special Characters: "\"" "\"" 1 +Special Characters: "\\" "\\" 1 +Special Characters: "\\b" "\\b" 1 +Special Characters: "\b" "\b" 1 +Special Characters: "\f" "\f" 1 +Special Characters: "\n" "\n" 1 +Special Characters: "\r" "\r" 1 +Special Characters: "\t" "\t" 1 +Special Characters: "f" "f" 1 +Special Characters: "key1 - with \" val " "key1 - with \" val " 1 +Special Characters: "q" "q" 1 +Special Characters: "some_string" "some_string" 1 +Special Characters: ["a ' b", "c ' d"] ["a ' b", "c ' d"] 1 +Special Characters: ["a \" b", "c \" d"] ["a \" b", "c \" d"] 1 +Special Characters: ["a \\ b", "c \\ d"] ["a \\ b", "c \\ d"] 1 +Special Characters: ["a \b b", "c \b d"] ["a \b b", "c \b d"] 1 +Special Characters: ["a \f b", "c \f d"] ["a \f b", "c \f d"] 1 +Special Characters: ["a \r b", "c \r d"] ["a \r b", "c \r d"] 1 +Special Characters: ["a \t b", "c \t d"] ["a \t b", "c \t d"] 1 +Special Characters: {"[": "]"} {"[": "]"} 1 +Special Characters: {"key ' key": "val ' val"} {"key ' key": "val ' val"} 1 +Special Characters: {"key \" key": "val \" val"} {"key \" key": "val \" val"} 1 +Special Characters: {"key \\ key": "val \\ val"} {"key \\ key": "val \\ val"} 1 +Special Characters: {"key \\0 key": "val \n val"} {"key \\0 key": "val \n val"} 1 +Special Characters: {"key \\Z key": "val ' val"} {"key \\Z key": "val ' val"} 1 +Special Characters: {"key \b key": "val \b val"} {"key \b key": "val \b val"} 1 +Special Characters: {"key \f key": "val \f val"} {"key \f key": "val \f val"} 1 +Special Characters: {"key \n key": "val \n val"} {"key \n key": "val \n val"} 1 +Special Characters: {"key \r key": "val \r val"} {"key \r key": "val \r val"} 1 +Special Characters: {"key \t key": "val \t val"} {"key \t key": "val \t val"} 1 +Special Characters: {"key1 and \n\"key2\"": "val1\t val2"} {"key1 and \n\"key2\"": "val1\t val2"} 1 +Special Characters: {"{": "}"} {"{": "}"} 1 +Special Characters: {"{": "}"} {"{": "}"} 1 +Special String Cases: [""] [""] 1 +Special String Cases: {"": ""} {"": ""} 1 +Timestamp as RawValue "2019-12-26 19:56:03.000000" "2019-12-26 19:56:03.000000" 1 +UTF8 Characters: "Anel Husaković - test: đžšćÄ" "Anel Husaković - test: đžšćÄ" 1 +UTF8 Characters: {"Name": "Anel Husaković - test: đžšćÄ"} {"Name": "Anel Husaković - test: đžšćÄ"} 1 +UTF8 Characters: {"Person": "EMP", "details": {"Name": "Anel Husaković - test: đžšćÄ"}} {"Person": "EMP", "details": {"Name": "Anel Husaković - test: đžšćÄ"}} 1 +UTF8 Characters: {"details": {"Name": "Anel Husaković - test: đžšćÄ"}, "\"Anel Husaković - test: đžšćÄ\"": "EMP"} {"details": {"Name": "Anel Husaković - test: đžšćÄ"}, "\"Anel Husaković - test: đžšćÄ\"": "EMP"} 1 +# +# A quick check that all rows match from the original MySQL Table. +# +select count(*) as 'Total_Number_of_Tests', +sum(expected = actual) as 'Succesful_Tests' +from mysql_json_test; +Total_Number_of_Tests Succesful_Tests +100 100 +show create table mysql_json_test; +Table Create Table +mysql_json_test CREATE TABLE `mysql_json_test` ( + `description` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `expected` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `actual` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci +show create table mysql_json_test_big; +ERROR HY000: Table rebuild required. Please do "ALTER TABLE `test.mysql_json_test_big` FORCE" or dump/reload to fix it! +select * from mysql_json_test_big; +ERROR HY000: Table rebuild required. Please do "ALTER TABLE `test.mysql_json_test_big` FORCE" or dump/reload to fix it! +# +# This test checks the long format implementation of MySQL's JSON +# Not printing the actual contents as they are not readable by a human, +# just compare the strings, make sure they match. +# +alter table mysql_json_test_big force; +select count(*) as 'Total_Number_of_Tests', +sum(expected = actual) as 'Succesful_Tests', +sum(JSON_VALID(actual)) as 'String_is_valid_JSON' +from mysql_json_test_big; +Total_Number_of_Tests Succesful_Tests String_is_valid_JSON +1 1 1 +drop table tempty; +drop table mysql_json_test; +drop table mysql_json_test_big; diff --git a/mysql-test/main/mysql_json_table_recreate.test b/mysql-test/main/mysql_json_table_recreate.test new file mode 100644 index 00000000000..a399b546591 --- /dev/null +++ b/mysql-test/main/mysql_json_table_recreate.test @@ -0,0 +1,90 @@ +--source include/have_utf8.inc +--source include/have_type_mysql_json.inc + +--echo # +--echo # The following test takes 2 tables containing a JSON column and attempts +--echo # to repair them. +--echo # +--echo # The tables header is (Description, Expected, Actual), where description +--echo # shows a brief description what the JSON value is testing in the MariaDB +--echo # implementation. Expected is the longtext string and actual is the JSON +--echo # column that needs to be converted to MariaDB's representation of +--echo # LONGTEXT. +--echo # + + +call mtr.add_suppression("Table rebuild required"); +call mtr.add_suppression("is marked as crashed"); +call mtr.add_suppression("Checking"); + +let $MYSQLD_DATADIR= `select @@datadir`; + +SET NAMES utf8; + +--copy_file std_data/mysql_json/tempty.frm $MYSQLD_DATADIR/test/tempty.frm +--copy_file std_data/mysql_json/tempty.MYI $MYSQLD_DATADIR/test/tempty.MYI +--copy_file std_data/mysql_json/tempty.MYD $MYSQLD_DATADIR/test/tempty.MYD + +--copy_file std_data/mysql_json/mysql_json_test.frm $MYSQLD_DATADIR/test/mysql_json_test.frm +--copy_file std_data/mysql_json/mysql_json_test.MYI $MYSQLD_DATADIR/test/mysql_json_test.MYI +--copy_file std_data/mysql_json/mysql_json_test.MYD $MYSQLD_DATADIR/test/mysql_json_test.MYD + +--copy_file std_data/mysql_json/mysql_json_test_big.frm $MYSQLD_DATADIR/test/mysql_json_test_big.frm +--copy_file std_data/mysql_json/mysql_json_test_big.MYI $MYSQLD_DATADIR/test/mysql_json_test_big.MYI +--copy_file std_data/mysql_json/mysql_json_test_big.MYD $MYSQLD_DATADIR/test/mysql_json_test_big.MYD + +--echo # +--echo # Check that only ALTER TABLE ... FORCE is allowed on a MySQL 5.7 table +--echo # with a JSON column. +--echo # + +--error ER_TABLE_NEEDS_REBUILD +show create table tempty; +--error ER_TABLE_NEEDS_REBUILD +select * from tempty; + +alter table tempty force; +show create table tempty; + +--error ER_TABLE_NEEDS_REBUILD +show create table mysql_json_test; +--error ER_TABLE_NEEDS_REBUILD +select * from mysql_json_test; + +--error ER_TABLE_NEEDS_REBUILD +LOCK TABLES mysql_json_test WRITE; + +alter table mysql_json_test force; + +--sorted_result +select description, expected, actual, expected = actual from mysql_json_test; + +--echo # +--echo # A quick check that all rows match from the original MySQL Table. +--echo # +select count(*) as 'Total_Number_of_Tests', + sum(expected = actual) as 'Succesful_Tests' +from mysql_json_test; + +show create table mysql_json_test; + +--error ER_TABLE_NEEDS_REBUILD +show create table mysql_json_test_big; +--error ER_TABLE_NEEDS_REBUILD +select * from mysql_json_test_big; + +--echo # +--echo # This test checks the long format implementation of MySQL's JSON +--echo # Not printing the actual contents as they are not readable by a human, +--echo # just compare the strings, make sure they match. +--echo # +alter table mysql_json_test_big force; + +select count(*) as 'Total_Number_of_Tests', + sum(expected = actual) as 'Succesful_Tests', + sum(JSON_VALID(actual)) as 'String_is_valid_JSON' +from mysql_json_test_big; + +drop table tempty; +drop table mysql_json_test; +drop table mysql_json_test_big; diff --git a/mysql-test/main/mysql_upgrade.result b/mysql-test/main/mysql_upgrade.result index c4c0af1601c..2b74c22a078 100644 --- a/mysql-test/main/mysql_upgrade.result +++ b/mysql-test/main/mysql_upgrade.result @@ -915,3 +915,62 @@ connection default; drop table mysql.global_priv; rename table mysql.global_priv_bak to mysql.global_priv; # End of 10.4 tests +# +# Check that mysql_upgrade can be run on mysqldump +# of mysql schema from previous versions +# +call mtr.add_suppression("innodb_table_stats has length mismatch in the column name table_name"); +# +# Upgrade from version 5.5 +# +# Loading dump of 5.5 mysql schema +# Running mysql_upgrade +# Checking that mysql.user is accessible and returns some data +SELECT COUNT(*) > 0 AS `mysql.user has data` FROM mysql.user; +mysql.user has data +1 +# +# Upgrade from version 10.0 +# +# Loading dump of 10.0 mysql schema +# Running mysql_upgrade +# Checking that mysql.user is accessible and returns some data +SELECT COUNT(*) > 0 AS `mysql.user has data` FROM mysql.user; +mysql.user has data +1 +# +# Upgrade from version 10.1 +# +# Loading dump of 10.1 mysql schema +# Running mysql_upgrade +# Checking that mysql.user is accessible and returns some data +SELECT COUNT(*) > 0 AS `mysql.user has data` FROM mysql.user; +mysql.user has data +1 +# +# Upgrade from version 10.2 +# +# Loading dump of 10.2 mysql schema +# Running mysql_upgrade +# Checking that mysql.user is accessible and returns some data +SELECT COUNT(*) > 0 AS `mysql.user has data` FROM mysql.user; +mysql.user has data +1 +# +# Upgrade from version 10.3 +# +# Loading dump of 10.3 mysql schema +# Running mysql_upgrade +# Checking that mysql.user is accessible and returns some data +SELECT COUNT(*) > 0 AS `mysql.user has data` FROM mysql.user; +mysql.user has data +1 +# +# Upgrade from version 10.4 +# +# Loading dump of 10.4 mysql schema +# Running mysql_upgrade +# Checking that mysql.user is accessible and returns some data +SELECT COUNT(*) > 0 AS `mysql.user has data` FROM mysql.user; +mysql.user has data +1 diff --git a/mysql-test/main/mysql_upgrade.test b/mysql-test/main/mysql_upgrade.test index afc06dfc5ee..54f47ae8657 100644 --- a/mysql-test/main/mysql_upgrade.test +++ b/mysql-test/main/mysql_upgrade.test @@ -395,3 +395,32 @@ rename table mysql.global_priv_bak to mysql.global_priv; --remove_file $MYSQLD_DATADIR/mysql_upgrade_info --echo # End of 10.4 tests + +# +# MDEV-22249 Upgrade testing between major versions in MTR +# +--echo # +--echo # Check that mysql_upgrade can be run on mysqldump +--echo # of mysql schema from previous versions +--echo # + +# The warning appears during mysql_upgrade, before the schema becomes consistent +call mtr.add_suppression("innodb_table_stats has length mismatch in the column name table_name"); + +--let $old_version= 5.5 +--source include/load_dump_and_upgrade.inc + +--let $old_version= 10.0 +--source include/load_dump_and_upgrade.inc + +--let $old_version= 10.1 +--source include/load_dump_and_upgrade.inc + +--let $old_version= 10.2 +--source include/load_dump_and_upgrade.inc + +--let $old_version= 10.3 +--source include/load_dump_and_upgrade.inc + +--let $old_version= 10.4 +--source include/load_dump_and_upgrade.inc diff --git a/mysql-test/main/mysql_upgrade_mysql_json_datatype.result b/mysql-test/main/mysql_upgrade_mysql_json_datatype.result new file mode 100644 index 00000000000..25bc70c9074 --- /dev/null +++ b/mysql-test/main/mysql_upgrade_mysql_json_datatype.result @@ -0,0 +1,104 @@ +call mtr.add_suppression("Table rebuild required"); +call mtr.add_suppression("is marked as crashed"); +call mtr.add_suppression("Checking"); +SET NAMES utf8; +set sql_mode=""; +show create table tempty; +ERROR HY000: Table rebuild required. Please do "ALTER TABLE `test.tempty` FORCE" or dump/reload to fix it! +show create table mysql_json_test; +ERROR HY000: Table rebuild required. Please do "ALTER TABLE `test.mysql_json_test` FORCE" or dump/reload to fix it! +show create table mysql_json_test_big; +ERROR HY000: Table rebuild required. Please do "ALTER TABLE `test.mysql_json_test_big` FORCE" or dump/reload to fix it! +# Run mysql_upgrade to fix the tables containing JSON. +Phase 1/7: Checking and upgrading mysql database +Processing databases +mysql +mysql.column_stats OK +mysql.columns_priv OK +mysql.db OK +mysql.event OK +mysql.func OK +mysql.global_priv OK +mysql.gtid_slave_pos OK +mysql.help_category OK +mysql.help_keyword OK +mysql.help_relation OK +mysql.help_topic OK +mysql.index_stats OK +mysql.innodb_index_stats OK +mysql.innodb_table_stats OK +mysql.plugin OK +mysql.proc OK +mysql.procs_priv OK +mysql.proxies_priv OK +mysql.roles_mapping OK +mysql.servers OK +mysql.table_stats OK +mysql.tables_priv OK +mysql.time_zone OK +mysql.time_zone_leap_second OK +mysql.time_zone_name OK +mysql.time_zone_transition OK +mysql.time_zone_transition_type OK +mysql.transaction_registry OK +Phase 2/7: Installing used storage engines... Skipped +Phase 3/7: Fixing views +mysql.user OK +Phase 4/7: Running 'mysql_fix_privilege_tables' +Phase 5/7: Fixing table and database names +Phase 6/7: Checking and upgrading tables +Processing databases +information_schema +mtr +mtr.global_suppressions OK +mtr.test_suppressions OK +performance_schema +test +test.mysql_json_test Needs upgrade +test.mysql_json_test_big Needs upgrade +test.tempty Needs upgrade + +Repairing tables +test.mysql_json_test OK +test.mysql_json_test_big OK +test.tempty OK +Phase 7/7: Running 'FLUSH PRIVILEGES' +OK +# +# Now check if the table structure is correct and that the data +# is still present. +# +show create table tempty; +Table Create Table +tempty CREATE TABLE `tempty` ( + `t` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +show create table mysql_json_test; +Table Create Table +mysql_json_test CREATE TABLE `mysql_json_test` ( + `description` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `expected` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `actual` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci +show create table mysql_json_test_big; +Table Create Table +mysql_json_test_big CREATE TABLE `mysql_json_test_big` ( + `description` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `expected` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `actual` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci +select count(*) as 'Total_Number_of_Tests', +sum(expected = actual) as 'Succesful_Tests', +sum(JSON_VALID(actual)) as 'String_is_valid_JSON' +from mysql_json_test; +Total_Number_of_Tests Succesful_Tests String_is_valid_JSON +100 100 100 +select count(*) as 'Total_Number_of_Tests', +sum(expected = actual) as 'Succesful_Tests', +sum(JSON_VALID(actual)) as 'String_is_valid_JSON' +from mysql_json_test_big; +Total_Number_of_Tests Succesful_Tests String_is_valid_JSON +1 1 1 +drop table tempty; +drop table mysql_json_test; +drop table mysql_json_test_big; diff --git a/mysql-test/main/mysql_upgrade_mysql_json_datatype.test b/mysql-test/main/mysql_upgrade_mysql_json_datatype.test new file mode 100644 index 00000000000..13d8ff5754a --- /dev/null +++ b/mysql-test/main/mysql_upgrade_mysql_json_datatype.test @@ -0,0 +1,61 @@ +-- source include/mysql_upgrade_preparation.inc +-- source include/have_working_dns.inc +-- source include/have_innodb.inc +-- source include/have_type_mysql_json.inc + +call mtr.add_suppression("Table rebuild required"); +call mtr.add_suppression("is marked as crashed"); +call mtr.add_suppression("Checking"); + +let $MYSQLD_DATADIR= `select @@datadir`; +SET NAMES utf8; + +--copy_file std_data/mysql_json/tempty.frm $MYSQLD_DATADIR/test/tempty.frm +--copy_file std_data/mysql_json/tempty.MYI $MYSQLD_DATADIR/test/tempty.MYI +--copy_file std_data/mysql_json/tempty.MYD $MYSQLD_DATADIR/test/tempty.MYD + +--copy_file std_data/mysql_json/mysql_json_test.frm $MYSQLD_DATADIR/test/mysql_json_test.frm +--copy_file std_data/mysql_json/mysql_json_test.MYI $MYSQLD_DATADIR/test/mysql_json_test.MYI +--copy_file std_data/mysql_json/mysql_json_test.MYD $MYSQLD_DATADIR/test/mysql_json_test.MYD + +--copy_file std_data/mysql_json/mysql_json_test_big.frm $MYSQLD_DATADIR/test/mysql_json_test_big.frm +--copy_file std_data/mysql_json/mysql_json_test_big.MYI $MYSQLD_DATADIR/test/mysql_json_test_big.MYI +--copy_file std_data/mysql_json/mysql_json_test_big.MYD $MYSQLD_DATADIR/test/mysql_json_test_big.MYD + + +set sql_mode=""; + +--error ER_TABLE_NEEDS_REBUILD +show create table tempty; +--error ER_TABLE_NEEDS_REBUILD +show create table mysql_json_test; +--error ER_TABLE_NEEDS_REBUILD +show create table mysql_json_test_big; + +--echo # Run mysql_upgrade to fix the tables containing JSON. +--exec $MYSQL_UPGRADE --force 2>&1 + +--echo # +--echo # Now check if the table structure is correct and that the data +--echo # is still present. +--echo # + +show create table tempty; +show create table mysql_json_test; +show create table mysql_json_test_big; + +select count(*) as 'Total_Number_of_Tests', +sum(expected = actual) as 'Succesful_Tests', +sum(JSON_VALID(actual)) as 'String_is_valid_JSON' +from mysql_json_test; + +select count(*) as 'Total_Number_of_Tests', +sum(expected = actual) as 'Succesful_Tests', +sum(JSON_VALID(actual)) as 'String_is_valid_JSON' +from mysql_json_test_big; + +drop table tempty; +drop table mysql_json_test; +drop table mysql_json_test_big; + +--remove_file $MYSQLD_DATADIR/mysql_upgrade_info diff --git a/mysql-test/main/mysql_upgrade_noengine.result b/mysql-test/main/mysql_upgrade_noengine.result index 7b7082ab007..1b915978a6d 100644 --- a/mysql-test/main/mysql_upgrade_noengine.result +++ b/mysql-test/main/mysql_upgrade_noengine.result @@ -318,3 +318,7 @@ uninstall plugin blackhole; uninstall plugin archive; drop table mysql.global_priv; rename table mysql.global_priv_bak to mysql.global_priv; +FLUSH PRIVILEGES; +SHOW GRANTS FOR root@localhost; +Grants for root@localhost GRANT ALL PRIVILEGES ON *.* TO `root`@`localhost` WITH GRANT OPTION +Grants for root@localhost GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION diff --git a/mysql-test/main/mysql_upgrade_noengine.test b/mysql-test/main/mysql_upgrade_noengine.test index e3c3e718591..efe36c355ab 100644 --- a/mysql-test/main/mysql_upgrade_noengine.test +++ b/mysql-test/main/mysql_upgrade_noengine.test @@ -1,6 +1,7 @@ # # MDEV-11942 BLACKHOLE is no longer active in 10.1 by default, mysql_upgrade not handling the situation # +source include/mysql_upgrade_preparation.inc; source include/have_innodb.inc; source include/not_embedded.inc; @@ -76,3 +77,6 @@ uninstall plugin archive; drop table mysql.global_priv; rename table mysql.global_priv_bak to mysql.global_priv; + +FLUSH PRIVILEGES; +SHOW GRANTS FOR root@localhost; diff --git a/mysql-test/main/mysql_upgrade_to_100502.result b/mysql-test/main/mysql_upgrade_to_100502.result new file mode 100644 index 00000000000..15095809092 --- /dev/null +++ b/mysql-test/main/mysql_upgrade_to_100502.result @@ -0,0 +1,119 @@ +# +# MDEV-22057 REPLICATION MASTER ADMIN is missing in root account after upgrade +# +# switching from mysql.global_priv to mysql.user +DROP VIEW mysql.user_bak; +FLUSH PRIVILEGES; +CREATE USER user_all@localhost; +GRANT ALL PRIVILEGES ON *.* TO user_all@localhost WITH GRANT OPTION; +SHOW GRANTS FOR user_all@localhost; +Grants for user_all@localhost +GRANT ALL PRIVILEGES ON *.* TO `user_all`@`localhost` WITH GRANT OPTION +CREATE USER user_super@localhost; +GRANT SUPER ON *.* TO user_super@localhost; +SHOW GRANTS FOR user_super@localhost; +Grants for user_super@localhost +GRANT SUPER, SET USER, FEDERATED ADMIN, CONNECTION ADMIN, READ_ONLY ADMIN, REPLICATION SLAVE ADMIN, BINLOG ADMIN, BINLOG REPLAY ON *.* TO `user_super`@`localhost` +CREATE USER user_super_replslave@localhost; +GRANT SUPER, REPLICATION SLAVE ON *.* TO user_super_replslave@localhost; +SHOW GRANTS FOR user_super_replslave@localhost; +Grants for user_super_replslave@localhost +GRANT SUPER, REPLICATION SLAVE, SET USER, FEDERATED ADMIN, CONNECTION ADMIN, READ_ONLY ADMIN, REPLICATION SLAVE ADMIN, REPLICATION MASTER ADMIN, BINLOG ADMIN, BINLOG REPLAY, SLAVE MONITOR ON *.* TO `user_super_replslave`@`localhost` +# +# MDEV-23610: Slave user can't run "SHOW SLAVE STATUS" anymore after upgrade to 10.5, mysql_upgrade should take of that +# +# +# Users with privilege SUPER prior to 10.5 should successfully execute +# SHOW SLAVE STATUS command +# +CREATE USER user_replsuper@localhost; +GRANT SUPER ON *.* TO user_replsuper@localhost; +SHOW GRANTS FOR user_replsuper@localhost; +Grants for user_replsuper@localhost +GRANT SUPER, SET USER, FEDERATED ADMIN, CONNECTION ADMIN, READ_ONLY ADMIN, REPLICATION SLAVE ADMIN, BINLOG ADMIN, BINLOG REPLAY ON *.* TO `user_replsuper`@`localhost` +# +# Users with privilege REPLICATION CLIENT prior to 10.5 should successfully execute +# SHOW SLAVE STATUS command +# +CREATE USER user_replclient@localhost; +GRANT REPLICATION CLIENT ON *.* TO user_replclient@localhost; +SHOW GRANTS FOR user_replclient@localhost; +Grants for user_replclient@localhost +GRANT BINLOG MONITOR ON *.* TO `user_replclient`@`localhost` +# +# Users with privilege REPLICATION SLAVE prior to 10.5 should successfully execute +# SHOW RELAYLOG EVENTS command +# +CREATE USER user_replslave@localhost; +GRANT REPLICATION SLAVE ON *.* TO user_replslave@localhost; +SHOW GRANTS FOR user_replslave@localhost; +Grants for user_replslave@localhost +GRANT REPLICATION SLAVE, REPLICATION MASTER ADMIN, SLAVE MONITOR ON *.* TO `user_replslave`@`localhost` +# mysql_upgrade --force --silent 2>&1 +FLUSH PRIVILEGES; +# +# Should get ALL PRIVILEGES WITH GRANT OPTION +# +SHOW GRANTS FOR user_all@localhost; +Grants for user_all@localhost +GRANT ALL PRIVILEGES ON *.* TO `user_all`@`localhost` WITH GRANT OPTION +# +# Should automatically get all new 10.5.2 priveleges that were splitted from SUPER +# +SHOW GRANTS FOR user_super@localhost; +Grants for user_super@localhost +GRANT SUPER, SET USER, FEDERATED ADMIN, CONNECTION ADMIN, READ_ONLY ADMIN, REPLICATION SLAVE ADMIN, BINLOG ADMIN, BINLOG REPLAY ON *.* TO `user_super`@`localhost` +# +# Should automatically get all new 10.5.2 priveleges that were splitted from SUPER, plus REPLICATION MASTER ADMIN +# +SHOW GRANTS FOR user_super_replslave@localhost; +Grants for user_super_replslave@localhost +GRANT SUPER, REPLICATION SLAVE, SET USER, FEDERATED ADMIN, CONNECTION ADMIN, READ_ONLY ADMIN, REPLICATION SLAVE ADMIN, REPLICATION MASTER ADMIN, BINLOG ADMIN, BINLOG REPLAY, SLAVE MONITOR ON *.* TO `user_super_replslave`@`localhost` +# +# MDEV-23610: Slave user can't run "SHOW SLAVE STATUS" anymore after upgrade to 10.5, mysql_upgrade should take of that +# +# +# Should automatically get BINLOG MONITOR and REPLICA MONITOR +# +SHOW GRANTS FOR user_replclient@localhost; +Grants for user_replclient@localhost +GRANT BINLOG MONITOR, SLAVE MONITOR ON *.* TO `user_replclient`@`localhost` +# +# Should automatically get REPLICA MONITOR +# +SHOW GRANTS FOR user_replslave@localhost; +Grants for user_replslave@localhost +GRANT REPLICATION SLAVE, SLAVE MONITOR ON *.* TO `user_replslave`@`localhost` +connect con1,localhost,user_super_replslave,,test; +connection con1; +SHOW SLAVE STATUS; +disconnect con1; +connect con1,localhost,user_replclient,,test; +connection con1; +SHOW SLAVE STATUS; +disconnect con1; +connect con1,localhost,user_replslave,,test; +connection con1; +SHOW RELAYLOG EVENTS; +disconnect con1; +connection default; +SELECT +json_value(Priv, '$.version_id'), +json_value(Priv, '$.access'), +user +FROM +mysql.global_priv +WHERE +host='localhost' +AND +user LIKE 'user_%'; +json_value(Priv, '$.version_id') json_value(Priv, '$.access') user +NULL 1073741823 user_all +NULL 1048576 user_replclient +NULL 524288 user_replslave +NULL 32768 user_replsuper +NULL 32768 user_super +NULL 557056 user_super_replslave +DROP TABLE mysql.global_priv; +RENAME TABLE mysql.global_priv_bak TO mysql.global_priv; +FLUSH PRIVILEGES; diff --git a/mysql-test/main/mysql_upgrade_to_100502.test b/mysql-test/main/mysql_upgrade_to_100502.test new file mode 100644 index 00000000000..b5a44080f17 --- /dev/null +++ b/mysql-test/main/mysql_upgrade_to_100502.test @@ -0,0 +1,127 @@ +-- source include/mysql_upgrade_preparation.inc +-- source include/have_working_dns.inc +-- source include/have_innodb.inc +-- source include/have_partition.inc +let $MYSQLD_DATADIR= `select @@datadir`; + + +--echo # +--echo # MDEV-22057 REPLICATION MASTER ADMIN is missing in root account after upgrade +--echo # + +--source include/switch_to_mysql_user.inc +DROP VIEW mysql.user_bak; +FLUSH PRIVILEGES; + +CREATE USER user_all@localhost; +GRANT ALL PRIVILEGES ON *.* TO user_all@localhost WITH GRANT OPTION; +SHOW GRANTS FOR user_all@localhost; + +CREATE USER user_super@localhost; +GRANT SUPER ON *.* TO user_super@localhost; +SHOW GRANTS FOR user_super@localhost; + +CREATE USER user_super_replslave@localhost; +GRANT SUPER, REPLICATION SLAVE ON *.* TO user_super_replslave@localhost; +SHOW GRANTS FOR user_super_replslave@localhost; + +--echo # +--echo # MDEV-23610: Slave user can't run "SHOW SLAVE STATUS" anymore after upgrade to 10.5, mysql_upgrade should take of that +--echo # + +--echo # +--echo # Users with privilege SUPER prior to 10.5 should successfully execute +--echo # SHOW SLAVE STATUS command +--echo # +CREATE USER user_replsuper@localhost; +GRANT SUPER ON *.* TO user_replsuper@localhost; +SHOW GRANTS FOR user_replsuper@localhost; + +--echo # +--echo # Users with privilege REPLICATION CLIENT prior to 10.5 should successfully execute +--echo # SHOW SLAVE STATUS command +--echo # +CREATE USER user_replclient@localhost; +GRANT REPLICATION CLIENT ON *.* TO user_replclient@localhost; +SHOW GRANTS FOR user_replclient@localhost; + +--echo # +--echo # Users with privilege REPLICATION SLAVE prior to 10.5 should successfully execute +--echo # SHOW RELAYLOG EVENTS command +--echo # +CREATE USER user_replslave@localhost; +GRANT REPLICATION SLAVE ON *.* TO user_replslave@localhost; +SHOW GRANTS FOR user_replslave@localhost; + +--echo # mysql_upgrade --force --silent 2>&1 +--exec $MYSQL_UPGRADE --force --silent 2>&1 +--remove_file $MYSQLD_DATADIR/mysql_upgrade_info +FLUSH PRIVILEGES; + +--echo # +--echo # Should get ALL PRIVILEGES WITH GRANT OPTION +--echo # +SHOW GRANTS FOR user_all@localhost; + +--echo # +--echo # Should automatically get all new 10.5.2 priveleges that were splitted from SUPER +--echo # +SHOW GRANTS FOR user_super@localhost; + +--echo # +--echo # Should automatically get all new 10.5.2 priveleges that were splitted from SUPER, plus REPLICATION MASTER ADMIN +--echo # +SHOW GRANTS FOR user_super_replslave@localhost; + +--echo # +--echo # MDEV-23610: Slave user can't run "SHOW SLAVE STATUS" anymore after upgrade to 10.5, mysql_upgrade should take of that +--echo # + +--echo # +--echo # Should automatically get BINLOG MONITOR and REPLICA MONITOR +--echo # +SHOW GRANTS FOR user_replclient@localhost; + +--echo # +--echo # Should automatically get REPLICA MONITOR +--echo # +SHOW GRANTS FOR user_replslave@localhost; + +--connect (con1,localhost,user_super_replslave,,test) +--connection con1 +--disable_result_log +SHOW SLAVE STATUS; +--enable_result_log +--disconnect con1 + +--connect (con1,localhost,user_replclient,,test) +--connection con1 +--disable_result_log +SHOW SLAVE STATUS; +--enable_result_log +--disconnect con1 + +--connect (con1,localhost,user_replslave,,test) +--connection con1 +--disable_ps_protocol +--disable_result_log +SHOW RELAYLOG EVENTS; +--enable_result_log +--enable_ps_protocol +--disconnect con1 + +--connection default +SELECT + json_value(Priv, '$.version_id'), + json_value(Priv, '$.access'), + user +FROM + mysql.global_priv +WHERE + host='localhost' +AND + user LIKE 'user_%'; + +DROP TABLE mysql.global_priv; +RENAME TABLE mysql.global_priv_bak TO mysql.global_priv; +FLUSH PRIVILEGES; diff --git a/mysql-test/main/mysqlbinlog-innodb.result b/mysql-test/main/mysqlbinlog-innodb.result index 9d3bcc7c776..8428e4cd74b 100644 --- a/mysql-test/main/mysqlbinlog-innodb.result +++ b/mysql-test/main/mysqlbinlog-innodb.result @@ -29,7 +29,7 @@ START TRANSACTION use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -60,7 +60,7 @@ START TRANSACTION use `foo`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/main/mysqlbinlog.result b/mysql-test/main/mysqlbinlog.result index 4c82563e0f6..83cc2ef510a 100644 --- a/mysql-test/main/mysqlbinlog.result +++ b/mysql-test/main/mysqlbinlog.result @@ -22,7 +22,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -102,7 +102,7 @@ START TRANSACTION use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -138,7 +138,7 @@ START TRANSACTION /*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -189,7 +189,7 @@ START TRANSACTION use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -216,7 +216,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -296,7 +296,7 @@ START TRANSACTION use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -332,7 +332,7 @@ START TRANSACTION /*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -383,7 +383,7 @@ START TRANSACTION use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -492,7 +492,7 @@ DELIMITER /*!*/; use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -544,7 +544,7 @@ DELIMITER /*!*/; use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -724,7 +724,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1253783037/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -778,7 +778,7 @@ DELIMITER /*!*/; ROLLBACK/*!*/; SET TIMESTAMP=1253783037/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -813,7 +813,7 @@ ROLLBACK /* added by mysqlbinlog */; DELIMITER /*!*/; SET TIMESTAMP=1266652094/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -855,7 +855,7 @@ ROLLBACK /* added by mysqlbinlog */; DELIMITER /*!*/; SET TIMESTAMP=1266652094/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -878,8 +878,19 @@ ROLLBACK /* added by mysqlbinlog */; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; End of 5.0 tests End of 5.1 tests -# Expect deprecation warning. -# Expect deprecation warning again. +# +# Expect error for invalid --base64-output argument value. +# MYSQL_BINLOG std_data/master-bin.000001 --base64-output=always 2>&1 +Unknown option to base64-output: always +Alternatives are: 'NEVER','AUTO','UNSPEC','DECODE-ROWS' +# +# Expect error for incomplete --base64-output argument. +# MYSQL_BINLOG std_data/master-bin.000001 --base64-output 2>&1 +mysqlbinlog: option '--base64-output' requires an argument +# +# Ensure --base64-output=auto outputs the same result as unspecified +# MYSQL_BINLOG -v MYSQLD_DATADIR/master-bin.000001 > MYSQLTEST_VARDIR/tmp/mysqlbinlog_nob64spec.out +# MYSQL_BINLOG --base64-output=auto -v MYSQLD_DATADIR/master-bin.000001 > MYSQLTEST_VARDIR/tmp/mysqlbinlog_b64auto.out RESET MASTER; CREATE DATABASE test1; USE test1; @@ -962,7 +973,7 @@ AAAAAAAAAAAAAAAAAAAgrgJSFzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC # Event: Query thread_id=1 exec_time=0 error_code=0 SET TIMESTAMP=1375907364/*!*/; SET @@session.pseudo_thread_id=1/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -1045,7 +1056,7 @@ AAAAAAAAAAAAAAAAAAA/rQJSGzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC # Event: Query thread_id=1 exec_time=1 error_code=0 SET TIMESTAMP=1375907141/*!*/; SET @@session.pseudo_thread_id=1/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -1128,7 +1139,7 @@ AAAAAAAAAAAAAAAAAAAnrAJSHzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC # Event: Query thread_id=1 exec_time=0 error_code=0 SET TIMESTAMP=1375906879/*!*/; SET @@session.pseudo_thread_id=1/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -1211,7 +1222,7 @@ AAAAAAAAAAAAAAAAAABbsAJSEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC # Event: Query thread_id=1 exec_time=0 error_code=0 SET TIMESTAMP=1375907933/*!*/; SET @@session.pseudo_thread_id=1/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -1257,3 +1268,21 @@ ROLLBACK /* added by mysqlbinlog */; /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; mysqlbinlog Ver VER for OS at ARCH +# +# Test --rewrite-db +# +RESET MASTER; +CREATE TABLE t1 (a int); +INSERT INTO t1 values(1); +DROP TABLE t1; +FLUSH LOGS; +ERROR: Bad syntax in rewrite-db: missing '->' + +ERROR: Bad syntax in rewrite-db: empty TO db + +ERROR: Bad syntax in rewrite-db: empty TO db + +ERROR: Bad syntax in rewrite-db: empty FROM db + +ERROR: Bad syntax in rewrite-db: empty FROM db + diff --git a/mysql-test/main/mysqlbinlog.test b/mysql-test/main/mysqlbinlog.test index e0503402bd6..c8a141404d0 100644 --- a/mysql-test/main/mysqlbinlog.test +++ b/mysql-test/main/mysqlbinlog.test @@ -130,6 +130,7 @@ select "--- reading stdin --" as ""; # postion is constant to correspond to an event in pre-recorded binlog --let $binlog_start_pos=79 --exec $MYSQL_BINLOG --short-form --start-position=$binlog_start_pos - < $MYSQL_TEST_DIR/std_data/trunc_binlog.000001 + drop table t1,t2; # @@ -520,18 +521,32 @@ remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn.empty; remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn; # -# WL#5625: Deprecate mysqlbinlog options --base64-output=always and --base64-output +# MDEV-25222: Remove mysqlbinlog options --base64-output=always and --base64-output # ---echo # Expect deprecation warning. ---exec $MYSQL_BINLOG --base64-output=always std_data/master-bin.000001 > /dev/null 2> $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn ---cat_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn +--echo # +--echo # Expect error for invalid --base64-output argument value. +--echo # MYSQL_BINLOG std_data/master-bin.000001 --base64-output=always 2>&1 +--error 1 +--exec $MYSQL_BINLOG std_data/master-bin.000001 --base64-output=always 2>&1 ---echo # Expect deprecation warning again. ---exec $MYSQL_BINLOG --base64-output std_data/master-bin.000001 > /dev/null 2> $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn ---cat_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn +--echo # +--echo # Expect error for incomplete --base64-output argument. +--echo # MYSQL_BINLOG std_data/master-bin.000001 --base64-output 2>&1 +# The error produces the absolute path of the mysqlbinlog executable, remove it. +--replace_regex /.*mysqlbinlog.*:/mysqlbinlog:/i +--error 1 +--exec $MYSQL_BINLOG std_data/master-bin.000001 --base64-output 2>&1 + +--echo # +--echo # Ensure --base64-output=auto outputs the same result as unspecified +--echo # MYSQL_BINLOG -v MYSQLD_DATADIR/master-bin.000001 > MYSQLTEST_VARDIR/tmp/mysqlbinlog_nob64spec.out +--exec $MYSQL_BINLOG -v $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_nob64spec.out +--echo # MYSQL_BINLOG --base64-output=auto -v MYSQLD_DATADIR/master-bin.000001 > MYSQLTEST_VARDIR/tmp/mysqlbinlog_b64auto.out +--exec $MYSQL_BINLOG --base64-output=auto -v $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_b64auto.out +--diff_files $MYSQLTEST_VARDIR/tmp/mysqlbinlog_nob64spec.out $MYSQLTEST_VARDIR/tmp/mysqlbinlog_b64auto.out +--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_nob64spec.out +--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_b64auto.out -# Clean up this part of the test. ---remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn # BUG#50914 # This test verifies if the approach of the mysqlbinlog prints @@ -595,3 +610,30 @@ eval SET GLOBAL SERVER_ID = $old_server_id; # replace_regex /.*mysqlbinlog(\.exe)? Ver .* for .* at [-_a-zA-Z0-9]+/mysqlbinlog Ver VER for OS at ARCH/; exec $MYSQL_BINLOG --version; + +--echo # +--echo # Test --rewrite-db +--echo # + +RESET MASTER; +CREATE TABLE t1 (a int); +INSERT INTO t1 values(1); +DROP TABLE t1; +FLUSH LOGS; + +--error 1 +--exec $MYSQL_BINLOG --rewrite-db=a --short-form $MYSQLD_DATADIR/master-bin.000001 2>&1 + +--error 1 +--exec $MYSQL_BINLOG --rewrite-db="a->" --short-form $MYSQLD_DATADIR/master-bin.000001 2>&1 + +--error 1 +--exec $MYSQL_BINLOG --rewrite-db="a-> " --short-form $MYSQLD_DATADIR/master-bin.000001 2>&1 + +--error 1 +--exec $MYSQL_BINLOG --rewrite-db="->b" --short-form $MYSQLD_DATADIR/master-bin.000001 2>&1 + +--error 1 +--exec $MYSQL_BINLOG --rewrite-db=" ->" --short-form $MYSQLD_DATADIR/master-bin.000001 2>&1 + +--exec $MYSQL_BINLOG --rewrite-db=" test -> foo " --short-form $MYSQLD_DATADIR/master-bin.000001 > /dev/null 2> $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn diff --git a/mysql-test/main/mysqlbinlog_row_compressed.result b/mysql-test/main/mysqlbinlog_row_compressed.result index cb8d60704f9..95a81c7305c 100644 --- a/mysql-test/main/mysqlbinlog_row_compressed.result +++ b/mysql-test/main/mysqlbinlog_row_compressed.result @@ -33,7 +33,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=X/*!*/; SET @@session.pseudo_thread_id=5/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/main/mysqlbinlog_row_minimal.result b/mysql-test/main/mysqlbinlog_row_minimal.result index aeaabab623a..659228a57e2 100644 --- a/mysql-test/main/mysqlbinlog_row_minimal.result +++ b/mysql-test/main/mysqlbinlog_row_minimal.result @@ -31,7 +31,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=X/*!*/; SET @@session.pseudo_thread_id=5/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -397,7 +397,7 @@ START TRANSACTION #<date> server id 1 end_log_pos END_LOG_POS CRC32 XXX Query thread_id=TID exec_time=x error_code=0 SET TIMESTAMP=X/*!*/; SET @@session.pseudo_thread_id=TID/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/main/mysqlbinlog_stmt_compressed.result b/mysql-test/main/mysqlbinlog_stmt_compressed.result index 654dff9e90d..078e6a746ff 100644 --- a/mysql-test/main/mysqlbinlog_stmt_compressed.result +++ b/mysql-test/main/mysqlbinlog_stmt_compressed.result @@ -33,7 +33,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=X/*!*/; SET @@session.pseudo_thread_id=5/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/main/mysqld--defaults-file.test b/mysql-test/main/mysqld--defaults-file.test index 91d30eb1617..9ca427568ef 100644 --- a/mysql-test/main/mysqld--defaults-file.test +++ b/mysql-test/main/mysqld--defaults-file.test @@ -4,12 +4,15 @@ source include/not_embedded.inc; source include/not_windows.inc; +source include/not_aix.inc; # All these tests refer to configuration files that do not exist +--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR --error 1 exec $MYSQLD --defaults-file=/path/with/no/extension --print-defaults 2>&1; +--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR --error 1 exec $MYSQLD --defaults-file=/path/with.ext --print-defaults 2>&1; @@ -35,7 +38,7 @@ exec $MYSQLD --defaults-file=no_extension --print-defaults 2>&1; --echo # --echo # Test on `defaults-file` ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--replace_result $MYSQLTEST_REAL_VARDIR MYSQLTEST_VARDIR exec $MYSQLD --defaults-file=$MYSQLTEST_VARDIR/my.cnf --help --verbose | grep -A 1 'Default options are read'; --echo # Test on `defaults-extra-file` diff --git a/mysql-test/main/mysqld--help,aix.rdiff b/mysql-test/main/mysqld--help,aix.rdiff index e69de29bb2d..972f8b1844b 100644 --- a/mysql-test/main/mysqld--help,aix.rdiff +++ b/mysql-test/main/mysqld--help,aix.rdiff @@ -0,0 +1,76 @@ +diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result +index 7b0ce27ead3..38176dcaa86 100644 +--- a/mysql-test/main/mysqld--help.result ++++ b/mysql-test/main/mysqld--help.result +@@ -1301,8 +1301,6 @@ The following specify which files/extra groups are read (specified before remain + WHERE clause, or a LIMIT clause, or else they will + aborted. Prevents the common mistake of accidentally + deleting or updating every row in a table. +- --stack-trace Print a symbolic stack trace on failure +- (Defaults to on; use --skip-stack-trace to disable.) + --standard-compliant-cte + Allow only CTEs compliant to SQL standard + (Defaults to on; use --skip-standard-compliant-cte to disable.) +@@ -1367,39 +1365,6 @@ The following specify which files/extra groups are read (specified before remain + --thread-cache-size=# + How many threads we should keep in a cache for reuse. + These are freed after 5 minutes of idle time +- --thread-pool-dedicated-listener +- If set to 1,listener thread will not pick up queries +- --thread-pool-exact-stats +- If set to 1, provides better statistics in +- information_schema threadpool tables +- --thread-pool-idle-timeout=# +- Timeout in seconds for an idle thread in the thread +- pool.Worker thread will be shut down after timeout +- --thread-pool-max-threads=# +- Maximum allowed number of worker threads in the thread +- pool +- --thread-pool-oversubscribe=# +- How many additional active worker threads in a group are +- allowed. +- --thread-pool-prio-kickup-timer=# +- The number of milliseconds before a dequeued low-priority +- statement is moved to the high-priority queue +- --thread-pool-priority=name +- Threadpool priority. High priority connections usually +- start executing earlier than low priority.If priority set +- to 'auto', the the actual priority(low or high) is +- determined based on whether or not connection is inside +- transaction. +- --thread-pool-size=# +- Number of thread groups in the pool. This parameter is +- roughly equivalent to maximum number of concurrently +- executing threads (threads in a waiting state do not +- count as executing). +- --thread-pool-stall-limit=# +- Maximum query execution time in milliseconds,before an +- executing non-yielding thread is considered stalled.If a +- worker thread is stalled, additional worker thread may be +- created to handle remaining clients. + --thread-stack=# The stack size for each thread + --time-format=name The TIME format (ignored) + --tls-version=name TLS protocol version for secure connections.. Any +@@ -1788,7 +1753,6 @@ slow-query-log FALSE + sort-buffer-size 2097152 + sql-mode STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION + sql-safe-updates FALSE +-stack-trace TRUE + standard-compliant-cte TRUE + stored-program-cache 256 + strict-password-validation TRUE +@@ -1807,14 +1771,6 @@ tcp-keepalive-probes 0 + tcp-keepalive-time 0 + tcp-nodelay TRUE + thread-cache-size 151 +-thread-pool-dedicated-listener FALSE +-thread-pool-exact-stats FALSE +-thread-pool-idle-timeout 60 +-thread-pool-max-threads 65536 +-thread-pool-oversubscribe 3 +-thread-pool-prio-kickup-timer 1000 +-thread-pool-priority auto +-thread-pool-stall-limit 500 + thread-stack 299008 + time-format %H:%i:%s + tmp-disk-table-size 18446744073709551615 diff --git a/mysql-test/main/mysqld--help,win.rdiff b/mysql-test/main/mysqld--help,win.rdiff index 1bdbc0fc287..337755252ba 100644 --- a/mysql-test/main/mysqld--help,win.rdiff +++ b/mysql-test/main/mysqld--help,win.rdiff @@ -1,13 +1,5 @@ --- a/mysql-test/r/mysqld--help.result +++ b/mysql-test/r/mysqld--help.result -@@ -419,7 +419,6 @@ - The number of segments in a key cache - -L, --language=name Client error messages in given language. May be given as - a full path. Deprecated. Use --lc-messages-dir instead. -- --large-pages Enable support for large pages - --lc-messages=name Set the language used for the error messages. - -L, --lc-messages-dir=name - Directory where error messages are @@ -647,6 +646,7 @@ Use MySQL-5.6 (instead of MariaDB-5.3) format for TIME, DATETIME, TIMESTAMP columns. @@ -58,14 +50,6 @@ --transaction-alloc-block-size=# Allocation block size for transactions to be stored in binary log -@@ -1513,7 +1523,6 @@ - key-cache-division-limit 100 - key-cache-file-hash-size 512 - key-cache-segments 0 --large-pages FALSE - lc-messages en_US - lc-messages-dir MYSQL_SHAREDIR/ - lc-time-names en_US @@ -1587,6 +1596,7 @@ myisam-stats-method NULLS_UNEQUAL myisam-use-mmap FALSE diff --git a/mysql-test/main/mysqld--help-aria.result b/mysql-test/main/mysqld--help-aria.result new file mode 100644 index 00000000000..70e7d8930c4 --- /dev/null +++ b/mysql-test/main/mysqld--help-aria.result @@ -0,0 +1,12 @@ +[ERROR] mariadbd: Can't lock aria aria_log_control for exclusive use, error: #. Will retry for 0 seconds +[ERROR] Plugin 'Aria' init function returned error. +[ERROR] Plugin 'Aria' registration as a STORAGE ENGINE failed. +[Warning] Could not open mysql.plugin table: "Unknown storage engine 'Aria'". Some options may be missing from the help text +# +# Check that we don't write any data to wrong or not existing datadir +# +[Warning] Could not open mysql.plugin table: "Table 'mysql.plugin' doesn't exist". Some options may be missing from the help text +# +# Check with existing directory +# +[Warning] Could not open mysql.plugin table: "Table 'mysql.plugin' doesn't exist". Some options may be missing from the help text diff --git a/mysql-test/main/mysqld--help-aria.test b/mysql-test/main/mysqld--help-aria.test new file mode 100644 index 00000000000..253a46492f0 --- /dev/null +++ b/mysql-test/main/mysqld--help-aria.test @@ -0,0 +1,39 @@ +# +# Check errors from mysqld--help when providing different datadir +# + +# We can't run this test on windows as windows doesn't provide file locking +# which the first exec requires. + +--source include/not_windows.inc + +--let $args=--table-cache=5 --max-connections=10 --log-warnings=1 --silent-startup --lower-case-table-names=1 --help --verbose + +--exec $MYSQLD_CMD $args > $MYSQL_TMP_DIR/mysqld--help2.txt 2> $MYSQL_TMP_DIR/mysqld--help2.err +--replace_regex /mysqld/mariadbd/ /\d\d\d\d-\d*-\d* *\d*:\d*:\d* \d* // /control file '.*aria_log_control'/aria_log_control/ /error: \d+/error: #/ +--cat_file $MYSQL_TMP_DIR/mysqld--help2.err + +--echo # +--echo # Check that we don't write any data to wrong or not existing datadir +--echo # + +--exec $MYSQLD_CMD $args --datadir=$MYSQL_TMP_DIR/help > $MYSQL_TMP_DIR/mysqld--help2.txt 2> $MYSQL_TMP_DIR/mysqld--help2.err +--replace_regex /\d\d\d\d-\d*-\d* *\d*:\d*:\d* \d* // +--cat_file $MYSQL_TMP_DIR/mysqld--help2.err + +--echo # +--echo # Check with existing directory +--echo # + +--mkdir $MYSQL_TMP_DIR/help +--exec $MYSQLD_CMD $args --datadir=$MYSQL_TMP_DIR/help > $MYSQL_TMP_DIR/mysqld--help2.txt 2> $MYSQL_TMP_DIR/mysqld--help2.err +--replace_regex /\d\d\d\d-\d*-\d* *\d*:\d*:\d* \d* // +--cat_file $MYSQL_TMP_DIR/mysqld--help2.err +--list_files $MYSQL_TMP_DIR/help + +# +# Cleanup +# +--rmdir $MYSQL_TMP_DIR/help +--remove_file $MYSQL_TMP_DIR/mysqld--help2.txt +--remove_file $MYSQL_TMP_DIR/mysqld--help2.err diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result index c008df32257..7b0ce27ead3 100644 --- a/mysql-test/main/mysqld--help.result +++ b/mysql-test/main/mysqld--help.result @@ -40,7 +40,7 @@ The following specify which files/extra groups are read (specified before remain --big-tables Old variable, which if set to 1, allows large result sets by saving all temporary sets to disk, avoiding 'table full' errors. No longer needed, as the server now handles - this automatically. sql_big_tables is a synonym. + this automatically. --bind-address=name IP address to bind to. --binlog-annotate-row-events Tells the master to annotate RBR events with the @@ -114,6 +114,12 @@ The following specify which files/extra groups are read (specified before remain the table) is logged in the before image, and only changed columns are logged in the after image. (Default: FULL). + --binlog-row-metadata=name + Controls whether metadata is logged using FULL , MINIMAL + format and NO_LOG.FULL causes all metadata to be logged; + MINIMAL means that only metadata actually required by + slave is logged; NO_LOG NO metadata will be + logged.Default: NO_LOG. --binlog-stmt-cache-size=# The size of the statement cache for updates to non-transactional engines for the binary log. If you @@ -196,7 +202,8 @@ The following specify which files/extra groups are read (specified before remain using the password expiration options in ALTER USER. --default-regex-flags=name Default flags for the regex library. Any combination of: - DOTALL, DUPNAMES, EXTENDED, EXTRA, MULTILINE, UNGREEDY + DOTALL, DUPNAMES, EXTENDED, EXTENDED_MORE, EXTRA, + MULTILINE, UNGREEDY --default-storage-engine=name The default storage engine for new tables --default-time-zone=name @@ -561,10 +568,6 @@ The following specify which files/extra groups are read (specified before remain max_join_size records return an error --max-length-for-sort-data=# Max number of bytes in sorted records - --max-long-data-size=# - The maximum BLOB length to send to server from - mysql_send_long_data API. Deprecated option; use - max_allowed_packet instead. --max-password-errors=# If there is more than this number of failed connect attempts due to invalid password, user will be blocked @@ -613,8 +616,6 @@ The following specify which files/extra groups are read (specified before remain Don't write queries to slow log that examine fewer rows than that --mrr-buffer-size=# Size of buffer to use when using MRR with range access - --multi-range-count=# - Ignored. Use mrr_buffer_size instead --myisam-block-size=# Block size to be used for MyISAM index pages --myisam-data-pointer-size=# @@ -680,6 +681,9 @@ The following specify which files/extra groups are read (specified before remain max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of file descriptors (Automatically configured unless set explicitly) + --optimizer-max-sel-arg-weight=# + The maximum weight of the SEL_ARG graph. Set to 0 for no + limit --optimizer-prune-level=# Controls the heuristic(s) applied during query optimization to prune less-promising partial plans from @@ -714,7 +718,7 @@ The following specify which files/extra groups are read (specified before remain extended_keys, exists_to_in, orderby_uses_equalities, condition_pushdown_for_derived, split_materialized, condition_pushdown_for_subquery, rowid_filter, - condition_pushdown_from_having + condition_pushdown_from_having, not_null_range_scan --optimizer-trace=name Controls tracing of the Optimizer: optimizer_trace=option=val[,option=val...], where option @@ -755,13 +759,21 @@ The following specify which files/extra groups are read (specified before remain --performance-schema-consumer-events-statements-current Default startup value for the events_statements_current consumer. - (Defaults to on; use --skip-performance-schema-consumer-events-statements-current to disable.) --performance-schema-consumer-events-statements-history Default startup value for the events_statements_history consumer. --performance-schema-consumer-events-statements-history-long Default startup value for the events_statements_history_long consumer. + --performance-schema-consumer-events-transactions-current + Default startup value for the events_transactions_current + consumer. + --performance-schema-consumer-events-transactions-history + Default startup value for the events_transactions_history + consumer. + --performance-schema-consumer-events-transactions-history-long + Default startup value for the + events_transactions_history_long consumer. --performance-schema-consumer-events-waits-current Default startup value for the events_waits_current consumer. @@ -797,6 +809,12 @@ The following specify which files/extra groups are read (specified before remain --performance-schema-events-statements-history-size=# Number of rows per thread in EVENTS_STATEMENTS_HISTORY. Use 0 to disable, -1 for automated sizing. + --performance-schema-events-transactions-history-long-size=# + Number of rows in EVENTS_TRANSACTIONS_HISTORY_LONG. Use 0 + to disable, -1 for automated sizing. + --performance-schema-events-transactions-history-size=# + Number of rows per thread in EVENTS_TRANSACTIONS_HISTORY. + Use 0 to disable, -1 for automated sizing. --performance-schema-events-waits-history-long-size=# Number of rows in EVENTS_WAITS_HISTORY_LONG. Use 0 to disable, -1 for automated sizing. @@ -824,11 +842,25 @@ The following specify which files/extra groups are read (specified before remain --performance-schema-max-file-instances=# Maximum number of instrumented files. Use 0 to disable, -1 for automated sizing. + --performance-schema-max-index-stat=# + Maximum number of index statistics for instrumented + tables. Use 0 to disable, -1 for automated scaling. + --performance-schema-max-memory-classes=# + Maximum number of memory pool instruments. + --performance-schema-max-metadata-locks=# + Maximum number of metadata locks. Use 0 to disable, -1 + for automated scaling. --performance-schema-max-mutex-classes=# Maximum number of mutex instruments. --performance-schema-max-mutex-instances=# Maximum number of instrumented MUTEX objects. Use 0 to disable, -1 for automated sizing. + --performance-schema-max-prepared-statements-instances=# + Maximum number of instrumented prepared statements. Use 0 + to disable, -1 for automated scaling. + --performance-schema-max-program-instances=# + Maximum number of instrumented programs. Use 0 to + disable, -1 for automated scaling. --performance-schema-max-rwlock-classes=# Maximum number of rwlock instruments. --performance-schema-max-rwlock-instances=# @@ -839,16 +871,23 @@ The following specify which files/extra groups are read (specified before remain --performance-schema-max-socket-instances=# Maximum number of opened instrumented sockets. Use 0 to disable, -1 for automated sizing. + --performance-schema-max-sql-text-length=# + Maximum length of displayed sql text. --performance-schema-max-stage-classes=# Maximum number of stage instruments. --performance-schema-max-statement-classes=# Maximum number of statement instruments. + --performance-schema-max-statement-stack=# + Number of rows per thread in EVENTS_STATEMENTS_CURRENT. --performance-schema-max-table-handles=# Maximum number of opened instrumented tables. Use 0 to disable, -1 for automated sizing. --performance-schema-max-table-instances=# Maximum number of instrumented tables. Use 0 to disable, -1 for automated sizing. + --performance-schema-max-table-lock-stat=# + Maximum number of lock statistics for instrumented + tables. Use 0 to disable, -1 for automated scaling. --performance-schema-max-thread-classes=# Maximum number of thread instruments. --performance-schema-max-thread-instances=# @@ -1046,6 +1085,10 @@ The following specify which files/extra groups are read (specified before remain not sure, leave this option unset --report-user=name The account user name of the slave to be reported to the master during slave registration + --require-secure-transport + When this option is enabled, connections attempted using + insecure transport will be rejected. Secure transports + are SSL/TLS, Unix sockets or named pipes. --rowid-merge-buff-size=# The size of the buffers used [NOT] IN evaluation via partial matching @@ -1115,8 +1158,6 @@ The following specify which files/extra groups are read (specified before remain Show user and password in SHOW SLAVE HOSTS on this master. --silent-startup Don't print [Note] to the error log during startup. - --skip-bdb Deprecated option; Exist only for compatibility with old - my.cnf files --skip-grant-tables Start without grant tables. This gives all users FULL ACCESS to all tables. --skip-host-cache Don't cache host names. @@ -1186,13 +1227,15 @@ The following specify which files/extra groups are read (specified before remain Alias for slave_parallel_threads --slave-run-triggers-for-rbr=name Modes for how triggers in row-base replication on slave - side will be executed. Legal values are NO (default), YES - and LOGGING. NO means that trigger for RBR will not be - running on slave. YES and LOGGING means that triggers - will be running on slave, if there was not triggers - running on the master for the statement. LOGGING also - means results of that the executed triggers work will be - written to the binlog. + side will be executed. Legal values are NO (default), + YES, LOGGING and ENFORCE. NO means that trigger for RBR + will not be running on slave. YES and LOGGING means that + triggers will be running on slave, if there was not + triggers running on the master for the statement. LOGGING + also means results of that the executed triggers work + will be written to the binlog. ENFORCE means that + triggers will always be run on the slave, even if there + are triggers on the master. ENFORCE implies LOGGING. --slave-skip-errors=name Tells the slave thread to continue replication when a query event returns an error from the provided list @@ -1324,6 +1367,11 @@ The following specify which files/extra groups are read (specified before remain --thread-cache-size=# How many threads we should keep in a cache for reuse. These are freed after 5 minutes of idle time + --thread-pool-dedicated-listener + If set to 1,listener thread will not pick up queries + --thread-pool-exact-stats + If set to 1, provides better statistics in + information_schema threadpool tables --thread-pool-idle-timeout=# Timeout in seconds for an idle thread in the thread pool.Worker thread will be shut down after timeout @@ -1354,8 +1402,6 @@ The following specify which files/extra groups are read (specified before remain created to handle remaining clients. --thread-stack=# The stack size for each thread --time-format=name The TIME format (ignored) - --timed-mutexes Specify whether to time mutexes. Deprecated, has no - effect. --tls-version=name TLS protocol version for secure connections.. Any combination of: TLSv1.0, TLSv1.1, TLSv1.2, TLSv1.3 --tmp-disk-table-size=# @@ -1428,6 +1474,7 @@ binlog-format MIXED binlog-optimize-thread-scheduling TRUE binlog-row-event-max-size 8192 binlog-row-image FULL +binlog-row-metadata NO_LOG binlog-stmt-cache-size 32768 bulk-insert-buffer-size 8388608 character-set-client-handshake TRUE @@ -1556,7 +1603,6 @@ max-error-count 64 max-heap-table-size 16777216 max-join-size 18446744073709551615 max-length-for-sort-data 1024 -max-long-data-size 16777216 max-password-errors 18446744073709551615 max-prepared-stmt-count 16382 max-recursive-iterations 18446744073709551615 @@ -1575,7 +1621,6 @@ metadata-locks-cache-size 1024 metadata-locks-hash-instances 8 min-examined-row-limit 0 mrr-buffer-size 262144 -multi-range-count 256 myisam-block-size 1024 myisam-data-pointer-size 6 myisam-max-sort-file-size 9223372036853727232 @@ -1595,6 +1640,7 @@ old-alter-table DEFAULT old-mode old-passwords FALSE old-style-user-limits FALSE +optimizer-max-sel-arg-weight 32000 optimizer-prune-level 1 optimizer-search-depth 62 optimizer-selectivity-sampling-limit 100 @@ -1607,9 +1653,12 @@ performance-schema-accounts-size -1 performance-schema-consumer-events-stages-current FALSE performance-schema-consumer-events-stages-history FALSE performance-schema-consumer-events-stages-history-long FALSE -performance-schema-consumer-events-statements-current TRUE +performance-schema-consumer-events-statements-current FALSE performance-schema-consumer-events-statements-history FALSE performance-schema-consumer-events-statements-history-long FALSE +performance-schema-consumer-events-transactions-current FALSE +performance-schema-consumer-events-transactions-history FALSE +performance-schema-consumer-events-transactions-history-long FALSE performance-schema-consumer-events-waits-current FALSE performance-schema-consumer-events-waits-history FALSE performance-schema-consumer-events-waits-history-long FALSE @@ -1621,6 +1670,8 @@ performance-schema-events-stages-history-long-size -1 performance-schema-events-stages-history-size -1 performance-schema-events-statements-history-long-size -1 performance-schema-events-statements-history-size -1 +performance-schema-events-transactions-history-long-size -1 +performance-schema-events-transactions-history-size -1 performance-schema-events-waits-history-long-size -1 performance-schema-events-waits-history-size -1 performance-schema-hosts-size -1 @@ -1628,24 +1679,32 @@ performance-schema-instrument performance-schema-max-cond-classes 90 performance-schema-max-cond-instances -1 performance-schema-max-digest-length 1024 -performance-schema-max-file-classes 50 +performance-schema-max-file-classes 80 performance-schema-max-file-handles 32768 performance-schema-max-file-instances -1 -performance-schema-max-mutex-classes 200 +performance-schema-max-index-stat -1 +performance-schema-max-memory-classes 320 +performance-schema-max-metadata-locks -1 +performance-schema-max-mutex-classes 210 performance-schema-max-mutex-instances -1 -performance-schema-max-rwlock-classes 40 +performance-schema-max-prepared-statements-instances -1 +performance-schema-max-program-instances -1 +performance-schema-max-rwlock-classes 50 performance-schema-max-rwlock-instances -1 performance-schema-max-socket-classes 10 performance-schema-max-socket-instances -1 +performance-schema-max-sql-text-length 1024 performance-schema-max-stage-classes 160 -performance-schema-max-statement-classes 202 +performance-schema-max-statement-classes 222 +performance-schema-max-statement-stack 10 performance-schema-max-table-handles -1 performance-schema-max-table-instances -1 +performance-schema-max-table-lock-stat -1 performance-schema-max-thread-classes 50 performance-schema-max-thread-instances -1 performance-schema-session-connect-attrs-size -1 -performance-schema-setup-actors-size 100 -performance-schema-setup-objects-size 100 +performance-schema-setup-actors-size -1 +performance-schema-setup-objects-size -1 performance-schema-users-size -1 port 3306 port-open-timeout 0 @@ -1680,6 +1739,7 @@ report-host (No default value) report-password (No default value) report-port 0 report-user (No default value) +require-secure-transport FALSE rowid-merge-buff-size 8388608 rpl-semi-sync-master-enabled FALSE rpl-semi-sync-master-timeout 10000 @@ -1747,6 +1807,8 @@ tcp-keepalive-probes 0 tcp-keepalive-time 0 tcp-nodelay TRUE thread-cache-size 151 +thread-pool-dedicated-listener FALSE +thread-pool-exact-stats FALSE thread-pool-idle-timeout 60 thread-pool-max-threads 65536 thread-pool-oversubscribe 3 @@ -1755,7 +1817,6 @@ thread-pool-priority auto thread-pool-stall-limit 500 thread-stack 299008 time-format %H:%i:%s -timed-mutexes FALSE tmp-disk-table-size 18446744073709551615 tmp-memory-table-size 16777216 tmp-table-size 16777216 diff --git a/mysql-test/main/mysqld--help.test b/mysql-test/main/mysqld--help.test index b54af092a5e..f918670d319 100644 --- a/mysql-test/main/mysqld--help.test +++ b/mysql-test/main/mysqld--help.test @@ -30,13 +30,14 @@ perl; tls-version version.*/; # Plugins which may or may not be there: - @plugins=qw/innodb archive blackhole federated partition + @plugins=qw/innodb archive blackhole federated partition s3 feedback debug temp-pool ssl des-key-file xtradb sequence thread-concurrency super-large-pages mutex-deadlock-detector connect null-audit aria oqgraph sphinx thread-handling test-sql-discovery query-cache-info query-response-time metadata-lock-info locales unix-socket - wsrep file-key-management cracklib-password-check user-variables/; + wsrep file-key-management cracklib-password-check user-variables + thread-pool-groups thread-pool-queues thread-pool-stats thread-pool-waits/; # And substitute the content some environment variables with their # names: diff --git a/mysql-test/main/mysqldump-max.result b/mysql-test/main/mysqldump-max.result index f936184849f..c1825814919 100644 --- a/mysql-test/main/mysqldump-max.result +++ b/mysql-test/main/mysqldump-max.result @@ -277,8 +277,8 @@ drop table t3; drop table t4; drop table t5; drop table t6; -SELECT @@global.storage_engine INTO @old_engine; -SET GLOBAL storage_engine=InnoDB; +SELECT @@global.default_storage_engine INTO @old_engine; +SET GLOBAL default_storage_engine=InnoDB; CREATE VIEW v1 AS SELECT * FROM t1; INSERT INTO t1 VALUES(); SELECT COUNT(*) FROM v1; @@ -289,7 +289,7 @@ COUNT(*) 1 DROP VIEW v1; DROP TABLE t1; -SET GLOBAL storage_engine=@old_engine; +SET GLOBAL default_storage_engine=@old_engine; connect c1,127.0.0.1,root,,test,$MASTER_MYPORT,; connect c2,127.0.0.1,root,,test,$MASTER_MYPORT,; connect c3,127.0.0.1,root,,test,$MASTER_MYPORT,; diff --git a/mysql-test/main/mysqldump-max.test b/mysql-test/main/mysqldump-max.test index a989fd28135..49e54d542b8 100644 --- a/mysql-test/main/mysqldump-max.test +++ b/mysql-test/main/mysqldump-max.test @@ -81,8 +81,8 @@ drop table t6; # type to avoid Inno's column-number limits (~1000 columns) etc. # Here because it needs Inno-engine. -SELECT @@global.storage_engine INTO @old_engine; -SET GLOBAL storage_engine=InnoDB; +SELECT @@global.default_storage_engine INTO @old_engine; +SET GLOBAL default_storage_engine=InnoDB; --disable_query_log CREATE TABLE `t1` ( @@ -1128,7 +1128,7 @@ SELECT COUNT(*) FROM v1; DROP VIEW v1; DROP TABLE t1; -SET GLOBAL storage_engine=@old_engine; +SET GLOBAL default_storage_engine=@old_engine; # Test fully non-locking mysqldump with consistent binlog position (MWL#136). diff --git a/mysql-test/main/mysqldump-system.result b/mysql-test/main/mysqldump-system.result index c443e250e4a..2fa010b3e4e 100644 --- a/mysql-test/main/mysqldump-system.result +++ b/mysql-test/main/mysqldump-system.result @@ -430,10 +430,10 @@ UNLOCK TABLES; SELECT * FROM mysql.global_priv ORDER BY User,Host; Host User Priv -% USER {"access":0,"plugin":"mysql_native_password","authentication_string":"","password_last_changed":NOW,"default_role":"role_2"} -localhost mariadb.sys {"access":0,"plugin":"mysql_native_password","authentication_string":"","account_locked":false,"password_last_changed":NOW} - role_1 {"access":16384,"is_role":true} - role_2 {"access":0,"is_role":true} +% USER {"access":0,"version_id":VERSION,"plugin":"mysql_native_password","authentication_string":"","password_last_changed":NOW,"default_role":"role_2"} +localhost mariadb.sys {"access":0,"plugin":"mysql_native_password","authentication_string":"","account_locked":false,"password_last_changed":NOW,"version_id":VERSION} + role_1 {"access":16384,"version_id":VERSION,"is_role":true} + role_2 {"access":0,"version_id":VERSION,"is_role":true} localhost root {"access":18446744073709551615} CHECKSUM TABLE mysql.roles_mapping, mysql.time_zone_transition, mysql.plugin, mysql.servers, mysql.func, mysql.innodb_table_stats, mysql.table_stats; @@ -465,11 +465,11 @@ set time_zone= @@global.time_zone; DROP USER mariadb_test_restore; SELECT * FROM mysql.global_priv ORDER BY User,Host; Host User Priv -% USER {"access":0,"plugin":"mysql_native_password","authentication_string":"","password_last_changed":NOW,"default_role":"role_2"} -localhost mariadb.sys {"access":0,"plugin":"mysql_native_password","authentication_string":"","password_last_changed":NOW,"password_lifetime":-1,"default_role":""} - role_1 {"access":16384,"is_role":true} - role_2 {"access":0,"is_role":true} -localhost root {"access":1073741823,"plugin":"mysql_native_password","authentication_string":"","password_last_changed":NOW,"default_role":""} +% USER {"access":0,"version_id":VERSION,"plugin":"mysql_native_password","authentication_string":"","password_last_changed":NOW,"default_role":"role_2"} +localhost mariadb.sys {"access":0,"version_id":VERSION,"plugin":"mysql_native_password","authentication_string":"","password_last_changed":NOW,"password_lifetime":-1,"default_role":""} + role_1 {"access":16384,"version_id":VERSION,"is_role":true} + role_2 {"access":0,"version_id":VERSION,"is_role":true} +localhost root {"access":549755813887,"version_id":VERSION,"plugin":"mysql_native_password","authentication_string":"","password_last_changed":NOW,"default_role":""} CHECKSUM TABLE mysql.roles_mapping, mysql.time_zone_transition, mysql.plugin, mysql.servers, mysql.func, mysql.innodb_table_stats, mysql.table_stats; Table Checksum diff --git a/mysql-test/main/mysqldump-system.test b/mysql-test/main/mysqldump-system.test index 74638bb9265..c1965410167 100644 --- a/mysql-test/main/mysqldump-system.test +++ b/mysql-test/main/mysqldump-system.test @@ -94,7 +94,7 @@ eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_SO"; # password_last_changed date isn't saved/restored # root user's Priv $.access lower number on restore ---replace_regex /"password_last_changed":[0-9]+/"password_last_changed":NOW/ +--replace_regex /"password_last_changed":[0-9]+/"password_last_changed":NOW/ /"version_id":[0-9]+/"version_id":VERSION/ SELECT * FROM mysql.global_priv ORDER BY User,Host; CHECKSUM TABLE mysql.roles_mapping, mysql.time_zone_transition, mysql.plugin, @@ -126,7 +126,7 @@ DROP USER mariadb_test_restore; # successful restore? ---replace_regex /"password_last_changed":[0-9]+/"password_last_changed":NOW/ +--replace_regex /"password_last_changed":[0-9]+/"password_last_changed":NOW/ /"version_id":[0-9]+/"version_id":VERSION/ SELECT * FROM mysql.global_priv ORDER BY User,Host; CHECKSUM TABLE mysql.roles_mapping, mysql.time_zone_transition, mysql.plugin, diff --git a/mysql-test/main/mysqldump.result b/mysql-test/main/mysqldump.result index d0d054b5473..cdccb13e892 100644 --- a/mysql-test/main/mysqldump.result +++ b/mysql-test/main/mysqldump.result @@ -3640,8 +3640,8 @@ reset master; mysqldump: Couldn't execute 'FLUSH /*!40101 LOCAL */ TABLES': Access denied; you need (at least one of) the RELOAD privilege(s) for this operation (1227) mysqldump: Couldn't execute 'FLUSH /*!40101 LOCAL */ TABLES': Access denied; you need (at least one of) the RELOAD privilege(s) for this operation (1227) grant RELOAD on *.* to mysqltest_1@localhost; -mysqldump: Couldn't execute 'SHOW MASTER STATUS': Access denied; you need (at least one of) the SUPER, REPLICATION CLIENT privilege(s) for this operation (1227) -mysqldump: Couldn't execute 'SHOW MASTER STATUS': Access denied; you need (at least one of) the SUPER, REPLICATION CLIENT privilege(s) for this operation (1227) +mysqldump: Couldn't execute 'SHOW MASTER STATUS': Access denied; you need (at least one of) the SUPER, BINLOG MONITOR privilege(s) for this operation (1227) +mysqldump: Couldn't execute 'SHOW MASTER STATUS': Access denied; you need (at least one of) the SUPER, BINLOG MONITOR privilege(s) for this operation (1227) grant REPLICATION CLIENT on *.* to mysqltest_1@localhost; drop table t1; drop user mysqltest_1@localhost; diff --git a/mysql-test/main/mysqlshow.test b/mysql-test/main/mysqlshow.test index 8c60b64a5f1..7201579452e 100644 --- a/mysql-test/main/mysqlshow.test +++ b/mysql-test/main/mysqlshow.test @@ -1,7 +1,5 @@ # Can't run test of external client with embedded server -- source include/not_embedded.inc -# Don't test when thread_pool active ---source include/not_threadpool.inc --disable_warnings DROP TABLE IF EXISTS t1,t2,test1,test2; diff --git a/mysql-test/main/mysqltest_tracking_info.result b/mysql-test/main/mysqltest_tracking_info.result index 3c474cee10f..2a58ba430ca 100644 --- a/mysql-test/main/mysqltest_tracking_info.result +++ b/mysql-test/main/mysqltest_tracking_info.result @@ -38,7 +38,7 @@ SET @@session.session_track_system_variables='optimizer_switch'; set optimizer_switch='index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,index_merge_sort_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=on,mrr_cost_based=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=on,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off'; -- Tracker : SESSION_TRACK_SYSTEM_VARIABLES -- optimizer_switch --- index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,index_merge_sort_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=on,mrr_cost_based=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=on,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on +-- index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,index_merge_sort_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=on,mrr_cost_based=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=on,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off Warnings: Warning 1681 'engine_condition_pushdown=on' is deprecated and will be removed in a future release @@ -57,3 +57,7 @@ ERROR 42000: Variable 'session_track_system_variables' can't be set to the value SET SESSION session_track_system_variables=NULL; ERROR 42000: Variable 'session_track_system_variables' can't be set to the value of 'NULL' # End of 10.3 tests +# +# MDEV-16470 - Session user variables tracker +# +# End of 10.5 tests diff --git a/mysql-test/main/mysqltest_tracking_info.test b/mysql-test/main/mysqltest_tracking_info.test index ae52571b2b9..a3dfbba53c0 100644 --- a/mysql-test/main/mysqltest_tracking_info.test +++ b/mysql-test/main/mysqltest_tracking_info.test @@ -60,3 +60,28 @@ SET @@GLOBAL.session_track_system_variables=NULL; SET SESSION session_track_system_variables=NULL; --echo # End of 10.3 tests + +--echo # +--echo # MDEV-16470 - Session user variables tracker +--echo # +#SET @@session.session_track_user_variables=1; +#--enable_session_track_info +#SET @a=1; +#SET @b=NULL; +#SELECT @c:=10; +#--disable_session_track_info +#SET @@session.session_track_user_variables=0; + +#--echo # +#--echo # mdev-22337 Assertion `Alloced_length >= (str_length + length + +#--echo net_length_size(length))' failed in Binary_string::q_net_store_data +#--echo on long MULTIPOLYGON query with session_track_user_variables=1 +#--echo (optimized builds) +#--echo # +#set @@session.session_track_user_variables=1; +#--enable_session_track_info +#set @a=repeat('X', 1029); +#--disable_session_track_info +#set @@session.session_track_user_variables=0; + +--echo # End of 10.5 tests diff --git a/mysql-test/main/named_pipe.result b/mysql-test/main/named_pipe.result index f8c2acf98a0..9fc7abd79f5 100644 --- a/mysql-test/main/named_pipe.result +++ b/mysql-test/main/named_pipe.result @@ -509,7 +509,7 @@ insert into tmp select * from t3; insert into t3 select * from tmp; alter table t3 add t2nr int not null auto_increment primary key first; drop table tmp; -SET BIG_TABLES=1; +set tmp_memory_table_size=0; select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10; namn Abraham Abraham @@ -522,7 +522,7 @@ ammonium ammonium analyzable analyzable animals animals animized animized -SET BIG_TABLES=0; +set tmp_memory_table_size=default; select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10; concat(fld3," ",fld3) Abraham Abraham @@ -559,7 +559,7 @@ attendants 1 bedlam 1 bedpost 1 boasted 1 -SET BIG_TABLES=1; +set tmp_memory_table_size=0; select distinct fld3,count(*) from t2 group by companynr,fld3 limit 10; fld3 count(*) affixed 1 @@ -572,7 +572,7 @@ attendants 1 bedlam 1 bedpost 1 boasted 1 -SET BIG_TABLES=0; +set tmp_memory_table_size=default; select distinct fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr,fld3 limit 100,10; fld3 repeat("a",length(fld3)) count(*) circus aaaaaa 1 diff --git a/mysql-test/main/named_pipe.test b/mysql-test/main/named_pipe.test index 2fe6f1cc5c0..3f01b415fc5 100644 --- a/mysql-test/main/named_pipe.test +++ b/mysql-test/main/named_pipe.test @@ -5,9 +5,6 @@ # Named pipe does not support the non-blocking API. --disable_non_blocking_api -# thread pool causes different results --- source include/not_threadpool.inc - # Only run this test if named pipe is avaliable let $nmp= query_get_value("SHOW VARIABLES LIKE 'named_pipe'", Value, 1); if ($nmp != ON){ diff --git a/mysql-test/main/negation_elimination.result b/mysql-test/main/negation_elimination.result index f9be5b55e46..7b9a76d86b2 100644 --- a/mysql-test/main/negation_elimination.result +++ b/mysql-test/main/negation_elimination.result @@ -4,7 +4,7 @@ insert into t1 values (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11), (12), (13), (14), (15), (16), (17), (18), (19); explain select * from t1 where not(not(a)); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index a a 5 NULL 21 Using where; Using index +1 SIMPLE t1 range a a 5 NULL 20 Using where; Using index select * from t1 where not(not(a)); a 1 @@ -55,7 +55,7 @@ a 10 explain select * from t1 where not(a = 10); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index a a 5 NULL 21 Using where; Using index +1 SIMPLE t1 range a a 5 NULL 19 Using where; Using index select * from t1 where not(a = 10); a 0 @@ -145,7 +145,7 @@ a 19 explain select * from t1 where not(a is null); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index a a 5 NULL 21 Using where; Using index +1 SIMPLE t1 range a a 5 NULL 20 Using where; Using index select * from t1 where not(a is null); a 0 @@ -192,7 +192,7 @@ a 15 explain select * from t1 where not(a < 15 and a > 5); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index a a 5 NULL 21 Using where; Using index +1 SIMPLE t1 range a a 5 NULL 11 Using where; Using index select * from t1 where not(a < 15 and a > 5); a 0 @@ -208,7 +208,7 @@ a 19 explain select * from t1 where a = 2 or not(a < 10); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index a a 5 NULL 21 Using where; Using index +1 SIMPLE t1 range a a 5 NULL 11 Using where; Using index select * from t1 where a = 2 or not(a < 10); a 2 @@ -255,7 +255,7 @@ a 19 explain select * from t1 where a = 2 or not(a < 5 or a > 15); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index a a 5 NULL 21 Using where; Using index +1 SIMPLE t1 range a a 5 NULL 12 Using where; Using index select * from t1 where a = 2 or not(a < 5 or a > 15); a 2 @@ -272,7 +272,7 @@ a 15 explain select * from t1 where a = 7 or not(a < 15 and a > 5); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index a a 5 NULL 21 Using where; Using index +1 SIMPLE t1 range a a 5 NULL 12 Using where; Using index select * from t1 where a = 7 or not(a < 15 and a > 5); a 0 @@ -289,7 +289,7 @@ a 19 explain select * from t1 where NULL or not(a < 15 and a > 5); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index a a 5 NULL 21 Using where; Using index +1 SIMPLE t1 range a a 5 NULL 11 Using where; Using index select * from t1 where NULL or not(a < 15 and a > 5); a 0 @@ -500,7 +500,7 @@ NULL NULL 3 1 explain extended select a, not(not(a)), not(a <= 2 and not(a)), not(a not like "1"), not (a not in (1,2)), not(a != 2) from t1 where not(not(a)) having not(not(a)); id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 index a a 5 NULL 5 80.00 Using where; Using index +1 SIMPLE t1 range a a 5 NULL 4 100.00 Using where; Using index Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`a` <> 0 AS `not(not(a))`,`test`.`t1`.`a` > 2 or `test`.`t1`.`a` <> 0 AS `not(a <= 2 and not(a))`,`test`.`t1`.`a` like '1' AS `not(a not like "1")`,`test`.`t1`.`a` in (1,2) AS `not (a not in (1,2))`,`test`.`t1`.`a` = 2 AS `not(a != 2)` from `test`.`t1` where `test`.`t1`.`a` <> 0 having `test`.`t1`.`a` <> 0 drop table t1; diff --git a/mysql-test/main/not_embedded_server.result b/mysql-test/main/not_embedded_server.result index bc794ce48c8..0b952f93ad8 100644 --- a/mysql-test/main/not_embedded_server.result +++ b/mysql-test/main/not_embedded_server.result @@ -68,7 +68,7 @@ ERROR HY000: Operation CREATE USER failed for 'user\"s_12601974'@'localhost' DROP USER 'user\"s_12601974'@'localhost'; CREATE USER 'user\bs_12601974'@'localhost'; CREATE USER 'user\bs_12601974'@'localhost'; -ERROR HY000: Operation CREATE USER failed for 'users_12601974'@'localhost' +ERROR HY000: Operation CREATE USER failed for 'user\0008s_12601974'@'localhost' DROP USER 'user\bs_12601974'@'localhost'; CREATE USER 'user\ns_12601974'@'localhost'; CREATE USER 'user\ns_12601974'@'localhost'; diff --git a/mysql-test/main/null.result b/mysql-test/main/null.result index fc29f68baf0..73ac958cacd 100644 --- a/mysql-test/main/null.result +++ b/mysql-test/main/null.result @@ -267,7 +267,7 @@ t1 CREATE TABLE `t1` ( `c30` varchar(317) CHARACTER SET latin2 DEFAULT NULL, `c31` varchar(192) CHARACTER SET latin2 DEFAULT NULL, `c32` char(0) CHARACTER SET latin2 DEFAULT NULL, - `c33` varchar(3) CHARACTER SET latin2 DEFAULT NULL, + `c33` varchar(6) CHARACTER SET latin2 DEFAULT NULL, `c34` varchar(3) CHARACTER SET latin2 DEFAULT NULL, `c35` varchar(3) CHARACTER SET latin2 DEFAULT NULL, `c36` varchar(3) CHARACTER SET latin2 DEFAULT NULL, diff --git a/mysql-test/main/null_key.result b/mysql-test/main/null_key.result index 55b2060475f..6b9d59c636a 100644 --- a/mysql-test/main/null_key.result +++ b/mysql-test/main/null_key.result @@ -20,7 +20,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL a 9 NULL 12 Using where; Using index explain select * from t1 where (a is null or a > 0 and a < 2) and b < 5 limit 3; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index a,b a 9 NULL 12 Using where; Using index +1 SIMPLE t1 range a,b a 9 NULL 2 Using where; Using index explain select * from t1 where (a is null or a = 7) and b=7; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref_or_null a,b a 9 const,const 2 Using where; Using index @@ -32,7 +32,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref a,b a 5 const 3 Using where; Using index explain select * from t1 where a is null and b=9 or a is null and b=7 limit 3; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref a,b a 5 const 2 Using where; Using index +1 SIMPLE t1 range a,b a 9 NULL 3 Using where; Using index explain select * from t1 where a > 1 and a < 3 limit 1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range a a 5 NULL 1 Using where; Using index @@ -160,7 +160,7 @@ a b 7 NULL explain select * from t1 where (a = 7 or a is null) and (b=7 or b is null); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref_or_null a,b a 5 const 4 Using where; Using index +1 SIMPLE t1 ref_or_null a,b a 5 const 5 Using where; Using index select * from t1 where (a = 7 or a is null) and (b=7 or b is null); a b 7 NULL @@ -194,7 +194,7 @@ a a b explain select * from t2,t1 where t1.a=t2.a and (b= 7 or b is null); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where -1 SIMPLE t1 ref_or_null a a 10 test.t2.a,const 4 Using where; Using index +1 SIMPLE t1 ref_or_null a a 10 test.t2.a,const 5 Using where; Using index select * from t2,t1 where t1.a=t2.a and (b= 7 or b is null); a a b 7 7 7 @@ -204,7 +204,7 @@ a a b explain select * from t2,t1 where (t1.a=t2.a or t1.a is null) and b= 7; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 2 -1 SIMPLE t1 ref_or_null a a 10 test.t2.a,const 4 Using where; Using index +1 SIMPLE t1 ref_or_null a a 10 test.t2.a,const 5 Using where; Using index select * from t2,t1 where (t1.a=t2.a or t1.a is null) and b= 7; a a b 7 7 7 @@ -214,7 +214,7 @@ a a b explain select * from t2,t1 where (t1.a=t2.a or t1.a is null) and (b= 7 or b is null); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 2 -1 SIMPLE t1 ref_or_null a a 5 test.t2.a 4 Using where; Using index +1 SIMPLE t1 ref_or_null a a 5 test.t2.a 5 Using where; Using index select * from t2,t1 where (t1.a=t2.a or t1.a is null) and (b= 7 or b is null); a a b 7 7 NULL @@ -261,7 +261,7 @@ INSERT INTO t1 VALUES (11,5),(12,6),(13,7),(14,8),(15,9); INSERT INTO t2 VALUES (1,NULL),(2,NULL),(3,1),(4,2),(5,NULL),(6,NULL),(7,3),(8,4),(9,NULL),(10,NULL); explain select id from t1 where uniq_id is null; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref idx1 idx1 5 const 6 Using index condition +1 SIMPLE t1 ALL idx1 NULL NULL NULL 15 Using where explain select id from t1 where uniq_id =1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const idx1 idx1 5 const 1 diff --git a/mysql-test/main/openssl_1.test b/mysql-test/main/openssl_1.test index b70d2018c9e..fff65624b12 100644 --- a/mysql-test/main/openssl_1.test +++ b/mysql-test/main/openssl_1.test @@ -1,5 +1,6 @@ # Needed for mysqldump --source include/have_utf8mb4.inc +--source include/not_asan.inc # Tests for SSL connections, only run if mysqld is compiled # with support for SSL. diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result index 0ced5f19e14..8f912e0500d 100644 --- a/mysql-test/main/opt_trace.result +++ b/mysql-test/main/opt_trace.result @@ -118,7 +118,7 @@ select * from v1 { "table": "t1", "table_scan": { "rows": 2, - "cost": 2.0044 + "cost": 2.004394531 } } ] @@ -133,19 +133,19 @@ select * from v1 { { "access_type": "scan", "resulting_rows": 1, - "cost": 2.2044, + "cost": 2.204394531, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 1, - "cost": 2.2044, + "cost": 2.204394531, "uses_join_buffering": false } }, "rows_for_plan": 1, - "cost_for_plan": 2.4044, + "cost_for_plan": 2.404394531, "estimated_join_cardinality": 1 } ] @@ -264,7 +264,7 @@ select * from (select * from t1 where t1.a=1)q { "table": "t1", "table_scan": { "rows": 2, - "cost": 2.0044 + "cost": 2.004394531 } } ] @@ -279,19 +279,19 @@ select * from (select * from t1 where t1.a=1)q { { "access_type": "scan", "resulting_rows": 1, - "cost": 2.2044, + "cost": 2.204394531, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 1, - "cost": 2.2044, + "cost": 2.204394531, "uses_join_buffering": false } }, "rows_for_plan": 1, - "cost_for_plan": 2.4044, + "cost_for_plan": 2.404394531, "estimated_join_cardinality": 1 } ] @@ -415,7 +415,7 @@ select * from v2 { "table": "t1", "table_scan": { "rows": 2, - "cost": 2.0044 + "cost": 2.004394531 } } ] @@ -430,7 +430,7 @@ select * from v2 { { "access_type": "scan", "resulting_rows": 1, - "cost": 2.2044, + "cost": 2.204394531, "chosen": true, "use_tmp_table": true } @@ -438,12 +438,12 @@ select * from v2 { "chosen_access_method": { "type": "scan", "records": 1, - "cost": 2.2044, + "cost": 2.204394531, "uses_join_buffering": false } }, "rows_for_plan": 1, - "cost_for_plan": 2.4044, + "cost_for_plan": 2.404394531, "cost_for_sorting": 1, "estimated_join_cardinality": 1 } @@ -622,7 +622,7 @@ explain select * from v2 { "table": "t2", "table_scan": { "rows": 10, - "cost": 2.022 + "cost": 2.021972656 } } ] @@ -637,19 +637,19 @@ explain select * from v2 { { "access_type": "scan", "resulting_rows": 10, - "cost": 2.022, + "cost": 2.021972656, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 10, - "cost": 2.022, + "cost": 2.021972656, "uses_join_buffering": false } }, "rows_for_plan": 10, - "cost_for_plan": 4.022, + "cost_for_plan": 4.021972656, "estimated_join_cardinality": 10 } ] @@ -740,7 +740,7 @@ explain select * from v1 { "table": "t1", "table_scan": { "rows": 10, - "cost": 2.022 + "cost": 2.021972656 } } ] @@ -755,7 +755,7 @@ explain select * from v1 { { "access_type": "scan", "resulting_rows": 10, - "cost": 2.022, + "cost": 2.021972656, "chosen": true, "use_tmp_table": true } @@ -763,12 +763,12 @@ explain select * from v1 { "chosen_access_method": { "type": "scan", "records": 10, - "cost": 2.022, + "cost": 2.021972656, "uses_join_buffering": false } }, "rows_for_plan": 10, - "cost_for_plan": 4.022, + "cost_for_plan": 4.021972656, "cost_for_sorting": 10, "estimated_join_cardinality": 10 } @@ -972,14 +972,14 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { "table": "t1", "table_scan": { "rows": 100, - "cost": 2.3174 + "cost": 2.317382812 } }, { "table": "t2", "table_scan": { "rows": 100, - "cost": 2.3174 + "cost": 2.317382812 } } ] @@ -994,19 +994,19 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { { "access_type": "scan", "resulting_rows": 100, - "cost": 2.3174, + "cost": 2.317382812, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 100, - "cost": 2.3174, + "cost": 2.317382812, "uses_join_buffering": false } }, "rows_for_plan": 100, - "cost_for_plan": 22.317, + "cost_for_plan": 22.31738281, "rest_of_plan": [ { "plan_prefix": ["t1"], @@ -1019,25 +1019,25 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { "used_range_estimates": false, "cause": "not available", "rows": 1, - "cost": 200, + "cost": 200.0585794, "chosen": true }, { "access_type": "scan", "resulting_rows": 100, - "cost": 2.3174, + "cost": 2.317382812, "chosen": false } ], "chosen_access_method": { "type": "ref", "records": 1, - "cost": 200, + "cost": 200.0585794, "uses_join_buffering": false } }, "rows_for_plan": 100, - "cost_for_plan": 242.32, + "cost_for_plan": 242.3759623, "estimated_join_cardinality": 100 } ] @@ -1050,19 +1050,19 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { { "access_type": "scan", "resulting_rows": 100, - "cost": 2.3174, + "cost": 2.317382812, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 100, - "cost": 2.3174, + "cost": 2.317382812, "uses_join_buffering": false } }, "rows_for_plan": 100, - "cost_for_plan": 22.317, + "cost_for_plan": 22.31738281, "rest_of_plan": [ { "plan_prefix": ["t2"], @@ -1075,25 +1075,25 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { "used_range_estimates": false, "cause": "not available", "rows": 1, - "cost": 200, + "cost": 200.0585794, "chosen": true }, { "access_type": "scan", "resulting_rows": 100, - "cost": 2.3174, + "cost": 2.317382812, "chosen": false } ], "chosen_access_method": { "type": "ref", "records": 1, - "cost": 200, + "cost": 200.0585794, "uses_join_buffering": false } }, "rows_for_plan": 100, - "cost_for_plan": 242.32, + "cost_for_plan": 242.3759623, "pruned_by_cost": true } ] @@ -1177,7 +1177,7 @@ EXPLAIN SELECT DISTINCT a FROM t1 { "range_analysis": { "table_scan": { "rows": 65536, - "cost": 13255 + "cost": 13255.2 }, "potential_range_indexes": [ { @@ -1193,8 +1193,9 @@ EXPLAIN SELECT DISTINCT a FROM t1 { ], "best_covering_index_scan": { "index": "a", - "cost": 4812.5, - "chosen": true + "cost": 13377.39141, + "chosen": false, + "cause": "cost" }, "group_index_range": { "distinct_query": true, @@ -1203,7 +1204,7 @@ EXPLAIN SELECT DISTINCT a FROM t1 { "index": "a", "covering": true, "rows": 5, - "cost": 6.75 + "cost": 6.25 } ] }, @@ -1215,7 +1216,7 @@ EXPLAIN SELECT DISTINCT a FROM t1 { "max_aggregate": false, "distinct_aggregate": false, "rows": 5, - "cost": 6.75, + "cost": 6.25, "key_parts_used_for_access": ["a"], "ranges": [], "chosen": true @@ -1229,12 +1230,12 @@ EXPLAIN SELECT DISTINCT a FROM t1 { "max_aggregate": false, "distinct_aggregate": false, "rows": 5, - "cost": 6.75, + "cost": 6.25, "key_parts_used_for_access": ["a"], "ranges": [] }, "rows_for_plan": 5, - "cost_for_plan": 6.75, + "cost_for_plan": 6.25, "chosen": true } } @@ -1251,19 +1252,19 @@ EXPLAIN SELECT DISTINCT a FROM t1 { { "access_type": "index_merge", "resulting_rows": 5, - "cost": 6.75, + "cost": 6.25, "chosen": true } ], "chosen_access_method": { "type": "index_merge", "records": 5, - "cost": 6.75, + "cost": 6.25, "uses_join_buffering": false } }, "rows_for_plan": 5, - "cost_for_plan": 7.75, + "cost_for_plan": 7.25, "estimated_join_cardinality": 5 } ] @@ -1306,7 +1307,7 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL a 20 NULL 7 Using where; Using index +1 SIMPLE t1 range NULL a 20 NULL 8 Using where; Using index for group-by select * from information_schema.OPTIMIZER_TRACE; QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a { @@ -1365,7 +1366,7 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a { "range_analysis": { "table_scan": { "rows": 7, - "cost": 5.5291 + "cost": 5.429052734 }, "potential_range_indexes": [ { @@ -1376,10 +1377,17 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a { ], "best_covering_index_scan": { "index": "a", - "cost": 1.3869, + "cost": 2.409226263, "chosen": true }, "setup_range_conditions": [], + "analyzing_range_alternatives": { + "range_scan_alternatives": [], + "analyzing_roworder_intersect": { + "cause": "too few roworder scans" + }, + "analyzing_index_merge_union": [] + }, "group_index_range": { "potential_group_range_indexes": [ { @@ -1402,33 +1410,26 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a { "cost": 2.2, "key_parts_used_for_access": ["a", "b", "c"], "ranges": ["(2,3) <= (b,c) <= (2,3)"], - "chosen": false, - "cause": "cost" + "chosen": true }, - "analyzing_range_alternatives": { - "range_scan_alternatives": [], - "analyzing_roworder_intersect": { - "cause": "too few roworder scans" + "chosen_range_access_summary": { + "range_access_plan": { + "type": "index_group", + "index": "a", + "min_max_arg": "d", + "min_aggregate": true, + "max_aggregate": false, + "distinct_aggregate": false, + "rows": 8, + "cost": 2.2, + "key_parts_used_for_access": ["a", "b", "c"], + "ranges": ["(2,3) <= (b,c) <= (2,3)"] }, - "analyzing_index_merge_union": [] + "rows_for_plan": 8, + "cost_for_plan": 2.2, + "chosen": true } } - }, - { - "selectivity_for_indexes": [], - "selectivity_for_columns": [ - { - "column_name": "b", - "ranges": ["2 <= b <= 2"], - "selectivity_from_histogram": 0.2891 - }, - { - "column_name": "c", - "ranges": ["3 <= c <= 3"], - "selectivity_from_histogram": 0.2891 - } - ], - "cond_selectivity": 0.0836 } ] }, @@ -1440,24 +1441,24 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a { "best_access_path": { "considered_access_paths": [ { - "access_type": "scan", - "resulting_rows": 0.5849, - "cost": 3.3121, + "access_type": "index_merge", + "resulting_rows": 8, + "cost": 2.2, "chosen": true, "use_tmp_table": true } ], "chosen_access_method": { - "type": "scan", - "records": 0.5849, - "cost": 3.3121, + "type": "index_merge", + "records": 8, + "cost": 2.2, "uses_join_buffering": false } }, - "rows_for_plan": 0.5849, - "cost_for_plan": 3.4291, - "cost_for_sorting": 0.5849, - "estimated_join_cardinality": 0.5849 + "rows_for_plan": 8, + "cost_for_plan": 3.8, + "cost_for_sorting": 8, + "estimated_join_cardinality": 8 } ] }, @@ -1475,25 +1476,6 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a { } ] } - }, - { - "reconsidering_access_paths_for_index_ordering": { - "clause": "GROUP BY", - "fanout": 1, - "read_time": 3.3131, - "table": "t1", - "rows_estimation": 7, - "possible_keys": [ - { - "index": "a", - "can_resolve_order": true, - "updated_limit": 7, - "index_scan_time": 7, - "records": 7, - "chosen": true - } - ] - } } ] } @@ -1519,7 +1501,7 @@ INSERT INTO t1 values (1,'2001-01-01'),(1,'2001-01-02'), set optimizer_trace='enabled=on'; EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL id 8 NULL 16 Using where; Using index +1 SIMPLE t1 range NULL id 8 NULL 9 Using where; Using index for group-by select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE; QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id { @@ -1578,7 +1560,7 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id { "range_analysis": { "table_scan": { "rows": 16, - "cost": 7.3313 + "cost": 7.23125 }, "potential_range_indexes": [ { @@ -1589,10 +1571,17 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id { ], "best_covering_index_scan": { "index": "id", - "cost": 1.8468, + "cost": 4.21171589, "chosen": true }, "setup_range_conditions": [], + "analyzing_range_alternatives": { + "range_scan_alternatives": [], + "analyzing_roworder_intersect": { + "cause": "too few roworder scans" + }, + "analyzing_index_merge_union": [] + }, "group_index_range": { "potential_group_range_indexes": [ { @@ -1615,22 +1604,26 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id { "cost": 2.35, "key_parts_used_for_access": ["id"], "ranges": ["(2001-01-04) <= (a)"], - "chosen": false, - "cause": "cost" + "chosen": true }, - "analyzing_range_alternatives": { - "range_scan_alternatives": [], - "analyzing_roworder_intersect": { - "cause": "too few roworder scans" + "chosen_range_access_summary": { + "range_access_plan": { + "type": "index_group", + "index": "id", + "min_max_arg": "a", + "min_aggregate": true, + "max_aggregate": true, + "distinct_aggregate": false, + "rows": 9, + "cost": 2.35, + "key_parts_used_for_access": ["id"], + "ranges": ["(2001-01-04) <= (a)"] }, - "analyzing_index_merge_union": [] + "rows_for_plan": 9, + "cost_for_plan": 2.35, + "chosen": true } } - }, - { - "selectivity_for_indexes": [], - "selectivity_for_columns": [], - "cond_selectivity": 1 } ] }, @@ -1642,24 +1635,24 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id { "best_access_path": { "considered_access_paths": [ { - "access_type": "scan", - "resulting_rows": 16, - "cost": 2.0312, + "access_type": "index_merge", + "resulting_rows": 9, + "cost": 2.35, "chosen": true, "use_tmp_table": true } ], "chosen_access_method": { - "type": "scan", - "records": 16, - "cost": 2.0312, + "type": "index_merge", + "records": 9, + "cost": 2.35, "uses_join_buffering": false } }, - "rows_for_plan": 16, - "cost_for_plan": 5.2313, - "cost_for_sorting": 16, - "estimated_join_cardinality": 16 + "rows_for_plan": 9, + "cost_for_plan": 4.15, + "cost_for_sorting": 9, + "estimated_join_cardinality": 9 } ] }, @@ -1677,25 +1670,6 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id { } ] } - }, - { - "reconsidering_access_paths_for_index_ordering": { - "clause": "GROUP BY", - "fanout": 1, - "read_time": 2.0322, - "table": "t1", - "rows_estimation": 9, - "possible_keys": [ - { - "index": "id", - "can_resolve_order": true, - "updated_limit": 16, - "index_scan_time": 16, - "records": 16, - "chosen": true - } - ] - } } ] } @@ -1710,7 +1684,7 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id { } 0 0 EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL id 8 NULL 16 Using where; Using index +1 SIMPLE t1 range NULL id 8 NULL 9 Using where; Using index for group-by select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE; QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id { @@ -1769,7 +1743,7 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id { "range_analysis": { "table_scan": { "rows": 16, - "cost": 7.3313 + "cost": 7.23125 }, "potential_range_indexes": [ { @@ -1780,10 +1754,17 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id { ], "best_covering_index_scan": { "index": "id", - "cost": 1.8468, + "cost": 4.21171589, "chosen": true }, "setup_range_conditions": [], + "analyzing_range_alternatives": { + "range_scan_alternatives": [], + "analyzing_roworder_intersect": { + "cause": "too few roworder scans" + }, + "analyzing_index_merge_union": [] + }, "group_index_range": { "potential_group_range_indexes": [ { @@ -1806,22 +1787,26 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id { "cost": 2.35, "key_parts_used_for_access": ["id", "a"], "ranges": ["(2001-01-04) <= (a) <= (2001-01-04)"], - "chosen": false, - "cause": "cost" + "chosen": true }, - "analyzing_range_alternatives": { - "range_scan_alternatives": [], - "analyzing_roworder_intersect": { - "cause": "too few roworder scans" + "chosen_range_access_summary": { + "range_access_plan": { + "type": "index_group", + "index": "id", + "min_max_arg": null, + "min_aggregate": false, + "max_aggregate": false, + "distinct_aggregate": false, + "rows": 9, + "cost": 2.35, + "key_parts_used_for_access": ["id", "a"], + "ranges": ["(2001-01-04) <= (a) <= (2001-01-04)"] }, - "analyzing_index_merge_union": [] + "rows_for_plan": 9, + "cost_for_plan": 2.35, + "chosen": true } } - }, - { - "selectivity_for_indexes": [], - "selectivity_for_columns": [], - "cond_selectivity": 1 } ] }, @@ -1833,24 +1818,24 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id { "best_access_path": { "considered_access_paths": [ { - "access_type": "scan", - "resulting_rows": 16, - "cost": 2.0312, + "access_type": "index_merge", + "resulting_rows": 9, + "cost": 2.35, "chosen": true, "use_tmp_table": true } ], "chosen_access_method": { - "type": "scan", - "records": 16, - "cost": 2.0312, + "type": "index_merge", + "records": 9, + "cost": 2.35, "uses_join_buffering": false } }, - "rows_for_plan": 16, - "cost_for_plan": 5.2313, - "cost_for_sorting": 16, - "estimated_join_cardinality": 16 + "rows_for_plan": 9, + "cost_for_plan": 4.15, + "cost_for_sorting": 9, + "estimated_join_cardinality": 9 } ] }, @@ -1868,25 +1853,6 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id { } ] } - }, - { - "reconsidering_access_paths_for_index_ordering": { - "clause": "GROUP BY", - "fanout": 1, - "read_time": 2.0322, - "table": "t1", - "rows_estimation": 9, - "possible_keys": [ - { - "index": "id", - "can_resolve_order": true, - "updated_limit": 16, - "index_scan_time": 16, - "records": 16, - "chosen": true - } - ] - } } ] } @@ -2006,7 +1972,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "range_analysis": { "table_scan": { "rows": 1000, - "cost": 232.66 + "cost": 232.5644531 }, "potential_range_indexes": [ { @@ -2026,10 +1992,6 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { } ], "setup_range_conditions": [], - "group_index_range": { - "chosen": false, - "cause": "no group by or distinct" - }, "analyzing_range_alternatives": { "range_scan_alternatives": [ { @@ -2039,7 +2001,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "using_mrr": false, "index_only": false, "rows": 180, - "cost": 229.72, + "cost": 216.2943776, "chosen": true }, { @@ -2049,7 +2011,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "using_mrr": false, "index_only": false, "rows": 21, - "cost": 27.445, + "cost": 25.36242739, "chosen": true } ], @@ -2058,6 +2020,10 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { }, "analyzing_index_merge_union": [] }, + "group_index_range": { + "chosen": false, + "cause": "no group by or distinct" + }, "chosen_range_access_summary": { "range_access_plan": { "type": "range_scan", @@ -2066,7 +2032,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "ranges": ["(1,2) <= (a,b) <= (1,2)"] }, "rows_for_plan": 21, - "cost_for_plan": 27.445, + "cost_for_plan": 25.36242739, "chosen": true } } @@ -2076,12 +2042,12 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "rowid_filters": [ { "key": "a_b", - "build_cost": 2.989, + "build_cost": 0.886777098, "rows": 21 }, { "key": "a_c", - "build_cost": 23.969, + "build_cost": 10.52169992, "rows": 180 } ] @@ -2097,12 +2063,12 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { { "column_name": "a", "ranges": ["1 <= a <= 1"], - "selectivity_from_histogram": 0.1797 + "selectivity_from_histogram": 0.1796875 }, { "column_name": "b", "ranges": ["2 <= b <= 2"], - "selectivity_from_histogram": 0.0156 + "selectivity_from_histogram": 0.015625 } ], "cond_selectivity": 0.021 @@ -2121,7 +2087,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "index": "a_c", "used_range_estimates": true, "rows": 180, - "cost": 92, + "cost": 180.2743776, "chosen": true }, { @@ -2129,7 +2095,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "index": "a_b", "used_range_estimates": true, "rows": 21, - "cost": 22, + "cost": 21.14242739, "chosen": true }, { @@ -2141,12 +2107,12 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "chosen_access_method": { "type": "ref", "records": 21, - "cost": 22, + "cost": 21.14242739, "uses_join_buffering": false } }, "rows_for_plan": 21, - "cost_for_plan": 26.2, + "cost_for_plan": 25.34242739, "estimated_join_cardinality": 21 } ] @@ -2170,7 +2136,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "reconsidering_access_paths_for_index_ordering": { "clause": "ORDER BY", "fanout": 1, - "read_time": 22.001, + "read_time": 21.14342739, "table": "t1", "rows_estimation": 21, "possible_keys": [ @@ -2186,8 +2152,8 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "index": "a_c", "can_resolve_order": true, "updated_limit": 47, - "range_scan_time": 4.324, - "index_scan_time": 4.324, + "range_scan_time": 4.331020747, + "index_scan_time": 4.331020747, "records": 180, "chosen": true }, @@ -2204,7 +2170,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "range_analysis": { "table_scan": { "rows": 1000, - "cost": 2e308 + "cost": 1.79769e308 }, "potential_range_indexes": [ { @@ -2224,10 +2190,6 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { } ], "setup_range_conditions": [], - "group_index_range": { - "chosen": false, - "cause": "no group by or distinct" - }, "analyzing_range_alternatives": { "range_scan_alternatives": [ { @@ -2237,7 +2199,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "using_mrr": false, "index_only": false, "rows": 180, - "cost": 229.72, + "cost": 216.2943776, "chosen": true } ], @@ -2246,6 +2208,10 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { }, "analyzing_index_merge_union": [] }, + "group_index_range": { + "chosen": false, + "cause": "no group by or distinct" + }, "chosen_range_access_summary": { "range_access_plan": { "type": "range_scan", @@ -2254,7 +2220,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "ranges": ["(1) <= (a) <= (1)"] }, "rows_for_plan": 180, - "cost_for_plan": 229.72, + "cost_for_plan": 216.2943776, "chosen": true } } @@ -2353,7 +2319,7 @@ select t1.a from t1 left join t2 on t1.a=t2.a { "table": "t1", "table_scan": { "rows": 4, - "cost": 2.0068 + "cost": 2.006835938 } }, { @@ -2374,19 +2340,19 @@ select t1.a from t1 left join t2 on t1.a=t2.a { { "access_type": "scan", "resulting_rows": 4, - "cost": 2.0068, + "cost": 2.006835938, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 4, - "cost": 2.0068, + "cost": 2.006835938, "uses_join_buffering": false } }, "rows_for_plan": 4, - "cost_for_plan": 2.8068, + "cost_for_plan": 2.806835937, "estimated_join_cardinality": 4 } ] @@ -2478,14 +2444,14 @@ explain select * from t1 left join t2 on t2.a=t1.a { "table": "t1", "table_scan": { "rows": 4, - "cost": 2.0068 + "cost": 2.006835938 } }, { "table": "t2", "table_scan": { "rows": 2, - "cost": 2.0044 + "cost": 2.004394531 } } ] @@ -2500,19 +2466,19 @@ explain select * from t1 left join t2 on t2.a=t1.a { { "access_type": "scan", "resulting_rows": 4, - "cost": 2.0068, + "cost": 2.006835938, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 4, - "cost": 2.0068, + "cost": 2.006835938, "uses_join_buffering": false } }, "rows_for_plan": 4, - "cost_for_plan": 2.8068, + "cost_for_plan": 2.806835937, "rest_of_plan": [ { "plan_prefix": ["t1"], @@ -2529,7 +2495,7 @@ explain select * from t1 left join t2 on t2.a=t1.a { { "access_type": "scan", "resulting_rows": 2, - "cost": 8.0176, + "cost": 8.017578125, "chosen": false } ], @@ -2541,7 +2507,7 @@ explain select * from t1 left join t2 on t2.a=t1.a { } }, "rows_for_plan": 4, - "cost_for_plan": 7.6068, + "cost_for_plan": 7.606835937, "estimated_join_cardinality": 4 } ] @@ -2662,7 +2628,7 @@ explain select t1.a from t1 left join (t2 join t3 on t2.b=t3.b) on t2.a=t1.a and "table": "t1", "table_scan": { "rows": 4, - "cost": 2.0068 + "cost": 2.006835938 } }, { @@ -2689,19 +2655,19 @@ explain select t1.a from t1 left join (t2 join t3 on t2.b=t3.b) on t2.a=t1.a and { "access_type": "scan", "resulting_rows": 4, - "cost": 2.0068, + "cost": 2.006835938, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 4, - "cost": 2.0068, + "cost": 2.006835938, "uses_join_buffering": false } }, "rows_for_plan": 4, - "cost_for_plan": 2.8068, + "cost_for_plan": 2.806835937, "estimated_join_cardinality": 4 } ] @@ -2861,14 +2827,14 @@ explain extended select * from t1 where a in (select pk from t10) { "table": "t1", "table_scan": { "rows": 3, - "cost": 2.0066 + "cost": 2.006591797 } }, { "table": "t10", "table_scan": { "rows": 10, - "cost": 2.022 + "cost": 2.021972656 } } ] @@ -2891,19 +2857,19 @@ explain extended select * from t1 where a in (select pk from t10) { { "access_type": "scan", "resulting_rows": 10, - "cost": 2.022, + "cost": 2.021972656, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 10, - "cost": 2.022, + "cost": 2.021972656, "uses_join_buffering": false } }, "rows_for_plan": 10, - "cost_for_plan": 4.022, + "cost_for_plan": 4.021972656, "estimated_join_cardinality": 10 } ] @@ -2921,19 +2887,19 @@ explain extended select * from t1 where a in (select pk from t10) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0066, + "cost": 2.006591797, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0066, + "cost": 2.006591797, "uses_join_buffering": false } }, "rows_for_plan": 3, - "cost_for_plan": 2.6066, + "cost_for_plan": 2.606591797, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -2944,34 +2910,34 @@ explain extended select * from t1 where a in (select pk from t10) { { "access_type": "scan", "resulting_rows": 10, - "cost": 2.022, + "cost": 2.021972656, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 10, - "cost": 2.022, + "cost": 2.021972656, "uses_join_buffering": true } }, "rows_for_plan": 30, - "cost_for_plan": 10.629, + "cost_for_plan": 10.62856445, "semijoin_strategy_choice": [ { "strategy": "FirstMatch", "records": 3, - "read_time": 10.629 + "read_time": 10.62856445 }, { "strategy": "SJ-Materialization", "records": 3, - "read_time": 5.2786 + "read_time": 5.278564453 }, { "strategy": "DuplicateWeedout", "records": 3, - "read_time": 27.129 + "read_time": 27.12856445 }, { "chosen_strategy": "SJ-Materialization" @@ -2989,19 +2955,19 @@ explain extended select * from t1 where a in (select pk from t10) { { "access_type": "scan", "resulting_rows": 10, - "cost": 2.022, + "cost": 2.021972656, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 10, - "cost": 2.022, + "cost": 2.021972656, "uses_join_buffering": false } }, "rows_for_plan": 10, - "cost_for_plan": 4.022, + "cost_for_plan": 4.021972656, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -3177,7 +3143,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "range_analysis": { "table_scan": { "rows": 10, - "cost": 6.1317 + "cost": 6.031738281 }, "potential_range_indexes": [ { @@ -3198,14 +3164,10 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { ], "best_covering_index_scan": { "index": "pk_a_b", - "cost": 1.5429, + "cost": 3.010739566, "chosen": true }, "setup_range_conditions": [], - "group_index_range": { - "chosen": false, - "cause": "no group by or distinct" - }, "analyzing_range_alternatives": { "range_scan_alternatives": [ { @@ -3215,9 +3177,8 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "using_mrr": false, "index_only": false, "rows": 1, - "cost": 2.3773, - "chosen": false, - "cause": "cost" + "cost": 1.345585794, + "chosen": true }, { "index": "pk_a", @@ -3226,7 +3187,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "using_mrr": false, "index_only": false, "rows": 1, - "cost": 2.3783, + "cost": 1.345829876, "chosen": false, "cause": "cost" }, @@ -3237,7 +3198,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "using_mrr": false, "index_only": true, "rows": 1, - "cost": 1.1793, + "cost": 0.346073957, "chosen": true } ], @@ -3245,10 +3206,10 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "intersecting_indexes": [ { "index": "pk", - "index_scan_cost": 1.0023, - "cumulated_index_scan_cost": 1.0023, - "disk_sweep_cost": 0.9008, - "cumulative_total_cost": 1.9031, + "index_scan_cost": 1.000585794, + "cumulated_index_scan_cost": 1.000585794, + "disk_sweep_cost": 0.90078125, + "cumulative_total_cost": 1.901367044, "usable": true, "matching_rows_now": 1, "intersect_covering_with_this_index": false, @@ -3274,6 +3235,10 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { }, "analyzing_index_merge_union": [] }, + "group_index_range": { + "chosen": false, + "cause": "no group by or distinct" + }, "chosen_range_access_summary": { "range_access_plan": { "type": "range_scan", @@ -3282,7 +3247,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "ranges": ["(2,5,1) <= (pk,a,b) <= (2,5,1)"] }, "rows_for_plan": 1, - "cost_for_plan": 1.1793, + "cost_for_plan": 0.346073957, "chosen": true } } @@ -3292,17 +3257,17 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "rowid_filters": [ { "key": "pk", - "build_cost": 1.1823, + "build_cost": 0.130585794, "rows": 1 }, { "key": "pk_a", - "build_cost": 1.1833, + "build_cost": 0.130829876, "rows": 1 }, { "key": "pk_a_b", - "build_cost": 1.1843, + "build_cost": 0.131073957, "rows": 1 } ] @@ -3342,7 +3307,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "index": "pk", "used_range_estimates": true, "rows": 1, - "cost": 2, + "cost": 1.125585794, "chosen": true }, { @@ -3350,7 +3315,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "index": "pk_a", "used_range_estimates": true, "rows": 1, - "cost": 2, + "cost": 1.125829876, "chosen": false, "cause": "cost" }, @@ -3359,7 +3324,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "index": "pk_a_b", "used_range_estimates": true, "rows": 1, - "cost": 1.0043, + "cost": 0.126073957, "chosen": true }, { @@ -3371,12 +3336,12 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "chosen_access_method": { "type": "ref", "records": 1, - "cost": 1.0043, + "cost": 0.126073957, "uses_join_buffering": false } }, "rows_for_plan": 1, - "cost_for_plan": 1.2043, + "cost_for_plan": 0.326073957, "estimated_join_cardinality": 1 } ] @@ -3473,7 +3438,7 @@ select f1(a) from t1 { "table": "t1", "table_scan": { "rows": 4, - "cost": 2.0068 + "cost": 2.006835938 } } ] @@ -3488,19 +3453,19 @@ select f1(a) from t1 { { "access_type": "scan", "resulting_rows": 4, - "cost": 2.0068, + "cost": 2.006835938, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 4, - "cost": 2.0068, + "cost": 2.006835938, "uses_join_buffering": false } }, "rows_for_plan": 4, - "cost_for_plan": 2.8068, + "cost_for_plan": 2.806835937, "estimated_join_cardinality": 4 } ] @@ -3571,7 +3536,7 @@ select f2(a) from t1 { "table": "t1", "table_scan": { "rows": 4, - "cost": 2.0068 + "cost": 2.006835938 } } ] @@ -3586,19 +3551,19 @@ select f2(a) from t1 { { "access_type": "scan", "resulting_rows": 4, - "cost": 2.0068, + "cost": 2.006835938, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 4, - "cost": 2.0068, + "cost": 2.006835938, "uses_join_buffering": false } }, "rows_for_plan": 4, - "cost_for_plan": 2.8068, + "cost_for_plan": 2.806835937, "estimated_join_cardinality": 4 } ] @@ -3646,7 +3611,7 @@ a 2 select length(trace) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; length(trace) -2163 +2183 set optimizer_trace_max_mem_size=100; select * from t1; a @@ -3660,7 +3625,7 @@ select * from t1 { "join_preparation": { "select_id": 1, "steps": [ - 2063 0 + 2083 0 set optimizer_trace_max_mem_size=0; select * from t1; a @@ -3668,7 +3633,7 @@ a 2 select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE; QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES -select * from t1 2163 0 +select * from t1 2183 0 drop table t1; set optimizer_trace='enabled=off'; set @@optimizer_trace_max_mem_size= @save_optimizer_trace_max_mem_size; @@ -3693,7 +3658,7 @@ explain delete from t0 where t0.a<3 { "range_analysis": { "table_scan": { "rows": 10, - "cost": 6.122 + "cost": 6.021972656 }, "potential_range_indexes": [ { @@ -3703,10 +3668,6 @@ explain delete from t0 where t0.a<3 { } ], "setup_range_conditions": [], - "group_index_range": { - "chosen": false, - "cause": "no join" - }, "analyzing_range_alternatives": { "range_scan_alternatives": [ { @@ -3716,12 +3677,16 @@ explain delete from t0 where t0.a<3 { "using_mrr": false, "index_only": false, "rows": 3, - "cost": 5.007, + "cost": 3.746757383, "chosen": true } ], "analyzing_index_merge_union": [] }, + "group_index_range": { + "chosen": false, + "cause": "no join" + }, "chosen_range_access_summary": { "range_access_plan": { "type": "range_scan", @@ -3730,7 +3695,7 @@ explain delete from t0 where t0.a<3 { "ranges": ["(NULL) < (a) < (3)"] }, "rows_for_plan": 3, - "cost_for_plan": 5.007, + "cost_for_plan": 3.746757383, "chosen": true } } @@ -3831,7 +3796,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "range_analysis": { "table_scan": { "rows": 10, - "cost": 6.122 + "cost": 6.021972656 }, "potential_range_indexes": [ { @@ -3842,14 +3807,10 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { ], "best_covering_index_scan": { "index": "a", - "cost": 1.5234, + "cost": 3.005857945, "chosen": true }, "setup_range_conditions": [], - "group_index_range": { - "chosen": false, - "cause": "not single_table" - }, "analyzing_range_alternatives": { "range_scan_alternatives": [ { @@ -3859,7 +3820,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "using_mrr": false, "index_only": true, "rows": 3, - "cost": 1.407, + "cost": 0.746757383, "chosen": true } ], @@ -3868,6 +3829,10 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { }, "analyzing_index_merge_union": [] }, + "group_index_range": { + "chosen": false, + "cause": "not single_table" + }, "chosen_range_access_summary": { "range_access_plan": { "type": "range_scan", @@ -3876,7 +3841,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "ranges": ["(NULL) < (a) < (3)"] }, "rows_for_plan": 3, - "cost_for_plan": 1.407, + "cost_for_plan": 0.746757383, "chosen": true } } @@ -3896,7 +3861,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "range_analysis": { "table_scan": { "rows": 10, - "cost": 6.122 + "cost": 6.021972656 }, "potential_range_indexes": [ { @@ -3907,14 +3872,10 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { ], "best_covering_index_scan": { "index": "a", - "cost": 1.5234, + "cost": 3.005857945, "chosen": true }, "setup_range_conditions": [], - "group_index_range": { - "chosen": false, - "cause": "not single_table" - }, "analyzing_range_alternatives": { "range_scan_alternatives": [ { @@ -3924,7 +3885,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "using_mrr": false, "index_only": true, "rows": 3, - "cost": 1.407, + "cost": 0.746757383, "chosen": true } ], @@ -3933,6 +3894,10 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { }, "analyzing_index_merge_union": [] }, + "group_index_range": { + "chosen": false, + "cause": "not single_table" + }, "chosen_range_access_summary": { "range_access_plan": { "type": "range_scan", @@ -3941,7 +3906,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "ranges": ["(NULL) < (a) < (3)"] }, "rows_for_plan": 3, - "cost_for_plan": 1.407, + "cost_for_plan": 0.746757383, "chosen": true } } @@ -3968,19 +3933,19 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { { "access_type": "range", "resulting_rows": 3, - "cost": 1.407, + "cost": 0.746757383, "chosen": true } ], "chosen_access_method": { "type": "range", "records": 3, - "cost": 1.407, + "cost": 0.746757383, "uses_join_buffering": false } }, "rows_for_plan": 3, - "cost_for_plan": 2.007, + "cost_for_plan": 1.346757383, "rest_of_plan": [ { "plan_prefix": ["t0"], @@ -3993,7 +3958,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "used_range_estimates": false, "cause": "not better than ref estimates", "rows": 1, - "cost": 3.007, + "cost": 3.001757383, "chosen": true }, { @@ -4005,12 +3970,12 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "chosen_access_method": { "type": "ref", "records": 1, - "cost": 3.007, + "cost": 3.001757383, "uses_join_buffering": false } }, "rows_for_plan": 3, - "cost_for_plan": 5.614, + "cost_for_plan": 4.948514767, "estimated_join_cardinality": 3 } ] @@ -4023,19 +3988,19 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { { "access_type": "range", "resulting_rows": 3, - "cost": 1.407, + "cost": 0.746757383, "chosen": true } ], "chosen_access_method": { "type": "range", "records": 3, - "cost": 1.407, + "cost": 0.746757383, "uses_join_buffering": false } }, "rows_for_plan": 3, - "cost_for_plan": 2.007, + "cost_for_plan": 1.346757383, "rest_of_plan": [ { "plan_prefix": ["t1"], @@ -4048,7 +4013,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "used_range_estimates": false, "cause": "not better than ref estimates", "rows": 2, - "cost": 3.014, + "cost": 3.003514767, "chosen": true }, { @@ -4060,12 +4025,12 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "chosen_access_method": { "type": "ref", "records": 2, - "cost": 3.014, + "cost": 3.003514767, "uses_join_buffering": false } }, "rows_for_plan": 6, - "cost_for_plan": 6.2211, + "cost_for_plan": 5.55027215, "pruned_by_cost": true } ] @@ -4177,7 +4142,7 @@ explain select * from (select rand() from t1)q { "table": "t1", "table_scan": { "rows": 3, - "cost": 2.0051 + "cost": 2.005126953 } } ] @@ -4192,19 +4157,19 @@ explain select * from (select rand() from t1)q { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": false } }, "rows_for_plan": 3, - "cost_for_plan": 2.6051, + "cost_for_plan": 2.605126953, "estimated_join_cardinality": 3 } ] @@ -4429,21 +4394,21 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ "table": "t1", "table_scan": { "rows": 3, - "cost": 2.0051 + "cost": 2.005126953 } }, { "table": "t_inner_1", "table_scan": { "rows": 3, - "cost": 2.0051 + "cost": 2.005126953 } }, { "table": "t_inner_2", "table_scan": { "rows": 3, - "cost": 2.0051 + "cost": 2.005126953 } } ] @@ -4466,19 +4431,19 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": false } }, "rows_for_plan": 3, - "cost_for_plan": 2.6051, + "cost_for_plan": 2.605126953, "rest_of_plan": [ { "plan_prefix": ["t_inner_1"], @@ -4488,19 +4453,19 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": true } }, "rows_for_plan": 9, - "cost_for_plan": 6.4103, + "cost_for_plan": 6.410253906, "estimated_join_cardinality": 9 } ] @@ -4513,19 +4478,19 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": false } }, "rows_for_plan": 3, - "cost_for_plan": 2.6051, + "cost_for_plan": 2.605126953, "pruned_by_heuristic": true } ] @@ -4543,19 +4508,19 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": false } }, "rows_for_plan": 3, - "cost_for_plan": 2.6051, + "cost_for_plan": 2.605126953, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -4566,19 +4531,19 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": true } }, "rows_for_plan": 9, - "cost_for_plan": 6.4103, + "cost_for_plan": 6.410253906, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -4589,34 +4554,34 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": true } }, "rows_for_plan": 27, - "cost_for_plan": 13.815, + "cost_for_plan": 13.81538086, "semijoin_strategy_choice": [ { "strategy": "FirstMatch", "records": 3, - "read_time": 33.867 + "read_time": 33.86665039 }, { "strategy": "SJ-Materialization", "records": 3, - "read_time": 7.2154 + "read_time": 7.215380859 }, { "strategy": "DuplicateWeedout", "records": 3, - "read_time": 18.315 + "read_time": 18.31538086 }, { "chosen_strategy": "SJ-Materialization" @@ -4634,19 +4599,19 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": true } }, "rows_for_plan": 9, - "cost_for_plan": 6.4103, + "cost_for_plan": 6.410253906, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -4660,19 +4625,19 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": false } }, "rows_for_plan": 3, - "cost_for_plan": 2.6051, + "cost_for_plan": 2.605126953, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -4684,19 +4649,19 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": false } }, "rows_for_plan": 3, - "cost_for_plan": 2.6051, + "cost_for_plan": 2.605126953, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -4927,42 +4892,42 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "table": "t_outer_1", "table_scan": { "rows": 3, - "cost": 2.0051 + "cost": 2.005126953 } }, { "table": "t_outer_2", "table_scan": { "rows": 9, - "cost": 2.0154 + "cost": 2.015380859 } }, { "table": "t_inner_2", "table_scan": { "rows": 9, - "cost": 2.0154 + "cost": 2.015380859 } }, { "table": "t_inner_1", "table_scan": { "rows": 3, - "cost": 2.0051 + "cost": 2.005126953 } }, { "table": "t_inner_3", "table_scan": { "rows": 9, - "cost": 2.0154 + "cost": 2.015380859 } }, { "table": "t_inner_4", "table_scan": { "rows": 3, - "cost": 2.0051 + "cost": 2.005126953 } } ] @@ -4992,19 +4957,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": false } }, "rows_for_plan": 3, - "cost_for_plan": 2.6051, + "cost_for_plan": 2.605126953, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -5015,19 +4980,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": true } }, "rows_for_plan": 9, - "cost_for_plan": 6.4103, + "cost_for_plan": 6.410253906, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -5038,29 +5003,29 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 81, - "cost_for_plan": 24.626, + "cost_for_plan": 24.62563477, "semijoin_strategy_choice": [ { "strategy": "FirstMatch", "records": 3, - "read_time": 44.759 + "read_time": 44.75893555 }, { "strategy": "DuplicateWeedout", "records": 3, - "read_time": 37.226 + "read_time": 37.22563477 }, { "chosen_strategy": "DuplicateWeedout" @@ -5075,19 +5040,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 27, - "cost_for_plan": 44.641, + "cost_for_plan": 44.64101563, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -5103,19 +5068,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": true } }, "rows_for_plan": 81, - "cost_for_plan": 62.846, + "cost_for_plan": 62.84614258, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -5132,29 +5097,29 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 729, - "cost_for_plan": 210.66, + "cost_for_plan": 210.6615234, "semijoin_strategy_choice": [ { "strategy": "FirstMatch", "records": 27, - "read_time": 424.03 + "read_time": 424.025293 }, { "strategy": "DuplicateWeedout", "records": 27, - "read_time": 324.06 + "read_time": 324.0615234 }, { "chosen_strategy": "DuplicateWeedout" @@ -5177,19 +5142,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 243, - "cost_for_plan": 95.256, + "cost_for_plan": 95.25639648, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -5203,19 +5168,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": true } }, "rows_for_plan": 9, - "cost_for_plan": 41.031, + "cost_for_plan": 41.03076172, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -5231,19 +5196,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 81, - "cost_for_plan": 59.246, + "cost_for_plan": 59.24614258, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -5260,24 +5225,24 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 729, - "cost_for_plan": 207.06, + "cost_for_plan": 207.0615234, "semijoin_strategy_choice": [ { "strategy": "DuplicateWeedout", "records": 27, - "read_time": 320.46 + "read_time": 320.4615234 }, { "chosen_strategy": "DuplicateWeedout" @@ -5300,19 +5265,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 81, - "cost_for_plan": 59.246, + "cost_for_plan": 59.24614258, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -5326,19 +5291,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 27, - "cost_for_plan": 44.641, + "cost_for_plan": 44.64101563, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -5352,19 +5317,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 81, - "cost_for_plan": 24.626, + "cost_for_plan": 24.62563477, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -5375,24 +5340,24 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 729, - "cost_for_plan": 172.44, + "cost_for_plan": 172.4410156, "semijoin_strategy_choice": [ { "strategy": "DuplicateWeedout", "records": 27, - "read_time": 285.84 + "read_time": 285.8410156 }, { "chosen_strategy": "DuplicateWeedout" @@ -5412,19 +5377,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": true } }, "rows_for_plan": 81, - "cost_for_plan": 304.05, + "cost_for_plan": 304.0461426, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -5441,24 +5406,24 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 729, - "cost_for_plan": 451.86, + "cost_for_plan": 451.8615234, "semijoin_strategy_choice": [ { "strategy": "DuplicateWeedout", "records": 27, - "read_time": 565.26 + "read_time": 565.2615234 }, { "chosen_strategy": "DuplicateWeedout" @@ -5481,19 +5446,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 243, - "cost_for_plan": 336.46, + "cost_for_plan": 336.4563965, "semijoin_strategy_choice": [], "pruned_by_cost": true } @@ -5507,19 +5472,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": true } }, "rows_for_plan": 243, - "cost_for_plan": 75.231, + "cost_for_plan": 75.23076172, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -5535,19 +5500,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 2187, - "cost_for_plan": 514.65, + "cost_for_plan": 514.6461426, "semijoin_strategy_choice": [], "pruned_by_cost": true }, @@ -5564,19 +5529,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 2187, - "cost_for_plan": 514.65, + "cost_for_plan": 514.6461426, "semijoin_strategy_choice": [], "pruned_by_cost": true } @@ -5590,19 +5555,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 729, - "cost_for_plan": 172.44, + "cost_for_plan": 172.4410156, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -5618,24 +5583,24 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": true } }, "rows_for_plan": 2187, - "cost_for_plan": 611.85, + "cost_for_plan": 611.8461426, "semijoin_strategy_choice": [ { "strategy": "FirstMatch", "records": 81, - "read_time": 2232.8 + "read_time": 2232.809033 }, { "chosen_strategy": "FirstMatch" @@ -5656,19 +5621,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 6561, - "cost_for_plan": 1486.7, + "cost_for_plan": 1486.656396, "semijoin_strategy_choice": [], "pruned_by_cost": true } @@ -5684,19 +5649,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": true } }, "rows_for_plan": 27, - "cost_for_plan": 13.815, + "cost_for_plan": 13.81538086, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -5707,19 +5672,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 243, - "cost_for_plan": 64.431, + "cost_for_plan": 64.43076172, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -5735,19 +5700,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 2187, - "cost_for_plan": 503.85, + "cost_for_plan": 503.8461426, "semijoin_strategy_choice": [], "pruned_by_cost": true }, @@ -5764,19 +5729,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 2187, - "cost_for_plan": 503.85, + "cost_for_plan": 503.8461426, "semijoin_strategy_choice": [], "pruned_by_cost": true } @@ -5790,19 +5755,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 243, - "cost_for_plan": 64.431, + "cost_for_plan": 64.43076172, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -5814,19 +5779,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 243, - "cost_for_plan": 64.431, + "cost_for_plan": 64.43076172, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -5840,19 +5805,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 81, - "cost_for_plan": 24.626, + "cost_for_plan": 24.62563477, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -5863,19 +5828,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 729, - "cost_for_plan": 172.44, + "cost_for_plan": 172.4410156, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -5891,19 +5856,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": true } }, "rows_for_plan": 2187, - "cost_for_plan": 611.85, + "cost_for_plan": 611.8461426, "semijoin_strategy_choice": [], "pruned_by_cost": true }, @@ -5920,19 +5885,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 6561, - "cost_for_plan": 1486.7, + "cost_for_plan": 1486.656396, "semijoin_strategy_choice": [], "pruned_by_cost": true } @@ -5946,19 +5911,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": true } }, "rows_for_plan": 243, - "cost_for_plan": 75.231, + "cost_for_plan": 75.23076172, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -5974,19 +5939,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 2187, - "cost_for_plan": 514.65, + "cost_for_plan": 514.6461426, "semijoin_strategy_choice": [], "pruned_by_cost": true }, @@ -6003,19 +5968,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 2187, - "cost_for_plan": 514.65, + "cost_for_plan": 514.6461426, "semijoin_strategy_choice": [], "pruned_by_cost": true } @@ -6029,19 +5994,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 729, - "cost_for_plan": 172.44, + "cost_for_plan": 172.4410156, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -6057,19 +6022,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 27, - "cost_for_plan": 10.021, + "cost_for_plan": 10.02050781, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -6081,19 +6046,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 27, - "cost_for_plan": 10.021, + "cost_for_plan": 10.02050781, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -6105,19 +6070,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": true } }, "rows_for_plan": 9, - "cost_for_plan": 6.4103, + "cost_for_plan": 6.410253906, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -6129,19 +6094,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 27, - "cost_for_plan": 10.021, + "cost_for_plan": 10.02050781, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -6155,19 +6120,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": false } }, "rows_for_plan": 3, - "cost_for_plan": 2.6051, + "cost_for_plan": 2.605126953, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -6179,19 +6144,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": false } }, "rows_for_plan": 9, - "cost_for_plan": 3.8154, + "cost_for_plan": 3.815380859, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -6203,19 +6168,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": false } }, "rows_for_plan": 9, - "cost_for_plan": 3.8154, + "cost_for_plan": 3.815380859, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -6227,19 +6192,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": false } }, "rows_for_plan": 3, - "cost_for_plan": 2.6051, + "cost_for_plan": 2.605126953, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -6251,19 +6216,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": false } }, "rows_for_plan": 9, - "cost_for_plan": 3.8154, + "cost_for_plan": 3.815380859, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -6502,42 +6467,42 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "table": "t_outer_1", "table_scan": { "rows": 3, - "cost": 2.0051 + "cost": 2.005126953 } }, { "table": "t_outer_2", "table_scan": { "rows": 9, - "cost": 2.0154 + "cost": 2.015380859 } }, { "table": "t_inner_2", "table_scan": { "rows": 9, - "cost": 2.0154 + "cost": 2.015380859 } }, { "table": "t_inner_1", "table_scan": { "rows": 3, - "cost": 2.0051 + "cost": 2.005126953 } }, { "table": "t_inner_3", "table_scan": { "rows": 9, - "cost": 2.0154 + "cost": 2.015380859 } }, { "table": "t_inner_4", "table_scan": { "rows": 3, - "cost": 2.0051 + "cost": 2.005126953 } } ] @@ -6565,19 +6530,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": false } }, "rows_for_plan": 3, - "cost_for_plan": 2.6051, + "cost_for_plan": 2.605126953, "rest_of_plan": [ { "plan_prefix": ["t_inner_1"], @@ -6587,19 +6552,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 27, - "cost_for_plan": 10.021, + "cost_for_plan": 10.02050781, "estimated_join_cardinality": 27 } ] @@ -6612,19 +6577,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": false } }, "rows_for_plan": 9, - "cost_for_plan": 3.8154, + "cost_for_plan": 3.815380859, "pruned_by_heuristic": true } ] @@ -6639,19 +6604,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": false } }, "rows_for_plan": 3, - "cost_for_plan": 2.6051, + "cost_for_plan": 2.605126953, "rest_of_plan": [ { "plan_prefix": ["t_inner_4"], @@ -6661,19 +6626,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 27, - "cost_for_plan": 10.021, + "cost_for_plan": 10.02050781, "estimated_join_cardinality": 27 } ] @@ -6686,19 +6651,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": false } }, "rows_for_plan": 9, - "cost_for_plan": 3.8154, + "cost_for_plan": 3.815380859, "pruned_by_heuristic": true } ] @@ -6716,19 +6681,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": false } }, "rows_for_plan": 3, - "cost_for_plan": 2.6051, + "cost_for_plan": 2.605126953, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -6739,19 +6704,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": true } }, "rows_for_plan": 9, - "cost_for_plan": 6.4103, + "cost_for_plan": 6.410253906, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -6762,34 +6727,34 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 81, - "cost_for_plan": 24.626, + "cost_for_plan": 24.62563477, "semijoin_strategy_choice": [ { "strategy": "FirstMatch", "records": 3, - "read_time": 44.759 + "read_time": 44.75893555 }, { "strategy": "SJ-Materialization", "records": 3, - "read_time": 8.1256 + "read_time": 8.125634766 }, { "strategy": "DuplicateWeedout", "records": 3, - "read_time": 37.226 + "read_time": 37.22563477 }, { "chosen_strategy": "SJ-Materialization" @@ -6804,19 +6769,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 27, - "cost_for_plan": 15.541, + "cost_for_plan": 15.54101562, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -6832,19 +6797,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": true } }, "rows_for_plan": 81, - "cost_for_plan": 33.746, + "cost_for_plan": 33.74614258, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -6861,34 +6826,34 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 729, - "cost_for_plan": 181.56, + "cost_for_plan": 181.5615234, "semijoin_strategy_choice": [ { "strategy": "FirstMatch", "records": 27, - "read_time": 394.93 + "read_time": 394.925293 }, { "strategy": "SJ-Materialization", "records": 27, - "read_time": 22.262 + "read_time": 22.26152344 }, { "strategy": "DuplicateWeedout", "records": 27, - "read_time": 294.96 + "read_time": 294.9615234 }, { "chosen_strategy": "SJ-Materialization" @@ -6911,19 +6876,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 243, - "cost_for_plan": 66.156, + "cost_for_plan": 66.15639648, "semijoin_strategy_choice": [], "pruned_by_cost": true } @@ -6937,19 +6902,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": true } }, "rows_for_plan": 9, - "cost_for_plan": 11.931, + "cost_for_plan": 11.93076172, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -6965,19 +6930,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 81, - "cost_for_plan": 30.146, + "cost_for_plan": 30.14614258, "semijoin_strategy_choice": [], "pruned_by_cost": true }, @@ -6994,19 +6959,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 81, - "cost_for_plan": 30.146, + "cost_for_plan": 30.14614258, "semijoin_strategy_choice": [], "pruned_by_cost": true } @@ -7020,19 +6985,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 27, - "cost_for_plan": 15.541, + "cost_for_plan": 15.54101562, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -7046,19 +7011,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 81, - "cost_for_plan": 24.626, + "cost_for_plan": 24.62563477, "semijoin_strategy_choice": [], "pruned_by_cost": true }, @@ -7070,19 +7035,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": true } }, "rows_for_plan": 27, - "cost_for_plan": 13.815, + "cost_for_plan": 13.81538086, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -7094,19 +7059,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 81, - "cost_for_plan": 24.626, + "cost_for_plan": 24.62563477, "semijoin_strategy_choice": [], "pruned_by_cost": true } @@ -7120,19 +7085,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 27, - "cost_for_plan": 10.021, + "cost_for_plan": 10.02050781, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -7144,19 +7109,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 27, - "cost_for_plan": 10.021, + "cost_for_plan": 10.02050781, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -7168,19 +7133,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": true } }, "rows_for_plan": 9, - "cost_for_plan": 6.4103, + "cost_for_plan": 6.410253906, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -7192,19 +7157,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": true } }, "rows_for_plan": 27, - "cost_for_plan": 10.021, + "cost_for_plan": 10.02050781, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -7218,19 +7183,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": false } }, "rows_for_plan": 3, - "cost_for_plan": 2.6051, + "cost_for_plan": 2.605126953, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -7242,19 +7207,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": false } }, "rows_for_plan": 9, - "cost_for_plan": 3.8154, + "cost_for_plan": 3.815380859, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -7266,19 +7231,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": false } }, "rows_for_plan": 9, - "cost_for_plan": 3.8154, + "cost_for_plan": 3.815380859, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -7290,19 +7255,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": false } }, "rows_for_plan": 3, - "cost_for_plan": 2.6051, + "cost_for_plan": 2.605126953, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -7314,19 +7279,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.0154, + "cost": 2.015380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.0154, + "cost": 2.015380859, "uses_join_buffering": false } }, "rows_for_plan": 9, - "cost_for_plan": 3.8154, + "cost_for_plan": 3.815380859, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -7466,7 +7431,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": true, "rows": 1, - "cost": 1.1783, + "cost": 0.345829876, "chosen": true } ], @@ -7500,7 +7465,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": true, "rows": 107, - "cost": 8.9549, + "cost": 21.63379668, "chosen": true } ], @@ -7537,7 +7502,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1000, - "cost": 1273.2, + "cost": 1203.877243, "chosen": true } ], @@ -7582,7 +7547,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 4, - "cost": 6.2648, + "cost": 4.948710032, "chosen": true } ], @@ -7621,7 +7586,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1, - "cost": 2.3797, + "cost": 1.346171589, "chosen": true } ], @@ -7655,7 +7620,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1, - "cost": 2.3797, + "cost": 1.346171589, "chosen": true } ], @@ -7697,7 +7662,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1, - "cost": 2.3787, + "cost": 1.345927508, "chosen": true } ], @@ -7732,7 +7697,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1, - "cost": 2.3785, + "cost": 1.345878692, "chosen": true } ], @@ -7767,7 +7732,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1, - "cost": 2.3787, + "cost": 1.345927508, "chosen": true } ], @@ -7805,7 +7770,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1, - "cost": 2.3785, + "cost": 1.345878692, "chosen": true } ], @@ -7846,7 +7811,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1, - "cost": 3.5719, + "cost": 1.394255553, "chosen": true } ], @@ -7885,7 +7850,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 2, - "cost": 3.6324, + "cost": 2.546855016, "chosen": true } ], @@ -7941,7 +7906,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1000, - "cost": 1273.2, + "cost": 1203.877243, "chosen": true } ], @@ -8006,7 +7971,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "access_type": "scan", "resulting_rows": 5.9375, - "cost": 2.8296, + "cost": 2.829589844, "chosen": true } ], @@ -8014,12 +7979,12 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "type": "scan", "records": 5.9375, - "cost": 2.8296, + "cost": 2.829589844, "uses_join_buffering": false } }, "rows_for_plan": 5.9375, - "cost_for_plan": 4.0171, + "cost_for_plan": 4.017089844, "rest_of_plan": [ @@ -8036,22 +8001,22 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "access_type": "scan", - "resulting_rows": 804.69, - "cost": 256.85, + "resulting_rows": 804.6875, + "cost": 256.8548584, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records": 804.69, - "cost": 256.85, + "records": 804.6875, + "cost": 256.8548584, "uses_join_buffering": false } }, - "rows_for_plan": 4777.8, - "cost_for_plan": 1216.4, - "estimated_join_cardinality": 4777.8 + "rows_for_plan": 4777.832031, + "cost_for_plan": 1216.438354, + "estimated_join_cardinality": 4777.832031 } ] }, @@ -8068,21 +8033,21 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "access_type": "scan", - "resulting_rows": 804.69, - "cost": 43.26, + "resulting_rows": 804.6875, + "cost": 43.25976562, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records": 804.69, - "cost": 43.26, + "records": 804.6875, + "cost": 43.25976562, "uses_join_buffering": false } }, - "rows_for_plan": 804.69, - "cost_for_plan": 204.2, + "rows_for_plan": 804.6875, + "cost_for_plan": 204.1972656, "pruned_by_heuristic": true } ] @@ -8112,7 +8077,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "access_type": "scan", "resulting_rows": 10, - "cost": 2.0171, + "cost": 2.017089844, "chosen": true } ], @@ -8120,12 +8085,12 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "type": "scan", "records": 10, - "cost": 2.0171, + "cost": 2.017089844, "uses_join_buffering": false } }, "rows_for_plan": 10, - "cost_for_plan": 4.0171, + "cost_for_plan": 4.017089844, "rest_of_plan": [ @@ -8146,14 +8111,14 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "used_range_estimates": false, "cause": "not available", "rows": 1, - "cost": 20, + "cost": 20.00585794, "chosen": true }, { "access_type": "scan", - "resulting_rows": 804.69, - "cost": 43.26, + "resulting_rows": 804.6875, + "cost": 43.25976562, "chosen": false } ], @@ -8161,14 +8126,14 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "type": "ref", "records": 1, - "cost": 20, + "cost": 20.00585794, "uses_join_buffering": false } }, "rows_for_plan": 10, - "cost_for_plan": 26.017, - "selectivity": 0.8047, - "estimated_join_cardinality": 8.0469 + "cost_for_plan": 26.02294779, + "selectivity": 0.8046875, + "estimated_join_cardinality": 8.046875 } ] }, @@ -8185,21 +8150,21 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "access_type": "scan", - "resulting_rows": 804.69, - "cost": 43.26, + "resulting_rows": 804.6875, + "cost": 43.25976562, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records": 804.69, - "cost": 43.26, + "records": 804.6875, + "cost": 43.25976562, "uses_join_buffering": false } }, - "rows_for_plan": 804.69, - "cost_for_plan": 204.2, + "rows_for_plan": 804.6875, + "cost_for_plan": 204.1972656, "pruned_by_cost": true } ] @@ -8233,7 +8198,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1, - "cost": 2.4265, + "cost": 1.357887479, "chosen": true } ], @@ -8299,9 +8264,8 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.range_scan_alternatives')) "using_mrr": false, "index_only": true, "rows": 1, - "cost": 1.3033, - "chosen": false, - "cause": "cost" + "cost": 0.345829876, + "chosen": true } ] ] @@ -8337,7 +8301,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "access_type": "scan", "resulting_rows": 10, - "cost": 2.022, + "cost": 2.021972656, "chosen": true } ], @@ -8345,12 +8309,12 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "type": "scan", "records": 10, - "cost": 2.022, + "cost": 2.021972656, "uses_join_buffering": false } }, "rows_for_plan": 10, - "cost_for_plan": 4.022, + "cost_for_plan": 4.021972656, "rest_of_plan": [ @@ -8371,14 +8335,14 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "used_range_estimates": false, "cause": "not available", "rows": 1, - "cost": 20, + "cost": 20.00585794, "chosen": true }, { "access_type": "scan", "resulting_rows": 100, - "cost": 2.2197, + "cost": 2.219726562, "chosen": false } ], @@ -8386,12 +8350,12 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "type": "ref", "records": 1, - "cost": 20, + "cost": 20.00585794, "uses_join_buffering": false } }, "rows_for_plan": 10, - "cost_for_plan": 26.022, + "cost_for_plan": 26.0278306, "cost_for_sorting": 10, "estimated_join_cardinality": 10 } @@ -8411,7 +8375,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "access_type": "scan", "resulting_rows": 100, - "cost": 2.2197, + "cost": 2.219726562, "chosen": true, "use_tmp_table": true } @@ -8420,12 +8384,12 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "type": "scan", "records": 100, - "cost": 2.2197, + "cost": 2.219726562, "uses_join_buffering": false } }, "rows_for_plan": 100, - "cost_for_plan": 22.22, + "cost_for_plan": 22.21972656, "rest_of_plan": [ @@ -8446,14 +8410,14 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "used_range_estimates": false, "cause": "not available", "rows": 1, - "cost": 200, + "cost": 200.0585794, "chosen": true }, { "access_type": "scan", "resulting_rows": 10, - "cost": 2.022, + "cost": 2.021972656, "chosen": true } ], @@ -8461,12 +8425,12 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "type": "scan", "records": 10, - "cost": 2.022, + "cost": 2.021972656, "uses_join_buffering": true } }, "rows_for_plan": 1000, - "cost_for_plan": 224.24, + "cost_for_plan": 224.2416992, "pruned_by_cost": true } ] @@ -8502,7 +8466,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_columns')) [ "1 <= a <= 5" ], - "selectivity_from_histogram": 0.0469 + "selectivity_from_histogram": 0.046875 }, { @@ -8511,7 +8475,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_columns')) [ "NULL < b <= 5" ], - "selectivity_from_histogram": 0.0469 + "selectivity_from_histogram": 0.046875 } ] ] @@ -8554,7 +8518,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_columns')) [ "10 <= b < 25" ], - "selectivity_from_histogram": 0.1562 + "selectivity_from_histogram": 0.15625 } ] ] @@ -8584,7 +8548,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.range_scan_alternatives')) "using_mrr": false, "index_only": false, "rows": 0, - "cost": 1.125, + "cost": 0.145, "chosen": true } ] @@ -8601,3 +8565,233 @@ set max_session_mem_used=default; # # End of 10.4 tests # +set optimizer_trace='enabled=on'; +# +# Test many rows to see output of big cost numbers +# +select count(*) from seq_1_to_10000000; +count(*) +10000000 +select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +select count(*) from seq_1_to_10000000 { + "steps": [ + { + "join_preparation": { + "select_id": 1, + "steps": [ + { + "expanded_query": "select count(0) AS `count(*)` from seq_1_to_10000000" + } + ] + } + }, + { + "join_optimization": { + "select_id": 1, + "steps": [ + { + "table_dependencies": [ + { + "table": "seq_1_to_10000000", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [] + } + ] + }, + { + "rows_estimation": [ + { + "table": "seq_1_to_10000000", + "table_scan": { + "rows": 10000000, + "cost": 10000000 + } + } + ] + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [], + "table": "seq_1_to_10000000", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "scan", + "resulting_rows": 10000000, + "cost": 10000000, + "chosen": true + } + ], + "chosen_access_method": { + "type": "scan", + "records": 10000000, + "cost": 10000000, + "uses_join_buffering": false + } + }, + "rows_for_plan": 10000000, + "cost_for_plan": 12000000, + "estimated_join_cardinality": 10000000 + } + ] + }, + { + "best_join_order": ["seq_1_to_10000000"] + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [], + "attached_conditions_summary": [ + { + "table": "seq_1_to_10000000", + "attached": null + } + ] + } + } + ] + } + }, + { + "join_execution": { + "select_id": 1, + "steps": [] + } + } + ] +} 0 0 +# +# MDEV-22891: Optimizer trace: const tables are not clearly visible +# +create table t0(a int primary key); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (pk int primary key, a int); +insert into t1 select a,a from t0; +create table t2 (pk int primary key, a int); +insert into t2 select a,a from t0; +create table t3 (pk int primary key, a int); +insert into t3 select a,a from t0; +explain +select * from t1 left join (t2 join t3 on t3.pk=1000) on t2.a=t1.a and t2.pk is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 const PRIMARY NULL NULL NULL 1 Impossible ON condition +1 SIMPLE t2 const PRIMARY NULL NULL NULL 1 Impossible ON condition +1 SIMPLE t1 ALL NULL NULL NULL NULL 10 +select JSON_DETAILED(JSON_EXTRACT(trace, '$**.mark_join_nest_as_const')) +from information_schema.optimizer_trace; +JSON_DETAILED(JSON_EXTRACT(trace, '$**.mark_join_nest_as_const')) +[ + + { + "members": + [ + "t3", + "t2" + ] + } +] +drop table t0, t1, t2, t3; +# +# MDEV-23767: IN-to-subquery conversion is not visible in optimizer trace +# +create table t0 (a int); +INSERT INTO t0 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +set @tmp=@@in_predicate_conversion_threshold; +set in_predicate_conversion_threshold=3; +explain select * from t0 where a in (1,2,3,4,5,6); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t0 ALL NULL NULL NULL NULL 10 Using where +1 PRIMARY <derived3> ref key0 key0 4 test.t0.a 2 FirstMatch(t0) +3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used +select json_detailed(json_extract(trace, '$**.in_to_subquery_conversion')) +from information_schema.optimizer_trace; +json_detailed(json_extract(trace, '$**.in_to_subquery_conversion')) +[ + + { + "item": "t0.a in (1,2,3,4,5,6)", + "conversion": + [ + + { + "join_preparation": + { + "select_id": 2, + "steps": + [ + + { + "derived": + { + "table": "tvc_0", + "select_id": 3, + "algorithm": "materialized" + } + }, + + { + "transformation": + { + "select_id": 2, + "from": "IN (SELECT)", + "to": "materialization", + "sjm_scan_allowed": true, + "possible": true + } + }, + + { + "transformation": + { + "select_id": 2, + "from": "IN (SELECT)", + "to": "semijoin", + "chosen": true + } + }, + + { + "expanded_query": "/* select#2 */ select tvc_0._col_1 from (values (1),(2),(3),(4),(5),(6)) tvc_0" + } + ] + } + } + ] + } +] +explain select * from t0 where a in (1,2,3,4,5,a+1); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where +select json_detailed(json_extract(trace, '$**.in_to_subquery_conversion')) +from information_schema.optimizer_trace; +json_detailed(json_extract(trace, '$**.in_to_subquery_conversion')) +[ + + { + "item": "t0.a in (1,2,3,4,5,t0.a + 1)", + "done": false, + "reason": "non-constant element in the IN-list" + } +] +explain select * from t0 where a in ('1','2','3','4','5','6'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where +select json_detailed(json_extract(trace, '$**.in_to_subquery_conversion')) +from information_schema.optimizer_trace; +json_detailed(json_extract(trace, '$**.in_to_subquery_conversion')) +[ + + { + "item": "t0.a in ('1','2','3','4','5','6')", + "done": false, + "reason": "type mismatch" + } +] +set in_predicate_conversion_threshold=@tmp; +drop table t0; +# End of 10.5 tests +set optimizer_trace='enabled=off'; diff --git a/mysql-test/main/opt_trace.test b/mysql-test/main/opt_trace.test index 3fae7f34750..ecb6658e338 100644 --- a/mysql-test/main/opt_trace.test +++ b/mysql-test/main/opt_trace.test @@ -637,3 +637,64 @@ set max_session_mem_used=default; --echo # --echo # End of 10.4 tests --echo # + +set optimizer_trace='enabled=on'; + +--echo # +--echo # Test many rows to see output of big cost numbers +--echo # + +select count(*) from seq_1_to_10000000; +select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE; + +--echo # +--echo # MDEV-22891: Optimizer trace: const tables are not clearly visible +--echo # +create table t0(a int primary key); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t1 (pk int primary key, a int); +insert into t1 select a,a from t0; + +create table t2 (pk int primary key, a int); +insert into t2 select a,a from t0; + +create table t3 (pk int primary key, a int); +insert into t3 select a,a from t0; + +explain +select * from t1 left join (t2 join t3 on t3.pk=1000) on t2.a=t1.a and t2.pk is null; + +select JSON_DETAILED(JSON_EXTRACT(trace, '$**.mark_join_nest_as_const')) +from information_schema.optimizer_trace; + +drop table t0, t1, t2, t3; + +--echo # +--echo # MDEV-23767: IN-to-subquery conversion is not visible in optimizer trace +--echo # +create table t0 (a int); +INSERT INTO t0 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +set @tmp=@@in_predicate_conversion_threshold; +set in_predicate_conversion_threshold=3; + +explain select * from t0 where a in (1,2,3,4,5,6); + +select json_detailed(json_extract(trace, '$**.in_to_subquery_conversion')) +from information_schema.optimizer_trace; + +explain select * from t0 where a in (1,2,3,4,5,a+1); + +select json_detailed(json_extract(trace, '$**.in_to_subquery_conversion')) +from information_schema.optimizer_trace; + +explain select * from t0 where a in ('1','2','3','4','5','6'); +select json_detailed(json_extract(trace, '$**.in_to_subquery_conversion')) +from information_schema.optimizer_trace; + +set in_predicate_conversion_threshold=@tmp; +drop table t0; + +--echo # End of 10.5 tests +set optimizer_trace='enabled=off'; diff --git a/mysql-test/main/opt_trace_index_merge.result b/mysql-test/main/opt_trace_index_merge.result index ed5ddfd69f4..3b79a7a44e8 100644 --- a/mysql-test/main/opt_trace_index_merge.result +++ b/mysql-test/main/opt_trace_index_merge.result @@ -73,7 +73,7 @@ explain select * from t1 where a=1 or b=1 { "range_analysis": { "table_scan": { "rows": 1000, - "cost": 231.69 + "cost": 231.5878906 }, "potential_range_indexes": [ { @@ -93,10 +93,6 @@ explain select * from t1 where a=1 or b=1 { } ], "setup_range_conditions": [], - "group_index_range": { - "chosen": false, - "cause": "no group by or distinct" - }, "analyzing_range_alternatives": { "range_scan_alternatives": [], "analyzing_roworder_intersect": { @@ -115,12 +111,12 @@ explain select * from t1 where a=1 or b=1 { "using_mrr": false, "index_only": true, "rows": 1, - "cost": 1.1773, + "cost": 0.345585794, "chosen": true } ], "index_to_merge": "a", - "cumulated_cost": 1.1773 + "cumulated_cost": 0.345585794 }, { "range_scan_alternatives": [ @@ -131,15 +127,15 @@ explain select * from t1 where a=1 or b=1 { "using_mrr": false, "index_only": true, "rows": 1, - "cost": 1.1773, + "cost": 0.345585794, "chosen": true } ], "index_to_merge": "b", - "cumulated_cost": 2.3547 + "cumulated_cost": 0.691171589 } ], - "cost_of_reading_ranges": 2.3547, + "cost_of_reading_ranges": 0.691171589, "use_roworder_union": true, "cause": "always cheaper than non roworder retrieval", "analyzing_roworder_scans": [ @@ -162,12 +158,16 @@ explain select * from t1 where a=1 or b=1 { } } ], - "index_roworder_union_cost": 4.1484, + "index_roworder_union_cost": 2.484903732, "members": 2, "chosen": true } ] }, + "group_index_range": { + "chosen": false, + "cause": "no group by or distinct" + }, "chosen_range_access_summary": { "range_access_plan": { "type": "index_roworder_union", @@ -187,7 +187,7 @@ explain select * from t1 where a=1 or b=1 { ] }, "rows_for_plan": 2, - "cost_for_plan": 4.1484, + "cost_for_plan": 2.484903732, "chosen": true } } @@ -209,19 +209,19 @@ explain select * from t1 where a=1 or b=1 { { "access_type": "index_merge", "resulting_rows": 2, - "cost": 4.1484, + "cost": 2.484903732, "chosen": true } ], "chosen_access_method": { "type": "index_merge", "records": 2, - "cost": 4.1484, + "cost": 2.484903732, "uses_join_buffering": false } }, "rows_for_plan": 2, - "cost_for_plan": 4.5484, + "cost_for_plan": 2.884903732, "estimated_join_cardinality": 2 } ] @@ -322,7 +322,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 2243, - "cost": 2844.1, + "cost": 2700.058937, "chosen": true }, @@ -336,7 +336,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 2243, - "cost": 2844.1, + "cost": 2700.058937, "chosen": false, "cause": "cost" }, @@ -351,7 +351,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 2243, - "cost": 2844.1, + "cost": 2700.058937, "chosen": false, "cause": "cost" } @@ -363,10 +363,10 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) { "index": "key1", - "index_scan_cost": 58.252, - "cumulated_index_scan_cost": 58.252, - "disk_sweep_cost": 1923.1, - "cumulative_total_cost": 1981.4, + "index_scan_cost": 10.31393703, + "cumulated_index_scan_cost": 10.31393703, + "disk_sweep_cost": 1923.144061, + "cumulative_total_cost": 1933.457998, "usable": true, "matching_rows_now": 2243, "intersect_covering_with_this_index": false, @@ -375,24 +375,24 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) { "index": "key2", - "index_scan_cost": 58.252, - "cumulated_index_scan_cost": 116.5, - "disk_sweep_cost": 84.518, - "cumulative_total_cost": 201.02, + "index_scan_cost": 10.31393703, + "cumulated_index_scan_cost": 20.62787405, + "disk_sweep_cost": 84.51771758, + "cumulative_total_cost": 105.1455916, "usable": true, - "matching_rows_now": 77.636, + "matching_rows_now": 77.6360508, "intersect_covering_with_this_index": false, "chosen": true }, { "index": "key3", - "index_scan_cost": 58.252, - "cumulated_index_scan_cost": 174.76, + "index_scan_cost": 10.31393703, + "cumulated_index_scan_cost": 30.94181108, "disk_sweep_cost": 0, - "cumulative_total_cost": 174.76, + "cumulative_total_cost": 30.94181108, "usable": true, - "matching_rows_now": 2.6872, + "matching_rows_now": 2.687185191, "intersect_covering_with_this_index": true, "chosen": true } @@ -403,7 +403,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "cause": "no clustered pk index" }, "rows": 2, - "cost": 174.76, + "cost": 30.94181108, "covering": true, "chosen": true }, @@ -421,7 +421,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary')) { "type": "index_roworder_intersect", "rows": 2, - "cost": 174.76, + "cost": 30.94181108, "covering": true, "clustered_pk_scan": false, "intersect_of": @@ -459,7 +459,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary')) ] }, "rows_for_plan": 2, - "cost_for_plan": 174.76, + "cost_for_plan": 30.94181108, "chosen": true } ] @@ -500,7 +500,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": true, "rows": 2243, - "cost": 152.53, + "cost": 457.058937, "chosen": true }, @@ -514,13 +514,13 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": true, "rows": 2243, - "cost": 152.53, + "cost": 457.058937, "chosen": false, "cause": "cost" } ], "index_to_merge": "key1", - "cumulated_cost": 152.53 + "cumulated_cost": 457.058937 }, { @@ -537,7 +537,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": true, "rows": 2243, - "cost": 152.53, + "cost": 457.058937, "chosen": true }, @@ -551,16 +551,16 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": true, "rows": 2243, - "cost": 152.53, + "cost": 457.058937, "chosen": false, "cause": "cost" } ], "index_to_merge": "key3", - "cumulated_cost": 305.05 + "cumulated_cost": 914.1178741 } ], - "cost_of_reading_ranges": 305.05, + "cost_of_reading_ranges": 914.1178741, "use_roworder_union": true, "cause": "always cheaper than non roworder retrieval", "analyzing_roworder_scans": @@ -581,10 +581,10 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) { "index": "key1", - "index_scan_cost": 58.252, - "cumulated_index_scan_cost": 58.252, - "disk_sweep_cost": 1923.1, - "cumulative_total_cost": 1981.4, + "index_scan_cost": 10.31393703, + "cumulated_index_scan_cost": 10.31393703, + "disk_sweep_cost": 1923.144061, + "cumulative_total_cost": 1933.457998, "usable": true, "matching_rows_now": 2243, "intersect_covering_with_this_index": false, @@ -593,12 +593,12 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) { "index": "key2", - "index_scan_cost": 58.252, - "cumulated_index_scan_cost": 116.5, - "disk_sweep_cost": 84.518, - "cumulative_total_cost": 201.02, + "index_scan_cost": 10.31393703, + "cumulated_index_scan_cost": 20.62787405, + "disk_sweep_cost": 84.51771758, + "cumulative_total_cost": 105.1455916, "usable": true, - "matching_rows_now": 77.636, + "matching_rows_now": 77.6360508, "intersect_covering_with_this_index": false, "chosen": true } @@ -609,7 +609,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "cause": "no clustered pk index" }, "rows": 77, - "cost": 201.02, + "cost": 105.1455916, "covering": false, "chosen": true } @@ -630,10 +630,10 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) { "index": "key3", - "index_scan_cost": 58.252, - "cumulated_index_scan_cost": 58.252, - "disk_sweep_cost": 1923.1, - "cumulative_total_cost": 1981.4, + "index_scan_cost": 10.31393703, + "cumulated_index_scan_cost": 10.31393703, + "disk_sweep_cost": 1923.144061, + "cumulative_total_cost": 1933.457998, "usable": true, "matching_rows_now": 2243, "intersect_covering_with_this_index": false, @@ -642,12 +642,12 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) { "index": "key4", - "index_scan_cost": 58.252, - "cumulated_index_scan_cost": 116.5, - "disk_sweep_cost": 84.518, - "cumulative_total_cost": 201.02, + "index_scan_cost": 10.31393703, + "cumulated_index_scan_cost": 20.62787405, + "disk_sweep_cost": 84.51771758, + "cumulative_total_cost": 105.1455916, "usable": true, - "matching_rows_now": 77.636, + "matching_rows_now": 77.6360508, "intersect_covering_with_this_index": false, "chosen": true } @@ -658,13 +658,13 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "cause": "no clustered pk index" }, "rows": 77, - "cost": 201.02, + "cost": 105.1455916, "covering": false, "chosen": true } } ], - "index_roworder_union_cost": 386.73, + "index_roworder_union_cost": 194.9771115, "members": 2, "chosen": true } @@ -685,7 +685,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary')) { "type": "index_roworder_intersect", "rows": 77, - "cost": 201.02, + "cost": 105.1455916, "covering": false, "clustered_pk_scan": false, "intersect_of": @@ -716,7 +716,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary')) { "type": "index_roworder_intersect", "rows": 77, - "cost": 201.02, + "cost": 105.1455916, "covering": false, "clustered_pk_scan": false, "intersect_of": @@ -746,7 +746,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary')) ] }, "rows_for_plan": 154, - "cost_for_plan": 386.73, + "cost_for_plan": 194.9771115, "chosen": true } ] diff --git a/mysql-test/main/opt_trace_index_merge_innodb.result b/mysql-test/main/opt_trace_index_merge_innodb.result index 97c2c262bfc..509569021a5 100644 --- a/mysql-test/main/opt_trace_index_merge_innodb.result +++ b/mysql-test/main/opt_trace_index_merge_innodb.result @@ -88,7 +88,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "range_analysis": { "table_scan": { "rows": 1000, - "cost": 206.1 + "cost": 206 }, "potential_range_indexes": [ { @@ -108,10 +108,6 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { } ], "setup_range_conditions": [], - "group_index_range": { - "chosen": false, - "cause": "no group by or distinct" - }, "analyzing_range_alternatives": { "range_scan_alternatives": [ { @@ -121,7 +117,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "using_mrr": false, "index_only": false, "rows": 1000, - "cost": 204.01, + "cost": 204.27, "chosen": true }, { @@ -131,7 +127,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "using_mrr": false, "index_only": false, "rows": 1, - "cost": 2.3751, + "cost": 1.345146475, "chosen": true } ], @@ -139,10 +135,10 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "intersecting_indexes": [ { "index": "key1", - "index_scan_cost": 1.0001, - "cumulated_index_scan_cost": 1.0001, - "disk_sweep_cost": 1.0042, - "cumulative_total_cost": 2.0043, + "index_scan_cost": 1.000146475, + "cumulated_index_scan_cost": 1.000146475, + "disk_sweep_cost": 1.004153686, + "cumulative_total_cost": 2.004300162, "usable": true, "matching_rows_now": 1, "intersect_covering_with_this_index": false, @@ -154,10 +150,14 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "cause": "cost" }, "chosen": false, - "cause": "too few indexes to merge" + "cause": "cost" }, "analyzing_index_merge_union": [] }, + "group_index_range": { + "chosen": false, + "cause": "no group by or distinct" + }, "chosen_range_access_summary": { "range_access_plan": { "type": "range_scan", @@ -166,7 +166,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "ranges": ["(1) <= (key1) <= (1)"] }, "rows_for_plan": 1, - "cost_for_plan": 2.3751, + "cost_for_plan": 1.345146475, "chosen": true } } @@ -176,7 +176,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "rowid_filters": [ { "key": "key1", - "build_cost": 1.1801, + "build_cost": 0.130146475, "rows": 1 } ] @@ -209,7 +209,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "index": "key1", "used_range_estimates": true, "rows": 1, - "cost": 2, + "cost": 1.125146475, "chosen": true }, { @@ -221,12 +221,12 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "chosen_access_method": { "type": "ref", "records": 1, - "cost": 2, + "cost": 1.125146475, "uses_join_buffering": false } }, "rows_for_plan": 1, - "cost_for_plan": 2.2, + "cost_for_plan": 1.325146475, "estimated_join_cardinality": 1 } ] diff --git a/mysql-test/main/opt_trace_security.result b/mysql-test/main/opt_trace_security.result index 6f377cd02b5..2c09f6c7d5a 100644 --- a/mysql-test/main/opt_trace_security.result +++ b/mysql-test/main/opt_trace_security.result @@ -80,7 +80,7 @@ select * from db1.t1 { "table": "t1", "table_scan": { "rows": 3, - "cost": 2.0051 + "cost": 2.005126953 } } ] @@ -95,19 +95,19 @@ select * from db1.t1 { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": false } }, "rows_for_plan": 3, - "cost_for_plan": 2.6051, + "cost_for_plan": 2.605126953, "estimated_join_cardinality": 3 } ] @@ -203,7 +203,7 @@ select * from db1.v1 { "table": "t1", "table_scan": { "rows": 3, - "cost": 2.0051 + "cost": 2.005126953 } } ] @@ -218,19 +218,19 @@ select * from db1.v1 { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.0051, + "cost": 2.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.0051, + "cost": 2.005126953, "uses_join_buffering": false } }, "rows_for_plan": 3, - "cost_for_plan": 2.6051, + "cost_for_plan": 2.605126953, "estimated_join_cardinality": 3 } ] diff --git a/mysql-test/main/opt_trace_ucs2.result b/mysql-test/main/opt_trace_ucs2.result index 306fdbf94ad..5de1fc5c3e9 100644 --- a/mysql-test/main/opt_trace_ucs2.result +++ b/mysql-test/main/opt_trace_ucs2.result @@ -38,7 +38,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 2, - "cost": 3.7609, + "cost": 2.547733708, "chosen": true } ], diff --git a/mysql-test/main/opt_tvc.result b/mysql-test/main/opt_tvc.result index a68e70e8a25..9752aa71bfb 100644 --- a/mysql-test/main/opt_tvc.result +++ b/mysql-test/main/opt_tvc.result @@ -568,18 +568,18 @@ explain extended select * from t1 where (a,b) not in ((1,2),(8,9), (5,1)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where -2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 3 100.00 +2 DEPENDENT SUBQUERY <derived3> index_subquery key0 key0 8 func,func 2 100.00 Using where; Full scan on NULL key 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<expr_cache><`test`.`t1`.`a`,`test`.`t1`.`b`>(<in_optimizer>((`test`.`t1`.`a`,`test`.`t1`.`b`),(`test`.`t1`.`a`,`test`.`t1`.`b`) in ( <materialize> (/* select#2 */ select `tvc_0`.`_col_1`,`tvc_0`.`_col_2` from (values (1,2),(8,9),(5,1)) `tvc_0` ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where `test`.`t1`.`a` = `<subquery2>`.`_col_1` and `test`.`t1`.`b` = `<subquery2>`.`_col_2`)))) +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<expr_cache><`test`.`t1`.`a`,`test`.`t1`.`b`>(<in_optimizer>((`test`.`t1`.`a`,`test`.`t1`.`b`),<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in (temporary) on key0 where trigcond(<cache>(`test`.`t1`.`a`) = `tvc_0`.`_col_1`) and trigcond(<cache>(`test`.`t1`.`b`) = `tvc_0`.`_col_2`))))) explain extended select * from t1 where (a,b) not in (select * from (values (1,2),(8,9), (5,1)) as tvc_0); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where -2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 3 100.00 +2 DEPENDENT SUBQUERY <derived3> index_subquery key0 key0 8 func,func 2 100.00 Using where; Full scan on NULL key 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<expr_cache><`test`.`t1`.`a`,`test`.`t1`.`b`>(<in_optimizer>((`test`.`t1`.`a`,`test`.`t1`.`b`),(`test`.`t1`.`a`,`test`.`t1`.`b`) in ( <materialize> (/* select#2 */ select `tvc_0`.`1`,`tvc_0`.`2` from (values (1,2),(8,9),(5,1)) `tvc_0` ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where `test`.`t1`.`a` = `<subquery2>`.`1` and `test`.`t1`.`b` = `<subquery2>`.`2`)))) +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<expr_cache><`test`.`t1`.`a`,`test`.`t1`.`b`>(<in_optimizer>((`test`.`t1`.`a`,`test`.`t1`.`b`),<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in (temporary) on key0 where trigcond(<cache>(`test`.`t1`.`a`) = `tvc_0`.`1`) and trigcond(<cache>(`test`.`t1`.`b`) = `tvc_0`.`2`))))) select * from t1 where b < 7 and (a,b) not in ((1,2),(8,9), (5,1)); a b @@ -590,10 +590,10 @@ explain extended select * from t1 where b < 7 and (a,b) not in ((1,2),(8,9), (5,1)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where -2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 3 100.00 +2 DEPENDENT SUBQUERY <derived3> index_subquery key0 key0 8 func,func 2 100.00 Using where; Full scan on NULL key 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` < 7 and !<expr_cache><`test`.`t1`.`a`,`test`.`t1`.`b`>(<in_optimizer>((`test`.`t1`.`a`,`test`.`t1`.`b`),(`test`.`t1`.`a`,`test`.`t1`.`b`) in ( <materialize> (/* select#2 */ select `tvc_0`.`_col_1`,`tvc_0`.`_col_2` from (values (1,2),(8,9),(5,1)) `tvc_0` ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where `test`.`t1`.`a` = `<subquery2>`.`_col_1` and `test`.`t1`.`b` = `<subquery2>`.`_col_2`)))) +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` < 7 and !<expr_cache><`test`.`t1`.`a`,`test`.`t1`.`b`>(<in_optimizer>((`test`.`t1`.`a`,`test`.`t1`.`b`),<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in (temporary) on key0 where trigcond(<cache>(`test`.`t1`.`a`) = `tvc_0`.`_col_1`) and trigcond(<cache>(`test`.`t1`.`b`) = `tvc_0`.`_col_2`))))) select * from t2 where (a,c) not in ((1,2),(8,9), (5,1)); a b c @@ -606,10 +606,10 @@ explain extended select * from t2 where (a,c) not in ((1,2),(8,9), (5,1)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 6 100.00 Using where -2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 3 100.00 +2 DEPENDENT SUBQUERY <derived3> index_subquery key0 key0 8 func,func 2 100.00 Using where; Full scan on NULL key 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where !<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`c`>(<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`c`),(`test`.`t2`.`a`,`test`.`t2`.`c`) in ( <materialize> (/* select#2 */ select `tvc_0`.`_col_1`,`tvc_0`.`_col_2` from (values (1,2),(8,9),(5,1)) `tvc_0` ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where `test`.`t2`.`a` = `<subquery2>`.`_col_1` and `test`.`t2`.`c` = `<subquery2>`.`_col_2`)))) +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where !<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`c`>(<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`c`),<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in (temporary) on key0 where trigcond(<cache>(`test`.`t2`.`a`) = `tvc_0`.`_col_1`) and trigcond(<cache>(`test`.`t2`.`c`) = `tvc_0`.`_col_2`))))) drop table t1, t2, t3; set @@in_predicate_conversion_threshold= default; # diff --git a/mysql-test/main/order_by.result b/mysql-test/main/order_by.result index 129bd8928f2..dc29859c112 100644 --- a/mysql-test/main/order_by.result +++ b/mysql-test/main/order_by.result @@ -1193,7 +1193,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 index k2 k3 5 NULL 111 Using where EXPLAIN SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 4000; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ref k2 k2 5 const 7341 Using where; Using filesort +1 SIMPLE t2 index k2 k3 5 NULL 22318 Using where EXPLAIN SELECT id,c3 FROM t2 WHERE c2 BETWEEN 10 AND 12 ORDER BY c3 LIMIT 20; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 index k2 k3 5 NULL 73 Using where @@ -3120,7 +3120,7 @@ id select_type table type possible_keys key key_len ref rows Extra # See above query EXPLAIN SELECT id1 FROM t2 WHERE id2=1 AND id3=1 ORDER BY date DESC LIMIT 0,4; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ref id_23_date,id_234_date id_23_date 2 const,const 8 Using where +1 SIMPLE t2 range id_23_date,id_234_date id_23_date 2 NULL 8 Using where drop table t1,t2; # # MDEV-8989: ORDER BY optimizer ignores equality propagation @@ -3409,16 +3409,17 @@ ANALYZE "r_total_time_ms": "REPLACED", "r_limit": 5, "r_used_priority_queue": false, - "r_output_rows": 35, - "r_sort_passes": 1, + "r_output_rows": 100, "r_buffer_size": "REPLACED", + "r_sort_mode": "sort_key,packed_addon_fields", "table": { "table_name": "t1", "access_type": "ALL", "r_loops": 1, "rows": 100, "r_rows": 100, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 } @@ -3658,3 +3659,642 @@ set histogram_size=@tmp_h, histogram_type=@tmp_ht, use_stat_tables=@tmp_u, optimizer_use_condition_selectivity=@tmp_o; drop table t1,t2,t3,t4; # End of 10.4 tests +# +# MDEV-21655: Server crashes in my_qsort2 / Filesort_buffer::sort_buffer +# +set @save_sql_mode= @@sql_mode; +set sql_mode= 'PAD_CHAR_TO_FULL_LENGTH'; +CREATE TABLE t1 ( a CHAR(255), b CHAR(255), c TEXT); +INSERT INTO t1 VALUES +('1','a', 'a'), ('2','b', 'b'), ('3','c', 'c'), ('4','d','d'), +('5','e', 'e'), ('6','f', 'f'), ('7','g','g'), ('8','h','h'), +('9','i', 'i'), ('10','j','j'), ('11','k','k'), ('12','l','l'), +('13','m','m'), ('14','n','n'), ('15','o','o'); +set sort_buffer_size=524*15; +select c from t1 order by a,b; +c +a +j +k +l +m +n +o +b +c +d +e +f +g +h +i +set sort_buffer_size= default; +set sql_mode= @save_sql_mode; +drop table t1; +# +# MDEV-21580: Allow packed sort keys in sort buffer +# +# +# This example should not pack sort keys +# all fields are fixed-size fields in the ORDER BY clause +# +create table t1 (a bigint, b bigint, c bigint); +insert into t1 select seq, seq, seq from seq_1_to_100; +# in r_sort_mode it should show sort_key and not packed_sort_key +ANALYZE FORMAT=JSON select * from t1 order by a,b,c; +ANALYZE +{ + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "read_sorted_file": { + "r_rows": 100, + "filesort": { + "sort_key": "t1.a, t1.b, t1.c", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "r_used_priority_queue": false, + "r_output_rows": 100, + "r_buffer_size": "REPLACED", + "r_sort_mode": "sort_key,packed_addon_fields", + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 100, + "r_rows": 100, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + } + } +} +select * from t1 order by a,b,c; +a b c +1 1 1 +2 2 2 +3 3 3 +4 4 4 +5 5 5 +6 6 6 +7 7 7 +8 8 8 +9 9 9 +10 10 10 +11 11 11 +12 12 12 +13 13 13 +14 14 14 +15 15 15 +16 16 16 +17 17 17 +18 18 18 +19 19 19 +20 20 20 +21 21 21 +22 22 22 +23 23 23 +24 24 24 +25 25 25 +26 26 26 +27 27 27 +28 28 28 +29 29 29 +30 30 30 +31 31 31 +32 32 32 +33 33 33 +34 34 34 +35 35 35 +36 36 36 +37 37 37 +38 38 38 +39 39 39 +40 40 40 +41 41 41 +42 42 42 +43 43 43 +44 44 44 +45 45 45 +46 46 46 +47 47 47 +48 48 48 +49 49 49 +50 50 50 +51 51 51 +52 52 52 +53 53 53 +54 54 54 +55 55 55 +56 56 56 +57 57 57 +58 58 58 +59 59 59 +60 60 60 +61 61 61 +62 62 62 +63 63 63 +64 64 64 +65 65 65 +66 66 66 +67 67 67 +68 68 68 +69 69 69 +70 70 70 +71 71 71 +72 72 72 +73 73 73 +74 74 74 +75 75 75 +76 76 76 +77 77 77 +78 78 78 +79 79 79 +80 80 80 +81 81 81 +82 82 82 +83 83 83 +84 84 84 +85 85 85 +86 86 86 +87 87 87 +88 88 88 +89 89 89 +90 90 90 +91 91 91 +92 92 92 +93 93 93 +94 94 94 +95 95 95 +96 96 96 +97 97 97 +98 98 98 +99 99 99 +100 100 100 +drop table t1; +# +# Test with Binary columns (using suffix length to determine ordering) +# Should show packed_sortkey in the r_sort_mode +# +create table t1 (a int, b blob); +set @save_max_sort_length= @@max_sort_length; +insert into t1 select 1, CONCAT(repeat('a', @save_max_sort_length), 'A'); +insert into t1 select 2, CONCAT(repeat('a', @save_max_sort_length), 'AB'); +insert into t1 select 3, CONCAT(repeat('a', @save_max_sort_length), 'ABE'); +insert into t1 select 4, CONCAT(repeat('a', @save_max_sort_length), 'APBX'); +insert into t1 select 5, CONCAT(repeat('a', @save_max_sort_length), 'ABAAX'); +show variables like '%sort_buffer_size'; +Variable_name Value +aria_sort_buffer_size 268434432 +myisam_sort_buffer_size 134216704 +sort_buffer_size 262144 +select a, substr(b, @save_max_sort_length+1) from t1 order by b desc; +a substr(b, @save_max_sort_length+1) +5 ABAAX +4 APBX +3 ABE +2 AB +1 A +analyze format=json +select a, substr(b, @save_max_sort_length+1) from t1 order by b desc; +ANALYZE +{ + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "read_sorted_file": { + "r_rows": 5, + "filesort": { + "sort_key": "t1.b desc", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "r_used_priority_queue": false, + "r_output_rows": 5, + "r_buffer_size": "REPLACED", + "r_sort_mode": "packed_sort_key,rowid", + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 5, + "r_rows": 5, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + } + } +} +drop table t1; +# +# Packing sort keys with complex collations +# +create table t1(a varchar(255) charset utf8, b int, c decimal); +insert into t1 values ('abc', 1, 1) , ('bcd', 2, 2), ('cde',3, 3); +insert into t1 values ('def', 4, 4) , ('efg', 5, 5), ('fgh', 6, 6); +# +# Should show packed_sortkey in the r_sort_mode +# +ANALYZE FORMAT=JSON select a, b, c from t1 order by a, b; +ANALYZE +{ + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "read_sorted_file": { + "r_rows": 6, + "filesort": { + "sort_key": "t1.a, t1.b", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "r_used_priority_queue": false, + "r_output_rows": 6, + "r_buffer_size": "REPLACED", + "r_sort_mode": "packed_sort_key,rowid", + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 6, + "r_rows": 6, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + } + } +} +select a, b, c from t1 order by a, b; +a b c +abc 1 1 +bcd 2 2 +cde 3 3 +def 4 4 +efg 5 5 +fgh 6 6 +set @save_max_sort_length= @@max_sort_length; +set max_sort_length=5; +Warnings: +Warning 1292 Truncated incorrect max_sort_length value: '5' +# +# should show sortkey in r_sort_mode as the collation is complex and +# truncation is not possible +# +ANALYZE FORMAT=JSON select a, b, c from t1 order by a, b; +ANALYZE +{ + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "read_sorted_file": { + "r_rows": 6, + "filesort": { + "sort_key": "t1.a, t1.b", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "r_used_priority_queue": false, + "r_output_rows": 6, + "r_buffer_size": "REPLACED", + "r_sort_mode": "sort_key,packed_addon_fields", + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 6, + "r_rows": 6, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + } + } +} +select a, b, c from t1 order by a, b; +a b c +abc 1 1 +bcd 2 2 +cde 3 3 +def 4 4 +efg 5 5 +fgh 6 6 +set max_sort_length= @save_max_sort_length; +drop table t1; +# +# MDEV-21922: Allow packing addon fields even if they don't honour max_length_for_sort_data +# +create table t1 (a varchar(200) character set utf8, b int); +insert into t1 select seq, seq from seq_1_to_10; +select * from t1 order by a; +a b +1 1 +10 10 +2 2 +3 3 +4 4 +5 5 +6 6 +7 7 +8 8 +9 9 +# +# r_sort_mode should show both packed_sort_key and packed_addon_fields +# +analyze format=json select * from t1 order by a; +ANALYZE +{ + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "read_sorted_file": { + "r_rows": 10, + "filesort": { + "sort_key": "t1.a", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "r_used_priority_queue": false, + "r_output_rows": 10, + "r_buffer_size": "REPLACED", + "r_sort_mode": "packed_sort_key,packed_addon_fields", + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 10, + "r_rows": 10, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + } + } +} +drop table t1; +# +# MDEV-21946: Server crash in store_length upon GROUP BY WITH ROLLUP with geometry field +# +create table t1 ( a longblob); +insert into t1 select repeat('a', 256); +insert into t1 select repeat('b', 256); +insert into t1 select repeat('c', 256); +insert into t1 select repeat('d', 256); +SELECT IF( 0, NULL, a ) AS f FROM t1 GROUP BY f WITH ROLLUP; +f +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd +NULL +DROP TABLE t1; +# +# MDEV-22303: Incorrect ordering with REGEXP_REPLACE and OFFSET/LIMIT +# +CREATE TABLE t1 (name VARCHAR(20) CHARACTER SET utf8 NOT NULL); +INSERT INTO t1 (name) VALUES ('Charles Dickens'), ('Roald Dahl'); +SELECT name, REGEXP_REPLACE(name, '^(.*) (.*)$', '\\2, \\1') AS surname_first FROM t1 +ORDER BY surname_first ASC; +name surname_first +Roald Dahl Dahl, Roald +Charles Dickens Dickens, Charles +SELECT name, REGEXP_REPLACE(name, '^(.*) (.*)$', '\\2, \\1') AS surname_first FROM t1 +ORDER BY surname_first ASC LIMIT 1; +name surname_first +Roald Dahl Dahl, Roald +SELECT name, REGEXP_REPLACE(name, '^(.*) (.*)$', '\\2, \\1') AS surname_first FROM t1 +ORDER BY surname_first ASC LIMIT 1 OFFSET 1; +name surname_first +Charles Dickens Dickens, Charles +DROP TABLE t1; +# +# MDEV-22836: Server crashes in err_conv / ErrBuff::set_str +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0),(1); +SELECT * FROM t1 ORDER BY CONVERT(AES_ENCRYPT(1,a), CHAR(4)); +a +1 +0 +DROP TABLE t1; +# +# MDEV-22819:Wrong result or Assertion `ix > 0' failed in read_to_buffer upon select +# with GROUP BY and GROUP_CONCAT +# +CREATE TABLE t1 (a VARCHAR(1000), b CHAR(1)); +INSERT INTO t1 VALUES +(REPEAT('a',1000),'a'),(REPEAT('t',932),'t'),('x',NULL),('x',NULL), +(REPEAT('z',298),'z'),(REPEAT('p',1000),'p'),(REPEAT('k',468),'k'), +(REPEAT('c',1000),'c'),(REPEAT('o',648),'o'),('x',NULL),('x',NULL), +(REPEAT('c',258),'c'),(REPEAT('t',414),'t'),(REPEAT('f',966),'f'), +(REPEAT('y',746),'y'),(REPEAT('f',1000),'f'); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +SET @save_sort_buffer_size= @@sort_buffer_size; +SET sort_buffer_size= 16384; +SELECT LEFT(a,1), GROUP_CONCAT(b) FROM t1 GROUP BY a; +LEFT(a,1) GROUP_CONCAT(b) +a a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a +c c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c +c c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c +f f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f +f f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f +k k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k +o o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o +p p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p +t t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t +t t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t +x NULL +y y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y +z z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z +SELECT SUBSTR(a,1,1), LENGTH(a), GROUP_CONCAT(b), COUNT(*) FROM t1 GROUP BY a; +SUBSTR(a,1,1) LENGTH(a) GROUP_CONCAT(b) COUNT(*) +a 1000 a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a 16 +c 258 c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c 16 +c 1000 c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c 16 +f 966 f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f 16 +f 1000 f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f 16 +k 468 k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k 16 +o 648 o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o 16 +p 1000 p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p 16 +t 414 t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t 16 +t 932 t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t 16 +x 1 NULL 64 +y 746 y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y 16 +z 298 z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z 16 +SET @@sort_buffer_size= @save_sort_buffer_size; +DROP TABLE t1; +CREATE TABLE t1(a VARCHAR(1027), b INT); +INSERT INTO t1 SELECT seq, seq from seq_1_to_34; +SET @save_tmp_memory_table_size= @@tmp_memory_table_size; +SET tmp_memory_table_size= 1056*2; +SELECT COUNT(DISTINCT a) FROM t1; +COUNT(DISTINCT a) +34 +SET @@tmp_memory_table_size= @save_tmp_memory_table_size; +DROP TABLE t1; +# +# MDEV-23216: LONGTEXT column with collation doesn't sort +# +CREATE TABLE t1 (a LONGTEXT COLLATE utf8mb4_swedish_ci); +INSERT INTO t1 VALUES ('A'),('Z'),('B'),('Y'); +SELECT * FROM t1 ORDER BY a; +a +A +B +Y +Z +SELECT * FROM t1 ORDER BY a DESC; +a +Z +Y +B +A +DROP TABLE t1; +# +# MDEV-23414 Assertion `res->charset() == item->collation.collation' failed in Type_handler_string_result::make_packed_sort_key_part +# +CREATE TABLE t1 (a CHAR(3), b BINARY(255)); +INSERT t1 VALUES ('foo','bar'),('baz','qux'); +SELECT COALESCE(a, b) AS f FROM t1 ORDER BY f; +f +baz +foo +DROP TABLE t1; +# +# MDEV-24015: SQL Error (1038): Out of sort memory when enough memory for the +# sort buffer is provided +# +CREATE TABLE t1 (a VARCHAR(100), b INT); +CREATE TABLE t2 (a VARCHAR(100), b INT); +INSERT INTO t1 SELECT 'abc', seq FROM seq_1_to_50; +INSERT INTO t2 SELECT seq, seq FROM seq_1_to_50; +set @save_sort_buffer_size= @@sort_buffer_size; +set sort_buffer_size=2000; +ANALYZE FORMAT=JSON +SELECT (SELECT sum(t2.b) FROM t2 WHERE t1.b=t2.b GROUP BY t2.a) FROM t1; +ANALYZE +{ + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 50, + "r_rows": 50, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + }, + "subqueries": [ + { + "expression_cache": { + "r_loops": 50, + "r_hit_ratio": 0, + "query_block": { + "select_id": 2, + "r_loops": 50, + "r_total_time_ms": "REPLACED", + "filesort": { + "sort_key": "t2.a", + "r_loops": 50, + "r_total_time_ms": "REPLACED", + "r_used_priority_queue": false, + "r_output_rows": 1, + "r_buffer_size": "REPLACED" across executions)", + "r_sort_mode": "sort_key,rowid", + "temporary_table": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "r_loops": 50, + "rows": 50, + "r_rows": 50, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 2, + "attached_condition": "t1.b = t2.b" + } + } + } + } + } + } + ] + } +} +SELECT (SELECT sum(t2.b) FROM t2 WHERE t1.b=t2.b GROUP BY t2.a) FROM t1; +(SELECT sum(t2.b) FROM t2 WHERE t1.b=t2.b GROUP BY t2.a) +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +set sort_buffer_size= @save_sort_buffer_size; +DROP TABLE t1,t2; +# End of 10.5 tests diff --git a/mysql-test/main/order_by.test b/mysql-test/main/order_by.test index 0bf0311a642..4cdd8d0b1c2 100644 --- a/mysql-test/main/order_by.test +++ b/mysql-test/main/order_by.test @@ -9,6 +9,7 @@ drop table if exists t1,t2,t3; --enable_warnings call mtr.add_suppression("Out of sort memory; increase server sort buffer size"); +--source include/have_sequence.inc # # Test old ORDER BY bug @@ -2388,3 +2389,228 @@ set histogram_size=@tmp_h, histogram_type=@tmp_ht, use_stat_tables=@tmp_u, drop table t1,t2,t3,t4; --echo # End of 10.4 tests + +--echo # +--echo # MDEV-21655: Server crashes in my_qsort2 / Filesort_buffer::sort_buffer +--echo # + +set @save_sql_mode= @@sql_mode; +set sql_mode= 'PAD_CHAR_TO_FULL_LENGTH'; +CREATE TABLE t1 ( a CHAR(255), b CHAR(255), c TEXT); +INSERT INTO t1 VALUES +('1','a', 'a'), ('2','b', 'b'), ('3','c', 'c'), ('4','d','d'), +('5','e', 'e'), ('6','f', 'f'), ('7','g','g'), ('8','h','h'), +('9','i', 'i'), ('10','j','j'), ('11','k','k'), ('12','l','l'), +('13','m','m'), ('14','n','n'), ('15','o','o'); + +set sort_buffer_size=524*15; +select c from t1 order by a,b; +set sort_buffer_size= default; +set sql_mode= @save_sql_mode; +drop table t1; + +--echo # +--echo # MDEV-21580: Allow packed sort keys in sort buffer +--echo # + +--echo # +--echo # This example should not pack sort keys +--echo # all fields are fixed-size fields in the ORDER BY clause +--echo # + +create table t1 (a bigint, b bigint, c bigint); +insert into t1 select seq, seq, seq from seq_1_to_100; + +--echo # in r_sort_mode it should show sort_key and not packed_sort_key +--source include/analyze-format.inc +ANALYZE FORMAT=JSON select * from t1 order by a,b,c; +select * from t1 order by a,b,c; + +drop table t1; + +--echo # +--echo # Test with Binary columns (using suffix length to determine ordering) +--echo # Should show packed_sortkey in the r_sort_mode +--echo # + +create table t1 (a int, b blob); + +set @save_max_sort_length= @@max_sort_length; +insert into t1 select 1, CONCAT(repeat('a', @save_max_sort_length), 'A'); +insert into t1 select 2, CONCAT(repeat('a', @save_max_sort_length), 'AB'); +insert into t1 select 3, CONCAT(repeat('a', @save_max_sort_length), 'ABE'); +insert into t1 select 4, CONCAT(repeat('a', @save_max_sort_length), 'APBX'); +insert into t1 select 5, CONCAT(repeat('a', @save_max_sort_length), 'ABAAX'); + +show variables like '%sort_buffer_size'; + +select a, substr(b, @save_max_sort_length+1) from t1 order by b desc; +--source include/analyze-format.inc +analyze format=json +select a, substr(b, @save_max_sort_length+1) from t1 order by b desc; + +drop table t1; + +--echo # +--echo # Packing sort keys with complex collations +--echo # + +create table t1(a varchar(255) charset utf8, b int, c decimal); +insert into t1 values ('abc', 1, 1) , ('bcd', 2, 2), ('cde',3, 3); +insert into t1 values ('def', 4, 4) , ('efg', 5, 5), ('fgh', 6, 6); + +--echo # +--echo # Should show packed_sortkey in the r_sort_mode +--echo # + +--source include/analyze-format.inc +ANALYZE FORMAT=JSON select a, b, c from t1 order by a, b; +select a, b, c from t1 order by a, b; + +set @save_max_sort_length= @@max_sort_length; +set max_sort_length=5; + +--echo # +--echo # should show sortkey in r_sort_mode as the collation is complex and +--echo # truncation is not possible +--echo # + +--source include/analyze-format.inc +ANALYZE FORMAT=JSON select a, b, c from t1 order by a, b; +select a, b, c from t1 order by a, b; + +set max_sort_length= @save_max_sort_length; + +drop table t1; + +--echo # +--echo # MDEV-21922: Allow packing addon fields even if they don't honour max_length_for_sort_data +--echo # + +create table t1 (a varchar(200) character set utf8, b int); +insert into t1 select seq, seq from seq_1_to_10; +select * from t1 order by a; +--echo # +--echo # r_sort_mode should show both packed_sort_key and packed_addon_fields +--echo # +--source include/analyze-format.inc +analyze format=json select * from t1 order by a; +drop table t1; + +--echo # +--echo # MDEV-21946: Server crash in store_length upon GROUP BY WITH ROLLUP with geometry field +--echo # + +create table t1 ( a longblob); +insert into t1 select repeat('a', 256); +insert into t1 select repeat('b', 256); +insert into t1 select repeat('c', 256); +insert into t1 select repeat('d', 256); + +SELECT IF( 0, NULL, a ) AS f FROM t1 GROUP BY f WITH ROLLUP; +DROP TABLE t1; + +--echo # +--echo # MDEV-22303: Incorrect ordering with REGEXP_REPLACE and OFFSET/LIMIT +--echo # + +CREATE TABLE t1 (name VARCHAR(20) CHARACTER SET utf8 NOT NULL); +INSERT INTO t1 (name) VALUES ('Charles Dickens'), ('Roald Dahl'); + +SELECT name, REGEXP_REPLACE(name, '^(.*) (.*)$', '\\2, \\1') AS surname_first FROM t1 +ORDER BY surname_first ASC; + +SELECT name, REGEXP_REPLACE(name, '^(.*) (.*)$', '\\2, \\1') AS surname_first FROM t1 +ORDER BY surname_first ASC LIMIT 1; + +SELECT name, REGEXP_REPLACE(name, '^(.*) (.*)$', '\\2, \\1') AS surname_first FROM t1 +ORDER BY surname_first ASC LIMIT 1 OFFSET 1; + +DROP TABLE t1; + +--echo # +--echo # MDEV-22836: Server crashes in err_conv / ErrBuff::set_str +--echo # + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0),(1); +--disable_warnings +SELECT * FROM t1 ORDER BY CONVERT(AES_ENCRYPT(1,a), CHAR(4)); +--enable_warnings +DROP TABLE t1; + +--echo # +--echo # MDEV-22819:Wrong result or Assertion `ix > 0' failed in read_to_buffer upon select +--echo # with GROUP BY and GROUP_CONCAT +--echo # + +CREATE TABLE t1 (a VARCHAR(1000), b CHAR(1)); + +INSERT INTO t1 VALUES + (REPEAT('a',1000),'a'),(REPEAT('t',932),'t'),('x',NULL),('x',NULL), + (REPEAT('z',298),'z'),(REPEAT('p',1000),'p'),(REPEAT('k',468),'k'), + (REPEAT('c',1000),'c'),(REPEAT('o',648),'o'),('x',NULL),('x',NULL), + (REPEAT('c',258),'c'),(REPEAT('t',414),'t'),(REPEAT('f',966),'f'), + (REPEAT('y',746),'y'),(REPEAT('f',1000),'f'); + +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; + +SET @save_sort_buffer_size= @@sort_buffer_size; +SET sort_buffer_size= 16384; +SELECT LEFT(a,1), GROUP_CONCAT(b) FROM t1 GROUP BY a; +SELECT SUBSTR(a,1,1), LENGTH(a), GROUP_CONCAT(b), COUNT(*) FROM t1 GROUP BY a; + +SET @@sort_buffer_size= @save_sort_buffer_size; +DROP TABLE t1; + +CREATE TABLE t1(a VARCHAR(1027), b INT); +INSERT INTO t1 SELECT seq, seq from seq_1_to_34; +SET @save_tmp_memory_table_size= @@tmp_memory_table_size; +SET tmp_memory_table_size= 1056*2; +SELECT COUNT(DISTINCT a) FROM t1; +SET @@tmp_memory_table_size= @save_tmp_memory_table_size; +DROP TABLE t1; + +--echo # +--echo # MDEV-23216: LONGTEXT column with collation doesn't sort +--echo # + +CREATE TABLE t1 (a LONGTEXT COLLATE utf8mb4_swedish_ci); +INSERT INTO t1 VALUES ('A'),('Z'),('B'),('Y'); +SELECT * FROM t1 ORDER BY a; +SELECT * FROM t1 ORDER BY a DESC; + +DROP TABLE t1; + +--echo # +--echo # MDEV-23414 Assertion `res->charset() == item->collation.collation' failed in Type_handler_string_result::make_packed_sort_key_part +--echo # +CREATE TABLE t1 (a CHAR(3), b BINARY(255)); +INSERT t1 VALUES ('foo','bar'),('baz','qux'); +SELECT COALESCE(a, b) AS f FROM t1 ORDER BY f; +DROP TABLE t1; + +--echo # +--echo # MDEV-24015: SQL Error (1038): Out of sort memory when enough memory for the +--echo # sort buffer is provided +--echo # + +CREATE TABLE t1 (a VARCHAR(100), b INT); +CREATE TABLE t2 (a VARCHAR(100), b INT); + +INSERT INTO t1 SELECT 'abc', seq FROM seq_1_to_50; +INSERT INTO t2 SELECT seq, seq FROM seq_1_to_50; + +set @save_sort_buffer_size= @@sort_buffer_size; +set sort_buffer_size=2000; +--source include/analyze-format.inc +ANALYZE FORMAT=JSON +SELECT (SELECT sum(t2.b) FROM t2 WHERE t1.b=t2.b GROUP BY t2.a) FROM t1; +SELECT (SELECT sum(t2.b) FROM t2 WHERE t1.b=t2.b GROUP BY t2.a) FROM t1; + +set sort_buffer_size= @save_sort_buffer_size; +DROP TABLE t1,t2; +--echo # End of 10.5 tests diff --git a/mysql-test/main/order_by_pack_big.result b/mysql-test/main/order_by_pack_big.result new file mode 100644 index 00000000000..a7cf2436bcc --- /dev/null +++ b/mysql-test/main/order_by_pack_big.result @@ -0,0 +1,499 @@ +set @save_rand_seed1= @@RAND_SEED1; +set @save_rand_seed2= @@RAND_SEED2; +set @@RAND_SEED1=810763568, @@RAND_SEED2=600681772; +create table t1(a int); +insert into t1 select seq from seq_1_to_10000 order by rand(),seq; +# +# parameters: +# mean mean for the column to be considered +# max_val max_value for the column to be considered +# +# This function generate a sample of a normal distribution +# This function return a point +# of the normal distribution with a given mean. +# +CREATE FUNCTION +generate_normal_distribution_sample(mean DOUBLE, max_val DOUBLE)RETURNS DOUBLE +BEGIN +DECLARE z DOUBLE DEFAULT 0; +SET z= (rand() + rand() + rand() + rand() + rand() + rand())/6; +SET z= 2*(max_val-mean)*z; +SET z= z + mean - (max_val-mean); +return z; +END| +# +# parameters: +# len length of the random string to be generated +# +# This function generates a random string for the length passed +# as an argument with characters in the range of [A,Z] +# +CREATE FUNCTION generate_random_string(len INT) RETURNS varchar(128) +BEGIN +DECLARE str VARCHAR(256) DEFAULT ''; +DECLARE x INT DEFAULT 0; +WHILE (len > 0) DO +SET x =round(rand()*25); +SET str= CONCAT(str, CHAR(65 + x)); +SET len= len-1; +END WHILE; +RETURN str; +END| +# +# parameters: +# mean mean for the column to be considered +# min_val min_value for the column to be considered +# max_val max_value for the column to be considered +# +# This function generate a normal distribution sample in the range of +# [min_val, max_val] +# +CREATE FUNCTION +clipped_normal_distribution(mean DOUBLE, min_val DOUBLE, max_val DOUBLE) +RETURNS INT +BEGIN +DECLARE r DOUBLE DEFAULT 0; +WHILE 1=1 DO +set r= generate_normal_distribution_sample(mean, max_val); +IF (r >= min_val AND r <= max_val) THEN +RETURN round(r); +end if; +END WHILE; +RETURN 0; +END| +create table t2 (id INT NOT NULL, a INT, b int); +insert into t2 +select a, clipped_normal_distribution(12, 0, 64), +clipped_normal_distribution(32, 0, 128) +from t1; +CREATE TABLE t3( +id INT NOT NULL, +names VARCHAR(64), +address VARCHAR(128), +PRIMARY KEY (id) +); +# +# table t3 stores random strings calculated from the length stored in +# table t2 +# +insert into t3 +select id, generate_random_string(a), generate_random_string(b) from t2; +# +# All records fit in memory +# +set sort_buffer_size=262144*10; +analyze format=json select id DIV 100 as x, +MD5(group_concat(substring(names,1,3), substring(address,1,3) +order by id)) +FROM t3 +GROUP BY x; +ANALYZE +{ + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "read_sorted_file": { + "r_rows": 10000, + "filesort": { + "sort_key": "t3.`id` DIV 100", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "r_used_priority_queue": false, + "r_output_rows": 10000, + "r_buffer_size": "REPLACED", + "r_sort_mode": "sort_key,packed_addon_fields", + "table": { + "table_name": "t3", + "access_type": "ALL", + "r_loops": 1, + "rows": 10000, + "r_rows": 10000, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + } + } +} +flush status; +select id DIV 100 as x, +MD5(group_concat(substring(names,1,3), substring(address,1,3) +order by id)) +FROM t3 +GROUP BY x; +x MD5(group_concat(substring(names,1,3), substring(address,1,3) +order by id)) +0 3d24cb0237caf81aa74a2dddf367ac23 +1 618f9b8b6cefaa268dcb5477eece5e90 +2 fbfe93cc7713f852852f66e578d999aa +3 34802712af9c95664f41e789d19fb6e7 +4 2d9a4d628013b45cea5301143ec559c5 +5 324b8e682ad2233498f36979fddddf30 +6 31ccc1ab69c00dcade71f7fda2fad599 +7 e059e0279a5654a1c5f6596d220691bf +8 a21e5021cfb19be280f7fa2c2e70608e +9 6230b389a5bb0f9cd464b839e8824d0d +10 f2db66b6c4ad49e406f965a80ff5d224 +11 75f39127d968cad28d30707889191d81 +12 2e75191c0f32966a9e7675d0ddcf1c1c +13 808b4ecabb9cbb40ff3549c81b21d2f5 +14 c7c0c0bbf0ab7558793a86eaca714a3f +15 3065d81035dc9c596bc235ab553f92de +16 13b1b17e93649fe49d6da356c2072c63 +17 e3ce0af10608e6467ba4d38b135ff873 +18 0f172b310ad772e13630b647e09ef79a +19 26bbfb77888fa151215fe8ff75e448e7 +20 fcd6d5113e8178766dc370b470eb053a +21 d3860a17be6da02e17432f2ff80a261f +22 1d0cb7cd3f54c15bd41491e6fa449f12 +23 15f95be2574a94677fa7e76ead23e025 +24 924abdbb21c79cc7fd11d4d5b87ac339 +25 7493978704b5223a4f5dc6d8beb51d90 +26 f4ac4696b05577ba4a05334cd131cf94 +27 cfd45d4915f342978fb6982a825f6cc2 +28 2bd8981c6245c32ea1dc27ef394df94e +29 0e47838fe4be239939424fcef1289002 +30 18e291b42da10b04434bdad010a5b66c +31 cbd1bf2554378ef7edd9087d4a8562d4 +32 ddb1e7282bb637f7fe3aa3aed149b482 +33 1963f2400c8870d67f99c391bc5040c2 +34 d2b44d3c13a7a2c83de840892a370f47 +35 7ff20517acf5ea901757262eae1edf5e +36 685fbfc47faad4243944d7331a2dee36 +37 9d58b82b5f9d369a16c4f2bcc424b412 +38 be15aa080dda65c9489892c34a330c30 +39 4b52ddf7b599c9a00d094008a464c18c +40 441b03789e58aec883138d9c657a005e +41 e76cc7b1cadcb4f31e0232a0a8458620 +42 3581a040fbf210f6942fe591621f0e41 +43 acc552d3cba6a900054093c3c6876fc5 +44 fd7fa7a0a4a58485a1aa30e804f024af +45 56afedd4f2e8101fbb4402051e9857e8 +46 019e4178eccbdd84150f196668e40888 +47 132c8e314dd7c9064e1cb4980856531c +48 dcc08184bf2f7cfb640af0c603ff7506 +49 691b29183f64480003f8a1a74cd3ac13 +50 105da23f1b4a63d755414beca9df20d5 +51 30b2e973a0186721f9a7720be6be09e5 +52 b307d14c06fd6f27173d683a5596b542 +53 2125a788f107a4ba6a364984f7145156 +54 aa0793982ae401cd2c1bea949d726ae1 +55 e1797ba6b7ecf5f84cda2703f79c878c +56 78fc3f94127c0d5c6b3fa82ac3a8c167 +57 b8c6d1e26cfd94aade5e32cf89e05da6 +58 1e3481d6ff3b22f6ad739b93afe4c341 +59 59e9d5be4a87ee707578a3a8e5d624e9 +60 7a00e357826e950ffbe688c3f9a99a97 +61 e5a8c0d404f6fb59d9e3dd88b13ba5a7 +62 19d22c20fbf76b5b9ac746679ade26e7 +63 c96f912f54b9b862532ce959398c76ca +64 86c167171b777a150356f1f083203d24 +65 e1bca8d6cc1904a919cce1090e62f34d +66 f5dd3f6267376875239222dbefac87b1 +67 d6a2aa26124dd42a9df9fa21b7eb8bce +68 ecd36ba9a56f89d4bf6fa83c2b800985 +69 87b64475fd3f4db6dd68a45fb9a825dc +70 f5f7aa5569558b3e6556c72c9dfc429b +71 9e1cc67e0c13d00c771b6bed2fd566cf +72 3a6e7c6ce76a04fa2503d094121d84d5 +73 5fd8ba2dd8d36814d06a1d278002e437 +74 10db883700dde7289eb640df3a6d6676 +75 3ebd59ed119d6dfda3eedc5bf05fd425 +76 5008d3ce585f3b2dda2b313c57ebcb0a +77 ac7cee33e39827de02acedb7584acae5 +78 3f440facefbd95f905942c75bfe60bbb +79 89639b3145c988c775d9d997c9d356ff +80 a6f8b29a83b2305188c241f2724ea998 +81 d79f9bd47505cee69627e8044f7745c2 +82 5f8d8b55bc9d5b44f817ada0b9bab2f7 +83 411a99ef2e2af45640f0224274979fb5 +84 60706cd1eb7dffae3d7a34133c5cb67e +85 272a5d09070b5a0569fb18e144100f8b +86 0f969fd16dd186e9eb099213a82fb119 +87 6c48f63ec50e26ba42d8ca074daee9a6 +88 83512539cc5a2561426564590d307a58 +89 c57cf49bbeaa12aaba2106278681c9cd +90 d248507181561f0aba09182c4326fb11 +91 a1e153dd8bb1334bccd73890fafc5ba9 +92 d7a0ba2d1241a07abf3691074cecff76 +93 466034794d577c41a9716bc9eb903ee2 +94 b5e2158feb4290b04a7bdfdec0a17976 +95 8a16a27008d033dd6e9074b042021e60 +96 ccaa12e89f6de3058b3a2baddc4eff00 +97 7fdbf02f369546d0fde2b7db85752e33 +98 63b286bb777298397f3acf03fc3e9deb +99 b271f751a4952f86b002b9730bd02c8b +100 cbd5cef546acc0bfa33117d7c1ae58a8 +show status like '%sort%'; +Variable_name Value +Sort_merge_passes 0 +Sort_priority_queue_sorts 0 +Sort_range 0 +Sort_rows 10000 +Sort_scan 1 +set sort_buffer_size=default; +# +# Test for merge_many_buff +# +set sort_buffer_size=32768; +analyze format=json select id DIV 100 as x, +MD5(group_concat(substring(names,1,3), substring(address,1,3) +order by id)) +FROM t3 +GROUP BY x; +ANALYZE +{ + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "read_sorted_file": { + "r_rows": 10000, + "filesort": { + "sort_key": "t3.`id` DIV 100", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "r_used_priority_queue": false, + "r_output_rows": 10000, + "r_sort_passes": 4, + "r_buffer_size": "REPLACED", + "r_sort_mode": "sort_key,packed_addon_fields", + "table": { + "table_name": "t3", + "access_type": "ALL", + "r_loops": 1, + "rows": 10000, + "r_rows": 10000, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + } + } +} +flush status; +select id DIV 100 as x, +MD5(group_concat(substring(names,1,3), substring(address,1,3) +order by id)) +FROM t3 +GROUP BY x; +x MD5(group_concat(substring(names,1,3), substring(address,1,3) +order by id)) +0 3d24cb0237caf81aa74a2dddf367ac23 +1 618f9b8b6cefaa268dcb5477eece5e90 +2 fbfe93cc7713f852852f66e578d999aa +3 34802712af9c95664f41e789d19fb6e7 +4 2d9a4d628013b45cea5301143ec559c5 +5 324b8e682ad2233498f36979fddddf30 +6 31ccc1ab69c00dcade71f7fda2fad599 +7 e059e0279a5654a1c5f6596d220691bf +8 a21e5021cfb19be280f7fa2c2e70608e +9 6230b389a5bb0f9cd464b839e8824d0d +10 f2db66b6c4ad49e406f965a80ff5d224 +11 75f39127d968cad28d30707889191d81 +12 2e75191c0f32966a9e7675d0ddcf1c1c +13 808b4ecabb9cbb40ff3549c81b21d2f5 +14 c7c0c0bbf0ab7558793a86eaca714a3f +15 3065d81035dc9c596bc235ab553f92de +16 13b1b17e93649fe49d6da356c2072c63 +17 e3ce0af10608e6467ba4d38b135ff873 +18 0f172b310ad772e13630b647e09ef79a +19 26bbfb77888fa151215fe8ff75e448e7 +20 fcd6d5113e8178766dc370b470eb053a +21 d3860a17be6da02e17432f2ff80a261f +22 1d0cb7cd3f54c15bd41491e6fa449f12 +23 15f95be2574a94677fa7e76ead23e025 +24 924abdbb21c79cc7fd11d4d5b87ac339 +25 7493978704b5223a4f5dc6d8beb51d90 +26 f4ac4696b05577ba4a05334cd131cf94 +27 cfd45d4915f342978fb6982a825f6cc2 +28 2bd8981c6245c32ea1dc27ef394df94e +29 0e47838fe4be239939424fcef1289002 +30 18e291b42da10b04434bdad010a5b66c +31 cbd1bf2554378ef7edd9087d4a8562d4 +32 ddb1e7282bb637f7fe3aa3aed149b482 +33 1963f2400c8870d67f99c391bc5040c2 +34 d2b44d3c13a7a2c83de840892a370f47 +35 7ff20517acf5ea901757262eae1edf5e +36 685fbfc47faad4243944d7331a2dee36 +37 9d58b82b5f9d369a16c4f2bcc424b412 +38 be15aa080dda65c9489892c34a330c30 +39 4b52ddf7b599c9a00d094008a464c18c +40 441b03789e58aec883138d9c657a005e +41 e76cc7b1cadcb4f31e0232a0a8458620 +42 3581a040fbf210f6942fe591621f0e41 +43 acc552d3cba6a900054093c3c6876fc5 +44 fd7fa7a0a4a58485a1aa30e804f024af +45 56afedd4f2e8101fbb4402051e9857e8 +46 019e4178eccbdd84150f196668e40888 +47 132c8e314dd7c9064e1cb4980856531c +48 dcc08184bf2f7cfb640af0c603ff7506 +49 691b29183f64480003f8a1a74cd3ac13 +50 105da23f1b4a63d755414beca9df20d5 +51 30b2e973a0186721f9a7720be6be09e5 +52 b307d14c06fd6f27173d683a5596b542 +53 2125a788f107a4ba6a364984f7145156 +54 aa0793982ae401cd2c1bea949d726ae1 +55 e1797ba6b7ecf5f84cda2703f79c878c +56 78fc3f94127c0d5c6b3fa82ac3a8c167 +57 b8c6d1e26cfd94aade5e32cf89e05da6 +58 1e3481d6ff3b22f6ad739b93afe4c341 +59 59e9d5be4a87ee707578a3a8e5d624e9 +60 7a00e357826e950ffbe688c3f9a99a97 +61 e5a8c0d404f6fb59d9e3dd88b13ba5a7 +62 19d22c20fbf76b5b9ac746679ade26e7 +63 c96f912f54b9b862532ce959398c76ca +64 86c167171b777a150356f1f083203d24 +65 e1bca8d6cc1904a919cce1090e62f34d +66 f5dd3f6267376875239222dbefac87b1 +67 d6a2aa26124dd42a9df9fa21b7eb8bce +68 ecd36ba9a56f89d4bf6fa83c2b800985 +69 87b64475fd3f4db6dd68a45fb9a825dc +70 f5f7aa5569558b3e6556c72c9dfc429b +71 9e1cc67e0c13d00c771b6bed2fd566cf +72 3a6e7c6ce76a04fa2503d094121d84d5 +73 5fd8ba2dd8d36814d06a1d278002e437 +74 10db883700dde7289eb640df3a6d6676 +75 3ebd59ed119d6dfda3eedc5bf05fd425 +76 5008d3ce585f3b2dda2b313c57ebcb0a +77 ac7cee33e39827de02acedb7584acae5 +78 3f440facefbd95f905942c75bfe60bbb +79 89639b3145c988c775d9d997c9d356ff +80 a6f8b29a83b2305188c241f2724ea998 +81 d79f9bd47505cee69627e8044f7745c2 +82 5f8d8b55bc9d5b44f817ada0b9bab2f7 +83 411a99ef2e2af45640f0224274979fb5 +84 60706cd1eb7dffae3d7a34133c5cb67e +85 272a5d09070b5a0569fb18e144100f8b +86 0f969fd16dd186e9eb099213a82fb119 +87 6c48f63ec50e26ba42d8ca074daee9a6 +88 83512539cc5a2561426564590d307a58 +89 c57cf49bbeaa12aaba2106278681c9cd +90 d248507181561f0aba09182c4326fb11 +91 a1e153dd8bb1334bccd73890fafc5ba9 +92 d7a0ba2d1241a07abf3691074cecff76 +93 466034794d577c41a9716bc9eb903ee2 +94 b5e2158feb4290b04a7bdfdec0a17976 +95 8a16a27008d033dd6e9074b042021e60 +96 ccaa12e89f6de3058b3a2baddc4eff00 +97 7fdbf02f369546d0fde2b7db85752e33 +98 63b286bb777298397f3acf03fc3e9deb +99 b271f751a4952f86b002b9730bd02c8b +100 cbd5cef546acc0bfa33117d7c1ae58a8 +show status like '%sort%'; +Variable_name Value +Sort_merge_passes 4 +Sort_priority_queue_sorts 0 +Sort_range 0 +Sort_rows 10000 +Sort_scan 1 +set sort_buffer_size=default; +# +# CASE #1 Packed sort keys with addon fields +# +ALTER TABLE t3 ADD INDEX idx(names, address); +set sort_buffer_size= 2097152; +ANALYZE FORMAT=JSON SELECT id, names, address FROM t3 ORDER BY names, address; +ANALYZE +{ + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "read_sorted_file": { + "r_rows": 10000, + "filesort": { + "sort_key": "t3.`names`, t3.address", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "r_used_priority_queue": false, + "r_output_rows": 10000, + "r_buffer_size": "REPLACED", + "r_sort_mode": "packed_sort_key,packed_addon_fields", + "table": { + "table_name": "t3", + "access_type": "ALL", + "r_loops": 1, + "rows": 10000, + "r_rows": 10000, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + } + } +} +flush status; +SELECT id, names, address INTO OUTFILE '$file1' FROM t3 ORDER BY names, address; +# Sort_merge_passes should be 0 +show status like '%sort%'; +Variable_name Value +Sort_merge_passes 0 +Sort_priority_queue_sorts 0 +Sort_range 0 +Sort_rows 10000 +Sort_scan 1 +SELECT id, names, address INTO OUTFILE '$file2' FROM t3 FORCE INDEX(idx) ORDER BY names, address; +# +# CASE #2 Packed sort keys and ROW_ID +# +set @save_max_length_for_sort_data=@@max_length_for_sort_data; +set max_length_for_sort_data= 300; +set sort_buffer_size= 1097152; +ANALYZE FORMAT=JSON SELECT id, names, address FROM t3 ORDER BY names, address; +ANALYZE +{ + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "read_sorted_file": { + "r_rows": 10000, + "filesort": { + "sort_key": "t3.`names`, t3.address", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "r_used_priority_queue": false, + "r_output_rows": 10000, + "r_buffer_size": "REPLACED", + "r_sort_mode": "packed_sort_key,rowid", + "table": { + "table_name": "t3", + "access_type": "ALL", + "r_loops": 1, + "rows": 10000, + "r_rows": 10000, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + } + } +} +flush status; +SELECT id, names, address INTO OUTFILE '$file1' FROM t3 ORDER BY names, address; +# Sort_merge_passes should be 0 +show status like '%sort%'; +Variable_name Value +Sort_merge_passes 0 +Sort_priority_queue_sorts 0 +Sort_range 0 +Sort_rows 10000 +Sort_scan 1 +set @@max_length_for_sort_data=@save_max_length_for_sort_data; +set @@sort_buffer_size=default; +set @@RAND_SEED1= @save_rand_seed1; +set @@RAND_SEED2= @save_rand_seed2; +drop function generate_normal_distribution_sample; +drop function generate_random_string; +drop function clipped_normal_distribution; +drop table t1, t2, t3; diff --git a/mysql-test/main/order_by_pack_big.test b/mysql-test/main/order_by_pack_big.test new file mode 100644 index 00000000000..dce7bcb905c --- /dev/null +++ b/mysql-test/main/order_by_pack_big.test @@ -0,0 +1,185 @@ +--source include/big_test.inc +--source include/have_sequence.inc +--source include/have_64bit.inc + +set @save_rand_seed1= @@RAND_SEED1; +set @save_rand_seed2= @@RAND_SEED2; +set @@RAND_SEED1=810763568, @@RAND_SEED2=600681772; + +create table t1(a int); +insert into t1 select seq from seq_1_to_10000 order by rand(),seq; +delimiter |; + +--echo # +--echo # parameters: +--echo # mean mean for the column to be considered +--echo # max_val max_value for the column to be considered +--echo # +--echo # This function generate a sample of a normal distribution +--echo # This function return a point +--echo # of the normal distribution with a given mean. +--echo # + +CREATE FUNCTION +generate_normal_distribution_sample(mean DOUBLE, max_val DOUBLE)RETURNS DOUBLE +BEGIN + DECLARE z DOUBLE DEFAULT 0; + SET z= (rand() + rand() + rand() + rand() + rand() + rand())/6; + SET z= 2*(max_val-mean)*z; + SET z= z + mean - (max_val-mean); + return z; +END| + +--echo # +--echo # parameters: +--echo # len length of the random string to be generated +--echo # +--echo # This function generates a random string for the length passed +--echo # as an argument with characters in the range of [A,Z] +--echo # + +CREATE FUNCTION generate_random_string(len INT) RETURNS varchar(128) +BEGIN + DECLARE str VARCHAR(256) DEFAULT ''; + DECLARE x INT DEFAULT 0; + WHILE (len > 0) DO + SET x =round(rand()*25); + SET str= CONCAT(str, CHAR(65 + x)); + SET len= len-1; + END WHILE; +RETURN str; +END| + +--echo # +--echo # parameters: +--echo # mean mean for the column to be considered +--echo # min_val min_value for the column to be considered +--echo # max_val max_value for the column to be considered +--echo # +--echo # This function generate a normal distribution sample in the range of +--echo # [min_val, max_val] +--echo # + +CREATE FUNCTION +clipped_normal_distribution(mean DOUBLE, min_val DOUBLE, max_val DOUBLE) +RETURNS INT +BEGIN + DECLARE r DOUBLE DEFAULT 0; + WHILE 1=1 DO + set r= generate_normal_distribution_sample(mean, max_val); + IF (r >= min_val AND r <= max_val) THEN + RETURN round(r); + end if; + END WHILE; + RETURN 0; +END| + +delimiter ;| + +create table t2 (id INT NOT NULL, a INT, b int); +insert into t2 +select a, clipped_normal_distribution(12, 0, 64), + clipped_normal_distribution(32, 0, 128) +from t1; + +CREATE TABLE t3( + id INT NOT NULL, + names VARCHAR(64), + address VARCHAR(128), + PRIMARY KEY (id) +); + +--echo # +--echo # table t3 stores random strings calculated from the length stored in +--echo # table t2 +--echo # + +insert into t3 +select id, generate_random_string(a), generate_random_string(b) from t2; + + +let $query= select id DIV 100 as x, + MD5(group_concat(substring(names,1,3), substring(address,1,3) + order by id)) + FROM t3 + GROUP BY x; + +--echo # +--echo # All records fit in memory +--echo # + +set sort_buffer_size=262144*10; +--source include/analyze-format.inc +eval analyze format=json $query; +flush status; +eval $query; +show status like '%sort%'; +set sort_buffer_size=default; + +--echo # +--echo # Test for merge_many_buff +--echo # + +set sort_buffer_size=32768; +--source include/analyze-format.inc +eval analyze format=json $query; +flush status; +eval $query; +show status like '%sort%'; +set sort_buffer_size=default; + +--echo # +--echo # CASE #1 Packed sort keys with addon fields +--echo # + +ALTER TABLE t3 ADD INDEX idx(names, address); + +let $file1 = `SELECT CONCAT(@@datadir, "t1.txt")`; +let $file2 = `SELECT CONCAT(@@datadir, "t2.txt")`; + +set sort_buffer_size= 2097152; +--source include/analyze-format.inc +eval ANALYZE FORMAT=JSON SELECT id, names, address FROM t3 ORDER BY names, address; +flush status; +evalp SELECT id, names, address INTO OUTFILE '$file1' FROM t3 ORDER BY names, address; + +--echo # Sort_merge_passes should be 0 +show status like '%sort%'; + +evalp SELECT id, names, address INTO OUTFILE '$file2' FROM t3 FORCE INDEX(idx) ORDER BY names, address; + +diff_files $file1 $file2; + +--remove_file $file1 + +--echo # +--echo # CASE #2 Packed sort keys and ROW_ID +--echo # + +set @save_max_length_for_sort_data=@@max_length_for_sort_data; +set max_length_for_sort_data= 300; + +set sort_buffer_size= 1097152; +--source include/analyze-format.inc +eval ANALYZE FORMAT=JSON SELECT id, names, address FROM t3 ORDER BY names, address; +flush status; +evalp SELECT id, names, address INTO OUTFILE '$file1' FROM t3 ORDER BY names, address; + +--echo # Sort_merge_passes should be 0 +show status like '%sort%'; + +diff_files $file1 $file2; + +--remove_file $file1 +--remove_file $file2 + +set @@max_length_for_sort_data=@save_max_length_for_sort_data; +set @@sort_buffer_size=default; + +set @@RAND_SEED1= @save_rand_seed1; +set @@RAND_SEED2= @save_rand_seed2; + +drop function generate_normal_distribution_sample; +drop function generate_random_string; +drop function clipped_normal_distribution; +drop table t1, t2, t3; diff --git a/mysql-test/main/parser.result b/mysql-test/main/parser.result index 5ca0e099026..f16978854ac 100644 --- a/mysql-test/main/parser.result +++ b/mysql-test/main/parser.result @@ -1400,6 +1400,7 @@ CALL p1(name, 'SELECT name TRANSACTION FROM t1'); CALL p1(name, 'SELECT name VALUE FROM t1'); CALL p1(name, 'SELECT name VERSIONING FROM t1'); CALL p1(name, 'SELECT name WITHOUT FROM t1'); +CALL p1(name, 'SELECT name OVERLAPS FROM t1'); DROP TABLE t1; END; $$ @@ -1426,6 +1427,7 @@ SELECT date TRANSACTION FROM t1 SELECT date VALUE FROM t1 SELECT date VERSIONING FROM t1 SELECT date WITHOUT FROM t1 +SELECT date OVERLAPS FROM t1 CALL p2('history'); BEGIN NOT ATOMIC DECLARE history INT; SET history=10; SELECT history; END 10 @@ -1448,6 +1450,7 @@ SELECT history TRANSACTION FROM t1 SELECT history VALUE FROM t1 SELECT history VERSIONING FROM t1 SELECT history WITHOUT FROM t1 +SELECT history OVERLAPS FROM t1 CALL p2('next'); BEGIN NOT ATOMIC DECLARE next INT; SET next=10; SELECT next; END 10 @@ -1471,6 +1474,7 @@ SELECT next VALUE FROM t1 Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'FROM t1' at line 1 SELECT next VERSIONING FROM t1 SELECT next WITHOUT FROM t1 +SELECT next OVERLAPS FROM t1 CALL p2('period'); BEGIN NOT ATOMIC DECLARE period INT; SET period=10; SELECT period; END 10 @@ -1493,6 +1497,7 @@ SELECT period TRANSACTION FROM t1 SELECT period VALUE FROM t1 SELECT period VERSIONING FROM t1 SELECT period WITHOUT FROM t1 +SELECT period OVERLAPS FROM t1 CALL p2('previous'); BEGIN NOT ATOMIC DECLARE previous INT; SET previous=10; SELECT previous; END 10 @@ -1516,6 +1521,7 @@ SELECT previous VALUE FROM t1 Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'FROM t1' at line 1 SELECT previous VERSIONING FROM t1 SELECT previous WITHOUT FROM t1 +SELECT previous OVERLAPS FROM t1 CALL p2('system'); BEGIN NOT ATOMIC DECLARE system INT; SET system=10; SELECT system; END 10 @@ -1538,6 +1544,7 @@ SELECT system TRANSACTION FROM t1 SELECT system VALUE FROM t1 SELECT system VERSIONING FROM t1 SELECT system WITHOUT FROM t1 +SELECT system OVERLAPS FROM t1 CALL p2('system_time'); BEGIN NOT ATOMIC DECLARE system_time INT; SET system_time=10; SELECT system_time; END 10 @@ -1560,6 +1567,7 @@ SELECT system_time TRANSACTION FROM t1 SELECT system_time VALUE FROM t1 SELECT system_time VERSIONING FROM t1 SELECT system_time WITHOUT FROM t1 +SELECT system_time OVERLAPS FROM t1 CALL p2('time'); BEGIN NOT ATOMIC DECLARE time INT; SET time=10; SELECT time; END 10 @@ -1583,6 +1591,7 @@ SELECT time TRANSACTION FROM t1 SELECT time VALUE FROM t1 SELECT time VERSIONING FROM t1 SELECT time WITHOUT FROM t1 +SELECT time OVERLAPS FROM t1 CALL p2('timestamp'); BEGIN NOT ATOMIC DECLARE timestamp INT; SET timestamp=10; SELECT timestamp; END 10 @@ -1606,6 +1615,7 @@ SELECT timestamp TRANSACTION FROM t1 SELECT timestamp VALUE FROM t1 SELECT timestamp VERSIONING FROM t1 SELECT timestamp WITHOUT FROM t1 +SELECT timestamp OVERLAPS FROM t1 CALL p2('transaction'); BEGIN NOT ATOMIC DECLARE transaction INT; SET transaction=10; SELECT transaction; END 10 @@ -1628,6 +1638,7 @@ SELECT transaction TRANSACTION FROM t1 SELECT transaction VALUE FROM t1 SELECT transaction VERSIONING FROM t1 SELECT transaction WITHOUT FROM t1 +SELECT transaction OVERLAPS FROM t1 CALL p2('value'); BEGIN NOT ATOMIC DECLARE value INT; SET value=10; SELECT value; END 10 @@ -1650,6 +1661,7 @@ SELECT value TRANSACTION FROM t1 SELECT value VALUE FROM t1 SELECT value VERSIONING FROM t1 SELECT value WITHOUT FROM t1 +SELECT value OVERLAPS FROM t1 CALL p2('versioning'); BEGIN NOT ATOMIC DECLARE versioning INT; SET versioning=10; SELECT versioning; END 10 @@ -1672,6 +1684,7 @@ SELECT versioning TRANSACTION FROM t1 SELECT versioning VALUE FROM t1 SELECT versioning VERSIONING FROM t1 SELECT versioning WITHOUT FROM t1 +SELECT versioning OVERLAPS FROM t1 CALL p2('without'); BEGIN NOT ATOMIC DECLARE without INT; SET without=10; SELECT without; END 10 @@ -1694,6 +1707,30 @@ SELECT without TRANSACTION FROM t1 SELECT without VALUE FROM t1 SELECT without VERSIONING FROM t1 SELECT without WITHOUT FROM t1 +SELECT without OVERLAPS FROM t1 +CALL p2('overlaps'); +BEGIN NOT ATOMIC DECLARE overlaps INT; SET overlaps=10; SELECT overlaps; END +10 +SELECT overlaps FROM t1 +SELECT overlaps 'alias' FROM t1 +SELECT overlaps() +Error 1582 Incorrect parameter count in the call to native function 'overlaps()' +SELECT overlaps.overlaps() +Error 1630 FUNCTION overlaps.overlaps does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual +SELECT overlaps DATE FROM t1 +SELECT overlaps HISTORY FROM t1 +SELECT overlaps NEXT FROM t1 +SELECT overlaps PERIOD FROM t1 +SELECT overlaps PREVIOUS FROM t1 +SELECT overlaps SYSTEM FROM t1 +SELECT overlaps SYSTEM_TIME FROM t1 +SELECT overlaps TIME FROM t1 +SELECT overlaps TIMESTAMP FROM t1 +SELECT overlaps TRANSACTION FROM t1 +SELECT overlaps VALUE FROM t1 +SELECT overlaps VERSIONING FROM t1 +SELECT overlaps WITHOUT FROM t1 +SELECT overlaps OVERLAPS FROM t1 DROP PROCEDURE p2; DROP PROCEDURE p1; # @@ -2024,3 +2061,47 @@ call p1(1,2); drop procedure p1; drop table t1,t2; # End of 10.4 tests +# +# Start of 10.5 tests +# +# +# MDEV-20734 Allow reserved keywords as user defined type names +# +CREATE TABLE t1 (a DUAL); +ERROR HY000: Unknown data type: 'DUAL' +SELECT CAST(1 AS DUAL); +ERROR HY000: Unknown data type: 'DUAL' +# +# MDEV-20735 Allow non-reserved keywords as user defined type names +# +CREATE TABLE t1 (a ASCII); +ERROR HY000: Unknown data type: 'ASCII' +SELECT CAST(1 AS ASCII); +ERROR HY000: Unknown data type: 'ASCII' +CREATE TABLE t1 (a LANGUAGE); +ERROR HY000: Unknown data type: 'LANGUAGE' +SELECT CAST(1 AS LANGUAGE); +ERROR HY000: Unknown data type: 'LANGUAGE' +CREATE TABLE t1 (a CLOSE); +ERROR HY000: Unknown data type: 'CLOSE' +SELECT CAST(1 AS CLOSE); +ERROR HY000: Unknown data type: 'CLOSE' +CREATE TABLE t1 (a NAMES); +ERROR HY000: Unknown data type: 'NAMES' +SELECT CAST(1 AS NAMES); +ERROR HY000: Unknown data type: 'NAMES' +CREATE TABLE t1 (a END); +ERROR HY000: Unknown data type: 'END' +SELECT CAST(1 AS END); +ERROR HY000: Unknown data type: 'END' +CREATE TABLE t1 (a GLOBAL); +ERROR HY000: Unknown data type: 'GLOBAL' +SELECT CAST(1 AS GLOBAL); +ERROR HY000: Unknown data type: 'GLOBAL' +CREATE TABLE t1 (a ACTION); +ERROR HY000: Unknown data type: 'ACTION' +SELECT CAST(1 AS ACTION); +ERROR HY000: Unknown data type: 'ACTION' +# +# End of 10.5 tests +# diff --git a/mysql-test/main/parser.test b/mysql-test/main/parser.test index d9a6c2df191..fae459740ad 100644 --- a/mysql-test/main/parser.test +++ b/mysql-test/main/parser.test @@ -1442,6 +1442,7 @@ BEGIN CALL p1(name, 'SELECT name VALUE FROM t1'); CALL p1(name, 'SELECT name VERSIONING FROM t1'); CALL p1(name, 'SELECT name WITHOUT FROM t1'); + CALL p1(name, 'SELECT name OVERLAPS FROM t1'); DROP TABLE t1; END; $$ @@ -1461,6 +1462,7 @@ CALL p2('transaction'); CALL p2('value'); CALL p2('versioning'); CALL p2('without'); +CALL p2('overlaps'); --enable_column_names DROP PROCEDURE p2; @@ -1823,3 +1825,61 @@ drop procedure p1; drop table t1,t2; --echo # End of 10.4 tests + + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-20734 Allow reserved keywords as user defined type names +--echo # + +--error ER_UNKNOWN_DATA_TYPE +CREATE TABLE t1 (a DUAL); +--error ER_UNKNOWN_DATA_TYPE +SELECT CAST(1 AS DUAL); + +--echo # +--echo # MDEV-20735 Allow non-reserved keywords as user defined type names +--echo # + +--error ER_UNKNOWN_DATA_TYPE +CREATE TABLE t1 (a ASCII); +--error ER_UNKNOWN_DATA_TYPE +SELECT CAST(1 AS ASCII); + +--error ER_UNKNOWN_DATA_TYPE +CREATE TABLE t1 (a LANGUAGE); +--error ER_UNKNOWN_DATA_TYPE +SELECT CAST(1 AS LANGUAGE); + +--error ER_UNKNOWN_DATA_TYPE +CREATE TABLE t1 (a CLOSE); +--error ER_UNKNOWN_DATA_TYPE +SELECT CAST(1 AS CLOSE); + +--error ER_UNKNOWN_DATA_TYPE +CREATE TABLE t1 (a NAMES); +--error ER_UNKNOWN_DATA_TYPE +SELECT CAST(1 AS NAMES); + +--error ER_UNKNOWN_DATA_TYPE +CREATE TABLE t1 (a END); +--error ER_UNKNOWN_DATA_TYPE +SELECT CAST(1 AS END); + +--error ER_UNKNOWN_DATA_TYPE +CREATE TABLE t1 (a GLOBAL); +--error ER_UNKNOWN_DATA_TYPE +SELECT CAST(1 AS GLOBAL); + +--error ER_UNKNOWN_DATA_TYPE +CREATE TABLE t1 (a ACTION); +--error ER_UNKNOWN_DATA_TYPE +SELECT CAST(1 AS ACTION); + + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/partition.result b/mysql-test/main/partition.result index c07f1bcd85a..373522ded40 100644 --- a/mysql-test/main/partition.result +++ b/mysql-test/main/partition.result @@ -306,7 +306,7 @@ drop table t1; CREATE TABLE t1 (a INT, FOREIGN KEY (a) REFERENCES t0 (a)) ENGINE=MyISAM PARTITION BY HASH (a); -ERROR HY000: Foreign key clause is not yet supported in conjunction with partitioning +ERROR HY000: Partitioned tables do not support FOREIGN KEY CREATE TABLE t1 ( pk INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (pk) @@ -551,7 +551,7 @@ INSERT INTO `t1` VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13), INSERT INTO `t2` VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17),(18),(19),(20); EXPLAIN PARTITIONS SELECT c1 FROM t1 WHERE (c1 > 10 AND c1 < 13) OR (c1 > 17 AND c1 < 20); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 NULL index c1 c1 5 NULL 20 Using where; Using index +1 SIMPLE t1 NULL range c1 c1 5 NULL 4 Using where; Using index FLUSH STATUS; SELECT c1 FROM t1 WHERE (c1 > 10 AND c1 < 13) OR (c1 > 17 AND c1 < 20); c1 @@ -561,10 +561,10 @@ c1 19 SHOW STATUS LIKE 'Handler_read_%'; Variable_name Value -Handler_read_first 1 -Handler_read_key 0 +Handler_read_first 0 +Handler_read_key 2 Handler_read_last 0 -Handler_read_next 20 +Handler_read_next 4 Handler_read_prev 0 Handler_read_retry 0 Handler_read_rnd 0 @@ -572,7 +572,7 @@ Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 EXPLAIN PARTITIONS SELECT c1 FROM t2 WHERE (c1 > 10 AND c1 < 13) OR (c1 > 17 AND c1 < 20); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t2 a index c1 c1 5 NULL 20 Using where; Using index +1 SIMPLE t2 a range c1 c1 5 NULL 4 Using where; Using index FLUSH STATUS; SELECT c1 FROM t2 WHERE (c1 > 10 AND c1 < 13) OR (c1 > 17 AND c1 < 20); c1 @@ -582,10 +582,10 @@ c1 19 SHOW STATUS LIKE 'Handler_read_%'; Variable_name Value -Handler_read_first 1 -Handler_read_key 0 +Handler_read_first 0 +Handler_read_key 2 Handler_read_last 0 -Handler_read_next 20 +Handler_read_next 4 Handler_read_prev 0 Handler_read_retry 0 Handler_read_rnd 0 @@ -1514,7 +1514,7 @@ s1 2 drop table t2; create temporary table t1 (a int) partition by hash(a); -ERROR HY000: Cannot create temporary table with partitions +ERROR HY000: Partitioned tables do not support CREATE TEMPORARY TABLE create table t1 (a int, b int) partition by list (a) (partition p1 values in (1), partition p2 values in (2)); alter table t1 add primary key (b); @@ -2362,6 +2362,10 @@ EXPLAIN SELECT b, c FROM t1 WHERE b = 1 GROUP BY b, c; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range bc bc 10 NULL 8 Using where; Using index for group-by +EXPLAIN +SELECT b, c FROM t1 WHERE b = 1 or b=2 GROUP BY b, c; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range bc bc 10 NULL 8 Using where; Using index for group-by DROP TABLE t1; # # Bug #45807: crash accessing partitioned table and sql_mode diff --git a/mysql-test/main/partition.test b/mysql-test/main/partition.test index cc19bb83494..5d5dafdb206 100644 --- a/mysql-test/main/partition.test +++ b/mysql-test/main/partition.test @@ -290,7 +290,7 @@ drop table t1; # # Bug#36001: Partitions: spelling and using some error messages # ---error ER_FOREIGN_KEY_ON_PARTITIONED +--error ER_FEATURE_NOT_SUPPORTED_WITH_PARTITIONING CREATE TABLE t1 (a INT, FOREIGN KEY (a) REFERENCES t0 (a)) ENGINE=MyISAM PARTITION BY HASH (a); @@ -1054,7 +1054,7 @@ drop table t1; # # Bug #17754 Change to explicit removal of partitioning scheme # Also added a number of tests to ensure that proper engine is -# choosen in all kinds of scenarios. +# chosen in all kinds of scenarios. # create table t1 (a int) @@ -1422,7 +1422,7 @@ drop table t2; # # Bug #17497: Partitions: crash if add partition on temporary table # ---error ER_PARTITION_NO_TEMPORARY +--error ER_FEATURE_NOT_SUPPORTED_WITH_PARTITIONING create temporary table t1 (a int) partition by hash(a); # @@ -2293,6 +2293,9 @@ SELECT b, c FROM t1 WHERE b = 1 GROUP BY b, c; EXPLAIN SELECT b, c FROM t1 WHERE b = 1 GROUP BY b, c; +EXPLAIN +SELECT b, c FROM t1 WHERE b = 1 or b=2 GROUP BY b, c; + DROP TABLE t1; --echo # diff --git a/mysql-test/main/partition_alter.test b/mysql-test/main/partition_alter.test index 804b43dc3c2..cca25d0989f 100644 --- a/mysql-test/main/partition_alter.test +++ b/mysql-test/main/partition_alter.test @@ -86,7 +86,11 @@ show create table t1; --error ER_CONSTRAINT_FAILED insert t1 values (2, '2020-01-03', 20); drop table t1; ---list_files $datadir/test +--let $regexp=/#sql-ib[0-9a-f]+\.ibd\n// +--list_files_write_file $datadir.files.txt $datadir/test +--replace_regex $regexp +--cat_file $datadir.files.txt +--remove_file $datadir.files.txt # MyISAM, different execution path create table t1(id int, d date not null, b bool not null default 0, primary key(id,d)) @@ -102,7 +106,10 @@ show create table t1; --error ER_CONSTRAINT_FAILED insert t1 values (2, '2020-01-03', 20); drop table t1; ---list_files $datadir/test +--list_files_write_file $datadir.files.txt $datadir/test +--replace_regex $regexp +--cat_file $datadir.files.txt +--remove_file $datadir.files.txt # # MDEV-13097 Online alter of a partitioned MyISAM table with auto_increment diff --git a/mysql-test/main/partition_cache.result b/mysql-test/main/partition_cache.result index 697ba1bcd15..0bd8d70e9cb 100644 --- a/mysql-test/main/partition_cache.result +++ b/mysql-test/main/partition_cache.result @@ -1,6 +1,6 @@ SET global query_cache_type=ON; SET local query_cache_type=ON; -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; drop table if exists t1,t2,t3; set @save_query_cache_size = @@global.query_cache_size; set GLOBAL query_cache_size = 1355776; @@ -114,7 +114,7 @@ count(*) 1 drop table t1; connect connection1,localhost,root,,; -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; SET @@autocommit=1; connection default; SHOW VARIABLES LIKE 'have_query_cache'; @@ -123,7 +123,7 @@ have_query_cache YES SET GLOBAL query_cache_size = 204800; flush status; SET @@autocommit=1; -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; CREATE TABLE t2 (s1 int, s2 varchar(1000), key(s1)) PARTITION BY KEY (s1) PARTITIONS 3; INSERT INTO t2 VALUES (1,repeat('a',10)),(2,repeat('a',10)),(3,repeat('a',10)),(4,repeat('a',10)); COMMIT; diff --git a/mysql-test/main/partition_cache_innodb.result b/mysql-test/main/partition_cache_innodb.result index e6e69ee686e..0cd60fa11a0 100644 --- a/mysql-test/main/partition_cache_innodb.result +++ b/mysql-test/main/partition_cache_innodb.result @@ -1,6 +1,6 @@ SET global query_cache_type=ON; SET local query_cache_type=ON; -SET SESSION STORAGE_ENGINE = innodb; +SET SESSION DEFAULT_STORAGE_ENGINE = innodb; drop table if exists t1; set @save_query_cache_size = @@global.query_cache_size; # Test that partitions works with query cache diff --git a/mysql-test/main/partition_cache_myisam.result b/mysql-test/main/partition_cache_myisam.result index d8e4f837ff7..441a7d080c3 100644 --- a/mysql-test/main/partition_cache_myisam.result +++ b/mysql-test/main/partition_cache_myisam.result @@ -1,6 +1,6 @@ SET global query_cache_type=ON; SET local query_cache_type=ON; -SET SESSION STORAGE_ENGINE = myisam; +SET SESSION DEFAULT_STORAGE_ENGINE = myisam; drop table if exists t1; set @save_query_cache_size = @@global.query_cache_size; # Test that partitions works with query cache diff --git a/mysql-test/main/partition_error.result b/mysql-test/main/partition_error.result index d99473d0718..25c29938f91 100644 --- a/mysql-test/main/partition_error.result +++ b/mysql-test/main/partition_error.result @@ -754,7 +754,7 @@ ERROR HY000: Field 'c' is of a not allowed type for this type of partitioning # CREATE TABLE t1 (a INT) PARTITION BY HASH(a); CREATE TEMPORARY TABLE tmp_t1 LIKE t1; -ERROR HY000: Cannot create temporary table with partitions +ERROR HY000: Partitioned tables do not support CREATE TEMPORARY TABLE DROP TABLE t1; # # Bug#42954: SQL MODE 'NO_DIR_IN_CREATE' does not work with diff --git a/mysql-test/main/partition_error.test b/mysql-test/main/partition_error.test index 8739c93fe92..7436bb060d2 100644 --- a/mysql-test/main/partition_error.test +++ b/mysql-test/main/partition_error.test @@ -788,7 +788,7 @@ PARTITION BY HASH (c) PARTITIONS 4; --echo # with temporary table and partitions --echo # CREATE TABLE t1 (a INT) PARTITION BY HASH(a); ---error ER_PARTITION_NO_TEMPORARY +--error ER_FEATURE_NOT_SUPPORTED_WITH_PARTITIONING CREATE TEMPORARY TABLE tmp_t1 LIKE t1; DROP TABLE t1; --echo # diff --git a/mysql-test/main/partition_explicit_prune.result b/mysql-test/main/partition_explicit_prune.result index 56fd0ff569a..5b3049c146f 100644 --- a/mysql-test/main/partition_explicit_prune.result +++ b/mysql-test/main/partition_explicit_prune.result @@ -546,7 +546,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 -HANDLER_READ_KEY 2 +HANDLER_READ_KEY 1 HANDLER_TMP_WRITE 24 HANDLER_UPDATE 2 HANDLER_WRITE 2 @@ -628,7 +628,7 @@ WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 4 HANDLER_DELETE 2 -HANDLER_READ_KEY 3 +HANDLER_READ_KEY 2 HANDLER_READ_NEXT 1 HANDLER_READ_RND_NEXT 112 HANDLER_ROLLBACK 1 @@ -651,7 +651,7 @@ VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 5 HANDLER_DELETE 2 HANDLER_READ_FIRST 1 -HANDLER_READ_KEY 3 +HANDLER_READ_KEY 2 HANDLER_READ_NEXT 4 HANDLER_READ_RND_NEXT 140 HANDLER_ROLLBACK 1 @@ -671,7 +671,7 @@ VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 5 HANDLER_DELETE 2 HANDLER_READ_FIRST 1 -HANDLER_READ_KEY 3 +HANDLER_READ_KEY 2 HANDLER_READ_NEXT 4 HANDLER_READ_RND_NEXT 168 HANDLER_ROLLBACK 1 diff --git a/mysql-test/main/partition_innodb.result b/mysql-test/main/partition_innodb.result index 6be6721f0d1..67829fd46d9 100644 --- a/mysql-test/main/partition_innodb.result +++ b/mysql-test/main/partition_innodb.result @@ -246,10 +246,10 @@ KEY parent_id (parent_id) ) ENGINE=InnoDB; ALTER TABLE t1 PARTITION BY HASH (id) PARTITIONS 1; ALTER TABLE t1 ADD CONSTRAINT test_ibfk_1 FOREIGN KEY (parent_id) REFERENCES t2 (id); -ERROR HY000: Foreign key clause is not yet supported in conjunction with partitioning +ERROR HY000: Partitioned tables do not support FOREIGN KEY ALTER TABLE t1 PARTITION BY HASH (id) PARTITIONS 2; ALTER TABLE t1 ADD CONSTRAINT test_ibfk_1 FOREIGN KEY (parent_id) REFERENCES t2 (id); -ERROR HY000: Foreign key clause is not yet supported in conjunction with partitioning +ERROR HY000: Partitioned tables do not support FOREIGN KEY DROP TABLE t1, t2; create table t1 (a varchar(5), b int signed, c varchar(10), d datetime) partition by range columns(b,c) @@ -699,7 +699,7 @@ EXPLAIN SELECT * FROM t1 WHERE col1 = 1 AND col2 = 2 AND col3 BETWEEN '2013-03-08 00:00:00' AND '2013-03-12 12:00:00' GROUP BY 1, 2, 3; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref PRIMARY,col1,col2 col1 8 const # Using where; Using filesort +1 SIMPLE t1 range PRIMARY,col1,col2 PRIMARY 5 NULL # Using where; Using filesort SELECT * FROM t1 USE INDEX () WHERE col1 = 1 AND col2 = 2 AND col3 BETWEEN '2013-03-08 00:00:00' AND '2013-03-12 12:00:00' GROUP BY 1, 2, 3; diff --git a/mysql-test/main/partition_innodb.test b/mysql-test/main/partition_innodb.test index 16fd7ea60ef..cdf4e257e70 100644 --- a/mysql-test/main/partition_innodb.test +++ b/mysql-test/main/partition_innodb.test @@ -240,12 +240,12 @@ CREATE TABLE t1 ( ALTER TABLE t1 PARTITION BY HASH (id) PARTITIONS 1; ---error ER_FOREIGN_KEY_ON_PARTITIONED +--error ER_FEATURE_NOT_SUPPORTED_WITH_PARTITIONING ALTER TABLE t1 ADD CONSTRAINT test_ibfk_1 FOREIGN KEY (parent_id) REFERENCES t2 (id); ALTER TABLE t1 PARTITION BY HASH (id) PARTITIONS 2; ---error ER_FOREIGN_KEY_ON_PARTITIONED +--error ER_FEATURE_NOT_SUPPORTED_WITH_PARTITIONING ALTER TABLE t1 ADD CONSTRAINT test_ibfk_1 FOREIGN KEY (parent_id) REFERENCES t2 (id); DROP TABLE t1, t2; diff --git a/mysql-test/main/partition_mrr_aria.result b/mysql-test/main/partition_mrr_aria.result index ccef491242b..99fb17338c3 100644 --- a/mysql-test/main/partition_mrr_aria.result +++ b/mysql-test/main/partition_mrr_aria.result @@ -4,8 +4,8 @@ drop table if exists t1,t3; # create table t1(a int); insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); -set @tmp=@@storage_engine; -set storage_engine=Aria; +set @tmp=@@default_storage_engine; +set default_storage_engine=Aria; create table t3 ( ID bigint(20) NOT NULL AUTO_INCREMENT, part_id int, @@ -32,7 +32,7 @@ t3 CREATE TABLE `t3` ( (PARTITION `p1` VALUES LESS THAN (3) ENGINE = Aria, PARTITION `p2` VALUES LESS THAN (7) ENGINE = Aria, PARTITION `p3` VALUES LESS THAN (10) ENGINE = Aria) -set storage_engine= @tmp; +set default_storage_engine= @tmp; insert into t3 select A.a+10*B.a, A.a, @@ -129,7 +129,7 @@ set join_cache_level=6; set optimizer_switch='mrr=on'; explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = t2.a-1; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 index idx idx 5 NULL 20 10.00 Using where; Using index +1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index 1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan Warnings: Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = `test`.`t2`.`a` - 1 @@ -146,7 +146,7 @@ tp a b c a 3 4 30 zzzyy 4 explain extended select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = t2.a-1; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 index idx idx 5 NULL 20 10.00 Using where; Using index +1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index 1 SIMPLE t1 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan Warnings: Note 1003 select `test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` / 10 = `test`.`t2`.`a` - 1 @@ -163,7 +163,7 @@ tp a b c a 3 4 30 zzzyy 4 explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 index idx idx 5 NULL 20 10.00 Using where; Using index +1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index 1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using index condition; Using join buffer (flat, BKA join); Rowid-ordered scan Warnings: Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = 4 @@ -189,7 +189,7 @@ tp a b c a 2 4 40 xxzy 4 explain extended select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 index idx idx 5 NULL 20 10.00 Using where; Using index +1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index 1 SIMPLE t1 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan Warnings: Note 1003 select `test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` / 10 = 4 @@ -221,7 +221,7 @@ test.t2 analyze status Engine-independent statistics collected test.t2 analyze status OK explain extended select * from t2 left join t0 on t2.a=t0.a where t2.a in (3,4) and t0.b is null; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 index idx idx 5 NULL 23 17.39 Using where; Using index +1 SIMPLE t2 range idx idx 5 NULL 4 100.00 Using where; Using index 1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using where; Not exists; Using join buffer (flat, BKA join); Rowid-ordered scan Warnings: Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c` from `test`.`t2` left join `test`.`t0` on(`test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` is not null) where `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` is null @@ -229,7 +229,7 @@ select * from t2 left join t0 on t2.a=t0.a where t2.a in (3,4) and t0.b is null; a tp a b c explain extended select * from t2 left join t1 on t2.a=t1.a where t2.a in (3,4) and t1.b is null; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 index idx idx 5 NULL 23 17.39 Using where; Using index +1 SIMPLE t2 range idx idx 5 NULL 4 100.00 Using where; Using index 1 SIMPLE t1 ref idx idx 5 test.t2.a 12 100.00 Using where; Not exists; Using join buffer (flat, BKA join); Rowid-ordered scan Warnings: Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t2` left join `test`.`t1` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` is not null) where `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` is null diff --git a/mysql-test/main/partition_mrr_innodb.result b/mysql-test/main/partition_mrr_innodb.result index 4aad8134866..8e34914a6e3 100644 --- a/mysql-test/main/partition_mrr_innodb.result +++ b/mysql-test/main/partition_mrr_innodb.result @@ -4,8 +4,8 @@ drop table if exists t1,t3; # create table t1(a int); insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); -set @tmp=@@storage_engine; -set storage_engine=InnoDB; +set @tmp=@@default_storage_engine; +set default_storage_engine=InnoDB; create table t3 ( ID bigint(20) NOT NULL AUTO_INCREMENT, part_id int, @@ -32,7 +32,7 @@ t3 CREATE TABLE `t3` ( (PARTITION `p1` VALUES LESS THAN (3) ENGINE = InnoDB, PARTITION `p2` VALUES LESS THAN (7) ENGINE = InnoDB, PARTITION `p3` VALUES LESS THAN (10) ENGINE = InnoDB) -set storage_engine= @tmp; +set default_storage_engine= @tmp; insert into t3 select A.a+10*B.a, A.a, @@ -129,7 +129,7 @@ set join_cache_level=6; set optimizer_switch='mrr=on'; explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = t2.a-1; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 index idx idx 5 NULL 20 10.00 Using where; Using index +1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index 1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan Warnings: Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = `test`.`t2`.`a` - 1 @@ -146,7 +146,7 @@ tp a b c a 3 4 30 zzzyy 4 explain extended select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = t2.a-1; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 index idx idx 5 NULL 20 10.00 Using where; Using index +1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index 1 SIMPLE t1 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan Warnings: Note 1003 select `test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` / 10 = `test`.`t2`.`a` - 1 @@ -163,7 +163,7 @@ tp a b c a 3 4 30 zzzyy 4 explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 index idx idx 5 NULL 20 10.00 Using where; Using index +1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index 1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using index condition; Using join buffer (flat, BKA join); Rowid-ordered scan Warnings: Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = 4 @@ -189,7 +189,7 @@ tp a b c a 2 4 40 xxzy 4 explain extended select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 index idx idx 5 NULL 20 10.00 Using where; Using index +1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index 1 SIMPLE t1 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan Warnings: Note 1003 select `test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` / 10 = 4 @@ -221,7 +221,7 @@ test.t2 analyze status Engine-independent statistics collected test.t2 analyze status OK explain extended select * from t2 left join t0 on t2.a=t0.a where t2.a in (3,4) and t0.b is null; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 index idx idx 5 NULL 23 17.39 Using where; Using index +1 SIMPLE t2 range idx idx 5 NULL 4 100.00 Using where; Using index 1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using where; Not exists; Using join buffer (flat, BKA join); Rowid-ordered scan Warnings: Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c` from `test`.`t2` left join `test`.`t0` on(`test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` is not null) where `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` is null @@ -229,7 +229,7 @@ select * from t2 left join t0 on t2.a=t0.a where t2.a in (3,4) and t0.b is null; a tp a b c explain extended select * from t2 left join t1 on t2.a=t1.a where t2.a in (3,4) and t1.b is null; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 index idx idx 5 NULL 23 17.39 Using where; Using index +1 SIMPLE t2 range idx idx 5 NULL 4 100.00 Using where; Using index 1 SIMPLE t1 ref idx idx 5 test.t2.a 12 100.00 Using where; Not exists; Using join buffer (flat, BKA join); Rowid-ordered scan Warnings: Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t2` left join `test`.`t1` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` is not null) where `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` is null diff --git a/mysql-test/main/partition_mrr_myisam.result b/mysql-test/main/partition_mrr_myisam.result index 7e060b35c53..395b64ffb11 100644 --- a/mysql-test/main/partition_mrr_myisam.result +++ b/mysql-test/main/partition_mrr_myisam.result @@ -4,8 +4,8 @@ drop table if exists t1,t3; # create table t1(a int); insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); -set @tmp=@@storage_engine; -set storage_engine=myisam; +set @tmp=@@default_storage_engine; +set default_storage_engine=myisam; create table t3 ( ID bigint(20) NOT NULL AUTO_INCREMENT, part_id int, @@ -32,7 +32,7 @@ t3 CREATE TABLE `t3` ( (PARTITION `p1` VALUES LESS THAN (3) ENGINE = MyISAM, PARTITION `p2` VALUES LESS THAN (7) ENGINE = MyISAM, PARTITION `p3` VALUES LESS THAN (10) ENGINE = MyISAM) -set storage_engine= @tmp; +set default_storage_engine= @tmp; insert into t3 select A.a+10*B.a, A.a, @@ -129,7 +129,7 @@ set join_cache_level=6; set optimizer_switch='mrr=on'; explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = t2.a-1; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 index idx idx 5 NULL 20 10.00 Using where; Using index +1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index 1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan Warnings: Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = `test`.`t2`.`a` - 1 @@ -146,7 +146,7 @@ tp a b c a 3 4 30 zzzyy 4 explain extended select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = t2.a-1; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 index idx idx 5 NULL 20 10.00 Using where; Using index +1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index 1 SIMPLE t1 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan Warnings: Note 1003 select `test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` / 10 = `test`.`t2`.`a` - 1 @@ -163,7 +163,7 @@ tp a b c a 3 4 30 zzzyy 4 explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 index idx idx 5 NULL 20 10.00 Using where; Using index +1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index 1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using index condition; Using join buffer (flat, BKA join); Rowid-ordered scan Warnings: Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = 4 @@ -189,7 +189,7 @@ tp a b c a 2 4 40 xxzy 4 explain extended select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 index idx idx 5 NULL 20 10.00 Using where; Using index +1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index 1 SIMPLE t1 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan Warnings: Note 1003 select `test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` / 10 = 4 @@ -221,7 +221,7 @@ test.t2 analyze status Engine-independent statistics collected test.t2 analyze status OK explain extended select * from t2 left join t0 on t2.a=t0.a where t2.a in (3,4) and t0.b is null; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 index idx idx 5 NULL 23 17.39 Using where; Using index +1 SIMPLE t2 range idx idx 5 NULL 4 100.00 Using where; Using index 1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using where; Not exists; Using join buffer (flat, BKA join); Rowid-ordered scan Warnings: Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c` from `test`.`t2` left join `test`.`t0` on(`test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` is not null) where `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` is null @@ -229,7 +229,7 @@ select * from t2 left join t0 on t2.a=t0.a where t2.a in (3,4) and t0.b is null; a tp a b c explain extended select * from t2 left join t1 on t2.a=t1.a where t2.a in (3,4) and t1.b is null; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 index idx idx 5 NULL 23 17.39 Using where; Using index +1 SIMPLE t2 range idx idx 5 NULL 4 100.00 Using where; Using index 1 SIMPLE t1 ref idx idx 5 test.t2.a 12 100.00 Using where; Not exists; Using join buffer (flat, BKA join); Rowid-ordered scan Warnings: Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t2` left join `test`.`t1` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` is not null) where `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` is null @@ -287,13 +287,13 @@ set join_cache_level=6, optimizer_switch='mrr=on'; explain select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 index idx idx 5 NULL 20 Using where; Using index +1 SIMPLE t2 range idx idx 5 NULL 2 Using where; Using index 1 SIMPLE t0 ref idx idx 5 test.t2.a 12 Using index condition; Using join buffer (flat, BKA join); Rowid-ordered scan # This will use "Using index condition(BKA)" explain select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 index idx idx 5 NULL 20 Using where; Using index +1 SIMPLE t2 range idx idx 5 NULL 2 Using where; Using index 1 SIMPLE t1 ref idx idx 5 test.t2.a 12 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan set join_cache_level=@tmp1, optimizer_switch=@tmp2; drop table t0,t1,t2; diff --git a/mysql-test/main/partition_myisam.result b/mysql-test/main/partition_myisam.result index 8f35075261a..3a549060d8e 100644 --- a/mysql-test/main/partition_myisam.result +++ b/mysql-test/main/partition_myisam.result @@ -87,10 +87,9 @@ test.t1 check Error Failed to read from the .par file test.t1 check error Corrupt SELECT * FROM t1; ERROR HY000: Failed to read from the .par file -# Note that it is currently impossible to drop a partitioned table -# without the .par file DROP TABLE t1; -ERROR HY000: Got error 1 "Operation not permitted" from storage engine partition +Warnings: +Warning 1017 Can't find file: './test/t1.par' (errno: 2 "No such file or directory") # # Bug#50392: insert_id is not reset for partitioned tables # auto_increment on duplicate entry diff --git a/mysql-test/main/partition_myisam.test b/mysql-test/main/partition_myisam.test index 4d083c37b68..b26b619a958 100644 --- a/mysql-test/main/partition_myisam.test +++ b/mysql-test/main/partition_myisam.test @@ -121,12 +121,8 @@ FLUSH TABLES; CHECK TABLE t1; --error ER_FAILED_READ_FROM_PAR_FILE SELECT * FROM t1; ---echo # Note that it is currently impossible to drop a partitioned table ---echo # without the .par file ---replace_result "Not owner" "Operation not permitted" ---error ER_GET_ERRNO +--replace_result $MYSQLD_DATADIR ./ DROP TABLE t1; ---remove_file $MYSQLD_DATADIR/test/t1.frm --remove_file $MYSQLD_DATADIR/test/t1#P#p0.MYI --remove_file $MYSQLD_DATADIR/test/t1#P#p0.MYD diff --git a/mysql-test/main/partition_not_blackhole.result b/mysql-test/main/partition_not_blackhole.result index ff1e51df892..6cb8dea80c8 100644 --- a/mysql-test/main/partition_not_blackhole.result +++ b/mysql-test/main/partition_not_blackhole.result @@ -11,6 +11,6 @@ t1 SHOW CREATE TABLE t1; ERROR HY000: Failed to read from the .par file DROP TABLE t1; -ERROR HY000: Got error 1 "Operation not permitted" from storage engine partition +ERROR HY000: Got error 175 "File too short; Expected more data in file" from storage engine partition t1.frm t1.par diff --git a/mysql-test/main/partition_pruning.result b/mysql-test/main/partition_pruning.result index f8ae65fbcea..519bf590b9b 100644 --- a/mysql-test/main/partition_pruning.result +++ b/mysql-test/main/partition_pruning.result @@ -18,7 +18,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra # # # # # # # # # 3 # EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 7; id select_type table partitions type possible_keys key key_len ref rows Extra -# # # # # # # # # 10 # +# # # # # # # # # 8 # EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 1; id select_type table partitions type possible_keys key key_len ref rows Extra # # # # # # # # # 3 # @@ -42,7 +42,7 @@ a 0 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 1; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index +1 SIMPLE t1 p0 range PRIMARY PRIMARY 4 NULL 2 Using where; Using index SELECT * FROM t1 WHERE a < 2; a -1 @@ -50,7 +50,7 @@ a 1 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 2; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1 index PRIMARY PRIMARY 4 NULL 3 Using where; Using index +1 SIMPLE t1 p0,p1 range PRIMARY PRIMARY 4 NULL 3 Using where; Using index SELECT * FROM t1 WHERE a < 3; a -1 @@ -59,7 +59,7 @@ a 2 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2 index PRIMARY PRIMARY 4 NULL 4 Using where; Using index +1 SIMPLE t1 p0,p1,p2 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index SELECT * FROM t1 WHERE a < 4; a -1 @@ -69,7 +69,7 @@ a 3 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 4; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3 index PRIMARY PRIMARY 4 NULL 5 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3 range PRIMARY PRIMARY 4 NULL 5 Using where; Using index SELECT * FROM t1 WHERE a < 5; a -1 @@ -80,7 +80,7 @@ a 4 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 5; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3,p4 index PRIMARY PRIMARY 4 NULL 6 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3,p4 range PRIMARY PRIMARY 4 NULL 6 Using where; Using index SELECT * FROM t1 WHERE a < 6; a -1 @@ -92,7 +92,7 @@ a 5 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 6; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3,p4,p5 index PRIMARY PRIMARY 4 NULL 7 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3,p4,p5 range PRIMARY PRIMARY 4 NULL 7 Using where; Using index SELECT * FROM t1 WHERE a < 7; a -1 @@ -105,7 +105,7 @@ a 6 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 7; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 8 Using where; Using index SELECT * FROM t1 WHERE a <= 1; a -1 @@ -113,7 +113,7 @@ a 1 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 1; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1 index PRIMARY PRIMARY 4 NULL 3 Using where; Using index +1 SIMPLE t1 p0,p1 range PRIMARY PRIMARY 4 NULL 3 Using where; Using index SELECT * FROM t1 WHERE a <= 2; a -1 @@ -122,7 +122,7 @@ a 2 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 2; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2 index PRIMARY PRIMARY 4 NULL 4 Using where; Using index +1 SIMPLE t1 p0,p1,p2 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index SELECT * FROM t1 WHERE a <= 3; a -1 @@ -132,7 +132,7 @@ a 3 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3 index PRIMARY PRIMARY 4 NULL 5 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3 range PRIMARY PRIMARY 4 NULL 5 Using where; Using index SELECT * FROM t1 WHERE a <= 4; a -1 @@ -143,7 +143,7 @@ a 4 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 4; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3,p4 index PRIMARY PRIMARY 4 NULL 6 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3,p4 range PRIMARY PRIMARY 4 NULL 6 Using where; Using index SELECT * FROM t1 WHERE a <= 5; a -1 @@ -155,7 +155,7 @@ a 5 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 5; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3,p4,p5 index PRIMARY PRIMARY 4 NULL 7 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3,p4,p5 range PRIMARY PRIMARY 4 NULL 7 Using where; Using index SELECT * FROM t1 WHERE a <= 6; a -1 @@ -168,7 +168,7 @@ a 6 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 6; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 8 Using where; Using index SELECT * FROM t1 WHERE a <= 7; a -1 @@ -182,7 +182,7 @@ a 7 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 7; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 9 Using where; Using index SELECT * FROM t1 WHERE a = 1; a 1 @@ -237,7 +237,7 @@ a 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 1; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p1,p2,p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 8 Using where; Using index +1 SIMPLE t1 p1,p2,p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 8 Using where; Using index SELECT * FROM t1 WHERE a >= 2; a 2 @@ -249,7 +249,7 @@ a 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 2; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2,p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 7 Using where; Using index +1 SIMPLE t1 p2,p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 7 Using where; Using index SELECT * FROM t1 WHERE a >= 3; a 3 @@ -260,7 +260,7 @@ a 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 6 Using where; Using index +1 SIMPLE t1 p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 6 Using where; Using index SELECT * FROM t1 WHERE a >= 4; a 4 @@ -270,7 +270,7 @@ a 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 4; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p4,p5,max index PRIMARY PRIMARY 4 NULL 5 Using where; Using index +1 SIMPLE t1 p4,p5,max range PRIMARY PRIMARY 4 NULL 5 Using where; Using index SELECT * FROM t1 WHERE a >= 5; a 5 @@ -279,7 +279,7 @@ a 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 5; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p5,max index PRIMARY PRIMARY 4 NULL 4 Using where; Using index +1 SIMPLE t1 p5,max range PRIMARY PRIMARY 4 NULL 4 Using where; Using index SELECT * FROM t1 WHERE a >= 6; a 6 @@ -287,14 +287,14 @@ a 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 6; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index +1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 3 Using where; Using index SELECT * FROM t1 WHERE a >= 7; a 7 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 7; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index +1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 2 Using where; Using index SELECT * FROM t1 WHERE a > 1; a 2 @@ -306,7 +306,7 @@ a 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 1; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2,p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 7 Using where; Using index +1 SIMPLE t1 p2,p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 7 Using where; Using index SELECT * FROM t1 WHERE a > 2; a 3 @@ -317,7 +317,7 @@ a 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 2; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 6 Using where; Using index +1 SIMPLE t1 p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 6 Using where; Using index SELECT * FROM t1 WHERE a > 3; a 4 @@ -327,7 +327,7 @@ a 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p4,p5,max index PRIMARY PRIMARY 4 NULL 5 Using where; Using index +1 SIMPLE t1 p4,p5,max range PRIMARY PRIMARY 4 NULL 5 Using where; Using index SELECT * FROM t1 WHERE a > 4; a 5 @@ -336,7 +336,7 @@ a 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 4; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p5,max index PRIMARY PRIMARY 4 NULL 4 Using where; Using index +1 SIMPLE t1 p5,max range PRIMARY PRIMARY 4 NULL 4 Using where; Using index SELECT * FROM t1 WHERE a > 5; a 6 @@ -344,20 +344,20 @@ a 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 5; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index +1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 3 Using where; Using index SELECT * FROM t1 WHERE a > 6; a 7 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 6; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index +1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 2 Using where; Using index SELECT * FROM t1 WHERE a > 7; a 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 7; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index +1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 1 Using where; Using index DROP TABLE t1; CREATE TABLE t1 (a INT PRIMARY KEY) PARTITION BY RANGE (a) ( @@ -374,7 +374,7 @@ a 0 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 1; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index +1 SIMPLE t1 p0 range PRIMARY PRIMARY 4 NULL 2 Using where; Using index SELECT * FROM t1 WHERE a < 2; a -1 @@ -382,7 +382,7 @@ a 1 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 2; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1 index PRIMARY PRIMARY 4 NULL 3 Using where; Using index +1 SIMPLE t1 p0,p1 range PRIMARY PRIMARY 4 NULL 3 Using where; Using index SELECT * FROM t1 WHERE a < 3; a -1 @@ -391,7 +391,7 @@ a 2 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2 index PRIMARY PRIMARY 4 NULL 4 Using where; Using index +1 SIMPLE t1 p0,p1,p2 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index SELECT * FROM t1 WHERE a < 4; a -1 @@ -401,7 +401,7 @@ a 3 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 4; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3 index PRIMARY PRIMARY 4 NULL 5 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3 range PRIMARY PRIMARY 4 NULL 5 Using where; Using index SELECT * FROM t1 WHERE a < 5; a -1 @@ -412,7 +412,7 @@ a 4 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 5; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3,p4 index PRIMARY PRIMARY 4 NULL 6 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3,p4 range PRIMARY PRIMARY 4 NULL 6 Using where; Using index SELECT * FROM t1 WHERE a < 6; a -1 @@ -424,7 +424,7 @@ a 5 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 6; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3,p4,max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3,p4,max range PRIMARY PRIMARY 4 NULL 7 Using where; Using index SELECT * FROM t1 WHERE a <= 1; a -1 @@ -432,7 +432,7 @@ a 1 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 1; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1 index PRIMARY PRIMARY 4 NULL 3 Using where; Using index +1 SIMPLE t1 p0,p1 range PRIMARY PRIMARY 4 NULL 3 Using where; Using index SELECT * FROM t1 WHERE a <= 2; a -1 @@ -441,7 +441,7 @@ a 2 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 2; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2 index PRIMARY PRIMARY 4 NULL 4 Using where; Using index +1 SIMPLE t1 p0,p1,p2 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index SELECT * FROM t1 WHERE a <= 3; a -1 @@ -451,7 +451,7 @@ a 3 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3 index PRIMARY PRIMARY 4 NULL 5 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3 range PRIMARY PRIMARY 4 NULL 5 Using where; Using index SELECT * FROM t1 WHERE a <= 4; a -1 @@ -462,7 +462,7 @@ a 4 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 4; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3,p4 index PRIMARY PRIMARY 4 NULL 6 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3,p4 range PRIMARY PRIMARY 4 NULL 6 Using where; Using index SELECT * FROM t1 WHERE a <= 5; a -1 @@ -474,7 +474,7 @@ a 5 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 5; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3,p4,max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3,p4,max range PRIMARY PRIMARY 4 NULL 7 Using where; Using index SELECT * FROM t1 WHERE a <= 6; a -1 @@ -487,7 +487,7 @@ a 6 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 6; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3,p4,max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3,p4,max range PRIMARY PRIMARY 4 NULL 8 Using where; Using index SELECT * FROM t1 WHERE a = 1; a 1 @@ -535,7 +535,7 @@ a 7 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 1; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p1,p2,p3,p4,max index PRIMARY PRIMARY 4 NULL 7 Using where; Using index +1 SIMPLE t1 p1,p2,p3,p4,max range PRIMARY PRIMARY 4 NULL 7 Using where; Using index SELECT * FROM t1 WHERE a >= 2; a 2 @@ -546,7 +546,7 @@ a 7 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 2; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2,p3,p4,max index PRIMARY PRIMARY 4 NULL 6 Using where; Using index +1 SIMPLE t1 p2,p3,p4,max range PRIMARY PRIMARY 4 NULL 6 Using where; Using index SELECT * FROM t1 WHERE a >= 3; a 3 @@ -556,7 +556,7 @@ a 7 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p3,p4,max index PRIMARY PRIMARY 4 NULL 5 Using where; Using index +1 SIMPLE t1 p3,p4,max range PRIMARY PRIMARY 4 NULL 5 Using where; Using index SELECT * FROM t1 WHERE a >= 4; a 4 @@ -565,7 +565,7 @@ a 7 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 4; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p4,max index PRIMARY PRIMARY 4 NULL 4 Using where; Using index +1 SIMPLE t1 p4,max range PRIMARY PRIMARY 4 NULL 4 Using where; Using index SELECT * FROM t1 WHERE a >= 5; a 5 @@ -573,14 +573,14 @@ a 7 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 5; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index +1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 3 Using where; Using index SELECT * FROM t1 WHERE a >= 6; a 6 7 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 6; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index +1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 2 Using where; Using index SELECT * FROM t1 WHERE a > 1; a 2 @@ -591,7 +591,7 @@ a 7 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 1; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2,p3,p4,max index PRIMARY PRIMARY 4 NULL 6 Using where; Using index +1 SIMPLE t1 p2,p3,p4,max range PRIMARY PRIMARY 4 NULL 6 Using where; Using index SELECT * FROM t1 WHERE a > 2; a 3 @@ -601,7 +601,7 @@ a 7 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 2; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p3,p4,max index PRIMARY PRIMARY 4 NULL 5 Using where; Using index +1 SIMPLE t1 p3,p4,max range PRIMARY PRIMARY 4 NULL 5 Using where; Using index SELECT * FROM t1 WHERE a > 3; a 4 @@ -610,7 +610,7 @@ a 7 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p4,max index PRIMARY PRIMARY 4 NULL 4 Using where; Using index +1 SIMPLE t1 p4,max range PRIMARY PRIMARY 4 NULL 4 Using where; Using index SELECT * FROM t1 WHERE a > 4; a 5 @@ -618,20 +618,20 @@ a 7 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 4; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index +1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 3 Using where; Using index SELECT * FROM t1 WHERE a > 5; a 6 7 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 5; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index +1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 2 Using where; Using index SELECT * FROM t1 WHERE a > 6; a 7 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 6; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index +1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 1 Using where; Using index DROP TABLE t1; # test of RANGE and index CREATE TABLE t1 (a DATE, KEY(a)) @@ -744,62 +744,62 @@ a 1001-01-01 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 index a a 4 NULL 6 Using where; Using index +1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 range a a 4 NULL 5 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 index a a 4 NULL 6 Using where; Using index +1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 range a a 4 NULL 5 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 index a a 4 NULL 5 Using where; Using index +1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 range a a 4 NULL 3 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p2001-01-01 index a a 4 NULL 4 Using where; Using index +1 SIMPLE t1 pNULL,p2001-01-01 range a a 4 NULL 2 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p1001-01-01 system a NULL NULL NULL 1 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 index a a 4 NULL 6 Using where; Using index +1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 range a a 4 NULL 4 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 index a a 4 NULL 6 Using where; Using index +1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 range a a 4 NULL 5 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 index a a 4 NULL 5 Using where; Using index +1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 range a a 4 NULL 4 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 index a a 4 NULL 5 Using where; Using index +1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 range a a 4 NULL 3 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 pNULL ref a a 4 const 1 Using index # Disabling warnings for the invalid date EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01,p2001-01-01 index a a 4 NULL 7 Using where; Using index +1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01,p2001-01-01 range a a 4 NULL 7 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01,p2001-01-01 index a a 4 NULL 7 Using where; Using index +1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01,p2001-01-01 range a a 4 NULL 7 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p2001-01-01 index a a 4 NULL 4 Using where; Using index +1 SIMPLE t1 pNULL,p2001-01-01 range a a 4 NULL 2 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p2001-01-01 index a a 4 NULL 4 Using where; Using index +1 SIMPLE t1 pNULL,p2001-01-01 range a a 4 NULL 2 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 pNULL ref a a 4 const 1 Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1002-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01,p2001-01-01 index a a 4 NULL 7 Using where; Using index +1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01,p2001-01-01 range a a 4 NULL 7 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 index a a 4 NULL 6 Using where; Using index +1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 range a a 4 NULL 5 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-02' AND '1002-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 index a a 4 NULL 5 Using where; Using index +1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 range a a 4 NULL 4 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-01' AND '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 index a a 4 NULL 6 Using where; Using index +1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 range a a 4 NULL 3 Using where; Using index # test without index ALTER TABLE t1 DROP KEY a; SELECT * FROM t1 WHERE a < '1001-01-01'; @@ -1073,62 +1073,62 @@ a 1001-01-01 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 index a a 4 NULL 5 Using where; Using index +1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 range a a 4 NULL 4 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index +1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 5 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 index a a 4 NULL 5 Using where; Using index +1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 range a a 4 NULL 3 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2001-01-01,pNULL index a a 4 NULL 4 Using where; Using index +1 SIMPLE t1 p2001-01-01,pNULL range a a 4 NULL 2 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p1001-01-01 system a NULL NULL NULL 1 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 index a a 4 NULL 5 Using where; Using index +1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 range a a 4 NULL 3 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 index a a 4 NULL 5 Using where; Using index +1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 range a a 4 NULL 4 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 index a a 4 NULL 5 Using where; Using index +1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 range a a 4 NULL 4 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 index a a 4 NULL 5 Using where; Using index +1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 range a a 4 NULL 3 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 pNULL ref a a 4 const 1 Using index # Disabling warnings for the invalid date EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index +1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 6 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index +1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 6 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2001-01-01,pNULL index a a 4 NULL 4 Using where; Using index +1 SIMPLE t1 p2001-01-01,pNULL range a a 4 NULL 2 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2001-01-01,pNULL index a a 4 NULL 4 Using where; Using index +1 SIMPLE t1 p2001-01-01,pNULL range a a 4 NULL 2 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 pNULL ref a a 4 const 1 Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1002-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index +1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 6 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index +1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 5 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-02' AND '1002-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p1001-01-01 index a a 4 NULL 4 Using where; Using index +1 SIMPLE t1 pNULL,p1001-01-01 range a a 4 NULL 3 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-01' AND '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0001-01-01,pNULL,p1001-01-01 index a a 4 NULL 5 Using where; Using index +1 SIMPLE t1 p0001-01-01,pNULL,p1001-01-01 range a a 4 NULL 3 Using where; Using index # test without index ALTER TABLE t1 DROP KEY a; SELECT * FROM t1 WHERE a < '1001-01-01'; @@ -1402,62 +1402,62 @@ a 1001-01-01 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 index a a 4 NULL 5 Using where; Using index +1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 range a a 4 NULL 4 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index +1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 5 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 index a a 4 NULL 5 Using where; Using index +1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 range a a 4 NULL 3 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2001-01-01,pNULL index a a 4 NULL 4 Using where; Using index +1 SIMPLE t1 p2001-01-01,pNULL range a a 4 NULL 2 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p1001-01-01 system a NULL NULL NULL 1 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 index a a 4 NULL 5 Using where; Using index +1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 range a a 4 NULL 3 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 index a a 4 NULL 5 Using where; Using index +1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 range a a 4 NULL 4 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 index a a 4 NULL 5 Using where; Using index +1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 range a a 4 NULL 4 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 index a a 4 NULL 5 Using where; Using index +1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 range a a 4 NULL 3 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 pNULL ref a a 4 const 1 Using index # Disabling warnings for the invalid date EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index +1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 6 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index +1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 6 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2001-01-01,pNULL index a a 4 NULL 4 Using where; Using index +1 SIMPLE t1 p2001-01-01,pNULL range a a 4 NULL 2 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2001-01-01,pNULL index a a 4 NULL 4 Using where; Using index +1 SIMPLE t1 p2001-01-01,pNULL range a a 4 NULL 2 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 pNULL ref a a 4 const 1 Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1002-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index +1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 6 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index +1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 5 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-02' AND '1002-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p1001-01-01 index a a 4 NULL 4 Using where; Using index +1 SIMPLE t1 pNULL,p1001-01-01 range a a 4 NULL 3 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-01' AND '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0001-01-01,pNULL,p1001-01-01 index a a 4 NULL 5 Using where; Using index +1 SIMPLE t1 p0001-01-01,pNULL,p1001-01-01 range a a 4 NULL 3 Using where; Using index # test without index ALTER TABLE t1 DROP KEY a; SELECT * FROM t1 WHERE a < '1001-01-01'; @@ -2676,13 +2676,13 @@ explain partitions select * from t1 X, t1 Y where X.b = Y.b and (X.a=1 or X.a=2) and (Y.a=2 or Y.a=3); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE X p1,p2 ALL a,b NULL NULL NULL 8 Using where -1 SIMPLE Y p2,p3 ALL a,b NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join) +1 SIMPLE X p1,p2 range a,b a 4 NULL 4 Using where +1 SIMPLE Y p2,p3 ref|filter a,b b|a 4|4 test.X.b 2 (50%) Using where; Using rowid filter explain partitions select * from t1 X, t1 Y where X.a = Y.a and (X.a=1 or X.a=2); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE X p1,p2 ALL a NULL NULL NULL 8 Using where -1 SIMPLE Y p1,p2 ALL a NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join) +1 SIMPLE X p1,p2 range a a 4 NULL 4 Using where +1 SIMPLE Y p1,p2 ref a a 4 test.X.a 2 drop table t1; create table t1 (a int) partition by hash(a) partitions 20; insert into t1 values (1),(2),(3); diff --git a/mysql-test/main/partition_range.result b/mysql-test/main/partition_range.result index 6eb7147b461..ac8d34c71a2 100644 --- a/mysql-test/main/partition_range.result +++ b/mysql-test/main/partition_range.result @@ -2,16 +2,25 @@ drop table if exists t1, t2; # # Bug#48229: group by performance issue of partitioned table # -CREATE TABLE t1 ( -a INT, -b INT, -KEY a (a,b) -) -PARTITION BY HASH (a) PARTITIONS 1; -INSERT INTO t1 VALUES (0, 580092), (3, 894076), (4, 805483), (4, 913540), (6, 611137), (8, 171602), (9, 599495), (9, 746305), (10, 272829), (10, 847519), (12, 258869), (12, 929028), (13, 288970), (15, 20971), (15, 105839), (16, 788272), (17, 76914), (18, 827274), (19, 802258), (20, 123677), (20, 587729), (22, 701449), (25, 31565), (25, 230782), (25, 442887), (25, 733139), (25, 851020); -EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10, 100, 3) GROUP BY a; +CREATE TABLE t1 (a INT,b INT,KEY a (a,b)); +INSERT INTO `t1` VALUES (0,580092),(3000,894076),(4000,805483),(4000,913540),(6000,611137),(8000,171602),(9000,599495),(9000,746305),(10000,272829),(10000,847519),(12000,258869),(12000,929028),(13000,288970),(15000,20971),(15000,105839),(16000,788272),(17000,76914),(18000,827274),(19000,802258),(20000,123677),(20000,587729),(22000,701449),(25000,31565),(25000,230782),(25000,442887),(25000,733139),(25000,851020); +EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10000, 1000000, 3000) GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range a a 5 NULL 1 Using where; Using index for group-by +alter table t1 partition by hash(a) partitions 1; +EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10000, 1000000, 3000) GROUP BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 5 NULL 1 Using where; Using index for group-by +alter table t1 remove partitioning; +insert into t1 (a,b) select seq,seq from seq_4001_to_4100; +insert into t1 (a,b) select seq,seq from seq_10001_to_10100; +EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10000, 1000000, 3000) GROUP BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 5 NULL 4 Using where; Using index +alter table t1 partition by hash(a) partitions 1; +EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10000, 1000000, 3000) GROUP BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 5 NULL 4 Using where; Using index DROP TABLE t1; create table t1 (a DATETIME) partition by range (TO_DAYS(a)) diff --git a/mysql-test/main/partition_range.test b/mysql-test/main/partition_range.test index 52497764241..f56851217cf 100644 --- a/mysql-test/main/partition_range.test +++ b/mysql-test/main/partition_range.test @@ -3,7 +3,8 @@ # Simple test for the partition storage engine # Focuses on range partitioning tests # --- source include/have_partition.inc +--source include/have_partition.inc +--source include/have_sequence.inc --disable_warnings drop table if exists t1, t2; @@ -12,19 +13,23 @@ drop table if exists t1, t2; --echo # --echo # Bug#48229: group by performance issue of partitioned table --echo # -CREATE TABLE t1 ( - a INT, - b INT, - KEY a (a,b) -) -PARTITION BY HASH (a) PARTITIONS 1; -# insert some rows (i.e. so that rows/blocks > 1) -INSERT INTO t1 VALUES (0, 580092), (3, 894076), (4, 805483), (4, 913540), (6, 611137), (8, 171602), (9, 599495), (9, 746305), (10, 272829), (10, 847519), (12, 258869), (12, 929028), (13, 288970), (15, 20971), (15, 105839), (16, 788272), (17, 76914), (18, 827274), (19, 802258), (20, 123677), (20, 587729), (22, 701449), (25, 31565), (25, 230782), (25, 442887), (25, 733139), (25, 851020); +CREATE TABLE t1 (a INT,b INT,KEY a (a,b)); +INSERT INTO `t1` VALUES (0,580092),(3000,894076),(4000,805483),(4000,913540),(6000,611137),(8000,171602),(9000,599495),(9000,746305),(10000,272829),(10000,847519),(12000,258869),(12000,929028),(13000,288970),(15000,20971),(15000,105839),(16000,788272),(17000,76914),(18000,827274),(19000,802258),(20000,123677),(20000,587729),(22000,701449),(25000,31565),(25000,230782),(25000,442887),(25000,733139),(25000,851020); + +EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10000, 1000000, 3000) GROUP BY a; + +alter table t1 partition by hash(a) partitions 1; +EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10000, 1000000, 3000) GROUP BY a; +alter table t1 remove partitioning; + +insert into t1 (a,b) select seq,seq from seq_4001_to_4100; +insert into t1 (a,b) select seq,seq from seq_10001_to_10100; -# Before the fix the 'Extra' column showed 'Using index for group-by' -EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10, 100, 3) GROUP BY a; +EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10000, 1000000, 3000) GROUP BY a; +alter table t1 partition by hash(a) partitions 1; +EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10000, 1000000, 3000) GROUP BY a; DROP TABLE t1; # diff --git a/mysql-test/main/partition_utf8-debug.result b/mysql-test/main/partition_utf8-debug.result new file mode 100644 index 00000000000..569bec3ea8a --- /dev/null +++ b/mysql-test/main/partition_utf8-debug.result @@ -0,0 +1,88 @@ +# +# Start of 10.5 tests +# +# +# MDEV-20856 Bad values in metadata views for partitions on VARBINARY +# +SET NAMES utf8; +SET @save_dbug = @@debug_dbug; +SET SESSION debug_dbug="+d,generate_partition_syntax_for_frm"; +CREATE OR REPLACE TABLE t1 (a VARCHAR(10)) CHARACTER SET latin1 +PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN (_utf8'á¹ ')); +ERROR HY000: This partition function is not allowed +CREATE OR REPLACE TABLE t1 (a VARCHAR(10)) CHARACTER SET latin1 +PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN ('á¹ ')); +ERROR HY000: This partition function is not allowed +CREATE OR REPLACE TABLE t1 (a VARCHAR(10)) CHARACTER SET latin1 +PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN (_latin1 0xDF)); +Warnings: +Note 1003 PARTITION BY LIST COLUMNS(`a`) +(PARTITION `p0` VALUES IN (_latin1 0xdf) ENGINE = MyISAM) +SELECT PARTITION_DESCRIPTION FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME='t1'; +PARTITION_DESCRIPTION +'ß' +DROP TABLE t1; +CREATE OR REPLACE TABLE t1 (a VARCHAR(10)) CHARACTER SET latin1 +PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN (_utf8'ß')); +Warnings: +Note 1003 PARTITION BY LIST COLUMNS(`a`) +(PARTITION `p0` VALUES IN (_latin1 0xdf) ENGINE = MyISAM) +SELECT PARTITION_DESCRIPTION FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME='t1'; +PARTITION_DESCRIPTION +'ß' +DROP TABLE t1; +CREATE OR REPLACE TABLE t1 (a VARCHAR(10)) CHARACTER SET latin1 +PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN ('ß')); +Warnings: +Note 1003 PARTITION BY LIST COLUMNS(`a`) +(PARTITION `p0` VALUES IN (_latin1 0xdf) ENGINE = MyISAM) +DROP TABLE t1; +CREATE OR REPLACE TABLE t1 (a VARCHAR(10)) CHARACTER SET utf8 +PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN (_utf8'ß')); +Warnings: +Note 1003 PARTITION BY LIST COLUMNS(`a`) +(PARTITION `p0` VALUES IN (_utf8 0xc39f) ENGINE = MyISAM) +SELECT PARTITION_DESCRIPTION FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME='t1'; +PARTITION_DESCRIPTION +'ß' +DROP TABLE t1; +CREATE OR REPLACE TABLE t1 (a VARCHAR(10)) CHARACTER SET utf8 +PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN ('ß')); +Warnings: +Note 1003 PARTITION BY LIST COLUMNS(`a`) +(PARTITION `p0` VALUES IN (_utf8 0xc39f) ENGINE = MyISAM) +SELECT PARTITION_DESCRIPTION FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME='t1'; +PARTITION_DESCRIPTION +'ß' +DROP TABLE t1; +CREATE OR REPLACE TABLE t1 (a VARBINARY(10)) CHARACTER SET utf8 +PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN (0xFF)); +Warnings: +Note 1003 PARTITION BY LIST COLUMNS(`a`) +(PARTITION `p0` VALUES IN (_binary 0xff) ENGINE = MyISAM) +SELECT PARTITION_DESCRIPTION FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME='t1'; +PARTITION_DESCRIPTION +_binary 0xff +DROP TABLE t1; +CREATE OR REPLACE TABLE t1 (a DATE) CHARACTER SET utf8 +PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN (FROM_DAYS(NULL))); +Warnings: +Note 1003 PARTITION BY LIST COLUMNS(`a`) +(PARTITION `p0` VALUES IN (NULL) ENGINE = MyISAM) +SELECT PARTITION_DESCRIPTION FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME='t1'; +PARTITION_DESCRIPTION +NULL +DROP TABLE t1; +CREATE OR REPLACE TABLE t1 (a DATE) CHARACTER SET utf8 +PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN (FROM_DAYS(100))); +Warnings: +Note 1003 PARTITION BY LIST COLUMNS(`a`) +(PARTITION `p0` VALUES IN (_utf8 0x303030302d30302d3030) ENGINE = MyISAM) +SELECT PARTITION_DESCRIPTION FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME='t1'; +PARTITION_DESCRIPTION +'0000-00-00' +DROP TABLE t1; +SET debug_dbug=@save_dbug; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/partition_utf8-debug.test b/mysql-test/main/partition_utf8-debug.test new file mode 100644 index 00000000000..c321c944676 --- /dev/null +++ b/mysql-test/main/partition_utf8-debug.test @@ -0,0 +1,71 @@ +--source include/have_partition.inc +--source include/have_debug_sync.inc + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-20856 Bad values in metadata views for partitions on VARBINARY +--echo # + +SET NAMES utf8; +SET @save_dbug = @@debug_dbug; +SET SESSION debug_dbug="+d,generate_partition_syntax_for_frm"; + + +--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +CREATE OR REPLACE TABLE t1 (a VARCHAR(10)) CHARACTER SET latin1 + PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN (_utf8'á¹ ')); + +--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +CREATE OR REPLACE TABLE t1 (a VARCHAR(10)) CHARACTER SET latin1 + PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN ('á¹ ')); + +CREATE OR REPLACE TABLE t1 (a VARCHAR(10)) CHARACTER SET latin1 + PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN (_latin1 0xDF)); +SELECT PARTITION_DESCRIPTION FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME='t1'; +DROP TABLE t1; + +CREATE OR REPLACE TABLE t1 (a VARCHAR(10)) CHARACTER SET latin1 + PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN (_utf8'ß')); +SELECT PARTITION_DESCRIPTION FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME='t1'; +DROP TABLE t1; + +CREATE OR REPLACE TABLE t1 (a VARCHAR(10)) CHARACTER SET latin1 + PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN ('ß')); +DROP TABLE t1; + +CREATE OR REPLACE TABLE t1 (a VARCHAR(10)) CHARACTER SET utf8 + PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN (_utf8'ß')); +SELECT PARTITION_DESCRIPTION FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME='t1'; +DROP TABLE t1; + +CREATE OR REPLACE TABLE t1 (a VARCHAR(10)) CHARACTER SET utf8 + PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN ('ß')); +SELECT PARTITION_DESCRIPTION FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME='t1'; +DROP TABLE t1; + + +CREATE OR REPLACE TABLE t1 (a VARBINARY(10)) CHARACTER SET utf8 + PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN (0xFF)); +SELECT PARTITION_DESCRIPTION FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME='t1'; +DROP TABLE t1; + + +CREATE OR REPLACE TABLE t1 (a DATE) CHARACTER SET utf8 + PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN (FROM_DAYS(NULL))); +SELECT PARTITION_DESCRIPTION FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME='t1'; +DROP TABLE t1; + +CREATE OR REPLACE TABLE t1 (a DATE) CHARACTER SET utf8 + PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN (FROM_DAYS(100))); +SELECT PARTITION_DESCRIPTION FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME='t1'; +DROP TABLE t1; + + +SET debug_dbug=@save_dbug; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/partition_utf8.result b/mysql-test/main/partition_utf8.result index 956ee790160..185d081b1c9 100644 --- a/mysql-test/main/partition_utf8.result +++ b/mysql-test/main/partition_utf8.result @@ -67,3 +67,25 @@ ERROR HY000: This partition function is not allowed # # End of 10.3 tests # +# +# Start of 10.5 tests +# +# +# MDEV-20856 Bad values in metadata views for partitions on VARBINARY +# +CREATE TABLE t1 (a VARBINARY(10)) CHARACTER SET utf8 +PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN (0xFF)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8 + PARTITION BY LIST COLUMNS(`a`) +(PARTITION `p0` VALUES IN (_binary 0xff) ENGINE = MyISAM) +SELECT PARTITION_DESCRIPTION FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME='t1'; +PARTITION_DESCRIPTION +_binary 0xff +DROP TABLE t1; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/partition_utf8.test b/mysql-test/main/partition_utf8.test index 65050429a52..9bfa352ab25 100644 --- a/mysql-test/main/partition_utf8.test +++ b/mysql-test/main/partition_utf8.test @@ -62,3 +62,22 @@ CREATE OR REPLACE TABLE t1 (a TIME) --echo # --echo # End of 10.3 tests --echo # + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-20856 Bad values in metadata views for partitions on VARBINARY +--echo # + +CREATE TABLE t1 (a VARBINARY(10)) CHARACTER SET utf8 + PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN (0xFF)); +SHOW CREATE TABLE t1; +SELECT PARTITION_DESCRIPTION FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME='t1'; +DROP TABLE t1; + + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/percona_nonflushing_analyze_debug.result b/mysql-test/main/percona_nonflushing_analyze_debug.result new file mode 100644 index 00000000000..78da085f26f --- /dev/null +++ b/mysql-test/main/percona_nonflushing_analyze_debug.result @@ -0,0 +1,28 @@ +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2), (3); +connect con1,localhost,root; +SET DEBUG_SYNC="handler_ha_index_next_end SIGNAL idx_scan_in_progress WAIT_FOR finish_scan"; +SELECT * FROM t1; +connection default; +SET DEBUG_SYNC="now WAIT_FOR idx_scan_in_progress"; +set @tmp=@@use_stat_tables; +set use_stat_tables='preferably_for_queries'; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +set use_stat_tables=@tmp; +SELECT * FROM t1; +a +1 +2 +3 +SET DEBUG_SYNC="now SIGNAL finish_scan"; +connection con1; +a +1 +2 +3 +disconnect con1; +connection default; +SET DEBUG_SYNC='reset'; +DROP TABLE t1; diff --git a/mysql-test/main/percona_nonflushing_analyze_debug.test b/mysql-test/main/percona_nonflushing_analyze_debug.test new file mode 100644 index 00000000000..4c9c2dcb768 --- /dev/null +++ b/mysql-test/main/percona_nonflushing_analyze_debug.test @@ -0,0 +1,12 @@ +--source include/have_debug_sync.inc +--source include/have_innodb.inc + +#set use_stat_tables='preferably_for_queries'; +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2), (3); + +--let $percona_nonflushing_analyze_table= t1 +--source include/percona_nonflushing_analyze_debug.inc + +DROP TABLE t1; + diff --git a/mysql-test/main/plugin_innodb.result b/mysql-test/main/plugin_innodb.result index c55bfd779c2..f1d9a28ec95 100644 --- a/mysql-test/main/plugin_innodb.result +++ b/mysql-test/main/plugin_innodb.result @@ -1,8 +1,8 @@ -install plugin example soname 'ha_example.so'; +install plugin example soname 'ha_example'; create table t1(a int) engine=example; drop table t1; alter table mysql.plugin engine=innodb; -restart + --example[=name] Enable or disable EXAMPLE plugin. One of: ON, OFF, FORCE # restart create table t1(a int) engine=example; select * from t1; diff --git a/mysql-test/main/plugin_innodb.test b/mysql-test/main/plugin_innodb.test index a9c7f04bd4a..d458299a900 100644 --- a/mysql-test/main/plugin_innodb.test +++ b/mysql-test/main/plugin_innodb.test @@ -2,14 +2,22 @@ --source include/have_example_plugin.inc --source include/have_static_innodb.inc ---replace_regex /\.dll/.so/ -eval install plugin example soname '$HA_EXAMPLE_SO'; +install plugin example soname 'ha_example'; create table t1(a int) engine=example; drop table t1; alter table mysql.plugin engine=innodb; ---echo restart ---source include/restart_mysqld.inc +--source include/shutdown_mysqld.inc + +--exec $MYSQLD_CMD --innodb --help --verbose > $MYSQL_TMP_DIR/plugin_innodb.txt 2> $MYSQL_TMP_DIR/plugin_innodb.err +perl; + open(F, '<', "$ENV{MYSQL_TMP_DIR}/plugin_innodb.txt") or die; + while (<F>) { + print if /EXAMPLE/; + } +EOF + +--source include/start_mysqld.inc create table t1(a int) engine=example; select * from t1; diff --git a/mysql-test/main/pool_of_threads.result b/mysql-test/main/pool_of_threads.result index 3f5ce1a37e5..d4a7d9092f4 100644 --- a/mysql-test/main/pool_of_threads.result +++ b/mysql-test/main/pool_of_threads.result @@ -509,7 +509,7 @@ insert into tmp select * from t3; insert into t3 select * from tmp; alter table t3 add t2nr int not null auto_increment primary key first; drop table tmp; -SET BIG_TABLES=1; +set tmp_memory_table_size=0; select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10; namn Abraham Abraham @@ -522,7 +522,7 @@ ammonium ammonium analyzable analyzable animals animals animized animized -SET BIG_TABLES=0; +set tmp_memory_table_size=default; select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10; concat(fld3," ",fld3) Abraham Abraham @@ -559,7 +559,7 @@ attendants 1 bedlam 1 bedpost 1 boasted 1 -SET BIG_TABLES=1; +set tmp_memory_table_size=0; select distinct fld3,count(*) from t2 group by companynr,fld3 limit 10; fld3 count(*) affixed 1 @@ -572,7 +572,7 @@ attendants 1 bedlam 1 bedpost 1 boasted 1 -SET BIG_TABLES=0; +set tmp_memory_table_size=default; select distinct fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr,fld3 limit 100,10; fld3 repeat("a",length(fld3)) count(*) circus aaaaaa 1 diff --git a/mysql-test/main/profiling.result b/mysql-test/main/profiling.result index 6590d89bc89..f1403c3ec2f 100644 --- a/mysql-test/main/profiling.result +++ b/mysql-test/main/profiling.result @@ -123,8 +123,7 @@ select query_id, count(*), sum(duration) from information_schema.profiling group select CPU_user, CPU_system, Context_voluntary, Context_involuntary, Block_ops_in, Block_ops_out, Messages_sent, Messages_received, Page_faults_major, Page_faults_minor, Swaps, Source_function, Source_file, Source_line from information_schema.profiling; drop table if exists t1, t2, t3; Warnings: -Note 1051 Unknown table 'test.t2' -Note 1051 Unknown table 'test.t3' +Note 1051 Unknown table 'test.t2,test.t3' create table t1 (id int ); create table t2 (id int not null); create table t3 (id int not null primary key); diff --git a/mysql-test/main/ps.result b/mysql-test/main/ps.result index 7ca8499ba76..1b77d713185 100644 --- a/mysql-test/main/ps.result +++ b/mysql-test/main/ps.result @@ -2856,12 +2856,10 @@ Level Code Message Note 1051 Unknown table 'test.t2' drop table if exists t1, t2; Warnings: -Note 1051 Unknown table 'test.t1' -Note 1051 Unknown table 'test.t2' +Note 1051 Unknown table 'test.t1,test.t2' call proc_1(); Level Code Message -Note 1051 Unknown table 'test.t1' -Note 1051 Unknown table 'test.t2' +Note 1051 Unknown table 'test.t1,test.t2' drop procedure proc_1; create function func_1() returns int begin show warnings; return 1; end| ERROR 0A000: Not allowed to return a result set from a function @@ -2880,12 +2878,10 @@ Level Code Message Note 1051 Unknown table 'test.t2' drop table if exists t1, t2; Warnings: -Note 1051 Unknown table 'test.t1' -Note 1051 Unknown table 'test.t2' +Note 1051 Unknown table 'test.t1,test.t2' execute abc; Level Code Message -Note 1051 Unknown table 'test.t1' -Note 1051 Unknown table 'test.t2' +Note 1051 Unknown table 'test.t1,test.t2' deallocate prepare abc; set @my_password="password"; set @my_data="clear text to encode"; diff --git a/mysql-test/main/ps_1general.result b/mysql-test/main/ps_1general.result index 2ef5571cdca..46812425ebc 100644 --- a/mysql-test/main/ps_1general.result +++ b/mysql-test/main/ps_1general.result @@ -462,15 +462,15 @@ Catalog Database Table Table_alias Column Column_alias Type Length Max length Is def id 8 3 1 Y 32928 0 63 def select_type 253 19 6 N 1 39 8 def table 253 64 2 Y 0 39 8 -def type 253 10 3 Y 0 39 8 +def type 253 10 5 Y 0 39 8 def possible_keys 253 4_OR_8_K 7 Y 0 39 8 -def key 253 64 0 Y 0 39 8 -def key_len 253 4_OR_8_K 0 Y 0 39 8 +def key 253 64 7 Y 0 39 8 +def key_len 253 4_OR_8_K 1 Y 0 39 8 def ref 253 2048 0 Y 0 39 8 def rows 253 64 1 Y 0 39 8 -def Extra 253 255 27 N 1 39 8 +def Extra 253 255 37 N 1 39 8 id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 4 Using where; Using filesort +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 Using index condition; Using filesort drop table if exists t2; create table t2 (id smallint, name varchar(20)) ; prepare stmt1 from ' insert into t2 values(?, ?) ' ; @@ -528,9 +528,11 @@ drop table if exists new_t2; prepare stmt3 from ' rename table t2 to new_t2 '; execute stmt3; execute stmt3; +ERROR 42S02: Table 'test.t2' doesn't exist +create table t2 like new_t2; +execute stmt3; ERROR 42S01: Table 'new_t2' already exists -rename table new_t2 to t2; -drop table t2; +drop table new_t2,t2; prepare stmt1 from ' rename table t5 to t6, t7 to t8 ' ; create table t5 (a int) ; execute stmt1 ; @@ -538,7 +540,7 @@ ERROR 42S02: Table 'test.t7' doesn't exist create table t7 (a int) ; execute stmt1 ; execute stmt1 ; -ERROR 42S01: Table 't6' already exists +ERROR 42S02: Table 'test.t5' doesn't exist rename table t6 to t5, t8 to t7 ; execute stmt1 ; drop table t6, t8 ; diff --git a/mysql-test/main/ps_1general.test b/mysql-test/main/ps_1general.test index 01a0164722d..47db79cb6c6 100644 --- a/mysql-test/main/ps_1general.test +++ b/mysql-test/main/ps_1general.test @@ -60,7 +60,7 @@ select * from t1 where a = @var ; # 3. DEALLOCATE PREPARE stmt_name; # -# Send the server the order to drop the parse informations. +# Send the server the order to drop the parse information. # The server will reply with "Query Ok" or an error message. DEALLOCATE PREPARE stmt ; @@ -576,10 +576,12 @@ drop table if exists new_t2; --enable_warnings prepare stmt3 from ' rename table t2 to new_t2 '; execute stmt3; +--error ER_NO_SUCH_TABLE +execute stmt3; +create table t2 like new_t2; --error ER_TABLE_EXISTS_ERROR execute stmt3; -rename table new_t2 to t2; -drop table t2; +drop table new_t2,t2; ## RENAME more than on TABLE within one statement # cases derived from client_test.c: test_rename() prepare stmt1 from ' rename table t5 to t6, t7 to t8 ' ; @@ -590,7 +592,7 @@ create table t7 (a int) ; # rename, t5 -> t6 and t7 -> t8 execute stmt1 ; # rename must fail, t5 and t7 does not exist t6 and t8 already exist ---error ER_TABLE_EXISTS_ERROR +--error ER_NO_SUCH_TABLE execute stmt1 ; rename table t6 to t5, t8 to t7 ; # rename, t5 -> t6 and t7 -> t8 diff --git a/mysql-test/main/ps_show_log.result b/mysql-test/main/ps_show_log.result index 54eabaeded6..63cd7789de4 100644 --- a/mysql-test/main/ps_show_log.result +++ b/mysql-test/main/ps_show_log.result @@ -54,10 +54,10 @@ DEALLOCATE PREPARE stmt_1; connect con2,localhost,u1,,test; PREPARE stmt_1 FROM 'SHOW BINLOG EVENTS'; EXECUTE stmt_1; -ERROR 42000: Access denied; you need (at least one of) the REPLICATION SLAVE privilege(s) for this operation +ERROR 42000: Access denied; you need (at least one of) the BINLOG MONITOR privilege(s) for this operation PREPARE stmt_1 FROM 'SHOW RELAYLOG EVENTS'; EXECUTE stmt_1; -ERROR 42000: Access denied; you need (at least one of) the REPLICATION SLAVE privilege(s) for this operation +ERROR 42000: Access denied; you need (at least one of) the SLAVE MONITOR privilege(s) for this operation DEALLOCATE PREPARE stmt_1; include/rpl_end.inc connection default; diff --git a/mysql-test/main/query_cache.result b/mysql-test/main/query_cache.result index fc7ca726c48..bff04de6520 100644 --- a/mysql-test/main/query_cache.result +++ b/mysql-test/main/query_cache.result @@ -2207,6 +2207,10 @@ Variable_name Value Qcache_queries_in_cache 0 DROP FUNCTION foo; drop table t1; +# +# MDEV-24858 SIGABRT in DbugExit from my_malloc in Query_cache::init_cache Regression +# +set global Query_cache_size=18446744073709547520; restore defaults SET GLOBAL query_cache_type= default; SET GLOBAL query_cache_size=@save_query_cache_size; diff --git a/mysql-test/main/query_cache.test b/mysql-test/main/query_cache.test index 6e113f0cdb7..4d769b46213 100644 --- a/mysql-test/main/query_cache.test +++ b/mysql-test/main/query_cache.test @@ -1800,6 +1800,13 @@ show status like "Qcache_queries_in_cache"; DROP FUNCTION foo; drop table t1; +--echo # +--echo # MDEV-24858 SIGABRT in DbugExit from my_malloc in Query_cache::init_cache Regression +--echo # +--disable_warnings +set global Query_cache_size=18446744073709547520; +--enable_warnings + --echo restore defaults SET GLOBAL query_cache_type= default; SET GLOBAL query_cache_size=@save_query_cache_size; diff --git a/mysql-test/main/range.result b/mysql-test/main/range.result index afd1571283f..d97cfb2b587 100644 --- a/mysql-test/main/range.result +++ b/mysql-test/main/range.result @@ -252,7 +252,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref x x 5 const 1 Using index explain select count(*) from t1 where x in (1,2,3,4); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index x x 5 NULL 9 Using where; Using index +1 SIMPLE t1 range x x 5 NULL 4 Using where; Using index drop table t1; CREATE TABLE t1 (key1 int(11) NOT NULL default '0', KEY i1 (key1)); INSERT INTO t1 VALUES (0),(0),(0),(0),(0),(1),(1); @@ -261,12 +261,12 @@ INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2); explain select * from t1, t2 where (t1.key1 <t2.keya + 1) and t2.keya=3; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ref j1 j1 4 const 1 Using index -1 SIMPLE t1 index i1 i1 4 NULL 7 Using where; Using index; Using join buffer (flat, BNL join) +1 SIMPLE t1 range i1 i1 4 NULL 7 Using where; Using index; Using join buffer (flat, BNL join) explain select * from t1 force index(i1), t2 force index(j1) where (t1.key1 <t2.keya + 1) and t2.keya=3; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ref j1 j1 4 const 1 Using index -1 SIMPLE t1 index i1 i1 4 NULL 7 Using where; Using index; Using join buffer (flat, BNL join) +1 SIMPLE t1 range i1 i1 4 NULL 7 Using where; Using index; Using join buffer (flat, BNL join) DROP TABLE t1,t2; CREATE TABLE t1 ( a int(11) default NULL, @@ -327,8 +327,8 @@ KEY recount( owner, line ) INSERT into t1 (owner,id,columnid,line) values (11,15,15,1),(11,13,13,5); SELECT id, columnid, tableid, content, showid, line, ordinal FROM t1 WHERE owner=11 AND ((columnid IN ( 15, 13, 14 ) AND line IN ( 1, 2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 31 )) OR (columnid IN ( 13, 14 ) AND line IN ( 15 ))) LIMIT 0 , 30; id columnid tableid content showid line ordinal -13 13 1 188 1 5 0 15 15 1 188 1 1 0 +13 13 1 188 1 5 0 drop table t1; create table t1 (id int(10) primary key); insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9); @@ -723,7 +723,7 @@ WHERE v.oxrootid ='d8c4177d09f8b11f5.52725521' AND s.oxleft > v.oxleft AND s.oxleft < v.oxright; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE v ref OXLEFT,OXRIGHT,OXROOTID OXROOTID 34 const 6 Using index condition +1 SIMPLE v ALL OXLEFT,OXRIGHT,OXROOTID NULL NULL NULL 12 Using where 1 SIMPLE s ALL OXLEFT NULL NULL NULL 12 Range checked for each record (index map: 0x4) SELECT s.oxid FROM t1 v, t1 s WHERE @@ -1047,10 +1047,10 @@ INSERT INTO `t1` VALUES ,(13,2),(14,2),(15,3),(16,3),(17,3),(18,3),(19,3); explain select * from t1 where a in (3,4) and b in (1,2,3); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL # Using where; Using index +1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index explain select * from v1 where a in (3,4) and b in (1,2,3); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL # Using where; Using index +1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index explain select * from t1 where a between 3 and 4 and b between 1 and 2; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index @@ -1427,7 +1427,7 @@ SELECT * FROM t3 WHERE a < 5 OR a < 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 index a a 10 NULL 23 Using where; Using index +1 SIMPLE t3 range a a 5 NULL 9 Using where; Using index DROP TABLE t1, t2, t3; # # Bug #47123: Endless 100% CPU loop with STRAIGHT_JOIN @@ -1981,7 +1981,7 @@ insert into t1 values (0,0,0), (2,2,0), (1,1,1), (2,2,1); explain select * from t1 force index (idx) where a >=1 and c <= 1 and a=b and b > 1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index idx idx 15 NULL 4 Using where; Using index +1 SIMPLE t1 range idx idx 5 NULL 2 Using where; Using index select * from t1 force index (idx) where a >=1 and c <= 1 and a=b and b > 1; a b c 2 2 0 @@ -2530,7 +2530,7 @@ insert into t2 values explain select * from t1,t2 where a = d and (a,e) in ((3,3),(7,7),(2,2)); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range idx1,idx2 idx1 5 NULL 3 Using index condition; Using where +1 SIMPLE t2 range|filter idx1,idx2 idx1|idx2 5|5 NULL 3 (60%) Using index condition; Using where; Using rowid filter 1 SIMPLE t1 ref idx idx 5 test.t2.d 8 explain format=json select * from t1,t2 where a = d and (a,e) in ((3,3),(7,7),(2,2)); @@ -2545,6 +2545,14 @@ EXPLAIN "key": "idx1", "key_length": "5", "used_key_parts": ["d"], + "rowid_filter": { + "range": { + "key": "idx2", + "used_key_parts": ["e"] + }, + "rows": 12, + "selectivity_pct": 60 + }, "rows": 3, "filtered": 60, "index_condition": "t2.d is not null", @@ -2623,10 +2631,10 @@ EXPLAIN "used_key_parts": ["e"] }, "rows": 15, - "selectivity_pct": 14.423 + "selectivity_pct": 14.42307692 }, "rows": 8, - "filtered": 14.423, + "filtered": 14.42307663, "index_condition": "t2.d is not null", "attached_condition": "(t2.d,t2.e) in (<cache>((3,3)),<cache>((7,7)),<cache>((8,8))) and octet_length(t2.f) = 1" }, @@ -2728,10 +2736,10 @@ EXPLAIN "used_key_parts": ["e"] }, "rows": 7, - "selectivity_pct": 6.7308 + "selectivity_pct": 6.730769231 }, "rows": 7, - "filtered": 6.7308, + "filtered": 6.730769157, "index_condition": "t2.d is not null", "attached_condition": "(t2.d,t2.e) in (<cache>((4,4)),<cache>((7,7)),<cache>((8,8))) and octet_length(t2.f) = 1" }, @@ -3287,14 +3295,325 @@ insert into t2 select A.a + B.a*10 + C.a*100 from ten A, ten B,ten C where A.a + # expected type=range, rows=1487 , reason=using index dives analyze SELECT * FROM t1 where a in (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198); id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE t1 index a a 5 NULL 2000 2000.00 74.35 59.95 Using where; Using index +1 SIMPLE t1 range a a 5 NULL 1487 1199.00 100.00 100.00 Using where; Using index insert into t2 values (200),(201); # expected type=range, rows=201 , reason=using index statistics analyze SELECT * FROM t1 where a in (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,200,201); id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE t1 index a a 5 NULL 2000 2000.00 10.05 60.05 Using where; Using index +1 SIMPLE t1 range a a 5 NULL 201 1201.00 100.00 100.00 Using where; Using index drop table t1,ten,t2; # End of 10.4 tests +# +# MDEV-15777: Use inferred IS NOT NULL predicates in the range optimizer +# +set @@optimizer_switch='not_null_range_scan=on'; +create table ten(a int); +insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table one_k(a int); +insert into one_k select A.a + B.a* 10 + C.a * 100 from ten A, ten B, ten C; +create table t1 ( +id int NOT NULL, +subset_id int DEFAULT NULL, +PRIMARY KEY (id), +KEY t1_subset_id (subset_id)); +create table t2 ( +id int, +col int NOT NULL, +key (id) +); +insert into t1 select a,a from one_k limit 5; +insert into t1 select a+5,NULL from one_k limit 995; +insert into t2 select a,a from one_k; +analyze table t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status Table is already up to date +# expected for t1: range access and rows = 4 (not 1000) +explain SELECT * FROM t1,t2 WHERE t1.subset_id=t2.id; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range t1_subset_id t1_subset_id 5 NULL 3 Using index condition +1 SIMPLE t2 ref id id 5 test.t1.subset_id 1 +SELECT * FROM t1,t2 WHERE t1.subset_id=t2.id; +id subset_id id col +0 0 0 0 +1 1 1 1 +2 2 2 2 +3 3 3 3 +4 4 4 4 +# with a subquery +# expected the same plan as above +explain SELECT * FROM t1 WHERE t1.subset_id IN (SELECT t2.id FROM t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 range t1_subset_id t1_subset_id 5 NULL 3 Using index condition +1 PRIMARY t2 ref id id 5 test.t1.subset_id 1 Using index; FirstMatch(t1) +SELECT * FROM t1 WHERE t1.subset_id IN (SELECT t2.id FROM t2); +id subset_id +0 0 +1 1 +2 2 +3 3 +4 4 +# non-mergable subquery +# expected for t1: range access and rows = 4 (not 1000) +explain SELECT * FROM t1 +WHERE t1.subset_id IN (SELECT max(t2.id) FROM t2 group by t2.col); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 range t1_subset_id t1_subset_id 5 NULL 3 Using index condition +1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 test.t1.subset_id 1 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 1000 Using temporary +SELECT * FROM t1 +WHERE t1.subset_id IN (SELECT max(t2.id) FROM t2 group by t2.col); +id subset_id +0 0 +1 1 +2 2 +3 3 +4 4 +create view v1 as SELECT t2.id FROM t2; +create view v2 as SELECT t2.id FROM t2 group by t2.col; +# with mergeable view +# expected for t1: range access and rows = 4 (not 1000) +explain SELECT * FROM t1, v1 where t1.subset_id=v1.id; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range t1_subset_id t1_subset_id 5 NULL 3 Using index condition +1 SIMPLE t2 ref id id 5 test.t1.subset_id 1 Using index +SELECT * FROM t1, v1 where t1.subset_id=v1.id; +id subset_id id +0 0 0 +1 1 1 +2 2 2 +3 3 3 +4 4 4 +# with non-mergeable view +# expected for t1: range access and rows = 4 (not 1000) +explain SELECT * FROM t1, v2 where t1.subset_id=v2.id; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 range t1_subset_id t1_subset_id 5 NULL 3 Using index condition +1 PRIMARY <derived2> ref key0 key0 5 test.t1.subset_id 10 +2 DERIVED t2 ALL NULL NULL NULL NULL 1000 Using temporary; Using filesort +SELECT * FROM t1, v2 where t1.subset_id=v2.id; +id subset_id id +0 0 0 +1 1 1 +2 2 2 +3 3 3 +4 4 4 +# expected for t2 and for t1: range access +explain SELECT * FROM t2 LEFT JOIN t1 ON t1.subset_id != 5 WHERE t2.id in (0,2,4); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range id id 5 NULL 3 Using index condition +1 SIMPLE t1 range t1_subset_id t1_subset_id 5 NULL 4 Using where; Using join buffer (flat, BNL join) +SELECT * FROM t2 LEFT JOIN t1 ON t1.subset_id != 5 WHERE t2.id in (0,2,4); +id col id subset_id +0 0 0 0 +2 2 0 0 +4 4 0 0 +0 0 1 1 +2 2 1 1 +4 4 1 1 +0 0 2 2 +2 2 2 2 +4 4 2 2 +0 0 3 3 +2 2 3 3 +4 4 3 3 +0 0 4 4 +2 2 4 4 +4 4 4 4 +# no range access expected for t1 +explain SELECT * FROM t1 LEFT JOIN t2 ON t1.subset_id=t2.id LIMIT 10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 +1 SIMPLE t2 ref id id 5 test.t1.subset_id 1 Using where +SELECT * FROM t1 LEFT JOIN t2 ON t1.subset_id=t2.id LIMIT 10; +id subset_id id col +0 0 0 0 +1 1 1 1 +2 2 2 2 +3 3 3 3 +4 4 4 4 +5 NULL NULL NULL +6 NULL NULL NULL +7 NULL NULL NULL +8 NULL NULL NULL +9 NULL NULL NULL +# expected for t1: range access +explain SELECT * FROM ten LEFT JOIN (t1,t2) ON ten.a=t2.col AND t1.subset_id=t2.id; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE ten ALL NULL NULL NULL NULL 10 +1 SIMPLE t1 range t1_subset_id t1_subset_id 5 NULL 3 Using where +1 SIMPLE t2 ref id id 5 test.t1.subset_id 1 Using where +SELECT * FROM ten LEFT JOIN (t1,t2) ON ten.a=t2.col AND t1.subset_id=t2.id; +a id subset_id id col +0 0 0 0 0 +1 1 1 1 1 +2 2 2 2 2 +3 3 3 3 3 +4 4 4 4 4 +5 NULL NULL NULL NULL +6 NULL NULL NULL NULL +7 NULL NULL NULL NULL +8 NULL NULL NULL NULL +9 NULL NULL NULL NULL +# no range access expected for t1 +explain SELECT * FROM t1 LEFT JOIN (t2,ten) ON ten.a=t2.col AND t1.subset_id=t2.id +LIMIT 10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 +1 SIMPLE t2 ref id id 5 test.t1.subset_id 1 Using where +1 SIMPLE ten ALL NULL NULL NULL NULL 10 Using where +SELECT * FROM t1 LEFT JOIN (t2,ten) ON ten.a=t2.col AND t1.subset_id=t2.id +LIMIT 10; +id subset_id id col a +0 0 0 0 0 +1 1 1 1 1 +2 2 2 2 2 +3 3 3 3 3 +4 4 4 4 4 +5 NULL NULL NULL NULL +6 NULL NULL NULL NULL +7 NULL NULL NULL NULL +8 NULL NULL NULL NULL +9 NULL NULL NULL NULL +drop index id on t2; +# expected for t1: range access +explain SELECT * FROM t1,t2 WHERE t1.subset_id=t2.id; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range t1_subset_id t1_subset_id 5 NULL 3 Using index condition +1 SIMPLE t2 ALL NULL NULL NULL NULL 1000 Using where; Using join buffer (flat, BNL join) +SELECT * FROM t1,t2 WHERE t1.subset_id=t2.id; +id subset_id id col +0 0 0 0 +1 1 1 1 +2 2 2 2 +3 3 3 3 +4 4 4 4 +# expected impossible where after reading const tables +explain SELECT * FROM t1,t2 WHERE t1.subset_id > t2.id AND t1.subset_id IS NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +SELECT * FROM t1,t2 WHERE t1.subset_id > t2.id AND t1.subset_id IS NULL; +id subset_id id col +# expected impossible where after reading const tables +explain SELECT * FROM t1,t2 WHERE t1.subset_id > t2.id AND t2.id IS NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +SELECT * FROM t1,t2 WHERE t1.subset_id > t2.id AND t2.id IS NULL; +id subset_id id col +drop index t1_subset_id on t1; +alter table t1 add column m int not null default 0; +alter table t1 add index idx(m,subset_id); +alter table t2 add index (id); +update t1 set m = id mod 2; +analyze table t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status Table is already up to date +# expected for t1: range access by idx (keylen=9) +explain SELECT * FROM t1,t2 WHERE t1.subset_id=t2.id and t1.m=0 ; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range idx idx 9 NULL 4 Using index condition +1 SIMPLE t2 ref id id 5 test.t1.subset_id 1 +SELECT * FROM t1,t2 WHERE t1.subset_id=t2.id and t1.m=0 ; +id subset_id m id col +0 0 0 0 0 +2 2 0 2 2 +4 4 0 4 4 +drop view v1,v2; +drop table t1,t2; +create table t1 ( +id int NOT NULL, +subset_id int DEFAULT NULL, +KEY key1(id, subset_id), +KEY t1_subset_id (subset_id) +); +create table t2 ( +id int NOT NULL, +col int NOT NULL, +key (id) +); +insert into t1 select 1,a from one_k limit 5; +insert into t1 select 1,NULL from one_k limit 495; +insert into t2 select a,a from one_k; +analyze table t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status Table is already up to date +# expected for t1 :range access by index key1 +# rows 4 instead of 500 +explain SELECT * FROM t1,t2 WHERE t1.id>=1 and t1.subset_id=t2.id; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range key1,t1_subset_id key1 9 NULL 3 Using where; Using index +1 SIMPLE t2 ref id id 4 test.t1.subset_id 1 +SELECT * FROM t1,t2 WHERE t1.id>=1 and t1.subset_id=t2.id; +id subset_id id col +1 0 0 0 +1 1 1 1 +1 2 2 2 +1 3 3 3 +1 4 4 4 +drop table t1,t2; +create table t1 (id int unsigned,col int, KEY key1(id)); +create table t2 (id int unsigned,col int DEFAULT NULL,key (id)); +insert into t1 select a,2 from one_k limit 50; +insert into t1 select NULL,2 from one_k limit 450; +insert into t2 select a,a from one_k; +insert into t2 select a,a from one_k; +analyze table t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status OK +# using key1 for range access on t1 and also using index for sorting, +# no filesort, rows should be 75 not 500 +explain SELECT * FROM t1,t2 WHERE t1.id=t2.id AND t1.col=2 ORDER BY t2.id LIMIT 10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range key1 key1 5 NULL 74 Using index condition; Using where +1 SIMPLE t2 ref id id 5 test.t1.id 2 +SELECT * FROM t1,t2 WHERE t1.id=t2.id AND t1.col=2 ORDER BY t2.id LIMIT 10; +id col id col +0 2 0 0 +0 2 0 0 +1 2 1 1 +1 2 1 1 +2 2 2 2 +2 2 2 2 +3 2 3 3 +3 2 3 3 +4 2 4 4 +4 2 4 4 +drop table t1,t2; +drop table ten,one_k; +set @@optimizer_switch= @save_optimizer_switch; +# +# MDEV-21683: ANDing of the range from inferred NOT NULL condition and +# the range from other conditions produces IMPOSSIBLE range +# +SET @save_optimizer_switch= @@optimizer_switch; +CREATE TABLE t1 (a INT, KEY(a)); +INSERT INTO t1 VALUES (8),(9); +CREATE TABLE t2 (pk INT, b INT, PRIMARY KEY(pk)); +INSERT INTO t2 VALUES (1,1),(2,2); +SET optimizer_switch = 'not_null_range_scan=on'; +EXPLAIN EXTENDED SELECT * FROM t1 LEFT JOIN t2 ON a = pk WHERE b >= 0 AND pk IS NULL; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +Warnings: +Note 1003 select NULL AS `a`,0 AS `pk`,NULL AS `b` from `test`.`t1` join `test`.`t2` where 0 +SELECT * FROM t1 LEFT JOIN t2 ON a = pk WHERE b >= 0 AND pk IS NULL; +a pk b +DROP TABLE t1, t2; +SET @@optimizer_switch= @save_optimizer_switch; +# +# End of 10.5 tests +# set global innodb_stats_persistent= @innodb_stats_persistent_save; set global innodb_stats_persistent_sample_pages= @innodb_stats_persistent_sample_pages_save; diff --git a/mysql-test/main/range.test b/mysql-test/main/range.test index de2a428c49a..6d43ad9090d 100644 --- a/mysql-test/main/range.test +++ b/mysql-test/main/range.test @@ -2268,6 +2268,210 @@ drop table t1,ten,t2; --echo # End of 10.4 tests +--echo # +--echo # MDEV-15777: Use inferred IS NOT NULL predicates in the range optimizer +--echo # + +set @@optimizer_switch='not_null_range_scan=on'; +create table ten(a int); +insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table one_k(a int); +insert into one_k select A.a + B.a* 10 + C.a * 100 from ten A, ten B, ten C; + +create table t1 ( + id int NOT NULL, + subset_id int DEFAULT NULL, + PRIMARY KEY (id), + KEY t1_subset_id (subset_id)); + +create table t2 ( + id int, + col int NOT NULL, + key (id) +); + +insert into t1 select a,a from one_k limit 5; +insert into t1 select a+5,NULL from one_k limit 995; +insert into t2 select a,a from one_k; + +analyze table t1,t2; + +let $q= +SELECT * FROM t1,t2 WHERE t1.subset_id=t2.id; +--echo # expected for t1: range access and rows = 4 (not 1000) +eval explain $q; +eval $q; + +let $q= +SELECT * FROM t1 WHERE t1.subset_id IN (SELECT t2.id FROM t2); +--echo # with a subquery +--echo # expected the same plan as above +eval explain $q; +eval $q; + +let $q= +SELECT * FROM t1 + WHERE t1.subset_id IN (SELECT max(t2.id) FROM t2 group by t2.col); +--echo # non-mergable subquery +--echo # expected for t1: range access and rows = 4 (not 1000) +eval explain $q; +eval $q; + +create view v1 as SELECT t2.id FROM t2; +create view v2 as SELECT t2.id FROM t2 group by t2.col; + +let $q= +SELECT * FROM t1, v1 where t1.subset_id=v1.id; +--echo # with mergeable view +--echo # expected for t1: range access and rows = 4 (not 1000) +eval explain $q; +eval $q; + +let $q= SELECT * FROM t1, v2 where t1.subset_id=v2.id; +--echo # with non-mergeable view +--echo # expected for t1: range access and rows = 4 (not 1000) +eval explain $q; +eval $q; + +let $q= +SELECT * FROM t2 LEFT JOIN t1 ON t1.subset_id != 5 WHERE t2.id in (0,2,4); +--echo # expected for t2 and for t1: range access +eval explain $q; +eval $q; + +let $q= +SELECT * FROM t1 LEFT JOIN t2 ON t1.subset_id=t2.id LIMIT 10; +--echo # no range access expected for t1 +eval explain $q; +eval $q; + +let $q= +SELECT * FROM ten LEFT JOIN (t1,t2) ON ten.a=t2.col AND t1.subset_id=t2.id; +--echo # expected for t1: range access +eval explain $q; +eval $q; + +let $q= +SELECT * FROM t1 LEFT JOIN (t2,ten) ON ten.a=t2.col AND t1.subset_id=t2.id +LIMIT 10; +--echo # no range access expected for t1 +eval explain $q; +eval $q; + +drop index id on t2; + +let $q= +SELECT * FROM t1,t2 WHERE t1.subset_id=t2.id; +--echo # expected for t1: range access +eval explain $q; +eval $q; + +let $q= +SELECT * FROM t1,t2 WHERE t1.subset_id > t2.id AND t1.subset_id IS NULL; +--echo # expected impossible where after reading const tables +eval explain $q; +eval $q; + +let $q= +SELECT * FROM t1,t2 WHERE t1.subset_id > t2.id AND t2.id IS NULL; +--echo # expected impossible where after reading const tables +eval explain $q; +eval $q; + +drop index t1_subset_id on t1; +alter table t1 add column m int not null default 0; +alter table t1 add index idx(m,subset_id); +alter table t2 add index (id); +update t1 set m = id mod 2; +analyze table t1,t2; + +let $q= +SELECT * FROM t1,t2 WHERE t1.subset_id=t2.id and t1.m=0 ; +--echo # expected for t1: range access by idx (keylen=9) +eval explain $q; +eval $q; + + +drop view v1,v2; +drop table t1,t2; + +create table t1 ( + id int NOT NULL, + subset_id int DEFAULT NULL, + KEY key1(id, subset_id), + KEY t1_subset_id (subset_id) +); + +create table t2 ( + id int NOT NULL, + col int NOT NULL, + key (id) +); + +insert into t1 select 1,a from one_k limit 5; +insert into t1 select 1,NULL from one_k limit 495; +insert into t2 select a,a from one_k; + +analyze table t1,t2; + +let $q= +SELECT * FROM t1,t2 WHERE t1.id>=1 and t1.subset_id=t2.id; +--echo # expected for t1 :range access by index key1 +--echo # rows 4 instead of 500 +eval explain $q; +eval $q; + +drop table t1,t2; + +create table t1 (id int unsigned,col int, KEY key1(id)); +create table t2 (id int unsigned,col int DEFAULT NULL,key (id)); +insert into t1 select a,2 from one_k limit 50; +insert into t1 select NULL,2 from one_k limit 450; +insert into t2 select a,a from one_k; +insert into t2 select a,a from one_k; + +analyze table t1,t2; + +let $q= +SELECT * FROM t1,t2 WHERE t1.id=t2.id AND t1.col=2 ORDER BY t2.id LIMIT 10; +--echo # using key1 for range access on t1 and also using index for sorting, +--echo # no filesort, rows should be 75 not 500 +eval explain $q; +eval $q; + +drop table t1,t2; + +drop table ten,one_k; +set @@optimizer_switch= @save_optimizer_switch; + +--echo # +--echo # MDEV-21683: ANDing of the range from inferred NOT NULL condition and +--echo # the range from other conditions produces IMPOSSIBLE range +--echo # + +SET @save_optimizer_switch= @@optimizer_switch; + +CREATE TABLE t1 (a INT, KEY(a)); +INSERT INTO t1 VALUES (8),(9); + +CREATE TABLE t2 (pk INT, b INT, PRIMARY KEY(pk)); +INSERT INTO t2 VALUES (1,1),(2,2); + +SET optimizer_switch = 'not_null_range_scan=on'; +let $q= +SELECT * FROM t1 LEFT JOIN t2 ON a = pk WHERE b >= 0 AND pk IS NULL; +eval EXPLAIN EXTENDED $q; +eval $q; + +DROP TABLE t1, t2; + +SET @@optimizer_switch= @save_optimizer_switch; + +--echo # +--echo # End of 10.5 tests +--echo # + set global innodb_stats_persistent= @innodb_stats_persistent_save; set global innodb_stats_persistent_sample_pages= - @innodb_stats_persistent_sample_pages_save; + @innodb_stats_persistent_sample_pages_save; diff --git a/mysql-test/main/range_innodb.result b/mysql-test/main/range_innodb.result index 66a1e6e6c87..be7e89b9fd2 100644 --- a/mysql-test/main/range_innodb.result +++ b/mysql-test/main/range_innodb.result @@ -58,8 +58,8 @@ explain select pk, a, b from t1,t2,t3 where b >= d and pk < c and b = '0'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 2 -1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) -1 SIMPLE t1 ALL PRIMARY,idx1,idx2 NULL NULL NULL 4 Using where; Using join buffer (incremental, BNL join) +1 SIMPLE t1 ref PRIMARY,idx1,idx2 idx1 5 const 3 Using index condition +1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) select pk, a, b from t1,t2,t3 where b >= d and pk < c and b = '0'; pk a b 1 6 0 @@ -123,7 +123,7 @@ KEY (a,b) INSERT INTO t1 VALUES (1,'a',1),(2,'b',2); explain SELECT a FROM t1 WHERE pk < 0 AND a <= 'w' and b > 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index PRIMARY,a a 9 NULL 2 Using where; Using index +1 SIMPLE t1 range PRIMARY,a PRIMARY 4 NULL 1 Using where SELECT a FROM t1 WHERE pk < 0 AND a <= 'w' and b > 0; a drop table t1; diff --git a/mysql-test/main/range_mrr_icp.result b/mysql-test/main/range_mrr_icp.result index 3fce8b0fc23..9fa7bd29851 100644 --- a/mysql-test/main/range_mrr_icp.result +++ b/mysql-test/main/range_mrr_icp.result @@ -255,7 +255,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref x x 5 const 1 Using index explain select count(*) from t1 where x in (1,2,3,4); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index x x 5 NULL 9 Using where; Using index +1 SIMPLE t1 range x x 5 NULL 4 Using where; Using index drop table t1; CREATE TABLE t1 (key1 int(11) NOT NULL default '0', KEY i1 (key1)); INSERT INTO t1 VALUES (0),(0),(0),(0),(0),(1),(1); @@ -264,12 +264,12 @@ INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2); explain select * from t1, t2 where (t1.key1 <t2.keya + 1) and t2.keya=3; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ref j1 j1 4 const 1 Using index -1 SIMPLE t1 index i1 i1 4 NULL 7 Using where; Using index; Using join buffer (flat, BNL join) +1 SIMPLE t1 range i1 i1 4 NULL 7 Using where; Using index; Using join buffer (flat, BNL join) explain select * from t1 force index(i1), t2 force index(j1) where (t1.key1 <t2.keya + 1) and t2.keya=3; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ref j1 j1 4 const 1 Using index -1 SIMPLE t1 index i1 i1 4 NULL 7 Using where; Using index; Using join buffer (flat, BNL join) +1 SIMPLE t1 range i1 i1 4 NULL 7 Using where; Using index; Using join buffer (flat, BNL join) DROP TABLE t1,t2; CREATE TABLE t1 ( a int(11) default NULL, @@ -330,8 +330,8 @@ KEY recount( owner, line ) INSERT into t1 (owner,id,columnid,line) values (11,15,15,1),(11,13,13,5); SELECT id, columnid, tableid, content, showid, line, ordinal FROM t1 WHERE owner=11 AND ((columnid IN ( 15, 13, 14 ) AND line IN ( 1, 2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 31 )) OR (columnid IN ( 13, 14 ) AND line IN ( 15 ))) LIMIT 0 , 30; id columnid tableid content showid line ordinal -13 13 1 188 1 5 0 15 15 1 188 1 1 0 +13 13 1 188 1 5 0 drop table t1; create table t1 (id int(10) primary key); insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9); @@ -726,7 +726,7 @@ WHERE v.oxrootid ='d8c4177d09f8b11f5.52725521' AND s.oxleft > v.oxleft AND s.oxleft < v.oxright; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE v ref OXLEFT,OXRIGHT,OXROOTID OXROOTID 34 const 6 Using index condition +1 SIMPLE v ALL OXLEFT,OXRIGHT,OXROOTID NULL NULL NULL 12 Using where 1 SIMPLE s ALL OXLEFT NULL NULL NULL 12 Range checked for each record (index map: 0x4) SELECT s.oxid FROM t1 v, t1 s WHERE @@ -1050,10 +1050,10 @@ INSERT INTO `t1` VALUES ,(13,2),(14,2),(15,3),(16,3),(17,3),(18,3),(19,3); explain select * from t1 where a in (3,4) and b in (1,2,3); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL # Using where; Using index +1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index explain select * from v1 where a in (3,4) and b in (1,2,3); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL # Using where; Using index +1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index explain select * from t1 where a between 3 and 4 and b between 1 and 2; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index @@ -1430,7 +1430,7 @@ SELECT * FROM t3 WHERE a < 5 OR a < 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 index a a 10 NULL 23 Using where; Using index +1 SIMPLE t3 range a a 5 NULL 9 Using where; Using index DROP TABLE t1, t2, t3; # # Bug #47123: Endless 100% CPU loop with STRAIGHT_JOIN @@ -1984,7 +1984,7 @@ insert into t1 values (0,0,0), (2,2,0), (1,1,1), (2,2,1); explain select * from t1 force index (idx) where a >=1 and c <= 1 and a=b and b > 1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index idx idx 15 NULL 4 Using where; Using index +1 SIMPLE t1 range idx idx 5 NULL 2 Using where; Using index select * from t1 force index (idx) where a >=1 and c <= 1 and a=b and b > 1; a b c 2 2 0 @@ -2625,7 +2625,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["d"], "rows": 8, - "filtered": 14.423, + "filtered": 14.42307663, "index_condition": "t2.d is not null", "attached_condition": "(t2.d,t2.e) in (<cache>((3,3)),<cache>((7,7)),<cache>((8,8))) and octet_length(t2.f) = 1", "mrr_type": "Rowid-ordered scan" @@ -2723,7 +2723,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["d"], "rows": 7, - "filtered": 6.7308, + "filtered": 6.730769157, "index_condition": "t2.d is not null", "attached_condition": "(t2.d,t2.e) in (<cache>((4,4)),<cache>((7,7)),<cache>((8,8))) and octet_length(t2.f) = 1", "mrr_type": "Rowid-ordered scan" @@ -3284,14 +3284,325 @@ insert into t2 select A.a + B.a*10 + C.a*100 from ten A, ten B,ten C where A.a + # expected type=range, rows=1487 , reason=using index dives analyze SELECT * FROM t1 where a in (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198); id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE t1 index a a 5 NULL 2000 2000.00 74.35 59.95 Using where; Using index +1 SIMPLE t1 range a a 5 NULL 1487 1199.00 100.00 100.00 Using where; Using index insert into t2 values (200),(201); # expected type=range, rows=201 , reason=using index statistics analyze SELECT * FROM t1 where a in (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,200,201); id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE t1 index a a 5 NULL 2000 2000.00 10.05 60.05 Using where; Using index +1 SIMPLE t1 range a a 5 NULL 201 1201.00 100.00 100.00 Using where; Using index drop table t1,ten,t2; # End of 10.4 tests +# +# MDEV-15777: Use inferred IS NOT NULL predicates in the range optimizer +# +set @@optimizer_switch='not_null_range_scan=on'; +create table ten(a int); +insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table one_k(a int); +insert into one_k select A.a + B.a* 10 + C.a * 100 from ten A, ten B, ten C; +create table t1 ( +id int NOT NULL, +subset_id int DEFAULT NULL, +PRIMARY KEY (id), +KEY t1_subset_id (subset_id)); +create table t2 ( +id int, +col int NOT NULL, +key (id) +); +insert into t1 select a,a from one_k limit 5; +insert into t1 select a+5,NULL from one_k limit 995; +insert into t2 select a,a from one_k; +analyze table t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status Table is already up to date +# expected for t1: range access and rows = 4 (not 1000) +explain SELECT * FROM t1,t2 WHERE t1.subset_id=t2.id; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range t1_subset_id t1_subset_id 5 NULL 3 Using index condition; Rowid-ordered scan +1 SIMPLE t2 ref id id 5 test.t1.subset_id 1 +SELECT * FROM t1,t2 WHERE t1.subset_id=t2.id; +id subset_id id col +0 0 0 0 +1 1 1 1 +2 2 2 2 +3 3 3 3 +4 4 4 4 +# with a subquery +# expected the same plan as above +explain SELECT * FROM t1 WHERE t1.subset_id IN (SELECT t2.id FROM t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 range t1_subset_id t1_subset_id 5 NULL 3 Using index condition; Rowid-ordered scan +1 PRIMARY t2 ref id id 5 test.t1.subset_id 1 Using index; FirstMatch(t1) +SELECT * FROM t1 WHERE t1.subset_id IN (SELECT t2.id FROM t2); +id subset_id +0 0 +1 1 +2 2 +3 3 +4 4 +# non-mergable subquery +# expected for t1: range access and rows = 4 (not 1000) +explain SELECT * FROM t1 +WHERE t1.subset_id IN (SELECT max(t2.id) FROM t2 group by t2.col); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 range t1_subset_id t1_subset_id 5 NULL 3 Using index condition; Rowid-ordered scan +1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 test.t1.subset_id 1 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 1000 Using temporary +SELECT * FROM t1 +WHERE t1.subset_id IN (SELECT max(t2.id) FROM t2 group by t2.col); +id subset_id +0 0 +1 1 +2 2 +3 3 +4 4 +create view v1 as SELECT t2.id FROM t2; +create view v2 as SELECT t2.id FROM t2 group by t2.col; +# with mergeable view +# expected for t1: range access and rows = 4 (not 1000) +explain SELECT * FROM t1, v1 where t1.subset_id=v1.id; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range t1_subset_id t1_subset_id 5 NULL 3 Using index condition; Rowid-ordered scan +1 SIMPLE t2 ref id id 5 test.t1.subset_id 1 Using index +SELECT * FROM t1, v1 where t1.subset_id=v1.id; +id subset_id id +0 0 0 +1 1 1 +2 2 2 +3 3 3 +4 4 4 +# with non-mergeable view +# expected for t1: range access and rows = 4 (not 1000) +explain SELECT * FROM t1, v2 where t1.subset_id=v2.id; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 range t1_subset_id t1_subset_id 5 NULL 3 Using index condition; Rowid-ordered scan +1 PRIMARY <derived2> ref key0 key0 5 test.t1.subset_id 10 +2 DERIVED t2 ALL NULL NULL NULL NULL 1000 Using temporary; Using filesort +SELECT * FROM t1, v2 where t1.subset_id=v2.id; +id subset_id id +0 0 0 +1 1 1 +2 2 2 +3 3 3 +4 4 4 +# expected for t2 and for t1: range access +explain SELECT * FROM t2 LEFT JOIN t1 ON t1.subset_id != 5 WHERE t2.id in (0,2,4); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range id id 5 NULL 3 Using index condition; Rowid-ordered scan +1 SIMPLE t1 range t1_subset_id t1_subset_id 5 NULL 4 Using where; Rowid-ordered scan; Using join buffer (flat, BNL join) +SELECT * FROM t2 LEFT JOIN t1 ON t1.subset_id != 5 WHERE t2.id in (0,2,4); +id col id subset_id +0 0 0 0 +2 2 0 0 +4 4 0 0 +0 0 1 1 +2 2 1 1 +4 4 1 1 +0 0 2 2 +2 2 2 2 +4 4 2 2 +0 0 3 3 +2 2 3 3 +4 4 3 3 +0 0 4 4 +2 2 4 4 +4 4 4 4 +# no range access expected for t1 +explain SELECT * FROM t1 LEFT JOIN t2 ON t1.subset_id=t2.id LIMIT 10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 +1 SIMPLE t2 ref id id 5 test.t1.subset_id 1 Using where +SELECT * FROM t1 LEFT JOIN t2 ON t1.subset_id=t2.id LIMIT 10; +id subset_id id col +0 0 0 0 +1 1 1 1 +2 2 2 2 +3 3 3 3 +4 4 4 4 +5 NULL NULL NULL +6 NULL NULL NULL +7 NULL NULL NULL +8 NULL NULL NULL +9 NULL NULL NULL +# expected for t1: range access +explain SELECT * FROM ten LEFT JOIN (t1,t2) ON ten.a=t2.col AND t1.subset_id=t2.id; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE ten ALL NULL NULL NULL NULL 10 +1 SIMPLE t1 range t1_subset_id t1_subset_id 5 NULL 3 Using where; Rowid-ordered scan +1 SIMPLE t2 ref id id 5 test.t1.subset_id 1 Using where +SELECT * FROM ten LEFT JOIN (t1,t2) ON ten.a=t2.col AND t1.subset_id=t2.id; +a id subset_id id col +0 0 0 0 0 +1 1 1 1 1 +2 2 2 2 2 +3 3 3 3 3 +4 4 4 4 4 +5 NULL NULL NULL NULL +6 NULL NULL NULL NULL +7 NULL NULL NULL NULL +8 NULL NULL NULL NULL +9 NULL NULL NULL NULL +# no range access expected for t1 +explain SELECT * FROM t1 LEFT JOIN (t2,ten) ON ten.a=t2.col AND t1.subset_id=t2.id +LIMIT 10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 +1 SIMPLE t2 ref id id 5 test.t1.subset_id 1 Using where +1 SIMPLE ten ALL NULL NULL NULL NULL 10 Using where +SELECT * FROM t1 LEFT JOIN (t2,ten) ON ten.a=t2.col AND t1.subset_id=t2.id +LIMIT 10; +id subset_id id col a +0 0 0 0 0 +1 1 1 1 1 +2 2 2 2 2 +3 3 3 3 3 +4 4 4 4 4 +5 NULL NULL NULL NULL +6 NULL NULL NULL NULL +7 NULL NULL NULL NULL +8 NULL NULL NULL NULL +9 NULL NULL NULL NULL +drop index id on t2; +# expected for t1: range access +explain SELECT * FROM t1,t2 WHERE t1.subset_id=t2.id; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range t1_subset_id t1_subset_id 5 NULL 3 Using index condition; Rowid-ordered scan +1 SIMPLE t2 ALL NULL NULL NULL NULL 1000 Using where; Using join buffer (flat, BNL join) +SELECT * FROM t1,t2 WHERE t1.subset_id=t2.id; +id subset_id id col +0 0 0 0 +1 1 1 1 +2 2 2 2 +3 3 3 3 +4 4 4 4 +# expected impossible where after reading const tables +explain SELECT * FROM t1,t2 WHERE t1.subset_id > t2.id AND t1.subset_id IS NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +SELECT * FROM t1,t2 WHERE t1.subset_id > t2.id AND t1.subset_id IS NULL; +id subset_id id col +# expected impossible where after reading const tables +explain SELECT * FROM t1,t2 WHERE t1.subset_id > t2.id AND t2.id IS NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +SELECT * FROM t1,t2 WHERE t1.subset_id > t2.id AND t2.id IS NULL; +id subset_id id col +drop index t1_subset_id on t1; +alter table t1 add column m int not null default 0; +alter table t1 add index idx(m,subset_id); +alter table t2 add index (id); +update t1 set m = id mod 2; +analyze table t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status Table is already up to date +# expected for t1: range access by idx (keylen=9) +explain SELECT * FROM t1,t2 WHERE t1.subset_id=t2.id and t1.m=0 ; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range idx idx 9 NULL 4 Using index condition; Rowid-ordered scan +1 SIMPLE t2 ref id id 5 test.t1.subset_id 1 +SELECT * FROM t1,t2 WHERE t1.subset_id=t2.id and t1.m=0 ; +id subset_id m id col +0 0 0 0 0 +2 2 0 2 2 +4 4 0 4 4 +drop view v1,v2; +drop table t1,t2; +create table t1 ( +id int NOT NULL, +subset_id int DEFAULT NULL, +KEY key1(id, subset_id), +KEY t1_subset_id (subset_id) +); +create table t2 ( +id int NOT NULL, +col int NOT NULL, +key (id) +); +insert into t1 select 1,a from one_k limit 5; +insert into t1 select 1,NULL from one_k limit 495; +insert into t2 select a,a from one_k; +analyze table t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status Table is already up to date +# expected for t1 :range access by index key1 +# rows 4 instead of 500 +explain SELECT * FROM t1,t2 WHERE t1.id>=1 and t1.subset_id=t2.id; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range key1,t1_subset_id key1 9 NULL 3 Using where; Using index +1 SIMPLE t2 ref id id 4 test.t1.subset_id 1 +SELECT * FROM t1,t2 WHERE t1.id>=1 and t1.subset_id=t2.id; +id subset_id id col +1 0 0 0 +1 1 1 1 +1 2 2 2 +1 3 3 3 +1 4 4 4 +drop table t1,t2; +create table t1 (id int unsigned,col int, KEY key1(id)); +create table t2 (id int unsigned,col int DEFAULT NULL,key (id)); +insert into t1 select a,2 from one_k limit 50; +insert into t1 select NULL,2 from one_k limit 450; +insert into t2 select a,a from one_k; +insert into t2 select a,a from one_k; +analyze table t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status OK +# using key1 for range access on t1 and also using index for sorting, +# no filesort, rows should be 75 not 500 +explain SELECT * FROM t1,t2 WHERE t1.id=t2.id AND t1.col=2 ORDER BY t2.id LIMIT 10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range key1 key1 5 NULL 74 Using index condition; Using where +1 SIMPLE t2 ref id id 5 test.t1.id 2 +SELECT * FROM t1,t2 WHERE t1.id=t2.id AND t1.col=2 ORDER BY t2.id LIMIT 10; +id col id col +0 2 0 0 +0 2 0 0 +1 2 1 1 +1 2 1 1 +2 2 2 2 +2 2 2 2 +3 2 3 3 +3 2 3 3 +4 2 4 4 +4 2 4 4 +drop table t1,t2; +drop table ten,one_k; +set @@optimizer_switch= @save_optimizer_switch; +# +# MDEV-21683: ANDing of the range from inferred NOT NULL condition and +# the range from other conditions produces IMPOSSIBLE range +# +SET @save_optimizer_switch= @@optimizer_switch; +CREATE TABLE t1 (a INT, KEY(a)); +INSERT INTO t1 VALUES (8),(9); +CREATE TABLE t2 (pk INT, b INT, PRIMARY KEY(pk)); +INSERT INTO t2 VALUES (1,1),(2,2); +SET optimizer_switch = 'not_null_range_scan=on'; +EXPLAIN EXTENDED SELECT * FROM t1 LEFT JOIN t2 ON a = pk WHERE b >= 0 AND pk IS NULL; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +Warnings: +Note 1003 select NULL AS `a`,0 AS `pk`,NULL AS `b` from `test`.`t1` join `test`.`t2` where 0 +SELECT * FROM t1 LEFT JOIN t2 ON a = pk WHERE b >= 0 AND pk IS NULL; +a pk b +DROP TABLE t1, t2; +SET @@optimizer_switch= @save_optimizer_switch; +# +# End of 10.5 tests +# set global innodb_stats_persistent= @innodb_stats_persistent_save; set global innodb_stats_persistent_sample_pages= @innodb_stats_persistent_sample_pages_save; diff --git a/mysql-test/main/range_notembedded.result b/mysql-test/main/range_notembedded.result index 7084e0ca7a0..eeab230e72f 100644 --- a/mysql-test/main/range_notembedded.result +++ b/mysql-test/main/range_notembedded.result @@ -13,7 +13,7 @@ set @tmp_21958=@@optimizer_trace; set optimizer_trace=1; explain select * from t2 where key1 in (1,2,3) and pk not in (1,2,3); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ALL PRIMARY,key1 NULL NULL NULL 5 Using where +1 SIMPLE t2 range PRIMARY,key1 key1 5 NULL 3 Using index condition # This should show only ranges in form "(1) <= (key1) <= (1)" # ranges over "pk" should not be constructed. select json_detailed(JSON_EXTRACT(trace, '$**.ranges')) @@ -25,7 +25,226 @@ json_detailed(JSON_EXTRACT(trace, '$**.ranges')) "(1) <= (key1) <= (1)", "(2) <= (key1) <= (2)", "(3) <= (key1) <= (3)" + ], + + [ + "(1) <= (key1) <= (1)", + "(2) <= (key1) <= (2)", + "(3) <= (key1) <= (3)" ] ] set optimizer_trace=@tmp_21958; drop table t2; +# +# MDEV-9750: Quick memory exhaustion with 'extended_keys=on'... +# +create table t1 ( +kp1 int, +kp2 int, +kp3 int, +kp4 int, +key key1(kp1, kp2, kp3,kp4) +); +insert into t1 values (1,1,1,1),(2,2,2,2),(3,3,3,3); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +show variables like 'optimizer_max_sel_arg_weight'; +Variable_name Value +optimizer_max_sel_arg_weight 32000 +set @tmp_9750=@@optimizer_trace; +set optimizer_trace=1; +explain select * from t1 where +kp1 in (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20) and +kp2 in (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20) and +kp3 in (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20) and +kp4 in (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20) +; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index key1 key1 20 NULL 3 Using where; Using index +set @json= (select json_detailed(JSON_EXTRACT(trace, '$**.range_scan_alternatives')) +from information_schema.optimizer_trace); +# This will show 3-component ranges. +# The ranges were produced, but the optimizer has cut away kp4 +# to keep the number of ranges at manageable level: +select left(@json, 500); +left(@json, 500) +[ + + [ + + { + "index": "key1", + "ranges": + [ + "(1,1,1) <= (kp1,kp2,kp3) <= (1,1,1)", + "(1,1,2) <= (kp1,kp2,kp3) <= (1,1,2)", + "(1,1,3) <= (kp1,kp2,kp3) <= (1,1,3)", + "(1,1,4) <= (kp1,kp2,kp3) <= (1,1,4)", + "(1,1,5) <= (kp1,kp2,kp3) <= (1,1,5)", + "(1,1,6) <= (kp1,kp2,kp3) <= (1,1,6)", + "(1,1,7) <= (kp1,kp2,kp3) <= (1,1,7)", + " +## Repeat the above with low max_weight: +set @tmp9750_weight=@@optimizer_max_sel_arg_weight; +set optimizer_max_sel_arg_weight=20; +explain select * from t1 where +kp1 in (1,2,3,4,5,6,7,8,9,10) and +kp2 in (1,2,3,4,5,6,7,8,9,10) and +kp3 in (1,2,3,4,5,6,7,8,9,10) and +kp4 in (1,2,3,4,5,6,7,8,9,10) +; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index key1 key1 20 NULL 3 Using where; Using index +set @trace= (select trace from information_schema.optimizer_trace); +set @json= json_detailed(json_extract(@trace, '$**.range_scan_alternatives')); +select left(@json, 500); +left(@json, 500) +[ + + [ + + { + "index": "key1", + "ranges": + [ + "(1) <= (kp1) <= (1)", + "(2) <= (kp1) <= (2)", + "(3) <= (kp1) <= (3)", + "(4) <= (kp1) <= (4)", + "(5) <= (kp1) <= (5)", + "(6) <= (kp1) <= (6)", + "(7) <= (kp1) <= (7)", + "(8) <= (kp1) <= (8)", + "(9) <= (kp1) <= (9)", + "(10) <= (kp1) <= (10)" + +set @json= json_detailed(json_extract(@trace, '$**.setup_range_conditions')); +select left(@json, 2500); +left(@json, 2500) +[ + + [ + + { + "sel_arg_weight_heuristic": + { + "key1_field": "kp1", + "key2_field": "kp2", + "key1_weight": 10, + "key2_weight": 10 + } + }, + + { + "sel_arg_weight_heuristic": + { + "key1_field": "kp1", + "key2_field": "kp3", + "key1_weight": 10, + "key2_weight": 10 + } + }, + + { + "sel_arg_weight_heuristic": + { + "key1_field": "kp1", + "key2_field": "kp4", + "key1_weight": 10, + "key2_weight": 10 + } + } + ] +] +## Repeat the above with a bit higher max_weight: +set optimizer_max_sel_arg_weight=120; +explain select * from t1 where +kp1 in (1,2,3,4,5,6,7,8,9,10) and +kp2 in (1,2,3,4,5,6,7,8,9,10) and +kp3 in (1,2,3,4,5,6,7,8,9,10) and +kp4 in (1,2,3,4,5,6,7,8,9,10) +; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index key1 key1 20 NULL 3 Using where; Using index +set @json= (select json_detailed(JSON_EXTRACT(trace, '$**.range_scan_alternatives')) +from information_schema.optimizer_trace); +select left(@json, 1500); +left(@json, 1500) +[ + + [ + + { + "index": "key1", + "ranges": + [ + "(1,1) <= (kp1,kp2) <= (1,1)", + "(1,2) <= (kp1,kp2) <= (1,2)", + "(1,3) <= (kp1,kp2) <= (1,3)", + "(1,4) <= (kp1,kp2) <= (1,4)", + "(1,5) <= (kp1,kp2) <= (1,5)", + "(1,6) <= (kp1,kp2) <= (1,6)", + "(1,7) <= (kp1,kp2) <= (1,7)", + "(1,8) <= (kp1,kp2) <= (1,8)", + "(1,9) <= (kp1,kp2) <= (1,9)", + "(1,10) <= (kp1,kp2) <= (1,10)", + "(2,1) <= (kp1,kp2) <= (2,1)", + "(2,2) <= (kp1,kp2) <= (2,2)", + "(2,3) <= (kp1,kp2) <= (2,3)", + "(2,4) <= (kp1,kp2) <= (2,4)", + "(2,5) <= (kp1,kp2) <= (2,5)", + "(2,6) <= (kp1,kp2) <= (2,6)", + "(2,7) <= (kp1,kp2) <= (2,7)", + "(2,8) <= (kp1,kp2) <= (2,8)", + "(2,9) <= (kp1,kp2) <= (2,9)", + "(2,10) <= (kp1,kp2) <= (2,10)", + "(3,1) <= (kp1,kp2) <= (3,1)", + "(3,2) <= (kp1,kp2) <= (3,2)", + "(3,3) <= (kp1,kp2) <= (3,3)", + "(3,4) <= (kp1,kp2) <= (3,4)", + "(3,5) <= (kp1,kp2) <= (3,5)", + "(3,6) <= (kp1,kp2) <= (3,6)", + "(3,7) <= (kp1,kp2) <= (3,7)", + "(3,8) <= (kp1,kp2) <= (3,8)", + "(3,9) <= (kp1,kp2) <= (3,9)", + "(3,10) <= (kp1,kp2 +set optimizer_max_sel_arg_weight= @tmp9750_weight; +set optimizer_trace=@tmp_9750; +drop table t1; +# +# MDEV-24739: Assertion `root->weight >= ...' failed in SEL_ARG::tree_delete +# +SELECT * +FROM mysql.help_relation +WHERE NOT (help_topic_id != 8 AND help_keyword_id != 0 OR help_keyword_id = 2 OR help_topic_id < 1900); +help_topic_id help_keyword_id +SELECT * +FROM mysql.help_relation ignore index (help_topic_id) +WHERE (help_topic_id = 8 OR help_keyword_id = 0) AND help_keyword_id != 2 AND help_topic_id >= 1900; +help_topic_id help_keyword_id +# +# MDEV-24953: 10.5.9 crashes with large IN() list +# +CREATE TABLE t1 ( +notification_type_id smallint(4) unsigned NOT NULL DEFAULT 0, +item_id int(10) unsigned NOT NULL DEFAULT 0, +item_parent_id int(10) unsigned NOT NULL DEFAULT 0, +user_id int(10) unsigned NOT NULL DEFAULT 0, +PRIMARY KEY (notification_type_id,item_id,item_parent_id,user_id) +); +insert into t1 values (1,1,1,1), (2,2,2,2), (3,3,3,3); +# Run crashing query +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 2 NULL 3 Using where +drop table t1; +# +# MDEV-25069: Assertion `root->weight >= ...' failed in SEL_ARG::tree_delete #2 +# +SELECT * +FROM mysql.help_relation +WHERE +(help_topic_id < '2' OR help_topic_id != 8 OR help_topic_id < 1) AND +help_keyword_id = help_topic_id; +help_topic_id help_keyword_id diff --git a/mysql-test/main/range_notembedded.test b/mysql-test/main/range_notembedded.test index 4dc49429ff1..4e77d6a4810 100644 --- a/mysql-test/main/range_notembedded.test +++ b/mysql-test/main/range_notembedded.test @@ -31,3 +31,122 @@ from information_schema.optimizer_trace; set optimizer_trace=@tmp_21958; drop table t2; +--echo # +--echo # MDEV-9750: Quick memory exhaustion with 'extended_keys=on'... +--echo # + +create table t1 ( + kp1 int, + kp2 int, + kp3 int, + kp4 int, + key key1(kp1, kp2, kp3,kp4) +); + +insert into t1 values (1,1,1,1),(2,2,2,2),(3,3,3,3); +analyze table t1; + +show variables like 'optimizer_max_sel_arg_weight'; + +# 20 * 20 * 20 *20 = 400*400 = 160,000 ranges +set @tmp_9750=@@optimizer_trace; +set optimizer_trace=1; +explain select * from t1 where + kp1 in (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20) and + kp2 in (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20) and + kp3 in (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20) and + kp4 in (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20) +; + +set @json= (select json_detailed(JSON_EXTRACT(trace, '$**.range_scan_alternatives')) + from information_schema.optimizer_trace); +--echo # This will show 3-component ranges. +--echo # The ranges were produced, but the optimizer has cut away kp4 +--echo # to keep the number of ranges at manageable level: +select left(@json, 500); + +--echo ## Repeat the above with low max_weight: +set @tmp9750_weight=@@optimizer_max_sel_arg_weight; +set optimizer_max_sel_arg_weight=20; +explain select * from t1 where + kp1 in (1,2,3,4,5,6,7,8,9,10) and + kp2 in (1,2,3,4,5,6,7,8,9,10) and + kp3 in (1,2,3,4,5,6,7,8,9,10) and + kp4 in (1,2,3,4,5,6,7,8,9,10) +; +set @trace= (select trace from information_schema.optimizer_trace); +set @json= json_detailed(json_extract(@trace, '$**.range_scan_alternatives')); +select left(@json, 500); + +set @json= json_detailed(json_extract(@trace, '$**.setup_range_conditions')); +select left(@json, 2500); + +--echo ## Repeat the above with a bit higher max_weight: +set optimizer_max_sel_arg_weight=120; +explain select * from t1 where + kp1 in (1,2,3,4,5,6,7,8,9,10) and + kp2 in (1,2,3,4,5,6,7,8,9,10) and + kp3 in (1,2,3,4,5,6,7,8,9,10) and + kp4 in (1,2,3,4,5,6,7,8,9,10) +; +set @json= (select json_detailed(JSON_EXTRACT(trace, '$**.range_scan_alternatives')) + from information_schema.optimizer_trace); +select left(@json, 1500); + +set optimizer_max_sel_arg_weight= @tmp9750_weight; +set optimizer_trace=@tmp_9750; + +drop table t1; + +--echo # +--echo # MDEV-24739: Assertion `root->weight >= ...' failed in SEL_ARG::tree_delete +--echo # +SELECT * +FROM mysql.help_relation +WHERE NOT (help_topic_id != 8 AND help_keyword_id != 0 OR help_keyword_id = 2 OR help_topic_id < 1900); + +SELECT * +FROM mysql.help_relation ignore index (help_topic_id) +WHERE (help_topic_id = 8 OR help_keyword_id = 0) AND help_keyword_id != 2 AND help_topic_id >= 1900; + +--echo # +--echo # MDEV-24953: 10.5.9 crashes with large IN() list +--echo # +--source include/have_sequence.inc + +CREATE TABLE t1 ( + notification_type_id smallint(4) unsigned NOT NULL DEFAULT 0, + item_id int(10) unsigned NOT NULL DEFAULT 0, + item_parent_id int(10) unsigned NOT NULL DEFAULT 0, + user_id int(10) unsigned NOT NULL DEFAULT 0, + PRIMARY KEY (notification_type_id,item_id,item_parent_id,user_id) +); +insert into t1 values (1,1,1,1), (2,2,2,2), (3,3,3,3); + +let $consts=`select group_concat(concat("'",seq,"'")) from seq_1_to_4642`; + +--echo # Run crashing query +--disable_query_log +eval +explain +DELETE FROM t1 +WHERE + notification_type_id IN (3, 4, 5, 6, 23) + AND + user_id = '5044' + AND + item_parent_id IN ($consts) +; +--enable_query_log + +drop table t1; + +--echo # +--echo # MDEV-25069: Assertion `root->weight >= ...' failed in SEL_ARG::tree_delete #2 +--echo # + +SELECT * +FROM mysql.help_relation +WHERE + (help_topic_id < '2' OR help_topic_id != 8 OR help_topic_id < 1) AND + help_keyword_id = help_topic_id; diff --git a/mysql-test/main/range_vs_index_merge.result b/mysql-test/main/range_vs_index_merge.result index 286338d0433..207e012b825 100644 --- a/mysql-test/main/range_vs_index_merge.result +++ b/mysql-test/main/range_vs_index_merge.result @@ -951,7 +951,7 @@ WHERE ((Population > 101000 AND Population < 11000) OR ID BETWEEN 3500 AND 3800) AND Country='USA' AND (Name LIKE 'P%' OR ID BETWEEN 4000 AND 4300); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City range PRIMARY,Population,Country,Name,CountryPopulation,CountryName CountryName 38 NULL 23 Using index condition; Using where +1 SIMPLE City range|filter PRIMARY,Population,Country,Name,CountryPopulation,CountryName CountryName|PRIMARY 38|4 NULL 23 (7%) Using index condition; Using where; Using rowid filter EXPLAIN SELECT * FROM City WHERE ((Population > 101000 AND Population < 11000) OR diff --git a/mysql-test/main/range_vs_index_merge_innodb.result b/mysql-test/main/range_vs_index_merge_innodb.result index 65800e7397b..4ac62e24940 100644 --- a/mysql-test/main/range_vs_index_merge_innodb.result +++ b/mysql-test/main/range_vs_index_merge_innodb.result @@ -1,4 +1,4 @@ -SET SESSION STORAGE_ENGINE='InnoDB'; +SET SESSION DEFAULT_STORAGE_ENGINE='InnoDB'; set @innodb_stats_persistent_save= @@innodb_stats_persistent; set @innodb_stats_persistent_sample_pages_save= @@innodb_stats_persistent_sample_pages; @@ -55,7 +55,7 @@ SELECT * FROM City WHERE (Population >= 100000 OR Name LIKE 'P%') AND Country='CAN' OR (Population < 100000 OR Name Like 'T%') AND Country='ARG'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City index_merge Population,Country,Name Population,Name,Country 4,35,3 NULL 821 Using sort_union(Population,Name,Country); Using where +1 SIMPLE City range Population,Country,Name Country 3 NULL 106 Using index condition; Using where EXPLAIN SELECT * FROM City WHERE Population < 200000 AND Name LIKE 'P%' AND @@ -622,7 +622,7 @@ WHERE ((Population > 101000 AND Population < 102000) AND ((ID BETWEEN 3400 AND 3800) AND (Country < 'AGO' OR Name LIKE 'Pa%')); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City index_merge PRIMARY,Population,Country,Name Country,Name 3,35 NULL 831 Using sort_union(Country,Name); Using where +1 SIMPLE City index_merge PRIMARY,Population,Country,Name Population,PRIMARY 4,4 NULL 440 Using sort_union(Population,PRIMARY); Using where EXPLAIN SELECT * FROM City WHERE ((Population > 101000 AND Population < 110000) AND @@ -630,7 +630,7 @@ WHERE ((Population > 101000 AND Population < 110000) AND ((ID BETWEEN 3790 AND 3800) AND (Country < 'C' OR Name LIKE 'P%')); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City index_merge PRIMARY,Population,Country,Name Country,Name 7,39 NULL 678 Using sort_union(Country,Name); Using where +1 SIMPLE City index_merge PRIMARY,Population,Country,Name Country,Name,PRIMARY 3,35,4 NULL 87 Using sort_union(Country,Name,PRIMARY); Using where SELECT * FROM City USE INDEX () WHERE ((Population > 101000 AND Population < 102000) AND (Country < 'C' OR Name BETWEEN 'P' AND 'S')) OR @@ -1085,7 +1085,7 @@ EXPLAIN SELECT Name, Country, Population FROM City WHERE (Name='Samara' AND Country='RUS') OR (Name='Seattle' AND Country='USA'); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City index_merge Country,CountryPopulation,CountryName,CityName CountryName,CityName 38,35 NULL 27 Using sort_union(CountryName,CityName); Using where +1 SIMPLE City range Country,CountryPopulation,CountryName,CityName CountryName 38 NULL 27 Using index condition SELECT Name, Country, Population FROM City WHERE (Name='Manila' AND Country='PHL') OR (Name='Addis Abeba' AND Country='ETH') OR @@ -1806,7 +1806,7 @@ SELECT * FROM t1 WHERE t1.a>300 AND t1.c!=0 AND t1.b>=350 AND t1.b<=400 AND (t1.c=0 OR t1.a=500); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index PRIMARY,idx idx 10 NULL 2 Using where; Using index +1 SIMPLE t1 range PRIMARY,idx idx 5 NULL 2 Using where; Using index SELECT * FROM t1 WHERE t1.a>300 AND t1.c!=0 AND t1.b>=350 AND t1.b<=400 AND (t1.c=0 OR t1.a=500); @@ -1952,4 +1952,4 @@ set session optimizer_switch='index_merge_sort_intersection=default'; set global innodb_stats_persistent= @innodb_stats_persistent_save; set global innodb_stats_persistent_sample_pages= @innodb_stats_persistent_sample_pages_save; -SET SESSION STORAGE_ENGINE=DEFAULT; +SET SESSION DEFAULT_STORAGE_ENGINE=DEFAULT; diff --git a/mysql-test/main/range_vs_index_merge_innodb.test b/mysql-test/main/range_vs_index_merge_innodb.test index 5117ee3668a..4f58bbec1f2 100644 --- a/mysql-test/main/range_vs_index_merge_innodb.test +++ b/mysql-test/main/range_vs_index_merge_innodb.test @@ -1,6 +1,6 @@ --source include/have_innodb.inc -SET SESSION STORAGE_ENGINE='InnoDB'; +SET SESSION DEFAULT_STORAGE_ENGINE='InnoDB'; set @innodb_stats_persistent_save= @@innodb_stats_persistent; set @innodb_stats_persistent_sample_pages_save= @@ -13,4 +13,4 @@ set global innodb_stats_persistent= @innodb_stats_persistent_save; set global innodb_stats_persistent_sample_pages= @innodb_stats_persistent_sample_pages_save; -SET SESSION STORAGE_ENGINE=DEFAULT; +SET SESSION DEFAULT_STORAGE_ENGINE=DEFAULT; diff --git a/mysql-test/main/read_many_rows_innodb.result b/mysql-test/main/read_many_rows_innodb.result index 24f9a2d54a5..80e831ca045 100644 --- a/mysql-test/main/read_many_rows_innodb.result +++ b/mysql-test/main/read_many_rows_innodb.result @@ -1,4 +1,4 @@ -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; DROP TABLE IF EXISTS t1, t2, t3, t4; CREATE TABLE t1 (id INTEGER) ENGINE=MyISAM; CREATE TABLE t2 (id INTEGER PRIMARY KEY); diff --git a/mysql-test/main/rename.result b/mysql-test/main/rename.result index da9e4b62ecd..15c744e158c 100644 --- a/mysql-test/main/rename.result +++ b/mysql-test/main/rename.result @@ -148,3 +148,28 @@ create table t1 (a int) engine=memory; rename table t1 to non_existent.t2; ERROR 42000: Unknown database 'non_existent' drop table t1; +# +# Test rename IF EXISTS +# +rename table if exists t1 to t2; +Warnings: +Note 1146 Table 'test.t1' doesn't exist +alter table if exists t1 rename to t2; +Warnings: +Error 1146 Table 'test.t1' doesn't exist +create table t2 (a int); +alter table if exists t1 rename to t2; +Warnings: +Error 1146 Table 'test.t1' doesn't exist +rename table if exists t1 to t2; +Warnings: +Note 1146 Table 'test.t1' doesn't exist +create table t1 (a int); +rename table if exists t1 to t2; +ERROR 42S01: Table 't2' already exists +alter table if exists t1 rename to t2; +ERROR 42S01: Table 't2' already exists +drop table t2; +rename table if exists t1 to t2; +alter table if exists t2 rename to t1; +drop table t1; diff --git a/mysql-test/main/rename.test b/mysql-test/main/rename.test index 215ecbcbb18..a0b9f38ae2e 100644 --- a/mysql-test/main/rename.test +++ b/mysql-test/main/rename.test @@ -148,3 +148,21 @@ create table t1 (a int) engine=memory; --error ER_BAD_DB_ERROR rename table t1 to non_existent.t2; drop table t1; + +--echo # +--echo # Test rename IF EXISTS +--echo # +rename table if exists t1 to t2; +alter table if exists t1 rename to t2; +create table t2 (a int); +alter table if exists t1 rename to t2; +rename table if exists t1 to t2; +create table t1 (a int); +--error ER_TABLE_EXISTS_ERROR +rename table if exists t1 to t2; +--error ER_TABLE_EXISTS_ERROR +alter table if exists t1 rename to t2; +drop table t2; +rename table if exists t1 to t2; +alter table if exists t2 rename to t1; +drop table t1; diff --git a/mysql-test/main/repair.result b/mysql-test/main/repair.result index a8d82afc626..899ca1e1a32 100644 --- a/mysql-test/main/repair.result +++ b/mysql-test/main/repair.result @@ -192,14 +192,14 @@ drop tables t1, t2; SET @save_global_character_set_server= @@global.character_set_server; set @@global.character_set_server=@@character_set_server; select count(*) from t1; -ERROR HY000: Got error 190 "Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine. You have to dump an" from storage engine MyISAM +ERROR HY000: Got error 190 "Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine. You may have retry " from storage engine MyISAM check table t1; Table Op Msg_type Msg_text -test.t1 check Error Got error 190 "Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine. You have to dump an" from storage engine MyISAM +test.t1 check Error Got error 190 "Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine. You may have retry " from storage engine MyISAM test.t1 check error Corrupt repair table t1; Table Op Msg_type Msg_text -test.t1 repair Error Got error 190 "Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine. You have to dump an" from storage engine MyISAM +test.t1 repair Error Got error 190 "Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine. You may have retry " from storage engine MyISAM test.t1 repair error Corrupt repair table t1 use_frm; Table Op Msg_type Msg_text diff --git a/mysql-test/main/repair_symlink-5543.test b/mysql-test/main/repair_symlink-5543.test index ac7bb497f24..7c4ad7db0dc 100644 --- a/mysql-test/main/repair_symlink-5543.test +++ b/mysql-test/main/repair_symlink-5543.test @@ -11,7 +11,7 @@ insert t1 values (1); --system ln -s $MYSQL_TMP_DIR/foobar5543 $MYSQL_TMP_DIR/t1.TMD --echo # Some systems fail with errcode 40, or 90 (MIPS) when doing openat, --echo # while others don't have openat and fail with errcode 20. ---replace_regex / '.*\/t1/ 'MYSQL_TMP_DIR\/t1/ /[49]0/20/ /".*"/"<errmsg>"/ +--replace_regex / '.*\/t1/ 'MYSQL_TMP_DIR\/t1/ /[49]0/20/ /85/20/ /".*"/"<errmsg>"/ repair table t1; drop table t1; @@ -19,7 +19,7 @@ drop table t1; eval create table t2 (a int) engine=aria data directory='$MYSQL_TMP_DIR'; insert t2 values (1); --system ln -s $MYSQL_TMP_DIR/foobar5543 $MYSQL_TMP_DIR/t2.TMD ---replace_regex / '.*\/t2/ 'MYSQL_TMP_DIR\/t2/ /[49]0/20/ /".*"/"<errmsg>"/ +--replace_regex / '.*\/t2/ 'MYSQL_TMP_DIR\/t2/ /[49]0/20/ /85/20/ /".*"/"<errmsg>"/ repair table t2; drop table t2; diff --git a/mysql-test/main/replace_returning.result b/mysql-test/main/replace_returning.result new file mode 100644 index 00000000000..1bc9bbd4cc5 --- /dev/null +++ b/mysql-test/main/replace_returning.result @@ -0,0 +1,262 @@ +# Test for REPLACE...RETURNING +CREATE TABLE t1(id1 INT PRIMARY KEY, val1 VARCHAR(1)); +CREATE TABLE t2(id2 INT PRIMARY KEY, val2 VARCHAR(1)); +INSERT INTO t2 VALUES (1,'a'),(2,'b'),(3,'c'); +CREATE FUNCTION f(arg INT) RETURNS INT +BEGIN +RETURN (SELECT arg+arg); +END| +# +# Simple replace statement...RETURNING +# +REPLACE INTO t1 (id1, val1) VALUES (1, 'a'); +REPLACE INTO t1 (id1, val1) VALUES (1, 'b') RETURNING *; +id1 val1 +1 b +REPLACE INTO t1 (id1, val1) VALUES (1, 'c') RETURNING id1+id1 AS total, +id1&&id1, id1|id1,UPPER(val1),f(id1); +total id1&&id1 id1|id1 UPPER(val1) f(id1) +2 1 1 C 2 +REPLACE INTO t1(id1,val1) VALUES (1,'d') RETURNING (SELECT GROUP_CONCAT(val2) +FROM t2 WHERE id2=1); +(SELECT GROUP_CONCAT(val2) +FROM t2 WHERE id2=1) +a +REPLACE INTO t1(id1,val1) VALUES(1,'e') RETURNING (SELECT GROUP_CONCAT(val2) +FROM t2 GROUP BY id2 HAVING id2=id2+1); +(SELECT GROUP_CONCAT(val2) +FROM t2 GROUP BY id2 HAVING id2=id2+1) +NULL +PREPARE stmt FROM "REPLACE INTO t1 (id1,val1) VALUES (1,'f') RETURNING +id1,(SELECT id2 FROM t2 WHERE val2='b')"; +EXECUTE stmt; +id1 (SELECT id2 FROM t2 WHERE val2='b') +1 2 +DEALLOCATE PREPARE stmt; +REPLACE INTO t1 (id1, val1) VALUES (1, 'g') RETURNING t1.*; +id1 val1 +1 g +SELECT * FROM t1; +id1 val1 +1 g +TRUNCATE TABLE t1; +# +# Multiple values in one replace statement...RETURNING +# +REPLACE INTO t1 VALUES (1,'a'),(2,'b'); +REPLACE INTO t1 VALUES (1,'c'),(2,'d') RETURNING *; +id1 val1 +1 c +2 d +REPLACE INTO t1 VALUES (1,'e'),(2,'f') RETURNING id1+id1 AS total, +id1&&id1, id1|id1,UPPER(val1),f(id1); +total id1&&id1 id1|id1 UPPER(val1) f(id1) +2 1 1 E 2 +4 1 2 F 4 +REPLACE INTO t1 VALUES (1,'o'),(2,'p') RETURNING (SELECT GROUP_CONCAT(val2) +FROM t2 WHERE id2=1); +(SELECT GROUP_CONCAT(val2) +FROM t2 WHERE id2=1) +a +a +REPLACE INTO t1 VALUES (1,'q'),(2,'r') RETURNING (SELECT GROUP_CONCAT(val2) +FROM t2 GROUP BY id2 HAVING id2=id2+1); +(SELECT GROUP_CONCAT(val2) +FROM t2 GROUP BY id2 HAVING id2=id2+1) +NULL +NULL +PREPARE stmt FROM "REPLACE INTO t1 VALUES (1,'s'),(2,'t') RETURNING id1, +(SELECT id2 FROM t2 WHERE val2='b')"; +EXECUTE stmt; +id1 (SELECT id2 FROM t2 WHERE val2='b') +1 2 +2 2 +DEALLOCATE PREPARE stmt; +REPLACE INTO t1 VALUES (1,'u'),(2,'v') RETURNING t1.*; +id1 val1 +1 u +2 v +SELECT * FROM t1; +id1 val1 +1 u +2 v +TRUNCATE TABLE t1; +# +# REPLACE...SET...RETURNING +# +REPLACE INTO t1 SET id1=1, val1 = 'a'; +REPLACE INTO t1 SET id1=2, val1 = 'b' RETURNING *; +id1 val1 +2 b +REPLACE INTO t1 SET id1=3, val1 = 'c' RETURNING id1+id1 AS total, +id1&&id1, id1|id1,UPPER(val1),f(id1); +total id1&&id1 id1|id1 UPPER(val1) f(id1) +6 1 3 C 6 +REPLACE INTO t1 SET id1=1, val1 = 'i' RETURNING (SELECT GROUP_CONCAT(val2) +FROM t2 WHERE id2=1); +(SELECT GROUP_CONCAT(val2) +FROM t2 WHERE id2=1) +a +REPLACE INTO t1 SET id1=2, val1='j' RETURNING (SELECT GROUP_CONCAT(val2) +FROM t2 GROUP BY id2 HAVING id2=id2+1); +(SELECT GROUP_CONCAT(val2) +FROM t2 GROUP BY id2 HAVING id2=id2+1) +NULL +PREPARE stmt FROM "REPLACE INTO t1 SET id1=3, val1='k' RETURNING id1, +(SELECT id2 FROM t2 WHERE val2='b')"; +EXECUTE stmt; +id1 (SELECT id2 FROM t2 WHERE val2='b') +3 2 +DEALLOCATE PREPARE stmt; +REPLACE INTO t1 SET id1=1, val1 = 'o' RETURNING t1.*; +id1 val1 +1 o +SELECT * FROM t1; +id1 val1 +1 o +2 j +3 k +# +# REPLACE...SELECT...RETURNING +# +TRUNCATE TABLE t2; +REPLACE INTO t2(id2,val2) SELECT * FROM t1; +REPLACE INTO t2 SELECT * FROM t1 WHERE id1=1 RETURNING *; +id2 val2 +1 o +REPLACE INTO t2 SELECT * FROM t1 WHERE id1=2 RETURNING id2+id2 AS total, +id2&&id2, id2|id2,UPPER(val2),f(id2); +total id2&&id2 id2|id2 UPPER(val2) f(id2) +4 1 2 J 4 +REPLACE INTO t2 SELECT * FROM t1 WHERE id1=3 RETURNING (SELECT +GROUP_CONCAT(val1) FROM t1 WHERE id1=1); +(SELECT +GROUP_CONCAT(val1) FROM t1 WHERE id1=1) +o +REPLACE INTO t2 SELECT * FROM t1 WHERE id1=1 RETURNING (SELECT +GROUP_CONCAT(val1) FROM t1 GROUP BY id1 HAVING id1=id1+1); +(SELECT +GROUP_CONCAT(val1) FROM t1 GROUP BY id1 HAVING id1=id1+1) +NULL +PREPARE stmt FROM "REPLACE INTO t2 SELECT * FROM t1 WHERE id1=2 RETURNING +id2,(SELECT id1 FROM t1 WHERE val1='b')"; +EXECUTE stmt; +id2 (SELECT id1 FROM t1 WHERE val1='b') +2 NULL +DEALLOCATE PREPARE stmt; +REPLACE INTO t2 SELECT * FROM t1 WHERE id1=3 RETURNING (SELECT id1+id2 +FROM t1 WHERE id1=1); +(SELECT id1+id2 +FROM t1 WHERE id1=1) +4 +REPLACE INTO t2 SELECT * FROM t1 WHERE id1=1 RETURNING (SELECT id1+id2 +FROM t2 WHERE id2=0); +(SELECT id1+id2 +FROM t2 WHERE id2=0) +NULL +REPLACE INTO t2 SELECT * FROM t1 WHERE id1=2 RETURNING t2.*; +id2 val2 +2 j +SELECT * FROM t2; +id2 val2 +1 o +2 j +3 k +DROP TABLE t1; +DROP TABLE t2; +DROP FUNCTION f; +# +# checking errors +# +CREATE TABLE t1(id1 INT,val1 VARCHAR(1)); +CREATE TABLE t2(id2 INT,val2 VARCHAR(1)); +REPLACE INTO t1 VALUES(1,'a'),(2,'b'),(3,'c'); +# +# SIMLPE REPLACE STATEMENT +# +REPLACE INTO t2(id2,val2) VALUES(1,'a') RETURNING id1; +ERROR 42S22: Unknown column 'id1' in 'field list' +REPLACE INTO t2(id2,val2) values(2,'b') RETURNING SUM(id2); +ERROR HY000: Invalid use of group function +REPLACE INTO t2(id2,val2) VALUES(3,'c') RETURNING (SELECT id1 FROM t1); +ERROR 21000: Subquery returns more than 1 row +REPLACE INTO t2(id2,val2) VALUES(4,'d') RETURNING (SELECT * FROM t1); +ERROR 21000: Operand should contain 1 column(s) +REPLACE INTO t2(id2,val2) VALUES(4,'d') RETURNING (SELECT * FROM t2); +ERROR 21000: Operand should contain 1 column(s) +REPLACE INTO t2(id2,val2) VALUES(5,'e') RETURNING id2, (SELECT id1+id2 FROM +t1 WHERE id1=1); +id2 (SELECT id1+id2 FROM +t1 WHERE id1=1) +5 6 +REPLACE INTO t2(id2,val2) VALUES(5,'f') RETURNING (SELECT id2 FROM t2); +ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data +REPLACE INTO t2 (id2, val2) VALUES (6,'f') RETURNING t1.*; +ERROR 42S02: Unknown table 'test.t1' +# +# Multiple rows in single insert statement +# +REPLACE INTO t2 VALUES(1,'a'),(2,'b') RETURNING id1; +ERROR 42S22: Unknown column 'id1' in 'field list' +REPLACE INTO t2 VALUES(3,'c'),(4,'d') RETURNING MAX(id2); +ERROR HY000: Invalid use of group function +REPLACE INTO t2 VALUES(5,'c'),(6,'f') RETURNING (SELECT id1 FROM t1); +ERROR 21000: Subquery returns more than 1 row +REPLACE INTO t2 VALUES(7,'g'),(8,'h') RETURNING (SELECT * FROM t1); +ERROR 21000: Operand should contain 1 column(s) +REPLACE INTO t2 VALUES(9,'g'),(10,'h') RETURNING (SELECT * FROM t2); +ERROR 21000: Operand should contain 1 column(s) +REPLACE INTO t2 VALUES(11,'e'),(12,'f') RETURNING id2, (SELECT id1+id2 FROM +t1 WHERE id1=1); +id2 (SELECT id1+id2 FROM +t1 WHERE id1=1) +11 12 +12 13 +REPLACE INTO t2 VALUES(13,'f'),(14,'g') RETURNING (SELECT id2 FROM t2); +ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data +REPLACE INTO t2 VALUES(13,'f'),(14,'g') RETURNING t1.*; +ERROR 42S02: Unknown table 'test.t1' +# +# REPLACE ... SET +# +REPLACE INTO t2 SET id2=1, val2='a' RETURNING id1; +ERROR 42S22: Unknown column 'id1' in 'field list' +REPLACE INTO t2 SET id2=2, val2='b' RETURNING COUNT(id2); +ERROR HY000: Invalid use of group function +REPLACE INTO t2 SET id2=3, val2='c' RETURNING (SELECT id1 FROM t1); +ERROR 21000: Subquery returns more than 1 row +REPLACE INTO t2 SET id2=4, val2='d' RETURNING (SELECT * FROM t1); +ERROR 21000: Operand should contain 1 column(s) +REPLACE INTO t2 SET id2=4, val2='d' RETURNING (SELECT * FROM t2); +ERROR 21000: Operand should contain 1 column(s) +REPLACE INTO t2 SET id2=5, val2='e' RETURNING id2, (SELECT id1+id2 FROM t1 +WHERE id1=1); +id2 (SELECT id1+id2 FROM t1 +WHERE id1=1) +5 6 +REPLACE INTO t2 SET id2=5, val2='f' RETURNING (SELECT id2 FROM t2); +ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data +REPLACE INTO t2 SET id2=5, val2='f' RETURNING t1.*; +ERROR 42S02: Unknown table 'test.t1' +# +# REPLACE...SELECT +# +REPLACE INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=1 RETURNING id1; +ERROR 42S22: Unknown column 'id1' in 'field list' +REPLACE INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=2 RETURNING MAX(id2); +ERROR HY000: Invalid use of group function +REPLACE INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=2 RETURNING (SELECT +id1 FROM t1); +ERROR 21000: Subquery returns more than 1 row +REPLACE INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=2 RETURNING (SELECT +* FROM t1); +ERROR 21000: Operand should contain 1 column(s) +REPLACE INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=2 RETURNING(SELECT +* FROM t2); +ERROR 21000: Operand should contain 1 column(s) +REPLACE INTO t2(id2,val2) SELECT * FROM t1 WHERE id1=2 RETURNING (SELECT +id2 FROM t2); +ERROR 21000: Subquery returns more than 1 row +REPLACE INTO t2(id2,val2) SELECT t1.* FROM t1 WHERE id1=2 RETURNING t1.*; +ERROR 42S02: Unknown table 'test.t1' +DROP TABLE t1,t2; diff --git a/mysql-test/main/replace_returning.test b/mysql-test/main/replace_returning.test new file mode 100644 index 00000000000..8b8a1c24e3e --- /dev/null +++ b/mysql-test/main/replace_returning.test @@ -0,0 +1,192 @@ +--echo # Test for REPLACE...RETURNING + +CREATE TABLE t1(id1 INT PRIMARY KEY, val1 VARCHAR(1)); +CREATE TABLE t2(id2 INT PRIMARY KEY, val2 VARCHAR(1)); +INSERT INTO t2 VALUES (1,'a'),(2,'b'),(3,'c'); + +DELIMITER |; + +CREATE FUNCTION f(arg INT) RETURNS INT +BEGIN + RETURN (SELECT arg+arg); +END| + +DELIMITER ;| + +--echo # +--echo # Simple replace statement...RETURNING +--echo # +REPLACE INTO t1 (id1, val1) VALUES (1, 'a'); +REPLACE INTO t1 (id1, val1) VALUES (1, 'b') RETURNING *; +REPLACE INTO t1 (id1, val1) VALUES (1, 'c') RETURNING id1+id1 AS total, +id1&&id1, id1|id1,UPPER(val1),f(id1); +REPLACE INTO t1(id1,val1) VALUES (1,'d') RETURNING (SELECT GROUP_CONCAT(val2) +FROM t2 WHERE id2=1); +REPLACE INTO t1(id1,val1) VALUES(1,'e') RETURNING (SELECT GROUP_CONCAT(val2) +FROM t2 GROUP BY id2 HAVING id2=id2+1); +PREPARE stmt FROM "REPLACE INTO t1 (id1,val1) VALUES (1,'f') RETURNING +id1,(SELECT id2 FROM t2 WHERE val2='b')"; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +REPLACE INTO t1 (id1, val1) VALUES (1, 'g') RETURNING t1.*; +SELECT * FROM t1; +TRUNCATE TABLE t1; + +--echo # +--echo # Multiple values in one replace statement...RETURNING +--echo # +REPLACE INTO t1 VALUES (1,'a'),(2,'b'); +REPLACE INTO t1 VALUES (1,'c'),(2,'d') RETURNING *; +REPLACE INTO t1 VALUES (1,'e'),(2,'f') RETURNING id1+id1 AS total, +id1&&id1, id1|id1,UPPER(val1),f(id1); +REPLACE INTO t1 VALUES (1,'o'),(2,'p') RETURNING (SELECT GROUP_CONCAT(val2) +FROM t2 WHERE id2=1); +REPLACE INTO t1 VALUES (1,'q'),(2,'r') RETURNING (SELECT GROUP_CONCAT(val2) +FROM t2 GROUP BY id2 HAVING id2=id2+1); +PREPARE stmt FROM "REPLACE INTO t1 VALUES (1,'s'),(2,'t') RETURNING id1, +(SELECT id2 FROM t2 WHERE val2='b')"; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +REPLACE INTO t1 VALUES (1,'u'),(2,'v') RETURNING t1.*; +SELECT * FROM t1; +TRUNCATE TABLE t1; + +--echo # +--echo # REPLACE...SET...RETURNING +--echo # +REPLACE INTO t1 SET id1=1, val1 = 'a'; +REPLACE INTO t1 SET id1=2, val1 = 'b' RETURNING *; +REPLACE INTO t1 SET id1=3, val1 = 'c' RETURNING id1+id1 AS total, +id1&&id1, id1|id1,UPPER(val1),f(id1); +REPLACE INTO t1 SET id1=1, val1 = 'i' RETURNING (SELECT GROUP_CONCAT(val2) +FROM t2 WHERE id2=1); +REPLACE INTO t1 SET id1=2, val1='j' RETURNING (SELECT GROUP_CONCAT(val2) +FROM t2 GROUP BY id2 HAVING id2=id2+1); +PREPARE stmt FROM "REPLACE INTO t1 SET id1=3, val1='k' RETURNING id1, +(SELECT id2 FROM t2 WHERE val2='b')"; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +REPLACE INTO t1 SET id1=1, val1 = 'o' RETURNING t1.*; + +SELECT * FROM t1; + +--echo # +--echo # REPLACE...SELECT...RETURNING +--echo # +TRUNCATE TABLE t2; +REPLACE INTO t2(id2,val2) SELECT * FROM t1; +REPLACE INTO t2 SELECT * FROM t1 WHERE id1=1 RETURNING *; +REPLACE INTO t2 SELECT * FROM t1 WHERE id1=2 RETURNING id2+id2 AS total, +id2&&id2, id2|id2,UPPER(val2),f(id2); +REPLACE INTO t2 SELECT * FROM t1 WHERE id1=3 RETURNING (SELECT +GROUP_CONCAT(val1) FROM t1 WHERE id1=1); +REPLACE INTO t2 SELECT * FROM t1 WHERE id1=1 RETURNING (SELECT +GROUP_CONCAT(val1) FROM t1 GROUP BY id1 HAVING id1=id1+1); +PREPARE stmt FROM "REPLACE INTO t2 SELECT * FROM t1 WHERE id1=2 RETURNING +id2,(SELECT id1 FROM t1 WHERE val1='b')"; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +REPLACE INTO t2 SELECT * FROM t1 WHERE id1=3 RETURNING (SELECT id1+id2 +FROM t1 WHERE id1=1); +REPLACE INTO t2 SELECT * FROM t1 WHERE id1=1 RETURNING (SELECT id1+id2 +FROM t2 WHERE id2=0); +REPLACE INTO t2 SELECT * FROM t1 WHERE id1=2 RETURNING t2.*; +SELECT * FROM t2; + +DROP TABLE t1; +DROP TABLE t2; +DROP FUNCTION f; + +--echo # +--echo # checking errors +--echo # + +CREATE TABLE t1(id1 INT,val1 VARCHAR(1)); +CREATE TABLE t2(id2 INT,val2 VARCHAR(1)); + +REPLACE INTO t1 VALUES(1,'a'),(2,'b'),(3,'c'); + +--echo # +--echo # SIMLPE REPLACE STATEMENT +--echo # +--error ER_BAD_FIELD_ERROR +REPLACE INTO t2(id2,val2) VALUES(1,'a') RETURNING id1; +--error ER_INVALID_GROUP_FUNC_USE +REPLACE INTO t2(id2,val2) values(2,'b') RETURNING SUM(id2); +--error ER_SUBQUERY_NO_1_ROW +REPLACE INTO t2(id2,val2) VALUES(3,'c') RETURNING (SELECT id1 FROM t1); +--error ER_OPERAND_COLUMNS +REPLACE INTO t2(id2,val2) VALUES(4,'d') RETURNING (SELECT * FROM t1); +--error ER_OPERAND_COLUMNS +REPLACE INTO t2(id2,val2) VALUES(4,'d') RETURNING (SELECT * FROM t2); +REPLACE INTO t2(id2,val2) VALUES(5,'e') RETURNING id2, (SELECT id1+id2 FROM +t1 WHERE id1=1); +--error ER_UPDATE_TABLE_USED +REPLACE INTO t2(id2,val2) VALUES(5,'f') RETURNING (SELECT id2 FROM t2); +--error ER_BAD_TABLE_ERROR +REPLACE INTO t2 (id2, val2) VALUES (6,'f') RETURNING t1.*; + +--echo # +--echo # Multiple rows in single insert statement +--echo # +--error ER_BAD_FIELD_ERROR +REPLACE INTO t2 VALUES(1,'a'),(2,'b') RETURNING id1; +--error ER_INVALID_GROUP_FUNC_USE +REPLACE INTO t2 VALUES(3,'c'),(4,'d') RETURNING MAX(id2); +--error ER_SUBQUERY_NO_1_ROW +REPLACE INTO t2 VALUES(5,'c'),(6,'f') RETURNING (SELECT id1 FROM t1); +--error ER_OPERAND_COLUMNS +REPLACE INTO t2 VALUES(7,'g'),(8,'h') RETURNING (SELECT * FROM t1); +--error ER_OPERAND_COLUMNS +REPLACE INTO t2 VALUES(9,'g'),(10,'h') RETURNING (SELECT * FROM t2); +REPLACE INTO t2 VALUES(11,'e'),(12,'f') RETURNING id2, (SELECT id1+id2 FROM +t1 WHERE id1=1); +--error ER_UPDATE_TABLE_USED +REPLACE INTO t2 VALUES(13,'f'),(14,'g') RETURNING (SELECT id2 FROM t2); +--error ER_BAD_TABLE_ERROR +REPLACE INTO t2 VALUES(13,'f'),(14,'g') RETURNING t1.*; + +--echo # +--echo # REPLACE ... SET +--echo # +--error ER_BAD_FIELD_ERROR +REPLACE INTO t2 SET id2=1, val2='a' RETURNING id1; +--error ER_INVALID_GROUP_FUNC_USE +REPLACE INTO t2 SET id2=2, val2='b' RETURNING COUNT(id2); +--error ER_SUBQUERY_NO_1_ROW +REPLACE INTO t2 SET id2=3, val2='c' RETURNING (SELECT id1 FROM t1); +--error ER_OPERAND_COLUMNS +REPLACE INTO t2 SET id2=4, val2='d' RETURNING (SELECT * FROM t1); +--error ER_OPERAND_COLUMNS +REPLACE INTO t2 SET id2=4, val2='d' RETURNING (SELECT * FROM t2); +REPLACE INTO t2 SET id2=5, val2='e' RETURNING id2, (SELECT id1+id2 FROM t1 +WHERE id1=1); +--error ER_UPDATE_TABLE_USED +REPLACE INTO t2 SET id2=5, val2='f' RETURNING (SELECT id2 FROM t2); +--error ER_BAD_TABLE_ERROR +REPLACE INTO t2 SET id2=5, val2='f' RETURNING t1.*; + +--echo # +--echo # REPLACE...SELECT +--echo # +--error ER_BAD_FIELD_ERROR +REPLACE INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=1 RETURNING id1; +--error ER_INVALID_GROUP_FUNC_USE +REPLACE INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=2 RETURNING MAX(id2); +--error ER_SUBQUERY_NO_1_ROW +REPLACE INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=2 RETURNING (SELECT +id1 FROM t1); +--error ER_OPERAND_COLUMNS +REPLACE INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=2 RETURNING (SELECT +* FROM t1); +--error ER_OPERAND_COLUMNS +REPLACE INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=2 RETURNING(SELECT +* FROM t2); +--error ER_SUBQUERY_NO_1_ROW +REPLACE INTO t2(id2,val2) SELECT * FROM t1 WHERE id1=2 RETURNING (SELECT +id2 FROM t2); +--error ER_BAD_TABLE_ERROR +REPLACE INTO t2(id2,val2) SELECT t1.* FROM t1 WHERE id1=2 RETURNING t1.*; + + +DROP TABLE t1,t2; diff --git a/mysql-test/main/replace_returning_datatypes.result b/mysql-test/main/replace_returning_datatypes.result new file mode 100644 index 00000000000..2dc7b5404c2 --- /dev/null +++ b/mysql-test/main/replace_returning_datatypes.result @@ -0,0 +1,61 @@ +CREATE TABLE t1(num_int1 INT(2) PRIMARY KEY, +num_bit1 BIT(8), +num_float1 FLOAT(5,2), +num_double1 DOUBLE(5,2), +char_enum1 ENUM('A','B','C','D'), +char_set1 SET('a','b','c','d','e'), +str_varchar1 VARCHAR(2), +d1 DATE, +dt1 DATETIME, +ts1 TIMESTAMP, +y1 YEAR, +b1 BOOL); +CREATE TABLE t2(num_int2 INT(2) PRIMARY KEY, +num_bit2 BIT(8), +num_float2 FLOAT(5,2), +num_double2 DOUBLE(5,2), +char_enum2 ENUM('A','B','C','D'), +char_set2 SET('a','b','c','d','e'), +str_varchar2 VARCHAR(2), +d2 DATE, +dt2 DATETIME, +ts2 TIMESTAMP, +y2 YEAR, +b2 BOOL); +# +# SIMLPE REPLACE STATEMENT +# +REPLACE INTO t1(num_int1,num_bit1,num_float1,num_double1,char_enum1,char_set1, +str_varchar1, d1,dt1,ts1,y1,b1) VALUES(1,b'1000011', 123.45, 123.55, +'A','b,e', 'V','120314',"2012-04-19 13:08:22", '2001-07-22 12:12:12', +2012,0) RETURNING *; +num_int1 num_bit1 num_float1 num_double1 char_enum1 char_set1 str_varchar1 d1 dt1 ts1 y1 b1 +1 C 123.45 123.55 A b,e V 2012-03-14 2012-04-19 13:08:22 2001-07-22 12:12:12 2012 0 +# +# MULTIPLE ROWS IN SINGLE STATEMENT +# +REPLACE INTO t1 VALUES(1,b'1000011', 123.45, 123.55, 'A','b,e', 'V', +'120314',"2012-04-19 13:08:22", '2001-07-22 12:12:12',2012,0),(3,b'1000011', +123.45, 123.55, 'A','b,e', 'V','120314',"2012-04-19 13:08:22", +'2001-07-22 12:12:12',2012,1) RETURNING *; +num_int1 num_bit1 num_float1 num_double1 char_enum1 char_set1 str_varchar1 d1 dt1 ts1 y1 b1 +1 C 123.45 123.55 A b,e V 2012-03-14 2012-04-19 13:08:22 2001-07-22 12:12:12 2012 0 +3 C 123.45 123.55 A b,e V 2012-03-14 2012-04-19 13:08:22 2001-07-22 12:12:12 2012 1 +# +# REPLACE...SET...RETURNING +# +REPLACE INTO t1 SET num_int1=1,num_bit1=b'1000011',num_float1=124.67, +num_double1=231.12,char_enum1='B',char_set1='a,d,e', +str_varchar1='AB',d1='120314',dt1="2012-04-19 13:08:22", +ts1='2001-07-22 12:12:1',y1=2014,b1=1 RETURNING *; +num_int1 num_bit1 num_float1 num_double1 char_enum1 char_set1 str_varchar1 d1 dt1 ts1 y1 b1 +1 C 124.67 231.12 B a,d,e AB 2012-03-14 2012-04-19 13:08:22 2001-07-22 12:12:01 2014 1 +# +# REPLACE...SELECT...RETURNING +# +REPLACE INTO t2 SELECT * FROM t1 RETURNING *; +num_int2 num_bit2 num_float2 num_double2 char_enum2 char_set2 str_varchar2 d2 dt2 ts2 y2 b2 +1 C 124.67 231.12 B a,d,e AB 2012-03-14 2012-04-19 13:08:22 2001-07-22 12:12:01 2014 1 +3 C 123.45 123.55 A b,e V 2012-03-14 2012-04-19 13:08:22 2001-07-22 12:12:12 2012 1 +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/main/replace_returning_datatypes.test b/mysql-test/main/replace_returning_datatypes.test new file mode 100644 index 00000000000..f063865ecb7 --- /dev/null +++ b/mysql-test/main/replace_returning_datatypes.test @@ -0,0 +1,66 @@ +#Test for checking all dataypes are returned + +CREATE TABLE t1(num_int1 INT(2) PRIMARY KEY, +num_bit1 BIT(8), +num_float1 FLOAT(5,2), +num_double1 DOUBLE(5,2), +char_enum1 ENUM('A','B','C','D'), +char_set1 SET('a','b','c','d','e'), +str_varchar1 VARCHAR(2), +d1 DATE, +dt1 DATETIME, +ts1 TIMESTAMP, +y1 YEAR, +b1 BOOL); + +CREATE TABLE t2(num_int2 INT(2) PRIMARY KEY, +num_bit2 BIT(8), +num_float2 FLOAT(5,2), +num_double2 DOUBLE(5,2), +char_enum2 ENUM('A','B','C','D'), +char_set2 SET('a','b','c','d','e'), +str_varchar2 VARCHAR(2), +d2 DATE, +dt2 DATETIME, +ts2 TIMESTAMP, +y2 YEAR, +b2 BOOL); + + +--echo # +--echo # SIMLPE REPLACE STATEMENT +--echo # +REPLACE INTO t1(num_int1,num_bit1,num_float1,num_double1,char_enum1,char_set1, +str_varchar1, d1,dt1,ts1,y1,b1) VALUES(1,b'1000011', 123.45, 123.55, +'A','b,e', 'V','120314',"2012-04-19 13:08:22", '2001-07-22 12:12:12', +2012,0) RETURNING *; + + +--echo # +--echo # MULTIPLE ROWS IN SINGLE STATEMENT +--echo # +REPLACE INTO t1 VALUES(1,b'1000011', 123.45, 123.55, 'A','b,e', 'V', +'120314',"2012-04-19 13:08:22", '2001-07-22 12:12:12',2012,0),(3,b'1000011', +123.45, 123.55, 'A','b,e', 'V','120314',"2012-04-19 13:08:22", +'2001-07-22 12:12:12',2012,1) RETURNING *; + + + +--echo # +--echo # REPLACE...SET...RETURNING +--echo # +REPLACE INTO t1 SET num_int1=1,num_bit1=b'1000011',num_float1=124.67, +num_double1=231.12,char_enum1='B',char_set1='a,d,e', +str_varchar1='AB',d1='120314',dt1="2012-04-19 13:08:22", +ts1='2001-07-22 12:12:1',y1=2014,b1=1 RETURNING *; + + + +--echo # +--echo # REPLACE...SELECT...RETURNING +--echo # +REPLACE INTO t2 SELECT * FROM t1 RETURNING *; + + +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/main/replace_returning_err.result b/mysql-test/main/replace_returning_err.result new file mode 100644 index 00000000000..04ccdb6c5a5 --- /dev/null +++ b/mysql-test/main/replace_returning_err.result @@ -0,0 +1,69 @@ +CREATE TABLE t1(id1 INT PRIMARY KEY, val1 VARCHAR(1)); +CREATE TABLE t2(id2 INT PRIMARY KEY, val2 VARCHAR(1)); +INSERT INTO t1 VALUES(1, 'a'), (2, 'b'), (3, 'c'); +# +# SIMLPE REPLACE STATEMENT +# +REPLACE INTO t2(id2, val2) VALUES(1, 'a') RETURNING id1; +ERROR 42S22: Unknown column 'id1' in 'field list' +REPLACE INTO t2(id2, val2) values(2, 'b') RETURNING SUM(id2); +ERROR HY000: Invalid use of group function +REPLACE INTO t2(id2, val2) VALUES(3, 'c') RETURNING(SELECT id1 FROM t1); +ERROR 21000: Subquery returns more than 1 row +REPLACE INTO t2(id2, val2) VALUES(4, 'd') RETURNING(SELECT* FROM t1); +ERROR 21000: Operand should contain 1 column(s) +REPLACE INTO t2(id2, val2) VALUES(4, 'd') RETURNING(SELECT* FROM t2); +ERROR 21000: Operand should contain 1 column(s) +REPLACE INTO t2(id2, val2) VALUES(5, 'f') RETURNING(SELECT id2 FROM t2); +ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data +# +# Multiple rows in single replace statement +# +REPLACE INTO t2 VALUES(1, 'a'), (2, 'b') RETURNING id1; +ERROR 42S22: Unknown column 'id1' in 'field list' +REPLACE INTO t2 VALUES(3, 'c'), (4, 'd') RETURNING MAX(id2); +ERROR HY000: Invalid use of group function +REPLACE INTO t2 VALUES(5, 'c'), (6, 'f') RETURNING(SELECT id1 FROM t1); +ERROR 21000: Subquery returns more than 1 row +REPLACE INTO t2 VALUES(7, 'g'), (8, 'h') RETURNING(SELECT* FROM t1); +ERROR 21000: Operand should contain 1 column(s) +REPLACE INTO t2 VALUES(9, 'g'), (10, 'h') RETURNING(SELECT* FROM t2); +ERROR 21000: Operand should contain 1 column(s) +REPLACE INTO t2 VALUES(13, 'f'), (14, 'g') RETURNING(SELECT id2 FROM t2); +ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data +# +# REPLACE ... SET +# +REPLACE INTO t2 SET id2 = 1, val2 = 'a' RETURNING id1; +ERROR 42S22: Unknown column 'id1' in 'field list' +REPLACE INTO t2 SET id2 = 2, val2 = 'b' RETURNING COUNT(id2); +ERROR HY000: Invalid use of group function +REPLACE INTO t2 SET id2 = 3, val2 = 'c' RETURNING(SELECT id1 FROM t1); +ERROR 21000: Subquery returns more than 1 row +REPLACE INTO t2 SET id2 = 4, val2 = 'd' RETURNING(SELECT * FROM t1); +ERROR 21000: Operand should contain 1 column(s) +REPLACE INTO t2 SET id2 = 4, val2 = 'd' RETURNING(SELECT * FROM t2); +ERROR 21000: Operand should contain 1 column(s) +REPLACE INTO t2 SET id2 = 5, val2 = 'f' RETURNING(SELECT id2 FROM t2); +ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data +# +# REPLACE...SELECT +# +REPLACE INTO t2(id2, val2) SELECT* FROM t1 WHERE id1 = 1 RETURNING id1; +ERROR 42S22: Unknown column 'id1' in 'field list' +REPLACE INTO t2(id2, val2) SELECT* FROM t1 WHERE id1 = 2 RETURNING MAX(id2); +ERROR HY000: Invalid use of group function +REPLACE INTO t2(id2, val2) SELECT* FROM t1 WHERE id1 = 2 RETURNING(SELECT id1 +FROM t1); +ERROR 21000: Subquery returns more than 1 row +REPLACE INTO t2(id2, val2) SELECT* FROM t1 WHERE id1 = 2 RETURNING(SELECT * +FROM t1); +ERROR 21000: Operand should contain 1 column(s) +REPLACE INTO t2(id2, val2) SELECT* FROM t1 WHERE id1 = 2 RETURNING(SELECT * +FROM t2); +ERROR 21000: Operand should contain 1 column(s) +REPLACE INTO t2(id2, val2) SELECT* FROM t1 WHERE id1 = 2 RETURNING(SELECT id2 +FROM t2); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/main/replace_returning_err.test b/mysql-test/main/replace_returning_err.test new file mode 100644 index 00000000000..383bd1e1c8b --- /dev/null +++ b/mysql-test/main/replace_returning_err.test @@ -0,0 +1,86 @@ +# +# Test for checking error message for REPLACE...RETURNING +# + +#REPLACE INTO <table> ... RETURNING <not existing col> +#REPLACE INTO <table> ... RETURNING <expr with aggr function> +#REPLACE INTO ... RETURNING subquery with more than 1 row +#REPLACE INTO ... RETURNING operand should contain 1 colunm(s) +#REPLACE INTO ... RETURNING operand should contain 1 colunm(s) +#REPLACE INTO ... SELECT...RETURNING < SELECT <colname> FROM <REPLACE TABLE> + +CREATE TABLE t1(id1 INT PRIMARY KEY, val1 VARCHAR(1)); +CREATE TABLE t2(id2 INT PRIMARY KEY, val2 VARCHAR(1)); + +INSERT INTO t1 VALUES(1, 'a'), (2, 'b'), (3, 'c'); + +--echo # +--echo # SIMLPE REPLACE STATEMENT +--echo # +--error ER_BAD_FIELD_ERROR +REPLACE INTO t2(id2, val2) VALUES(1, 'a') RETURNING id1; +--error ER_INVALID_GROUP_FUNC_USE +REPLACE INTO t2(id2, val2) values(2, 'b') RETURNING SUM(id2); +--error ER_SUBQUERY_NO_1_ROW +REPLACE INTO t2(id2, val2) VALUES(3, 'c') RETURNING(SELECT id1 FROM t1); +--error ER_OPERAND_COLUMNS +REPLACE INTO t2(id2, val2) VALUES(4, 'd') RETURNING(SELECT* FROM t1); +--error ER_OPERAND_COLUMNS +REPLACE INTO t2(id2, val2) VALUES(4, 'd') RETURNING(SELECT* FROM t2); +--error ER_UPDATE_TABLE_USED +REPLACE INTO t2(id2, val2) VALUES(5, 'f') RETURNING(SELECT id2 FROM t2); + +--echo # +--echo # Multiple rows in single replace statement +--echo # +--error ER_BAD_FIELD_ERROR +REPLACE INTO t2 VALUES(1, 'a'), (2, 'b') RETURNING id1; +--error ER_INVALID_GROUP_FUNC_USE +REPLACE INTO t2 VALUES(3, 'c'), (4, 'd') RETURNING MAX(id2); +--error ER_SUBQUERY_NO_1_ROW +REPLACE INTO t2 VALUES(5, 'c'), (6, 'f') RETURNING(SELECT id1 FROM t1); +--error ER_OPERAND_COLUMNS +REPLACE INTO t2 VALUES(7, 'g'), (8, 'h') RETURNING(SELECT* FROM t1); +--error ER_OPERAND_COLUMNS +REPLACE INTO t2 VALUES(9, 'g'), (10, 'h') RETURNING(SELECT* FROM t2); +--error ER_UPDATE_TABLE_USED +REPLACE INTO t2 VALUES(13, 'f'), (14, 'g') RETURNING(SELECT id2 FROM t2); + +--echo # +--echo # REPLACE ... SET +--echo # +--error ER_BAD_FIELD_ERROR +REPLACE INTO t2 SET id2 = 1, val2 = 'a' RETURNING id1; +--error ER_INVALID_GROUP_FUNC_USE +REPLACE INTO t2 SET id2 = 2, val2 = 'b' RETURNING COUNT(id2); +--error ER_SUBQUERY_NO_1_ROW +REPLACE INTO t2 SET id2 = 3, val2 = 'c' RETURNING(SELECT id1 FROM t1); +--error ER_OPERAND_COLUMNS +REPLACE INTO t2 SET id2 = 4, val2 = 'd' RETURNING(SELECT * FROM t1); +--error ER_OPERAND_COLUMNS +REPLACE INTO t2 SET id2 = 4, val2 = 'd' RETURNING(SELECT * FROM t2); +--error ER_UPDATE_TABLE_USED +REPLACE INTO t2 SET id2 = 5, val2 = 'f' RETURNING(SELECT id2 FROM t2); + +--echo # +--echo # REPLACE...SELECT +--echo # +--error ER_BAD_FIELD_ERROR +REPLACE INTO t2(id2, val2) SELECT* FROM t1 WHERE id1 = 1 RETURNING id1; +--error ER_INVALID_GROUP_FUNC_USE +REPLACE INTO t2(id2, val2) SELECT* FROM t1 WHERE id1 = 2 RETURNING MAX(id2); +--error ER_SUBQUERY_NO_1_ROW +REPLACE INTO t2(id2, val2) SELECT* FROM t1 WHERE id1 = 2 RETURNING(SELECT id1 +FROM t1); +--error ER_OPERAND_COLUMNS +REPLACE INTO t2(id2, val2) SELECT* FROM t1 WHERE id1 = 2 RETURNING(SELECT * +FROM t1); +--error ER_OPERAND_COLUMNS +REPLACE INTO t2(id2, val2) SELECT* FROM t1 WHERE id1 = 2 RETURNING(SELECT * +FROM t2); +--error ER_SUBQUERY_NO_1_ROW +REPLACE INTO t2(id2, val2) SELECT* FROM t1 WHERE id1 = 2 RETURNING(SELECT id2 +FROM t2); + +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/main/require_secure_transport-master.opt b/mysql-test/main/require_secure_transport-master.opt new file mode 100644 index 00000000000..0a25b054d71 --- /dev/null +++ b/mysql-test/main/require_secure_transport-master.opt @@ -0,0 +1 @@ +--require-secure-transport=0 diff --git a/mysql-test/main/require_secure_transport.result b/mysql-test/main/require_secure_transport.result new file mode 100644 index 00000000000..c9df2f90b45 --- /dev/null +++ b/mysql-test/main/require_secure_transport.result @@ -0,0 +1,8 @@ +CREATE TABLE t1 (t int(1)); +SET GLOBAL require_secure_transport=ON; +ERROR 28000: Access denied for user 'root'@'localhost' (using password: NO) +connection default; +SET GLOBAL require_secure_transport=OFF; +disconnect without_ssl; +connection default; +DROP TABLE t1; diff --git a/mysql-test/main/require_secure_transport.test b/mysql-test/main/require_secure_transport.test new file mode 100644 index 00000000000..ce62e7d5492 --- /dev/null +++ b/mysql-test/main/require_secure_transport.test @@ -0,0 +1,15 @@ +-- source include/have_ssl_communication.inc +CREATE TABLE t1 (t int(1)); +SET GLOBAL require_secure_transport=ON; +--disable_query_log +--error ER_ACCESS_DENIED_ERROR +connect without_ssl,localhost,root,,,,,TCP NOSSL; +--enable_query_log +connection default; +SET GLOBAL require_secure_transport=OFF; +--disable_query_log +connect without_ssl,localhost,root,,,,,TCP NOSSL; +--enable_query_log +disconnect without_ssl; +connection default; +DROP TABLE t1; diff --git a/mysql-test/main/row.result b/mysql-test/main/row.result index 40d3e2640f0..12ab4208c11 100644 --- a/mysql-test/main/row.result +++ b/mysql-test/main/row.result @@ -545,3 +545,16 @@ SELECT (1,null) NOT IN ((2,2),(3,3)), (1,null) NOT IN ((2,2)), (1,null) NOT IN ( # # End of 10.1 tests # +# +# Start of 10.5 tests +# +# +# MDEV-20809 EXTRACT from INET6 value does not produce any warnings +# +CREATE TABLE t1 (a GEOMETRY); +SELECT EXTRACT(DAY FROM a) FROM t1; +ERROR HY000: Illegal parameter data type geometry for operation 'extract(day)' +DROP TABLE t1; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/row.test b/mysql-test/main/row.test index 80c61c414bf..d78d61b078a 100644 --- a/mysql-test/main/row.test +++ b/mysql-test/main/row.test @@ -314,3 +314,21 @@ SELECT (1,null) NOT IN ((2,2),(3,3)), (1,null) NOT IN ((2,2)), (1,null) NOT IN ( --echo # --echo # End of 10.1 tests --echo # + + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-20809 EXTRACT from INET6 value does not produce any warnings +--echo # + +CREATE TABLE t1 (a GEOMETRY); +--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION +SELECT EXTRACT(DAY FROM a) FROM t1; +DROP TABLE t1; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/rowid_filter.result b/mysql-test/main/rowid_filter.result index b1660a8aba3..376cb63944a 100644 --- a/mysql-test/main/rowid_filter.result +++ b/mysql-test/main/rowid_filter.result @@ -90,10 +90,10 @@ EXPLAIN "used_key_parts": ["l_quantity"] }, "rows": 702, - "selectivity_pct": 11.69 + "selectivity_pct": 11.69025812 }, "rows": 509, - "filtered": 11.69, + "filtered": 11.69025803, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", "attached_condition": "lineitem.l_quantity > 45" } @@ -126,17 +126,18 @@ ANALYZE "used_key_parts": ["l_quantity"] }, "rows": 702, - "selectivity_pct": 11.69, + "selectivity_pct": 11.69025812, "r_rows": 605, - "r_selectivity_pct": 11.765, + "r_selectivity_pct": 11.76470588, "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, "r_loops": 1, "rows": 509, "r_rows": 60, - "r_total_time_ms": "REPLACED", - "filtered": 11.69, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 11.69025803, "r_filtered": 100, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", "attached_condition": "lineitem.l_quantity > 45" @@ -227,7 +228,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_shipDATE"], "rows": 509, - "filtered": 11.69, + "filtered": 11.69025803, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", "attached_condition": "lineitem.l_quantity > 45" } @@ -257,9 +258,10 @@ ANALYZE "r_loops": 1, "rows": 509, "r_rows": 510, - "r_total_time_ms": "REPLACED", - "filtered": 11.69, - "r_filtered": 11.765, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 11.69025803, + "r_filtered": 11.76470588, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", "attached_condition": "lineitem.l_quantity > 45" } @@ -377,7 +379,7 @@ EXPLAIN "selectivity_pct": 4.6 }, "rows": 1, - "filtered": 4.6, + "filtered": 4.599999905, "attached_condition": "orders.o_totalprice between 200000 and 230000" } } @@ -414,7 +416,8 @@ ANALYZE "r_loops": 1, "rows": 98, "r_rows": 98, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'" @@ -435,15 +438,16 @@ ANALYZE "rows": 69, "selectivity_pct": 4.6, "r_rows": 71, - "r_selectivity_pct": 10.417, + "r_selectivity_pct": 10.41666667, "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, "r_loops": 98, "rows": 1, - "r_rows": 0.1122, - "r_total_time_ms": "REPLACED", - "filtered": 4.6, + "r_rows": 0.112244898, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 4.599999905, "r_filtered": 100, "attached_condition": "orders.o_totalprice between 200000 and 230000" } @@ -505,7 +509,7 @@ EXPLAIN "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], "rows": 1, - "filtered": 4.6, + "filtered": 4.599999905, "attached_condition": "orders.o_totalprice between 200000 and 230000" } } @@ -542,7 +546,8 @@ ANALYZE "r_loops": 1, "rows": 98, "r_rows": 98, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'" @@ -558,9 +563,10 @@ ANALYZE "r_loops": 98, "rows": 1, "r_rows": 1, - "r_total_time_ms": "REPLACED", - "filtered": 4.6, - "r_filtered": 11.224, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 4.599999905, + "r_filtered": 11.2244898, "attached_condition": "orders.o_totalprice between 200000 and 230000" } } @@ -617,10 +623,10 @@ EXPLAIN "used_key_parts": ["l_quantity"] }, "rows": 702, - "selectivity_pct": 11.69 + "selectivity_pct": 11.69025812 }, "rows": 509, - "filtered": 11.69, + "filtered": 11.69025803, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", "attached_condition": "lineitem.l_quantity > 45" }, @@ -638,10 +644,10 @@ EXPLAIN "used_key_parts": ["o_totalprice"] }, "rows": 139, - "selectivity_pct": 9.2667 + "selectivity_pct": 9.266666667 }, "rows": 1, - "filtered": 9.2667, + "filtered": 9.266666412, "attached_condition": "orders.o_totalprice between 180000 and 230000" } } @@ -684,17 +690,18 @@ ANALYZE "used_key_parts": ["l_quantity"] }, "rows": 702, - "selectivity_pct": 11.69, + "selectivity_pct": 11.69025812, "r_rows": 605, - "r_selectivity_pct": 11.765, + "r_selectivity_pct": 11.76470588, "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, "r_loops": 1, "rows": 509, "r_rows": 60, - "r_total_time_ms": "REPLACED", - "filtered": 11.69, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 11.69025803, "r_filtered": 100, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", "attached_condition": "lineitem.l_quantity > 45" @@ -713,17 +720,18 @@ ANALYZE "used_key_parts": ["o_totalprice"] }, "rows": 139, - "selectivity_pct": 9.2667, + "selectivity_pct": 9.266666667, "r_rows": 144, - "r_selectivity_pct": 25.424, + "r_selectivity_pct": 25.42372881, "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, "r_loops": 60, "rows": 1, - "r_rows": 0.2667, - "r_total_time_ms": "REPLACED", - "filtered": 9.2667, + "r_rows": 0.266666667, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 9.266666412, "r_filtered": 100, "attached_condition": "orders.o_totalprice between 180000 and 230000" } @@ -782,7 +790,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_shipDATE"], "rows": 509, - "filtered": 11.69, + "filtered": 11.69025803, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", "attached_condition": "lineitem.l_quantity > 45" }, @@ -795,7 +803,7 @@ EXPLAIN "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], "rows": 1, - "filtered": 9.2667, + "filtered": 9.266666412, "attached_condition": "orders.o_totalprice between 180000 and 230000" } } @@ -835,9 +843,10 @@ ANALYZE "r_loops": 1, "rows": 509, "r_rows": 510, - "r_total_time_ms": "REPLACED", - "filtered": 11.69, - "r_filtered": 11.765, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 11.69025803, + "r_filtered": 11.76470588, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", "attached_condition": "lineitem.l_quantity > 45" }, @@ -852,9 +861,10 @@ ANALYZE "r_loops": 60, "rows": 1, "r_rows": 1, - "r_total_time_ms": "REPLACED", - "filtered": 9.2667, - "r_filtered": 26.667, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 9.266666412, + "r_filtered": 26.66666667, "attached_condition": "orders.o_totalprice between 180000 and 230000" } } @@ -887,7 +897,7 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND o_totalprice between 200000 and 230000; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 69 Using index condition -1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (8%) Using where; Using rowid filter +1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (8%) Using where; Using rowid filter set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND @@ -916,7 +926,7 @@ EXPLAIN "i_l_orderkey", "i_l_orderkey_quantity" ], - "key": "PRIMARY", + "key": "i_l_orderkey", "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], @@ -926,10 +936,10 @@ EXPLAIN "used_key_parts": ["l_shipDATE"] }, "rows": 509, - "selectivity_pct": 8.4763 + "selectivity_pct": 8.476269775 }, "rows": 4, - "filtered": 8.4763, + "filtered": 8.476269722, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } } @@ -940,7 +950,7 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND o_totalprice between 200000 and 230000; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra 1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 69 71.00 100.00 100.00 Using index condition -1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (8%) 0.52 (7%) 8.48 100.00 Using where; Using rowid filter +1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (8%) 0.52 (7%) 8.48 100.00 Using where; Using rowid filter set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND @@ -961,7 +971,8 @@ ANALYZE "r_loops": 1, "rows": 69, "r_rows": 71, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "index_condition": "orders.o_totalprice between 200000 and 230000" @@ -975,7 +986,7 @@ ANALYZE "i_l_orderkey", "i_l_orderkey_quantity" ], - "key": "PRIMARY", + "key": "i_l_orderkey", "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], @@ -985,17 +996,18 @@ ANALYZE "used_key_parts": ["l_shipDATE"] }, "rows": 509, - "selectivity_pct": 8.4763, + "selectivity_pct": 8.476269775, "r_rows": 510, - "r_selectivity_pct": 7.7731, + "r_selectivity_pct": 7.773109244, "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, "r_loops": 71, "rows": 4, - "r_rows": 0.5211, - "r_total_time_ms": "REPLACED", - "filtered": 8.4763, + "r_rows": 0.521126761, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 8.476269722, "r_filtered": 100, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } @@ -1049,7 +1061,7 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND o_totalprice between 200000 and 230000; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 69 Using index condition -1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 Using where set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND @@ -1078,12 +1090,12 @@ EXPLAIN "i_l_orderkey", "i_l_orderkey_quantity" ], - "key": "PRIMARY", + "key": "i_l_orderkey", "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "rows": 4, - "filtered": 8.4763, + "filtered": 8.476269722, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } } @@ -1094,7 +1106,7 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND o_totalprice between 200000 and 230000; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra 1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 69 71.00 100.00 100.00 Using index condition -1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.70 8.48 7.77 Using where +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 6.70 8.48 7.77 Using where set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND @@ -1115,7 +1127,8 @@ ANALYZE "r_loops": 1, "rows": 69, "r_rows": 71, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "index_condition": "orders.o_totalprice between 200000 and 230000" @@ -1129,16 +1142,17 @@ ANALYZE "i_l_orderkey", "i_l_orderkey_quantity" ], - "key": "PRIMARY", + "key": "i_l_orderkey", "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "r_loops": 71, "rows": 4, - "r_rows": 6.7042, - "r_total_time_ms": "REPLACED", - "filtered": 8.4763, - "r_filtered": 7.7731, + "r_rows": 6.704225352, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 8.476269722, + "r_filtered": 7.773109244, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } } @@ -1225,7 +1239,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_receiptDATE"], "rows": 18, - "filtered": 0.5662, + "filtered": 0.566194832, "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" }, @@ -1238,7 +1252,7 @@ EXPLAIN "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], "rows": 1, - "filtered": 7.4667, + "filtered": 7.466666698, "attached_condition": "orders.o_totalprice between 200000 and 250000" } } @@ -1280,9 +1294,10 @@ ANALYZE "r_loops": 1, "rows": 18, "r_rows": 18, - "r_total_time_ms": "REPLACED", - "filtered": 0.5662, - "r_filtered": 38.889, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 0.566194832, + "r_filtered": 38.88888889, "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" }, @@ -1297,9 +1312,10 @@ ANALYZE "r_loops": 7, "rows": 1, "r_rows": 1, - "r_total_time_ms": "REPLACED", - "filtered": 7.4667, - "r_filtered": 14.286, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 7.466666698, + "r_filtered": 14.28571429, "attached_condition": "orders.o_totalprice between 200000 and 250000" } } @@ -1345,7 +1361,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_receiptDATE"], "rows": 18, - "filtered": 0.5662, + "filtered": 0.566194832, "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" }, @@ -1358,7 +1374,7 @@ EXPLAIN "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], "rows": 1, - "filtered": 7.4667, + "filtered": 7.466666698, "attached_condition": "orders.o_totalprice between 200000 and 250000" } } @@ -1400,9 +1416,10 @@ ANALYZE "r_loops": 1, "rows": 18, "r_rows": 18, - "r_total_time_ms": "REPLACED", - "filtered": 0.5662, - "r_filtered": 38.889, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 0.566194832, + "r_filtered": 38.88888889, "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" }, @@ -1417,9 +1434,10 @@ ANALYZE "r_loops": 7, "rows": 1, "r_rows": 1, - "r_total_time_ms": "REPLACED", - "filtered": 7.4667, - "r_filtered": 14.286, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 7.466666698, + "r_filtered": 14.28571429, "attached_condition": "orders.o_totalprice between 200000 and 250000" } } @@ -1447,7 +1465,7 @@ o_totalprice BETWEEN 200000 AND 220000 AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 Using index condition; Using where -1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 Using where set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate FROM orders, lineitem WHERE o_orderkey=l_orderkey AND @@ -1466,7 +1484,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["o_totaldiscount"], "rows": 39, - "filtered": 3.2, + "filtered": 3.200000048, "index_condition": "orders.o_totaldiscount between 18000 and 20000", "attached_condition": "orders.o_totalprice between 200000 and 220000" }, @@ -1479,12 +1497,12 @@ EXPLAIN "i_l_orderkey", "i_l_orderkey_quantity" ], - "key": "PRIMARY", + "key": "i_l_orderkey", "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "rows": 4, - "filtered": 3.0475, + "filtered": 3.047460556, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } } @@ -1497,7 +1515,7 @@ o_totalprice BETWEEN 200000 AND 220000 AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra 1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 41.00 3.20 2.44 Using index condition; Using where -1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.00 3.05 66.67 Using where +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 6.00 3.05 66.67 Using where set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate FROM orders, lineitem WHERE o_orderkey=l_orderkey AND @@ -1520,9 +1538,10 @@ ANALYZE "r_loops": 1, "rows": 39, "r_rows": 41, - "r_total_time_ms": "REPLACED", - "filtered": 3.2, - "r_filtered": 2.439, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 3.200000048, + "r_filtered": 2.43902439, "index_condition": "orders.o_totaldiscount between 18000 and 20000", "attached_condition": "orders.o_totalprice between 200000 and 220000" }, @@ -1535,16 +1554,17 @@ ANALYZE "i_l_orderkey", "i_l_orderkey_quantity" ], - "key": "PRIMARY", + "key": "i_l_orderkey", "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "r_loops": 1, "rows": 4, "r_rows": 6, - "r_total_time_ms": "REPLACED", - "filtered": 3.0475, - "r_filtered": 66.667, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 3.047460556, + "r_filtered": 66.66666667, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } } @@ -1568,7 +1588,7 @@ o_totalprice BETWEEN 200000 AND 220000 AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 Using index condition; Using where -1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 Using where set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate FROM orders, lineitem WHERE o_orderkey=l_orderkey AND @@ -1587,7 +1607,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["o_totaldiscount"], "rows": 39, - "filtered": 3.2, + "filtered": 3.200000048, "index_condition": "orders.o_totaldiscount between 18000 and 20000", "attached_condition": "orders.o_totalprice between 200000 and 220000" }, @@ -1600,12 +1620,12 @@ EXPLAIN "i_l_orderkey", "i_l_orderkey_quantity" ], - "key": "PRIMARY", + "key": "i_l_orderkey", "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "rows": 4, - "filtered": 3.0475, + "filtered": 3.047460556, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } } @@ -1618,7 +1638,7 @@ o_totalprice BETWEEN 200000 AND 220000 AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra 1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 41.00 3.20 2.44 Using index condition; Using where -1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.00 3.05 66.67 Using where +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 6.00 3.05 66.67 Using where set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate FROM orders, lineitem WHERE o_orderkey=l_orderkey AND @@ -1641,9 +1661,10 @@ ANALYZE "r_loops": 1, "rows": 39, "r_rows": 41, - "r_total_time_ms": "REPLACED", - "filtered": 3.2, - "r_filtered": 2.439, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 3.200000048, + "r_filtered": 2.43902439, "index_condition": "orders.o_totaldiscount between 18000 and 20000", "attached_condition": "orders.o_totalprice between 200000 and 220000" }, @@ -1656,16 +1677,17 @@ ANALYZE "i_l_orderkey", "i_l_orderkey_quantity" ], - "key": "PRIMARY", + "key": "i_l_orderkey", "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "r_loops": 1, "rows": 4, "r_rows": 6, - "r_total_time_ms": "REPLACED", - "filtered": 3.0475, - "r_filtered": 66.667, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 3.047460556, + "r_filtered": 66.66666667, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } } @@ -1692,7 +1714,7 @@ o_totalprice BETWEEN 200000 AND 220000 AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE orders range PRIMARY,i_o_orderdate,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 Using index condition; Using where -1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 Using where set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate FROM v1, lineitem WHERE o_orderkey=l_orderkey AND @@ -1729,7 +1751,7 @@ EXPLAIN "i_l_orderkey", "i_l_orderkey_quantity" ], - "key": "PRIMARY", + "key": "i_l_orderkey", "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], @@ -1747,7 +1769,7 @@ o_totalprice BETWEEN 200000 AND 220000 AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra 1 SIMPLE orders range PRIMARY,i_o_orderdate,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 41.00 # 2.44 Using index condition; Using where -1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.00 # 66.67 Using where +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 6.00 # 66.67 Using where set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate FROM v1, lineitem WHERE o_orderkey=l_orderkey AND @@ -1775,9 +1797,10 @@ ANALYZE "r_loops": 1, "rows": 39, "r_rows": 41, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": "REPLACED", - "r_filtered": 2.439, + "r_filtered": 2.43902439, "index_condition": "orders.o_totaldiscount between 18000 and 20000", "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" }, @@ -1790,16 +1813,17 @@ ANALYZE "i_l_orderkey", "i_l_orderkey_quantity" ], - "key": "PRIMARY", + "key": "i_l_orderkey", "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "r_loops": 1, "rows": 4, "r_rows": 6, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": "REPLACED", - "r_filtered": 66.667, + "r_filtered": 66.66666667, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } } @@ -1823,7 +1847,7 @@ o_totalprice BETWEEN 200000 AND 220000 AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE orders range PRIMARY,i_o_orderdate,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 Using index condition; Using where -1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 Using where set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate FROM v1, lineitem WHERE o_orderkey=l_orderkey AND @@ -1860,7 +1884,7 @@ EXPLAIN "i_l_orderkey", "i_l_orderkey_quantity" ], - "key": "PRIMARY", + "key": "i_l_orderkey", "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], @@ -1878,7 +1902,7 @@ o_totalprice BETWEEN 200000 AND 220000 AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra 1 SIMPLE orders range PRIMARY,i_o_orderdate,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 41.00 # 2.44 Using index condition; Using where -1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.00 # 66.67 Using where +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 6.00 # 66.67 Using where set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate FROM v1, lineitem WHERE o_orderkey=l_orderkey AND @@ -1906,9 +1930,10 @@ ANALYZE "r_loops": 1, "rows": 39, "r_rows": 41, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": "REPLACED", - "r_filtered": 2.439, + "r_filtered": 2.43902439, "index_condition": "orders.o_totaldiscount between 18000 and 20000", "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" }, @@ -1921,16 +1946,17 @@ ANALYZE "i_l_orderkey", "i_l_orderkey_quantity" ], - "key": "PRIMARY", + "key": "i_l_orderkey", "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "r_loops": 1, "rows": 4, "r_rows": 6, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": "REPLACED", - "r_filtered": 66.667, + "r_filtered": 66.66666667, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } } diff --git a/mysql-test/main/rowid_filter.test b/mysql-test/main/rowid_filter.test index a68c32cf0de..163b71b6153 100644 --- a/mysql-test/main/rowid_filter.test +++ b/mysql-test/main/rowid_filter.test @@ -220,7 +220,7 @@ eval $with_filter EXPLAIN $q7; eval $with_filter EXPLAIN FORMAT=JSON $q7; --replace_column 11 # eval $with_filter ANALYZE $q7; ---replace_regex /("(r_total_time_ms|r_buffer_size|r_filling_time_ms|filtered)": )[^, \n]*/\1"REPLACED"/ +--replace_regex /("(r_(total|table|other)_time_ms|r_buffer_size|r_filling_time_ms|filtered)": )[^, \n]*/\1"REPLACED"/ eval $with_filter ANALYZE FORMAT=JSON $q7; --sorted_result eval $with_filter $q7; @@ -230,7 +230,7 @@ eval $without_filter EXPLAIN $q7; eval $without_filter EXPLAIN FORMAT=JSON $q7; --replace_column 11 # eval $without_filter ANALYZE $q7; ---replace_regex /("(r_total_time_ms|r_buffer_size|r_filling_time_ms|filtered)": )[^, \n]*/\1"REPLACED"/ +--replace_regex /("(r_(total|table|other)_time_ms|r_buffer_size|r_filling_time_ms|filtered)": )[^, \n]*/\1"REPLACED"/ eval $without_filter ANALYZE FORMAT=JSON $q7; --sorted_result eval $without_filter $q7; diff --git a/mysql-test/main/rowid_filter_innodb.result b/mysql-test/main/rowid_filter_innodb.result index af7ff3210a5..ae52f9416b9 100644 --- a/mysql-test/main/rowid_filter_innodb.result +++ b/mysql-test/main/rowid_filter_innodb.result @@ -1,4 +1,4 @@ -SET SESSION STORAGE_ENGINE='InnoDB'; +SET SESSION DEFAULT_STORAGE_ENGINE='InnoDB'; DROP DATABASE IF EXISTS dbt3_s001; CREATE DATABASE dbt3_s001; use dbt3_s001; @@ -91,10 +91,10 @@ EXPLAIN "used_key_parts": ["l_quantity"] }, "rows": 605, - "selectivity_pct": 10.075 + "selectivity_pct": 10.07493755 }, "rows": 510, - "filtered": 10.075, + "filtered": 10.07493782, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", "attached_condition": "lineitem.l_quantity > 45" } @@ -127,17 +127,18 @@ ANALYZE "used_key_parts": ["l_quantity"] }, "rows": 605, - "selectivity_pct": 10.075, + "selectivity_pct": 10.07493755, "r_rows": 605, - "r_selectivity_pct": 11.765, + "r_selectivity_pct": 11.76470588, "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, "r_loops": 1, "rows": 510, "r_rows": 60, - "r_total_time_ms": "REPLACED", - "filtered": 10.075, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 10.07493782, "r_filtered": 100, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", "attached_condition": "lineitem.l_quantity > 45" @@ -228,7 +229,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_shipDATE"], "rows": 510, - "filtered": 10.075, + "filtered": 10.07493782, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", "attached_condition": "lineitem.l_quantity > 45" } @@ -258,9 +259,10 @@ ANALYZE "r_loops": 1, "rows": 510, "r_rows": 510, - "r_total_time_ms": "REPLACED", - "filtered": 10.075, - "r_filtered": 11.765, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 10.07493782, + "r_filtered": 11.76470588, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", "attached_condition": "lineitem.l_quantity > 45" } @@ -371,7 +373,7 @@ EXPLAIN "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], "rows": 1, - "filtered": 4.7333, + "filtered": 4.733333111, "attached_condition": "orders.o_totalprice between 200000 and 230000" } } @@ -408,7 +410,8 @@ ANALYZE "r_loops": 1, "rows": 98, "r_rows": 98, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'", @@ -425,9 +428,10 @@ ANALYZE "r_loops": 98, "rows": 1, "r_rows": 1, - "r_total_time_ms": "REPLACED", - "filtered": 4.7333, - "r_filtered": 11.224, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 4.733333111, + "r_filtered": 11.2244898, "attached_condition": "orders.o_totalprice between 200000 and 230000" } } @@ -489,7 +493,7 @@ EXPLAIN "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], "rows": 1, - "filtered": 4.7333, + "filtered": 4.733333111, "attached_condition": "orders.o_totalprice between 200000 and 230000" } } @@ -526,7 +530,8 @@ ANALYZE "r_loops": 1, "rows": 98, "r_rows": 98, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'", @@ -543,9 +548,10 @@ ANALYZE "r_loops": 98, "rows": 1, "r_rows": 1, - "r_total_time_ms": "REPLACED", - "filtered": 4.7333, - "r_filtered": 11.224, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 4.733333111, + "r_filtered": 11.2244898, "attached_condition": "orders.o_totalprice between 200000 and 230000" } } @@ -572,8 +578,8 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 45 AND o_totalprice between 180000 and 230000; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 144 Using where; Using index -1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where +1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 510 (10%) Using index condition; Using where; Using rowid filter +1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND @@ -584,20 +590,8 @@ EXPLAIN "query_block": { "select_id": 1, "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "i_o_totalprice", - "key_length": "9", - "used_key_parts": ["o_totalprice"], - "rows": 144, - "filtered": 100, - "attached_condition": "orders.o_totalprice between 180000 and 230000", - "using_index": true - }, - "table": { "table_name": "lineitem", - "access_type": "ref", + "access_type": "range", "possible_keys": [ "PRIMARY", "i_l_shipdate", @@ -605,13 +599,33 @@ EXPLAIN "i_l_orderkey_quantity", "i_l_quantity" ], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "rowid_filter": { + "range": { + "key": "i_l_quantity", + "used_key_parts": ["l_quantity"] + }, + "rows": 605, + "selectivity_pct": 10.07493755 + }, + "rows": 510, + "filtered": 10.07493782, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + }, + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], "key": "PRIMARY", "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "rows": 4, - "filtered": 0.8557, - "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 45" + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rows": 1, + "filtered": 9.600000381, + "attached_condition": "orders.o_totalprice between 180000 and 230000" } } } @@ -621,8 +635,8 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 45 AND o_totalprice between 180000 and 230000; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 144 144.00 100.00 100.00 Using where; Using index -1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.62 0.86 1.68 Using where +1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 510 (10%) 60.00 (11%) 10.07 100.00 Using index condition; Using where; Using rowid filter +1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 1.00 9.60 26.67 Using where set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND @@ -635,24 +649,8 @@ ANALYZE "r_loops": 1, "r_total_time_ms": "REPLACED", "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "i_o_totalprice", - "key_length": "9", - "used_key_parts": ["o_totalprice"], - "r_loops": 1, - "rows": 144, - "r_rows": 144, - "r_total_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "attached_condition": "orders.o_totalprice between 180000 and 230000", - "using_index": true - }, - "table": { "table_name": "lineitem", - "access_type": "ref", + "access_type": "range", "possible_keys": [ "PRIMARY", "i_l_shipdate", @@ -660,17 +658,47 @@ ANALYZE "i_l_orderkey_quantity", "i_l_quantity" ], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "rowid_filter": { + "range": { + "key": "i_l_quantity", + "used_key_parts": ["l_quantity"] + }, + "rows": 605, + "selectivity_pct": 10.07493755, + "r_rows": 605, + "r_selectivity_pct": 11.76470588, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, + "r_loops": 1, + "rows": 510, + "r_rows": 60, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 10.07493782, + "r_filtered": 100, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + }, + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], "key": "PRIMARY", "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "r_loops": 144, - "rows": 4, - "r_rows": 6.625, - "r_total_time_ms": "REPLACED", - "filtered": 0.8557, - "r_filtered": 1.6771, - "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 45" + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "r_loops": 60, + "rows": 1, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 9.600000381, + "r_filtered": 26.66666667, + "attached_condition": "orders.o_totalprice between 180000 and 230000" } } } @@ -740,7 +768,7 @@ EXPLAIN "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "rows": 4, - "filtered": 0.8557, + "filtered": 0.855656624, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 45" } } @@ -774,7 +802,8 @@ ANALYZE "r_loops": 1, "rows": 144, "r_rows": 144, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "attached_condition": "orders.o_totalprice between 180000 and 230000", @@ -797,9 +826,10 @@ ANALYZE "r_loops": 144, "rows": 4, "r_rows": 6.625, - "r_total_time_ms": "REPLACED", - "filtered": 0.8557, - "r_filtered": 1.6771, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 0.855656624, + "r_filtered": 1.677148847, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 45" } } @@ -867,7 +897,7 @@ EXPLAIN "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "rows": 4, - "filtered": 8.4929, + "filtered": 8.492922783, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } } @@ -899,7 +929,8 @@ ANALYZE "r_loops": 1, "rows": 71, "r_rows": 71, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "attached_condition": "orders.o_totalprice between 200000 and 230000", @@ -920,10 +951,11 @@ ANALYZE "ref": ["dbt3_s001.orders.o_orderkey"], "r_loops": 71, "rows": 4, - "r_rows": 6.7042, - "r_total_time_ms": "REPLACED", - "filtered": 8.4929, - "r_filtered": 7.7731, + "r_rows": 6.704225352, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 8.492922783, + "r_filtered": 7.773109244, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } } @@ -1011,7 +1043,7 @@ EXPLAIN "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "rows": 4, - "filtered": 8.4929, + "filtered": 8.492922783, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } } @@ -1043,7 +1075,8 @@ ANALYZE "r_loops": 1, "rows": 71, "r_rows": 71, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "attached_condition": "orders.o_totalprice between 200000 and 230000", @@ -1064,10 +1097,11 @@ ANALYZE "ref": ["dbt3_s001.orders.o_orderkey"], "r_loops": 71, "rows": 4, - "r_rows": 6.7042, - "r_total_time_ms": "REPLACED", - "filtered": 8.4929, - "r_filtered": 7.7731, + "r_rows": 6.704225352, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 8.492922783, + "r_filtered": 7.773109244, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } } @@ -1154,7 +1188,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_receiptDATE"], "rows": 18, - "filtered": 0.5662, + "filtered": 0.566194832, "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" }, @@ -1167,7 +1201,7 @@ EXPLAIN "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], "rows": 1, - "filtered": 5.6667, + "filtered": 5.666666508, "attached_condition": "orders.o_totalprice between 200000 and 250000" } } @@ -1209,9 +1243,10 @@ ANALYZE "r_loops": 1, "rows": 18, "r_rows": 18, - "r_total_time_ms": "REPLACED", - "filtered": 0.5662, - "r_filtered": 38.889, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 0.566194832, + "r_filtered": 38.88888889, "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" }, @@ -1226,9 +1261,10 @@ ANALYZE "r_loops": 7, "rows": 1, "r_rows": 1, - "r_total_time_ms": "REPLACED", - "filtered": 5.6667, - "r_filtered": 14.286, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 5.666666508, + "r_filtered": 14.28571429, "attached_condition": "orders.o_totalprice between 200000 and 250000" } } @@ -1274,7 +1310,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_receiptDATE"], "rows": 18, - "filtered": 0.5662, + "filtered": 0.566194832, "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" }, @@ -1287,7 +1323,7 @@ EXPLAIN "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], "rows": 1, - "filtered": 5.6667, + "filtered": 5.666666508, "attached_condition": "orders.o_totalprice between 200000 and 250000" } } @@ -1329,9 +1365,10 @@ ANALYZE "r_loops": 1, "rows": 18, "r_rows": 18, - "r_total_time_ms": "REPLACED", - "filtered": 0.5662, - "r_filtered": 38.889, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 0.566194832, + "r_filtered": 38.88888889, "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" }, @@ -1346,9 +1383,10 @@ ANALYZE "r_loops": 7, "rows": 1, "r_rows": 1, - "r_total_time_ms": "REPLACED", - "filtered": 5.6667, - "r_filtered": 14.286, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 5.666666508, + "r_filtered": 14.28571429, "attached_condition": "orders.o_totalprice between 200000 and 250000" } } @@ -1395,7 +1433,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["o_totaldiscount"], "rows": 41, - "filtered": 3.3333, + "filtered": 3.333333254, "index_condition": "orders.o_totaldiscount between 18000 and 20000", "attached_condition": "orders.o_totalprice between 200000 and 220000" }, @@ -1413,7 +1451,7 @@ EXPLAIN "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "rows": 4, - "filtered": 3.0475, + "filtered": 3.047460556, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } } @@ -1449,9 +1487,10 @@ ANALYZE "r_loops": 1, "rows": 41, "r_rows": 41, - "r_total_time_ms": "REPLACED", - "filtered": 3.3333, - "r_filtered": 2.439, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 3.333333254, + "r_filtered": 2.43902439, "index_condition": "orders.o_totaldiscount between 18000 and 20000", "attached_condition": "orders.o_totalprice between 200000 and 220000" }, @@ -1471,9 +1510,10 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 6, - "r_total_time_ms": "REPLACED", - "filtered": 3.0475, - "r_filtered": 66.667, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 3.047460556, + "r_filtered": 66.66666667, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } } @@ -1516,7 +1556,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["o_totaldiscount"], "rows": 41, - "filtered": 3.3333, + "filtered": 3.333333254, "index_condition": "orders.o_totaldiscount between 18000 and 20000", "attached_condition": "orders.o_totalprice between 200000 and 220000" }, @@ -1534,7 +1574,7 @@ EXPLAIN "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "rows": 4, - "filtered": 3.0475, + "filtered": 3.047460556, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } } @@ -1570,9 +1610,10 @@ ANALYZE "r_loops": 1, "rows": 41, "r_rows": 41, - "r_total_time_ms": "REPLACED", - "filtered": 3.3333, - "r_filtered": 2.439, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 3.333333254, + "r_filtered": 2.43902439, "index_condition": "orders.o_totaldiscount between 18000 and 20000", "attached_condition": "orders.o_totalprice between 200000 and 220000" }, @@ -1592,9 +1633,10 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 6, - "r_total_time_ms": "REPLACED", - "filtered": 3.0475, - "r_filtered": 66.667, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 3.047460556, + "r_filtered": 66.66666667, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } } @@ -1704,9 +1746,10 @@ ANALYZE "r_loops": 1, "rows": 41, "r_rows": 41, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": "REPLACED", - "r_filtered": 2.439, + "r_filtered": 2.43902439, "index_condition": "orders.o_totaldiscount between 18000 and 20000", "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" }, @@ -1726,9 +1769,10 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 6, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": "REPLACED", - "r_filtered": 66.667, + "r_filtered": 66.66666667, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } } @@ -1835,9 +1879,10 @@ ANALYZE "r_loops": 1, "rows": 41, "r_rows": 41, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": "REPLACED", - "r_filtered": 2.439, + "r_filtered": 2.43902439, "index_condition": "orders.o_totaldiscount between 18000 and 20000", "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" }, @@ -1857,9 +1902,10 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 6, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": "REPLACED", - "r_filtered": 66.667, + "r_filtered": 66.66666667, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } } @@ -2133,8 +2179,8 @@ union ( select * from t1 where (f1 is null and f2 is null) and (f2 between 'a' and 'z' or f1 in ('a'))); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index_merge f1,f2 f1,f2 13,33 NULL 1 Using intersect(f1,f2); Using where -2 UNION t1 index_merge f1,f2 f1,f2 13,33 NULL 1 Using intersect(f1,f2); Using where +1 PRIMARY t1 ref|filter f1,f2 f1|f1 13|13 const 1 (2%) Using index condition; Using where; Using rowid filter +2 UNION t1 ref|filter f1,f2 f1|f1 13|13 const 1 (2%) Using index condition; Using where; Using rowid filter NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL explain format=json ( select * from t1 where (f1 is null and f2 is null) and (f2 between 'a' and 'z' or f1 in ('a'))) @@ -2153,24 +2199,24 @@ EXPLAIN "select_id": 1, "table": { "table_name": "t1", - "access_type": "index_merge", + "access_type": "ref", "possible_keys": ["f1", "f2"], - "key_length": "13,33", - "index_merge": { - "intersect": { - "range": { - "key": "f1", - "used_key_parts": ["f1"] - }, - "range": { - "key": "f2", - "used_key_parts": ["f2"] - } - } + "key": "f1", + "key_length": "13", + "used_key_parts": ["f1"], + "ref": ["const"], + "rowid_filter": { + "range": { + "key": "f1", + "used_key_parts": ["f1"] + }, + "rows": 1, + "selectivity_pct": 1.587301587 }, "rows": 1, - "filtered": 1.5873, - "attached_condition": "t1.f1 is null and t1.f2 is null and (t1.f2 between 'a' and 'z' or t1.f1 = 'a')" + "filtered": 1.587301612, + "index_condition": "t1.f1 is null", + "attached_condition": "t1.f2 is null and (t1.f2 between 'a' and 'z' or t1.f1 = 'a')" } } }, @@ -2180,24 +2226,24 @@ EXPLAIN "operation": "UNION", "table": { "table_name": "t1", - "access_type": "index_merge", + "access_type": "ref", "possible_keys": ["f1", "f2"], - "key_length": "13,33", - "index_merge": { - "intersect": { - "range": { - "key": "f1", - "used_key_parts": ["f1"] - }, - "range": { - "key": "f2", - "used_key_parts": ["f2"] - } - } + "key": "f1", + "key_length": "13", + "used_key_parts": ["f1"], + "ref": ["const"], + "rowid_filter": { + "range": { + "key": "f1", + "used_key_parts": ["f1"] + }, + "rows": 1, + "selectivity_pct": 1.587301587 }, "rows": 1, - "filtered": 1.5873, - "attached_condition": "t1.f1 is null and t1.f2 is null and (t1.f2 between 'a' and 'z' or t1.f1 = 'a')" + "filtered": 1.587301612, + "index_condition": "t1.f1 is null", + "attached_condition": "t1.f2 is null and (t1.f2 between 'a' and 'z' or t1.f1 = 'a')" } } } @@ -2222,7 +2268,7 @@ id y x explain extended select * from t1 join t2 on t1.id = t2.x where t2.y = 2 and t1.id = 1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 100.00 Using index -1 SIMPLE t2 index_merge x,y y,x 5,5 NULL 1 100.00 Using intersect(y,x); Using where; Using index +1 SIMPLE t2 ref x,y y 5 const 2 100.00 Using where Warnings: Note 1003 select 1 AS `id`,`test`.`t2`.`y` AS `y`,`test`.`t2`.`x` AS `x` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`y` = 2 and `test`.`t2`.`x` = 1 drop table t1, t2; @@ -2243,17 +2289,17 @@ count(*) 6 explain extended select count(*) from t1 where a in (22,83,11) and b=2; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ref b,a b 5 const 59 3.30 Using where +1 SIMPLE t1 range b,a a 5 NULL 33 5.90 Using index condition; Using where Warnings: Note 1003 select count(0) AS `count(*)` from `test`.`t1` where `test`.`t1`.`b` = 2 and `test`.`t1`.`a` in (22,83,11) select * from t1 where a in (22,83,11) and b=2; a b 11 2 11 2 -83 2 11 2 -83 2 22 2 +83 2 +83 2 set optimizer_switch='rowid_filter=on'; select count(*) from t1 where a in (22,83,11) and b=2; count(*) @@ -2273,7 +2319,7 @@ a b 22 2 drop table t1; set optimizer_switch=@save_optimizer_switch; -SET SESSION STORAGE_ENGINE=DEFAULT; +SET SESSION DEFAULT_STORAGE_ENGINE=DEFAULT; # # MDEV-19919: use of rowid filter for innodb table + ORDER BY # @@ -2849,7 +2895,8 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 3, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100, "attached_condition": "t.tp = 121 and t.rid = 'B5FCC8C7111E4E3CBC21AAF5012F59C2'", @@ -2867,7 +2914,8 @@ ANALYZE "r_loops": 1, "rows": 1, "r_rows": 3, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 }, @@ -2893,7 +2941,7 @@ ANALYZE "used_key_parts": ["fh"] }, "rows": 6, - "selectivity_pct": 17.143, + "selectivity_pct": 17.14285714, "r_rows": 5, "r_selectivity_pct": 40, "r_buffer_size": "REPLACED", @@ -2902,8 +2950,9 @@ ANALYZE "r_loops": 1, "rows": 1, "r_rows": 2, - "r_total_time_ms": "REPLACED", - "filtered": 17.143, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 17.1428566, "r_filtered": 100 }, "buffer_type": "incremental", diff --git a/mysql-test/main/rowid_filter_innodb.test b/mysql-test/main/rowid_filter_innodb.test index 74349b8c6bb..ab65a40e89e 100644 --- a/mysql-test/main/rowid_filter_innodb.test +++ b/mysql-test/main/rowid_filter_innodb.test @@ -1,6 +1,6 @@ --source include/have_innodb.inc -SET SESSION STORAGE_ENGINE='InnoDB'; +SET SESSION DEFAULT_STORAGE_ENGINE='InnoDB'; --source rowid_filter.test --source include/have_sequence.inc @@ -95,7 +95,7 @@ eval $q1; drop table t1; set optimizer_switch=@save_optimizer_switch; -SET SESSION STORAGE_ENGINE=DEFAULT; +SET SESSION DEFAULT_STORAGE_ENGINE=DEFAULT; --echo # --echo # MDEV-19919: use of rowid filter for innodb table + ORDER BY diff --git a/mysql-test/main/rowid_order_innodb.result b/mysql-test/main/rowid_order_innodb.result index dc339304041..9b32bf6018f 100644 --- a/mysql-test/main/rowid_order_innodb.result +++ b/mysql-test/main/rowid_order_innodb.result @@ -1,4 +1,4 @@ -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; drop table if exists t1, t2, t3,t4; create table t1 ( pk1 int not NULL, diff --git a/mysql-test/main/select.result b/mysql-test/main/select.result index 0f84ed684da..7547b5b1347 100644 --- a/mysql-test/main/select.result +++ b/mysql-test/main/select.result @@ -512,7 +512,7 @@ insert into tmp select * from t3; insert into t3 select * from tmp; alter table t3 add t2nr int not null auto_increment primary key first; drop table tmp; -SET BIG_TABLES=1; +set tmp_memory_table_size=0; select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10; namn Abraham Abraham @@ -525,7 +525,7 @@ ammonium ammonium analyzable analyzable animals animals animized animized -SET BIG_TABLES=0; +set tmp_memory_table_size=default; select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10; concat(fld3," ",fld3) Abraham Abraham @@ -562,7 +562,7 @@ attendants 1 bedlam 1 bedpost 1 boasted 1 -SET BIG_TABLES=1; +set tmp_memory_table_size=0; select distinct fld3,count(*) from t2 group by companynr,fld3 limit 10; fld3 count(*) affixed 1 @@ -575,7 +575,7 @@ attendants 1 bedlam 1 bedpost 1 boasted 1 -SET BIG_TABLES=0; +set tmp_memory_table_size=default; select distinct fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr,fld3 limit 100,10; fld3 repeat("a",length(fld3)) count(*) circus aaaaaa 1 @@ -2782,10 +2782,10 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away explain select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index key1 key1 5 NULL 4 Using where; Using index +1 SIMPLE t1 range key1 key1 5 NULL 3 Using where; Using index explain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index key1 key1 5 NULL 4 Using where; Using index +1 SIMPLE t1 range key1 key1 5 NULL 3 Using where; Using index select max(key1) from t1 where key1 <= 0.6158; max(key1) 0.6158 @@ -3632,7 +3632,7 @@ t3.c IN ('bb','ee'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 range si si 5 NULL 2 Using index condition; Using where -1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where +1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using rowid filter EXPLAIN SELECT t3.a FROM t1,t2,t3 WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND @@ -3640,7 +3640,7 @@ t3.c IN ('bb','ee'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 range si,ai si 5 NULL 2 Using index condition; Using where -1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where +1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using rowid filter DROP TABLE t1,t2,t3; CREATE TABLE t1 ( f1 int primary key, f2 int, f3 int, f4 int, f5 int, f6 int, checked_out int); CREATE TABLE t2 ( f11 int PRIMARY KEY ); @@ -3717,7 +3717,7 @@ COUNT(*) EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where +1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (6%) Using where; Using rowid filter EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ; id select_type table type possible_keys key key_len ref rows Extra @@ -3731,7 +3731,7 @@ CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null); EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where +1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (7%) Using where; Using rowid filter EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ; id select_type table type possible_keys key key_len ref rows Extra @@ -4031,7 +4031,7 @@ EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2 ON ( f1.b=f2.b AND f1.a<f2.a ) WHERE 1 AND f1.b NOT IN (100,2232,3343,51111); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE f1 index inx inx 10 NULL 7 Using where; Using index +1 SIMPLE f1 range inx inx 5 NULL 7 Using where; Using index 1 SIMPLE f2 ref inx inx 5 test.f1.b 1 Using where; Using index DROP TABLE t1; CREATE TABLE t1 (c1 INT, c2 INT); @@ -5134,8 +5134,8 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t5 system PRIMARY NULL NULL NULL 1 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index 1 SIMPLE t2 ref f22 f22 5 const 1 -1 SIMPLE t6 ref f61 f61 5 const 1 Using where 1 SIMPLE t4 ref f42 f42 5 const 1 Using index +1 SIMPLE t6 ref f61 f61 5 const 1 Using where 1 SIMPLE t7 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) SELECT t2.f23 FROM (t1 LEFT JOIN (t2 JOIN t3 ON t2.f22=t3.f32) ON t1.f11=t3.f31) diff --git a/mysql-test/main/select.test b/mysql-test/main/select.test index 43984810c66..22baccc625c 100644 --- a/mysql-test/main/select.test +++ b/mysql-test/main/select.test @@ -1425,9 +1425,9 @@ drop table tmp; # big table done -SET BIG_TABLES=1; +set tmp_memory_table_size=0; # force on-disk tmp table select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10; -SET BIG_TABLES=0; +set tmp_memory_table_size=default; select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10; select distinct fld5 from t2 limit 10; @@ -1436,9 +1436,9 @@ select distinct fld5 from t2 limit 10; # select distinct fld3,count(*) from t2 group by companynr,fld3 limit 10; -SET BIG_TABLES=1; # Force use of MyISAM +set tmp_memory_table_size=0; # force on-disk tmp table select distinct fld3,count(*) from t2 group by companynr,fld3 limit 10; -SET BIG_TABLES=0; +set tmp_memory_table_size=default; select distinct fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr,fld3 limit 100,10; # diff --git a/mysql-test/main/select_jcl6.result b/mysql-test/main/select_jcl6.result index 7276814114f..6a8174d124c 100644 --- a/mysql-test/main/select_jcl6.result +++ b/mysql-test/main/select_jcl6.result @@ -523,7 +523,7 @@ insert into tmp select * from t3; insert into t3 select * from tmp; alter table t3 add t2nr int not null auto_increment primary key first; drop table tmp; -SET BIG_TABLES=1; +set tmp_memory_table_size=0; select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10; namn Abraham Abraham @@ -536,7 +536,7 @@ ammonium ammonium analyzable analyzable animals animals animized animized -SET BIG_TABLES=0; +set tmp_memory_table_size=default; select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10; concat(fld3," ",fld3) Abraham Abraham @@ -573,7 +573,7 @@ attendants 1 bedlam 1 bedpost 1 boasted 1 -SET BIG_TABLES=1; +set tmp_memory_table_size=0; select distinct fld3,count(*) from t2 group by companynr,fld3 limit 10; fld3 count(*) affixed 1 @@ -586,7 +586,7 @@ attendants 1 bedlam 1 bedpost 1 boasted 1 -SET BIG_TABLES=0; +set tmp_memory_table_size=default; select distinct fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr,fld3 limit 100,10; fld3 repeat("a",length(fld3)) count(*) circus aaaaaa 1 @@ -2793,10 +2793,10 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away explain select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index key1 key1 5 NULL 4 Using where; Using index +1 SIMPLE t1 range key1 key1 5 NULL 3 Using where; Using index explain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index key1 key1 5 NULL 4 Using where; Using index +1 SIMPLE t1 range key1 key1 5 NULL 3 Using where; Using index select max(key1) from t1 where key1 <= 0.6158; max(key1) 0.6158 @@ -3643,7 +3643,7 @@ t3.c IN ('bb','ee'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 range si si 5 NULL 2 Using index condition; Using where; Rowid-ordered scan -1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan; Using rowid filter EXPLAIN SELECT t3.a FROM t1,t2,t3 WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND @@ -3651,7 +3651,7 @@ t3.c IN ('bb','ee'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 range si,ai si 5 NULL 2 Using index condition; Using where; Rowid-ordered scan -1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan; Using rowid filter DROP TABLE t1,t2,t3; CREATE TABLE t1 ( f1 int primary key, f2 int, f3 int, f4 int, f5 int, f6 int, checked_out int); CREATE TABLE t2 ( f11 int PRIMARY KEY ); @@ -3728,7 +3728,7 @@ COUNT(*) EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where +1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (6%) Using where; Using rowid filter EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ; id select_type table type possible_keys key key_len ref rows Extra @@ -3742,7 +3742,7 @@ CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null); EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where +1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (7%) Using where; Using rowid filter EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ; id select_type table type possible_keys key key_len ref rows Extra @@ -4042,7 +4042,7 @@ EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2 ON ( f1.b=f2.b AND f1.a<f2.a ) WHERE 1 AND f1.b NOT IN (100,2232,3343,51111); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE f1 index inx inx 10 NULL 7 Using where; Using index +1 SIMPLE f1 range inx inx 5 NULL 7 Using where; Using index 1 SIMPLE f2 ref inx inx 5 test.f1.b 1 Using where; Using index DROP TABLE t1; CREATE TABLE t1 (c1 INT, c2 INT); @@ -5145,9 +5145,9 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t5 system PRIMARY NULL NULL NULL 1 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index 1 SIMPLE t2 ref f22 f22 5 const 1 -1 SIMPLE t6 ref f61 f61 5 const 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t4 ref f42 f42 5 const 1 Using index -1 SIMPLE t7 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t6 ref f61 f61 5 const 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t7 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join) SELECT t2.f23 FROM (t1 LEFT JOIN (t2 JOIN t3 ON t2.f22=t3.f32) ON t1.f11=t3.f31) LEFT JOIN diff --git a/mysql-test/main/select_pkeycache.result b/mysql-test/main/select_pkeycache.result index 0f84ed684da..7547b5b1347 100644 --- a/mysql-test/main/select_pkeycache.result +++ b/mysql-test/main/select_pkeycache.result @@ -512,7 +512,7 @@ insert into tmp select * from t3; insert into t3 select * from tmp; alter table t3 add t2nr int not null auto_increment primary key first; drop table tmp; -SET BIG_TABLES=1; +set tmp_memory_table_size=0; select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10; namn Abraham Abraham @@ -525,7 +525,7 @@ ammonium ammonium analyzable analyzable animals animals animized animized -SET BIG_TABLES=0; +set tmp_memory_table_size=default; select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10; concat(fld3," ",fld3) Abraham Abraham @@ -562,7 +562,7 @@ attendants 1 bedlam 1 bedpost 1 boasted 1 -SET BIG_TABLES=1; +set tmp_memory_table_size=0; select distinct fld3,count(*) from t2 group by companynr,fld3 limit 10; fld3 count(*) affixed 1 @@ -575,7 +575,7 @@ attendants 1 bedlam 1 bedpost 1 boasted 1 -SET BIG_TABLES=0; +set tmp_memory_table_size=default; select distinct fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr,fld3 limit 100,10; fld3 repeat("a",length(fld3)) count(*) circus aaaaaa 1 @@ -2782,10 +2782,10 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away explain select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index key1 key1 5 NULL 4 Using where; Using index +1 SIMPLE t1 range key1 key1 5 NULL 3 Using where; Using index explain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index key1 key1 5 NULL 4 Using where; Using index +1 SIMPLE t1 range key1 key1 5 NULL 3 Using where; Using index select max(key1) from t1 where key1 <= 0.6158; max(key1) 0.6158 @@ -3632,7 +3632,7 @@ t3.c IN ('bb','ee'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 range si si 5 NULL 2 Using index condition; Using where -1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where +1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using rowid filter EXPLAIN SELECT t3.a FROM t1,t2,t3 WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND @@ -3640,7 +3640,7 @@ t3.c IN ('bb','ee'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 range si,ai si 5 NULL 2 Using index condition; Using where -1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where +1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using rowid filter DROP TABLE t1,t2,t3; CREATE TABLE t1 ( f1 int primary key, f2 int, f3 int, f4 int, f5 int, f6 int, checked_out int); CREATE TABLE t2 ( f11 int PRIMARY KEY ); @@ -3717,7 +3717,7 @@ COUNT(*) EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where +1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (6%) Using where; Using rowid filter EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ; id select_type table type possible_keys key key_len ref rows Extra @@ -3731,7 +3731,7 @@ CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null); EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where +1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (7%) Using where; Using rowid filter EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ; id select_type table type possible_keys key key_len ref rows Extra @@ -4031,7 +4031,7 @@ EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2 ON ( f1.b=f2.b AND f1.a<f2.a ) WHERE 1 AND f1.b NOT IN (100,2232,3343,51111); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE f1 index inx inx 10 NULL 7 Using where; Using index +1 SIMPLE f1 range inx inx 5 NULL 7 Using where; Using index 1 SIMPLE f2 ref inx inx 5 test.f1.b 1 Using where; Using index DROP TABLE t1; CREATE TABLE t1 (c1 INT, c2 INT); @@ -5134,8 +5134,8 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t5 system PRIMARY NULL NULL NULL 1 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index 1 SIMPLE t2 ref f22 f22 5 const 1 -1 SIMPLE t6 ref f61 f61 5 const 1 Using where 1 SIMPLE t4 ref f42 f42 5 const 1 Using index +1 SIMPLE t6 ref f61 f61 5 const 1 Using where 1 SIMPLE t7 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) SELECT t2.f23 FROM (t1 LEFT JOIN (t2 JOIN t3 ON t2.f22=t3.f32) ON t1.f11=t3.f31) diff --git a/mysql-test/main/selectivity.result b/mysql-test/main/selectivity.result index 7e3202337ec..40ab309fffd 100644 --- a/mysql-test/main/selectivity.result +++ b/mysql-test/main/selectivity.result @@ -73,12 +73,12 @@ order by s_acctbal desc, n_name, s_name, p_partkey; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 0.31 Using where; Using temporary; Using filesort -1 PRIMARY partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 4 dbt3_s001.part.p_partkey 3 100.00 Using where +1 PRIMARY partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_partkey 4 dbt3_s001.part.p_partkey 3 100.00 Using where 1 PRIMARY supplier eq_ref PRIMARY,i_s_nationkey PRIMARY 4 dbt3_s001.partsupp.ps_suppkey 1 100.00 Using where 1 PRIMARY nation eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 100.00 Using where 1 PRIMARY region eq_ref PRIMARY PRIMARY 4 dbt3_s001.nation.n_regionkey 1 20.00 Using where 2 DEPENDENT SUBQUERY region ALL PRIMARY NULL NULL NULL 5 20.00 Using where -2 DEPENDENT SUBQUERY partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 4 dbt3_s001.part.p_partkey 3 100.00 +2 DEPENDENT SUBQUERY partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_partkey 4 dbt3_s001.part.p_partkey 3 100.00 2 DEPENDENT SUBQUERY supplier eq_ref PRIMARY,i_s_nationkey PRIMARY 4 dbt3_s001.partsupp.ps_suppkey 1 100.00 Using where 2 DEPENDENT SUBQUERY nation eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 100.00 Using where Warnings: @@ -119,7 +119,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 2.08 Using where; Using join buffer (flat, BNL join) 1 PRIMARY partsupp eq_ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 8 dbt3_s001.part.p_partkey,dbt3_s001.supplier.s_suppkey 1 100.00 Using where 2 DEPENDENT SUBQUERY region ALL PRIMARY NULL NULL NULL 5 20.00 Using where -2 DEPENDENT SUBQUERY partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 4 dbt3_s001.part.p_partkey 3 100.00 +2 DEPENDENT SUBQUERY partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_partkey 4 dbt3_s001.part.p_partkey 3 100.00 2 DEPENDENT SUBQUERY supplier eq_ref PRIMARY,i_s_nationkey PRIMARY 4 dbt3_s001.partsupp.ps_suppkey 1 100.00 Using where 2 DEPENDENT SUBQUERY nation eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 100.00 Using where Warnings: @@ -489,7 +489,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00 1 PRIMARY nation eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 100.00 Using where 2 MATERIALIZED part ALL PRIMARY NULL NULL NULL 200 100.00 Using where -2 MATERIALIZED partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 4 dbt3_s001.part.p_partkey 3 100.00 Using where +2 MATERIALIZED partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_partkey 4 dbt3_s001.part.p_partkey 3 100.00 Using where 4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 100.00 Using where Warnings: Note 1276 Field or reference 'dbt3_s001.partsupp.ps_partkey' of SELECT #4 was resolved in SELECT #2 @@ -1850,7 +1850,7 @@ WHERE A.a=t1.a AND t2.b < 20); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 100 Using where 2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1 -2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where +2 DEPENDENT SUBQUERY t2 ref|filter a,b a|b 5|5 test.A.id 1 (10%) Using where; Using rowid filter EXPLAIN SELECT * FROM t1 A, t1 B WHERE A.a = B.a and A.id = 65; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE A const PRIMARY,a PRIMARY 4 const 1 @@ -1862,7 +1862,7 @@ WHERE A.a=t1.a AND t2.b < 20); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 100 Using where 2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1 -2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where +2 DEPENDENT SUBQUERY t2 ref|filter a,b a|b 5|5 test.A.id 1 (10%) Using where; Using rowid filter set optimizer_switch= @save_optimizer_switch; set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; drop table t1,t2; diff --git a/mysql-test/main/selectivity_innodb.result b/mysql-test/main/selectivity_innodb.result index 2159989597a..a1d227a9baa 100644 --- a/mysql-test/main/selectivity_innodb.result +++ b/mysql-test/main/selectivity_innodb.result @@ -1,4 +1,4 @@ -SET SESSION STORAGE_ENGINE='InnoDB'; +SET SESSION DEFAULT_STORAGE_ENGINE='InnoDB'; set @save_optimizer_switch_for_selectivity_test=@@optimizer_switch; set optimizer_switch='extended_keys=on'; drop table if exists t0,t1,t2,t3; @@ -1860,7 +1860,7 @@ WHERE A.a=t1.a AND t2.b < 20); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index NULL a 5 NULL 100 Using where; Using index 2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1 Using index -2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where +2 DEPENDENT SUBQUERY t2 ref|filter a,b a|b 5|5 test.A.id 1 (19%) Using where; Using rowid filter EXPLAIN SELECT * FROM t1 A, t1 B WHERE A.a = B.a and A.id = 65; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE A const PRIMARY,a PRIMARY 4 const 1 @@ -1872,7 +1872,7 @@ WHERE A.a=t1.a AND t2.b < 20); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index NULL a 5 NULL 100 Using where; Using index 2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1 Using index -2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where +2 DEPENDENT SUBQUERY t2 ref|filter a,b a|b 5|5 test.A.id 1 (19%) Using where; Using rowid filter set optimizer_switch= @save_optimizer_switch; set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; drop table t1,t2; @@ -2152,4 +2152,4 @@ drop table t1; set use_stat_tables= @tmp_ust; set optimizer_use_condition_selectivity= @tmp_oucs; set @@global.histogram_size=@save_histogram_size; -SET SESSION STORAGE_ENGINE=DEFAULT; +SET SESSION DEFAULT_STORAGE_ENGINE=DEFAULT; diff --git a/mysql-test/main/selectivity_innodb.test b/mysql-test/main/selectivity_innodb.test index 057a36fcf62..4bcdb5d6ec9 100644 --- a/mysql-test/main/selectivity_innodb.test +++ b/mysql-test/main/selectivity_innodb.test @@ -3,7 +3,7 @@ --source include/big_test.inc --source include/default_optimizer_switch.inc -SET SESSION STORAGE_ENGINE='InnoDB'; +SET SESSION DEFAULT_STORAGE_ENGINE='InnoDB'; set @save_optimizer_switch_for_selectivity_test=@@optimizer_switch; set optimizer_switch='extended_keys=on'; @@ -232,4 +232,4 @@ drop table t1; set use_stat_tables= @tmp_ust; set optimizer_use_condition_selectivity= @tmp_oucs; set @@global.histogram_size=@save_histogram_size; -SET SESSION STORAGE_ENGINE=DEFAULT; +SET SESSION DEFAULT_STORAGE_ENGINE=DEFAULT; diff --git a/mysql-test/main/set_operation.result b/mysql-test/main/set_operation.result new file mode 100644 index 00000000000..24d2c7fbdd6 --- /dev/null +++ b/mysql-test/main/set_operation.result @@ -0,0 +1,1191 @@ +create table t1 (a int, b int) engine=MyISAM; +create table t2 (c int, d int) engine=MyISAM; +create table t3 (e int, f int) engine=MyISAM; +create table t4 (g int, h int) engine=MyISAM; +insert into t1 values (1,1),(2,2),(3,3),(2,2),(3,3); +insert into t2 values (2,2),(3,3),(5,5),(2,2),(2,2),(3,3); +insert into t3 values (4,4),(2,2),(2,2),(1,1),(3,3); +insert into t4 values (2,2),(4,4),(1,1); +create view v0(g, h) as select a,c from t1,t2; +# test optimization +select * from t1 +INTERSECT ALL +select * from t2 +INTERSECT ALL +select * from t3; +a b +2 2 +2 2 +3 3 +EXPLAIN EXTENDED select * from t1 +INTERSECT ALL +select * from t2 +INTERSECT ALL +select * from t3; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00 +2 INTERSECT t2 ALL NULL NULL NULL NULL 6 100.00 +3 INTERSECT t3 ALL NULL NULL NULL NULL 5 100.00 +NULL INTERSECT RESULT <intersect1,2,3> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` intersect all /* select#2 */ select `test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` intersect all /* select#3 */ select `test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t3` +select * from t1 +INTERSECT ALL +select * from t2 +INTERSECT ALL +select * from t3 +INTERSECT +select * from t1; +a b +2 2 +3 3 +EXPLAIN EXTENDED select * from t1 +INTERSECT ALL +select * from t2 +INTERSECT ALL +select * from t3 +INTERSECT +select * from t1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00 +2 INTERSECT t2 ALL NULL NULL NULL NULL 6 100.00 +3 INTERSECT t3 ALL NULL NULL NULL NULL 5 100.00 +4 INTERSECT t1 ALL NULL NULL NULL NULL 5 100.00 +NULL INTERSECT RESULT <intersect1,2,3,4> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` intersect /* select#2 */ select `test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` intersect /* select#3 */ select `test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t3` intersect /* select#4 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` +select * from t1 +INTERSECT ALL +select * from t2 +INTERSECT ALL +select * from t3 +EXCEPT ALL +select * from t4; +a b +2 2 +3 3 +EXPLAIN EXTENDED select * from t1 +INTERSECT ALL +select * from t2 +INTERSECT ALL +select * from t3 +EXCEPT ALL +select * from t4; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00 +2 INTERSECT t2 ALL NULL NULL NULL NULL 6 100.00 +3 INTERSECT t3 ALL NULL NULL NULL NULL 5 100.00 +4 EXCEPT t4 ALL NULL NULL NULL NULL 3 100.00 +NULL UNIT RESULT <unit1,2,3,4> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` intersect all /* select#2 */ select `test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` intersect all /* select#3 */ select `test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t3` except all /* select#4 */ select `test`.`t4`.`g` AS `g`,`test`.`t4`.`h` AS `h` from `test`.`t4` +select * from t1 +INTERSECT +select * from t2 +EXCEPT ALL +select * from t4; +a b +3 3 +EXPLAIN EXTENDED select * from t1 +INTERSECT +select * from t2 +EXCEPT ALL +select * from t4; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00 +2 INTERSECT t2 ALL NULL NULL NULL NULL 6 100.00 +3 EXCEPT t4 ALL NULL NULL NULL NULL 3 100.00 +NULL UNIT RESULT <unit1,2,3> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` intersect /* select#2 */ select `test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` except /* select#3 */ select `test`.`t4`.`g` AS `g`,`test`.`t4`.`h` AS `h` from `test`.`t4` +insert into t4 values (1,1),(9,9); +select * from t1 +UNION ALL +select * from t2 +UNION ALL +select * from t3 +EXCEPT +select * from t4; +a b +3 3 +5 5 +EXPLAIN EXTENDED select * from t1 +UNION ALL +select * from t2 +UNION ALL +select * from t3 +EXCEPT +select * from t4; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00 +2 UNION t2 ALL NULL NULL NULL NULL 6 100.00 +3 UNION t3 ALL NULL NULL NULL NULL 5 100.00 +4 EXCEPT t4 ALL NULL NULL NULL NULL 5 100.00 +NULL UNIT RESULT <unit1,2,3,4> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` union /* select#2 */ select `test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` union /* select#3 */ select `test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t3` except /* select#4 */ select `test`.`t4`.`g` AS `g`,`test`.`t4`.`h` AS `h` from `test`.`t4` +delete from t4; +insert into t4 values (3,3),(3,3); +select * from t1 +INTERSECT ALL +select * from t2 +UNION ALL +select * from t3 +EXCEPT ALL +select * from t1 +UNION +select * from t4 +EXCEPT +select * from t3 +UNION ALL +select * from t1; +a b +2 2 +2 2 +1 1 +3 3 +3 3 +EXPLAIN EXTENDED select * from t1 +INTERSECT ALL +select * from t2 +UNION ALL +select * from t3 +EXCEPT ALL +select * from t1 +UNION +select * from t4 +EXCEPT +select * from t3 +UNION ALL +select * from t1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00 +2 INTERSECT t2 ALL NULL NULL NULL NULL 6 100.00 +3 UNION t3 ALL NULL NULL NULL NULL 5 100.00 +4 EXCEPT t1 ALL NULL NULL NULL NULL 5 100.00 +5 UNION t4 ALL NULL NULL NULL NULL 2 100.00 +6 EXCEPT t3 ALL NULL NULL NULL NULL 5 100.00 +7 UNION t1 ALL NULL NULL NULL NULL 5 100.00 +NULL UNIT RESULT <unit1,2,3,4,5,6,7> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` intersect all /* select#2 */ select `test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` union all /* select#3 */ select `test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t3` except all /* select#4 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` union /* select#5 */ select `test`.`t4`.`g` AS `g`,`test`.`t4`.`h` AS `h` from `test`.`t4` except /* select#6 */ select `test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t3` union all /* select#7 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` +drop table t4; +# test optimization with brackets +( +(select 1 except select 5 union all select 6) +union +(select 2 intersect all select 3 intersect all select 4) +except +(select 7 intersect all select 8) +) +union all +(select 9 union all select 10) +except all +select 11; +1 +1 +6 +9 +10 +EXPLAIN EXTENDED ( +(select 1 except select 5 union all select 6) +union +(select 2 intersect all select 3 intersect all select 4) +except +(select 7 intersect all select 8) +) +union all +(select 9 union all select 10) +except all +select 11; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY <derived8> ALL NULL NULL NULL NULL 4 100.00 +8 DERIVED <derived2> ALL NULL NULL NULL NULL 2 100.00 +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +3 EXCEPT NULL NULL NULL NULL NULL NULL NULL NULL No tables used +4 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNIT RESULT <unit2,3,4> ALL NULL NULL NULL NULL NULL NULL +9 UNION <derived5> ALL NULL NULL NULL NULL 2 100.00 +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +6 INTERSECT NULL NULL NULL NULL NULL NULL NULL NULL No tables used +7 INTERSECT NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL INTERSECT RESULT <intersect5,6,7> ALL NULL NULL NULL NULL NULL NULL +12 EXCEPT <derived10> ALL NULL NULL NULL NULL 2 100.00 +10 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +11 INTERSECT NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL INTERSECT RESULT <intersect10,11> ALL NULL NULL NULL NULL NULL NULL +NULL UNIT RESULT <unit8,9,12> ALL NULL NULL NULL NULL NULL NULL +15 UNION <derived13> ALL NULL NULL NULL NULL 2 100.00 +13 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +14 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used +16 EXCEPT NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNIT RESULT <unit1,15,16> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `__14`.`1` AS `1` from (/* select#8 */ select `__7`.`1` AS `1` from (/* select#2 */ select 1 AS `1` except /* select#3 */ select 5 AS `5` union /* select#4 */ select 6 AS `6`) `__7` union /* select#9 */ select `__8`.`2` AS `2` from (/* select#5 */ select 2 AS `2` intersect /* select#6 */ select 3 AS `3` intersect /* select#7 */ select 4 AS `4`) `__8` except /* select#12 */ select `__11`.`7` AS `7` from (/* select#10 */ select 7 AS `7` intersect /* select#11 */ select 8 AS `8`) `__11`) `__14` union all /* select#15 */ select `__15`.`9` AS `9` from (/* select#13 */ select 9 AS `9` union all /* select#14 */ select 10 AS `10`) `__15` except all /* select#16 */ select 11 AS `11` +(select 1 union all select 2) +union +(select 3 union all select 4); +1 +1 +2 +3 +4 +EXPLAIN EXTENDED (select 1 union all select 2) +union +(select 3 union all select 4); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 100.00 +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +3 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used +6 UNION <derived4> ALL NULL NULL NULL NULL 2 100.00 +4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +5 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT <union1,6> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `__5`.`1` AS `1` from (/* select#2 */ select 1 AS `1` union /* select#3 */ select 2 AS `2`) `__5` union /* select#6 */ select `__6`.`3` AS `3` from (/* select#4 */ select 3 AS `3` union /* select#5 */ select 4 AS `4`) `__6` +(select 1 intersect all select 2) +except +select 3; +1 +EXPLAIN EXTENDED (select 1 intersect all select 2) +except +select 3; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 100.00 +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +3 INTERSECT NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL INTERSECT RESULT <intersect2,3> ALL NULL NULL NULL NULL NULL NULL +4 EXCEPT NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL EXCEPT RESULT <except1,4> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `__4`.`1` AS `1` from (/* select#2 */ select 1 AS `1` intersect /* select#3 */ select 2 AS `2`) `__4` except /* select#4 */ select 3 AS `3` +(select 1 intersect all select 2 intersect all select 3) +intersect +(select 4 intersect all select 5); +1 +EXPLAIN EXTENDED (select 1 intersect all select 2 intersect all select 3) +intersect +(select 4 intersect all select 5); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 100.00 +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +3 INTERSECT NULL NULL NULL NULL NULL NULL NULL NULL No tables used +4 INTERSECT NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL INTERSECT RESULT <intersect2,3,4> ALL NULL NULL NULL NULL NULL NULL +7 INTERSECT <derived5> ALL NULL NULL NULL NULL 2 100.00 +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +6 INTERSECT NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL INTERSECT RESULT <intersect5,6> ALL NULL NULL NULL NULL NULL NULL +NULL INTERSECT RESULT <intersect1,7> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `__6`.`1` AS `1` from (/* select#2 */ select 1 AS `1` intersect /* select#3 */ select 2 AS `2` intersect /* select#4 */ select 3 AS `3`) `__6` intersect /* select#7 */ select `__7`.`4` AS `4` from (/* select#5 */ select 4 AS `4` intersect /* select#6 */ select 5 AS `5`) `__7` +# test set operations with table value constructor +(values (1,1),(1,1),(1,1),(2,2),(2,2),(3,3),(9,9)) +INTERSECT ALL +(values (1,1),(2,2),(2,2),(3,3),(3,3),(3,3),(8,8)) +EXCEPT ALL +(values (7,7),(1,1)); +1 1 +2 2 +2 2 +3 3 +delete from t1; +insert into t1 values(1,1),(1,1),(2,2),(4,4),(9,9); +select * from t1 +UNION ALL +(values (11,12),(3,3),(2,2),(3,3),(4,4),(8,8)) +INTERSECT +(values (13,14),(7,7),(2,2),(3,3),(1,1)) +INTERSECT ALL +(values (15,16),(2,2),(1,1)) +EXCEPT +(values (17,18),(1,1)); +a b +2 2 +4 4 +9 9 +# test set operations with derived table +select * from ( +select * from t1 +UNION ALL +select * from t2 +)dt1 +INTERSECT ALL +select * from ( +select * from t2 +EXCEPT ALL +select * from t3 +)dt2; +a b +2 2 +3 3 +5 5 +select * from ( +select * from t1 +UNION ALL +select * from t3 +)dt1 +EXCEPT ALL +select * from ( +select * from t2 +INTERSECT ALL +select * from t2 +)dt2; +a b +1 1 +1 1 +4 4 +9 9 +1 1 +4 4 +SELECT * from( +select * from ( +select * from t1 +UNION ALL +select * from t2 +)dt1 +INTERSECT ALL +select * from ( +select * from t2 +EXCEPT ALL +select * from t3 +)dt2 +)dt3; +a b +2 2 +3 3 +5 5 +# integration test +select * from t1 +UNION ALL +select * from t2 +INTERSECT ALL +(values (1,1), (2,2), (2,2), (5,5), (2,2)) +INTERSECT ALL +select * from (select * from t1 union all select * from t1) sq +EXCEPT ALL +select * from t3 +UNION ALL +select * from t2 +UNION +select * from t3 +EXCEPT +select a,c from t1,t2 +UNION ALL +select * from v0 where g < 4 +UNION ALL +select * from t3; +a b +1 1 +1 2 +3 3 +9 9 +5 5 +4 4 +1 2 +2 2 +1 3 +1 3 +2 3 +1 5 +1 5 +2 5 +1 2 +1 2 +2 2 +1 2 +1 2 +2 2 +1 3 +1 3 +2 3 +4 4 +2 2 +2 2 +1 1 +3 3 +select * from t1 +UNION ALL +select * from t2 +INTERSECT ALL +(values (1,1), (2,2), (2,2), (5,5), (2,2)) +INTERSECT ALL +select * from (select * from t1 union all select * from t1) sq +EXCEPT ALL +select * from t3 +UNION ALL +select * from t2 +UNION +select * from t3 +EXCEPT +select a,c from t1,t2 +UNION ALL +select * from v0 where g < 4 +UNION ALL +select * from t3 +ORDER BY a; +a b +1 1 +1 1 +1 2 +1 2 +1 2 +1 2 +1 2 +1 2 +1 3 +1 3 +1 3 +1 3 +1 5 +1 5 +2 2 +2 2 +2 2 +2 2 +2 2 +2 3 +2 3 +2 5 +3 3 +3 3 +4 4 +4 4 +5 5 +9 9 +select * from ( +select * from t1 +UNION ALL +select * from t2 +INTERSECT ALL +(values (1,1), (2,2), (2,2), (5,5), (2,2) ) +INTERSECT ALL +select * from (select * from t1 union all select * from t1) sq +EXCEPT ALL +select * from t3 +UNION ALL +select * from t2 +UNION +select * from t3 +EXCEPT +select a,c from t1,t2 +UNION ALL +select * from v0 where g < 4 +UNION ALL +select * from t3 +) dt; +a b +1 1 +1 2 +3 3 +9 9 +5 5 +4 4 +1 2 +2 2 +1 3 +1 3 +2 3 +1 5 +1 5 +2 5 +1 2 +1 2 +2 2 +1 2 +1 2 +2 2 +1 3 +1 3 +2 3 +4 4 +2 2 +2 2 +1 1 +3 3 +EXPLAIN +select * from t1 +UNION ALL +select * from t2 +INTERSECT ALL +(values (1,1), (2,2), (2,2), (5,5), (2,2) ) +INTERSECT ALL +select * from (select * from t1 union all select * from t1) sq +EXCEPT ALL +select * from t3 +UNION ALL +select * from t2 +UNION +select * from t3 +EXCEPT +select a,c from t1,t2 +UNION ALL +select * from v0 where g < 4 +UNION ALL +select * from t3; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 +8 UNION <derived2> ALL NULL NULL NULL NULL 5 +2 DERIVED t2 ALL NULL NULL NULL NULL 6 +3 INTERSECT NULL NULL NULL NULL NULL NULL NULL No tables used +4 INTERSECT <derived5> ALL NULL NULL NULL NULL 10 +5 DERIVED t1 ALL NULL NULL NULL NULL 5 +6 UNION t1 ALL NULL NULL NULL NULL 5 +NULL INTERSECT RESULT <intersect2,3,4> ALL NULL NULL NULL NULL NULL +7 EXCEPT t3 ALL NULL NULL NULL NULL 5 +9 UNION t2 ALL NULL NULL NULL NULL 6 +10 UNION t3 ALL NULL NULL NULL NULL 5 +11 EXCEPT t1 ALL NULL NULL NULL NULL 5 +11 EXCEPT t2 ALL NULL NULL NULL NULL 6 Using join buffer (flat, BNL join) +12 UNION t1 ALL NULL NULL NULL NULL 5 Using where +12 UNION t2 ALL NULL NULL NULL NULL 6 Using join buffer (flat, BNL join) +13 UNION t3 ALL NULL NULL NULL NULL 5 +NULL UNIT RESULT <unit1,8,7,9,10,11,12,13> ALL NULL NULL NULL NULL NULL +EXPLAIN format=json +select * from t1 +UNION ALL +select * from t2 +INTERSECT ALL +(values (1,1), (2,2), (2,2), (5,5), (2,2) ) +INTERSECT ALL +select * from (select * from t1 union all select * from t1) sq +EXCEPT ALL +select * from t3 +UNION ALL +select * from t2 +UNION +select * from t3 +EXCEPT +select a,c from t1,t2 +UNION ALL +select * from v0 where g < 4 +UNION ALL +select * from t3; +EXPLAIN +{ + "query_block": { + "union_result": { + "table_name": "<unit1,8,7,9,10,11,12,13>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 1, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + } + } + }, + { + "query_block": { + "select_id": 8, + "operation": "UNION", + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "materialized": { + "query_block": { + "union_result": { + "table_name": "<intersect2,3,4>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 6, + "filtered": 100 + } + } + }, + { + "query_block": { + "select_id": 3, + "operation": "INTERSECT", + "table": { + "message": "No tables used" + } + } + }, + { + "query_block": { + "select_id": 4, + "operation": "INTERSECT", + "table": { + "table_name": "<derived5>", + "access_type": "ALL", + "rows": 10, + "filtered": 100, + "materialized": { + "query_block": { + "union_result": { + "table_name": "<union5,6>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 5, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + } + } + }, + { + "query_block": { + "select_id": 6, + "operation": "UNION", + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + } + } + } + ] + } + } + } + } + } + } + ] + } + } + } + } + } + }, + { + "query_block": { + "select_id": 7, + "operation": "EXCEPT", + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + } + } + }, + { + "query_block": { + "select_id": 9, + "operation": "UNION", + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 6, + "filtered": 100 + } + } + }, + { + "query_block": { + "select_id": 10, + "operation": "UNION", + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + } + } + }, + { + "query_block": { + "select_id": 11, + "operation": "EXCEPT", + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + }, + "block-nl-join": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 6, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "65", + "join_type": "BNL" + } + } + }, + { + "query_block": { + "select_id": 12, + "operation": "UNION", + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a < 4" + }, + "block-nl-join": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 6, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "65", + "join_type": "BNL" + } + } + }, + { + "query_block": { + "select_id": 13, + "operation": "UNION", + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + } + } + } + ] + } + } +} +EXPLAIN EXTENDED +select * from t1 +UNION ALL +select * from t2 +INTERSECT ALL +(values (1,1), (2,2), (2,2), (5,5), (2,2) ) +INTERSECT ALL +select * from (select * from t1 union all select * from t1) sq +EXCEPT ALL +select * from t3 +UNION ALL +select * from t2 +UNION +select * from t3 +EXCEPT +select a,c from t1,t2 +UNION ALL +select * from v0 where g < 4 +UNION ALL +select * from t3; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00 +8 UNION <derived2> ALL NULL NULL NULL NULL 5 100.00 +2 DERIVED t2 ALL NULL NULL NULL NULL 6 100.00 +3 INTERSECT NULL NULL NULL NULL NULL NULL NULL NULL No tables used +4 INTERSECT <derived5> ALL NULL NULL NULL NULL 10 100.00 +5 DERIVED t1 ALL NULL NULL NULL NULL 5 100.00 +6 UNION t1 ALL NULL NULL NULL NULL 5 100.00 +NULL INTERSECT RESULT <intersect2,3,4> ALL NULL NULL NULL NULL NULL NULL +7 EXCEPT t3 ALL NULL NULL NULL NULL 5 100.00 +9 UNION t2 ALL NULL NULL NULL NULL 6 100.00 +10 UNION t3 ALL NULL NULL NULL NULL 5 100.00 +11 EXCEPT t1 ALL NULL NULL NULL NULL 5 100.00 +11 EXCEPT t2 ALL NULL NULL NULL NULL 6 100.00 Using join buffer (flat, BNL join) +12 UNION t1 ALL NULL NULL NULL NULL 5 100.00 Using where +12 UNION t2 ALL NULL NULL NULL NULL 6 100.00 Using join buffer (flat, BNL join) +13 UNION t3 ALL NULL NULL NULL NULL 5 100.00 +NULL UNIT RESULT <unit1,8,7,9,10,11,12,13> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` union all /* select#8 */ select `__8`.`c` AS `c`,`__8`.`d` AS `d` from (/* select#2 */ select `test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` intersect all (values (1,1),(2,2),(2,2),(5,5),(2,2)) intersect all /* select#4 */ select `sq`.`a` AS `a`,`sq`.`b` AS `b` from (/* select#5 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` union all /* select#6 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) `sq`) `__8` except all /* select#7 */ select `test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t3` union /* select#9 */ select `test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` union /* select#10 */ select `test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t3` except /* select#11 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` union all /* select#12 */ select `test`.`t1`.`a` AS `g`,`test`.`t2`.`c` AS `h` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` < 4 union all /* select#13 */ select `test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t3` +PREPARE stmt from" + select * from t1 + UNION ALL + select * from t2 + INTERSECT ALL + (values (1,1), (2,2), (2,2), (5,5), (2,2) ) + INTERSECT ALL + select * from (select * from t1 union all select * from t1) sq + EXCEPT ALL + select * from t3 + UNION ALL + select * from t2 + UNION + select * from t3 + EXCEPT + select a,c from t1,t2 + UNION ALL + select * from v0 where g < 4 + UNION ALL + select * from t3 +"; +EXECUTE stmt; +a b +1 1 +1 2 +3 3 +9 9 +5 5 +4 4 +1 2 +2 2 +1 3 +1 3 +2 3 +1 5 +1 5 +2 5 +1 2 +1 2 +2 2 +1 2 +1 2 +2 2 +1 3 +1 3 +2 3 +4 4 +2 2 +2 2 +1 1 +3 3 +EXECUTE stmt; +a b +1 1 +1 2 +3 3 +9 9 +5 5 +4 4 +1 2 +2 2 +1 3 +1 3 +2 3 +1 5 +1 5 +2 5 +1 2 +1 2 +2 2 +1 2 +1 2 +2 2 +1 3 +1 3 +2 3 +4 4 +2 2 +2 2 +1 1 +3 3 +deallocate prepare stmt; +create view v1(i1, i2) as +select * from t1 +UNION ALL +select * from t2 +INTERSECT ALL +(values (1,1), (2,2), (2,2), (5,5), (2,2) ) +INTERSECT ALL +select * from (select * from t1 union all select * from t1) sq +EXCEPT ALL +select * from t3 +UNION ALL +select * from t2 +UNION +select * from t3 +EXCEPT +select a,c from t1,t2 +UNION ALL +select * from v0 where g < 4 +UNION ALL +select * from t3; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`t1`.`a` AS `i1`,`test`.`t1`.`b` AS `i2` from `test`.`t1` union all select `__9`.`c` AS `c`,`__9`.`d` AS `d` from (select `test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` intersect all (values (1,1),(2,2),(2,2),(5,5),(2,2)) intersect all select `sq`.`a` AS `a`,`sq`.`b` AS `b` from (select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` union all select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) `sq`) `__9` except all select `test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t3` union all select `test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` union select `test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t3` except select `test`.`t1`.`a` AS `a`,`test`.`t2`.`c` AS `c` from (`test`.`t1` join `test`.`t2`) union all select `v0`.`g` AS `g`,`v0`.`h` AS `h` from `test`.`v0` where `v0`.`g` < 4 union all select `test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t3` latin1 latin1_swedish_ci +select * from v1 limit 14; +i1 i2 +1 1 +1 2 +3 3 +9 9 +5 5 +4 4 +1 2 +2 2 +1 3 +1 3 +2 3 +1 5 +1 5 +2 5 +select * from v1 order by i1 limit 14; +i1 i2 +1 1 +1 1 +1 2 +1 2 +1 2 +1 2 +1 2 +1 2 +1 3 +1 3 +1 3 +1 3 +1 5 +1 5 +drop table t1,t2,t3; +drop view v0,v1; +# compare result +create table t1 (a int, b int); +create table t2 (c int, d int); +create table t3 (e int, f int); +create table t4 (g int, h int); +insert into t1 values (1,1),(1,1),(2,2); +insert into t2 values (1,1),(1,1),(2,2),(3,3); +insert into t3 values (1,1); +insert into t4 values (4,4); +select * from t1 intersect all select * from t2 except select * from t3 union select * from t4; +a b +4 4 +2 2 +select * from t1 intersect all select * from t2 except ALL select * from t3 union select * from t4; +a b +1 1 +2 2 +4 4 +select * from t1 intersect DISTINCT select * from t2 except select * from t3 union select * from t4; +a b +4 4 +2 2 +select * from t1 intersect DISTINCT select * from t2 except ALL select * from t3 union select * from t4; +a b +4 4 +2 2 +delete from t1; +delete from t2; +delete from t3; +delete from t4; +insert into t1 values (1,1),(1,1),(1,1),(2,2),(2,2),(4,4),(5,5); +insert into t2 values (1,1),(1,1),(1,1),(2,2),(2,2),(3,3); +insert into t3 values (1,1),(2,2),(2,2); +select * from t1 intersect all select * from t2 intersect all select * from t3; +a b +1 1 +2 2 +2 2 +select * from t1 intersect all select * from t2 intersect select * from t3; +a b +1 1 +2 2 +select * from t1 intersect all select * from t1 intersect all select * from t2 intersect select * from t3; +a b +1 1 +2 2 +delete from t1; +delete from t2; +delete from t3; +insert into t1 values (1,1),(1,1),(2,2); +insert into t2 values (1,1),(1,1),(2,2),(3,3); +insert into t3 values (1,1),(5,5); +insert into t4 values (4,4),(4,4),(4,4); +select * from t1 intersect all select * from t2 union all select * from t3 union select * from t4; +a b +1 1 +2 2 +5 5 +4 4 +select * from t1 intersect DISTINCT select * from t2 union DISTINCT select * from t3 union select * from t4; +a b +1 1 +2 2 +5 5 +4 4 +select * from t1 intersect all select * from t2 intersect all select * from t3 union select * from t4; +a b +1 1 +4 4 +select * from t1 intersect all select * from t2 intersect DISTINCT select * from t3 union select * from t4; +a b +1 1 +4 4 +select * from t1 intersect DISTINCT select * from t2 intersect DISTINCT select * from t3 union select * from t4; +a b +1 1 +4 4 +select * from t1 intersect all select * from t2 EXCEPT select * from t3 union select * from t4; +a b +4 4 +2 2 +select * from t1 intersect DISTINCT select * from t2 EXCEPT select * from t3 union select * from t4; +a b +4 4 +2 2 +select * from t1 intersect all select * from t2 EXCEPT ALL select * from t3 union select * from t4; +a b +1 1 +2 2 +4 4 +select * from t1 EXCEPT select * from t2 union all select * from t3 union select * from t4; +a b +5 5 +1 1 +4 4 +select * from t1 EXCEPT select * from t2 union DISTINCT select * from t3 union select * from t4; +a b +5 5 +1 1 +4 4 +delete from t1; +delete from t2; +delete from t3; +delete from t4; +insert into t1 values (1,1),(2,2); +insert into t2 values (1,1),(2,2); +insert into t3 values (1,1),(3,3); +select * from t1 union all select * from t2 except all select * from t3; +a b +1 1 +2 2 +2 2 +select * from t1 union all select * from t2 except DISTINCT select * from t3; +a b +2 2 +select * from t1 union DISTINCT select * from t2 except all select * from t3; +a b +2 2 +select * from t1 union DISTINCT select * from t2 except DISTINCT select * from t3; +a b +2 2 +drop table t1; +drop table t2; +drop table t3; +drop table t4; +select 1 intersect all select 2 intersect all select 3 intersect select 4 union select 5; +1 +5 +select 1 intersect all select 2 intersect all select 3 union select 4 except select 5; +1 +4 +select 1 union select 2 except all select 3 union select 4; +1 +1 +2 +4 +select 1 union all select 2 union all select 3 union select 4; +1 +1 +2 +3 +4 +# test with limited resource +set @@max_heap_table_size= 1024; +Warnings: +Warning 1292 Truncated incorrect max_heap_table_size value: '1024' +set @@tmp_table_size= 1024; +create table t1 (a int, b int); +insert into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(0,0); +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select a+100, b+100 from t1; +create table t2 (a int, b int); +insert into t2 values (10,10),(11,11),(12,12),(13,13),(14,14),(5,5),(6,6),(7,7),(8,8),(9,9); +insert into t2 select * from t2; +insert into t2 select * from t2; +insert into t2 select * from t2; +insert into t2 select a+100, b+100 from t2; +select count(*) from +( +select * from t1 +INTERSECT ALL +select * from t2 +) c; +count(*) +80 +select count(*) from +( +select * from t1 +EXCEPT ALL +select * from t2 +) c; +count(*) +80 +select count(*) from +( +select * from t1 +INTERSECT ALL +select * from t2 +UNION ALL +select * from t1 +EXCEPT ALL +select * from t2 +) c; +count(*) +160 +delete from t1; +delete from t2; +insert into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(0,0); +insert into t1 select a+10, b+10 from t1; +insert into t1 select a+20, b+20 from t1; +insert into t1 select a+40, b+40 from t1; +insert into t1 select a+80, b+80 from t1; +insert into t2 values (1110,1110),(1111,1111),(1112,1112),(1113,1113),(1114,1114),(1105,1105),(1106,1106),(1107,1107),(1108,1108),(1109,1109); +insert into t2 select a+10, b+10 from t2; +insert into t2 select a+20, b+20 from t2; +insert into t2 select a+40, b+40 from t2; +insert into t2 select a+80, b+80 from t2; +select count(*) from +( +select * from t1 +UNION ALL +select * from t2 +EXCEPT ALL +values (1,1) +) c; +count(*) +319 +drop table t1; +drop table t2; +# +# MDEV-24242: set expression with empty intermediate result +# when tmp_memory_table_size is set to 0 +# +create table t1 (a int, b int) engine=MyISAM; +insert into t1 values (1,1), (2,2); +create table t2 (a int, b int) engine=MyISAM; +insert into t2 values (11,11), (12,12), (13,13); +select * from t1 +except all +select * from t1 +except +select * from t1 +union all +select * from t2; +a b +12 12 +11 11 +13 13 +set tmp_memory_table_size=0; +select * from t1 +except all +select * from t1 +except +select * from t1 +union all +select * from t2; +a b +12 12 +11 11 +13 13 +set tmp_memory_table_size=default; +drop table t1,t2; +# End of 10.4 tests diff --git a/mysql-test/main/set_operation.test b/mysql-test/main/set_operation.test new file mode 100644 index 00000000000..c422042f371 --- /dev/null +++ b/mysql-test/main/set_operation.test @@ -0,0 +1,554 @@ +create table t1 (a int, b int) engine=MyISAM; +create table t2 (c int, d int) engine=MyISAM; +create table t3 (e int, f int) engine=MyISAM; +create table t4 (g int, h int) engine=MyISAM; +insert into t1 values (1,1),(2,2),(3,3),(2,2),(3,3); +insert into t2 values (2,2),(3,3),(5,5),(2,2),(2,2),(3,3); +insert into t3 values (4,4),(2,2),(2,2),(1,1),(3,3); +insert into t4 values (2,2),(4,4),(1,1); +create view v0(g, h) as select a,c from t1,t2; + +--echo # test optimization + +let $q= + select * from t1 + INTERSECT ALL + select * from t2 + INTERSECT ALL + select * from t3; +eval $q; +eval EXPLAIN EXTENDED $q; + +let $q= + select * from t1 + INTERSECT ALL + select * from t2 + INTERSECT ALL + select * from t3 + INTERSECT + select * from t1; +eval $q; +eval EXPLAIN EXTENDED $q; + +let $q= + select * from t1 + INTERSECT ALL + select * from t2 + INTERSECT ALL + select * from t3 + EXCEPT ALL + select * from t4; +eval $q; +eval EXPLAIN EXTENDED $q; + +let $q= + select * from t1 + INTERSECT + select * from t2 + EXCEPT ALL + select * from t4; +eval $q; +eval EXPLAIN EXTENDED $q; + +insert into t4 values (1,1),(9,9); +let $q= + select * from t1 + UNION ALL + select * from t2 + UNION ALL + select * from t3 + EXCEPT + select * from t4; +eval $q; +eval EXPLAIN EXTENDED $q; + +delete from t4; +insert into t4 values (3,3),(3,3); +let $q= + select * from t1 + INTERSECT ALL + select * from t2 + UNION ALL + select * from t3 + EXCEPT ALL + select * from t1 + UNION + select * from t4 + EXCEPT + select * from t3 + UNION ALL + select * from t1; + +eval $q; +eval EXPLAIN EXTENDED $q; +drop table t4; + +--echo # test optimization with brackets + +let $q= +( + (select 1 except select 5 union all select 6) + union + (select 2 intersect all select 3 intersect all select 4) + except + (select 7 intersect all select 8) +) + union all +(select 9 union all select 10) + except all +select 11; +eval $q; +eval EXPLAIN EXTENDED $q; + +let $q= +(select 1 union all select 2) + union +(select 3 union all select 4); +eval $q; +eval EXPLAIN EXTENDED $q; + +let $q= +(select 1 intersect all select 2) + except +select 3; +eval $q; +eval EXPLAIN EXTENDED $q; + +let $q= +(select 1 intersect all select 2 intersect all select 3) + intersect +(select 4 intersect all select 5); +eval $q; +eval EXPLAIN EXTENDED $q; + + +--echo # test set operations with table value constructor + +(values (1,1),(1,1),(1,1),(2,2),(2,2),(3,3),(9,9)) +INTERSECT ALL +(values (1,1),(2,2),(2,2),(3,3),(3,3),(3,3),(8,8)) +EXCEPT ALL +(values (7,7),(1,1)); + +delete from t1; +insert into t1 values(1,1),(1,1),(2,2),(4,4),(9,9); + +select * from t1 +UNION ALL +(values (11,12),(3,3),(2,2),(3,3),(4,4),(8,8)) +INTERSECT +(values (13,14),(7,7),(2,2),(3,3),(1,1)) +INTERSECT ALL +(values (15,16),(2,2),(1,1)) +EXCEPT +(values (17,18),(1,1)); + +--echo # test set operations with derived table + +select * from ( + select * from t1 + UNION ALL + select * from t2 +)dt1 +INTERSECT ALL +select * from ( + select * from t2 + EXCEPT ALL + select * from t3 +)dt2; + +select * from ( + select * from t1 + UNION ALL + select * from t3 +)dt1 +EXCEPT ALL +select * from ( + select * from t2 + INTERSECT ALL + select * from t2 +)dt2; + +SELECT * from( + select * from ( + select * from t1 + UNION ALL + select * from t2 + )dt1 + INTERSECT ALL + select * from ( + select * from t2 + EXCEPT ALL + select * from t3 + )dt2 +)dt3; + +--echo # integration test + + +select * from t1 +UNION ALL +select * from t2 +INTERSECT ALL +(values (1,1), (2,2), (2,2), (5,5), (2,2)) +INTERSECT ALL +select * from (select * from t1 union all select * from t1) sq +EXCEPT ALL +select * from t3 +UNION ALL +select * from t2 +UNION +select * from t3 +EXCEPT +select a,c from t1,t2 +UNION ALL +select * from v0 where g < 4 +UNION ALL +select * from t3; + +--sorted_result +select * from t1 +UNION ALL +select * from t2 +INTERSECT ALL +(values (1,1), (2,2), (2,2), (5,5), (2,2)) +INTERSECT ALL +select * from (select * from t1 union all select * from t1) sq +EXCEPT ALL +select * from t3 +UNION ALL +select * from t2 +UNION +select * from t3 +EXCEPT +select a,c from t1,t2 +UNION ALL +select * from v0 where g < 4 +UNION ALL +select * from t3 +ORDER BY a; + + +select * from ( + select * from t1 + UNION ALL + select * from t2 + INTERSECT ALL + (values (1,1), (2,2), (2,2), (5,5), (2,2) ) + INTERSECT ALL + select * from (select * from t1 union all select * from t1) sq + EXCEPT ALL + select * from t3 + UNION ALL + select * from t2 + UNION + select * from t3 + EXCEPT + select a,c from t1,t2 + UNION ALL + select * from v0 where g < 4 + UNION ALL + select * from t3 +) dt; + +EXPLAIN +select * from t1 +UNION ALL +select * from t2 +INTERSECT ALL +(values (1,1), (2,2), (2,2), (5,5), (2,2) ) +INTERSECT ALL +select * from (select * from t1 union all select * from t1) sq +EXCEPT ALL +select * from t3 +UNION ALL +select * from t2 +UNION +select * from t3 +EXCEPT +select a,c from t1,t2 +UNION ALL +select * from v0 where g < 4 +UNION ALL +select * from t3; + +EXPLAIN format=json +select * from t1 +UNION ALL +select * from t2 +INTERSECT ALL +(values (1,1), (2,2), (2,2), (5,5), (2,2) ) +INTERSECT ALL +select * from (select * from t1 union all select * from t1) sq +EXCEPT ALL +select * from t3 +UNION ALL +select * from t2 +UNION +select * from t3 +EXCEPT +select a,c from t1,t2 +UNION ALL +select * from v0 where g < 4 +UNION ALL +select * from t3; + +EXPLAIN EXTENDED +select * from t1 +UNION ALL +select * from t2 +INTERSECT ALL +(values (1,1), (2,2), (2,2), (5,5), (2,2) ) +INTERSECT ALL +select * from (select * from t1 union all select * from t1) sq +EXCEPT ALL +select * from t3 +UNION ALL +select * from t2 +UNION +select * from t3 +EXCEPT +select a,c from t1,t2 +UNION ALL +select * from v0 where g < 4 +UNION ALL +select * from t3; + +PREPARE stmt from" + select * from t1 + UNION ALL + select * from t2 + INTERSECT ALL + (values (1,1), (2,2), (2,2), (5,5), (2,2) ) + INTERSECT ALL + select * from (select * from t1 union all select * from t1) sq + EXCEPT ALL + select * from t3 + UNION ALL + select * from t2 + UNION + select * from t3 + EXCEPT + select a,c from t1,t2 + UNION ALL + select * from v0 where g < 4 + UNION ALL + select * from t3 +"; + + +EXECUTE stmt; + +EXECUTE stmt; +deallocate prepare stmt; + +create view v1(i1, i2) as + select * from t1 + UNION ALL + select * from t2 + INTERSECT ALL + (values (1,1), (2,2), (2,2), (5,5), (2,2) ) + INTERSECT ALL + select * from (select * from t1 union all select * from t1) sq + EXCEPT ALL + select * from t3 + UNION ALL + select * from t2 + UNION + select * from t3 + EXCEPT + select a,c from t1,t2 + UNION ALL + select * from v0 where g < 4 + UNION ALL + select * from t3; + +show create view v1; + +select * from v1 limit 14; +--sorted_result +select * from v1 order by i1 limit 14; + +drop table t1,t2,t3; +drop view v0,v1; + +--echo # compare result + +create table t1 (a int, b int); +create table t2 (c int, d int); +create table t3 (e int, f int); +create table t4 (g int, h int); + + +insert into t1 values (1,1),(1,1),(2,2); +insert into t2 values (1,1),(1,1),(2,2),(3,3); +insert into t3 values (1,1); +insert into t4 values (4,4); + +select * from t1 intersect all select * from t2 except select * from t3 union select * from t4; +select * from t1 intersect all select * from t2 except ALL select * from t3 union select * from t4; + +select * from t1 intersect DISTINCT select * from t2 except select * from t3 union select * from t4; +select * from t1 intersect DISTINCT select * from t2 except ALL select * from t3 union select * from t4; + +delete from t1; +delete from t2; +delete from t3; +delete from t4; + + +insert into t1 values (1,1),(1,1),(1,1),(2,2),(2,2),(4,4),(5,5); +insert into t2 values (1,1),(1,1),(1,1),(2,2),(2,2),(3,3); +insert into t3 values (1,1),(2,2),(2,2); + +select * from t1 intersect all select * from t2 intersect all select * from t3; +select * from t1 intersect all select * from t2 intersect select * from t3; +select * from t1 intersect all select * from t1 intersect all select * from t2 intersect select * from t3; + +delete from t1; +delete from t2; +delete from t3; + + +insert into t1 values (1,1),(1,1),(2,2); +insert into t2 values (1,1),(1,1),(2,2),(3,3); +insert into t3 values (1,1),(5,5); +insert into t4 values (4,4),(4,4),(4,4); + +select * from t1 intersect all select * from t2 union all select * from t3 union select * from t4; +select * from t1 intersect DISTINCT select * from t2 union DISTINCT select * from t3 union select * from t4; + +select * from t1 intersect all select * from t2 intersect all select * from t3 union select * from t4; +select * from t1 intersect all select * from t2 intersect DISTINCT select * from t3 union select * from t4; +select * from t1 intersect DISTINCT select * from t2 intersect DISTINCT select * from t3 union select * from t4; + +select * from t1 intersect all select * from t2 EXCEPT select * from t3 union select * from t4; +select * from t1 intersect DISTINCT select * from t2 EXCEPT select * from t3 union select * from t4; +select * from t1 intersect all select * from t2 EXCEPT ALL select * from t3 union select * from t4; + +select * from t1 EXCEPT select * from t2 union all select * from t3 union select * from t4; +select * from t1 EXCEPT select * from t2 union DISTINCT select * from t3 union select * from t4; + +delete from t1; +delete from t2; +delete from t3; +delete from t4; + + +insert into t1 values (1,1),(2,2); +insert into t2 values (1,1),(2,2); +insert into t3 values (1,1),(3,3); + +select * from t1 union all select * from t2 except all select * from t3; +select * from t1 union all select * from t2 except DISTINCT select * from t3; +select * from t1 union DISTINCT select * from t2 except all select * from t3; +select * from t1 union DISTINCT select * from t2 except DISTINCT select * from t3; + +drop table t1; +drop table t2; +drop table t3; +drop table t4; + + +select 1 intersect all select 2 intersect all select 3 intersect select 4 union select 5; +select 1 intersect all select 2 intersect all select 3 union select 4 except select 5; +select 1 union select 2 except all select 3 union select 4; +select 1 union all select 2 union all select 3 union select 4; + +--echo # test with limited resource + +set @@max_heap_table_size= 1024; +set @@tmp_table_size= 1024; + +create table t1 (a int, b int); +insert into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(0,0); +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select a+100, b+100 from t1; +create table t2 (a int, b int); +insert into t2 values (10,10),(11,11),(12,12),(13,13),(14,14),(5,5),(6,6),(7,7),(8,8),(9,9); +insert into t2 select * from t2; +insert into t2 select * from t2; +insert into t2 select * from t2; +insert into t2 select a+100, b+100 from t2; + + +select count(*) from +( + select * from t1 + INTERSECT ALL + select * from t2 +) c; + +select count(*) from +( + select * from t1 + EXCEPT ALL + select * from t2 +) c; + +select count(*) from +( + select * from t1 + INTERSECT ALL + select * from t2 + UNION ALL + select * from t1 + EXCEPT ALL + select * from t2 +) c; + +delete from t1; +delete from t2; + +insert into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(0,0); +insert into t1 select a+10, b+10 from t1; +insert into t1 select a+20, b+20 from t1; +insert into t1 select a+40, b+40 from t1; +insert into t1 select a+80, b+80 from t1; +insert into t2 values (1110,1110),(1111,1111),(1112,1112),(1113,1113),(1114,1114),(1105,1105),(1106,1106),(1107,1107),(1108,1108),(1109,1109); +insert into t2 select a+10, b+10 from t2; +insert into t2 select a+20, b+20 from t2; +insert into t2 select a+40, b+40 from t2; +insert into t2 select a+80, b+80 from t2; + +select count(*) from +( + select * from t1 + UNION ALL + select * from t2 + EXCEPT ALL + values (1,1) +) c; + +drop table t1; +drop table t2; + +--echo # +--echo # MDEV-24242: set expression with empty intermediate result +--echo # when tmp_memory_table_size is set to 0 +--echo # + +create table t1 (a int, b int) engine=MyISAM; +insert into t1 values (1,1), (2,2); +create table t2 (a int, b int) engine=MyISAM; +insert into t2 values (11,11), (12,12), (13,13); + +let $q= +select * from t1 +except all +select * from t1 +except +select * from t1 +union all +select * from t2; + +eval $q; +set tmp_memory_table_size=0; +eval $q; +set tmp_memory_table_size=default; + +drop table t1,t2; + +--echo # End of 10.4 tests diff --git a/mysql-test/main/set_operation_oracle.result b/mysql-test/main/set_operation_oracle.result new file mode 100644 index 00000000000..947e5e9a11c --- /dev/null +++ b/mysql-test/main/set_operation_oracle.result @@ -0,0 +1,127 @@ +create table t1 (a int, b blob) engine=MyISAM; +create table t2 (c int, d blob) engine=MyISAM; +create table t3 (e int, f blob) engine=MyISAM; +insert into t1 values (5,5),(6,6); +insert into t2 values (2,2),(3,3); +insert into t3 values (1,1),(3,3); +set SQL_MODE=ORACLE; +(select a,b from t1) union (select c,d from t2) intersect (select e,f from t3) union (select 4,4); +a b +4 4 +3 3 +explain extended +(select a,b from t1) union (select c,d from t2) intersect (select e,f from t3) union (select 4,4); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 +2 UNION t2 ALL NULL NULL NULL NULL 2 100.00 +3 INTERSECT t3 ALL NULL NULL NULL NULL 2 100.00 +4 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNIT RESULT <unit1,2,3,4> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 (/* select#1 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1") union (/* select#2 */ select "test"."t2"."c" AS "c","test"."t2"."d" AS "d" from "test"."t2") intersect (/* select#3 */ select "test"."t3"."e" AS "e","test"."t3"."f" AS "f" from "test"."t3") union (/* select#4 */ select 4 AS "4",4 AS "4") +(select e,f from t3) intersect (select c,d from t2) union (select a,b from t1) union (select 4,4); +e f +5 5 +3 3 +6 6 +4 4 +explain extended +(select e,f from t3) intersect (select c,d from t2) union (select a,b from t1) union (select 4,4); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 ALL NULL NULL NULL NULL 2 100.00 +2 INTERSECT t2 ALL NULL NULL NULL NULL 2 100.00 +3 UNION t1 ALL NULL NULL NULL NULL 2 100.00 +4 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNIT RESULT <unit1,2,3,4> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 (/* select#1 */ select "test"."t3"."e" AS "e","test"."t3"."f" AS "f" from "test"."t3") intersect (/* select#2 */ select "test"."t2"."c" AS "c","test"."t2"."d" AS "d" from "test"."t2") union (/* select#3 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1") union (/* select#4 */ select 4 AS "4",4 AS "4") +create table t12(c1 int); +insert into t12 values(1); +insert into t12 values(2); +create table t13(c1 int); +insert into t13 values(1); +insert into t13 values(3); +create table t234(c1 int); +insert into t234 values(2); +insert into t234 values(3); +insert into t234 values(4); +select * from t13 union select * from t234 intersect select * from t12; +c1 +1 +2 +set SQL_MODE=default; +drop table t1,t2,t3; +drop table t12,t13, t234; +create table t1 (a int, b blob) engine=MyISAM; +create table t2 (c int, d blob) engine=MyISAM; +create table t3 (e int, f blob) engine=MyISAM; +insert into t1 values (5,5),(6,6); +insert into t2 values (2,2),(3,3); +insert into t3 values (1,1),(3,3); +set SQL_MODE=ORACLE; +select a,b from t1 union all select c,d from t2 intersect select e,f from t3 union all select 4,'4' from dual; +a b +4 4 +3 3 +explain extended +select a,b from t1 union all select c,d from t2 intersect select e,f from t3 union all select 4,'4' from dual; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 +2 UNION t2 ALL NULL NULL NULL NULL 2 100.00 +3 INTERSECT t3 ALL NULL NULL NULL NULL 2 100.00 +4 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNIT RESULT <unit1,2,3,4> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1" union all /* select#2 */ select "test"."t2"."c" AS "c","test"."t2"."d" AS "d" from "test"."t2" intersect /* select#3 */ select "test"."t3"."e" AS "e","test"."t3"."f" AS "f" from "test"."t3" union all /* select#4 */ select 4 AS "4",'4' AS "4" +select a,b from t1 union all select c,d from t2 intersect all select e,f from t3 union all select 4,'4' from dual; +a b +3 3 +4 4 +explain extended +select a,b from t1 union all select c,d from t2 intersect all select e,f from t3 union all select 4,'4' from dual; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 +2 UNION t2 ALL NULL NULL NULL NULL 2 100.00 +3 INTERSECT t3 ALL NULL NULL NULL NULL 2 100.00 +4 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNIT RESULT <unit1,2,3,4> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1" union all /* select#2 */ select "test"."t2"."c" AS "c","test"."t2"."d" AS "d" from "test"."t2" intersect all /* select#3 */ select "test"."t3"."e" AS "e","test"."t3"."f" AS "f" from "test"."t3" union all /* select#4 */ select 4 AS "4",'4' AS "4" +select e,f from t3 intersect select c,d from t2 union all select a,b from t1 union all select 4,'4' from dual; +e f +5 5 +3 3 +6 6 +4 4 +explain extended +select e,f from t3 intersect select c,d from t2 union all select a,b from t1 union all select 4,'4' from dual; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 ALL NULL NULL NULL NULL 2 100.00 +2 INTERSECT t2 ALL NULL NULL NULL NULL 2 100.00 +3 UNION t1 ALL NULL NULL NULL NULL 2 100.00 +4 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNIT RESULT <unit1,2,3,4> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select "test"."t3"."e" AS "e","test"."t3"."f" AS "f" from "test"."t3" intersect /* select#2 */ select "test"."t2"."c" AS "c","test"."t2"."d" AS "d" from "test"."t2" union all /* select#3 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1" union all /* select#4 */ select 4 AS "4",'4' AS "4" +select e,f from t3 intersect all select c,d from t2 union all select a,b from t1 union all select 4,'4' from dual; +e f +3 3 +5 5 +6 6 +4 4 +explain extended +select e,f from t3 intersect all select c,d from t2 union all select a,b from t1 union all select 4,'4' from dual; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 ALL NULL NULL NULL NULL 2 100.00 +2 INTERSECT t2 ALL NULL NULL NULL NULL 2 100.00 +3 UNION t1 ALL NULL NULL NULL NULL 2 100.00 +4 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNIT RESULT <unit1,2,3,4> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select "test"."t3"."e" AS "e","test"."t3"."f" AS "f" from "test"."t3" intersect all /* select#2 */ select "test"."t2"."c" AS "c","test"."t2"."d" AS "d" from "test"."t2" union all /* select#3 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1" union all /* select#4 */ select 4 AS "4",'4' AS "4" +set SQL_MODE=default; +drop table t1,t2,t3; +set SQL_MODE=oracle; +select * from t13 union select * from t234 intersect all select * from t12; +ERROR 42S02: Table 'test.t13' doesn't exist +set SQL_MODE=default; diff --git a/mysql-test/main/set_operation_oracle.test b/mysql-test/main/set_operation_oracle.test new file mode 100644 index 00000000000..60fda4a5cb5 --- /dev/null +++ b/mysql-test/main/set_operation_oracle.test @@ -0,0 +1,71 @@ +# from intersect.test +create table t1 (a int, b blob) engine=MyISAM; +create table t2 (c int, d blob) engine=MyISAM; +create table t3 (e int, f blob) engine=MyISAM; +insert into t1 values (5,5),(6,6); +insert into t2 values (2,2),(3,3); +insert into t3 values (1,1),(3,3); + +set SQL_MODE=ORACLE; + +(select a,b from t1) union (select c,d from t2) intersect (select e,f from t3) union (select 4,4); +explain extended +(select a,b from t1) union (select c,d from t2) intersect (select e,f from t3) union (select 4,4); + + +(select e,f from t3) intersect (select c,d from t2) union (select a,b from t1) union (select 4,4); +explain extended +(select e,f from t3) intersect (select c,d from t2) union (select a,b from t1) union (select 4,4); + +create table t12(c1 int); +insert into t12 values(1); +insert into t12 values(2); +create table t13(c1 int); +insert into t13 values(1); +insert into t13 values(3); +create table t234(c1 int); +insert into t234 values(2); +insert into t234 values(3); +insert into t234 values(4); + + +select * from t13 union select * from t234 intersect select * from t12; +set SQL_MODE=default; + +drop table t1,t2,t3; +drop table t12,t13, t234; + +#from intersect_all.test +create table t1 (a int, b blob) engine=MyISAM; +create table t2 (c int, d blob) engine=MyISAM; +create table t3 (e int, f blob) engine=MyISAM; +insert into t1 values (5,5),(6,6); +insert into t2 values (2,2),(3,3); +insert into t3 values (1,1),(3,3); + +set SQL_MODE=ORACLE; + +select a,b from t1 union all select c,d from t2 intersect select e,f from t3 union all select 4,'4' from dual; +explain extended +select a,b from t1 union all select c,d from t2 intersect select e,f from t3 union all select 4,'4' from dual; + +select a,b from t1 union all select c,d from t2 intersect all select e,f from t3 union all select 4,'4' from dual; +explain extended +select a,b from t1 union all select c,d from t2 intersect all select e,f from t3 union all select 4,'4' from dual; + +select e,f from t3 intersect select c,d from t2 union all select a,b from t1 union all select 4,'4' from dual; +explain extended +select e,f from t3 intersect select c,d from t2 union all select a,b from t1 union all select 4,'4' from dual; + +select e,f from t3 intersect all select c,d from t2 union all select a,b from t1 union all select 4,'4' from dual; +explain extended +select e,f from t3 intersect all select c,d from t2 union all select a,b from t1 union all select 4,'4' from dual; + +set SQL_MODE=default; + +drop table t1,t2,t3; + +set SQL_MODE=oracle; +--error ER_NO_SUCH_TABLE +select * from t13 union select * from t234 intersect all select * from t12; +set SQL_MODE=default; diff --git a/mysql-test/main/shutdown.result b/mysql-test/main/shutdown.result index 7a69f58ffd9..681c184f640 100644 --- a/mysql-test/main/shutdown.result +++ b/mysql-test/main/shutdown.result @@ -13,4 +13,4 @@ drop user user1@localhost; # # MDEV-8491 - On shutdown, report the user and the host executed that. # -FOUND 2 /mysqld(\.exe)? \(initiated by: root\[root\] @ localhost \[(::1)?\]\): Normal shutdown/ in mysqld.1.err +FOUND 3 /(mysqld|mariadbd)(\.exe)? \(initiated by: root\[root\] @ localhost \[(::1)?\]\): Normal shutdown/ in mysqld.1.err diff --git a/mysql-test/main/shutdown.test b/mysql-test/main/shutdown.test index e423725177b..69616f535b2 100644 --- a/mysql-test/main/shutdown.test +++ b/mysql-test/main/shutdown.test @@ -34,5 +34,5 @@ drop user user1@localhost; --echo # MDEV-8491 - On shutdown, report the user and the host executed that. --echo # --let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err ---let SEARCH_PATTERN=mysqld(\.exe)? \(initiated by: root\[root\] @ localhost \[(::1)?\]\): Normal shutdown +--let SEARCH_PATTERN=(mysqld|mariadbd)(\.exe)? \(initiated by: root\[root\] @ localhost \[(::1)?\]\): Normal shutdown --source include/search_pattern_in_file.inc diff --git a/mysql-test/main/sp-code.result b/mysql-test/main/sp-code.result index 2b5f7374ce6..462c9f80263 100644 --- a/mysql-test/main/sp-code.result +++ b/mysql-test/main/sp-code.result @@ -847,8 +847,8 @@ drop procedure if exists p_20906_b; create procedure p_20906_a() SET @a=@a+1, @b=@b+1; show procedure code p_20906_a; Pos Instruction -0 stmt 31 "SET @a=@a+1" -1 stmt 31 "SET @b=@b+1" +0 stmt 31 "SET @a=@a+1" +1 stmt 31 "SET @b=@b+1" set @a=1; set @b=1; call p_20906_a(); @@ -858,9 +858,9 @@ select @a, @b; create procedure p_20906_b() SET @a=@a+1, @b=@b+1, @c=@c+1; show procedure code p_20906_b; Pos Instruction -0 stmt 31 "SET @a=@a+1" -1 stmt 31 "SET @b=@b+1" -2 stmt 31 "SET @c=@c+1" +0 stmt 31 "SET @a=@a+1" +1 stmt 31 "SET @b=@b+1" +2 stmt 31 "SET @c=@c+1" set @a=1; set @b=1; set @c=1; @@ -1356,3 +1356,21 @@ drop function f1; # # End of 10.3 tests # +# +# MDEV-19640 Wrong SHOW PROCEDURE output for SET GLOBAL sysvar1=expr, sysvar2=expr +# +CREATE OR REPLACE PROCEDURE p1() +BEGIN +SET GLOBAL max_allowed_packet=16000000, max_error_count=60; +SELECT @@GLOBAL.max_allowed_packet, @@GLOBAL.max_error_count; +END; +$$ +SHOW PROCEDURE CODE p1; +Pos Instruction +0 stmt 31 "SET GLOBAL max_allowed_packet=16000000" +1 stmt 31 "SET GLOBAL max_error_count=60" +2 stmt 0 "SELECT @@GLOBAL.max_allowed_packet, @..." +DROP PROCEDURE p1; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/sp-code.test b/mysql-test/main/sp-code.test index 35c9d4b9da1..eef3382f214 100644 --- a/mysql-test/main/sp-code.test +++ b/mysql-test/main/sp-code.test @@ -975,3 +975,23 @@ drop function f1; --echo # --echo # End of 10.3 tests --echo # + + +--echo # +--echo # MDEV-19640 Wrong SHOW PROCEDURE output for SET GLOBAL sysvar1=expr, sysvar2=expr +--echo # + +DELIMITER $$; +CREATE OR REPLACE PROCEDURE p1() +BEGIN + SET GLOBAL max_allowed_packet=16000000, max_error_count=60; + SELECT @@GLOBAL.max_allowed_packet, @@GLOBAL.max_error_count; +END; +$$ +DELIMITER ;$$ +SHOW PROCEDURE CODE p1; +DROP PROCEDURE p1; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/sp-error.result b/mysql-test/main/sp-error.result index 1fe5bd6b77b..f64735f8006 100644 --- a/mysql-test/main/sp-error.result +++ b/mysql-test/main/sp-error.result @@ -443,9 +443,7 @@ create procedure nodb.bug3339() begin end| ERROR 42000: Unknown database 'nodb' create procedure bug2653_1(a int, out b int) set b = aa| -call bug2653_1(1, @b)| -ERROR 42S22: Unknown column 'aa' in 'field list' -drop procedure bug2653_1| +ERROR 42000: Undeclared variable: aa create procedure bug2653_2(a int, out b int) begin if aa < 0 then @@ -1205,9 +1203,7 @@ set selectstr = concat(selectstr, c.operatorid, 'in (',conditionstr, ')'); end| -call bug15091(); -ERROR 42S02: Unknown table 'c' in field list -drop procedure bug15091; +ERROR 42000: Undeclared variable: c drop function if exists bug16896; create aggregate function bug16896() returns int return 1; ERROR HY000: Aggregate specific instruction(FETCH GROUP NEXT ROW) missing from the aggregate function @@ -2246,7 +2242,7 @@ H2 Warnings: Warning 1642 Unhandled user-defined warning condition -# -- Check that handlers are choosen properly in case of deep stack and +# -- Check that handlers are chosen properly in case of deep stack and # -- nested SQL-blocks. CREATE PROCEDURE p10() diff --git a/mysql-test/main/sp-error.test b/mysql-test/main/sp-error.test index 45a54fddad4..d2af9834823 100644 --- a/mysql-test/main/sp-error.test +++ b/mysql-test/main/sp-error.test @@ -607,13 +607,10 @@ create procedure nodb.bug3339() begin end| # # BUG#2653 # +--error ER_SP_UNDECLARED_VAR create procedure bug2653_1(a int, out b int) set b = aa| ---error ER_BAD_FIELD_ERROR -call bug2653_1(1, @b)| - -drop procedure bug2653_1| --error ER_SP_UNDECLARED_VAR create procedure bug2653_2(a int, out b int) @@ -1714,6 +1711,7 @@ drop procedure if exists bug15091; --enable_warnings delimiter |; +--error ER_SP_UNDECLARED_VAR create procedure bug15091() begin declare selectstr varchar(6000) default ' '; @@ -1726,15 +1724,6 @@ begin end| delimiter ;| -# The error message used to be: -# ERROR 1109 (42S02): Unknown table 'c' in order clause -# but is now rephrased to something less misleading: -# ERROR 1109 (42S02): Unknown table 'c' in field list ---error ER_UNKNOWN_TABLE -call bug15091(); - -drop procedure bug15091; - # # BUG#16896: Stored function: unused AGGREGATE-clause in CREATE FUNCTION @@ -3173,7 +3162,7 @@ END| CALL p9()| --echo ---echo # -- Check that handlers are choosen properly in case of deep stack and +--echo # -- Check that handlers are chosen properly in case of deep stack and --echo # -- nested SQL-blocks. --echo diff --git a/mysql-test/main/sp-row.result b/mysql-test/main/sp-row.result index 4b87798e0bb..7c257297934 100644 --- a/mysql-test/main/sp-row.result +++ b/mysql-test/main/sp-row.result @@ -189,7 +189,7 @@ SELECT a+1; END; $$ CALL p1(); -ERROR 21000: Operand should contain 1 column(s) +ERROR HY000: Illegal parameter data types row and int for operation '+' DROP PROCEDURE p1; CREATE PROCEDURE p1() BEGIN @@ -198,7 +198,7 @@ SELECT a+1; END; $$ CALL p1(); -ERROR 21000: Operand should contain 1 column(s) +ERROR HY000: Illegal parameter data types row and int for operation '+' DROP PROCEDURE p1; # # Comparing the entire ROW to a scalar value diff --git a/mysql-test/main/sp-row.test b/mysql-test/main/sp-row.test index 3352c940cb6..b9143b1113b 100644 --- a/mysql-test/main/sp-row.test +++ b/mysql-test/main/sp-row.test @@ -244,7 +244,7 @@ BEGIN END; $$ DELIMITER ;$$ ---error ER_OPERAND_COLUMNS +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION CALL p1(); DROP PROCEDURE p1; @@ -257,7 +257,7 @@ BEGIN END; $$ DELIMITER ;$$ ---error ER_OPERAND_COLUMNS +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION CALL p1(); DROP PROCEDURE p1; diff --git a/mysql-test/main/sp-security.result b/mysql-test/main/sp-security.result index 5050955c806..2c48883a509 100644 --- a/mysql-test/main/sp-security.result +++ b/mysql-test/main/sp-security.result @@ -417,7 +417,7 @@ CREATE DATABASE mysqltest; CREATE USER mysqltest_1@localhost; GRANT ALL PRIVILEGES ON mysqltest.* TO mysqltest_1@localhost; CREATE USER mysqltest_2@localhost; -GRANT SUPER ON *.* TO mysqltest_2@localhost; +GRANT SET USER ON *.* TO mysqltest_2@localhost; GRANT ALL PRIVILEGES ON mysqltest.* TO mysqltest_2@localhost; connect mysqltest_2_con,localhost,mysqltest_2,,mysqltest; connect mysqltest_1_con,localhost,mysqltest_1,,mysqltest; @@ -428,9 +428,9 @@ CREATE FUNCTION wl2897_f1() RETURNS INT RETURN 1; connection mysqltest_1_con; USE mysqltest; CREATE DEFINER=root@localhost PROCEDURE wl2897_p2() SELECT 2; -ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation +ERROR 42000: Access denied; you need (at least one of) the SUPER, SET USER privilege(s) for this operation CREATE DEFINER=root@localhost FUNCTION wl2897_f2() RETURNS INT RETURN 2; -ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation +ERROR 42000: Access denied; you need (at least one of) the SUPER, SET USER privilege(s) for this operation connection mysqltest_2_con; use mysqltest; CREATE DEFINER='a @ b @ c'@localhost PROCEDURE wl2897_p3() SELECT 3; @@ -802,3 +802,21 @@ connection default; DROP DATABASE u1; DROP USER u1@localhost; set @@global.character_set_server=@save_character_set_server; +# +# Start of 10.5 tests +# +# +# MDEV-20366 Server crashes in get_current_user upon SET PASSWORD via SP +# +CREATE PROCEDURE p1() SET PASSWORD FOR foo@localhost=PASSWORD('x'); +CALL p1(); +ERROR 28000: Can't find any matching row in the user table +DROP PROCEDURE p1; +CREATE USER foo@localhost; +CREATE PROCEDURE p1() SET PASSWORD FOR foo@localhost=PASSWORD('x'); +CALL p1(); +DROP PROCEDURE p1; +DROP USER foo@localhost; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/sp-security.test b/mysql-test/main/sp-security.test index acc05cafa21..e7790bf703a 100644 --- a/mysql-test/main/sp-security.test +++ b/mysql-test/main/sp-security.test @@ -594,7 +594,7 @@ CREATE USER mysqltest_1@localhost; GRANT ALL PRIVILEGES ON mysqltest.* TO mysqltest_1@localhost; CREATE USER mysqltest_2@localhost; -GRANT SUPER ON *.* TO mysqltest_2@localhost; +GRANT SET USER ON *.* TO mysqltest_2@localhost; GRANT ALL PRIVILEGES ON mysqltest.* TO mysqltest_2@localhost; --connect (mysqltest_2_con,localhost,mysqltest_2,,mysqltest) @@ -1078,3 +1078,30 @@ DROP DATABASE u1; DROP USER u1@localhost; set @@global.character_set_server=@save_character_set_server; + + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-20366 Server crashes in get_current_user upon SET PASSWORD via SP +--echo # + +# Testing without the user +CREATE PROCEDURE p1() SET PASSWORD FOR foo@localhost=PASSWORD('x'); +--error ER_PASSWORD_NO_MATCH +CALL p1(); +DROP PROCEDURE p1; + +# Testing with the user +CREATE USER foo@localhost; +CREATE PROCEDURE p1() SET PASSWORD FOR foo@localhost=PASSWORD('x'); +CALL p1(); +DROP PROCEDURE p1; +DROP USER foo@localhost; + + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/sp-vars.result b/mysql-test/main/sp-vars.result index 236695a6c0f..4952746c4e0 100644 --- a/mysql-test/main/sp-vars.result +++ b/mysql-test/main/sp-vars.result @@ -1310,3 +1310,406 @@ t1 CREATE TABLE "t1" ( "var" char(1) DEFAULT NULL ) DROP TABLE t1; +# +# MDEV-14347 CREATE PROCEDURE returns no error when using an unknown variable +# +# +# Simple cases (without subqueries) - the most typical problem: +# a typo in an SP variable name +# +CREATE PROCEDURE p1(a INT) +BEGIN +DECLARE res INT DEFAULT 0; +IF (a < 0) THEN +SET res= a_long_variable_name_with_a_typo; +END IF; +END; +$$ +ERROR 42000: Undeclared variable: a_long_variable_name_with_a_typo +CREATE PROCEDURE p1(a INT) +BEGIN +DECLARE res INT DEFAULT 0; +IF (a < 0) THEN +SET res= 1 + a_long_variable_name_with_a_typo; +END IF; +END; +$$ +ERROR 42000: Undeclared variable: a_long_variable_name_with_a_typo +# +# Complex cases with subqueries +# +# +# Maybe a table field identifier (there are some tables) - no error +# +CREATE PROCEDURE p1() +BEGIN +DECLARE res INT DEFAULT 0; +SET res=(SELECT * FROM t1 LEFT OUTER JOIN t2 USING (c1)); +END; +$$ +DROP PROCEDURE p1; +CREATE PROCEDURE p1() +BEGIN +DECLARE res INT DEFAULT 0; +SET res=(SELECT * FROM t1 LEFT OUTER JOIN t2 ON (c1=c2)); +END; +$$ +DROP PROCEDURE p1; +# +# One unknown identifier, no tables +# +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=unknown_ident; +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=unknown_ident1.unknown_ident2; +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident1 +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=unknown_ident1.unknown_ident2.unknown_ident3; +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident1 +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=(SELECT unknown_ident); +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=(SELECT unknown_ident FROM dual); +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=(SELECT (SELECT unknown_ident)); +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=(SELECT (SELECT unknown_ident FROM dual)); +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=(SELECT 1 WHERE unknown_ident); +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=(SELECT 1 WHERE unknown_ident=1); +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=(SELECT 1 LIMIT unknown_ident); +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +# +# GROUP, HAVING, ORDER are not tested yet for unknown identifiers +# +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=(SELECT 1 GROUP BY unknown_ident); +END; +$$ +DROP PROCEDURE p1; +CREATE PROCEDURE p1() +BEGIN +DECLARE res INT DEFAULT 0; +SET res=(SELECT 1 HAVING unknown_ident); +END; +$$ +DROP PROCEDURE p1; +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=(SELECT 1 ORDER BY unknown_ident); +END; +$$ +DROP PROCEDURE p1; +# +# HAVING + aggregate_function(unknown_identifier) is a special case +# +CREATE PROCEDURE p1() +BEGIN +DECLARE res INT DEFAULT 0; +SET res=(SELECT 1 HAVING SUM(unknown_ident)); +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +# +# Known indentifier + unknown identifier, no tables +# +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=a+unknown_ident; +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=a+(SELECT unknown_ident); +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=a+(SELECT unknown_ident FROM dual); +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=(SELECT (a+(SELECT unknown_ident))); +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=(SELECT (a+(SELECT unknown_ident FROM dual))); +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +# +# Unknown indentifier + known identifier, no tables +# +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=unknown_ident+a; +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=(SELECT unknown_ident)+a; +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=(SELECT unknown_ident FROM dual)+a; +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=(SELECT (SELECT unknown_ident)+a); +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=(SELECT (SELECT unknown_ident FROM dual)+a); +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +# +# Maybe a table field indentifier + unknown identifier +# +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=(SELECT c1 FROM t1)+unknown_ident; +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=(SELECT c1 FROM t1)+(SELECT unknown_ident); +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=(SELECT c1 FROM t1)+(SELECT unknown_ident FROM dual); +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=(SELECT ((SELECT c1 FROM t1)+(SELECT unknown_ident))); +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=(SELECT ((SELECT c1 FROM t1)+(SELECT unknown_ident FROM dual))); +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +# +# Unknown indentifier + maybe a table field identifier +# +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=unknown_ident+(SELECT c1 FROM t1); +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=(SELECT unknown_ident)+(SELECT c1 FROM t1); +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=(SELECT unknown_ident FROM dual)+(SELECT c1 FROM t1); +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=(SELECT (SELECT unknown_ident)+(SELECT c1 FROM t1)); +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +SET a=(SELECT (SELECT unknown_ident FROM dual)+(SELECT c1 FROM t1)); +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +# +# Maybe a table field identifier + maybe a field table identifier +# +CREATE PROCEDURE p1() +BEGIN +DECLARE a INT; +-- c2 does not have a table on its level +-- but it can be a field of a table on the uppder level, i.e. t1 +SET a=(SELECT c1+(SELECT c2) FROM t1); +END; +$$ +DROP PROCEDURE p1; +# +# TVC - unknown identifier +# +CREATE PROCEDURE p1(a INT) +BEGIN +DECLARE res INT DEFAULT 0; +SET res=(VALUES(unknown_ident)); +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +CREATE PROCEDURE p1(a INT) +BEGIN +DECLARE res INT DEFAULT 0; +SET res=(VALUES(1),(unknown_ident)); +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +CREATE PROCEDURE p1(a INT) +BEGIN +DECLARE res INT DEFAULT 0; +SET res=(VALUES((SELECT unknown_ident))); +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +CREATE PROCEDURE p1(a INT) +BEGIN +DECLARE res INT DEFAULT 0; +SET res=(VALUES(1),((SELECT unknown_ident))); +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +CREATE PROCEDURE p1(a INT) +BEGIN +DECLARE res INT DEFAULT 0; +SET res=(VALUES(1) LIMIT unknown_ident); +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +# +# TVC - ORDER BY - not tested yet for unknown identifiers +# +CREATE PROCEDURE p1(a INT) +BEGIN +DECLARE res INT DEFAULT 0; +SET res=(VALUES(1) ORDER BY unknown_ident); +END; +$$ +DROP PROCEDURE p1; +# +# TVC - maybe a table field identifier - no error +# +CREATE PROCEDURE p1(a INT) +BEGIN +DECLARE res INT DEFAULT 0; +SET res=(VALUES((SELECT c1 FROM t1))); +END; +$$ +DROP PROCEDURE p1; +CREATE PROCEDURE p1(a INT) +BEGIN +DECLARE res INT DEFAULT 0; +SET res=(VALUES(1),((SELECT c1 FROM t1))); +END; +$$ +DROP PROCEDURE p1; +# +# Functions DEFAULT(x) and VALUE(x) +# +CREATE PROCEDURE p1() +BEGIN +DECLARE res INT DEFAULT 0; +SET res=DEFAULT(unknown_ident); +SELECT res; +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +CREATE PROCEDURE p1() +BEGIN +DECLARE res INT DEFAULT 0; +SET res=VALUE(unknown_ident); +SELECT res; +END; +$$ +ERROR 42000: Undeclared variable: unknown_ident +# +# End of MDEV-14347 CREATE PROCEDURE returns no error when using an unknown variable +# diff --git a/mysql-test/main/sp-vars.test b/mysql-test/main/sp-vars.test index ba8cd4f5ca8..9edf245acbe 100644 --- a/mysql-test/main/sp-vars.test +++ b/mysql-test/main/sp-vars.test @@ -1603,3 +1603,594 @@ $$ DELIMITER ;$$ SHOW CREATE TABLE t1; DROP TABLE t1; + + + +--echo # +--echo # MDEV-14347 CREATE PROCEDURE returns no error when using an unknown variable +--echo # + +--echo # +--echo # Simple cases (without subqueries) - the most typical problem: +--echo # a typo in an SP variable name +--echo # + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1(a INT) +BEGIN + DECLARE res INT DEFAULT 0; + IF (a < 0) THEN + SET res= a_long_variable_name_with_a_typo; + END IF; +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1(a INT) +BEGIN + DECLARE res INT DEFAULT 0; + IF (a < 0) THEN + SET res= 1 + a_long_variable_name_with_a_typo; + END IF; +END; +$$ +DELIMITER ;$$ + + +--echo # +--echo # Complex cases with subqueries +--echo # + +--echo # +--echo # Maybe a table field identifier (there are some tables) - no error +--echo # + +DELIMITER $$; +CREATE PROCEDURE p1() +BEGIN + DECLARE res INT DEFAULT 0; + SET res=(SELECT * FROM t1 LEFT OUTER JOIN t2 USING (c1)); +END; +$$ +DELIMITER ;$$ +DROP PROCEDURE p1; + +DELIMITER $$; +CREATE PROCEDURE p1() +BEGIN + DECLARE res INT DEFAULT 0; + SET res=(SELECT * FROM t1 LEFT OUTER JOIN t2 ON (c1=c2)); +END; +$$ +DELIMITER ;$$ +DROP PROCEDURE p1; + + +--echo # +--echo # One unknown identifier, no tables +--echo # + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=unknown_ident; +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=unknown_ident1.unknown_ident2; +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=unknown_ident1.unknown_ident2.unknown_ident3; +END; +$$ +DELIMITER ;$$ + + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=(SELECT unknown_ident); +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=(SELECT unknown_ident FROM dual); +END; +$$ +DELIMITER ;$$ + + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=(SELECT (SELECT unknown_ident)); +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=(SELECT (SELECT unknown_ident FROM dual)); +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=(SELECT 1 WHERE unknown_ident); +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=(SELECT 1 WHERE unknown_ident=1); +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=(SELECT 1 LIMIT unknown_ident); +END; +$$ +DELIMITER ;$$ + + +--echo # +--echo # GROUP, HAVING, ORDER are not tested yet for unknown identifiers +--echo # + +DELIMITER $$; +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=(SELECT 1 GROUP BY unknown_ident); +END; +$$ +DELIMITER ;$$ +DROP PROCEDURE p1; + + +DELIMITER $$; +CREATE PROCEDURE p1() +BEGIN + DECLARE res INT DEFAULT 0; + SET res=(SELECT 1 HAVING unknown_ident); +END; +$$ +DELIMITER ;$$ +DROP PROCEDURE p1; + + +DELIMITER $$; +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=(SELECT 1 ORDER BY unknown_ident); +END; +$$ +DELIMITER ;$$ +DROP PROCEDURE p1; + + +--echo # +--echo # HAVING + aggregate_function(unknown_identifier) is a special case +--echo # + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE res INT DEFAULT 0; + SET res=(SELECT 1 HAVING SUM(unknown_ident)); +END; +$$ +DELIMITER ;$$ + + +--echo # +--echo # Known indentifier + unknown identifier, no tables +--echo # + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=a+unknown_ident; +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=a+(SELECT unknown_ident); +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=a+(SELECT unknown_ident FROM dual); +END; +$$ +DELIMITER ;$$ + + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=(SELECT (a+(SELECT unknown_ident))); +END; +$$ +DELIMITER ;$$ + + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=(SELECT (a+(SELECT unknown_ident FROM dual))); +END; +$$ +DELIMITER ;$$ + + +--echo # +--echo # Unknown indentifier + known identifier, no tables +--echo # + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=unknown_ident+a; +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=(SELECT unknown_ident)+a; +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=(SELECT unknown_ident FROM dual)+a; +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=(SELECT (SELECT unknown_ident)+a); +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=(SELECT (SELECT unknown_ident FROM dual)+a); +END; +$$ +DELIMITER ;$$ + + +--echo # +--echo # Maybe a table field indentifier + unknown identifier +--echo # + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=(SELECT c1 FROM t1)+unknown_ident; +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=(SELECT c1 FROM t1)+(SELECT unknown_ident); +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=(SELECT c1 FROM t1)+(SELECT unknown_ident FROM dual); +END; +$$ +DELIMITER ;$$ + + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=(SELECT ((SELECT c1 FROM t1)+(SELECT unknown_ident))); +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=(SELECT ((SELECT c1 FROM t1)+(SELECT unknown_ident FROM dual))); +END; +$$ +DELIMITER ;$$ + + +--echo # +--echo # Unknown indentifier + maybe a table field identifier +--echo # + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=unknown_ident+(SELECT c1 FROM t1); +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=(SELECT unknown_ident)+(SELECT c1 FROM t1); +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=(SELECT unknown_ident FROM dual)+(SELECT c1 FROM t1); +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=(SELECT (SELECT unknown_ident)+(SELECT c1 FROM t1)); +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + SET a=(SELECT (SELECT unknown_ident FROM dual)+(SELECT c1 FROM t1)); +END; +$$ +DELIMITER ;$$ + + +--echo # +--echo # Maybe a table field identifier + maybe a field table identifier +--echo # + +DELIMITER $$; +CREATE PROCEDURE p1() +BEGIN + DECLARE a INT; + -- c2 does not have a table on its level + -- but it can be a field of a table on the uppder level, i.e. t1 + SET a=(SELECT c1+(SELECT c2) FROM t1); +END; +$$ +DELIMITER ;$$ +DROP PROCEDURE p1; + + +--echo # +--echo # TVC - unknown identifier +--echo # + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1(a INT) +BEGIN + DECLARE res INT DEFAULT 0; + SET res=(VALUES(unknown_ident)); +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1(a INT) +BEGIN + DECLARE res INT DEFAULT 0; + SET res=(VALUES(1),(unknown_ident)); +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1(a INT) +BEGIN + DECLARE res INT DEFAULT 0; + SET res=(VALUES((SELECT unknown_ident))); +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1(a INT) +BEGIN + DECLARE res INT DEFAULT 0; + SET res=(VALUES(1),((SELECT unknown_ident))); +END; +$$ +DELIMITER ;$$ + + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1(a INT) +BEGIN + DECLARE res INT DEFAULT 0; + SET res=(VALUES(1) LIMIT unknown_ident); +END; +$$ +DELIMITER ;$$ + + +--echo # +--echo # TVC - ORDER BY - not tested yet for unknown identifiers +--echo # + +DELIMITER $$; +CREATE PROCEDURE p1(a INT) +BEGIN + DECLARE res INT DEFAULT 0; + SET res=(VALUES(1) ORDER BY unknown_ident); +END; +$$ +DELIMITER ;$$ +DROP PROCEDURE p1; + + +--echo # +--echo # TVC - maybe a table field identifier - no error +--echo # + +DELIMITER $$; +CREATE PROCEDURE p1(a INT) +BEGIN + DECLARE res INT DEFAULT 0; + SET res=(VALUES((SELECT c1 FROM t1))); +END; +$$ +DELIMITER ;$$ +DROP PROCEDURE p1; + +DELIMITER $$; +CREATE PROCEDURE p1(a INT) +BEGIN + DECLARE res INT DEFAULT 0; + SET res=(VALUES(1),((SELECT c1 FROM t1))); +END; +$$ +DELIMITER ;$$ +DROP PROCEDURE p1; + + +--echo # +--echo # Functions DEFAULT(x) and VALUE(x) +--echo # + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE res INT DEFAULT 0; + SET res=DEFAULT(unknown_ident); + SELECT res; +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_UNDECLARED_VAR +CREATE PROCEDURE p1() +BEGIN + DECLARE res INT DEFAULT 0; + SET res=VALUE(unknown_ident); + SELECT res; +END; +$$ +DELIMITER ;$$ + + +--echo # +--echo # End of MDEV-14347 CREATE PROCEDURE returns no error when using an unknown variable +--echo # diff --git a/mysql-test/main/sp.result b/mysql-test/main/sp.result index e6665af8442..135734a513d 100644 --- a/mysql-test/main/sp.result +++ b/mysql-test/main/sp.result @@ -3220,9 +3220,7 @@ Warnings: Note 4092 Unknown VIEW: 'test.tv' DROP TABLE IF EXISTS tt1,tt2,tt3| Warnings: -Note 1051 Unknown table 'test.tt1' -Note 1051 Unknown table 'test.tt2' -Note 1051 Unknown table 'test.tt3' +Note 1051 Unknown table 'test.tt1,test.tt2,test.tt3' CREATE TABLE tt1 (a1 int, a2 int, a3 int, data varchar(10))| CREATE TABLE tt2 (a2 int, data2 varchar(10))| CREATE TABLE tt3 (a3 int, data3 varchar(10))| diff --git a/mysql-test/main/sp_gis.result b/mysql-test/main/sp_gis.result index 7a76507754f..35c7e52e833 100644 --- a/mysql-test/main/sp_gis.result +++ b/mysql-test/main/sp_gis.result @@ -28,3 +28,75 @@ test.a() test.x() test.y() drop function a; drop function x; drop function y; +# +# Start of 10.5 tests +# +# +# MDEV-19944 Remove GIS data types from keyword list in lex.h +# +CREATE FUNCTION point() RETURNS POINT RETURN NULL; +Warnings: +Note 1585 This function 'point' has the same name as a native function +SELECT point(); +point() +NULL +DROP FUNCTION point; +CREATE FUNCTION point(x INT) RETURNS POINT RETURN NULL; +Warnings: +Note 1585 This function 'point' has the same name as a native function +SELECT point(1); +point(1) +NULL +DROP FUNCTION point; +CREATE FUNCTION point(x INT, y INT) RETURNS POINT RETURN NULL; +Warnings: +Note 1585 This function 'point' has the same name as a native function +SELECT AsText(point(1,1)); +AsText(point(1,1)) +POINT(1 1) +DROP FUNCTION point; +CREATE FUNCTION linestring() RETURNS POINT RETURN NULL; +Warnings: +Note 1585 This function 'linestring' has the same name as a native function +SELECT linestring(); +linestring() +NULL +DROP FUNCTION linestring; +CREATE FUNCTION polygon() RETURNS POINT RETURN NULL; +Warnings: +Note 1585 This function 'polygon' has the same name as a native function +SELECT polygon(); +polygon() +NULL +DROP FUNCTION polygon; +CREATE FUNCTION multipoint() RETURNS POINT RETURN NULL; +Warnings: +Note 1585 This function 'multipoint' has the same name as a native function +SELECT multipoint(); +multipoint() +NULL +DROP FUNCTION multipoint; +CREATE FUNCTION multilinestring() RETURNS POINT RETURN NULL; +Warnings: +Note 1585 This function 'multilinestring' has the same name as a native function +SELECT multilinestring(); +multilinestring() +NULL +DROP FUNCTION multilinestring; +CREATE FUNCTION multipolygon() RETURNS POINT RETURN NULL; +Warnings: +Note 1585 This function 'multipolygon' has the same name as a native function +SELECT multipolygon(); +multipolygon() +NULL +DROP FUNCTION multipolygon; +CREATE FUNCTION geometrycollection() RETURNS POINT RETURN NULL; +Warnings: +Note 1585 This function 'geometrycollection' has the same name as a native function +SELECT geometrycollection(); +geometrycollection() +NULL +DROP FUNCTION geometrycollection; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/sp_gis.test b/mysql-test/main/sp_gis.test index 51ed78b27d5..4148a4ec423 100644 --- a/mysql-test/main/sp_gis.test +++ b/mysql-test/main/sp_gis.test @@ -37,3 +37,66 @@ drop function a; drop function x; drop function y; +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-19944 Remove GIS data types from keyword list in lex.h +--echo # + +CREATE FUNCTION point() RETURNS POINT RETURN NULL; +--disable_warnings +SELECT point(); +--enable_warnings +DROP FUNCTION point; + +CREATE FUNCTION point(x INT) RETURNS POINT RETURN NULL; +--disable_warnings +SELECT point(1); +--enable_warnings +DROP FUNCTION point; + +CREATE FUNCTION point(x INT, y INT) RETURNS POINT RETURN NULL; +SELECT AsText(point(1,1)); +DROP FUNCTION point; + +CREATE FUNCTION linestring() RETURNS POINT RETURN NULL; +--disable_warnings +SELECT linestring(); +--enable_warnings +DROP FUNCTION linestring; + +CREATE FUNCTION polygon() RETURNS POINT RETURN NULL; +--disable_warnings +SELECT polygon(); +--enable_warnings +DROP FUNCTION polygon; + +CREATE FUNCTION multipoint() RETURNS POINT RETURN NULL; +--disable_warnings +SELECT multipoint(); +--enable_warnings +DROP FUNCTION multipoint; + +CREATE FUNCTION multilinestring() RETURNS POINT RETURN NULL; +--disable_warnings +SELECT multilinestring(); +--enable_warnings +DROP FUNCTION multilinestring; + +CREATE FUNCTION multipolygon() RETURNS POINT RETURN NULL; +--disable_warnings +SELECT multipolygon(); +--enable_warnings +DROP FUNCTION multipolygon; + +CREATE FUNCTION geometrycollection() RETURNS POINT RETURN NULL; +--disable_warnings +SELECT geometrycollection(); +--enable_warnings +DROP FUNCTION geometrycollection; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/sp_trans.result b/mysql-test/main/sp_trans.result index cee2a7e5188..58ef4ad15f7 100644 --- a/mysql-test/main/sp_trans.result +++ b/mysql-test/main/sp_trans.result @@ -557,22 +557,22 @@ f1 bug13575(f1) 3 ccc drop function bug13575| drop table t3| -SELECT @@GLOBAL.storage_engine INTO @old_engine| -SET @@GLOBAL.storage_engine=InnoDB| -SET @@SESSION.storage_engine=InnoDB| -SHOW GLOBAL VARIABLES LIKE 'storage_engine'| +SELECT @@GLOBAL.default_storage_engine INTO @old_engine| +SET @@GLOBAL.default_storage_engine=InnoDB| +SET @@SESSION.default_storage_engine=InnoDB| +SHOW GLOBAL VARIABLES LIKE 'default_storage_engine'| Variable_name Value -storage_engine InnoDB -SHOW SESSION VARIABLES LIKE 'storage_engine'| +default_storage_engine InnoDB +SHOW SESSION VARIABLES LIKE 'default_storage_engine'| Variable_name Value -storage_engine InnoDB +default_storage_engine InnoDB CREATE PROCEDURE bug11758414() BEGIN -SET @@GLOBAL.storage_engine="MyISAM"; -SET @@SESSION.storage_engine="MyISAM"; +SET @@GLOBAL.default_storage_engine="MyISAM"; +SET @@SESSION.default_storage_engine="MyISAM"; # show defaults at execution time / that setting them worked -SHOW GLOBAL VARIABLES LIKE 'storage_engine'; -SHOW SESSION VARIABLES LIKE 'storage_engine'; +SHOW GLOBAL VARIABLES LIKE 'default_storage_engine'; +SHOW SESSION VARIABLES LIKE 'default_storage_engine'; CREATE TABLE t1 (id int); CREATE TABLE t2 (id int) ENGINE=InnoDB; # show we're heeding the default (at run-time, not parse-time!) @@ -583,9 +583,9 @@ END; | CALL bug11758414| Variable_name Value -storage_engine MyISAM +default_storage_engine MyISAM Variable_name Value -storage_engine MyISAM +default_storage_engine MyISAM Table Create Table t1 CREATE TABLE `t1` ( `id` int(11) DEFAULT NULL @@ -594,15 +594,15 @@ Table Create Table t2 CREATE TABLE `t2` ( `id` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -SHOW GLOBAL VARIABLES LIKE 'storage_engine'| +SHOW GLOBAL VARIABLES LIKE 'default_storage_engine'| Variable_name Value -storage_engine MyISAM -SHOW SESSION VARIABLES LIKE 'storage_engine'| +default_storage_engine MyISAM +SHOW SESSION VARIABLES LIKE 'default_storage_engine'| Variable_name Value -storage_engine MyISAM +default_storage_engine MyISAM DROP PROCEDURE bug11758414| DROP TABLE t1, t2| -SET @@GLOBAL.storage_engine=@old_engine| +SET @@GLOBAL.default_storage_engine=@old_engine| # # End of 5.1 tests # diff --git a/mysql-test/main/sp_trans.test b/mysql-test/main/sp_trans.test index 7d6faba9789..b39c13287ed 100644 --- a/mysql-test/main/sp_trans.test +++ b/mysql-test/main/sp_trans.test @@ -601,22 +601,22 @@ drop function bug13575| drop table t3| # -# BUG#11758414: Default storage_engine not honored when set +# BUG#11758414: Default default_storage_engine not honored when set # from within a stored procedure # -SELECT @@GLOBAL.storage_engine INTO @old_engine| -SET @@GLOBAL.storage_engine=InnoDB| -SET @@SESSION.storage_engine=InnoDB| +SELECT @@GLOBAL.default_storage_engine INTO @old_engine| +SET @@GLOBAL.default_storage_engine=InnoDB| +SET @@SESSION.default_storage_engine=InnoDB| # show defaults at define-time -SHOW GLOBAL VARIABLES LIKE 'storage_engine'| -SHOW SESSION VARIABLES LIKE 'storage_engine'| +SHOW GLOBAL VARIABLES LIKE 'default_storage_engine'| +SHOW SESSION VARIABLES LIKE 'default_storage_engine'| CREATE PROCEDURE bug11758414() BEGIN - SET @@GLOBAL.storage_engine="MyISAM"; - SET @@SESSION.storage_engine="MyISAM"; + SET @@GLOBAL.default_storage_engine="MyISAM"; + SET @@SESSION.default_storage_engine="MyISAM"; # show defaults at execution time / that setting them worked - SHOW GLOBAL VARIABLES LIKE 'storage_engine'; - SHOW SESSION VARIABLES LIKE 'storage_engine'; + SHOW GLOBAL VARIABLES LIKE 'default_storage_engine'; + SHOW SESSION VARIABLES LIKE 'default_storage_engine'; CREATE TABLE t1 (id int); CREATE TABLE t2 (id int) ENGINE=InnoDB; # show we're heeding the default (at run-time, not parse-time!) @@ -627,11 +627,11 @@ END; | CALL bug11758414| # show that changing defaults within SP stuck -SHOW GLOBAL VARIABLES LIKE 'storage_engine'| -SHOW SESSION VARIABLES LIKE 'storage_engine'| +SHOW GLOBAL VARIABLES LIKE 'default_storage_engine'| +SHOW SESSION VARIABLES LIKE 'default_storage_engine'| DROP PROCEDURE bug11758414| DROP TABLE t1, t2| -SET @@GLOBAL.storage_engine=@old_engine| +SET @@GLOBAL.default_storage_engine=@old_engine| --echo # --echo # End of 5.1 tests diff --git a/mysql-test/main/ssl.result b/mysql-test/main/ssl.result index 00faea58fd2..40a32fdd1dd 100644 --- a/mysql-test/main/ssl.result +++ b/mysql-test/main/ssl.result @@ -518,7 +518,7 @@ insert into tmp select * from t3; insert into t3 select * from tmp; alter table t3 add t2nr int not null auto_increment primary key first; drop table tmp; -SET BIG_TABLES=1; +set tmp_memory_table_size=0; select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10; namn Abraham Abraham @@ -531,7 +531,7 @@ ammonium ammonium analyzable analyzable animals animals animized animized -SET BIG_TABLES=0; +set tmp_memory_table_size=default; select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10; concat(fld3," ",fld3) Abraham Abraham @@ -568,7 +568,7 @@ attendants 1 bedlam 1 bedpost 1 boasted 1 -SET BIG_TABLES=1; +set tmp_memory_table_size=0; select distinct fld3,count(*) from t2 group by companynr,fld3 limit 10; fld3 count(*) affixed 1 @@ -581,7 +581,7 @@ attendants 1 bedlam 1 bedpost 1 boasted 1 -SET BIG_TABLES=0; +set tmp_memory_table_size=default; select distinct fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr,fld3 limit 100,10; fld3 repeat("a",length(fld3)) count(*) circus aaaaaa 1 diff --git a/mysql-test/main/ssl_compress.result b/mysql-test/main/ssl_compress.result index d298f8ec6e4..8c63c798afa 100644 --- a/mysql-test/main/ssl_compress.result +++ b/mysql-test/main/ssl_compress.result @@ -515,7 +515,7 @@ insert into tmp select * from t3; insert into t3 select * from tmp; alter table t3 add t2nr int not null auto_increment primary key first; drop table tmp; -SET BIG_TABLES=1; +set tmp_memory_table_size=0; select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10; namn Abraham Abraham @@ -528,7 +528,7 @@ ammonium ammonium analyzable analyzable animals animals animized animized -SET BIG_TABLES=0; +set tmp_memory_table_size=default; select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10; concat(fld3," ",fld3) Abraham Abraham @@ -565,7 +565,7 @@ attendants 1 bedlam 1 bedpost 1 boasted 1 -SET BIG_TABLES=1; +set tmp_memory_table_size=0; select distinct fld3,count(*) from t2 group by companynr,fld3 limit 10; fld3 count(*) affixed 1 @@ -578,7 +578,7 @@ attendants 1 bedlam 1 bedpost 1 boasted 1 -SET BIG_TABLES=0; +set tmp_memory_table_size=default; select distinct fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr,fld3 limit 100,10; fld3 repeat("a",length(fld3)) count(*) circus aaaaaa 1 diff --git a/mysql-test/main/stack-crash.result b/mysql-test/main/stack-crash.result index 62870db79f3..8c0001e748a 100644 --- a/mysql-test/main/stack-crash.result +++ b/mysql-test/main/stack-crash.result @@ -1,7 +1,6 @@ drop table if exists t1,t2; Warnings: -Note 1051 Unknown table 'test.t1' -Note 1051 Unknown table 'test.t2' +Note 1051 Unknown table 'test.t1,test.t2' CREATE TABLE t1 ( `sspo_id` int(11) NOT NULL AUTO_INCREMENT, `sspo_uid` int(11) NOT NULL DEFAULT '0', diff --git a/mysql-test/main/stat_tables.result b/mysql-test/main/stat_tables.result index 53557b39b05..a5089c609d2 100644 --- a/mysql-test/main/stat_tables.result +++ b/mysql-test/main/stat_tables.result @@ -74,7 +74,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1 1 SIMPLE customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6 1 SIMPLE orders ref|filter PRIMARY,i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (12%) Using where; Using rowid filter -1 SIMPLE lineitem ref PRIMARY,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where +1 SIMPLE lineitem ref PRIMARY,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 Using where select n_name, sum(l_extendedprice * (1 - l_discount)) as revenue from customer, orders, lineitem, supplier, nation, region where c_custkey = o_custkey and l_orderkey = o_orderkey @@ -181,7 +181,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1 1 SIMPLE customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6 1 SIMPLE orders ref|filter PRIMARY,i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (12%) Using where; Using rowid filter -1 SIMPLE lineitem ref PRIMARY,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where +1 SIMPLE lineitem ref PRIMARY,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 Using where select n_name, sum(l_extendedprice * (1 - l_discount)) as revenue from customer, orders, lineitem, supplier, nation, region where c_custkey = o_custkey and l_orderkey = o_orderkey @@ -214,10 +214,10 @@ order by o_year; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE region ALL PRIMARY NULL NULL NULL 5 Using where; Using temporary; Using filesort 1 SIMPLE part ALL PRIMARY NULL NULL NULL 200 Using where; Using join buffer (flat, BNL join) -1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_suppkey_partkey 5 dbt3_s001.part.p_partkey 30 Using index condition +1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_partkey 5 dbt3_s001.part.p_partkey 30 Using where 1 SIMPLE supplier eq_ref PRIMARY,i_s_nationkey PRIMARY 4 dbt3_s001.lineitem.l_suppkey 1 Using where +1 SIMPLE orders eq_ref|filter PRIMARY,i_o_orderdate,i_o_custkey PRIMARY|i_o_orderdate 4|4 dbt3_s001.lineitem.l_orderkey 1 (27%) Using where; Using rowid filter 1 SIMPLE n2 eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 -1 SIMPLE orders eq_ref PRIMARY,i_o_orderdate,i_o_custkey PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where 1 SIMPLE customer eq_ref PRIMARY,i_c_nationkey PRIMARY 4 dbt3_s001.orders.o_custkey 1 Using where 1 SIMPLE n1 eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.customer.c_nationkey 1 Using where select o_year, @@ -337,7 +337,7 @@ and o_orderkey=l_orderkey and p_partkey=l_partkey; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE part range PRIMARY,i_p_retailprice i_p_retailprice 9 NULL 1 Using index condition 1 SIMPLE orders ref PRIMARY,i_o_orderdate i_o_orderdate 4 const 1 -1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where +1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 Using where select o_orderkey, p_partkey from part, lineitem, orders where p_retailprice > 1100 and o_orderdate='1997-01-01' diff --git a/mysql-test/main/stat_tables_disabled.result b/mysql-test/main/stat_tables_disabled.result index c974bba5a4b..14be9535ea4 100644 --- a/mysql-test/main/stat_tables_disabled.result +++ b/mysql-test/main/stat_tables_disabled.result @@ -3,7 +3,7 @@ set @innodb_stats_persistent_sample_pages_save= @@innodb_stats_persistent_sample_pages; set global innodb_stats_persistent= 1; set global innodb_stats_persistent_sample_pages=100; -SET SESSION STORAGE_ENGINE='InnoDB'; +SET SESSION DEFAULT_STORAGE_ENGINE='InnoDB'; select @@global.use_stat_tables; @@global.use_stat_tables PREFERABLY @@ -73,7 +73,7 @@ set optimizer_switch=@save_optimizer_switch; DROP DATABASE dbt3_s001; use test; set use_stat_tables=@save_use_stat_tables; -SET SESSION STORAGE_ENGINE=DEFAULT; +SET SESSION DEFAULT_STORAGE_ENGINE=DEFAULT; set global innodb_stats_persistent= @innodb_stats_persistent_save; set global innodb_stats_persistent_sample_pages= @innodb_stats_persistent_sample_pages_save; diff --git a/mysql-test/main/stat_tables_disabled.test b/mysql-test/main/stat_tables_disabled.test index 427cf4874bc..e6b965afe34 100644 --- a/mysql-test/main/stat_tables_disabled.test +++ b/mysql-test/main/stat_tables_disabled.test @@ -6,7 +6,7 @@ set global innodb_stats_persistent= 1; set global innodb_stats_persistent_sample_pages=100; --source include/have_innodb.inc -SET SESSION STORAGE_ENGINE='InnoDB'; +SET SESSION DEFAULT_STORAGE_ENGINE='InnoDB'; select @@global.use_stat_tables; select @@session.use_stat_tables; @@ -82,7 +82,7 @@ use test; set use_stat_tables=@save_use_stat_tables; -SET SESSION STORAGE_ENGINE=DEFAULT; +SET SESSION DEFAULT_STORAGE_ENGINE=DEFAULT; set global innodb_stats_persistent= @innodb_stats_persistent_save; set global innodb_stats_persistent_sample_pages= diff --git a/mysql-test/main/stat_tables_innodb.result b/mysql-test/main/stat_tables_innodb.result index 41fd303ed4c..6fafac8776b 100644 --- a/mysql-test/main/stat_tables_innodb.result +++ b/mysql-test/main/stat_tables_innodb.result @@ -1,4 +1,4 @@ -SET SESSION STORAGE_ENGINE='InnoDB'; +SET SESSION DEFAULT_STORAGE_ENGINE='InnoDB'; set @save_optimizer_switch_for_stat_tables_test=@@optimizer_switch; set optimizer_switch='extended_keys=on'; set @innodb_stats_persistent_save= @@innodb_stats_persistent; @@ -246,7 +246,7 @@ order by o_year; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE region ALL PRIMARY NULL NULL NULL 5 Using where; Using temporary; Using filesort 1 SIMPLE part ALL PRIMARY NULL NULL NULL 200 Using where; Using join buffer (flat, BNL join) -1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_suppkey_partkey 5 dbt3_s001.part.p_partkey 30 Using index condition +1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_partkey 5 dbt3_s001.part.p_partkey 30 Using where 1 SIMPLE supplier eq_ref PRIMARY,i_s_nationkey PRIMARY 4 dbt3_s001.lineitem.l_suppkey 1 Using where 1 SIMPLE n2 eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 1 SIMPLE orders eq_ref PRIMARY,i_o_orderdate,i_o_custkey PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where @@ -964,4 +964,4 @@ test t1 a 1 1 0.0000 4.0000 60000.0000 0 NULL NULL SET use_stat_tables= @save_use_stat_tables; DROP TABLE t1; # end of 10.1 tests -SET SESSION STORAGE_ENGINE=DEFAULT; +SET SESSION DEFAULT_STORAGE_ENGINE=DEFAULT; diff --git a/mysql-test/main/stat_tables_innodb.test b/mysql-test/main/stat_tables_innodb.test index 301ee8692b9..f439ec52315 100644 --- a/mysql-test/main/stat_tables_innodb.test +++ b/mysql-test/main/stat_tables_innodb.test @@ -1,7 +1,7 @@ --source include/have_innodb.inc --source include/have_sequence.inc -SET SESSION STORAGE_ENGINE='InnoDB'; +SET SESSION DEFAULT_STORAGE_ENGINE='InnoDB'; set @save_optimizer_switch_for_stat_tables_test=@@optimizer_switch; set optimizer_switch='extended_keys=on'; @@ -38,4 +38,4 @@ DROP TABLE t1; --echo # end of 10.1 tests -SET SESSION STORAGE_ENGINE=DEFAULT; +SET SESSION DEFAULT_STORAGE_ENGINE=DEFAULT; diff --git a/mysql-test/main/stat_tables_par.inc b/mysql-test/main/stat_tables_par.inc new file mode 100644 index 00000000000..16f64cebfe7 --- /dev/null +++ b/mysql-test/main/stat_tables_par.inc @@ -0,0 +1,275 @@ +# Note that this test requires a fresh restart to not have problems with the +# old status values + +set @save_use_stat_tables=@@use_stat_tables; + +set use_stat_tables='preferably'; + +--disable_warnings +DROP DATABASE IF EXISTS dbt3_s001; +--enable_warnings + +CREATE DATABASE dbt3_s001; + +use dbt3_s001; + +set @save_optimizer_switch=@@optimizer_switch; +set optimizer_switch='extended_keys=off'; + +--disable_query_log +--disable_result_log +--disable_warnings +--source include/dbt3_s001.inc +truncate mysql.table_stats; +truncate mysql.column_stats; +truncate mysql.index_stats; +ANALYZE TABLE +customer, lineitem, nation, orders, part, partsupp, region, supplier; +--enable_warnings +--enable_result_log +--enable_query_log + +select * from mysql.table_stats; +select * from mysql.index_stats; + + +# +# Test for parallel memory allocation for statistical data +# +# assumes that start the code of memory allocation for stats data has this line: +# +# DEBUG_SYNC(thd, "statistics_mem_alloc_start1"); +# DEBUG_SYNC(thd, "statistics_mem_alloc_start2"); +# + +let $Q6= +select round(sum(l_extendedprice*l_discount),4) as revenue +from lineitem +where l_shipdate >= date '1994-01-01' + and l_shipdate < date '1994-01-01' + interval '1' year + and l_discount between 0.06 - 0.01 and 0.06 + 0.01 + and l_quantity < 24; + +flush table lineitem; +set use_stat_tables='never'; +eval $Q6; + +connect (con1, localhost, root,,); +connect (con2, localhost, root,,); + +connection con1; +set debug_sync='statistics_mem_alloc_start1 WAIT_FOR second_thread_started_too'; +set debug_sync='statistics_mem_alloc_start2 SIGNAL first_thread_working'; +use dbt3_s001; +set use_stat_tables='preferably'; +--send_eval $Q6 + +connection con2; +set debug_sync='statistics_mem_alloc_start1 SIGNAL second_thread_started_too'; +set debug_sync='statistics_mem_alloc_start2 WAIT_FOR first_thread_working'; +use dbt3_s001; +set use_stat_tables='preferably'; +--send_eval $Q6 + +connection con1; +--reap + +connection con2; +--reap + +connection default; +set use_stat_tables='preferably'; +disconnect con1; +disconnect con2; +set debug_sync='RESET'; + +# +# Test for parallel statistics collection +# +# assumes that start of stats collection code has this line: +# +# DEBUG_SYNC(thd, "statistics_collection_start1"); +# DEBUG_SYNC(thd, "statistics_collection_start2"); +# + +select * from mysql.index_stats where table_name='lineitem' order by index_name; +delete from mysql.index_stats + where table_name='lineitem' and + index_name in ('i_l_shipdate', 'i_l_receiptdate'); +select * from mysql.index_stats where table_name='lineitem' order by index_name; +--disable_result_log +--disable_warnings +analyze table lineitem persistent for columns() indexes (i_l_shipdate); +--enable_warnings +--enable_result_log +select * from mysql.index_stats where table_name='lineitem' order by index_name; +delete from mysql.index_stats + where table_name='lineitem' and index_name= 'i_l_shipdate'; +select * from mysql.index_stats where table_name='lineitem' order by index_name; + +connect (con1, localhost, root,,); +connect (con2, localhost, root,,); + +connection con1; +set debug_sync='statistics_collection_start1 WAIT_FOR second_thread_started_too'; +set debug_sync='statistics_collection_start2 SIGNAL first_thread_working'; +use dbt3_s001; +set use_stat_tables='preferably'; +--send analyze table lineitem persistent for columns() indexes (i_l_shipdate) + +connection con2; +set debug_sync='statistics_collection_start1 SIGNAL second_thread_started_too'; +set debug_sync='statistics_collection_start2 WAIT_FOR first_thread_working'; +use dbt3_s001; +set use_stat_tables='preferably'; +--send analyze table lineitem persistent for columns() indexes (i_l_receiptdate) + +connection con1; +--disable_result_log +--disable_warnings +--reap +--enable_warnings +--enable_result_log + +connection con2; +--disable_result_log +--disable_warnings +--reap +--enable_warnings +--enable_result_log + +connection default; +disconnect con1; +disconnect con2; +set debug_sync='RESET'; + +select * from mysql.index_stats where table_name='lineitem' order by index_name, prefix_arity; + +# +# Test for parallel statistics collection and update (innodb) +# + +select * from mysql.index_stats where table_name='lineitem' + order by index_name, prefix_arity; +set debug_sync='RESET'; + +let $innodb_storage_engine= 0; +if (`SELECT UPPER(@@default_storage_engine) = 'INNODB'`) +{ + let $innodb_storage_engine= 1; +} + +connect (con1, localhost, root,,); +connect (con2, localhost, root,,); + +connection con1; +set debug_sync='statistics_collection_start SIGNAL parked WAIT_FOR finish'; +use dbt3_s001; +set use_stat_tables='preferably'; +--send analyze table lineitem persistent for all + +connection con2; +set debug_sync='now WAIT_FOR parked'; +use dbt3_s001; +set use_stat_tables='never'; +if ($innodb_storage_engine) +{ + select * from lineitem where l_orderkey=1 and l_partkey=156; + delete from lineitem where l_orderkey=1 and l_partkey=156; + select * from lineitem where l_orderkey=1 and l_partkey=156; +} +set debug_sync='now SIGNAL finish'; + +connection con1; +--disable_result_log +--disable_warnings +--reap +--enable_warnings +--enable_result_log + +connection default; +disconnect con1; +disconnect con2; +set debug_sync='RESET'; + +select * from mysql.index_stats where table_name='lineitem' + order by index_name, prefix_arity; + +# +# Bug mdev-3891: deadlock for ANALYZE and SELECT over mysql.index_stats +# + +set @save_global_use_stat_tables=@@global.use_stat_tables; +set global use_stat_tables='preferably'; +set debug_sync='RESET'; + +connect (con1, localhost, root,,); +connect (con2, localhost, root,,); + +connection con1; +set debug_sync='statistics_update_start SIGNAL parker WAIT_FOR go1 EXECUTE 1'; +set debug_sync='thr_multi_lock_before_thr_lock SIGNAL go2 EXECUTE 3'; +use dbt3_s001; +--send analyze table lineitem persistent for all + +connection con2; +set debug_sync='open_and_process_table WAIT_FOR parker'; +set debug_sync='statistics_read_start SIGNAL go1 WAIT_FOR go2'; +use dbt3_s001; +--send select * from mysql.index_stats, lineitem where index_name= 'i_l_shipdate' and l_orderkey=1 and l_partkey=68 order by prefix_arity; + +connection con1; +--disable_result_log +--disable_warnings +--reap +--enable_warnings +--enable_result_log + +connection con2; +--disable_warnings +--reap +--enable_warnings + +connection default; +disconnect con1; +disconnect con2; +set debug_sync='RESET'; + +set global use_stat_tables=@save_global_use_stat_tables; + +DROP DATABASE dbt3_s001; + +use test; + +# +# Bug mdev-4019: crash when executing in parallel ANALYZE and +# SELECT * FROM information_schema.statistics +# + +set @save_global_use_stat_tables=@@global.use_stat_tables; +set global use_stat_tables='preferably'; +set debug_sync='RESET'; + +create table t1 (a int, b int, key(a)); +insert t1 values (1,1),(2,2); + +analyze table t1; + +SET debug_sync='after_open_table_ignore_flush WAIT_FOR go'; +send select * from information_schema.statistics where table_schema='test'; + +connect(con1, localhost, root); +connection con1; +select * from t1; +SET DEBUG_SYNC= "now SIGNAL go"; + +connection default; +reap; + +connection default; +disconnect con1; +set debug_sync='RESET'; + +drop table t1; +set global use_stat_tables=@save_global_use_stat_tables; +set use_stat_tables=@save_use_stat_tables; diff --git a/mysql-test/main/stat_tables_par.result b/mysql-test/main/stat_tables_par.result index 09ee2bbf16a..33fbe079c9e 100644 --- a/mysql-test/main/stat_tables_par.result +++ b/mysql-test/main/stat_tables_par.result @@ -1,3 +1,4 @@ +# restart set @save_use_stat_tables=@@use_stat_tables; set use_stat_tables='preferably'; DROP DATABASE IF EXISTS dbt3_s001; diff --git a/mysql-test/main/stat_tables_par.test b/mysql-test/main/stat_tables_par.test index 9d4038911ff..5bad16075d4 100644 --- a/mysql-test/main/stat_tables_par.test +++ b/mysql-test/main/stat_tables_par.test @@ -1,278 +1,9 @@ +# Note that this test requires a fresh restart to not have problems with the +# old status values + --source include/have_stat_tables.inc --source include/have_debug_sync.inc --source include/not_embedded.inc +--source include/restart_mysqld.inc -set @save_use_stat_tables=@@use_stat_tables; - -set use_stat_tables='preferably'; - ---disable_warnings -DROP DATABASE IF EXISTS dbt3_s001; ---enable_warnings - -CREATE DATABASE dbt3_s001; - -use dbt3_s001; - -set @save_optimizer_switch=@@optimizer_switch; -set optimizer_switch='extended_keys=off'; - ---disable_query_log ---disable_result_log ---disable_warnings ---source include/dbt3_s001.inc -delete from mysql.table_stats; -delete from mysql.column_stats; -delete from mysql.index_stats; -ANALYZE TABLE -customer, lineitem, nation, orders, part, partsupp, region, supplier; ---enable_warnings ---enable_result_log ---enable_query_log - -select * from mysql.table_stats; -select * from mysql.index_stats; - - -# -# Test for parallel memory allocation for statistical data -# -# assumes that start the code of memory allocation for stats data has this line: -# -# DEBUG_SYNC(thd, "statistics_mem_alloc_start1"); -# DEBUG_SYNC(thd, "statistics_mem_alloc_start2"); -# - -let $Q6= -select round(sum(l_extendedprice*l_discount),4) as revenue -from lineitem -where l_shipdate >= date '1994-01-01' - and l_shipdate < date '1994-01-01' + interval '1' year - and l_discount between 0.06 - 0.01 and 0.06 + 0.01 - and l_quantity < 24; - -flush table lineitem; -set use_stat_tables='never'; -eval $Q6; - -connect (con1, localhost, root,,); -connect (con2, localhost, root,,); - -connection con1; -set debug_sync='statistics_mem_alloc_start1 WAIT_FOR second_thread_started_too'; -set debug_sync='statistics_mem_alloc_start2 SIGNAL first_thread_working'; -use dbt3_s001; -set use_stat_tables='preferably'; ---send_eval $Q6 - -connection con2; -set debug_sync='statistics_mem_alloc_start1 SIGNAL second_thread_started_too'; -set debug_sync='statistics_mem_alloc_start2 WAIT_FOR first_thread_working'; -use dbt3_s001; -set use_stat_tables='preferably'; ---send_eval $Q6 - -connection con1; ---reap - -connection con2; ---reap - -connection default; -set use_stat_tables='preferably'; -disconnect con1; -disconnect con2; -set debug_sync='RESET'; - -# -# Test for parallel statistics collection -# -# assumes that start of stats collection code has this line: -# -# DEBUG_SYNC(thd, "statistics_collection_start1"); -# DEBUG_SYNC(thd, "statistics_collection_start2"); -# - -select * from mysql.index_stats where table_name='lineitem' order by index_name; -delete from mysql.index_stats - where table_name='lineitem' and - index_name in ('i_l_shipdate', 'i_l_receiptdate'); -select * from mysql.index_stats where table_name='lineitem' order by index_name; ---disable_result_log ---disable_warnings -analyze table lineitem persistent for columns() indexes (i_l_shipdate); ---enable_warnings ---enable_result_log -select * from mysql.index_stats where table_name='lineitem' order by index_name; -delete from mysql.index_stats - where table_name='lineitem' and index_name= 'i_l_shipdate'; -select * from mysql.index_stats where table_name='lineitem' order by index_name; - -connect (con1, localhost, root,,); -connect (con2, localhost, root,,); - -connection con1; -set debug_sync='statistics_collection_start1 WAIT_FOR second_thread_started_too'; -set debug_sync='statistics_collection_start2 SIGNAL first_thread_working'; -use dbt3_s001; -set use_stat_tables='preferably'; ---send analyze table lineitem persistent for columns() indexes (i_l_shipdate) - -connection con2; -set debug_sync='statistics_collection_start1 SIGNAL second_thread_started_too'; -set debug_sync='statistics_collection_start2 WAIT_FOR first_thread_working'; -use dbt3_s001; -set use_stat_tables='preferably'; ---send analyze table lineitem persistent for columns() indexes (i_l_receiptdate) - -connection con1; ---disable_result_log ---disable_warnings ---reap ---enable_warnings ---enable_result_log - -connection con2; ---disable_result_log ---disable_warnings ---reap ---enable_warnings ---enable_result_log - -connection default; -disconnect con1; -disconnect con2; -set debug_sync='RESET'; - -select * from mysql.index_stats where table_name='lineitem' order by index_name, prefix_arity; - -# -# Test for parallel statistics collection and update (innodb) -# - -select * from mysql.index_stats where table_name='lineitem' - order by index_name, prefix_arity; -set debug_sync='RESET'; - -let $innodb_storage_engine= 0; -if (`SELECT UPPER(@@storage_engine) = 'INNODB'`) -{ - let $innodb_storage_engine= 1; -} - -connect (con1, localhost, root,,); -connect (con2, localhost, root,,); - -connection con1; -set debug_sync='statistics_collection_start SIGNAL parked WAIT_FOR finish'; -use dbt3_s001; -set use_stat_tables='preferably'; ---send analyze table lineitem persistent for all - -connection con2; -set debug_sync='now WAIT_FOR parked'; -use dbt3_s001; -set use_stat_tables='never'; -if ($innodb_storage_engine) -{ - select * from lineitem where l_orderkey=1 and l_partkey=156; - delete from lineitem where l_orderkey=1 and l_partkey=156; - select * from lineitem where l_orderkey=1 and l_partkey=156; -} -set debug_sync='now SIGNAL finish'; - -connection con1; ---disable_result_log ---disable_warnings ---reap ---enable_warnings ---enable_result_log - -connection default; -disconnect con1; -disconnect con2; -set debug_sync='RESET'; - -select * from mysql.index_stats where table_name='lineitem' - order by index_name, prefix_arity; - -# -# Bug mdev-3891: deadlock for ANALYZE and SELECT over mysql.index_stats -# - -set @save_global_use_stat_tables=@@global.use_stat_tables; -set global use_stat_tables='preferably'; -set debug_sync='RESET'; - -connect (con1, localhost, root,,); -connect (con2, localhost, root,,); - -connection con1; -set debug_sync='statistics_update_start SIGNAL parker WAIT_FOR go1 EXECUTE 1'; -set debug_sync='thr_multi_lock_before_thr_lock SIGNAL go2 EXECUTE 3'; -use dbt3_s001; ---send analyze table lineitem persistent for all - -connection con2; -set debug_sync='open_and_process_table WAIT_FOR parker'; -set debug_sync='statistics_read_start SIGNAL go1 WAIT_FOR go2'; -use dbt3_s001; ---send select * from mysql.index_stats, lineitem where index_name= 'i_l_shipdate' and l_orderkey=1 and l_partkey=68 order by prefix_arity; - -connection con1; ---disable_result_log ---disable_warnings ---reap ---enable_warnings ---enable_result_log - -connection con2; ---disable_warnings ---reap ---enable_warnings - -connection default; -disconnect con1; -disconnect con2; -set debug_sync='RESET'; - -set global use_stat_tables=@save_global_use_stat_tables; - -DROP DATABASE dbt3_s001; - -use test; - -# -# Bug mdev-4019: crash when executing in parallel ANALYZE and -# SELECT * FROM information_schema.statistics -# - -set @save_global_use_stat_tables=@@global.use_stat_tables; -set global use_stat_tables='preferably'; -set debug_sync='RESET'; - -create table t1 (a int, b int, key(a)); -insert t1 values (1,1),(2,2); - -analyze table t1; - -SET debug_sync='after_open_table_ignore_flush WAIT_FOR go'; -send select * from information_schema.statistics where table_schema='test'; - -connect(con1, localhost, root); -connection con1; -select * from t1; -SET DEBUG_SYNC= "now SIGNAL go"; - -connection default; -reap; - -connection default; -disconnect con1; -set debug_sync='RESET'; - -drop table t1; -set global use_stat_tables=@save_global_use_stat_tables; - - -set use_stat_tables=@save_use_stat_tables; +--source stat_tables_par.inc diff --git a/mysql-test/main/stat_tables_par_innodb.result b/mysql-test/main/stat_tables_par_innodb.result index 54579aff990..c33785a9436 100644 --- a/mysql-test/main/stat_tables_par_innodb.result +++ b/mysql-test/main/stat_tables_par_innodb.result @@ -1,4 +1,5 @@ -SET SESSION STORAGE_ENGINE='InnoDB'; +# restart +SET SESSION DEFAULT_STORAGE_ENGINE='InnoDB'; set @save_optimizer_switch_for_stat_tables_test=@@optimizer_switch; set optimizer_switch='extended_keys=on'; set @save_use_stat_tables=@@use_stat_tables; @@ -315,4 +316,4 @@ drop table t1; set global use_stat_tables=@save_global_use_stat_tables; set use_stat_tables=@save_use_stat_tables; set optimizer_switch=@save_optimizer_switch_for_stat_tables_test; -SET SESSION STORAGE_ENGINE=DEFAULT; +SET SESSION DEFAULT_STORAGE_ENGINE=DEFAULT; diff --git a/mysql-test/main/stat_tables_par_innodb.test b/mysql-test/main/stat_tables_par_innodb.test index fd5833e4aaf..79ab23dcc3f 100644 --- a/mysql-test/main/stat_tables_par_innodb.test +++ b/mysql-test/main/stat_tables_par_innodb.test @@ -1,12 +1,19 @@ +# Note that this test requires a fresh restart to not have problems with the +# old status values + +--source include/have_stat_tables.inc +--source include/have_debug_sync.inc +--source include/not_embedded.inc --source include/have_innodb.inc +--source include/restart_mysqld.inc -SET SESSION STORAGE_ENGINE='InnoDB'; +SET SESSION DEFAULT_STORAGE_ENGINE='InnoDB'; set @save_optimizer_switch_for_stat_tables_test=@@optimizer_switch; set optimizer_switch='extended_keys=on'; ---source stat_tables_par.test +--source stat_tables_par.inc set optimizer_switch=@save_optimizer_switch_for_stat_tables_test; -SET SESSION STORAGE_ENGINE=DEFAULT; +SET SESSION DEFAULT_STORAGE_ENGINE=DEFAULT; diff --git a/mysql-test/main/status_bug17954.test b/mysql-test/main/status_bug17954.test index 36430cceeff..75c9ab27dfd 100644 --- a/mysql-test/main/status_bug17954.test +++ b/mysql-test/main/status_bug17954.test @@ -4,9 +4,6 @@ # embedded server causes different stat -- source include/not_embedded.inc -# thread pool causes different results --- source include/not_threadpool.inc - # Save the initial number of concurrent sessions --source include/count_sessions.inc diff --git a/mysql-test/main/subselect.result b/mysql-test/main/subselect.result index 15ebaa33474..167382fc328 100644 --- a/mysql-test/main/subselect.result +++ b/mysql-test/main/subselect.result @@ -682,8 +682,6 @@ x 3 11 11 -INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(x) FROM t2)); -ERROR 42S22: Unknown column 'x' in 'field list' INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); select * from t1; x @@ -1505,7 +1503,7 @@ a explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index -1 PRIMARY t3 index a a 5 NULL 3 100.00 Using where; Using index +1 PRIMARY t3 range a a 5 NULL 3 100.00 Using where; Using index 1 PRIMARY t1 ref a a 10 test.t2.a,test.t3.a 116 100.00 Using index; FirstMatch(t2) Warnings: Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where `test`.`t1`.`b` = `test`.`t3`.`a` and `test`.`t1`.`a` = `test`.`t2`.`a` @@ -3178,7 +3176,7 @@ INSERT INTO t2 VALUES (1),(2),(3); EXPLAIN SELECT a, a IN (SELECT a FROM t1) FROM t2; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 3 -2 SUBQUERY t1 index_subquery a a 5 func 2 Using index; Full scan on NULL key +2 SUBQUERY t1 index_subquery a a 5 func 3 Using index; Full scan on NULL key SELECT a, a IN (SELECT a FROM t1) FROM t2; a a IN (SELECT a FROM t1) 1 1 @@ -7042,8 +7040,8 @@ SELECT * FROM t1 WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index a a 5 NULL 2 Using where; Using index -2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where -2 SUBQUERY <subquery3> eq_ref distinct_key distinct_key 4 test.t2.c 1 +2 SUBQUERY <subquery3> ALL distinct_key NULL NULL NULL 1 +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) 3 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 SELECT * FROM t1 WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10; @@ -7134,7 +7132,7 @@ drop table t1,t2,t3,t4; # MDEV-7122 # Assertion `0' failed in subselect_hash_sj_engine::init # -SET SESSION big_tables=1; +set tmp_memory_table_size=0; CREATE TABLE t1(a char(255) DEFAULT '', KEY(a(10))) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; INSERT INTO t1 VALUES(0),(0),(0); SELECT * FROM t1 WHERE a IN(SELECT MIN(a) FROM t1); @@ -7143,7 +7141,7 @@ a 0 0 DROP TABLE t1; -SET SESSION big_tables=0; +set tmp_memory_table_size=default; # # MDEV-10776: Server crash on query # diff --git a/mysql-test/main/subselect.test b/mysql-test/main/subselect.test index d87aba57567..a58a08e1a58 100644 --- a/mysql-test/main/subselect.test +++ b/mysql-test/main/subselect.test @@ -394,8 +394,6 @@ select * from t1; # After this, only data based on old t1 records should have been added. INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2; select * from t1; --- error ER_BAD_FIELD_ERROR -INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(x) FROM t2)); let $row_count_before= `SELECT COUNT(*) FROM t1`; INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); let $wait_condition= SELECT COUNT(*) <> $row_count_before FROM t1; @@ -5959,12 +5957,12 @@ drop table t1,t2,t3,t4; --echo # MDEV-7122 --echo # Assertion `0' failed in subselect_hash_sj_engine::init --echo # -SET SESSION big_tables=1; +set tmp_memory_table_size=0; # force on-disk tmp table CREATE TABLE t1(a char(255) DEFAULT '', KEY(a(10))) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; INSERT INTO t1 VALUES(0),(0),(0); SELECT * FROM t1 WHERE a IN(SELECT MIN(a) FROM t1); DROP TABLE t1; -SET SESSION big_tables=0; +set tmp_memory_table_size=default; --echo # --echo # MDEV-10776: Server crash on query diff --git a/mysql-test/main/subselect2.result b/mysql-test/main/subselect2.result index a3d7fda7abc..34e6e857d14 100644 --- a/mysql-test/main/subselect2.result +++ b/mysql-test/main/subselect2.result @@ -287,7 +287,7 @@ ORDER BY mirror_date ASC ) AS calculated_result; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 -2 DERIVED t1 ALL date NULL NULL NULL 3 Using where; Using filesort +2 DERIVED t1 range date date 6 NULL 3 Using index condition; Using where; Rowid-ordered scan; Using filesort SELECT * FROM ( SELECT node_uid, date, mirror_date, @result := 0 AS result FROM t1 @@ -310,7 +310,7 @@ ORDER BY mirror_date ASC ) AS calculated_result; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 -2 DERIVED t1 ALL date NULL NULL NULL 3 Using where; Using filesort +2 DERIVED t1 range date date 6 NULL 3 Using index condition; Using where; Using filesort SELECT * FROM ( SELECT node_uid, date, mirror_date, @result := 0 AS result FROM t1 diff --git a/mysql-test/main/subselect3.result b/mysql-test/main/subselect3.result index 5c4544a1b05..299faadeff7 100644 --- a/mysql-test/main/subselect3.result +++ b/mysql-test/main/subselect3.result @@ -96,10 +96,10 @@ explain extended select oref, a, a in (select a from t1 where oref=t2.oref) Z from t2; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 4 100.00 -2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 2 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY t1 ALL a NULL NULL NULL 8 100.00 Using where Warnings: Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1 -Note 1003 /* select#1 */ select `test`.`t2`.`oref` AS `oref`,`test`.`t2`.`a` AS `a`,<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`oref`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a checking NULL where `test`.`t1`.`oref` = `test`.`t2`.`oref` having trigcond(`test`.`t1`.`a` is null))))) AS `Z` from `test`.`t2` +Note 1003 /* select#1 */ select `test`.`t2`.`oref` AS `oref`,`test`.`t2`.`a` AS `a`,<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`oref`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`oref` = `test`.`t2`.`oref` and trigcond(<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a` or `test`.`t1`.`a` is null) having trigcond(`test`.`t1`.`a` is null)))) AS `Z` from `test`.`t2` flush status; select oref, a from t2 where a in (select a from t1 where oref=t2.oref); oref a diff --git a/mysql-test/main/subselect3_jcl6.result b/mysql-test/main/subselect3_jcl6.result index 4260676cc37..aebeb4e0cc1 100644 --- a/mysql-test/main/subselect3_jcl6.result +++ b/mysql-test/main/subselect3_jcl6.result @@ -99,10 +99,10 @@ explain extended select oref, a, a in (select a from t1 where oref=t2.oref) Z from t2; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 4 100.00 -2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 2 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY t1 ALL a NULL NULL NULL 8 100.00 Using where Warnings: Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1 -Note 1003 /* select#1 */ select `test`.`t2`.`oref` AS `oref`,`test`.`t2`.`a` AS `a`,<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`oref`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a checking NULL where `test`.`t1`.`oref` = `test`.`t2`.`oref` having trigcond(`test`.`t1`.`a` is null))))) AS `Z` from `test`.`t2` +Note 1003 /* select#1 */ select `test`.`t2`.`oref` AS `oref`,`test`.`t2`.`a` AS `a`,<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`oref`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`oref` = `test`.`t2`.`oref` and trigcond(<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a` or `test`.`t1`.`a` is null) having trigcond(`test`.`t1`.`a` is null)))) AS `Z` from `test`.`t2` flush status; select oref, a from t2 where a in (select a from t1 where oref=t2.oref); oref a diff --git a/mysql-test/main/subselect4.result b/mysql-test/main/subselect4.result index e4e9a5c8917..7b97f499768 100644 --- a/mysql-test/main/subselect4.result +++ b/mysql-test/main/subselect4.result @@ -1368,8 +1368,8 @@ GROUP BY SQ1_t1.f4)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system NULL NULL NULL NULL 1 2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where -3 SUBQUERY SQ1_t1 index NULL f4 5 NULL 2 Using index; Using temporary -3 SUBQUERY SQ1_t3 index f4 f4 5 NULL 2 Using where; Using index; Using join buffer (flat, BNL join) +3 SUBQUERY SQ1_t3 range f4 f4 5 NULL 2 Using where; Using index; Using temporary +3 SUBQUERY SQ1_t1 index NULL f4 5 NULL 2 Using index; Using join buffer (flat, BNL join) SELECT * FROM t1 WHERE (SELECT f2 FROM t2 WHERE f4 <= ALL @@ -2784,12 +2784,13 @@ set names 'utf8'; # IN predicate to IN subquery is performed as materialization is llowed # The character set on the inner side is a proper subset of the outer side # +# this test in 10.5 has only 2 rows in the IN predicate EXPLAIN -SELECT * FROM t2 WHERE (t2.a,t2.b) IN (('abx',1),('def',2), ('abc', 3)); +SELECT * FROM t2 WHERE (t2.a,t2.b) IN (('abc',1), ('def', 2)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 16 func,func 1 Using where -2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 3 +2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 2 3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used set names default; set @@in_predicate_conversion_threshold= @save_in_predicate_conversion_threshold; diff --git a/mysql-test/main/subselect4.test b/mysql-test/main/subselect4.test index 329a6726a6b..2f65db875f8 100644 --- a/mysql-test/main/subselect4.test +++ b/mysql-test/main/subselect4.test @@ -2311,8 +2311,10 @@ set names 'utf8'; --echo # The character set on the inner side is a proper subset of the outer side --echo # +--echo # this test in 10.5 has only 2 rows in the IN predicate + EXPLAIN -SELECT * FROM t2 WHERE (t2.a,t2.b) IN (('abx',1),('def',2), ('abc', 3)); +SELECT * FROM t2 WHERE (t2.a,t2.b) IN (('abc',1), ('def', 2)); set names default; set @@in_predicate_conversion_threshold= @save_in_predicate_conversion_threshold; diff --git a/mysql-test/main/subselect_cache.result b/mysql-test/main/subselect_cache.result index abd978de9a5..e12facf8b8c 100644 --- a/mysql-test/main/subselect_cache.result +++ b/mysql-test/main/subselect_cache.result @@ -54,7 +54,8 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 }, @@ -73,7 +74,8 @@ ANALYZE "r_loops": 4, "rows": 4, "r_rows": 4, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 18.75, "attached_condition": "t1.b = t2.c" @@ -98,7 +100,8 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 }, @@ -125,7 +128,8 @@ ANALYZE "r_loops": 4, "rows": 4, "r_rows": 4, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 18.75, "attached_condition": "t1.b = t2.c" @@ -160,7 +164,8 @@ ANALYZE "r_loops": 4, "rows": 4, "r_rows": 4, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 18.75, "attached_condition": "t1.b = t2.c" @@ -1860,8 +1865,8 @@ Variable_name Value Subquery_cache_hit 0 Subquery_cache_miss 4 drop table t1; -#test of sql_big_tables switch and outer table reference in subquery with grouping -set big_tables=1; +#test of big_tables switch and outer table reference in subquery with grouping +set tmp_memory_table_size=0; CREATE TABLE t1 (a INT PRIMARY KEY, b INT); INSERT INTO t1 VALUES (1,1),(2,1),(3,2),(4,2),(5,3),(6,3); SELECT (SELECT t1_outer.a FROM t1 AS t1_inner GROUP BY b LIMIT 1) FROM t1 AS t1_outer; @@ -1873,7 +1878,7 @@ SELECT (SELECT t1_outer.a FROM t1 AS t1_inner GROUP BY b LIMIT 1) FROM t1 AS t1_ 5 6 drop table t1; -set big_tables=0; +set tmp_memory_table_size=default; #test of function reference to outer query set local group_concat_max_len=400; create table t2 (a int, b int); diff --git a/mysql-test/main/subselect_cache.test b/mysql-test/main/subselect_cache.test index 55da0000f13..8fcecf1281b 100644 --- a/mysql-test/main/subselect_cache.test +++ b/mysql-test/main/subselect_cache.test @@ -428,13 +428,13 @@ select a, a in (select a from t1 where -1 < benchmark(a,100)) from t1 as ext; show status like "subquery_cache%"; drop table t1; ---echo #test of sql_big_tables switch and outer table reference in subquery with grouping -set big_tables=1; +--echo #test of big_tables switch and outer table reference in subquery with grouping +set tmp_memory_table_size=0; # force on-disk tmp table CREATE TABLE t1 (a INT PRIMARY KEY, b INT); INSERT INTO t1 VALUES (1,1),(2,1),(3,2),(4,2),(5,3),(6,3); SELECT (SELECT t1_outer.a FROM t1 AS t1_inner GROUP BY b LIMIT 1) FROM t1 AS t1_outer; drop table t1; -set big_tables=0; +set tmp_memory_table_size=default; --echo #test of function reference to outer query set local group_concat_max_len=400; diff --git a/mysql-test/main/subselect_innodb.result b/mysql-test/main/subselect_innodb.result index f1e07ce09fe..73ca2640491 100644 --- a/mysql-test/main/subselect_innodb.result +++ b/mysql-test/main/subselect_innodb.result @@ -435,8 +435,7 @@ drop table t1; # drop table if exists `t1`,`t2`; Warnings: -Note 1051 Unknown table 'test.t1' -Note 1051 Unknown table 'test.t2' +Note 1051 Unknown table 'test.t1,test.t2' create table `t1`(`a` char(1) character set utf8)engine=innodb; create table `t2`(`b` char(1) character set utf8)engine=memory; select distinct (select 1 from `t2` where `a`) `d2` from `t1`; diff --git a/mysql-test/main/subselect_mat.result b/mysql-test/main/subselect_mat.result index 34b58daa50e..5f38d2a5d35 100644 --- a/mysql-test/main/subselect_mat.result +++ b/mysql-test/main/subselect_mat.result @@ -105,7 +105,7 @@ explain extended select * from t1i where a1 in (select b1 from t2i where b1 > '0'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1i index NULL _it1_idx # NULL 3 100.00 Using where; -2 MATERIALIZED t2i index it2i1,it2i3 it2i1 # NULL 5 100.00 Using where; +2 MATERIALIZED t2i range it2i1,it2i3 it2i1 # NULL 5 100.00 Using where; Warnings: Note 1003 /* select#1 */ select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <expr_cache><`test`.`t1i`.`a1`>(<in_optimizer>(`test`.`t1i`.`a1`,`test`.`t1i`.`a1` in ( <materialize> (/* select#2 */ select `test`.`t2i`.`b1` from `test`.`t2i` where `test`.`t2i`.`b1` > '0' ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where `test`.`t1i`.`a1` = `<subquery2>`.`b1`)))) select * from t1i where a1 in (select b1 from t2i where b1 > '0'); @@ -127,7 +127,7 @@ explain extended select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1i index NULL _it1_idx # NULL 3 100.00 Using where; -2 MATERIALIZED t2i index it2i1,it2i3 it2i3 # NULL 5 100.00 Using where; +2 MATERIALIZED t2i range it2i1,it2i3 it2i3 # NULL 5 100.00 Using where; Warnings: Note 1003 /* select#1 */ select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <expr_cache><`test`.`t1i`.`a1`,`test`.`t1i`.`a2`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (/* select#2 */ select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where `test`.`t2i`.`b1` > '0' ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where `test`.`t1i`.`a1` = `<subquery2>`.`b1` and `test`.`t1i`.`a2` = `<subquery2>`.`b2`)))) select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0'); @@ -340,7 +340,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1i index NULL # # # 3 100.00 # 3 MATERIALIZED t3i index NULL # # # 4 100.00 # 4 MATERIALIZED t2i index it2i2 # # # 5 100.00 # -2 MATERIALIZED t2i index it2i1,it2i3 # # # 5 100.00 # +2 MATERIALIZED t2i range it2i1,it2i3 # # # 5 100.00 # Warnings: Note 1003 /* select#1 */ select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <expr_cache><`test`.`t1i`.`a1`,`test`.`t1i`.`a2`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (/* select#2 */ select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where `test`.`t2i`.`b1` > '0' ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where `test`.`t1i`.`a1` = `<subquery2>`.`b1` and `test`.`t1i`.`a2` = `<subquery2>`.`b2`)))) and <expr_cache><`test`.`t1i`.`a1`,`test`.`t1i`.`a2`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (/* select#3 */ select `test`.`t3i`.`c1`,`test`.`t3i`.`c2` from `test`.`t3i` where <expr_cache><`test`.`t3i`.`c1`,`test`.`t3i`.`c2`>(<in_optimizer>((`test`.`t3i`.`c1`,`test`.`t3i`.`c2`),(`test`.`t3i`.`c1`,`test`.`t3i`.`c2`) in ( <materialize> (/* select#4 */ select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where `test`.`t2i`.`b2` > '0' ), <primary_index_lookup>(`test`.`t3i`.`c1` in <temporary table> on distinct_key where `test`.`t3i`.`c1` = `<subquery4>`.`b1` and `test`.`t3i`.`c2` = `<subquery4>`.`b2`)))) ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where `test`.`t1i`.`a1` = `<subquery3>`.`c1` and `test`.`t1i`.`a2` = `<subquery3>`.`c2`)))) select * from t1i @@ -423,7 +423,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 7 UNION t1i index NULL # # # 3 100.00 # 9 MATERIALIZED t3i index NULL # # # 4 100.00 # 10 MATERIALIZED t2i index it2i2 # # # 5 100.00 # -8 MATERIALIZED t2i index it2i1,it2i3 # # # 5 100.00 # +8 MATERIALIZED t2i range it2i1,it2i3 # # # 5 100.00 # NULL UNION RESULT <union1,7> ALL NULL # # # NULL NULL # Warnings: Note 1003 (/* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (/* select#2 */ select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (/* select#3 */ select `test`.`t3`.`c2` from `test`.`t3` where `test`.`t3`.`c2` like '%02' ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where `test`.`t2`.`b2` = `<subquery3>`.`c2`)))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (/* select#4 */ select `test`.`t3`.`c2` from `test`.`t3` where `test`.`t3`.`c2` like '%03' ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where `test`.`t2`.`b2` = `<subquery4>`.`c2`)))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where `test`.`t1`.`a1` = `<subquery2>`.`b1` and `test`.`t1`.`a2` = `<subquery2>`.`b2`)))) and <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (/* select#5 */ select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c1`,`test`.`t3`.`c2`>(<in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (/* select#6 */ select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where `test`.`t2i`.`b2` > '0' ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where `test`.`t3`.`c1` = `<subquery6>`.`b1` and `test`.`t3`.`c2` = `<subquery6>`.`b2`)))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where `test`.`t1`.`a1` = `<subquery5>`.`c1` and `test`.`t1`.`a2` = `<subquery5>`.`c2`))))) union (/* select#7 */ select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <expr_cache><`test`.`t1i`.`a1`,`test`.`t1i`.`a2`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (/* select#8 */ select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where `test`.`t2i`.`b1` > '0' ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where `test`.`t1i`.`a1` = `<subquery8>`.`b1` and `test`.`t1i`.`a2` = `<subquery8>`.`b2`)))) and <expr_cache><`test`.`t1i`.`a1`,`test`.`t1i`.`a2`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (/* select#9 */ select `test`.`t3i`.`c1`,`test`.`t3i`.`c2` from `test`.`t3i` where <expr_cache><`test`.`t3i`.`c1`,`test`.`t3i`.`c2`>(<in_optimizer>((`test`.`t3i`.`c1`,`test`.`t3i`.`c2`),(`test`.`t3i`.`c1`,`test`.`t3i`.`c2`) in ( <materialize> (/* select#10 */ select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where `test`.`t2i`.`b2` > '0' ), <primary_index_lookup>(`test`.`t3i`.`c1` in <temporary table> on distinct_key where `test`.`t3i`.`c1` = `<subquery10>`.`b1` and `test`.`t3i`.`c2` = `<subquery10>`.`b2`)))) ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where `test`.`t1i`.`a1` = `<subquery9>`.`c1` and `test`.`t1i`.`a2` = `<subquery9>`.`c2`))))) @@ -1142,7 +1142,7 @@ a explain extended select a from t1 group by a having a in (select c from t2 where d >= 20); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 index NULL it1a 4 NULL 7 100.00 Using index +1 PRIMARY t1 range NULL it1a 4 NULL 8 100.00 Using index for group-by 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 7 100.00 Using where Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (/* select#2 */ select `test`.`t2`.`c` from `test`.`t2` where `test`.`t2`.`d` >= 20 ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where `test`.`t1`.`a` = `<subquery2>`.`c`)))) @@ -1154,7 +1154,7 @@ create index iab on t1(a, b); explain extended select a from t1 group by a having a in (select c from t2 where d >= 20); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 index NULL it1a 4 NULL 7 100.00 Using index +1 PRIMARY t1 range NULL it1a 4 NULL 8 100.00 Using index for group-by 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 7 100.00 Using where Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (/* select#2 */ select `test`.`t2`.`c` from `test`.`t2` where `test`.`t2`.`d` >= 20 ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where `test`.`t1`.`a` = `<subquery2>`.`c`)))) @@ -1166,7 +1166,7 @@ explain extended select a from t1 group by a having a in (select c from t2 where d >= some(select e from t3 where max(b)=e)); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 index NULL iab 8 NULL 7 100.00 Using index +1 PRIMARY t1 range NULL iab 4 NULL 8 100.00 Using index for group-by 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00 Using where 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: @@ -1889,8 +1889,8 @@ WHERE alias4.c = alias3.b ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables -3 MATERIALIZED alias3 ALL NULL NULL NULL NULL 2 -3 MATERIALIZED alias4 index c c 11 NULL 2 Using where; Using index; Using join buffer (flat, BNL join) +3 MATERIALIZED alias3 ALL NULL NULL NULL NULL 2 Using where +3 MATERIALIZED alias4 ref c c 11 test.alias3.b 2 Using where; Using index DROP TABLE t1,t2; # # BUG#928048: Query containing IN subquery with OR in the where clause returns a wrong result @@ -2118,8 +2118,7 @@ DROP VIEW v2; # # MDEV-5811: Server crashes in best_access_path with materialization+semijoin and big_tables=ON # -SET @tmp_mdev5811= @@big_tables; -SET big_tables = ON; +set tmp_memory_table_size=0; CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (1),(2); CREATE TABLE t2 (b INT); @@ -2128,7 +2127,7 @@ SELECT * FROM t1 AS t1_1, t1 AS t1_2 WHERE ( t1_1.a, t1_2.a ) IN ( SELECT MAX(b), MIN(b) FROM t2 ); a a DROP TABLE t1,t2; -SET big_tables=@tmp_mdev5811; +set tmp_memory_table_size=default; # End of 5.3 tests # # MDEV-5056: Wrong result (extra rows) with materialization+semijoin, IN subqueries @@ -2277,7 +2276,7 @@ WHERE i3 = i2 AND f1 IN ( SELECT f3 FROM t3 ) ); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where 2 DEPENDENT SUBQUERY <subquery3> eq_ref distinct_key distinct_key 4 func 1 100.00 -2 DEPENDENT SUBQUERY t2 index i2 i2 5 NULL 3 100.00 Using where; Using index; Using join buffer (flat, BNL join) +2 DEPENDENT SUBQUERY t2 range i2 i2 5 NULL 3 100.00 Using where; Using index; Using join buffer (flat, BNL join) 2 DEPENDENT SUBQUERY t3 ref i3 i3 5 test.t2.i2 2 100.00 Using index 3 MATERIALIZED t3 ALL NULL NULL NULL NULL 8 100.00 Warnings: diff --git a/mysql-test/main/subselect_mat_cost.result b/mysql-test/main/subselect_mat_cost.result index 083917cef7e..66d48b549c4 100644 --- a/mysql-test/main/subselect_mat_cost.result +++ b/mysql-test/main/subselect_mat_cost.result @@ -289,7 +289,7 @@ AND Code = Country; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY CountryLanguage range PRIMARY,Language Language 30 NULL 44 Using index condition; Rowid-ordered scan 1 PRIMARY Country eq_ref PRIMARY PRIMARY 3 world.CountryLanguage.Country 1 Using where -3 MATERIALIZED CountryLanguage ref PRIMARY,Language Language 30 const 48 Using index condition +3 DEPENDENT SUBQUERY CountryLanguage unique_subquery PRIMARY,Language PRIMARY 33 func,const 1 Using index; Using where set statement optimizer_switch='rowid_filter=off' for SELECT Country.Name FROM Country, CountryLanguage diff --git a/mysql-test/main/subselect_mat_cost_bugs.result b/mysql-test/main/subselect_mat_cost_bugs.result index ecceac27b2d..6a218ed5e04 100644 --- a/mysql-test/main/subselect_mat_cost_bugs.result +++ b/mysql-test/main/subselect_mat_cost_bugs.result @@ -196,8 +196,8 @@ ORDER BY field1 ; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 Using where; Using filesort 1 PRIMARY alias1 eq_ref PRIMARY PRIMARY 4 alias2.f3 1 Using index -3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 -3 DEPENDENT SUBQUERY t1 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index; Using join buffer (flat, BNL join) +3 DEPENDENT SUBQUERY t1 range PRIMARY PRIMARY 4 NULL 2 Using where; Using index +3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join) 2 DERIVED t2 ALL NULL NULL NULL NULL 2 SELECT alias2.f2 AS field1 FROM t1 AS alias1 JOIN ( SELECT * FROM t2 ) AS alias2 ON alias2.f3 = alias1.f1 @@ -316,7 +316,7 @@ explain select c1 from t1 where c1 in (select kp1 from t2 where kp2 = 10 and c2 = 4) or c1 > 7; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where -2 DEPENDENT SUBQUERY t2 index_subquery key1,key2,key3 key1 10 func,const 1 Using where +2 DEPENDENT SUBQUERY t2 ref key1,key2,key3 key3 5 const 1 Using where select c1 from t1 where c1 in (select kp1 from t2 where kp2 = 10 and c2 = 4) or c1 > 7; c1 set @@optimizer_switch='default'; diff --git a/mysql-test/main/subselect_no_exists_to_in.result b/mysql-test/main/subselect_no_exists_to_in.result index b1432cf0979..70add4d1740 100644 --- a/mysql-test/main/subselect_no_exists_to_in.result +++ b/mysql-test/main/subselect_no_exists_to_in.result @@ -686,8 +686,6 @@ x 3 11 11 -INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(x) FROM t2)); -ERROR 42S22: Unknown column 'x' in 'field list' INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); select * from t1; x @@ -1509,7 +1507,7 @@ a explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index -1 PRIMARY t3 index a a 5 NULL 3 100.00 Using where; Using index +1 PRIMARY t3 range a a 5 NULL 3 100.00 Using where; Using index 1 PRIMARY t1 ref a a 10 test.t2.a,test.t3.a 116 100.00 Using index; FirstMatch(t2) Warnings: Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where `test`.`t1`.`b` = `test`.`t3`.`a` and `test`.`t1`.`a` = `test`.`t2`.`a` @@ -3181,7 +3179,7 @@ INSERT INTO t2 VALUES (1),(2),(3); EXPLAIN SELECT a, a IN (SELECT a FROM t1) FROM t2; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 3 -2 SUBQUERY t1 index_subquery a a 5 func 2 Using index; Full scan on NULL key +2 SUBQUERY t1 index_subquery a a 5 func 3 Using index; Full scan on NULL key SELECT a, a IN (SELECT a FROM t1) FROM t2; a a IN (SELECT a FROM t1) 1 1 @@ -7042,8 +7040,8 @@ SELECT * FROM t1 WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index a a 5 NULL 2 Using where; Using index -2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where -2 SUBQUERY <subquery3> eq_ref distinct_key distinct_key 4 test.t2.c 1 +2 SUBQUERY <subquery3> ALL distinct_key NULL NULL NULL 1 +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) 3 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 SELECT * FROM t1 WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10; @@ -7134,7 +7132,7 @@ drop table t1,t2,t3,t4; # MDEV-7122 # Assertion `0' failed in subselect_hash_sj_engine::init # -SET SESSION big_tables=1; +set tmp_memory_table_size=0; CREATE TABLE t1(a char(255) DEFAULT '', KEY(a(10))) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; INSERT INTO t1 VALUES(0),(0),(0); SELECT * FROM t1 WHERE a IN(SELECT MIN(a) FROM t1); @@ -7143,7 +7141,7 @@ a 0 0 DROP TABLE t1; -SET SESSION big_tables=0; +set tmp_memory_table_size=default; # # MDEV-10776: Server crash on query # diff --git a/mysql-test/main/subselect_no_mat.result b/mysql-test/main/subselect_no_mat.result index da60f98bf00..f0c7033803c 100644 --- a/mysql-test/main/subselect_no_mat.result +++ b/mysql-test/main/subselect_no_mat.result @@ -689,8 +689,6 @@ x 3 11 11 -INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(x) FROM t2)); -ERROR 42S22: Unknown column 'x' in 'field list' INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); select * from t1; x @@ -1512,7 +1510,7 @@ a explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index -1 PRIMARY t3 index a a 5 NULL 3 100.00 Using where; Using index +1 PRIMARY t3 range a a 5 NULL 3 100.00 Using where; Using index 1 PRIMARY t1 ref a a 10 test.t2.a,test.t3.a 116 100.00 Using index; FirstMatch(t2) Warnings: Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where `test`.`t1`.`b` = `test`.`t3`.`a` and `test`.`t1`.`a` = `test`.`t2`.`a` @@ -3183,7 +3181,7 @@ INSERT INTO t2 VALUES (1),(2),(3); EXPLAIN SELECT a, a IN (SELECT a FROM t1) FROM t2; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 3 -2 SUBQUERY t1 index_subquery a a 5 func 2 Using index; Full scan on NULL key +2 SUBQUERY t1 index_subquery a a 5 func 3 Using index; Full scan on NULL key SELECT a, a IN (SELECT a FROM t1) FROM t2; a a IN (SELECT a FROM t1) 1 1 @@ -7127,7 +7125,7 @@ drop table t1,t2,t3,t4; # MDEV-7122 # Assertion `0' failed in subselect_hash_sj_engine::init # -SET SESSION big_tables=1; +set tmp_memory_table_size=0; CREATE TABLE t1(a char(255) DEFAULT '', KEY(a(10))) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; INSERT INTO t1 VALUES(0),(0),(0); SELECT * FROM t1 WHERE a IN(SELECT MIN(a) FROM t1); @@ -7136,7 +7134,7 @@ a 0 0 DROP TABLE t1; -SET SESSION big_tables=0; +set tmp_memory_table_size=default; # # MDEV-10776: Server crash on query # diff --git a/mysql-test/main/subselect_no_opts.result b/mysql-test/main/subselect_no_opts.result index fb99e237a1c..8ff79c1790b 100644 --- a/mysql-test/main/subselect_no_opts.result +++ b/mysql-test/main/subselect_no_opts.result @@ -685,8 +685,6 @@ x 3 11 11 -INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(x) FROM t2)); -ERROR 42S22: Unknown column 'x' in 'field list' INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); select * from t1; x @@ -1618,7 +1616,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index 2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 = ANY (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index @@ -1630,13 +1628,13 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index 2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index 2 SUBQUERY t2 index_subquery s1 s1 6 func 2 50.00 Using index; Using where; Full scan on NULL key Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where `test`.`t2`.`s1` < 'a2' having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from `test`.`t1` +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where `test`.`t2`.`s1` < 'a2' having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from `test`.`t1` drop table t1,t2; create table t2 (a int, b int not null); create table t3 (a int); @@ -1891,7 +1889,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 12 100.00 Using where 2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index; Using where Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`text` AS `text` from `test`.`t1` where !<in_optimizer>(`test`.`t1`.`id`,<exists>(<primary_index_lookup>(<cache>(`test`.`t1`.`id`) in t1 on PRIMARY where `test`.`t1`.`id` < 8 and <cache>(`test`.`t1`.`id`) = `test`.`t1`.`id`))) +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`text` AS `text` from `test`.`t1` where !(<in_optimizer>(`test`.`t1`.`id`,<exists>(<primary_index_lookup>(<cache>(`test`.`t1`.`id`) in t1 on PRIMARY where `test`.`t1`.`id` < 8 and <cache>(`test`.`t1`.`id`) = `test`.`t1`.`id`)))) explain extended select * from t1 as tt where not exists (select id from t1 where id < 8 and (id = tt.id or id is null) having id is not null); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY tt ALL NULL NULL NULL NULL 12 100.00 Using where @@ -3179,7 +3177,7 @@ INSERT INTO t2 VALUES (1),(2),(3); EXPLAIN SELECT a, a IN (SELECT a FROM t1) FROM t2; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 3 -2 SUBQUERY t1 index_subquery a a 5 func 2 Using index; Full scan on NULL key +2 SUBQUERY t1 index_subquery a a 5 func 3 Using index; Full scan on NULL key SELECT a, a IN (SELECT a FROM t1) FROM t2; a a IN (SELECT a FROM t1) 1 1 @@ -7033,8 +7031,8 @@ SELECT * FROM t1 WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index a a 5 NULL 2 Using where; Using index -2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where -2 SUBQUERY <subquery3> eq_ref distinct_key distinct_key 4 test.t2.c 1 +2 SUBQUERY <subquery3> ALL distinct_key NULL NULL NULL 1 +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) 3 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 SELECT * FROM t1 WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10; @@ -7125,7 +7123,7 @@ drop table t1,t2,t3,t4; # MDEV-7122 # Assertion `0' failed in subselect_hash_sj_engine::init # -SET SESSION big_tables=1; +set tmp_memory_table_size=0; CREATE TABLE t1(a char(255) DEFAULT '', KEY(a(10))) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; INSERT INTO t1 VALUES(0),(0),(0); SELECT * FROM t1 WHERE a IN(SELECT MIN(a) FROM t1); @@ -7134,7 +7132,7 @@ a 0 0 DROP TABLE t1; -SET SESSION big_tables=0; +set tmp_memory_table_size=default; # # MDEV-10776: Server crash on query # diff --git a/mysql-test/main/subselect_no_scache.result b/mysql-test/main/subselect_no_scache.result index 4b910009248..37ca0d4c030 100644 --- a/mysql-test/main/subselect_no_scache.result +++ b/mysql-test/main/subselect_no_scache.result @@ -688,8 +688,6 @@ x 3 11 11 -INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(x) FROM t2)); -ERROR 42S22: Unknown column 'x' in 'field list' INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); select * from t1; x @@ -1511,7 +1509,7 @@ a explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index -1 PRIMARY t3 index a a 5 NULL 3 100.00 Using where; Using index +1 PRIMARY t3 range a a 5 NULL 3 100.00 Using where; Using index 1 PRIMARY t1 ref a a 10 test.t2.a,test.t3.a 116 100.00 Using index; FirstMatch(t2) Warnings: Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where `test`.`t1`.`b` = `test`.`t3`.`a` and `test`.`t1`.`a` = `test`.`t2`.`a` @@ -1621,7 +1619,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index 2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 = ANY (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index @@ -1633,13 +1631,13 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index 2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index 2 SUBQUERY t2 index_subquery s1 s1 6 func 2 50.00 Using index; Using where; Full scan on NULL key Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where `test`.`t2`.`s1` < 'a2' having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from `test`.`t1` +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where `test`.`t2`.`s1` < 'a2' having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from `test`.`t1` drop table t1,t2; create table t2 (a int, b int not null); create table t3 (a int); @@ -1894,7 +1892,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 12 100.00 Using where 2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index; Using where Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`text` AS `text` from `test`.`t1` where !<in_optimizer>(`test`.`t1`.`id`,<exists>(<primary_index_lookup>(<cache>(`test`.`t1`.`id`) in t1 on PRIMARY where `test`.`t1`.`id` < 8 and <cache>(`test`.`t1`.`id`) = `test`.`t1`.`id`))) +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`text` AS `text` from `test`.`t1` where !(<in_optimizer>(`test`.`t1`.`id`,<exists>(<primary_index_lookup>(<cache>(`test`.`t1`.`id`) in t1 on PRIMARY where `test`.`t1`.`id` < 8 and <cache>(`test`.`t1`.`id`) = `test`.`t1`.`id`)))) explain extended select * from t1 as tt where not exists (select id from t1 where id < 8 and (id = tt.id or id is null) having id is not null); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY tt ALL NULL NULL NULL NULL 12 100.00 Using where @@ -3184,7 +3182,7 @@ INSERT INTO t2 VALUES (1),(2),(3); EXPLAIN SELECT a, a IN (SELECT a FROM t1) FROM t2; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 3 -2 SUBQUERY t1 index_subquery a a 5 func 2 Using index; Full scan on NULL key +2 SUBQUERY t1 index_subquery a a 5 func 3 Using index; Full scan on NULL key SELECT a, a IN (SELECT a FROM t1) FROM t2; a a IN (SELECT a FROM t1) 1 1 @@ -7048,8 +7046,8 @@ SELECT * FROM t1 WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index a a 5 NULL 2 Using where; Using index -2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where -2 SUBQUERY <subquery3> eq_ref distinct_key distinct_key 4 test.t2.c 1 +2 SUBQUERY <subquery3> ALL distinct_key NULL NULL NULL 1 +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) 3 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 SELECT * FROM t1 WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10; @@ -7140,7 +7138,7 @@ drop table t1,t2,t3,t4; # MDEV-7122 # Assertion `0' failed in subselect_hash_sj_engine::init # -SET SESSION big_tables=1; +set tmp_memory_table_size=0; CREATE TABLE t1(a char(255) DEFAULT '', KEY(a(10))) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; INSERT INTO t1 VALUES(0),(0),(0); SELECT * FROM t1 WHERE a IN(SELECT MIN(a) FROM t1); @@ -7149,7 +7147,7 @@ a 0 0 DROP TABLE t1; -SET SESSION big_tables=0; +set tmp_memory_table_size=default; # # MDEV-10776: Server crash on query # diff --git a/mysql-test/main/subselect_no_semijoin.result b/mysql-test/main/subselect_no_semijoin.result index f2230718754..1abdde5ff7f 100644 --- a/mysql-test/main/subselect_no_semijoin.result +++ b/mysql-test/main/subselect_no_semijoin.result @@ -685,8 +685,6 @@ x 3 11 11 -INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(x) FROM t2)); -ERROR 42S22: Unknown column 'x' in 'field list' INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); select * from t1; x @@ -1634,7 +1632,7 @@ Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<expr_cache><`test`.`t explain extended select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index -2 MATERIALIZED t2 index s1 s1 6 NULL 2 50.00 Using where; Using index +2 MATERIALIZED t2 range s1 s1 6 NULL 1 100.00 Using where; Using index Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,`test`.`t1`.`s1` in ( <materialize> (/* select#2 */ select `test`.`t2`.`s1` from `test`.`t2` where `test`.`t2`.`s1` < 'a2' ), <primary_index_lookup>(`test`.`t1`.`s1` in <temporary table> on distinct_key where `test`.`t1`.`s1` = `<subquery2>`.`s1`)))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from `test`.`t1` drop table t1,t2; @@ -7033,8 +7031,8 @@ SELECT * FROM t1 WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index a a 5 NULL 2 Using where; Using index -2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where -2 SUBQUERY <subquery3> eq_ref distinct_key distinct_key 4 test.t2.c 1 +2 SUBQUERY <subquery3> ALL distinct_key NULL NULL NULL 1 +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) 3 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 SELECT * FROM t1 WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10; @@ -7125,7 +7123,7 @@ drop table t1,t2,t3,t4; # MDEV-7122 # Assertion `0' failed in subselect_hash_sj_engine::init # -SET SESSION big_tables=1; +set tmp_memory_table_size=0; CREATE TABLE t1(a char(255) DEFAULT '', KEY(a(10))) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; INSERT INTO t1 VALUES(0),(0),(0); SELECT * FROM t1 WHERE a IN(SELECT MIN(a) FROM t1); @@ -7134,7 +7132,7 @@ a 0 0 DROP TABLE t1; -SET SESSION big_tables=0; +set tmp_memory_table_size=default; # # MDEV-10776: Server crash on query # diff --git a/mysql-test/main/subselect_partial_match.result b/mysql-test/main/subselect_partial_match.result index 5f444457794..52c30492675 100644 --- a/mysql-test/main/subselect_partial_match.result +++ b/mysql-test/main/subselect_partial_match.result @@ -775,7 +775,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DERIVED t1 ALL NULL NULL NULL NULL 2 100.00 Using where 3 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00 Warnings: -Note 1003 /* select#1 */ select `table1`.`a1` AS `a1`,`table1`.`a2` AS `a2` from (/* select#2 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where !<in_optimizer>(`test`.`t1`.`a1`,`test`.`t1`.`a1` in ( <materialize> (/* select#3 */ select `test`.`t2`.`b2` from `test`.`t2` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where `test`.`t1`.`a1` = `<subquery3>`.`b2`)))) `table1` +Note 1003 /* select#1 */ select `table1`.`a1` AS `a1`,`table1`.`a2` AS `a2` from (/* select#2 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where !(<in_optimizer>(`test`.`t1`.`a1`,`test`.`t1`.`a1` in ( <materialize> (/* select#3 */ select `test`.`t2`.`b2` from `test`.`t2` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where `test`.`t1`.`a1` = `<subquery3>`.`b2`))))) `table1` set optimizer_switch=@tmp_optimizer_switch; DROP TABLE t1, t2; # diff --git a/mysql-test/main/subselect_sj.result b/mysql-test/main/subselect_sj.result index f3519e1d846..b4ad66458dc 100644 --- a/mysql-test/main/subselect_sj.result +++ b/mysql-test/main/subselect_sj.result @@ -2768,8 +2768,8 @@ SELECT * FROM t1 AS t1_1, t1 AS t1_2 WHERE (t1_1.a, t1_2.a) IN ( SELECT a, b FROM v1 ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1_1 ALL NULL NULL NULL NULL 11 Using where -1 PRIMARY <derived3> ref key0 key0 5 test.t1_1.a 2 Start temporary -1 PRIMARY t1_2 ALL NULL NULL NULL NULL 11 Using where; End temporary +1 PRIMARY t1_2 ALL NULL NULL NULL NULL 11 +1 PRIMARY <derived3> ref key0 key0 5 test.t1_1.a 2 Using where; FirstMatch(t1_2) 3 DERIVED t1 ALL NULL NULL NULL NULL 11 SELECT * FROM t1 AS t1_1, t1 AS t1_2 WHERE (t1_1.a, t1_2.a) IN ( SELECT a, b FROM v1 ); @@ -2777,10 +2777,10 @@ a b a b 3 1 9 1 5 8 4 0 3 9 9 1 -2 4 6 8 2 4 4 0 -2 6 6 8 +2 4 6 8 2 6 4 0 +2 6 6 8 5 4 4 0 7 7 7 7 5 4 4 0 @@ -2927,8 +2927,8 @@ alias2.col_int_key = alias1.col_int_key WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' ); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t2 ALL NULL NULL NULL NULL 2 1 PRIMARY alias1 index_merge PRIMARY,col_int_key,col_varchar_key PRIMARY,col_varchar_key 4,4 NULL 2 Using sort_union(PRIMARY,col_varchar_key); Using where; Start temporary +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) 1 PRIMARY alias2 ALL col_int_key NULL NULL NULL 12 Range checked for each record (index map: 0x2); End temporary SELECT * FROM t2 diff --git a/mysql-test/main/subselect_sj2.result b/mysql-test/main/subselect_sj2.result index 8045a810e3f..2d0df9a05d0 100644 --- a/mysql-test/main/subselect_sj2.result +++ b/mysql-test/main/subselect_sj2.result @@ -304,7 +304,7 @@ from t0 where a in id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t0 ALL NULL NULL NULL NULL 10 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func 1 Using where -2 MATERIALIZED t1 index a a 5 NULL 10 Using where; Using index +2 MATERIALIZED t1 range a a 5 NULL 10 Using where; Using index 2 MATERIALIZED t2 ref a a 5 test.t1.a 1 Using index 2 MATERIALIZED t3 ref a a 5 test.t1.a 1 Using index drop table t0, t1,t2,t3; @@ -957,9 +957,9 @@ SELECT d FROM t2, t1 WHERE a = d AND ( pk < 2 OR d = 'z' ) ); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL b NULL NULL NULL 19 -1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 -2 MATERIALIZED t2 index PRIMARY,d d 9 NULL 17 Using where; Using index +1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2 +1 PRIMARY t1 ref b b 4 test.t2.d 1 +2 MATERIALIZED t2 index_merge PRIMARY,d d,PRIMARY 4,4 NULL 2 Using sort_union(d,PRIMARY); Using where 2 MATERIALIZED t1 ref a a 5 test.t2.d 1 Using where; Using index SELECT * FROM t1 WHERE b IN ( SELECT d FROM t2, t1 diff --git a/mysql-test/main/subselect_sj2_jcl6.result b/mysql-test/main/subselect_sj2_jcl6.result index 22310ab5361..f0e8e9b4881 100644 --- a/mysql-test/main/subselect_sj2_jcl6.result +++ b/mysql-test/main/subselect_sj2_jcl6.result @@ -315,7 +315,7 @@ from t0 where a in id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t0 ALL NULL NULL NULL NULL 10 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func 1 Using where -2 MATERIALIZED t1 index a a 5 NULL 10 Using where; Using index +2 MATERIALIZED t1 range a a 5 NULL 10 Using where; Using index 2 MATERIALIZED t2 ref a a 5 test.t1.a 1 Using index 2 MATERIALIZED t3 ref a a 5 test.t1.a 1 Using index drop table t0, t1,t2,t3; @@ -970,9 +970,9 @@ SELECT d FROM t2, t1 WHERE a = d AND ( pk < 2 OR d = 'z' ) ); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL b NULL NULL NULL 19 -1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 -2 MATERIALIZED t2 index PRIMARY,d d 9 NULL 17 Using where; Using index +1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2 +1 PRIMARY t1 ref b b 4 test.t2.d 1 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +2 MATERIALIZED t2 index_merge PRIMARY,d d,PRIMARY 4,4 NULL 2 Using sort_union(d,PRIMARY); Using where 2 MATERIALIZED t1 ref a a 5 test.t2.d 1 Using where; Using index SELECT * FROM t1 WHERE b IN ( SELECT d FROM t2, t1 diff --git a/mysql-test/main/subselect_sj2_mat.result b/mysql-test/main/subselect_sj2_mat.result index e2c9adbfc37..9b497ade58b 100644 --- a/mysql-test/main/subselect_sj2_mat.result +++ b/mysql-test/main/subselect_sj2_mat.result @@ -306,7 +306,7 @@ from t0 where a in id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t0 ALL NULL NULL NULL NULL 10 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func 1 Using where -2 MATERIALIZED t1 index a a 5 NULL 10 Using where; Using index +2 MATERIALIZED t1 range a a 5 NULL 10 Using where; Using index 2 MATERIALIZED t2 ref a a 5 test.t1.a 1 Using index 2 MATERIALIZED t3 ref a a 5 test.t1.a 1 Using index drop table t0, t1,t2,t3; @@ -959,9 +959,9 @@ SELECT d FROM t2, t1 WHERE a = d AND ( pk < 2 OR d = 'z' ) ); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL b NULL NULL NULL 19 -1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 -2 MATERIALIZED t2 index PRIMARY,d d 9 NULL 17 Using where; Using index +1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2 +1 PRIMARY t1 ref b b 4 test.t2.d 1 +2 MATERIALIZED t2 index_merge PRIMARY,d d,PRIMARY 4,4 NULL 2 Using sort_union(d,PRIMARY); Using where 2 MATERIALIZED t1 ref a a 5 test.t2.d 1 Using where; Using index SELECT * FROM t1 WHERE b IN ( SELECT d FROM t2, t1 @@ -1727,7 +1727,7 @@ WHERE f1 IN ( SELECT f2 FROM t2 WHERE f2 > 'bar' ) HAVING f1 != 'foo' ORDER BY f1; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index f1 f1 11 NULL 2 Using where; Using index +1 PRIMARY t1 range f1 f1 11 NULL 2 Using where; Using index 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 11 func 1 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where DROP TABLE t1,t2; @@ -1932,20 +1932,20 @@ AND t3.id_product IN (SELECT id_product FROM t2 t2_3 WHERE t2_3.id_t2 = 18 OR t2 AND t3.id_product IN (SELECT id_product FROM t2 t2_4 WHERE t2_4.id_t2 = 34 OR t2_4.id_t2 = 23) AND t3.id_product IN (SELECT id_product FROM t2 t2_5 WHERE t2_5.id_t2 = 29 OR t2_5.id_t2 = 28 OR t2_5.id_t2 = 26); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY <subquery3> ALL distinct_key NULL NULL NULL 12 -1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t2_2.id_product 1 Using where; Using index -1 PRIMARY <subquery5> eq_ref distinct_key distinct_key 4 func 1 Using where +1 PRIMARY t3 index PRIMARY PRIMARY 4 NULL 18 Using index +1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1 Using where 1 PRIMARY t5 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) +1 PRIMARY <subquery4> eq_ref distinct_key distinct_key 4 func 1 Using where 1 PRIMARY <subquery6> eq_ref distinct_key distinct_key 4 func 1 Using where -1 PRIMARY t4 eq_ref PRIMARY PRIMARY 8 test.t3.id_product,const 1 Using where; Using index 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 Using where -1 PRIMARY <subquery4> eq_ref distinct_key distinct_key 4 func 1 Using where +1 PRIMARY t4 eq_ref PRIMARY PRIMARY 8 test.t3.id_product,const 1 Using where; Using index +1 PRIMARY <subquery5> eq_ref distinct_key distinct_key 4 func 1 Using where 1 PRIMARY t1 index NULL PRIMARY 8 NULL 73 Using where; Using index; Using join buffer (flat, BNL join) -3 MATERIALIZED t2_2 ref id_t2,id_product id_t2 5 const 12 Using where -5 MATERIALIZED t2_4 range id_t2,id_product id_t2 5 NULL 18 Using index condition; Using where -6 MATERIALIZED t2_5 range id_t2,id_product id_t2 5 NULL 31 Using index condition; Using where -2 MATERIALIZED t2_1 ref id_t2,id_product id_t2 5 const 51 +3 MATERIALIZED t2_2 ref id_t2,id_product id_t2 5 const 12 4 MATERIALIZED t2_3 range id_t2,id_product id_t2 5 NULL 33 Using index condition; Using where +6 MATERIALIZED t2_5 range id_t2,id_product id_t2 5 NULL 31 Using index condition; Using where +2 MATERIALIZED t2_1 ALL id_t2,id_product NULL NULL NULL 223 Using where +5 MATERIALIZED t2_4 range id_t2,id_product id_t2 5 NULL 18 Using index condition; Using where set optimizer_switch='rowid_filter=default'; drop table t1,t2,t3,t4,t5; set global innodb_stats_persistent= @innodb_stats_persistent_save; diff --git a/mysql-test/main/subselect_sj_jcl6.result b/mysql-test/main/subselect_sj_jcl6.result index 02e9a833db6..2301a03f973 100644 --- a/mysql-test/main/subselect_sj_jcl6.result +++ b/mysql-test/main/subselect_sj_jcl6.result @@ -2779,8 +2779,8 @@ SELECT * FROM t1 AS t1_1, t1 AS t1_2 WHERE (t1_1.a, t1_2.a) IN ( SELECT a, b FROM v1 ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1_1 ALL NULL NULL NULL NULL 11 Using where -1 PRIMARY <derived3> ref key0 key0 5 test.t1_1.a 2 Start temporary -1 PRIMARY t1_2 ALL NULL NULL NULL NULL 11 Using where; End temporary +1 PRIMARY t1_2 ALL NULL NULL NULL NULL 11 +1 PRIMARY <derived3> ref key0 key0 5 test.t1_1.a 2 Using where; FirstMatch(t1_2) 3 DERIVED t1 ALL NULL NULL NULL NULL 11 SELECT * FROM t1 AS t1_1, t1 AS t1_2 WHERE (t1_1.a, t1_2.a) IN ( SELECT a, b FROM v1 ); @@ -2788,10 +2788,10 @@ a b a b 3 1 9 1 5 8 4 0 3 9 9 1 -2 4 6 8 2 4 4 0 -2 6 6 8 +2 4 6 8 2 6 4 0 +2 6 6 8 5 4 4 0 7 7 7 7 5 4 4 0 @@ -2938,8 +2938,8 @@ alias2.col_int_key = alias1.col_int_key WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' ); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t2 ALL NULL NULL NULL NULL 2 -1 PRIMARY alias1 index_merge PRIMARY,col_int_key,col_varchar_key PRIMARY,col_varchar_key 4,4 NULL 2 Using sort_union(PRIMARY,col_varchar_key); Using where; Start temporary; Using join buffer (flat, BNL join) +1 PRIMARY alias1 index_merge PRIMARY,col_int_key,col_varchar_key PRIMARY,col_varchar_key 4,4 NULL 2 Using sort_union(PRIMARY,col_varchar_key); Using where; Start temporary +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) 1 PRIMARY alias2 ALL col_int_key NULL NULL NULL 12 Range checked for each record (index map: 0x2); End temporary SELECT * FROM t2 diff --git a/mysql-test/main/subselect_sj_mat.result b/mysql-test/main/subselect_sj_mat.result index afc75a22962..695c010692c 100644 --- a/mysql-test/main/subselect_sj_mat.result +++ b/mysql-test/main/subselect_sj_mat.result @@ -107,10 +107,11 @@ a1 a2 explain extended select * from t1i where a1 in (select b1 from t2i where b1 > '0'); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2i index it2i1,it2i3 it2i1 # NULL 5 50.00 Using where; Using index; LooseScan -1 PRIMARY t1i ref _it1_idx _it1_idx # _ref_ 1 100.00 +1 PRIMARY t1i range _it1_idx _it1_idx # NULL 3 100.00 Using where; +1 PRIMARY <subquery2> eq_ref distinct_key distinct_key # func 1 100.00 +2 MATERIALIZED t2i range it2i1,it2i3 it2i1 # NULL 5 100.00 Using where; Warnings: -Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) where `test`.`t1i`.`a1` = `test`.`t2i`.`b1` and `test`.`t2i`.`b1` > '0' +Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) where `test`.`t2i`.`b1` > '0' select * from t1i where a1 in (select b1 from t2i where b1 > '0'); a1 a2 1 - 01 2 - 01 @@ -130,10 +131,11 @@ a1 a2 explain extended select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0'); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2i index it2i1,it2i2,it2i3 it2i3 # NULL 5 50.00 Using where; Using index; LooseScan -1 PRIMARY t1i ref _it1_idx _it1_idx # _ref_ 1 100.00 +1 PRIMARY t1i range _it1_idx _it1_idx # NULL 3 100.00 Using where; +1 PRIMARY <subquery2> eq_ref distinct_key distinct_key # func,func 1 100.00 +2 MATERIALIZED t2i range it2i1,it2i2,it2i3 it2i3 # NULL 5 100.00 Using where; Warnings: -Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) where `test`.`t1i`.`a1` = `test`.`t2i`.`b1` and `test`.`t1i`.`a2` = `test`.`t2i`.`b2` and `test`.`t2i`.`b1` > '0' +Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) where `test`.`t2i`.`b1` > '0' select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0'); a1 a2 1 - 01 2 - 01 @@ -350,12 +352,14 @@ where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and (a1, a2) in (select c1, c2 from t3i where (c1, c2) in (select b1, b2 from t2i where b2 > '0')); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2i index it2i1,it2i2,it2i3 # # # 5 50.00 # -1 PRIMARY t1i ref it1i1,it1i2,it1i3 # # # 1 100.00 # -1 PRIMARY t3i ref it3i1,it3i2,it3i3 # # # 1 100.00 # -1 PRIMARY t2i ref it2i1,it2i2,it2i3 # # # 1 100.00 # +1 PRIMARY t1i range it1i1,it1i2,it1i3 # # # 3 100.00 # +1 PRIMARY <subquery3> eq_ref distinct_key # # # 1 100.00 # +1 PRIMARY <subquery2> eq_ref distinct_key # # # 1 100.00 # +3 MATERIALIZED t3i range it3i1,it3i2,it3i3 # # # 4 100.00 # +3 MATERIALIZED t2i ref it2i1,it2i2,it2i3 # # # 1 100.00 # +2 MATERIALIZED t2i range it2i1,it2i2,it2i3 # # # 5 100.00 # Warnings: -Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) semi join (`test`.`t2i` join `test`.`t3i`) where `test`.`t1i`.`a1` = `test`.`t2i`.`b1` and `test`.`t3i`.`c1` = `test`.`t2i`.`b1` and `test`.`t2i`.`b1` = `test`.`t2i`.`b1` and `test`.`t1i`.`a2` = `test`.`t2i`.`b2` and `test`.`t3i`.`c2` = `test`.`t2i`.`b2` and `test`.`t2i`.`b2` = `test`.`t2i`.`b2` and `test`.`t2i`.`b1` > '0' and `test`.`t2i`.`b2` > '0' +Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) semi join (`test`.`t2i` join `test`.`t3i`) where `test`.`t2i`.`b1` = `test`.`t3i`.`c1` and `test`.`t2i`.`b2` = `test`.`t3i`.`c2` and `test`.`t2i`.`b1` > '0' and `test`.`t3i`.`c2` > '0' select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and (a1, a2) in (select c1, c2 from t3i @@ -438,13 +442,15 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 MATERIALIZED t2 ALL NULL # # # 5 99.22 # 4 MATERIALIZED t3 ALL NULL # # # 4 100.00 # 3 MATERIALIZED t3 ALL NULL # # # 4 100.00 # -7 UNION t2i index it2i1,it2i2,it2i3 # # # 5 50.00 # -7 UNION t1i ref it1i1,it1i2,it1i3 # # # 1 100.00 # -7 UNION t3i ref it3i1,it3i2,it3i3 # # # 1 100.00 # -7 UNION t2i ref it2i1,it2i2,it2i3 # # # 1 100.00 # +7 UNION t1i range it1i1,it1i2,it1i3 # # # 3 100.00 # +7 UNION <subquery9> eq_ref distinct_key # # # 1 100.00 # +7 UNION <subquery8> eq_ref distinct_key # # # 1 100.00 # +9 MATERIALIZED t3i range it3i1,it3i2,it3i3 # # # 4 100.00 # +9 MATERIALIZED t2i ref it2i1,it2i2,it2i3 # # # 1 100.00 # +8 MATERIALIZED t2i range it2i1,it2i2,it2i3 # # # 5 100.00 # NULL UNION RESULT <union1,7> ALL NULL # # # NULL NULL # Warnings: -Note 1003 (/* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) semi join (`test`.`t2i` join `test`.`t3`) where `test`.`t2i`.`b1` = `test`.`t3`.`c1` and `test`.`t2i`.`b2` = `test`.`t3`.`c2` and (<expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (/* select#3 */ select `test`.`t3`.`c2` from `test`.`t3` where `test`.`t3`.`c2` like '%02' ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where `test`.`t2`.`b2` = `<subquery3>`.`c2`)))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (/* select#4 */ select `test`.`t3`.`c2` from `test`.`t3` where `test`.`t3`.`c2` like '%03' ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where `test`.`t2`.`b2` = `<subquery4>`.`c2`))))) and `test`.`t3`.`c2` > '0') union (/* select#7 */ select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) semi join (`test`.`t2i` join `test`.`t3i`) where `test`.`t1i`.`a1` = `test`.`t2i`.`b1` and `test`.`t3i`.`c1` = `test`.`t2i`.`b1` and `test`.`t2i`.`b1` = `test`.`t2i`.`b1` and `test`.`t1i`.`a2` = `test`.`t2i`.`b2` and `test`.`t3i`.`c2` = `test`.`t2i`.`b2` and `test`.`t2i`.`b2` = `test`.`t2i`.`b2` and `test`.`t2i`.`b1` > '0' and `test`.`t2i`.`b2` > '0') +Note 1003 (/* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) semi join (`test`.`t2i` join `test`.`t3`) where `test`.`t2i`.`b1` = `test`.`t3`.`c1` and `test`.`t2i`.`b2` = `test`.`t3`.`c2` and (<expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (/* select#3 */ select `test`.`t3`.`c2` from `test`.`t3` where `test`.`t3`.`c2` like '%02' ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where `test`.`t2`.`b2` = `<subquery3>`.`c2`)))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (/* select#4 */ select `test`.`t3`.`c2` from `test`.`t3` where `test`.`t3`.`c2` like '%03' ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where `test`.`t2`.`b2` = `<subquery4>`.`c2`))))) and `test`.`t3`.`c2` > '0') union (/* select#7 */ select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) semi join (`test`.`t2i` join `test`.`t3i`) where `test`.`t2i`.`b1` = `test`.`t3i`.`c1` and `test`.`t2i`.`b2` = `test`.`t3i`.`c2` and `test`.`t2i`.`b1` > '0' and `test`.`t3i`.`c2` > '0') (select * from t1 where (a1, a2) in (select b1, b2 from t2 where b2 in (select c2 from t3 where c2 LIKE '%02') or @@ -1175,7 +1181,7 @@ a explain extended select a from t1 group by a having a in (select c from t2 where d >= 20); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 index NULL it1a 4 NULL 7 100.00 Using index +1 PRIMARY t1 range NULL it1a 4 NULL 8 100.00 Using index for group-by 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 7 100.00 Using where Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (/* select#2 */ select `test`.`t2`.`c` from `test`.`t2` where `test`.`t2`.`d` >= 20 ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where `test`.`t1`.`a` = `<subquery2>`.`c`)))) @@ -1187,7 +1193,7 @@ create index iab on t1(a, b); explain extended select a from t1 group by a having a in (select c from t2 where d >= 20); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 index NULL it1a 4 NULL 7 100.00 Using index +1 PRIMARY t1 range NULL it1a 4 NULL 8 100.00 Using index for group-by 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 7 100.00 Using where Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (/* select#2 */ select `test`.`t2`.`c` from `test`.`t2` where `test`.`t2`.`d` >= 20 ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where `test`.`t1`.`a` = `<subquery2>`.`c`)))) @@ -1199,7 +1205,7 @@ explain extended select a from t1 group by a having a in (select c from t2 where d >= some(select e from t3 where max(b)=e)); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 index NULL iab 8 NULL 7 100.00 Using index +1 PRIMARY t1 range NULL iab 4 NULL 8 100.00 Using index for group-by 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00 Using where 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: @@ -2154,8 +2160,7 @@ DROP VIEW v2; # # MDEV-5811: Server crashes in best_access_path with materialization+semijoin and big_tables=ON # -SET @tmp_mdev5811= @@big_tables; -SET big_tables = ON; +set tmp_memory_table_size=0; CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (1),(2); CREATE TABLE t2 (b INT); @@ -2164,7 +2169,7 @@ SELECT * FROM t1 AS t1_1, t1 AS t1_2 WHERE ( t1_1.a, t1_2.a ) IN ( SELECT MAX(b), MIN(b) FROM t2 ); a a DROP TABLE t1,t2; -SET big_tables=@tmp_mdev5811; +set tmp_memory_table_size=default; # End of 5.3 tests # # MDEV-5056: Wrong result (extra rows) with materialization+semijoin, IN subqueries @@ -2313,7 +2318,7 @@ WHERE i3 = i2 AND f1 IN ( SELECT f3 FROM t3 ) ); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where 2 DEPENDENT SUBQUERY <subquery3> eq_ref distinct_key distinct_key 4 func 1 100.00 -2 DEPENDENT SUBQUERY t2 index i2 i2 5 NULL 3 100.00 Using where; Using index; Using join buffer (flat, BNL join) +2 DEPENDENT SUBQUERY t2 range i2 i2 5 NULL 3 100.00 Using where; Using index; Using join buffer (flat, BNL join) 2 DEPENDENT SUBQUERY t3 ref i3 i3 5 test.t2.i2 2 100.00 Using index 3 MATERIALIZED t3 ALL NULL NULL NULL NULL 8 100.00 Warnings: diff --git a/mysql-test/main/subselect_sj_mat.test b/mysql-test/main/subselect_sj_mat.test index 1de8701ecbb..8d5bbd8ef82 100644 --- a/mysql-test/main/subselect_sj_mat.test +++ b/mysql-test/main/subselect_sj_mat.test @@ -1760,8 +1760,7 @@ DROP VIEW v2; --echo # --echo # MDEV-5811: Server crashes in best_access_path with materialization+semijoin and big_tables=ON --echo # -SET @tmp_mdev5811= @@big_tables; -SET big_tables = ON; +set tmp_memory_table_size=0; # force on-disk tmp table CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (1),(2); @@ -1773,7 +1772,7 @@ SELECT * FROM t1 AS t1_1, t1 AS t1_2 WHERE ( t1_1.a, t1_2.a ) IN ( SELECT MAX(b), MIN(b) FROM t2 ); DROP TABLE t1,t2; -SET big_tables=@tmp_mdev5811; +set tmp_memory_table_size=default; --echo # End of 5.3 tests diff --git a/mysql-test/main/subselect_sj_nonmerged.result b/mysql-test/main/subselect_sj_nonmerged.result index 7b73ae0fc57..422af02c31a 100644 --- a/mysql-test/main/subselect_sj_nonmerged.result +++ b/mysql-test/main/subselect_sj_nonmerged.result @@ -47,8 +47,8 @@ id select_type table type possible_keys key key_len ref rows Extra # Compare to this which really will have 50 record combinations: explain select * from t3 where a in (select max(t2.a) from t1, t2 group by t2.b, t1.b); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 50 -1 PRIMARY t3 eq_ref PRIMARY PRIMARY 8 <subquery2>.max(t2.a) 1 Using where; Using index +1 PRIMARY t3 index PRIMARY PRIMARY 8 NULL 100 Using index +1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 test.t3.a 1 Using where 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 Using temporary 2 MATERIALIZED t1 ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join) SET @save_optimizer_switch=@@optimizer_switch; @@ -57,8 +57,8 @@ SET optimizer_switch='outer_join_with_cache=off'; explain select * from t3 where a in (select max(t2.a) from t1 left join t2 on t1.a=t2.a group by t2.b, t1.b); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 50 -1 PRIMARY t3 eq_ref PRIMARY PRIMARY 8 <subquery2>.max(t2.a) 1 Using where; Using index +1 PRIMARY t3 index PRIMARY PRIMARY 8 NULL 100 Using index +1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 test.t3.a 1 Using where 2 MATERIALIZED t1 ALL NULL NULL NULL NULL 10 Using temporary 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 Using where SET optimizer_switch=@save_optimizer_switch; diff --git a/mysql-test/main/sum_distinct-big.result b/mysql-test/main/sum_distinct-big.result index 08afa1dd1b0..086dd33fad2 100644 --- a/mysql-test/main/sum_distinct-big.result +++ b/mysql-test/main/sum_distinct-big.result @@ -1,6 +1,6 @@ set @save_tmp_table_size=@@tmp_table_size; set @save_max_heap_table_size=@@max_heap_table_size; -set storage_engine=MYISAM; +set default_storage_engine=MYISAM; CREATE TABLE t1 (id INTEGER); CREATE TABLE t2 (id INTEGER); INSERT INTO t1 SELECT b.seq FROM seq_1_to_128,seq_1_to_1024 b; diff --git a/mysql-test/main/sum_distinct-big.test b/mysql-test/main/sum_distinct-big.test index d87569f8668..41aa5a44c19 100644 --- a/mysql-test/main/sum_distinct-big.test +++ b/mysql-test/main/sum_distinct-big.test @@ -3,6 +3,8 @@ # --source include/big_test.inc +# Test will take more than one hour with valgrind +--source include/not_valgrind.inc --source include/have_innodb.inc --source include/have_sequence.inc @@ -14,7 +16,7 @@ set @save_max_heap_table_size=@@max_heap_table_size; # filesort is used (see uniques.cc:merge_walk) # -set storage_engine=MYISAM; +set default_storage_engine=MYISAM; CREATE TABLE t1 (id INTEGER); CREATE TABLE t2 (id INTEGER); diff --git a/mysql-test/main/symlink-myisam-11902.test b/mysql-test/main/symlink-myisam-11902.test index 8fd4961d1fb..8fae41222cf 100644 --- a/mysql-test/main/symlink-myisam-11902.test +++ b/mysql-test/main/symlink-myisam-11902.test @@ -25,7 +25,7 @@ exec rm -r $MYSQLTEST_VARDIR/tmp/foo; exec ln -s $datadir/mysql $MYSQLTEST_VARDIR/tmp/foo; set debug_sync='now SIGNAL go'; connection default; -replace_regex / '.*\/tmp\// 'MYSQLTEST_VARDIR\/tmp\// /31/20/ /40/20/ /20.*/20 <errmsg>)/; +replace_regex / '.*\/tmp\// 'MYSQLTEST_VARDIR\/tmp\// /31/20/ /40/20/ /85/20/ /20.*/20 <errmsg>)/; error 29; reap; flush tables; @@ -49,7 +49,7 @@ exec rm -r $MYSQLTEST_VARDIR/tmp/foo; exec ln -s $datadir/mysql $MYSQLTEST_VARDIR/tmp/foo; set debug_sync='now SIGNAL run'; connection default; -replace_regex / '.*\/test\// '.\/test\// /31/20/ /40/20/ /20.*/20 <errmsg>)/; +replace_regex / '.*\/test\// '.\/test\// /31/20/ /40/20/ /85/20/ /20.*/20 <errmsg>)/; error ER_FILE_NOT_FOUND; reap; flush tables; diff --git a/mysql-test/main/system_mysql_db_error_log-master.opt b/mysql-test/main/system_mysql_db_error_log-master.opt new file mode 100644 index 00000000000..37a865d29e0 --- /dev/null +++ b/mysql-test/main/system_mysql_db_error_log-master.opt @@ -0,0 +1 @@ +--log-error=$MYSQLTEST_VARDIR/tmp/system_mysql_db_error_log.err diff --git a/mysql-test/main/system_mysql_db_error_log.result b/mysql-test/main/system_mysql_db_error_log.result new file mode 100644 index 00000000000..5af3eda0700 --- /dev/null +++ b/mysql-test/main/system_mysql_db_error_log.result @@ -0,0 +1,118 @@ +# +# MDEV-21704 Add a new JSON field "version_id" into mysql.global_priv.priv +# +SET @super_acl_100500= 1 << 15; +SELECT HEX(@super_acl_100500); +HEX(@super_acl_100500) +8000 +SET @all_known_privileges_100500= (1 << 30) - 1; +SELECT HEX(@all_known_privileges_100500); +HEX(@all_known_privileges_100500) +3FFFFFFF +CREATE USER user1@localhost; +GRANT ALL PRIVILEGES ON *.* TO user1@localhost WITH GRANT OPTION; +SET @all_known_privileges_current=(SELECT CAST(json_value(Priv, '$.access') AS UNSIGNED) FROM mysql.global_priv WHERE host='localhost' and user='user1'); +DROP USER user1@localhost; +SELECT HEX(@all_known_privileges_current); +HEX(@all_known_privileges_current) +7FFFFFFFFF +CREATE USER bad_access1@localhost; +UPDATE +mysql.global_priv +SET +Priv=json_set(Priv, '$.access',@all_known_privileges_current+1) +WHERE +host='localhost' and user='bad_access1'; +FLUSH PRIVILEGES; +SHOW GRANTS FOR bad_access1@localhost; +Grants for bad_access1@localhost +GRANT USAGE ON *.* TO `bad_access1`@`localhost` +DROP USER bad_access1@localhost; +CREATE USER bad_version_id_1000000@localhost; +GRANT ALL PRIVILEGES ON *.* to bad_version_id_1000000@localhost; +SHOW GRANTS FOR bad_version_id_1000000@localhost; +Grants for bad_version_id_1000000@localhost +GRANT ALL PRIVILEGES ON *.* TO `bad_version_id_1000000`@`localhost` +UPDATE +mysql.global_priv +SET +Priv=json_set(Priv, '$.version_id',1000000) +WHERE +host='localhost' and user='bad_version_id_1000000'; +FLUSH PRIVILEGES; +SHOW GRANTS FOR bad_version_id_1000000@localhost; +Grants for bad_version_id_1000000@localhost +GRANT USAGE ON *.* TO `bad_version_id_1000000`@`localhost` +DROP USER bad_version_id_1000000@localhost; +CREATE USER bad_version_id_minus_3@localhost; +GRANT ALL PRIVILEGES ON *.* to bad_version_id_minus_3@localhost; +SHOW GRANTS FOR bad_version_id_minus_3@localhost; +Grants for bad_version_id_minus_3@localhost +GRANT ALL PRIVILEGES ON *.* TO `bad_version_id_minus_3`@`localhost` +UPDATE +mysql.global_priv +SET +Priv=json_set(Priv, '$.version_id',-3) +WHERE +host='localhost' and user='bad_version_id_minus_3'; +FLUSH PRIVILEGES; +SHOW GRANTS FOR bad_version_id_minus_3@localhost; +Grants for bad_version_id_minus_3@localhost +GRANT USAGE ON *.* TO `bad_version_id_minus_3`@`localhost` +DROP USER bad_version_id_minus_3@localhost; +CREATE USER bad_version_id_100300@localhost; +GRANT ALL PRIVILEGES ON *.* to bad_version_id_100300@localhost; +SHOW GRANTS FOR bad_version_id_100300@localhost; +Grants for bad_version_id_100300@localhost +GRANT ALL PRIVILEGES ON *.* TO `bad_version_id_100300`@`localhost` +UPDATE +mysql.global_priv +SET +Priv=json_set(Priv, '$.version_id',100300) +WHERE +host='localhost' and user='bad_version_id_100300'; +FLUSH PRIVILEGES; +SHOW GRANTS FOR bad_version_id_100300@localhost; +Grants for bad_version_id_100300@localhost +GRANT USAGE ON *.* TO `bad_version_id_100300`@`localhost` +DROP USER bad_version_id_100300@localhost; +CREATE USER good_version_id_100400@localhost; +GRANT ALL PRIVILEGES ON *.* to good_version_id_100400@localhost; +SHOW GRANTS FOR good_version_id_100400@localhost; +Grants for good_version_id_100400@localhost +GRANT ALL PRIVILEGES ON *.* TO `good_version_id_100400`@`localhost` +UPDATE +mysql.global_priv +SET +Priv=json_set(Priv, '$.version_id',100400, '$.access', @all_known_privileges_100500) +WHERE +host='localhost' and user='good_version_id_100400'; +FLUSH PRIVILEGES; +SHOW GRANTS FOR good_version_id_100400@localhost; +Grants for good_version_id_100400@localhost +GRANT ALL PRIVILEGES ON *.* TO `good_version_id_100400`@`localhost` WITH GRANT OPTION +GRANT REPLICATION MASTER ADMIN ON *.* TO good_version_id_100400@localhost; +SHOW GRANTS FOR good_version_id_100400@localhost; +Grants for good_version_id_100400@localhost +GRANT ALL PRIVILEGES ON *.* TO `good_version_id_100400`@`localhost` WITH GRANT OPTION +DROP USER good_version_id_100400@localhost; +CREATE USER good_version_id_100500@localhost; +GRANT SUPER ON *.* to good_version_id_100500@localhost; +SHOW GRANTS FOR good_version_id_100500@localhost; +Grants for good_version_id_100500@localhost +GRANT SUPER ON *.* TO `good_version_id_100500`@`localhost` +UPDATE +mysql.global_priv +SET +Priv=json_set(Priv, '$.version_id',100500) +WHERE +host='localhost' and user='good_version_id_100500'; +FLUSH PRIVILEGES; +SHOW GRANTS FOR good_version_id_100500@localhost; +Grants for good_version_id_100500@localhost +GRANT SUPER, SET USER, FEDERATED ADMIN, CONNECTION ADMIN, READ_ONLY ADMIN, REPLICATION SLAVE ADMIN, BINLOG ADMIN, BINLOG REPLAY ON *.* TO `good_version_id_100500`@`localhost` +DROP USER good_version_id_100500@localhost; +FOUND 1 /Warning.*'user' entry 'bad_access1@localhost' has a wrong 'access' value.*version_id=/ in system_mysql_db_error_log.err +FOUND 1 /Warning.*'user' entry 'bad_version_id_1000000@localhost' has a wrong 'version_id' value 1000000/ in system_mysql_db_error_log.err +FOUND 1 /Warning.*'user' entry 'bad_version_id_minus_3@localhost' has a wrong 'version_id' value -3/ in system_mysql_db_error_log.err +FOUND 1 /Warning.*'user' entry 'bad_version_id_100300@localhost' has a wrong 'version_id' value 100300/ in system_mysql_db_error_log.err diff --git a/mysql-test/main/system_mysql_db_error_log.test b/mysql-test/main/system_mysql_db_error_log.test new file mode 100644 index 00000000000..17c04a9cc14 --- /dev/null +++ b/mysql-test/main/system_mysql_db_error_log.test @@ -0,0 +1,117 @@ +--source include/not_embedded.inc + +--echo # +--echo # MDEV-21704 Add a new JSON field "version_id" into mysql.global_priv.priv +--echo # + +SET @super_acl_100500= 1 << 15; +SELECT HEX(@super_acl_100500); + +SET @all_known_privileges_100500= (1 << 30) - 1; +SELECT HEX(@all_known_privileges_100500); + +CREATE USER user1@localhost; +GRANT ALL PRIVILEGES ON *.* TO user1@localhost WITH GRANT OPTION; +SET @all_known_privileges_current=(SELECT CAST(json_value(Priv, '$.access') AS UNSIGNED) FROM mysql.global_priv WHERE host='localhost' and user='user1'); +DROP USER user1@localhost; +SELECT HEX(@all_known_privileges_current); + + +CREATE USER bad_access1@localhost; +UPDATE + mysql.global_priv +SET + Priv=json_set(Priv, '$.access',@all_known_privileges_current+1) +WHERE + host='localhost' and user='bad_access1'; +FLUSH PRIVILEGES; +SHOW GRANTS FOR bad_access1@localhost; +DROP USER bad_access1@localhost; + + +CREATE USER bad_version_id_1000000@localhost; +GRANT ALL PRIVILEGES ON *.* to bad_version_id_1000000@localhost; +SHOW GRANTS FOR bad_version_id_1000000@localhost; +UPDATE + mysql.global_priv +SET + Priv=json_set(Priv, '$.version_id',1000000) +WHERE + host='localhost' and user='bad_version_id_1000000'; +FLUSH PRIVILEGES; +SHOW GRANTS FOR bad_version_id_1000000@localhost; +DROP USER bad_version_id_1000000@localhost; + + +CREATE USER bad_version_id_minus_3@localhost; +GRANT ALL PRIVILEGES ON *.* to bad_version_id_minus_3@localhost; +SHOW GRANTS FOR bad_version_id_minus_3@localhost; +UPDATE + mysql.global_priv +SET + Priv=json_set(Priv, '$.version_id',-3) +WHERE + host='localhost' and user='bad_version_id_minus_3'; +FLUSH PRIVILEGES; +SHOW GRANTS FOR bad_version_id_minus_3@localhost; +DROP USER bad_version_id_minus_3@localhost; + +CREATE USER bad_version_id_100300@localhost; +GRANT ALL PRIVILEGES ON *.* to bad_version_id_100300@localhost; +SHOW GRANTS FOR bad_version_id_100300@localhost; +UPDATE + mysql.global_priv +SET + Priv=json_set(Priv, '$.version_id',100300) +WHERE + host='localhost' and user='bad_version_id_100300'; +FLUSH PRIVILEGES; +SHOW GRANTS FOR bad_version_id_100300@localhost; +DROP USER bad_version_id_100300@localhost; + + +CREATE USER good_version_id_100400@localhost; +GRANT ALL PRIVILEGES ON *.* to good_version_id_100400@localhost; +SHOW GRANTS FOR good_version_id_100400@localhost; +UPDATE + mysql.global_priv +SET + Priv=json_set(Priv, '$.version_id',100400, '$.access', @all_known_privileges_100500) +WHERE + host='localhost' and user='good_version_id_100400'; +FLUSH PRIVILEGES; +SHOW GRANTS FOR good_version_id_100400@localhost; +# Testing that it's missing only "REPLICATION MASTER ADMIN". +# Should report ALL PRIVILEGES after GRANT REPLICATION MASTER ADMIN: +GRANT REPLICATION MASTER ADMIN ON *.* TO good_version_id_100400@localhost; +SHOW GRANTS FOR good_version_id_100400@localhost; +DROP USER good_version_id_100400@localhost; + + +CREATE USER good_version_id_100500@localhost; +GRANT SUPER ON *.* to good_version_id_100500@localhost; +SHOW GRANTS FOR good_version_id_100500@localhost; +UPDATE + mysql.global_priv +SET + Priv=json_set(Priv, '$.version_id',100500) +WHERE + host='localhost' and user='good_version_id_100500'; +FLUSH PRIVILEGES; +SHOW GRANTS FOR good_version_id_100500@localhost; +DROP USER good_version_id_100500@localhost; + + +--let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/system_mysql_db_error_log.err + +--let SEARCH_PATTERN= Warning.*'user' entry 'bad_access1@localhost' has a wrong 'access' value.*version_id= +--source include/search_pattern_in_file.inc + +--let SEARCH_PATTERN= Warning.*'user' entry 'bad_version_id_1000000@localhost' has a wrong 'version_id' value 1000000 +--source include/search_pattern_in_file.inc + +--let SEARCH_PATTERN= Warning.*'user' entry 'bad_version_id_minus_3@localhost' has a wrong 'version_id' value -3 +--source include/search_pattern_in_file.inc + +--let SEARCH_PATTERN= Warning.*'user' entry 'bad_version_id_100300@localhost' has a wrong 'version_id' value 100300 +--source include/search_pattern_in_file.inc diff --git a/mysql-test/main/system_mysql_db_fix40123.result b/mysql-test/main/system_mysql_db_fix40123.result index f76a4b37e31..c1bf2f492f1 100644 --- a/mysql-test/main/system_mysql_db_fix40123.result +++ b/mysql-test/main/system_mysql_db_fix40123.result @@ -1,5 +1,5 @@ use test; -set storage_engine=myisam; +set default_storage_engine=myisam; CREATE TABLE db ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db,User), KEY User (User) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Database privileges'; Warnings: Warning 1280 Name 'Host' ignored for PRIMARY key. diff --git a/mysql-test/main/system_mysql_db_fix40123.test b/mysql-test/main/system_mysql_db_fix40123.test index 00747cd7ba0..2e7ebd151d2 100644 --- a/mysql-test/main/system_mysql_db_fix40123.test +++ b/mysql-test/main/system_mysql_db_fix40123.test @@ -24,7 +24,7 @@ use test; # create system tables as in mysql-4.1.23 # created by executing "./mysql_create_system_tables real ." -set storage_engine=myisam; +set default_storage_engine=myisam; CREATE TABLE db ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db,User), KEY User (User) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Database privileges'; INSERT INTO db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y'); INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y'); diff --git a/mysql-test/main/system_mysql_db_fix50030.result b/mysql-test/main/system_mysql_db_fix50030.result index a9ef62aa5d4..bb003eabffe 100644 --- a/mysql-test/main/system_mysql_db_fix50030.result +++ b/mysql-test/main/system_mysql_db_fix50030.result @@ -1,5 +1,5 @@ use test; -set storage_engine=myisam; +set default_storage_engine=myisam; CREATE TABLE db ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db,User), KEY User (User) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Database privileges'; Warnings: Warning 1280 Name 'Host' ignored for PRIMARY key. diff --git a/mysql-test/main/system_mysql_db_fix50030.test b/mysql-test/main/system_mysql_db_fix50030.test index 085286637b0..77f1a97b1aa 100644 --- a/mysql-test/main/system_mysql_db_fix50030.test +++ b/mysql-test/main/system_mysql_db_fix50030.test @@ -24,7 +24,7 @@ use test; # create system tables as in mysql-5.0.30 # created by executing "./mysql_create_system_tables real ." -set storage_engine=myisam; +set default_storage_engine=myisam; CREATE TABLE db ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db,User), KEY User (User) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Database privileges'; INSERT INTO db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N'); INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N'); diff --git a/mysql-test/main/table_elim.result b/mysql-test/main/table_elim.result index b49e7b11ed6..deff0623370 100644 --- a/mysql-test/main/table_elim.result +++ b/mysql-test/main/table_elim.result @@ -333,11 +333,11 @@ id select_type table type possible_keys key key_len ref rows Extra explain select t1.a from t1 left join t2 on t2.pk between 10 and 20; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 -1 SIMPLE t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index +1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 1 Using where; Using index explain select t1.a from t1 left join t2 on t2.pk between 0.5 and 1.5; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 -1 SIMPLE t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index +1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using where; Using index explain select t1.a from t1 left join t2 on t2.pk between 10 and 10; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 @@ -408,7 +408,7 @@ select t1.* from t1 left join t2 on t2.pk=3 or t2.pk= 4; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 -1 SIMPLE t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index +1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using where; Using index explain select t1.* from t1 left join t2 on t2.pk=3 or t2.pk= 3; @@ -419,7 +419,7 @@ select t1.* from t1 left join t2 on (t2.pk=3 and t2.b=3) or (t2.pk= 4 and t2.b=3); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 -1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 2 Using where +1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using where drop table t1, t2; # # LPBUG#523593: Running RQG optimizer_no_subquery crashes MariaDB diff --git a/mysql-test/main/table_value_constr.result b/mysql-test/main/table_value_constr.result index 7cbec119a81..8b5df420269 100644 --- a/mysql-test/main/table_value_constr.result +++ b/mysql-test/main/table_value_constr.result @@ -2062,9 +2062,9 @@ values (1,2),(3,4,5); ERROR HY000: The used table value constructor has a different number of values # illegal parameter data types in TVC values (1,point(1,1)),(1,1); -ERROR HY000: Illegal parameter data types geometry and int for operation 'TABLE VALUE CONSTRUCTOR' +ERROR HY000: Illegal parameter data types point and int for operation 'TABLE VALUE CONSTRUCTOR' values (1,point(1,1)+1); -ERROR HY000: Illegal parameter data types geometry and int for operation '+' +ERROR HY000: Illegal parameter data types point and int for operation '+' # field reference in TVC select * from (values (1), (b), (2)) as new_tvc; ERROR HY000: Field reference 'b' can't be used in table value constructor @@ -2593,7 +2593,7 @@ ERROR 42S22: Unknown column '2' in 'order clause' create view v1 as with t(a) as (values (2), (1)) select a from t; show create view v1; View Create View character_set_client collation_connection -v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS with t(a) as (values (2),(1))select `t`.`a` AS `a` from `t` latin1 latin1_swedish_ci +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS with t(`a`) as (values (2),(1))select `t`.`a` AS `a` from `t` latin1 latin1_swedish_ci select * from v1; a 2 @@ -2837,9 +2837,8 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used 6 SUBQUERY <derived2> ALL NULL NULL NULL NULL 2 2 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used -3 SUBQUERY t3 ALL NULL NULL NULL NULL 11 -3 SUBQUERY <subquery4> eq_ref distinct_key distinct_key 8 func 1 Using where -4 MATERIALIZED <derived5> ALL NULL NULL NULL NULL 11 +3 SUBQUERY t3 ALL NULL NULL NULL NULL 11 Using where +3 SUBQUERY <derived5> ref key0 key0 8 test.t3.a 2 Using where; FirstMatch(t3) 5 DERIVED t3 ALL NULL NULL NULL NULL 11 Using temporary; Using filesort prepare stmt from "select (values ((select * from t3 where a in (select * from v1))))"; @@ -2864,8 +2863,7 @@ id select_type table type possible_keys key key_len ref rows Extra 6 SUBQUERY <derived2> ALL NULL NULL NULL NULL 2 2 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used 3 SUBQUERY t3 ALL NULL NULL NULL NULL 11 Using where -3 SUBQUERY <subquery4> eq_ref distinct_key distinct_key 8 func 1 Using where -4 MATERIALIZED <derived5> ALL NULL NULL NULL NULL 11 +3 SUBQUERY <derived5> ref key0 key0 8 test.t3.a 2 Using where; FirstMatch(t3) 5 DERIVED t3 ALL NULL NULL NULL NULL 11 Using temporary; Using filesort prepare stmt from "select (values ((select * from t3 diff --git a/mysql-test/main/table_value_constr.test b/mysql-test/main/table_value_constr.test index d131022e2e0..b3881a77d0e 100644 --- a/mysql-test/main/table_value_constr.test +++ b/mysql-test/main/table_value_constr.test @@ -1345,13 +1345,13 @@ DELIMITER ;$$ --echo # MDEV-21995 Server crashes in Item_field::real_type_handler with table value constructor --echo # ---error ER_UNKNOWN_ERROR +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT VALUES (IGNORE); ---error ER_UNKNOWN_ERROR +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT VALUES (DEFAULT); ---error ER_UNKNOWN_ERROR +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT EXECUTE IMMEDIATE 'VALUES (?)' USING IGNORE; ---error ER_UNKNOWN_ERROR +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT EXECUTE IMMEDIATE 'VALUES (?)' USING DEFAULT; --echo # @@ -1656,14 +1656,14 @@ drop table t1; --echo # MDEV-22610 Crash in INSERT INTO t1 (VALUES (DEFAULT) UNION VALUES (DEFAULT)) --echo # ---error ER_UNKNOWN_ERROR +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT VALUES (DEFAULT) UNION VALUES (DEFAULT); ---error ER_UNKNOWN_ERROR +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT VALUES (IGNORE) UNION VALUES (IGNORE); CREATE TABLE t1 (a INT DEFAULT 10); ---error ER_UNKNOWN_ERROR +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT INSERT INTO t1 (VALUES (DEFAULT) UNION VALUES (DEFAULT)); ---error ER_UNKNOWN_ERROR +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT INSERT INTO t1 (VALUES (IGNORE) UNION VALUES (IGNORE)); DROP TABLE t1; diff --git a/mysql-test/main/tc_heuristic_recover.test b/mysql-test/main/tc_heuristic_recover.test index 8cbf7d61143..86fea084de8 100644 --- a/mysql-test/main/tc_heuristic_recover.test +++ b/mysql-test/main/tc_heuristic_recover.test @@ -49,7 +49,7 @@ SELECT * FROM t1; # TODO: MDEV-12700 Allow innodb_read_only startup without prior slow shutdown. --source include/kill_mysqld.inc --error 1 ---exec $MYSQLD_LAST_CMD --log-bin=master-bin --binlog-format=mixed --core-file --loose-debug-sync-timeout=300 --innodb-force-recovery=4 +--exec $MYSQLD_LAST_CMD --log-bin=master-bin --binlog-format=mixed --core-file --loose-debug-sync-timeout=300 --debug_dbug="+d,innobase_xa_fail" --let SEARCH_PATTERN= was in the XA prepared state --source include/search_pattern_in_file.inc @@ -59,7 +59,7 @@ SELECT * FROM t1; --source include/search_pattern_in_file.inc --error 1 ---exec $MYSQLD_LAST_CMD --log-bin=master-bin --binlog-format=mixed --core-file --loose-debug-sync-timeout=300 --innodb-force-recovery=4 --tc-heuristic-recover=COMMIT +--exec $MYSQLD_LAST_CMD --log-bin=master-bin --binlog-format=mixed --core-file --loose-debug-sync-timeout=300 --debug_dbug="+d,innobase_xa_fail" --tc-heuristic-recover=COMMIT --let SEARCH_PATTERN= was in the XA prepared state --source include/search_pattern_in_file.inc --let SEARCH_PATTERN= Found 1 prepared transactions! diff --git a/mysql-test/main/temp_table.result b/mysql-test/main/temp_table.result index 293b6d5cd77..64a5d9b681b 100644 --- a/mysql-test/main/temp_table.result +++ b/mysql-test/main/temp_table.result @@ -1,5 +1,3 @@ -drop table if exists t1,t2; -drop view if exists v1; # # test basic creation of temporary tables together with normal table # @@ -602,3 +600,22 @@ DROP TEMPORARY TABLE t1; # # End of 10.2 tests # +create function f1() returns int +begin +drop temporary table t1, t2; +return 1; +end; +$$ +create temporary table t1 (a int); +create temporary table t2 (a int); +insert t1 values (2); +insert t2 values (3); +select a,f1() from t1; +ERROR HY000: Can't reopen table: 't1' +drop function f1; +drop temporary table t1; +drop temporary table t2; +ERROR 42S02: Unknown table 'test.t2' +# +# End of 10.5 tests +# diff --git a/mysql-test/main/temp_table.test b/mysql-test/main/temp_table.test index dc5fe7f3cd0..ccaa5fb93e8 100644 --- a/mysql-test/main/temp_table.test +++ b/mysql-test/main/temp_table.test @@ -6,11 +6,6 @@ # Test of temporary tables # ---disable_warnings -drop table if exists t1,t2; -drop view if exists v1; ---enable_warnings - --echo # --echo # test basic creation of temporary tables together with normal table --echo # @@ -658,3 +653,31 @@ DROP TEMPORARY TABLE t1; --echo # --echo # End of 10.2 tests --echo # + +# +# DROP TEMPORARY TABLE fails in the middle +# +delimiter $$; +create function f1() returns int +begin + drop temporary table t1, t2; + return 1; +end; +$$ +delimiter ;$$ + +create temporary table t1 (a int); +create temporary table t2 (a int); +insert t1 values (2); +insert t2 values (3); +--error ER_CANT_REOPEN_TABLE +select a,f1() from t1; +drop function f1; +drop temporary table t1; +--error ER_BAD_TABLE_ERROR +drop temporary table t2; + +--echo # +--echo # End of 10.5 tests +--echo # + diff --git a/mysql-test/main/temp_table_symlink.test b/mysql-test/main/temp_table_symlink.test index 9297b472805..ea5f1dfa4de 100644 --- a/mysql-test/main/temp_table_symlink.test +++ b/mysql-test/main/temp_table_symlink.test @@ -10,11 +10,12 @@ create temporary table t1 (a int); perl; chdir "$ENV{MYSQL_TMP_DIR}/mysqld.1/"; for (<#sql*.MYI>) { - /^#sql(.*)_([0-9a-f]+_)([0-9a-f]+)\.MYI$/ or die; - symlink "$ENV{datadir}/test/d1.MYI", sprintf "#sql$1_$2%x.MYI", hex($3)+1; - symlink "$ENV{datadir}/test/d1.MYI", sprintf "#sql$1_$2%x.MAI", hex($3)+1; - symlink "$ENV{datadir}/test/d1.MYI", sprintf "#sql$1_$2%x.MAI", hex($3)+2; - symlink "$ENV{datadir}/test/d1.MYI", "#sql_$1_0.MAI"; + /^(#sql-temptable-[0-9a-f]+)(-[0-9a-f]+-)([0-9a-f]+)\.MYI$/ or die $_; + symlink "$ENV{datadir}/test/d1.MYI", sprintf "$1$2%x.MYI", hex($3)+1; + symlink "$ENV{datadir}/test/d1.MYI", sprintf "$1$2%x.MAI", hex($3)+2; + symlink "$ENV{datadir}/test/d1.MYI", sprintf "$1$2%x.MAI", hex($3)+3; + symlink "$ENV{datadir}/test/d1.MYI", sprintf "$1$2%x.MAI", hex($3)+4; + symlink "$ENV{datadir}/test/d1.MYI", "$1-0.MAI"; } EOF diff --git a/mysql-test/main/thread_pool_info.opt b/mysql-test/main/thread_pool_info.opt new file mode 100644 index 00000000000..61bfc80d237 --- /dev/null +++ b/mysql-test/main/thread_pool_info.opt @@ -0,0 +1 @@ +--thread-handling=pool-of-threads --loose-thread-pool-mode=generic --loose-thread-pool-groups=ON --loose-thread-pool-queues=ON --thread-pool-stats=ON --thread-pool-waits=ON --thread-pool-size=1 --thread-pool-max-threads=2 --thread-pool-dedicated-listener diff --git a/mysql-test/main/thread_pool_info.result b/mysql-test/main/thread_pool_info.result new file mode 100644 index 00000000000..53fa1d1255d --- /dev/null +++ b/mysql-test/main/thread_pool_info.result @@ -0,0 +1,111 @@ +DESC INFORMATION_SCHEMA.THREAD_POOL_GROUPS; +Field Type Null Key Default Extra +GROUP_ID int(6) NO 0 +CONNECTIONS int(6) NO 0 +THREADS int(6) NO 0 +ACTIVE_THREADS int(6) NO 0 +STANDBY_THREADS int(6) NO 0 +QUEUE_LENGTH int(6) NO 0 +HAS_LISTENER tinyint(1) NO 0 +IS_STALLED tinyint(1) NO 0 +SELECT COUNT(*)=@@thread_pool_size FROM INFORMATION_SCHEMA.THREAD_POOL_GROUPS; +COUNT(*)=@@thread_pool_size +1 +SELECT SUM(CONNECTIONS) FROM INFORMATION_SCHEMA.THREAD_POOL_GROUPS; +SUM(CONNECTIONS) +1 +SELECT SUM(THREADS) > 0 FROM INFORMATION_SCHEMA.THREAD_POOL_GROUPS; +SUM(THREADS) > 0 +1 +SELECT SUM(ACTIVE_THREADS) > 0 FROM INFORMATION_SCHEMA.THREAD_POOL_GROUPS; +SUM(ACTIVE_THREADS) > 0 +1 +SELECT SUM(QUEUE_LENGTH) FROM INFORMATION_SCHEMA.THREAD_POOL_GROUPS; +SUM(QUEUE_LENGTH) +0 +SELECT SUM(IS_STALLED) FROM INFORMATION_SCHEMA.THREAD_POOL_GROUPS; +SUM(IS_STALLED) +0 +DESC INFORMATION_SCHEMA.THREAD_POOL_STATS; +Field Type Null Key Default Extra +GROUP_ID int(6) NO 0 +THREAD_CREATIONS bigint(19) NO 0 +THREAD_CREATIONS_DUE_TO_STALL bigint(19) NO 0 +WAKES bigint(19) NO 0 +WAKES_DUE_TO_STALL bigint(19) NO 0 +THROTTLES bigint(19) NO 0 +STALLS bigint(19) NO 0 +POLLS_BY_LISTENER bigint(19) NO 0 +POLLS_BY_WORKER bigint(19) NO 0 +DEQUEUES_BY_LISTENER bigint(19) NO 0 +DEQUEUES_BY_WORKER bigint(19) NO 0 +SELECT SUM(DEQUEUES_BY_LISTENER+DEQUEUES_BY_WORKER) > 0 FROM INFORMATION_SCHEMA.THREAD_POOL_STATS; +SUM(DEQUEUES_BY_LISTENER+DEQUEUES_BY_WORKER) > 0 +1 +SELECT SUM(POLLS_BY_LISTENER+POLLS_BY_WORKER) > 0 FROM INFORMATION_SCHEMA.THREAD_POOL_STATS; +SUM(POLLS_BY_LISTENER+POLLS_BY_WORKER) > 0 +1 +FLUSH THREAD_POOL_STATS; +SELECT SUM(DEQUEUES_BY_LISTENER+DEQUEUES_BY_WORKER) FROM INFORMATION_SCHEMA.THREAD_POOL_STATS; +SUM(DEQUEUES_BY_LISTENER+DEQUEUES_BY_WORKER) +1 +SELECT SUM(POLLS_BY_LISTENER) FROM INFORMATION_SCHEMA.THREAD_POOL_STATS; +SUM(POLLS_BY_LISTENER) +2 +SELECT SUM(POLLS_BY_WORKER) FROM INFORMATION_SCHEMA.THREAD_POOL_STATS; +SUM(POLLS_BY_WORKER) +0 +DESC INFORMATION_SCHEMA.THREAD_POOL_WAITS; +Field Type Null Key Default Extra +REASON varchar(16) NO +COUNT bigint(19) NO 0 +SELECT REASON FROM INFORMATION_SCHEMA.THREAD_POOL_WAITS; +REASON +UNKNOWN +SLEEP +DISKIO +ROW_LOCK +GLOBAL_LOCK +META_DATA_LOCK +TABLE_LOCK +USER_LOCK +BINLOG +GROUP_COMMIT +SYNC +NET +SELECT COUNT FROM INFORMATION_SCHEMA.THREAD_POOL_WAITS WHERE REASON='Sleep'; +COUNT +0 +SELECT SLEEP(0.01); +SLEEP(0.01) +0 +SELECT COUNT FROM INFORMATION_SCHEMA.THREAD_POOL_WAITS WHERE REASON='Sleep'; +COUNT +1 +FLUSH THREAD_POOL_WAITS; +DESC INFORMATION_SCHEMA.THREAD_POOL_QUEUES; +Field Type Null Key Default Extra +GROUP_ID int(6) NO 0 +POSITION int(6) NO 0 +PRIORITY int(1) NO 0 +CONNECTION_ID bigint(19) unsigned YES NULL +QUEUEING_TIME_MICROSECONDS bigint(19) NO 0 +# restart: with restart_parameters +connect con1, localhost, root,,test; +connection con1; +connect con2, localhost, root,,test; +connection con2; +connect extra_con,127.0.0.1,root,,test,$extra_port,; +connection con1; +SELECT SLEEP(1000); +connection extra_con; +connection con2; +DO 1; +connection extra_con; +KILL QUERY con1_id; +disconnect extra_con; +connection con1; +disconnect con1; +connection con2; +disconnect con2; +connection default; diff --git a/mysql-test/main/thread_pool_info.test b/mysql-test/main/thread_pool_info.test new file mode 100644 index 00000000000..cd906454d8c --- /dev/null +++ b/mysql-test/main/thread_pool_info.test @@ -0,0 +1,92 @@ +source include/not_embedded.inc; + +let $have_plugin = `SELECT COUNT(*) FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_STATUS='ACTIVE' AND PLUGIN_NAME = 'THREAD_POOL_GROUPS'`; +if(!$have_plugin) +{ + --skip Need thread_pool_groups plugin +} + +#I_S.THREAD_POOL_GROUPS +DESC INFORMATION_SCHEMA.THREAD_POOL_GROUPS; +SELECT COUNT(*)=@@thread_pool_size FROM INFORMATION_SCHEMA.THREAD_POOL_GROUPS; +SELECT SUM(CONNECTIONS) FROM INFORMATION_SCHEMA.THREAD_POOL_GROUPS; +SELECT SUM(THREADS) > 0 FROM INFORMATION_SCHEMA.THREAD_POOL_GROUPS; +SELECT SUM(ACTIVE_THREADS) > 0 FROM INFORMATION_SCHEMA.THREAD_POOL_GROUPS; +SELECT SUM(QUEUE_LENGTH) FROM INFORMATION_SCHEMA.THREAD_POOL_GROUPS; +SELECT SUM(IS_STALLED) FROM INFORMATION_SCHEMA.THREAD_POOL_GROUPS; + + +# I_S.THREAD_POOL_STATS +DESC INFORMATION_SCHEMA.THREAD_POOL_STATS; +# The following query does not reliably give results, after FLUSH +# so if the test runs with --repeat, it would fail +#SELECT SUM(THREAD_CREATIONS) > 0 FROM INFORMATION_SCHEMA.THREAD_POOL_STATS; +SELECT SUM(DEQUEUES_BY_LISTENER+DEQUEUES_BY_WORKER) > 0 FROM INFORMATION_SCHEMA.THREAD_POOL_STATS; +SELECT SUM(POLLS_BY_LISTENER+POLLS_BY_WORKER) > 0 FROM INFORMATION_SCHEMA.THREAD_POOL_STATS; +--disable_ps_protocol +FLUSH THREAD_POOL_STATS; +SELECT SUM(DEQUEUES_BY_LISTENER+DEQUEUES_BY_WORKER) FROM INFORMATION_SCHEMA.THREAD_POOL_STATS; +SELECT SUM(POLLS_BY_LISTENER) FROM INFORMATION_SCHEMA.THREAD_POOL_STATS; +SELECT SUM(POLLS_BY_WORKER) FROM INFORMATION_SCHEMA.THREAD_POOL_STATS; +--enable_ps_protocol + +#I_S.THREAD_POOL_WAITS +DESC INFORMATION_SCHEMA.THREAD_POOL_WAITS; +SELECT REASON FROM INFORMATION_SCHEMA.THREAD_POOL_WAITS; +SELECT COUNT FROM INFORMATION_SCHEMA.THREAD_POOL_WAITS WHERE REASON='Sleep'; +SELECT SLEEP(0.01); +SELECT COUNT FROM INFORMATION_SCHEMA.THREAD_POOL_WAITS WHERE REASON='Sleep'; +FLUSH THREAD_POOL_WAITS; + + +# I_S.THREAD_POOL_QUEUES +DESC INFORMATION_SCHEMA.THREAD_POOL_QUEUES; +let $extra_port=`select @@port+1`; + +let $restart_parameters=--extra-port=$extra_port; +let $restart_noprint=1; +source include/restart_mysqld.inc; + +connect (con1, localhost, root,,test); +connection con1; +let $con1_id=`SELECT CONNECTION_ID()`; + +connect (con2, localhost, root,,test); +connection con2; +let $con2_id=`SELECT CONNECTION_ID()`; + +connect(extra_con,127.0.0.1,root,,test,$extra_port,); + +connection con1; +send SELECT SLEEP(1000); + +connection extra_con; +let $wait_condition= + SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.PROCESSLIST + WHERE STATE='User sleep' AND ID=$con1_id; +--source include/wait_condition.inc + +connection con2; +send DO 1; + + +connection extra_con; +let $wait_condition= + SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.THREAD_POOL_QUEUES + WHERE CONNECTION_ID IS NOT NULL; +--source include/wait_condition.inc + +--replace_result $con1_id con1_id +eval KILL QUERY $con1_id; +disconnect extra_con; + +connection con1; +error 0,ER_QUERY_INTERRUPTED; +reap; +disconnect con1; + +connection con2; +reap; +disconnect con2; + +connection default; diff --git a/mysql-test/main/trigger-trans.result b/mysql-test/main/trigger-trans.result index c58c4230a40..2113377b1ab 100644 --- a/mysql-test/main/trigger-trans.result +++ b/mysql-test/main/trigger-trans.result @@ -229,3 +229,17 @@ INSERT INTO t2 (id) VALUES (1); disconnect con2; connection default; DROP TABLE t3, t2, t1; +# +# MDEV-25738 Assertion `ticket->m_duration == MDL_EXPLICIT' failed in +# void MDL_context::release_lock(MDL_ticket*) +# +CREATE TABLE t1 (id int(11)) ENGINE=InnoDB; +LOCK TABLES t1 WRITE; +SET max_statement_time= 0.001; +CREATE TRIGGER tr16 AFTER UPDATE ON t1 FOR EACH ROW INSERT INTO t1 VALUES (1); +SET max_statement_time= default; +DROP TRIGGER IF EXISTS trg16; +DROP TABLE t1; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/trigger-trans.test b/mysql-test/main/trigger-trans.test index 17656c3516e..5d7d1f8afef 100644 --- a/mysql-test/main/trigger-trans.test +++ b/mysql-test/main/trigger-trans.test @@ -233,3 +233,25 @@ DROP TABLE t3, t2, t1; # Wait till we reached the initial number of concurrent sessions --source include/wait_until_count_sessions.inc + +--echo # +--echo # MDEV-25738 Assertion `ticket->m_duration == MDL_EXPLICIT' failed in +--echo # void MDL_context::release_lock(MDL_ticket*) +--echo # + +CREATE TABLE t1 (id int(11)) ENGINE=InnoDB; +LOCK TABLES t1 WRITE; +SET max_statement_time= 0.001; +--error 0,1969,2013 +--disable_warnings +CREATE TRIGGER tr16 AFTER UPDATE ON t1 FOR EACH ROW INSERT INTO t1 VALUES (1); +--enable_warnings +SET max_statement_time= default; +--disable_warnings +DROP TRIGGER IF EXISTS trg16; +--enable_warnings +DROP TABLE t1; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/trigger.test b/mysql-test/main/trigger.test index 581015a45e6..543d516010d 100644 --- a/mysql-test/main/trigger.test +++ b/mysql-test/main/trigger.test @@ -2616,7 +2616,7 @@ DROP TABLE t1, t2; --echo # End of 5.3 tests. # -# MDEV-4829 BEFORE INSERT triggers dont issue 1406 error +# MDEV-4829 BEFORE INSERT triggers don't issue 1406 error # Also check timestamp for trigger # diff --git a/mysql-test/main/trigger_notembedded.result b/mysql-test/main/trigger_notembedded.result index 94e651b1340..e276ddd1e48 100644 --- a/mysql-test/main/trigger_notembedded.result +++ b/mysql-test/main/trigger_notembedded.result @@ -112,10 +112,10 @@ CREATE DEFINER='mysqltest_inv'@'localhost' TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW SET @new_sum = 0; -ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation +ERROR 42000: Access denied; you need (at least one of) the SUPER, SET USER privilege(s) for this operation connection default; use mysqltest_db1; -GRANT SUPER ON *.* TO mysqltest_dfn@localhost; +GRANT SET USER ON *.* TO mysqltest_dfn@localhost; disconnect wl2818_definer_con; connect wl2818_definer_con,localhost,mysqltest_dfn,,mysqltest_db1; connection wl2818_definer_con; diff --git a/mysql-test/main/trigger_notembedded.test b/mysql-test/main/trigger_notembedded.test index 9f89e66bbfe..313faea982c 100644 --- a/mysql-test/main/trigger_notembedded.test +++ b/mysql-test/main/trigger_notembedded.test @@ -255,7 +255,7 @@ CREATE DEFINER='mysqltest_inv'@'localhost' use mysqltest_db1; -GRANT SUPER ON *.* TO mysqltest_dfn@localhost; +GRANT SET USER ON *.* TO mysqltest_dfn@localhost; --disconnect wl2818_definer_con --connect (wl2818_definer_con,localhost,mysqltest_dfn,,mysqltest_db1) diff --git a/mysql-test/main/type_binary.result b/mysql-test/main/type_binary.result index 7dfe44ab045..76dab6e4e93 100644 --- a/mysql-test/main/type_binary.result +++ b/mysql-test/main/type_binary.result @@ -180,3 +180,43 @@ DROP TABLE t1; # # End of 10.0 tests # +# +# Start of 10.5 tests +# +# +# MDEV-20818 ER_CRASHED_ON_USAGE or Assertion `length <= column->length' failed in write_block_record on temporary table +# +CREATE TABLE t1 (a VARCHAR(39)); +SELECT +CAST(a AS BINARY(0)), +CAST(a AS BINARY(1)), +CAST(a AS BINARY(16)), +CAST(a AS BINARY(255)), +CAST(a AS BINARY(256)), +CAST(a AS BINARY(512)), +CAST(a AS BINARY(513)), +CAST(a AS BINARY(65532)), +CAST(a AS BINARY(65533)), +CAST(a AS BINARY(65534)), +CAST(a AS BINARY(65535)), +CAST(a AS BINARY(65536)), +CAST(a AS BINARY(16777215)), +CAST(a AS BINARY(16777216)) +FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def CAST(a AS BINARY(0)) 253 0 0 Y 128 0 63 +def CAST(a AS BINARY(1)) 253 1 0 Y 128 0 63 +def CAST(a AS BINARY(16)) 253 16 0 Y 128 0 63 +def CAST(a AS BINARY(255)) 253 255 0 Y 128 0 63 +def CAST(a AS BINARY(256)) 253 256 0 Y 128 0 63 +def CAST(a AS BINARY(512)) 253 512 0 Y 128 0 63 +def CAST(a AS BINARY(513)) 253 513 0 Y 128 0 63 +def CAST(a AS BINARY(65532)) 252 65532 0 Y 128 0 63 +def CAST(a AS BINARY(65533)) 252 65533 0 Y 128 0 63 +def CAST(a AS BINARY(65534)) 252 65534 0 Y 128 0 63 +def CAST(a AS BINARY(65535)) 252 65535 0 Y 128 0 63 +def CAST(a AS BINARY(65536)) 250 65536 0 Y 128 0 63 +def CAST(a AS BINARY(16777215)) 250 16777215 0 Y 128 0 63 +def CAST(a AS BINARY(16777216)) 251 16777216 0 Y 128 0 63 +CAST(a AS BINARY(0)) CAST(a AS BINARY(1)) CAST(a AS BINARY(16)) CAST(a AS BINARY(255)) CAST(a AS BINARY(256)) CAST(a AS BINARY(512)) CAST(a AS BINARY(513)) CAST(a AS BINARY(65532)) CAST(a AS BINARY(65533)) CAST(a AS BINARY(65534)) CAST(a AS BINARY(65535)) CAST(a AS BINARY(65536)) CAST(a AS BINARY(16777215)) CAST(a AS BINARY(16777216)) +DROP TABLE t1; diff --git a/mysql-test/main/type_binary.test b/mysql-test/main/type_binary.test index 952bc6ef231..9f7a0db66d5 100644 --- a/mysql-test/main/type_binary.test +++ b/mysql-test/main/type_binary.test @@ -126,3 +126,31 @@ DROP TABLE t1; --echo # End of 10.0 tests --echo # +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-20818 ER_CRASHED_ON_USAGE or Assertion `length <= column->length' failed in write_block_record on temporary table +--echo # + +CREATE TABLE t1 (a VARCHAR(39)); +--enable_metadata +SELECT + CAST(a AS BINARY(0)), + CAST(a AS BINARY(1)), + CAST(a AS BINARY(16)), + CAST(a AS BINARY(255)), + CAST(a AS BINARY(256)), + CAST(a AS BINARY(512)), + CAST(a AS BINARY(513)), + CAST(a AS BINARY(65532)), + CAST(a AS BINARY(65533)), + CAST(a AS BINARY(65534)), + CAST(a AS BINARY(65535)), + CAST(a AS BINARY(65536)), + CAST(a AS BINARY(16777215)), + CAST(a AS BINARY(16777216)) +FROM t1; +--disable_metadata +DROP TABLE t1; diff --git a/mysql-test/main/type_bit.result b/mysql-test/main/type_bit.result index 4e9d698b0c2..f44bdf70c4a 100644 --- a/mysql-test/main/type_bit.result +++ b/mysql-test/main/type_bit.result @@ -766,7 +766,7 @@ CREATE TABLE t1 (a BIT(7), b BIT(9), KEY(a, b)); INSERT INTO t1 VALUES(0, 0), (5, 3), (5, 6), (6, 4), (7, 0); EXPLAIN SELECT a+0, b+0 FROM t1 WHERE a > 4 and b < 7 ORDER BY 2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index a a 5 NULL 5 Using where; Using index; Using filesort +1 SIMPLE t1 range a a 2 NULL 4 Using where; Using index; Using filesort DROP TABLE t1; End of 5.0 tests create table t1(a bit(7)); @@ -1861,3 +1861,26 @@ ct 18446744073709551615 # # End of 10.4 tests # +# +# Start of 10.5 tests +# +# +# MDEV-20496 Assertion `field.is_sane()' failed in Protocol_text::store_field_metadata +# +CREATE TABLE t1 (b BIT(1)); +SELECT MIN(CASE WHEN 0 THEN b END) FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def MIN(CASE WHEN 0 THEN b END) 8 1 0 Y 32928 0 63 +MIN(CASE WHEN 0 THEN b END) +NULL +CREATE TABLE t2 AS SELECT MIN(CASE WHEN 0 THEN b END) FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `MIN(CASE WHEN 0 THEN b END)` bigint(1) unsigned DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t2; +DROP TABLE t1; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/type_bit.test b/mysql-test/main/type_bit.test index 2353fc535ad..2e66c7fb7cd 100644 --- a/mysql-test/main/type_bit.test +++ b/mysql-test/main/type_bit.test @@ -540,3 +540,26 @@ DELIMITER ;$$ --echo # --echo # End of 10.4 tests --echo # + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-20496 Assertion `field.is_sane()' failed in Protocol_text::store_field_metadata +--echo # + +CREATE TABLE t1 (b BIT(1)); +--disable_ps_protocol +--enable_metadata +SELECT MIN(CASE WHEN 0 THEN b END) FROM t1; +--disable_metadata +--enable_ps_protocol +CREATE TABLE t2 AS SELECT MIN(CASE WHEN 0 THEN b END) FROM t1; +SHOW CREATE TABLE t2; +DROP TABLE t2; +DROP TABLE t1; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/type_blob.result b/mysql-test/main/type_blob.result index a0a5f82a656..28f5d8fb868 100644 --- a/mysql-test/main/type_blob.result +++ b/mysql-test/main/type_blob.result @@ -245,7 +245,7 @@ HELLO HELLO MY a hello -set big_tables=1; +set tmp_memory_table_size=0; select distinct t from t1; t NULL @@ -326,7 +326,7 @@ HELLO HELLO MY a hello -set big_tables=0; +set tmp_memory_table_size=default; select distinct * from t1; t c b d NULL NULL NULL NULL @@ -625,7 +625,7 @@ id txt 3 NULL explain select * from t1 where txt='Chevy' or txt is NULL; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL txt_index NULL NULL NULL 6 Using where +1 SIMPLE t1 ref_or_null txt_index txt_index 23 const 3 Using where explain select * from t1 FORCE INDEX (`txt_index`) where txt='Chevy' or txt is NULL; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref_or_null txt_index txt_index 23 const 3 Using where diff --git a/mysql-test/main/type_blob.test b/mysql-test/main/type_blob.test index a9b044b5318..38c8b9a83ca 100644 --- a/mysql-test/main/type_blob.test +++ b/mysql-test/main/type_blob.test @@ -113,7 +113,7 @@ select distinct t from t1 order by t; select distinct b from t1 order by b; select t from t1 group by t; select b from t1 group by b; -set big_tables=1; +set tmp_memory_table_size=0; # force on-disk tmp table select distinct t from t1; select distinct b from t1; select distinct t from t1 order by t; @@ -124,7 +124,7 @@ select distinct c from t1 order by c; select distinct d from t1 order by d; select c from t1 group by c; select d from t1 group by d; -set big_tables=0; +set tmp_memory_table_size=default; select distinct * from t1; select t,count(*) from t1 group by t; select b,count(*) from t1 group by b; diff --git a/mysql-test/main/type_date.result b/mysql-test/main/type_date.result index 1724b7ae605..926ed1a8393 100644 --- a/mysql-test/main/type_date.result +++ b/mysql-test/main/type_date.result @@ -933,7 +933,7 @@ CREATE TABLE t1 (f DATE, KEY(f)); INSERT INTO t1 VALUES ('2020-01-01'),('2020-01-02'); EXPLAIN EXTENDED SELECT * FROM t1 WHERE 1995.0000000 BETWEEN f AND '2012-12-12'; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 index f f 4 NULL 2 50.00 Using where; Using index +1 SIMPLE t1 range f f 4 NULL 1 100.00 Using where; Using index Warnings: Warning 1292 Truncated incorrect datetime value: '1995.0000000' Note 1003 select `test`.`t1`.`f` AS `f` from `test`.`t1` where '0000-00-00' between `test`.`t1`.`f` and <cache>('2012-12-12') diff --git a/mysql-test/main/type_datetime.result b/mysql-test/main/type_datetime.result index bb3e86b6543..3c1baf82167 100644 --- a/mysql-test/main/type_datetime.result +++ b/mysql-test/main/type_datetime.result @@ -1340,7 +1340,7 @@ CREATE TABLE t1 (f DATETIME, KEY(f)); INSERT INTO t1 VALUES ('2020-01-01 00:00:00'),('2020-01-02 00:00:00'); EXPLAIN EXTENDED SELECT * FROM t1 WHERE 1995.0000000 BETWEEN f AND '2012-12-12'; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 index f f 6 NULL 2 50.00 Using where; Using index +1 SIMPLE t1 range f f 6 NULL 1 100.00 Using where; Using index Warnings: Warning 1292 Truncated incorrect datetime value: '1995.0000000' Note 1003 select `test`.`t1`.`f` AS `f` from `test`.`t1` where '0000-00-00 00:00:00.000000' between `test`.`t1`.`f` and <cache>('2012-12-12') diff --git a/mysql-test/main/type_enum.result b/mysql-test/main/type_enum.result index c8277ab832f..d8b558c7ce0 100644 --- a/mysql-test/main/type_enum.result +++ b/mysql-test/main/type_enum.result @@ -1932,16 +1932,14 @@ ALTER TABLE t2 ADD PRIMARY KEY(c1); SELECT t1.* FROM t1 JOIN t2 ON t1.c1 COLLATE latin1_swedish_ci=t2.c1; c1 a -a SELECT t1.* FROM t1 LEFT JOIN t2 ON t1.c1 COLLATE latin1_swedish_ci=t2.c1; c1 a -a # t2 should NOT be eliminated EXPLAIN SELECT t1.* FROM t1 LEFT JOIN t2 ON t1.c1 COLLATE latin1_swedish_ci=t2.c1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 system NULL NULL NULL NULL 1 -1 SIMPLE t2 index PRIMARY PRIMARY 1 NULL 2 Using where; Using index +1 SIMPLE t2 range PRIMARY PRIMARY 1 NULL 1 Using where; Using index DROP TABLE IF EXISTS t1,t2; CREATE TABLE t1 (c1 SET('a') CHARACTER SET latin1 PRIMARY KEY); INSERT INTO t1 VALUES ('a'); @@ -1959,16 +1957,14 @@ ALTER TABLE t2 ADD PRIMARY KEY(c1); SELECT t1.* FROM t1 JOIN t2 ON t1.c1 COLLATE latin1_swedish_ci=t2.c1; c1 a -a SELECT t1.* FROM t1 LEFT JOIN t2 ON t1.c1 COLLATE latin1_swedish_ci=t2.c1; c1 a -a # t2 should NOT be eliminated EXPLAIN SELECT t1.* FROM t1 LEFT JOIN t2 ON t1.c1 COLLATE latin1_swedish_ci=t2.c1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 system NULL NULL NULL NULL 1 -1 SIMPLE t2 index PRIMARY PRIMARY 1 NULL 2 Using where; Using index +1 SIMPLE t2 range PRIMARY PRIMARY 1 NULL 1 Using where; Using index DROP TABLE IF EXISTS t1,t2; CREATE TABLE t1 (c1 VARCHAR(10) CHARACTER SET latin1 PRIMARY KEY); INSERT INTO t1 VALUES ('a'); @@ -1986,16 +1982,14 @@ ALTER TABLE t2 ADD PRIMARY KEY(c1); SELECT t1.* FROM t1 JOIN t2 ON t1.c1 COLLATE latin1_swedish_ci=t2.c1; c1 a -a SELECT t1.* FROM t1 LEFT JOIN t2 ON t1.c1 COLLATE latin1_swedish_ci=t2.c1; c1 a -a # t2 should NOT be eliminated EXPLAIN SELECT t1.* FROM t1 LEFT JOIN t2 ON t1.c1 COLLATE latin1_swedish_ci=t2.c1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 system NULL NULL NULL NULL 1 -1 SIMPLE t2 index PRIMARY PRIMARY 1 NULL 2 Using where; Using index +1 SIMPLE t2 range PRIMARY PRIMARY 1 NULL 1 Using where; Using index DROP TABLE IF EXISTS t1,t2; # # MDEV-6991 GROUP_MIN_MAX optimization is erroneously applied in some cases diff --git a/mysql-test/main/type_int.result b/mysql-test/main/type_int.result index 08abf2db916..c9763a1453e 100644 --- a/mysql-test/main/type_int.result +++ b/mysql-test/main/type_int.result @@ -1493,3 +1493,18 @@ DROP TABLE t1; # # End of 10.4 tests # +# +# Start of 10.5 tests +# +# +# MDEV-20363 Assertion `is_unsigned() == attr.unsigned_flag' failed in Type_handler_longlong::make_table_field +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +SELECT DISTINCT 1 FROM t1 GROUP BY 0 >> NULL WITH ROLLUP; +1 +1 +DROP TABLE t1; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/type_int.test b/mysql-test/main/type_int.test index 0505020374d..c2edb0a9756 100644 --- a/mysql-test/main/type_int.test +++ b/mysql-test/main/type_int.test @@ -438,3 +438,21 @@ DROP TABLE t1; --echo # --echo # End of 10.4 tests --echo # + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-20363 Assertion `is_unsigned() == attr.unsigned_flag' failed in Type_handler_longlong::make_table_field +--echo # + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +SELECT DISTINCT 1 FROM t1 GROUP BY 0 >> NULL WITH ROLLUP; +DROP TABLE t1; + + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/type_json.result b/mysql-test/main/type_json.result index 96e96cca404..dfe4699b361 100644 --- a/mysql-test/main/type_json.result +++ b/mysql-test/main/type_json.result @@ -98,3 +98,33 @@ select cast('{a:1}' as text); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'text)' at line 1 select cast('{a:1}' as json); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'json)' at line 1 +# +# Start of 10.5 tests +# +# +# MDEV-17832 Protocol: extensions for Pluggable types and JSON, GEOMETRY +# +SET NAMES utf8; +CREATE TABLE t1 ( +js0 JSON, +js1 TEXT CHECK (JSON_VALID(js1)), +js2 TEXT CHECK (LENGTH(js2) > 0 AND JSON_VALID(js2)), +js3 TEXT CHECK (LENGTH(js2) > 0 OR JSON_VALID(js2)) +) CHARACTER SET utf8; +SELECT * FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 t1 js0 js0 252 (format=json) 4294967295 0 Y 144 0 33 +def test t1 t1 js1 js1 252 (format=json) 196605 0 Y 16 0 33 +def test t1 t1 js2 js2 252 (format=json) 196605 0 Y 16 0 33 +def test t1 t1 js3 js3 252 196605 0 Y 16 0 33 +js0 js1 js2 js3 +SELECT js0, JSON_COMPACT(js0), JSON_COMPACT('{}') FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 t1 js0 js0 252 (format=json) 4294967295 0 Y 144 0 33 +def JSON_COMPACT(js0) 251 (format=json) 4294967295 0 Y 128 0 33 +def JSON_COMPACT('{}') 253 (format=json) 6 0 Y 0 0 33 +js0 JSON_COMPACT(js0) JSON_COMPACT('{}') +DROP TABLE t1; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/type_json.test b/mysql-test/main/type_json.test index bd13dc1fcf4..7ab0af20e03 100644 --- a/mysql-test/main/type_json.test +++ b/mysql-test/main/type_json.test @@ -64,3 +64,30 @@ drop table t1; select cast('{a:1}' as text); --error ER_PARSE_ERROR select cast('{a:1}' as json); + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-17832 Protocol: extensions for Pluggable types and JSON, GEOMETRY +--echo # + +SET NAMES utf8; +CREATE TABLE t1 ( + js0 JSON, + js1 TEXT CHECK (JSON_VALID(js1)), + js2 TEXT CHECK (LENGTH(js2) > 0 AND JSON_VALID(js2)), + js3 TEXT CHECK (LENGTH(js2) > 0 OR JSON_VALID(js2)) +) CHARACTER SET utf8; +--disable_ps_protocol +--enable_metadata +SELECT * FROM t1; +SELECT js0, JSON_COMPACT(js0), JSON_COMPACT('{}') FROM t1; +--disable_metadata +--enable_ps_protocol +DROP TABLE t1; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/type_row.result b/mysql-test/main/type_row.result new file mode 100644 index 00000000000..dc74cfc88a4 --- /dev/null +++ b/mysql-test/main/type_row.result @@ -0,0 +1,51 @@ +# +# Start of 10.5 tests +# +# +# MDEV-20175 Move Type_handler_row from Type_collection_std to Type_collection_row +# +SELECT LEAST(ROW(1,1), ROW(1,1)); +ERROR HY000: Illegal parameter data types row and row for operation 'least' +SELECT GREATEST(ROW(1,1), ROW(1,1)); +ERROR HY000: Illegal parameter data types row and row for operation 'greatest' +SELECT LEAST(ROW(1,1), 1); +ERROR HY000: Illegal parameter data types row and int for operation 'least' +SELECT GREATEST(ROW(1,1), 1); +ERROR HY000: Illegal parameter data types row and int for operation 'greatest' +SELECT LEAST(1, ROW(1,1)); +ERROR HY000: Illegal parameter data types int and row for operation 'least' +SELECT GREATEST(1, ROW(1,1)); +ERROR HY000: Illegal parameter data types int and row for operation 'greatest' +SELECT ROW(1,1) + ROW(1,1); +ERROR HY000: Illegal parameter data types row and row for operation '+' +SELECT 1 + ROW(1,1); +ERROR HY000: Illegal parameter data types int and row for operation '+' +SELECT ROW(1,1) + 1; +ERROR HY000: Illegal parameter data types row and int for operation '+' +SELECT ROW(1,1) - ROW(1,1); +ERROR HY000: Illegal parameter data types row and row for operation '-' +SELECT 1 - ROW(1,1); +ERROR HY000: Illegal parameter data types int and row for operation '-' +SELECT ROW(1,1) - 1; +ERROR HY000: Illegal parameter data types row and int for operation '-' +SELECT ROW(1,1) * ROW(1,1); +ERROR HY000: Illegal parameter data types row and row for operation '*' +SELECT 1 * ROW(1,1); +ERROR HY000: Illegal parameter data types int and row for operation '*' +SELECT ROW(1,1) * 1; +ERROR HY000: Illegal parameter data types row and int for operation '*' +SELECT ROW(1,1) / ROW(1,1); +ERROR HY000: Illegal parameter data types row and row for operation '/' +SELECT 1 / ROW(1,1); +ERROR HY000: Illegal parameter data types int and row for operation '/' +SELECT ROW(1,1) / 1; +ERROR HY000: Illegal parameter data types row and int for operation '/' +SELECT ROW(1,1) % ROW(1,1); +ERROR HY000: Illegal parameter data types row and row for operation 'MOD' +SELECT 1 % ROW(1,1); +ERROR HY000: Illegal parameter data types int and row for operation 'MOD' +SELECT ROW(1,1) % 1; +ERROR HY000: Illegal parameter data types row and int for operation 'MOD' +# +# End of 10.5 tests +# diff --git a/mysql-test/main/type_row.test b/mysql-test/main/type_row.test new file mode 100644 index 00000000000..2a5902351e2 --- /dev/null +++ b/mysql-test/main/type_row.test @@ -0,0 +1,62 @@ +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-20175 Move Type_handler_row from Type_collection_std to Type_collection_row +--echo # + +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT LEAST(ROW(1,1), ROW(1,1)); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT GREATEST(ROW(1,1), ROW(1,1)); + +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT LEAST(ROW(1,1), 1); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT GREATEST(ROW(1,1), 1); + +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT LEAST(1, ROW(1,1)); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT GREATEST(1, ROW(1,1)); + + +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT ROW(1,1) + ROW(1,1); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT 1 + ROW(1,1); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT ROW(1,1) + 1; + +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT ROW(1,1) - ROW(1,1); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT 1 - ROW(1,1); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT ROW(1,1) - 1; + +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT ROW(1,1) * ROW(1,1); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT 1 * ROW(1,1); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT ROW(1,1) * 1; + +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT ROW(1,1) / ROW(1,1); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT 1 / ROW(1,1); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT ROW(1,1) / 1; + +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT ROW(1,1) % ROW(1,1); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT 1 % ROW(1,1); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +SELECT ROW(1,1) % 1; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/type_temporal_mariadb53.result b/mysql-test/main/type_temporal_mariadb53.result new file mode 100644 index 00000000000..140c74ac836 --- /dev/null +++ b/mysql-test/main/type_temporal_mariadb53.result @@ -0,0 +1,237 @@ +# +# MDEV-19906 Port show_old_temporals from MySQL 5.6 +# +TRUNCATE TABLE mariadb5312_datetime; +SHOW CREATE TABLE mariadb5312_datetime; +Table Create Table +mariadb5312_datetime CREATE TABLE `mariadb5312_datetime` ( + `t0` datetime /* mariadb-5.3 */ DEFAULT NULL, + `t1` datetime(1) /* mariadb-5.3 */ DEFAULT NULL, + `t2` datetime(2) /* mariadb-5.3 */ DEFAULT NULL, + `t3` datetime(3) /* mariadb-5.3 */ DEFAULT NULL, + `t4` datetime(4) /* mariadb-5.3 */ DEFAULT NULL, + `t5` datetime(5) /* mariadb-5.3 */ DEFAULT NULL, + `t6` datetime(6) /* mariadb-5.3 */ DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT COLUMN_NAME, DATA_TYPE, COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='mariadb5312_datetime'; +COLUMN_NAME t0 +DATA_TYPE datetime +COLUMN_TYPE datetime /* mariadb-5.3 */ +COLUMN_NAME t1 +DATA_TYPE datetime +COLUMN_TYPE datetime(1) /* mariadb-5.3 */ +COLUMN_NAME t2 +DATA_TYPE datetime +COLUMN_TYPE datetime(2) /* mariadb-5.3 */ +COLUMN_NAME t3 +DATA_TYPE datetime +COLUMN_TYPE datetime(3) /* mariadb-5.3 */ +COLUMN_NAME t4 +DATA_TYPE datetime +COLUMN_TYPE datetime(4) /* mariadb-5.3 */ +COLUMN_NAME t5 +DATA_TYPE datetime +COLUMN_TYPE datetime(5) /* mariadb-5.3 */ +COLUMN_NAME t6 +DATA_TYPE datetime +COLUMN_TYPE datetime(6) /* mariadb-5.3 */ +DESCRIBE mariadb5312_datetime; +Field t0 +Type datetime /* mariadb-5.3 */ +Null YES +Key +Default NULL +Extra +Field t1 +Type datetime(1) /* mariadb-5.3 */ +Null YES +Key +Default NULL +Extra +Field t2 +Type datetime(2) /* mariadb-5.3 */ +Null YES +Key +Default NULL +Extra +Field t3 +Type datetime(3) /* mariadb-5.3 */ +Null YES +Key +Default NULL +Extra +Field t4 +Type datetime(4) /* mariadb-5.3 */ +Null YES +Key +Default NULL +Extra +Field t5 +Type datetime(5) /* mariadb-5.3 */ +Null YES +Key +Default NULL +Extra +Field t6 +Type datetime(6) /* mariadb-5.3 */ +Null YES +Key +Default NULL +Extra +DROP TABLE mariadb5312_datetime; +TRUNCATE TABLE mariadb5312_timestamp; +SHOW CREATE TABLE mariadb5312_timestamp; +Table Create Table +mariadb5312_timestamp CREATE TABLE `mariadb5312_timestamp` ( + `t0` timestamp /* mariadb-5.3 */ NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `t1` timestamp(1) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0', + `t2` timestamp(2) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00', + `t3` timestamp(3) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000', + `t4` timestamp(4) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0000', + `t5` timestamp(5) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00000', + `t6` timestamp(6) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000000' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT COLUMN_NAME, DATA_TYPE, COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='mariadb5312_timestamp'; +COLUMN_NAME t0 +DATA_TYPE timestamp +COLUMN_TYPE timestamp /* mariadb-5.3 */ +COLUMN_NAME t1 +DATA_TYPE timestamp +COLUMN_TYPE timestamp(1) /* mariadb-5.3 */ +COLUMN_NAME t2 +DATA_TYPE timestamp +COLUMN_TYPE timestamp(2) /* mariadb-5.3 */ +COLUMN_NAME t3 +DATA_TYPE timestamp +COLUMN_TYPE timestamp(3) /* mariadb-5.3 */ +COLUMN_NAME t4 +DATA_TYPE timestamp +COLUMN_TYPE timestamp(4) /* mariadb-5.3 */ +COLUMN_NAME t5 +DATA_TYPE timestamp +COLUMN_TYPE timestamp(5) /* mariadb-5.3 */ +COLUMN_NAME t6 +DATA_TYPE timestamp +COLUMN_TYPE timestamp(6) /* mariadb-5.3 */ +DESCRIBE mariadb5312_timestamp; +Field t0 +Type timestamp /* mariadb-5.3 */ +Null NO +Key +Default current_timestamp() +Extra on update current_timestamp() +Field t1 +Type timestamp(1) /* mariadb-5.3 */ +Null NO +Key +Default 0000-00-00 00:00:00.0 +Extra +Field t2 +Type timestamp(2) /* mariadb-5.3 */ +Null NO +Key +Default 0000-00-00 00:00:00.00 +Extra +Field t3 +Type timestamp(3) /* mariadb-5.3 */ +Null NO +Key +Default 0000-00-00 00:00:00.000 +Extra +Field t4 +Type timestamp(4) /* mariadb-5.3 */ +Null NO +Key +Default 0000-00-00 00:00:00.0000 +Extra +Field t5 +Type timestamp(5) /* mariadb-5.3 */ +Null NO +Key +Default 0000-00-00 00:00:00.00000 +Extra +Field t6 +Type timestamp(6) /* mariadb-5.3 */ +Null NO +Key +Default 0000-00-00 00:00:00.000000 +Extra +DROP TABLE mariadb5312_timestamp; +TRUNCATE TABLE mariadb5312_time; +SHOW CREATE TABLE mariadb5312_time; +Table Create Table +mariadb5312_time CREATE TABLE `mariadb5312_time` ( + `t0` time /* mariadb-5.3 */ DEFAULT NULL, + `t1` time(1) /* mariadb-5.3 */ DEFAULT NULL, + `t2` time(2) /* mariadb-5.3 */ DEFAULT NULL, + `t3` time(3) /* mariadb-5.3 */ DEFAULT NULL, + `t4` time(4) /* mariadb-5.3 */ DEFAULT NULL, + `t5` time(5) /* mariadb-5.3 */ DEFAULT NULL, + `t6` time(6) /* mariadb-5.3 */ DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT COLUMN_NAME, DATA_TYPE, COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='mariadb5312_time'; +COLUMN_NAME t0 +DATA_TYPE time +COLUMN_TYPE time /* mariadb-5.3 */ +COLUMN_NAME t1 +DATA_TYPE time +COLUMN_TYPE time(1) /* mariadb-5.3 */ +COLUMN_NAME t2 +DATA_TYPE time +COLUMN_TYPE time(2) /* mariadb-5.3 */ +COLUMN_NAME t3 +DATA_TYPE time +COLUMN_TYPE time(3) /* mariadb-5.3 */ +COLUMN_NAME t4 +DATA_TYPE time +COLUMN_TYPE time(4) /* mariadb-5.3 */ +COLUMN_NAME t5 +DATA_TYPE time +COLUMN_TYPE time(5) /* mariadb-5.3 */ +COLUMN_NAME t6 +DATA_TYPE time +COLUMN_TYPE time(6) /* mariadb-5.3 */ +DESCRIBE mariadb5312_time; +Field t0 +Type time /* mariadb-5.3 */ +Null YES +Key +Default NULL +Extra +Field t1 +Type time(1) /* mariadb-5.3 */ +Null YES +Key +Default NULL +Extra +Field t2 +Type time(2) /* mariadb-5.3 */ +Null YES +Key +Default NULL +Extra +Field t3 +Type time(3) /* mariadb-5.3 */ +Null YES +Key +Default NULL +Extra +Field t4 +Type time(4) /* mariadb-5.3 */ +Null YES +Key +Default NULL +Extra +Field t5 +Type time(5) /* mariadb-5.3 */ +Null YES +Key +Default NULL +Extra +Field t6 +Type time(6) /* mariadb-5.3 */ +Null YES +Key +Default NULL +Extra +DROP TABLE mariadb5312_time; diff --git a/mysql-test/main/type_temporal_mariadb53.test b/mysql-test/main/type_temporal_mariadb53.test new file mode 100644 index 00000000000..452c0be578d --- /dev/null +++ b/mysql-test/main/type_temporal_mariadb53.test @@ -0,0 +1,32 @@ +--let $MYSQLD_DATADIR= `select @@datadir` + +--echo # +--echo # MDEV-19906 Port show_old_temporals from MySQL 5.6 +--echo # + +--copy_file $MYSQL_TEST_DIR/std_data/mariadb53_temporal/mariadb5312_datetime.frm $MYSQLD_DATADIR/test/mariadb5312_datetime.frm +TRUNCATE TABLE mariadb5312_datetime; +SHOW CREATE TABLE mariadb5312_datetime; +--vertical_results +SELECT COLUMN_NAME, DATA_TYPE, COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='mariadb5312_datetime'; +DESCRIBE mariadb5312_datetime; +--horizontal_results +DROP TABLE mariadb5312_datetime; + +--copy_file $MYSQL_TEST_DIR/std_data/mariadb53_temporal/mariadb5312_timestamp.frm $MYSQLD_DATADIR/test/mariadb5312_timestamp.frm +TRUNCATE TABLE mariadb5312_timestamp; +SHOW CREATE TABLE mariadb5312_timestamp; +--vertical_results +SELECT COLUMN_NAME, DATA_TYPE, COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='mariadb5312_timestamp'; +DESCRIBE mariadb5312_timestamp; +--horizontal_results +DROP TABLE mariadb5312_timestamp; + +--copy_file $MYSQL_TEST_DIR/std_data/mariadb53_temporal/mariadb5312_time.frm $MYSQLD_DATADIR/test/mariadb5312_time.frm +TRUNCATE TABLE mariadb5312_time; +SHOW CREATE TABLE mariadb5312_time; +--vertical_results +SELECT COLUMN_NAME, DATA_TYPE, COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='mariadb5312_time'; +DESCRIBE mariadb5312_time; +--horizontal_results +DROP TABLE mariadb5312_time; diff --git a/mysql-test/main/type_temporal_mysql56_debug.result b/mysql-test/main/type_temporal_mysql56_debug.result index a6a6c071ea3..a93ec82fa4d 100644 --- a/mysql-test/main/type_temporal_mysql56_debug.result +++ b/mysql-test/main/type_temporal_mysql56_debug.result @@ -61,44 +61,44 @@ CALL mdev16542; # Original table Table Create Table t1 CREATE TABLE `t1` ( - `a0` time /* mysql-5.6 */ DEFAULT NULL, - `a1` time(1) /* mysql-5.6 */ DEFAULT NULL, - `a2` time(2) /* mysql-5.6 */ DEFAULT NULL, - `a3` time(3) /* mysql-5.6 */ DEFAULT NULL, - `a4` time(4) /* mysql-5.6 */ DEFAULT NULL, - `a5` time(5) /* mysql-5.6 */ DEFAULT NULL, - `a6` time(6) /* mysql-5.6 */ DEFAULT NULL + `a0` time /* mysql-5.6 */ DEFAULT NULL, + `a1` time(1) /* mysql-5.6 */ DEFAULT NULL, + `a2` time(2) /* mysql-5.6 */ DEFAULT NULL, + `a3` time(3) /* mysql-5.6 */ DEFAULT NULL, + `a4` time(4) /* mysql-5.6 */ DEFAULT NULL, + `a5` time(5) /* mysql-5.6 */ DEFAULT NULL, + `a6` time(6) /* mysql-5.6 */ DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 # CREATE..SELECT and SHOW Table Create Table t2 CREATE TABLE `t2` ( - `a0` time /* mysql-5.6 */ DEFAULT NULL, - `a1` time(1) /* mysql-5.6 */ DEFAULT NULL, - `a2` time(2) /* mysql-5.6 */ DEFAULT NULL, - `a3` time(3) /* mysql-5.6 */ DEFAULT NULL, - `a4` time(4) /* mysql-5.6 */ DEFAULT NULL, - `a5` time(5) /* mysql-5.6 */ DEFAULT NULL, - `a6` time(6) /* mysql-5.6 */ DEFAULT NULL, - `COALESCE(a0)` time /* mysql-5.6 */ DEFAULT NULL, - `COALESCE(a1)` time(1) /* mysql-5.6 */ DEFAULT NULL, - `COALESCE(a2)` time(2) /* mysql-5.6 */ DEFAULT NULL, - `COALESCE(a3)` time(3) /* mysql-5.6 */ DEFAULT NULL, - `COALESCE(a4)` time(4) /* mysql-5.6 */ DEFAULT NULL, - `COALESCE(a5)` time(5) /* mysql-5.6 */ DEFAULT NULL, - `COALESCE(a6)` time(6) /* mysql-5.6 */ DEFAULT NULL + `a0` time /* mysql-5.6 */ DEFAULT NULL, + `a1` time(1) /* mysql-5.6 */ DEFAULT NULL, + `a2` time(2) /* mysql-5.6 */ DEFAULT NULL, + `a3` time(3) /* mysql-5.6 */ DEFAULT NULL, + `a4` time(4) /* mysql-5.6 */ DEFAULT NULL, + `a5` time(5) /* mysql-5.6 */ DEFAULT NULL, + `a6` time(6) /* mysql-5.6 */ DEFAULT NULL, + `COALESCE(a0)` time /* mysql-5.6 */ DEFAULT NULL, + `COALESCE(a1)` time(1) /* mysql-5.6 */ DEFAULT NULL, + `COALESCE(a2)` time(2) /* mysql-5.6 */ DEFAULT NULL, + `COALESCE(a3)` time(3) /* mysql-5.6 */ DEFAULT NULL, + `COALESCE(a4)` time(4) /* mysql-5.6 */ DEFAULT NULL, + `COALESCE(a5)` time(5) /* mysql-5.6 */ DEFAULT NULL, + `COALESCE(a6)` time(6) /* mysql-5.6 */ DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 # ALTER..FORCE and SHOW Table Create Table t1 CREATE TABLE `t1` ( - `a0` time /* mysql-5.6 */ DEFAULT NULL, - `a1` time(1) /* mysql-5.6 */ DEFAULT NULL, - `a2` time(2) /* mysql-5.6 */ DEFAULT NULL, - `a3` time(3) /* mysql-5.6 */ DEFAULT NULL, - `a4` time(4) /* mysql-5.6 */ DEFAULT NULL, - `a5` time(5) /* mysql-5.6 */ DEFAULT NULL, - `a6` time(6) /* mysql-5.6 */ DEFAULT NULL + `a0` time /* mysql-5.6 */ DEFAULT NULL, + `a1` time(1) /* mysql-5.6 */ DEFAULT NULL, + `a2` time(2) /* mysql-5.6 */ DEFAULT NULL, + `a3` time(3) /* mysql-5.6 */ DEFAULT NULL, + `a4` time(4) /* mysql-5.6 */ DEFAULT NULL, + `a5` time(5) /* mysql-5.6 */ DEFAULT NULL, + `a6` time(6) /* mysql-5.6 */ DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 # Setting @@global.mysql56_temporal_format=false @@ -106,32 +106,32 @@ t1 CREATE TABLE `t1` ( # CREATE..SELECT and SHOW Table Create Table t2 CREATE TABLE `t2` ( - `a0` time /* mariadb-5.3 */ DEFAULT NULL, - `a1` time(1) /* mariadb-5.3 */ DEFAULT NULL, - `a2` time(2) /* mariadb-5.3 */ DEFAULT NULL, - `a3` time(3) /* mariadb-5.3 */ DEFAULT NULL, - `a4` time(4) /* mariadb-5.3 */ DEFAULT NULL, - `a5` time(5) /* mariadb-5.3 */ DEFAULT NULL, - `a6` time(6) /* mariadb-5.3 */ DEFAULT NULL, - `COALESCE(a0)` time /* mariadb-5.3 */ DEFAULT NULL, - `COALESCE(a1)` time(1) /* mariadb-5.3 */ DEFAULT NULL, - `COALESCE(a2)` time(2) /* mariadb-5.3 */ DEFAULT NULL, - `COALESCE(a3)` time(3) /* mariadb-5.3 */ DEFAULT NULL, - `COALESCE(a4)` time(4) /* mariadb-5.3 */ DEFAULT NULL, - `COALESCE(a5)` time(5) /* mariadb-5.3 */ DEFAULT NULL, - `COALESCE(a6)` time(6) /* mariadb-5.3 */ DEFAULT NULL + `a0` time /* mariadb-5.3 */ DEFAULT NULL, + `a1` time(1) /* mariadb-5.3 */ DEFAULT NULL, + `a2` time(2) /* mariadb-5.3 */ DEFAULT NULL, + `a3` time(3) /* mariadb-5.3 */ DEFAULT NULL, + `a4` time(4) /* mariadb-5.3 */ DEFAULT NULL, + `a5` time(5) /* mariadb-5.3 */ DEFAULT NULL, + `a6` time(6) /* mariadb-5.3 */ DEFAULT NULL, + `COALESCE(a0)` time /* mariadb-5.3 */ DEFAULT NULL, + `COALESCE(a1)` time(1) /* mariadb-5.3 */ DEFAULT NULL, + `COALESCE(a2)` time(2) /* mariadb-5.3 */ DEFAULT NULL, + `COALESCE(a3)` time(3) /* mariadb-5.3 */ DEFAULT NULL, + `COALESCE(a4)` time(4) /* mariadb-5.3 */ DEFAULT NULL, + `COALESCE(a5)` time(5) /* mariadb-5.3 */ DEFAULT NULL, + `COALESCE(a6)` time(6) /* mariadb-5.3 */ DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 # ALTER..FORCE and SHOW Table Create Table t1 CREATE TABLE `t1` ( - `a0` time /* mariadb-5.3 */ DEFAULT NULL, - `a1` time(1) /* mariadb-5.3 */ DEFAULT NULL, - `a2` time(2) /* mariadb-5.3 */ DEFAULT NULL, - `a3` time(3) /* mariadb-5.3 */ DEFAULT NULL, - `a4` time(4) /* mariadb-5.3 */ DEFAULT NULL, - `a5` time(5) /* mariadb-5.3 */ DEFAULT NULL, - `a6` time(6) /* mariadb-5.3 */ DEFAULT NULL + `a0` time /* mariadb-5.3 */ DEFAULT NULL, + `a1` time(1) /* mariadb-5.3 */ DEFAULT NULL, + `a2` time(2) /* mariadb-5.3 */ DEFAULT NULL, + `a3` time(3) /* mariadb-5.3 */ DEFAULT NULL, + `a4` time(4) /* mariadb-5.3 */ DEFAULT NULL, + `a5` time(5) /* mariadb-5.3 */ DEFAULT NULL, + `a6` time(6) /* mariadb-5.3 */ DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 # Setting @@global.mysql56_temporal_format=true @@ -139,32 +139,32 @@ t1 CREATE TABLE `t1` ( # CREATE..SELECT and SHOW Table Create Table t2 CREATE TABLE `t2` ( - `a0` time /* mysql-5.6 */ DEFAULT NULL, - `a1` time(1) /* mysql-5.6 */ DEFAULT NULL, - `a2` time(2) /* mysql-5.6 */ DEFAULT NULL, - `a3` time(3) /* mysql-5.6 */ DEFAULT NULL, - `a4` time(4) /* mysql-5.6 */ DEFAULT NULL, - `a5` time(5) /* mysql-5.6 */ DEFAULT NULL, - `a6` time(6) /* mysql-5.6 */ DEFAULT NULL, - `COALESCE(a0)` time /* mysql-5.6 */ DEFAULT NULL, - `COALESCE(a1)` time(1) /* mysql-5.6 */ DEFAULT NULL, - `COALESCE(a2)` time(2) /* mysql-5.6 */ DEFAULT NULL, - `COALESCE(a3)` time(3) /* mysql-5.6 */ DEFAULT NULL, - `COALESCE(a4)` time(4) /* mysql-5.6 */ DEFAULT NULL, - `COALESCE(a5)` time(5) /* mysql-5.6 */ DEFAULT NULL, - `COALESCE(a6)` time(6) /* mysql-5.6 */ DEFAULT NULL + `a0` time /* mysql-5.6 */ DEFAULT NULL, + `a1` time(1) /* mysql-5.6 */ DEFAULT NULL, + `a2` time(2) /* mysql-5.6 */ DEFAULT NULL, + `a3` time(3) /* mysql-5.6 */ DEFAULT NULL, + `a4` time(4) /* mysql-5.6 */ DEFAULT NULL, + `a5` time(5) /* mysql-5.6 */ DEFAULT NULL, + `a6` time(6) /* mysql-5.6 */ DEFAULT NULL, + `COALESCE(a0)` time /* mysql-5.6 */ DEFAULT NULL, + `COALESCE(a1)` time(1) /* mysql-5.6 */ DEFAULT NULL, + `COALESCE(a2)` time(2) /* mysql-5.6 */ DEFAULT NULL, + `COALESCE(a3)` time(3) /* mysql-5.6 */ DEFAULT NULL, + `COALESCE(a4)` time(4) /* mysql-5.6 */ DEFAULT NULL, + `COALESCE(a5)` time(5) /* mysql-5.6 */ DEFAULT NULL, + `COALESCE(a6)` time(6) /* mysql-5.6 */ DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 # ALTER..FORCE and SHOW Table Create Table t1 CREATE TABLE `t1` ( - `a0` time /* mysql-5.6 */ DEFAULT NULL, - `a1` time(1) /* mysql-5.6 */ DEFAULT NULL, - `a2` time(2) /* mysql-5.6 */ DEFAULT NULL, - `a3` time(3) /* mysql-5.6 */ DEFAULT NULL, - `a4` time(4) /* mysql-5.6 */ DEFAULT NULL, - `a5` time(5) /* mysql-5.6 */ DEFAULT NULL, - `a6` time(6) /* mysql-5.6 */ DEFAULT NULL + `a0` time /* mysql-5.6 */ DEFAULT NULL, + `a1` time(1) /* mysql-5.6 */ DEFAULT NULL, + `a2` time(2) /* mysql-5.6 */ DEFAULT NULL, + `a3` time(3) /* mysql-5.6 */ DEFAULT NULL, + `a4` time(4) /* mysql-5.6 */ DEFAULT NULL, + `a5` time(5) /* mysql-5.6 */ DEFAULT NULL, + `a6` time(6) /* mysql-5.6 */ DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; CREATE TABLE t1 ( @@ -181,44 +181,44 @@ CALL mdev16542; # Original table Table Create Table t1 CREATE TABLE `t1` ( - `a0` datetime /* mysql-5.6 */ DEFAULT NULL, - `a1` datetime(1) /* mysql-5.6 */ DEFAULT NULL, - `a2` datetime(2) /* mysql-5.6 */ DEFAULT NULL, - `a3` datetime(3) /* mysql-5.6 */ DEFAULT NULL, - `a4` datetime(4) /* mysql-5.6 */ DEFAULT NULL, - `a5` datetime(5) /* mysql-5.6 */ DEFAULT NULL, - `a6` datetime(6) /* mysql-5.6 */ DEFAULT NULL + `a0` datetime /* mysql-5.6 */ DEFAULT NULL, + `a1` datetime(1) /* mysql-5.6 */ DEFAULT NULL, + `a2` datetime(2) /* mysql-5.6 */ DEFAULT NULL, + `a3` datetime(3) /* mysql-5.6 */ DEFAULT NULL, + `a4` datetime(4) /* mysql-5.6 */ DEFAULT NULL, + `a5` datetime(5) /* mysql-5.6 */ DEFAULT NULL, + `a6` datetime(6) /* mysql-5.6 */ DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 # CREATE..SELECT and SHOW Table Create Table t2 CREATE TABLE `t2` ( - `a0` datetime /* mysql-5.6 */ DEFAULT NULL, - `a1` datetime(1) /* mysql-5.6 */ DEFAULT NULL, - `a2` datetime(2) /* mysql-5.6 */ DEFAULT NULL, - `a3` datetime(3) /* mysql-5.6 */ DEFAULT NULL, - `a4` datetime(4) /* mysql-5.6 */ DEFAULT NULL, - `a5` datetime(5) /* mysql-5.6 */ DEFAULT NULL, - `a6` datetime(6) /* mysql-5.6 */ DEFAULT NULL, - `COALESCE(a0)` datetime /* mysql-5.6 */ DEFAULT NULL, - `COALESCE(a1)` datetime(1) /* mysql-5.6 */ DEFAULT NULL, - `COALESCE(a2)` datetime(2) /* mysql-5.6 */ DEFAULT NULL, - `COALESCE(a3)` datetime(3) /* mysql-5.6 */ DEFAULT NULL, - `COALESCE(a4)` datetime(4) /* mysql-5.6 */ DEFAULT NULL, - `COALESCE(a5)` datetime(5) /* mysql-5.6 */ DEFAULT NULL, - `COALESCE(a6)` datetime(6) /* mysql-5.6 */ DEFAULT NULL + `a0` datetime /* mysql-5.6 */ DEFAULT NULL, + `a1` datetime(1) /* mysql-5.6 */ DEFAULT NULL, + `a2` datetime(2) /* mysql-5.6 */ DEFAULT NULL, + `a3` datetime(3) /* mysql-5.6 */ DEFAULT NULL, + `a4` datetime(4) /* mysql-5.6 */ DEFAULT NULL, + `a5` datetime(5) /* mysql-5.6 */ DEFAULT NULL, + `a6` datetime(6) /* mysql-5.6 */ DEFAULT NULL, + `COALESCE(a0)` datetime /* mysql-5.6 */ DEFAULT NULL, + `COALESCE(a1)` datetime(1) /* mysql-5.6 */ DEFAULT NULL, + `COALESCE(a2)` datetime(2) /* mysql-5.6 */ DEFAULT NULL, + `COALESCE(a3)` datetime(3) /* mysql-5.6 */ DEFAULT NULL, + `COALESCE(a4)` datetime(4) /* mysql-5.6 */ DEFAULT NULL, + `COALESCE(a5)` datetime(5) /* mysql-5.6 */ DEFAULT NULL, + `COALESCE(a6)` datetime(6) /* mysql-5.6 */ DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 # ALTER..FORCE and SHOW Table Create Table t1 CREATE TABLE `t1` ( - `a0` datetime /* mysql-5.6 */ DEFAULT NULL, - `a1` datetime(1) /* mysql-5.6 */ DEFAULT NULL, - `a2` datetime(2) /* mysql-5.6 */ DEFAULT NULL, - `a3` datetime(3) /* mysql-5.6 */ DEFAULT NULL, - `a4` datetime(4) /* mysql-5.6 */ DEFAULT NULL, - `a5` datetime(5) /* mysql-5.6 */ DEFAULT NULL, - `a6` datetime(6) /* mysql-5.6 */ DEFAULT NULL + `a0` datetime /* mysql-5.6 */ DEFAULT NULL, + `a1` datetime(1) /* mysql-5.6 */ DEFAULT NULL, + `a2` datetime(2) /* mysql-5.6 */ DEFAULT NULL, + `a3` datetime(3) /* mysql-5.6 */ DEFAULT NULL, + `a4` datetime(4) /* mysql-5.6 */ DEFAULT NULL, + `a5` datetime(5) /* mysql-5.6 */ DEFAULT NULL, + `a6` datetime(6) /* mysql-5.6 */ DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 # Setting @@global.mysql56_temporal_format=false @@ -226,32 +226,32 @@ t1 CREATE TABLE `t1` ( # CREATE..SELECT and SHOW Table Create Table t2 CREATE TABLE `t2` ( - `a0` datetime /* mariadb-5.3 */ DEFAULT NULL, - `a1` datetime(1) /* mariadb-5.3 */ DEFAULT NULL, - `a2` datetime(2) /* mariadb-5.3 */ DEFAULT NULL, - `a3` datetime(3) /* mariadb-5.3 */ DEFAULT NULL, - `a4` datetime(4) /* mariadb-5.3 */ DEFAULT NULL, - `a5` datetime(5) /* mariadb-5.3 */ DEFAULT NULL, - `a6` datetime(6) /* mariadb-5.3 */ DEFAULT NULL, - `COALESCE(a0)` datetime /* mariadb-5.3 */ DEFAULT NULL, - `COALESCE(a1)` datetime(1) /* mariadb-5.3 */ DEFAULT NULL, - `COALESCE(a2)` datetime(2) /* mariadb-5.3 */ DEFAULT NULL, - `COALESCE(a3)` datetime(3) /* mariadb-5.3 */ DEFAULT NULL, - `COALESCE(a4)` datetime(4) /* mariadb-5.3 */ DEFAULT NULL, - `COALESCE(a5)` datetime(5) /* mariadb-5.3 */ DEFAULT NULL, - `COALESCE(a6)` datetime(6) /* mariadb-5.3 */ DEFAULT NULL + `a0` datetime /* mariadb-5.3 */ DEFAULT NULL, + `a1` datetime(1) /* mariadb-5.3 */ DEFAULT NULL, + `a2` datetime(2) /* mariadb-5.3 */ DEFAULT NULL, + `a3` datetime(3) /* mariadb-5.3 */ DEFAULT NULL, + `a4` datetime(4) /* mariadb-5.3 */ DEFAULT NULL, + `a5` datetime(5) /* mariadb-5.3 */ DEFAULT NULL, + `a6` datetime(6) /* mariadb-5.3 */ DEFAULT NULL, + `COALESCE(a0)` datetime /* mariadb-5.3 */ DEFAULT NULL, + `COALESCE(a1)` datetime(1) /* mariadb-5.3 */ DEFAULT NULL, + `COALESCE(a2)` datetime(2) /* mariadb-5.3 */ DEFAULT NULL, + `COALESCE(a3)` datetime(3) /* mariadb-5.3 */ DEFAULT NULL, + `COALESCE(a4)` datetime(4) /* mariadb-5.3 */ DEFAULT NULL, + `COALESCE(a5)` datetime(5) /* mariadb-5.3 */ DEFAULT NULL, + `COALESCE(a6)` datetime(6) /* mariadb-5.3 */ DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 # ALTER..FORCE and SHOW Table Create Table t1 CREATE TABLE `t1` ( - `a0` datetime /* mariadb-5.3 */ DEFAULT NULL, - `a1` datetime(1) /* mariadb-5.3 */ DEFAULT NULL, - `a2` datetime(2) /* mariadb-5.3 */ DEFAULT NULL, - `a3` datetime(3) /* mariadb-5.3 */ DEFAULT NULL, - `a4` datetime(4) /* mariadb-5.3 */ DEFAULT NULL, - `a5` datetime(5) /* mariadb-5.3 */ DEFAULT NULL, - `a6` datetime(6) /* mariadb-5.3 */ DEFAULT NULL + `a0` datetime /* mariadb-5.3 */ DEFAULT NULL, + `a1` datetime(1) /* mariadb-5.3 */ DEFAULT NULL, + `a2` datetime(2) /* mariadb-5.3 */ DEFAULT NULL, + `a3` datetime(3) /* mariadb-5.3 */ DEFAULT NULL, + `a4` datetime(4) /* mariadb-5.3 */ DEFAULT NULL, + `a5` datetime(5) /* mariadb-5.3 */ DEFAULT NULL, + `a6` datetime(6) /* mariadb-5.3 */ DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 # Setting @@global.mysql56_temporal_format=true @@ -259,32 +259,32 @@ t1 CREATE TABLE `t1` ( # CREATE..SELECT and SHOW Table Create Table t2 CREATE TABLE `t2` ( - `a0` datetime /* mysql-5.6 */ DEFAULT NULL, - `a1` datetime(1) /* mysql-5.6 */ DEFAULT NULL, - `a2` datetime(2) /* mysql-5.6 */ DEFAULT NULL, - `a3` datetime(3) /* mysql-5.6 */ DEFAULT NULL, - `a4` datetime(4) /* mysql-5.6 */ DEFAULT NULL, - `a5` datetime(5) /* mysql-5.6 */ DEFAULT NULL, - `a6` datetime(6) /* mysql-5.6 */ DEFAULT NULL, - `COALESCE(a0)` datetime /* mysql-5.6 */ DEFAULT NULL, - `COALESCE(a1)` datetime(1) /* mysql-5.6 */ DEFAULT NULL, - `COALESCE(a2)` datetime(2) /* mysql-5.6 */ DEFAULT NULL, - `COALESCE(a3)` datetime(3) /* mysql-5.6 */ DEFAULT NULL, - `COALESCE(a4)` datetime(4) /* mysql-5.6 */ DEFAULT NULL, - `COALESCE(a5)` datetime(5) /* mysql-5.6 */ DEFAULT NULL, - `COALESCE(a6)` datetime(6) /* mysql-5.6 */ DEFAULT NULL + `a0` datetime /* mysql-5.6 */ DEFAULT NULL, + `a1` datetime(1) /* mysql-5.6 */ DEFAULT NULL, + `a2` datetime(2) /* mysql-5.6 */ DEFAULT NULL, + `a3` datetime(3) /* mysql-5.6 */ DEFAULT NULL, + `a4` datetime(4) /* mysql-5.6 */ DEFAULT NULL, + `a5` datetime(5) /* mysql-5.6 */ DEFAULT NULL, + `a6` datetime(6) /* mysql-5.6 */ DEFAULT NULL, + `COALESCE(a0)` datetime /* mysql-5.6 */ DEFAULT NULL, + `COALESCE(a1)` datetime(1) /* mysql-5.6 */ DEFAULT NULL, + `COALESCE(a2)` datetime(2) /* mysql-5.6 */ DEFAULT NULL, + `COALESCE(a3)` datetime(3) /* mysql-5.6 */ DEFAULT NULL, + `COALESCE(a4)` datetime(4) /* mysql-5.6 */ DEFAULT NULL, + `COALESCE(a5)` datetime(5) /* mysql-5.6 */ DEFAULT NULL, + `COALESCE(a6)` datetime(6) /* mysql-5.6 */ DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 # ALTER..FORCE and SHOW Table Create Table t1 CREATE TABLE `t1` ( - `a0` datetime /* mysql-5.6 */ DEFAULT NULL, - `a1` datetime(1) /* mysql-5.6 */ DEFAULT NULL, - `a2` datetime(2) /* mysql-5.6 */ DEFAULT NULL, - `a3` datetime(3) /* mysql-5.6 */ DEFAULT NULL, - `a4` datetime(4) /* mysql-5.6 */ DEFAULT NULL, - `a5` datetime(5) /* mysql-5.6 */ DEFAULT NULL, - `a6` datetime(6) /* mysql-5.6 */ DEFAULT NULL + `a0` datetime /* mysql-5.6 */ DEFAULT NULL, + `a1` datetime(1) /* mysql-5.6 */ DEFAULT NULL, + `a2` datetime(2) /* mysql-5.6 */ DEFAULT NULL, + `a3` datetime(3) /* mysql-5.6 */ DEFAULT NULL, + `a4` datetime(4) /* mysql-5.6 */ DEFAULT NULL, + `a5` datetime(5) /* mysql-5.6 */ DEFAULT NULL, + `a6` datetime(6) /* mysql-5.6 */ DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; CREATE TABLE t1 ( @@ -301,44 +301,44 @@ CALL mdev16542; # Original table Table Create Table t1 CREATE TABLE `t1` ( - `a0` timestamp /* mysql-5.6 */ NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), - `a1` timestamp(1) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0', - `a2` timestamp(2) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00', - `a3` timestamp(3) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000', - `a4` timestamp(4) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0000', - `a5` timestamp(5) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00000', - `a6` timestamp(6) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000000' + `a0` timestamp /* mysql-5.6 */ NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `a1` timestamp(1) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0', + `a2` timestamp(2) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00', + `a3` timestamp(3) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000', + `a4` timestamp(4) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0000', + `a5` timestamp(5) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00000', + `a6` timestamp(6) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000000' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 # CREATE..SELECT and SHOW Table Create Table t2 CREATE TABLE `t2` ( - `a0` timestamp /* mysql-5.6 */ NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), - `a1` timestamp(1) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0', - `a2` timestamp(2) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00', - `a3` timestamp(3) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000', - `a4` timestamp(4) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0000', - `a5` timestamp(5) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00000', - `a6` timestamp(6) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000000', - `COALESCE(a0)` timestamp /* mysql-5.6 */ NULL DEFAULT NULL, - `COALESCE(a1)` timestamp(1) /* mysql-5.6 */ NULL DEFAULT NULL, - `COALESCE(a2)` timestamp(2) /* mysql-5.6 */ NULL DEFAULT NULL, - `COALESCE(a3)` timestamp(3) /* mysql-5.6 */ NULL DEFAULT NULL, - `COALESCE(a4)` timestamp(4) /* mysql-5.6 */ NULL DEFAULT NULL, - `COALESCE(a5)` timestamp(5) /* mysql-5.6 */ NULL DEFAULT NULL, - `COALESCE(a6)` timestamp(6) /* mysql-5.6 */ NULL DEFAULT NULL + `a0` timestamp /* mysql-5.6 */ NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `a1` timestamp(1) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0', + `a2` timestamp(2) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00', + `a3` timestamp(3) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000', + `a4` timestamp(4) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0000', + `a5` timestamp(5) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00000', + `a6` timestamp(6) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000000', + `COALESCE(a0)` timestamp /* mysql-5.6 */ NULL DEFAULT NULL, + `COALESCE(a1)` timestamp(1) /* mysql-5.6 */ NULL DEFAULT NULL, + `COALESCE(a2)` timestamp(2) /* mysql-5.6 */ NULL DEFAULT NULL, + `COALESCE(a3)` timestamp(3) /* mysql-5.6 */ NULL DEFAULT NULL, + `COALESCE(a4)` timestamp(4) /* mysql-5.6 */ NULL DEFAULT NULL, + `COALESCE(a5)` timestamp(5) /* mysql-5.6 */ NULL DEFAULT NULL, + `COALESCE(a6)` timestamp(6) /* mysql-5.6 */ NULL DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 # ALTER..FORCE and SHOW Table Create Table t1 CREATE TABLE `t1` ( - `a0` timestamp /* mysql-5.6 */ NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), - `a1` timestamp(1) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0', - `a2` timestamp(2) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00', - `a3` timestamp(3) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000', - `a4` timestamp(4) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0000', - `a5` timestamp(5) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00000', - `a6` timestamp(6) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000000' + `a0` timestamp /* mysql-5.6 */ NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `a1` timestamp(1) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0', + `a2` timestamp(2) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00', + `a3` timestamp(3) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000', + `a4` timestamp(4) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0000', + `a5` timestamp(5) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00000', + `a6` timestamp(6) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000000' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 # Setting @@global.mysql56_temporal_format=false @@ -346,32 +346,32 @@ t1 CREATE TABLE `t1` ( # CREATE..SELECT and SHOW Table Create Table t2 CREATE TABLE `t2` ( - `a0` timestamp /* mariadb-5.3 */ NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), - `a1` timestamp(1) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0', - `a2` timestamp(2) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00', - `a3` timestamp(3) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000', - `a4` timestamp(4) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0000', - `a5` timestamp(5) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00000', - `a6` timestamp(6) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000000', - `COALESCE(a0)` timestamp /* mariadb-5.3 */ NULL DEFAULT NULL, - `COALESCE(a1)` timestamp(1) /* mariadb-5.3 */ NULL DEFAULT NULL, - `COALESCE(a2)` timestamp(2) /* mariadb-5.3 */ NULL DEFAULT NULL, - `COALESCE(a3)` timestamp(3) /* mariadb-5.3 */ NULL DEFAULT NULL, - `COALESCE(a4)` timestamp(4) /* mariadb-5.3 */ NULL DEFAULT NULL, - `COALESCE(a5)` timestamp(5) /* mariadb-5.3 */ NULL DEFAULT NULL, - `COALESCE(a6)` timestamp(6) /* mariadb-5.3 */ NULL DEFAULT NULL + `a0` timestamp /* mariadb-5.3 */ NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `a1` timestamp(1) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0', + `a2` timestamp(2) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00', + `a3` timestamp(3) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000', + `a4` timestamp(4) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0000', + `a5` timestamp(5) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00000', + `a6` timestamp(6) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000000', + `COALESCE(a0)` timestamp /* mariadb-5.3 */ NULL DEFAULT NULL, + `COALESCE(a1)` timestamp(1) /* mariadb-5.3 */ NULL DEFAULT NULL, + `COALESCE(a2)` timestamp(2) /* mariadb-5.3 */ NULL DEFAULT NULL, + `COALESCE(a3)` timestamp(3) /* mariadb-5.3 */ NULL DEFAULT NULL, + `COALESCE(a4)` timestamp(4) /* mariadb-5.3 */ NULL DEFAULT NULL, + `COALESCE(a5)` timestamp(5) /* mariadb-5.3 */ NULL DEFAULT NULL, + `COALESCE(a6)` timestamp(6) /* mariadb-5.3 */ NULL DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 # ALTER..FORCE and SHOW Table Create Table t1 CREATE TABLE `t1` ( - `a0` timestamp /* mariadb-5.3 */ NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), - `a1` timestamp(1) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0', - `a2` timestamp(2) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00', - `a3` timestamp(3) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000', - `a4` timestamp(4) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0000', - `a5` timestamp(5) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00000', - `a6` timestamp(6) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000000' + `a0` timestamp /* mariadb-5.3 */ NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `a1` timestamp(1) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0', + `a2` timestamp(2) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00', + `a3` timestamp(3) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000', + `a4` timestamp(4) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0000', + `a5` timestamp(5) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00000', + `a6` timestamp(6) /* mariadb-5.3 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000000' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 # Setting @@global.mysql56_temporal_format=true @@ -379,32 +379,32 @@ t1 CREATE TABLE `t1` ( # CREATE..SELECT and SHOW Table Create Table t2 CREATE TABLE `t2` ( - `a0` timestamp /* mysql-5.6 */ NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), - `a1` timestamp(1) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0', - `a2` timestamp(2) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00', - `a3` timestamp(3) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000', - `a4` timestamp(4) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0000', - `a5` timestamp(5) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00000', - `a6` timestamp(6) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000000', - `COALESCE(a0)` timestamp /* mysql-5.6 */ NULL DEFAULT NULL, - `COALESCE(a1)` timestamp(1) /* mysql-5.6 */ NULL DEFAULT NULL, - `COALESCE(a2)` timestamp(2) /* mysql-5.6 */ NULL DEFAULT NULL, - `COALESCE(a3)` timestamp(3) /* mysql-5.6 */ NULL DEFAULT NULL, - `COALESCE(a4)` timestamp(4) /* mysql-5.6 */ NULL DEFAULT NULL, - `COALESCE(a5)` timestamp(5) /* mysql-5.6 */ NULL DEFAULT NULL, - `COALESCE(a6)` timestamp(6) /* mysql-5.6 */ NULL DEFAULT NULL + `a0` timestamp /* mysql-5.6 */ NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `a1` timestamp(1) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0', + `a2` timestamp(2) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00', + `a3` timestamp(3) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000', + `a4` timestamp(4) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0000', + `a5` timestamp(5) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00000', + `a6` timestamp(6) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000000', + `COALESCE(a0)` timestamp /* mysql-5.6 */ NULL DEFAULT NULL, + `COALESCE(a1)` timestamp(1) /* mysql-5.6 */ NULL DEFAULT NULL, + `COALESCE(a2)` timestamp(2) /* mysql-5.6 */ NULL DEFAULT NULL, + `COALESCE(a3)` timestamp(3) /* mysql-5.6 */ NULL DEFAULT NULL, + `COALESCE(a4)` timestamp(4) /* mysql-5.6 */ NULL DEFAULT NULL, + `COALESCE(a5)` timestamp(5) /* mysql-5.6 */ NULL DEFAULT NULL, + `COALESCE(a6)` timestamp(6) /* mysql-5.6 */ NULL DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 # ALTER..FORCE and SHOW Table Create Table t1 CREATE TABLE `t1` ( - `a0` timestamp /* mysql-5.6 */ NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), - `a1` timestamp(1) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0', - `a2` timestamp(2) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00', - `a3` timestamp(3) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000', - `a4` timestamp(4) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0000', - `a5` timestamp(5) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00000', - `a6` timestamp(6) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000000' + `a0` timestamp /* mysql-5.6 */ NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `a1` timestamp(1) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0', + `a2` timestamp(2) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00', + `a3` timestamp(3) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000', + `a4` timestamp(4) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.0000', + `a5` timestamp(5) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.00000', + `a6` timestamp(6) /* mysql-5.6 */ NOT NULL DEFAULT '0000-00-00 00:00:00.000000' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; SET @@global.mysql56_temporal_format=DEFAULT; diff --git a/mysql-test/main/type_time.result b/mysql-test/main/type_time.result index 69aa9561ebf..ead494e3ace 100644 --- a/mysql-test/main/type_time.result +++ b/mysql-test/main/type_time.result @@ -1374,7 +1374,7 @@ CREATE TABLE t1 (f TIME, KEY(f)); INSERT INTO t1 VALUES ('10:10:10'),('20:20:20'); EXPLAIN EXTENDED SELECT * FROM t1 WHERE 1995.0000000 BETWEEN f AND '23:59:59'; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 index f f 4 NULL 2 50.00 Using where; Using index +1 SIMPLE t1 range f f 4 NULL 1 100.00 Using where; Using index Warnings: Warning 1292 Truncated incorrect time value: '1995.0000000' Note 1003 select `test`.`t1`.`f` AS `f` from `test`.`t1` where '00:00:00.000000' between `test`.`t1`.`f` and <cache>('23:59:59') diff --git a/mysql-test/main/type_varchar.result b/mysql-test/main/type_varchar.result index cec279913b4..e42a363a2c2 100644 --- a/mysql-test/main/type_varchar.result +++ b/mysql-test/main/type_varchar.result @@ -739,3 +739,32 @@ SET sql_mode=DEFAULT; # # End of 10.4 tests # +# +# Start of 10.5 tests +# +# +# MDEV-15592 Column COMPRESSED should select a 'high order' datatype +# +TRUNCATE TABLE vchar; +SHOW CREATE TABLE vchar; +Table Create Table +vchar CREATE TABLE `vchar` ( + `v` varchar(30)/*old*/ DEFAULT NULL, + `c` char(3) DEFAULT NULL, + `e` enum('abc','def','ghi') DEFAULT NULL, + `t` text DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +ALTER TABLE vchar ADD FULLTEXT INDEX(v); +SHOW CREATE TABLE vchar; +Table Create Table +vchar CREATE TABLE `vchar` ( + `v` varchar(30) DEFAULT NULL, + `c` char(3) DEFAULT NULL, + `e` enum('abc','def','ghi') DEFAULT NULL, + `t` text DEFAULT NULL, + FULLTEXT KEY `v` (`v`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE vchar; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/type_varchar.test b/mysql-test/main/type_varchar.test index 9d0ad8a128b..f63523e226b 100644 --- a/mysql-test/main/type_varchar.test +++ b/mysql-test/main/type_varchar.test @@ -373,3 +373,26 @@ SET sql_mode=DEFAULT; --echo # --echo # End of 10.4 tests --echo # + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-15592 Column COMPRESSED should select a 'high order' datatype +--echo # + +# +# Old VARCHAR is automatically upgraded to new VARCHAR. +# So we don't have to override Type_handler_var_string::Key_part_spec_init_ft() +# +copy_file $MYSQL_TEST_DIR/std_data/vchar.frm $MYSQLD_DATADIR/test/vchar.frm; +TRUNCATE TABLE vchar; +SHOW CREATE TABLE vchar; +ALTER TABLE vchar ADD FULLTEXT INDEX(v); +SHOW CREATE TABLE vchar; +DROP TABLE vchar; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/type_year.result b/mysql-test/main/type_year.result index 26f90757d09..a3918580e1f 100644 --- a/mysql-test/main/type_year.result +++ b/mysql-test/main/type_year.result @@ -677,3 +677,29 @@ DROP TABLE t2,t1; # # End of 10.4 tests # +# +# Start of 10.5 tests +# +# +# MDEV-20384 Assertion `field.is_sane()' failed in Protocol_text::store_field_metadata +# +CREATE TABLE t1 (a YEAR); +INSERT INTO t1 VALUES (2000),(2001); +SELECT MAX( NULLIF( a, 1970 ) ) AS f FROM t1; +f +2001 +SELECT NULLIF(a, 1970) AS f FROM t1 ORDER BY a; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def f 13 4 4 Y 32928 0 63 +f +2000 +2001 +SELECT MAX(NULLIF(a, 1970)) AS f FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def f 8 4 4 Y 32928 0 63 +f +2001 +DROP TABLE t1; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/type_year.test b/mysql-test/main/type_year.test index c1231cc3e79..0f1f49be5d0 100644 --- a/mysql-test/main/type_year.test +++ b/mysql-test/main/type_year.test @@ -352,3 +352,27 @@ DROP TABLE t2,t1; --echo # --echo # End of 10.4 tests --echo # + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-20384 Assertion `field.is_sane()' failed in Protocol_text::store_field_metadata +--echo # + +CREATE TABLE t1 (a YEAR); +INSERT INTO t1 VALUES (2000),(2001); +SELECT MAX( NULLIF( a, 1970 ) ) AS f FROM t1; +--disable_ps_protocol +--enable_metadata +SELECT NULLIF(a, 1970) AS f FROM t1 ORDER BY a; +SELECT MAX(NULLIF(a, 1970)) AS f FROM t1; +--disable_metadata +--enable_ps_protocol +DROP TABLE t1; + + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/unsafe_binlog_innodb-master.opt b/mysql-test/main/unsafe_binlog_innodb-master.opt deleted file mode 100644 index 0d13f0834a5..00000000000 --- a/mysql-test/main/unsafe_binlog_innodb-master.opt +++ /dev/null @@ -1 +0,0 @@ ---loose-innodb_locks_unsafe_for_binlog --loose-innodb_lock_wait_timeout=1 diff --git a/mysql-test/main/unsafe_binlog_innodb.result b/mysql-test/main/unsafe_binlog_innodb.result index 0fe3d38035b..ced29926400 100644 --- a/mysql-test/main/unsafe_binlog_innodb.result +++ b/mysql-test/main/unsafe_binlog_innodb.result @@ -1,3 +1,7 @@ +SET @save_timeout = @@GLOBAL.innodb_lock_wait_timeout; +SET GLOBAL innodb_lock_wait_timeout = 1; +SET @save_isolation = @@GLOBAL.tx_isolation; +SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; create table t1 (id int not null, f_id int not null, f int not null, primary key(f_id, id)) engine = InnoDB; @@ -94,15 +98,15 @@ connect a,localhost,root,,; connect b,localhost,root,,; connect c,localhost,root,,; connect d,localhost,root,,; -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; connect e,localhost,root,,; connect f,localhost,root,,; connect g,localhost,root,,; -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; connect h,localhost,root,,; connect i,localhost,root,,; connect j,localhost,root,,; -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; connection a; create table t1(a int not null, b int, primary key(a)) engine = InnoDB; insert into t1 values (1,2),(5,3),(4,2); @@ -187,3 +191,5 @@ disconnect h; disconnect i; disconnect j; drop table t1, t2, t3, t5, t6, t8, t9; +SET GLOBAL innodb_lock_wait_timeout = @save_timeout; +SET GLOBAL tx_isolation = @save_isolation; diff --git a/mysql-test/main/unsafe_binlog_innodb.test b/mysql-test/main/unsafe_binlog_innodb.test index a0516749451..abd2c58de30 100644 --- a/mysql-test/main/unsafe_binlog_innodb.test +++ b/mysql-test/main/unsafe_binlog_innodb.test @@ -13,4 +13,12 @@ --source include/have_innodb.inc let $engine_type= InnoDB; +SET @save_timeout = @@GLOBAL.innodb_lock_wait_timeout; +SET GLOBAL innodb_lock_wait_timeout = 1; +SET @save_isolation = @@GLOBAL.tx_isolation; +SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED; + --source include/unsafe_binlog.inc + +SET GLOBAL innodb_lock_wait_timeout = @save_timeout; +SET GLOBAL tx_isolation = @save_isolation; diff --git a/mysql-test/main/user_var-binlog.result b/mysql-test/main/user_var-binlog.result index 0a9fe956aee..20d1d8e7da8 100644 --- a/mysql-test/main/user_var-binlog.result +++ b/mysql-test/main/user_var-binlog.result @@ -29,7 +29,7 @@ SET @`a b`:=_latin1 X'68656C6C6F' COLLATE `latin1_swedish_ci`/*!*/; use `test`/*!*/; SET TIMESTAMP=10000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/; SET @@session.sql_mode=1411383296/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/main/user_var.result b/mysql-test/main/user_var.result index b475a8ca60a..7b4c8e0b66e 100644 --- a/mysql-test/main/user_var.result +++ b/mysql-test/main/user_var.result @@ -188,7 +188,7 @@ NULL 2 set @v1=null, @v2=1, @v3=1.1, @v4=now(); select coercibility(@v1),coercibility(@v2),coercibility(@v3),coercibility(@v4); coercibility(@v1) coercibility(@v2) coercibility(@v3) coercibility(@v4) -2 2 2 2 +2 5 5 2 set session @honk=99; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '@honk=99' at line 1 select @@local.max_allowed_packet; diff --git a/mysql-test/main/variables.result b/mysql-test/main/variables.result index 9cf751a1ee5..5a5247cf05e 100644 --- a/mysql-test/main/variables.result +++ b/mysql-test/main/variables.result @@ -162,7 +162,6 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: Note 1003 select @@IDENTITY AS `@@IDENTITY`,last_insert_id() AS `last_insert_id()`,@@identity AS `@@identity` -set big_tables=OFF, big_tables=ON, big_tables=0, big_tables=1, big_tables="OFF", big_tables="ON"; set global concurrent_insert=2; show variables like 'concurrent_insert'; Variable_name Value @@ -188,24 +187,6 @@ set global concurrent_insert=DEFAULT; select @@concurrent_insert; @@concurrent_insert AUTO -set global timed_mutexes=ON; -Warnings: -Warning 1287 '@@timed_mutexes' is deprecated and will be removed in a future release -show variables like 'timed_mutexes'; -Variable_name Value -timed_mutexes ON -select * from information_schema.session_variables where variable_name like 'timed_mutexes'; -VARIABLE_NAME VARIABLE_VALUE -TIMED_MUTEXES ON -set global timed_mutexes=0; -Warnings: -Warning 1287 '@@timed_mutexes' is deprecated and will be removed in a future release -show variables like 'timed_mutexes'; -Variable_name Value -timed_mutexes OFF -select * from information_schema.session_variables where variable_name like 'timed_mutexes'; -VARIABLE_NAME VARIABLE_VALUE -TIMED_MUTEXES OFF set default_storage_engine=MYISAM, default_storage_engine="HEAP", global default_storage_engine="MERGE"; show local variables like 'default_storage_engine'; Variable_name Value @@ -422,18 +403,14 @@ SELECT @@version LIKE 'non-existent'; SELECT @@version_compile_os LIKE 'non-existent'; @@version_compile_os LIKE 'non-existent' 0 -set big_tables=OFFF; -ERROR 42000: Variable 'big_tables' can't be set to the value of 'OFFF' -set big_tables="OFFF"; -ERROR 42000: Variable 'big_tables' can't be set to the value of 'OFFF' set unknown_variable=1; ERROR HY000: Unknown system variable 'unknown_variable' set max_join_size="hello"; ERROR 42000: Incorrect argument type to variable 'max_join_size' set default_storage_engine=UNKNOWN_TABLE_TYPE; ERROR 42000: Unknown storage engine 'UNKNOWN_TABLE_TYPE' -set default_storage_engine=MERGE, big_tables=2; -ERROR 42000: Variable 'big_tables' can't be set to the value of '2' +set default_storage_engine=MERGE, sql_warnings=NULL; +ERROR 42000: Variable 'sql_warnings' can't be set to the value of 'NULL' show local variables like 'default_storage_engine'; Variable_name Value default_storage_engine MEMORY @@ -456,10 +433,9 @@ ERROR HY000: Variable 'myisam_max_sort_file_size' is a GLOBAL variable and shoul set @@SQL_WARNINGS=NULL; ERROR 42000: Variable 'sql_warnings' can't be set to the value of 'NULL' set autocommit=1; -set big_tables=1; -select @@autocommit, @@big_tables; -@@autocommit @@big_tables -1 1 +select @@autocommit; +@@autocommit +1 set global binlog_cache_size=100; Warnings: Warning 1292 Truncated incorrect binlog_cache_size value: '100' @@ -1532,9 +1508,6 @@ SET @@global.max_binlog_cache_size=DEFAULT; SET @@global.max_join_size=DEFAULT; SET @@global.key_buffer_size=@kbs; SET @@global.key_cache_block_size=@kcbs; -select @@max_long_data_size > 0; -@@max_long_data_size > 0 -1 # # Bug#11766424 59527: # Assert in DECIMAL_BIN_SIZE: diff --git a/mysql-test/main/variables.test b/mysql-test/main/variables.test index 846d2665013..495ab101352 100644 --- a/mysql-test/main/variables.test +++ b/mysql-test/main/variables.test @@ -113,8 +113,6 @@ explain extended select last_insert_id(345); select @@IDENTITY,last_insert_id(), @@identity; explain extended select @@IDENTITY,last_insert_id(), @@identity; -set big_tables=OFF, big_tables=ON, big_tables=0, big_tables=1, big_tables="OFF", big_tables="ON"; - set global concurrent_insert=2; show variables like 'concurrent_insert'; select * from information_schema.session_variables where variable_name like 'concurrent_insert'; @@ -127,13 +125,6 @@ select * from information_schema.session_variables where variable_name like 'con set global concurrent_insert=DEFAULT; select @@concurrent_insert; -set global timed_mutexes=ON; -show variables like 'timed_mutexes'; -select * from information_schema.session_variables where variable_name like 'timed_mutexes'; -set global timed_mutexes=0; -show variables like 'timed_mutexes'; -select * from information_schema.session_variables where variable_name like 'timed_mutexes'; - set default_storage_engine=MYISAM, default_storage_engine="HEAP", global default_storage_engine="MERGE"; show local variables like 'default_storage_engine'; select * from information_schema.session_variables where variable_name like 'default_storage_engine'; @@ -241,10 +232,6 @@ SELECT @@version_compile_os LIKE 'non-existent'; # The following should give errors ---error ER_WRONG_VALUE_FOR_VAR -set big_tables=OFFF; ---error ER_WRONG_VALUE_FOR_VAR -set big_tables="OFFF"; --error ER_UNKNOWN_SYSTEM_VARIABLE set unknown_variable=1; --error ER_WRONG_TYPE_FOR_VAR @@ -252,7 +239,7 @@ set max_join_size="hello"; --error ER_UNKNOWN_STORAGE_ENGINE set default_storage_engine=UNKNOWN_TABLE_TYPE; --error ER_WRONG_VALUE_FOR_VAR -set default_storage_engine=MERGE, big_tables=2; +set default_storage_engine=MERGE, sql_warnings=NULL; show local variables like 'default_storage_engine'; --error ER_UNKNOWN_CHARACTER_SET set character_set_client=UNKNOWN_CHARACTER_SET; @@ -276,8 +263,7 @@ set @@SQL_WARNINGS=NULL; # Test setting all variables set autocommit=1; -set big_tables=1; -select @@autocommit, @@big_tables; +select @@autocommit; set global binlog_cache_size=100; set bulk_insert_buffer_size=100; set character set cp1251_koi8; @@ -1264,11 +1250,6 @@ SET @@global.max_join_size=DEFAULT; SET @@global.key_buffer_size=@kbs; SET @@global.key_cache_block_size=@kcbs; -# -# Bug#56976: added new start-up parameter -# -select @@max_long_data_size > 0; - --echo # --echo # Bug#11766424 59527: --echo # Assert in DECIMAL_BIN_SIZE: diff --git a/mysql-test/main/view.result b/mysql-test/main/view.result index b096397f8b2..fa3afd93dfa 100644 --- a/mysql-test/main/view.result +++ b/mysql-test/main/view.result @@ -198,7 +198,7 @@ c d drop view v100; ERROR 42S02: Unknown VIEW: 'test.v100' drop view t1; -ERROR HY000: 'test.t1' is not of type 'VIEW' +ERROR 42S02: Unknown VIEW: 'test.t1' drop table v1; ERROR 42S02: 'test.v1' is a view drop view v1,v2; @@ -2848,7 +2848,11 @@ Tables_in_test t1 CREATE VIEW v1 AS SELECT id FROM t1; DROP VIEW t1,v1; -ERROR HY000: 'test.t1' is not of type 'VIEW' +ERROR 42S02: Unknown VIEW: 'test.t1' +show warnings; +Level Code Message +Warning 1347 'test.t1' is not of type 'VIEW' +Error 4092 Unknown VIEW: 'test.t1' SHOW TABLES; Tables_in_test t1 @@ -5738,8 +5742,7 @@ drop view v60; # # MDEV-15572: view.test, server crash with --big-tables=1 # -set @save_big_tables=@@big_tables; -set big_tables=ON; +set tmp_memory_table_size=0; CREATE TABLE t1 ( f1 int , f2 int , f3 int , f4 int); CREATE TABLE t2 ( f1 int , f2 int , f3 int , f4 int); CREATE VIEW v1 AS @@ -5749,7 +5752,7 @@ SELECT f1, f2, f3, f4 FROM t1; ERROR HY000: Can not modify more than one base table through a join view 'test.v1' drop view v1; drop table t1, t2; -set big_tables=@save_big_tables; +set tmp_memory_table_size=default; # ----------------------------------------------------------------- # -- End of 5.5 tests. # ----------------------------------------------------------------- diff --git a/mysql-test/main/view.test b/mysql-test/main/view.test index 64f65c04dff..11476d5d49e 100644 --- a/mysql-test/main/view.test +++ b/mysql-test/main/view.test @@ -130,7 +130,7 @@ select * from v2; drop view v100; # try to drop table with DROP VIEW --- error ER_WRONG_OBJECT +-- error ER_UNKNOWN_VIEW drop view t1; # try to drop VIEW with DROP TABLE @@ -510,7 +510,7 @@ drop table t1; # create table t1 (a int, b int); create view v1 as select a, sum(b) from t1 group by a; ---error ER_KEY_DOES_NOT_EXITS +--error ER_KEY_DOES_NOT_EXISTS select b from v1 use index (some_index) where b=1; drop view v1; drop table t1; @@ -2730,8 +2730,9 @@ DROP VIEW v2,v1; SHOW TABLES; CREATE VIEW v1 AS SELECT id FROM t1; ---error ER_WRONG_OBJECT +--error ER_UNKNOWN_VIEW DROP VIEW t1,v1; +show warnings; SHOW TABLES; DROP TABLE t1; @@ -3470,11 +3471,11 @@ drop table t1; CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (1),(2); CREATE VIEW v1 AS SELECT * FROM t1; ---error ER_KEY_DOES_NOT_EXITS +--error ER_KEY_DOES_NOT_EXISTS SELECT * FROM v1 USE KEY(non_existant); ---error ER_KEY_DOES_NOT_EXITS +--error ER_KEY_DOES_NOT_EXISTS SELECT * FROM v1 FORCE KEY(non_existant); ---error ER_KEY_DOES_NOT_EXITS +--error ER_KEY_DOES_NOT_EXISTS SELECT * FROM v1 IGNORE KEY(non_existant); DROP VIEW v1; @@ -3629,17 +3630,17 @@ SELECT * FROM t1 USE INDEX (c2) WHERE c2=2; CREATE VIEW v1 AS SELECT c1, c2 FROM t1; SHOW INDEX FROM v1; ---error ER_KEY_DOES_NOT_EXITS +--error ER_KEY_DOES_NOT_EXISTS SELECT * FROM v1 USE INDEX (PRIMARY) WHERE c1=2; ---error ER_KEY_DOES_NOT_EXITS +--error ER_KEY_DOES_NOT_EXISTS SELECT * FROM v1 FORCE INDEX (PRIMARY) WHERE c1=2; ---error ER_KEY_DOES_NOT_EXITS +--error ER_KEY_DOES_NOT_EXISTS SELECT * FROM v1 IGNORE INDEX (PRIMARY) WHERE c1=2; ---error ER_KEY_DOES_NOT_EXITS +--error ER_KEY_DOES_NOT_EXISTS SELECT * FROM v1 USE INDEX (c2) WHERE c2=2; ---error ER_KEY_DOES_NOT_EXITS +--error ER_KEY_DOES_NOT_EXISTS SELECT * FROM v1 FORCE INDEX (c2) WHERE c2=2; ---error ER_KEY_DOES_NOT_EXITS +--error ER_KEY_DOES_NOT_EXISTS SELECT * FROM v1 IGNORE INDEX (c2) WHERE c2=2; DROP VIEW v1; @@ -5628,8 +5629,7 @@ drop view v60; --echo # MDEV-15572: view.test, server crash with --big-tables=1 --echo # -set @save_big_tables=@@big_tables; -set big_tables=ON; +set tmp_memory_table_size=0; # force on-disk tmp table CREATE TABLE t1 ( f1 int , f2 int , f3 int , f4 int); CREATE TABLE t2 ( f1 int , f2 int , f3 int , f4 int); @@ -5642,7 +5642,7 @@ REPLACE INTO v1 (f1, f2, f3, f4) drop view v1; drop table t1, t2; -set big_tables=@save_big_tables; +set tmp_memory_table_size=default; --echo # ----------------------------------------------------------------- --echo # -- End of 5.5 tests. diff --git a/mysql-test/main/view_grant.result b/mysql-test/main/view_grant.result index 954b57db768..f091d4de2d1 100644 --- a/mysql-test/main/view_grant.result +++ b/mysql-test/main/view_grant.result @@ -22,7 +22,7 @@ grant create view,select on test.* to mysqltest_1@localhost; connect user1,localhost,mysqltest_1,,test; connection user1; create definer=root@localhost view v1 as select * from mysqltest.t1; -ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation +ERROR 42000: Access denied; you need (at least one of) the SUPER, SET USER privilege(s) for this operation create view v1 as select * from mysqltest.t1; alter view v1 as select * from mysqltest.t1; ERROR 42000: DROP command denied to user 'mysqltest_1'@'localhost' for table 'v1' @@ -833,12 +833,30 @@ connect def,localhost,def_17254,,db17254; connection def; CREATE VIEW v1 AS SELECT * FROM t1; connection root; +GRANT SELECT ON db17254.v1 TO inv_17254@localhost; DROP USER def_17254@localhost; connect inv,localhost,inv_17254,,db17254; connection inv; -for a user +for a user without SET USER SELECT * FROM v1; -ERROR 42000: SELECT command denied to user 'inv_17254'@'localhost' for table 'v1' +ERROR 28000: Access denied for user 'inv_17254'@'localhost' (using password: NO) +disconnect inv; +connection root; +GRANT SET USER ON *.* TO inv_17254@localhost; +connect inv2,localhost,inv_17254,,db17254; +connection inv2; +SHOW GRANTS; +Grants for inv_17254@localhost +GRANT SET USER ON *.* TO `inv_17254`@`localhost` +GRANT SELECT ON `db17254`.`v1` TO `inv_17254`@`localhost` +GRANT SELECT ON `db17254`.`t1` TO `inv_17254`@`localhost` +SELECT CURRENT_USER, SYSTEM_USER(), USER(); +CURRENT_USER SYSTEM_USER() USER() +inv_17254@localhost inv_17254@localhost inv_17254@localhost +for a user with SET USER +SELECT * FROM v1; +ERROR HY000: The user specified as a definer ('def_17254'@'localhost') does not exist +disconnect inv2; connection root; for a superuser SELECT * FROM v1; @@ -846,7 +864,6 @@ ERROR HY000: The user specified as a definer ('def_17254'@'localhost') does not DROP USER inv_17254@localhost; DROP DATABASE db17254; disconnect def; -disconnect inv; DROP DATABASE IF EXISTS mysqltest_db1; DROP DATABASE IF EXISTS mysqltest_db2; DROP USER mysqltest_u1; @@ -915,7 +932,7 @@ ERROR 42000: CREATE VIEW command denied to user 'u26813'@'localhost' for table ' ALTER VIEW v2 AS SELECT f2 FROM t1; ERROR 42000: DROP command denied to user 'u26813'@'localhost' for table 'v2' ALTER VIEW v3 AS SELECT f2 FROM t1; -ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation +ERROR 42000: Access denied; you need (at least one of) the SUPER, SET USER privilege(s) for this operation connection root; SHOW CREATE VIEW v3; View Create View character_set_client collation_connection @@ -943,9 +960,9 @@ GRANT SELECT, DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v2 TO u29908_2@loc GRANT SELECT ON mysqltest_29908.t1 TO u29908_2@localhost; connect u2,localhost,u29908_2,,mysqltest_29908; ALTER VIEW v1 AS SELECT f2 FROM t1; -ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation +ERROR 42000: Access denied; you need (at least one of) the SUPER, SET USER privilege(s) for this operation ALTER VIEW v2 AS SELECT f2 FROM t1; -ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation +ERROR 42000: Access denied; you need (at least one of) the SUPER, SET USER privilege(s) for this operation SHOW CREATE VIEW v2; View Create View character_set_client collation_connection v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f1` AS `f1` from `t1` latin1 latin1_swedish_ci diff --git a/mysql-test/main/view_grant.test b/mysql-test/main/view_grant.test index cc17cae58d1..c9bb9569145 100644 --- a/mysql-test/main/view_grant.test +++ b/mysql-test/main/view_grant.test @@ -987,13 +987,27 @@ connection def; CREATE VIEW v1 AS SELECT * FROM t1; connection root; +GRANT SELECT ON db17254.v1 TO inv_17254@localhost; DROP USER def_17254@localhost; connect (inv,localhost,inv_17254,,db17254); connection inv; ---echo for a user ---error ER_TABLEACCESS_DENIED_ERROR +--echo for a user without SET USER +--error ER_ACCESS_DENIED_ERROR +SELECT * FROM v1; +disconnect inv; + +connection root; +GRANT SET USER ON *.* TO inv_17254@localhost; + +connect (inv2,localhost,inv_17254,,db17254); +connection inv2; +SHOW GRANTS; +SELECT CURRENT_USER, SYSTEM_USER(), USER(); +--echo for a user with SET USER +--error ER_NO_SUCH_USER SELECT * FROM v1; +disconnect inv2; connection root; --echo for a superuser @@ -1002,7 +1016,6 @@ SELECT * FROM v1; DROP USER inv_17254@localhost; DROP DATABASE db17254; disconnect def; -disconnect inv; # diff --git a/mysql-test/main/warnings_debug.result b/mysql-test/main/warnings_debug.result index 3a9d8225795..4d815767c14 100644 --- a/mysql-test/main/warnings_debug.result +++ b/mysql-test/main/warnings_debug.result @@ -5,8 +5,12 @@ SET SESSION debug_dbug="+d,warn_during_ha_commit_trans"; INSERT INTO t1 VALUES (1); Warnings: Warning 1196 Some non-transactional changed tables couldn't be rolled back +Warning 1196 Some non-transactional changed tables couldn't be rolled back +Warning 1196 Some non-transactional changed tables couldn't be rolled back SHOW WARNINGS; Level Code Message Warning 1196 Some non-transactional changed tables couldn't be rolled back -drop table t1; +Warning 1196 Some non-transactional changed tables couldn't be rolled back +Warning 1196 Some non-transactional changed tables couldn't be rolled back SET debug_dbug= @saved_dbug; +drop table t1; diff --git a/mysql-test/main/warnings_debug.test b/mysql-test/main/warnings_debug.test index 6605daf875d..4d084b1f52c 100644 --- a/mysql-test/main/warnings_debug.test +++ b/mysql-test/main/warnings_debug.test @@ -17,5 +17,5 @@ INSERT INTO t1 VALUES (1); # packet. Show the warnings manually also. SHOW WARNINGS; -drop table t1; SET debug_dbug= @saved_dbug; +drop table t1; diff --git a/mysql-test/main/win.result b/mysql-test/main/win.result index d4a5ac63216..095936f8b82 100644 --- a/mysql-test/main/win.result +++ b/mysql-test/main/win.result @@ -1742,8 +1742,7 @@ drop table t1; # create table t1(a int); insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); -set @tmp=@@big_tables; -set big_tables=1; +set tmp_memory_table_size=0; select rank() over (order by a) from t1; rank() over (order by a) 1 @@ -1756,7 +1755,7 @@ rank() over (order by a) 8 9 10 -set big_tables=@tmp; +set tmp_memory_table_size=default; drop table t1; # # Check if "ORDER BY window_func" works @@ -3763,7 +3762,8 @@ ANALYZE "r_total_time_ms": "REPLACED", "r_used_priority_queue": false, "r_output_rows": 3, - "r_buffer_size": "REPLACED" + "r_buffer_size": "REPLACED", + "r_sort_mode": "sort_key,rowid" } }, "temporary_table": { @@ -3773,7 +3773,8 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, - "r_total_time_ms": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", "filtered": 100, "r_filtered": 100 } diff --git a/mysql-test/main/win.test b/mysql-test/main/win.test index 2b3ce469990..43133386461 100644 --- a/mysql-test/main/win.test +++ b/mysql-test/main/win.test @@ -1068,10 +1068,9 @@ drop table t1; --echo # create table t1(a int); insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); -set @tmp=@@big_tables; -set big_tables=1; +set tmp_memory_table_size=0; # force on-disk tmp table select rank() over (order by a) from t1; -set big_tables=@tmp; +set tmp_memory_table_size=default; drop table t1; --echo # diff --git a/mysql-test/main/win_percentile.result b/mysql-test/main/win_percentile.result index a2ca775fcfb..09c2c4fc5de 100644 --- a/mysql-test/main/win_percentile.result +++ b/mysql-test/main/win_percentile.result @@ -99,7 +99,14 @@ Tatiana select score, percentile_cont(0.5) within group(order by name) over (partition by score) from t1; ERROR HY000: Numeric datatype is required for percentile_cont function select score, percentile_disc(0.5) within group(order by name) over (partition by score) from t1; -ERROR HY000: Numeric datatype is required for percentile_disc function +score percentile_disc(0.5) within group(order by name) over (partition by score) +3.0000 Chun +3.0000 Chun +4.0000 Tata +4.0000 Tata +4.0000 Tata +7.0000 Chun +7.0000 Chun #parameter value should be in the range of [0,1] select percentile_disc(1.5) within group(order by score) over (partition by name) from t1; ERROR HY000: Argument to the percentile_disc function does not belong to the range [0,1] @@ -452,7 +459,7 @@ Lord of the Ladybirds 30000000000.00 Lord of the Ladybirds 30000000000.00 DROP TABLE t2, t1; # -# MDEV-20272 PERCENTILE_DISC() crashes on a temporal type input +# MDEV-20280 PERCENTILE_DISC() rejects temporal and string input # CREATE OR REPLACE TABLE t1 (name CHAR(30), star_rating TIME); INSERT INTO t1 VALUES ('Lord of the Ladybirds', 5); @@ -463,5 +470,28 @@ INSERT INTO t1 VALUES ('Lady of the Flies', 5); SELECT name, PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY star_rating) OVER (PARTITION BY name) AS pc FROM t1; -ERROR HY000: Numeric datatype is required for percentile_disc function +name pc +Lady of the Flies 00:00:02 +Lady of the Flies 00:00:02 +Lady of the Flies 00:00:02 +Lord of the Ladybirds 00:00:03 +Lord of the Ladybirds 00:00:03 +SELECT name, PERCENTILE_DISC(0) +WITHIN GROUP (ORDER BY star_rating) +OVER (PARTITION BY name) AS pc FROM t1; +name pc +Lady of the Flies 00:00:01 +Lady of the Flies 00:00:01 +Lady of the Flies 00:00:01 +Lord of the Ladybirds 00:00:03 +Lord of the Ladybirds 00:00:03 +SELECT name, PERCENTILE_DISC(1) +WITHIN GROUP (ORDER BY star_rating) +OVER (PARTITION BY name) AS pc FROM t1; +name pc +Lady of the Flies 00:00:05 +Lady of the Flies 00:00:05 +Lady of the Flies 00:00:05 +Lord of the Ladybirds 00:00:05 +Lord of the Ladybirds 00:00:05 DROP TABLE t1; diff --git a/mysql-test/main/win_percentile.test b/mysql-test/main/win_percentile.test index 8705be123ff..e981dc62c41 100644 --- a/mysql-test/main/win_percentile.test +++ b/mysql-test/main/win_percentile.test @@ -61,7 +61,7 @@ select name from t1 a where (select percentile_disc(0.5) within group (order by --echo #disallowed fields in order by --error ER_WRONG_TYPE_FOR_PERCENTILE_FUNC select score, percentile_cont(0.5) within group(order by name) over (partition by score) from t1; ---error ER_WRONG_TYPE_FOR_PERCENTILE_FUNC + select score, percentile_disc(0.5) within group(order by name) over (partition by score) from t1; --echo #parameter value should be in the range of [0,1] @@ -212,7 +212,7 @@ DROP TABLE t2, t1; --echo # ---echo # MDEV-20272 PERCENTILE_DISC() crashes on a temporal type input +--echo # MDEV-20280 PERCENTILE_DISC() rejects temporal and string input --echo # CREATE OR REPLACE TABLE t1 (name CHAR(30), star_rating TIME); @@ -221,8 +221,13 @@ INSERT INTO t1 VALUES ('Lord of the Ladybirds', 3); INSERT INTO t1 VALUES ('Lady of the Flies', 1); INSERT INTO t1 VALUES ('Lady of the Flies', 2); INSERT INTO t1 VALUES ('Lady of the Flies', 5); ---error ER_WRONG_TYPE_FOR_PERCENTILE_FUNC SELECT name, PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY star_rating) OVER (PARTITION BY name) AS pc FROM t1; +SELECT name, PERCENTILE_DISC(0) + WITHIN GROUP (ORDER BY star_rating) + OVER (PARTITION BY name) AS pc FROM t1; +SELECT name, PERCENTILE_DISC(1) + WITHIN GROUP (ORDER BY star_rating) + OVER (PARTITION BY name) AS pc FROM t1; DROP TABLE t1; diff --git a/mysql-test/main/xa.result b/mysql-test/main/xa.result index 725dc99bfce..75f32a1a0aa 100644 --- a/mysql-test/main/xa.result +++ b/mysql-test/main/xa.result @@ -51,7 +51,7 @@ formatID gtrid_length bqual_length data 11 5 5 testb 0@P` 1 5 5 testatestb xa commit 'testb',0x2030405060,11; -ERROR XAE04: XAER_NOTA: Unknown XID +ERROR XAE09: XAER_OUTSIDE: Some work is done outside global transaction xa rollback 'testa','testb'; xa start 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1 @@ -59,6 +59,9 @@ select * from t1; a 20 disconnect con1; +xa rollback 'testb',0x2030405060,11; +xa recover; +formatID gtrid_length bqual_length data connection default; xa start 'tr1'; insert t1 values (40); @@ -372,6 +375,61 @@ DROP TABLE t1; disconnect con1; connection default; # +# MDEV-21766 - Forbid XID with empty 'gtrid' +# +CREATE TABLE t1(a INT) ENGINE=InnoDB; +XA BEGIN ''; +ERROR XAE05: XAER_INVAL: Invalid arguments (or unsupported command) +XA BEGIN '8bytes1x8bytes2x8bytes3x8bytes4x8bytes5x8bytes6x8bytes7x8bytes8x', +'8bytes1x8bytes2x8bytes3x8bytes4x8bytes5x8bytes6x8bytes7x8bytes8x'; +INSERT INTO t1 VALUES(1); +XA END '8bytes1x8bytes2x8bytes3x8bytes4x8bytes5x8bytes6x8bytes7x8bytes8x', +'8bytes1x8bytes2x8bytes3x8bytes4x8bytes5x8bytes6x8bytes7x8bytes8x'; +XA PREPARE '8bytes1x8bytes2x8bytes3x8bytes4x8bytes5x8bytes6x8bytes7x8bytes8x', +'8bytes1x8bytes2x8bytes3x8bytes4x8bytes5x8bytes6x8bytes7x8bytes8x'; +XA ROLLBACK '8bytes1x8bytes2x8bytes3x8bytes4x8bytes5x8bytes6x8bytes7x8bytes8x', +'8bytes1x8bytes2x8bytes3x8bytes4x8bytes5x8bytes6x8bytes7x8bytes8x'; +SET NAMES utf8; +XA BEGIN 'Я_упала_Ñ_Ñеновала_тормозила_головой'; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1 +XA BEGIN 'Я_упaлa_c_Ñеновала_тормозила_головой'; +XA END 'Я_упaлa_c_Ñеновала_тормозила_головой'; +XA PREPARE 'Я_упaлa_c_Ñеновала_тормозила_головой'; +XA ROLLBACK 'Я_упaлa_c_Ñеновала_тормозила_головой'; +SET NAMES default; +DROP TABLE t1; +# +# MDEV-21659 XA rollback foreign_xid is allowed inside active XA +# MDEV-21854 - xa commit one phase for already prepared transaction +# must always error out +# +BEGIN; +XA COMMIT 'unknown'; +ERROR XAE09: XAER_OUTSIDE: Some work is done outside global transaction +XA COMMIT 'unknown' ONE PHASE; +ERROR XAE09: XAER_OUTSIDE: Some work is done outside global transaction +BEGIN; +XA ROLLBACK 'unknown'; +ERROR XAE09: XAER_OUTSIDE: Some work is done outside global transaction +ROLLBACK; +XA START 'xid1'; +XA COMMIT 'unknown'; +ERROR XAE09: XAER_OUTSIDE: Some work is done outside global transaction +XA COMMIT 'unknown' ONE PHASE; +ERROR XAE09: XAER_OUTSIDE: Some work is done outside global transaction +XA ROLLBACK 'unknown'; +ERROR XAE09: XAER_OUTSIDE: Some work is done outside global transaction +XA END 'xid1'; +XA PREPARE 'xid1'; +XA COMMIT 'xid1' ONE PHASE; +ERROR XAE05: XAER_INVAL: Invalid arguments (or unsupported command) +XA ROLLBACK 'xid1'; +# +# MDEV-21856 - xid_t::formatID has to be constrained to 4 byte size +# +XA START 'gtrid', 'bqual', 0x80000000; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '0x80000000' at line 1 +# # XA states and SHOW commands # create table t1 (pk int primary key) engine=innodb; @@ -425,3 +483,67 @@ XA ROLLBACK 'xid'; # # End of 10.3 tests # +# +# Start of 10.5 tests +# +# MDEV-7974 related +# Check XA state when lock_wait_timeout happens +# More tests added to flush_read_lock.test +connect con_tmp,localhost,root,,; +set session lock_wait_timeout=1; +create table asd (a int) engine=innodb; +xa start 'test1'; +insert into asd values(1); +xa end 'test1'; +connection default; +flush table with read lock; +connection con_tmp; +# PREPARE error will do auto rollback. +xa prepare 'test1'; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +show errors; +Level Code Message +Error 1205 Lock wait timeout exceeded; try restarting transaction +Error 1402 XA_RBROLLBACK: Transaction branch was rolled back +connection default; +unlock tables; +connection con_tmp; +xa start 'test1'; +insert into asd values(1); +xa end 'test1'; +xa prepare 'test1'; +connection default; +flush tables with read lock; +connection con_tmp; +# LOCK error during ROLLBACK will not alter transaction state. +xa rollback 'test1'; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +show errors; +Level Code Message +Error 1205 Lock wait timeout exceeded; try restarting transaction +Error 1401 XAER_RMERR: Fatal error occurred in the transaction branch - check your data for consistency +xa recover; +formatID gtrid_length bqual_length data +1 5 0 test1 +# LOCK error during COMMIT will not alter transaction state. +xa commit 'test1'; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +show errors; +Level Code Message +Error 1205 Lock wait timeout exceeded; try restarting transaction +Error 1401 XAER_RMERR: Fatal error occurred in the transaction branch - check your data for consistency +xa recover; +formatID gtrid_length bqual_length data +1 5 0 test1 +connection default; +unlock tables; +connection con_tmp; +xa rollback 'test1'; +xa recover; +formatID gtrid_length bqual_length data +drop table asd; +disconnect con_tmp; +connection default; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/xa.test b/mysql-test/main/xa.test index 5f122a215b5..408c7e01c9d 100644 --- a/mysql-test/main/xa.test +++ b/mysql-test/main/xa.test @@ -72,7 +72,7 @@ xa prepare 'testa','testb'; xa recover; ---error ER_XAER_NOTA +--error ER_XAER_OUTSIDE xa commit 'testb',0x2030405060,11; xa rollback 'testa','testb'; @@ -82,6 +82,8 @@ xa start 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'; select * from t1; disconnect con1; --source include/wait_until_count_sessions.inc +xa rollback 'testb',0x2030405060,11; +xa recover; connection default; @@ -515,6 +517,69 @@ DROP TABLE t1; --disconnect con1 connection default; +--echo # +--echo # MDEV-21766 - Forbid XID with empty 'gtrid' +--echo # +CREATE TABLE t1(a INT) ENGINE=InnoDB; + +--error ER_XAER_INVAL +XA BEGIN ''; + +XA BEGIN '8bytes1x8bytes2x8bytes3x8bytes4x8bytes5x8bytes6x8bytes7x8bytes8x', + '8bytes1x8bytes2x8bytes3x8bytes4x8bytes5x8bytes6x8bytes7x8bytes8x'; +INSERT INTO t1 VALUES(1); +XA END '8bytes1x8bytes2x8bytes3x8bytes4x8bytes5x8bytes6x8bytes7x8bytes8x', + '8bytes1x8bytes2x8bytes3x8bytes4x8bytes5x8bytes6x8bytes7x8bytes8x'; +XA PREPARE '8bytes1x8bytes2x8bytes3x8bytes4x8bytes5x8bytes6x8bytes7x8bytes8x', + '8bytes1x8bytes2x8bytes3x8bytes4x8bytes5x8bytes6x8bytes7x8bytes8x'; +XA ROLLBACK '8bytes1x8bytes2x8bytes3x8bytes4x8bytes5x8bytes6x8bytes7x8bytes8x', + '8bytes1x8bytes2x8bytes3x8bytes4x8bytes5x8bytes6x8bytes7x8bytes8x'; + +SET NAMES utf8; +--error ER_PARSE_ERROR +XA BEGIN 'Я_упала_Ñ_Ñеновала_тормозила_головой'; # 36 characters, 67 bytes +XA BEGIN 'Я_упaлa_c_Ñеновала_тормозила_головой'; # 36 characters, 64 bytes +XA END 'Я_упaлa_c_Ñеновала_тормозила_головой'; +XA PREPARE 'Я_упaлa_c_Ñеновала_тормозила_головой'; +XA ROLLBACK 'Я_упaлa_c_Ñеновала_тормозила_головой'; +SET NAMES default; + +DROP TABLE t1; +--echo # +--echo # MDEV-21659 XA rollback foreign_xid is allowed inside active XA +--echo # MDEV-21854 - xa commit one phase for already prepared transaction +--echo # must always error out +--echo # +BEGIN; +--error ER_XAER_OUTSIDE +XA COMMIT 'unknown'; +--error ER_XAER_OUTSIDE +XA COMMIT 'unknown' ONE PHASE; +BEGIN; +--error ER_XAER_OUTSIDE +XA ROLLBACK 'unknown'; +ROLLBACK; + +XA START 'xid1'; +--error ER_XAER_OUTSIDE +XA COMMIT 'unknown'; +--error ER_XAER_OUTSIDE +XA COMMIT 'unknown' ONE PHASE; +--error ER_XAER_OUTSIDE +XA ROLLBACK 'unknown'; +XA END 'xid1'; +XA PREPARE 'xid1'; +--error ER_XAER_INVAL +XA COMMIT 'xid1' ONE PHASE; +XA ROLLBACK 'xid1'; + + +--echo # +--echo # MDEV-21856 - xid_t::formatID has to be constrained to 4 byte size +--echo # +--error ER_PARSE_ERROR +XA START 'gtrid', 'bqual', 0x80000000; + --source include/wait_until_count_sessions.inc --echo # @@ -578,3 +643,58 @@ XA ROLLBACK 'xid'; --echo # --echo # End of 10.3 tests --echo # + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # MDEV-7974 related +--echo # Check XA state when lock_wait_timeout happens +--echo # More tests added to flush_read_lock.test +connect (con_tmp,localhost,root,,); +set session lock_wait_timeout=1; +create table asd (a int) engine=innodb; +xa start 'test1'; +insert into asd values(1); +xa end 'test1'; +connection default; +flush table with read lock; +connection con_tmp; +--echo # PREPARE error will do auto rollback. +--ERROR ER_LOCK_WAIT_TIMEOUT +xa prepare 'test1'; +show errors; +connection default; +unlock tables; + +connection con_tmp; +xa start 'test1'; +insert into asd values(1); +xa end 'test1'; +xa prepare 'test1'; +connection default; +flush tables with read lock; +connection con_tmp; +--echo # LOCK error during ROLLBACK will not alter transaction state. +--ERROR ER_LOCK_WAIT_TIMEOUT +xa rollback 'test1'; +show errors; +xa recover; +--echo # LOCK error during COMMIT will not alter transaction state. +--ERROR ER_LOCK_WAIT_TIMEOUT +xa commit 'test1'; +show errors; +xa recover; +connection default; +unlock tables; +connection con_tmp; +xa rollback 'test1'; +xa recover; +drop table asd; +disconnect con_tmp; +--source include/wait_until_disconnected.inc +connection default; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/xa_binlog.result b/mysql-test/main/xa_binlog.result index 619a6e08b20..a272570aac1 100644 --- a/mysql-test/main/xa_binlog.result +++ b/mysql-test/main/xa_binlog.result @@ -18,15 +18,68 @@ a 1 2 3 -SHOW BINLOG EVENTS LIMIT 3,9; +DROP TABLE t1; +CREATE TABLE t1 (a INT) ENGINE=Aria; +INSERT INTO t1 VALUES (1),(2); +XA BEGIN 'x'; +DELETE FROM t1; +XA END 'x'; +XA PREPARE 'x'; +Warnings: +Warning 1030 Got error 131 "Command not supported by the engine" from storage engine Aria +XA COMMIT 'x'; +SELECT * from t1; +a +XA BEGIN 'x'; +INSERT INTO t1 VALUES (3),(4); +XA END 'x'; +XA PREPARE 'x'; +Warnings: +Warning 1030 Got error 131 "Command not supported by the engine" from storage engine Aria +XA ROLLBACK 'x'; +Warnings: +Warning 1196 Some non-transactional changed tables couldn't be rolled back +SELECT * from t1; +a +3 +4 +DROP TABLE t1; +SHOW BINLOG EVENTS LIMIT 3,100; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid 1 # BEGIN GTID #-#-# +master-bin.000001 # Gtid 1 # XA START X'786174657374',X'',1 GTID #-#-# master-bin.000001 # Query 1 # use `test`; INSERT INTO t1 VALUES (1) -master-bin.000001 # Query 1 # COMMIT +master-bin.000001 # Query 1 # XA END X'786174657374',X'',1 +master-bin.000001 # XA_prepare 1 # XA PREPARE X'786174657374',X'',1 +master-bin.000001 # Gtid 1 # GTID #-#-# +master-bin.000001 # Query 1 # XA COMMIT X'786174657374',X'',1 master-bin.000001 # Gtid 1 # BEGIN GTID #-#-# master-bin.000001 # Query 1 # use `test`; INSERT INTO t1 VALUES (2) -master-bin.000001 # Query 1 # COMMIT +master-bin.000001 # Xid 1 # COMMIT /* xid=XX */ master-bin.000001 # Gtid 1 # BEGIN GTID #-#-# master-bin.000001 # Query 1 # use `test`; INSERT INTO t1 VALUES (3) master-bin.000001 # Xid 1 # COMMIT /* xid=XX */ -DROP TABLE t1; +master-bin.000001 # Gtid 1 # GTID #-#-# +master-bin.000001 # Query 1 # use `test`; DROP TABLE `t1` /* generated by server */ +master-bin.000001 # Gtid 1 # GTID #-#-# +master-bin.000001 # Query 1 # use `test`; CREATE TABLE t1 (a INT) ENGINE=Aria +master-bin.000001 # Gtid 1 # BEGIN GTID #-#-# +master-bin.000001 # Query 1 # use `test`; INSERT INTO t1 VALUES (1),(2) +master-bin.000001 # Query 1 # COMMIT +master-bin.000001 # Gtid 1 # BEGIN GTID #-#-# +master-bin.000001 # Query 1 # use `test`; DELETE FROM t1 +master-bin.000001 # Query 1 # COMMIT +master-bin.000001 # Gtid 1 # XA START X'78',X'',1 GTID #-#-# +master-bin.000001 # Query 1 # XA END X'78',X'',1 +master-bin.000001 # XA_prepare 1 # XA PREPARE X'78',X'',1 +master-bin.000001 # Gtid 1 # GTID #-#-# +master-bin.000001 # Query 1 # XA COMMIT X'78',X'',1 +master-bin.000001 # Gtid 1 # BEGIN GTID #-#-# +master-bin.000001 # Query 1 # use `test`; INSERT INTO t1 VALUES (3),(4) +master-bin.000001 # Query 1 # COMMIT +master-bin.000001 # Gtid 1 # XA START X'78',X'',1 GTID #-#-# +master-bin.000001 # Query 1 # XA END X'78',X'',1 +master-bin.000001 # XA_prepare 1 # XA PREPARE X'78',X'',1 +master-bin.000001 # Gtid 1 # GTID #-#-# +master-bin.000001 # Query 1 # XA ROLLBACK X'78',X'',1 +master-bin.000001 # Gtid 1 # GTID #-#-# +master-bin.000001 # Query 1 # use `test`; DROP TABLE `t1` /* generated by server */ diff --git a/mysql-test/main/xa_binlog.test b/mysql-test/main/xa_binlog.test index ecbf1f4f066..1343fa2aaee 100644 --- a/mysql-test/main/xa_binlog.test +++ b/mysql-test/main/xa_binlog.test @@ -24,9 +24,38 @@ INSERT INTO t1 VALUES (3); COMMIT; SELECT * FROM t1 ORDER BY a; +DROP TABLE t1; ---replace_column 2 # 5 # ---replace_regex /xid=[0-9]+/xid=XX/ /GTID [0-9]+-[0-9]+-[0-9]+/GTID #-#-#/ -SHOW BINLOG EVENTS LIMIT 3,9; +# +# MDEV-22607 Assertion `ha_info->ht() != binlog_hton' failed in +# MYSQL_BIN_LOG::unlog_xa_prepare +# + +CREATE TABLE t1 (a INT) ENGINE=Aria; +INSERT INTO t1 VALUES (1),(2); +XA BEGIN 'x'; +DELETE FROM t1; +XA END 'x'; +XA PREPARE 'x'; + +# Cleanup +XA COMMIT 'x'; + +SELECT * from t1; +XA BEGIN 'x'; +INSERT INTO t1 VALUES (3),(4); +XA END 'x'; +XA PREPARE 'x'; +XA ROLLBACK 'x'; + +SELECT * from t1; DROP TABLE t1; + +# +# Time to check the log +# + +--replace_column 2 # 5 # +--replace_regex /xid=[0-9]+/xid=XX/ /GTID [0-9]+-[0-9]+-[0-9]+/GTID #-#-#/ +SHOW BINLOG EVENTS LIMIT 3,100; diff --git a/mysql-test/main/xa_prepared_binlog_off-master.opt b/mysql-test/main/xa_prepared_binlog_off-master.opt new file mode 100644 index 00000000000..789275fa25e --- /dev/null +++ b/mysql-test/main/xa_prepared_binlog_off-master.opt @@ -0,0 +1 @@ +--skip-log-bin diff --git a/mysql-test/main/xa_prepared_binlog_off.result b/mysql-test/main/xa_prepared_binlog_off.result new file mode 100644 index 00000000000..ca19f6cdfaf --- /dev/null +++ b/mysql-test/main/xa_prepared_binlog_off.result @@ -0,0 +1,1044 @@ +call mtr.add_suppression("You need to use --log-bin to make --log-slave-updates work."); +connection default; +CREATE VIEW v_processlist as SELECT * FROM performance_schema.threads where type = 'FOREGROUND'; +call mtr.add_suppression("Found 10 prepared XA transactions"); +CREATE TABLE t (a INT) ENGINE=innodb; +connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@sql_log_bin = OFF; +CREATE TEMPORARY TABLE tmp1 (a int) ENGINE=innodb; +XA START 'trx1tmp'; +INSERT INTO tmp1 SET a=1; +XA END 'trx1tmp'; +XA PREPARE 'trx1tmp'; +connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@sql_log_bin = OFF; +CREATE TEMPORARY TABLE tmp1 (a int) ENGINE=innodb; +XA START 'trx2tmp'; +INSERT INTO tmp1 SET a=1; +XA END 'trx2tmp'; +XA PREPARE 'trx2tmp'; +connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@sql_log_bin = OFF; +CREATE TEMPORARY TABLE tmp1 (a int) ENGINE=innodb; +XA START 'trx3tmp'; +INSERT INTO tmp1 SET a=1; +XA END 'trx3tmp'; +XA PREPARE 'trx3tmp'; +connection default; +XA COMMIT 'trx1tmp'; +ERROR XAE04: XAER_NOTA: Unknown XID +XA ROLLBACK 'trx1tmp'; +ERROR XAE04: XAER_NOTA: Unknown XID +XA START 'trx1tmp'; +ERROR XAE08: XAER_DUPID: The XID already exists +connection default; +*** 3 prepared transactions must be in the list *** +XA RECOVER; +formatID gtrid_length bqual_length data +1 LEN1 LEN2 TRX_N +1 LEN1 LEN2 TRX_N +1 LEN1 LEN2 TRX_N +connection conn1tmp; +disconnect conn1tmp; +connection default; +XA COMMIT 'trx1tmp'; +KILL connection CONN_ID; +XA COMMIT 'trx3tmp'; +connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'trx1ro'; +SELECT * from t ORDER BY a; +a +XA END 'trx1ro'; +XA PREPARE 'trx1ro'; +connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'trx2ro'; +SELECT * from t ORDER BY a; +a +XA END 'trx2ro'; +XA PREPARE 'trx2ro'; +connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'trx3ro'; +SELECT * from t ORDER BY a; +a +XA END 'trx3ro'; +XA PREPARE 'trx3ro'; +connection default; +*** 4 prepared transactions must be in the list *** +XA RECOVER; +formatID gtrid_length bqual_length data +1 LEN1 LEN2 TRX_N +1 LEN1 LEN2 TRX_N +1 LEN1 LEN2 TRX_N +1 LEN1 LEN2 TRX_N +connection conn1ro; +disconnect conn1ro; +connection default; +XA ROLLBACK 'trx1ro'; +KILL connection CONN_ID; +XA ROLLBACK 'trx3ro'; +connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'trx1empty'; +XA END 'trx1empty'; +XA PREPARE 'trx1empty'; +connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'trx2empty'; +XA END 'trx2empty'; +XA PREPARE 'trx2empty'; +connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'trx3empty'; +XA END 'trx3empty'; +XA PREPARE 'trx3empty'; +connection default; +*** 5 prepared transactions must be in the list *** +XA RECOVER; +formatID gtrid_length bqual_length data +1 LEN1 LEN2 TRX_N +1 LEN1 LEN2 TRX_N +1 LEN1 LEN2 TRX_N +1 LEN1 LEN2 TRX_N +1 LEN1 LEN2 TRX_N +connection conn1empty; +disconnect conn1empty; +connection default; +XA COMMIT 'trx1empty'; +KILL connection CONN_ID; +XA COMMIT 'trx3empty'; +connect conn1$type, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'trx1unprepared'; +INSERT INTO t set a=0; +XA END 'trx1unprepared'; +INSERT INTO t set a=0; +ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the IDLE state +XA START 'trx1unprepared'; +ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the IDLE state +XA START 'trx1unprepared'; +ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the IDLE state +disconnect conn1unprepared; +connection default; +XA COMMIT 'trx1unprepared'; +ERROR XAE04: XAER_NOTA: Unknown XID +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +XA START 'trx_0'; +INSERT INTO t SET a=0; +XA END 'trx_0'; +XA PREPARE 'trx_0'; +disconnect conn0; +connection default; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +SET @@binlog_format = ROW; +XA START 'trx_1'; +INSERT INTO t SET a=1; +XA END 'trx_1'; +XA PREPARE 'trx_1'; +disconnect conn1; +connection default; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +XA START 'trx_2'; +INSERT INTO t SET a=2; +XA END 'trx_2'; +XA PREPARE 'trx_2'; +disconnect conn2; +connection default; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +SET @@binlog_format = ROW; +XA START 'trx_3'; +INSERT INTO t SET a=3; +XA END 'trx_3'; +XA PREPARE 'trx_3'; +disconnect conn3; +connection default; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +XA START 'trx_4'; +INSERT INTO t SET a=4; +XA END 'trx_4'; +XA PREPARE 'trx_4'; +disconnect conn4; +connection default; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +SET @@binlog_format = ROW; +XA START 'trx_5'; +INSERT INTO t SET a=5; +XA END 'trx_5'; +XA PREPARE 'trx_5'; +disconnect conn5; +connection default; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +XA START 'trx_6'; +INSERT INTO t SET a=6; +XA END 'trx_6'; +XA PREPARE 'trx_6'; +disconnect conn6; +connection default; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +SET @@binlog_format = ROW; +XA START 'trx_7'; +INSERT INTO t SET a=7; +XA END 'trx_7'; +XA PREPARE 'trx_7'; +disconnect conn7; +connection default; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +XA START 'trx_8'; +INSERT INTO t SET a=8; +XA END 'trx_8'; +XA PREPARE 'trx_8'; +disconnect conn8; +connection default; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +SET @@binlog_format = ROW; +XA START 'trx_9'; +INSERT INTO t SET a=9; +XA END 'trx_9'; +XA PREPARE 'trx_9'; +disconnect conn9; +connection default; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +XA START 'trx_10'; +INSERT INTO t SET a=10; +XA END 'trx_10'; +XA PREPARE 'trx_10'; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +SET @@binlog_format = ROW; +XA START 'trx_11'; +INSERT INTO t SET a=11; +XA END 'trx_11'; +XA PREPARE 'trx_11'; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +XA START 'trx_12'; +INSERT INTO t SET a=12; +XA END 'trx_12'; +XA PREPARE 'trx_12'; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +SET @@binlog_format = ROW; +XA START 'trx_13'; +INSERT INTO t SET a=13; +XA END 'trx_13'; +XA PREPARE 'trx_13'; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +XA START 'trx_14'; +INSERT INTO t SET a=14; +XA END 'trx_14'; +XA PREPARE 'trx_14'; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +SET @@binlog_format = ROW; +XA START 'trx_15'; +INSERT INTO t SET a=15; +XA END 'trx_15'; +XA PREPARE 'trx_15'; +connection default; +KILL CONNECTION CONN_ID; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +XA START 'trx_16'; +INSERT INTO t SET a=16; +XA END 'trx_16'; +XA PREPARE 'trx_16'; +connection default; +KILL CONNECTION CONN_ID; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +SET @@binlog_format = ROW; +XA START 'trx_17'; +INSERT INTO t SET a=17; +XA END 'trx_17'; +XA PREPARE 'trx_17'; +connection default; +KILL CONNECTION CONN_ID; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +XA START 'trx_18'; +INSERT INTO t SET a=18; +XA END 'trx_18'; +XA PREPARE 'trx_18'; +connection default; +KILL CONNECTION CONN_ID; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +SET @@binlog_format = ROW; +XA START 'trx_19'; +INSERT INTO t SET a=19; +XA END 'trx_19'; +XA PREPARE 'trx_19'; +connection default; +KILL CONNECTION CONN_ID; +connection default; +XA ROLLBACK 'trx_0'; +XA ROLLBACK 'trx_1'; +XA ROLLBACK 'trx_2'; +XA ROLLBACK 'trx_3'; +XA ROLLBACK 'trx_4'; +XA COMMIT 'trx_5'; +XA COMMIT 'trx_6'; +XA COMMIT 'trx_7'; +XA COMMIT 'trx_8'; +XA COMMIT 'trx_9'; +# restart +connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'new_trx_0'; +INSERT INTO t SET a=0; +XA END 'new_trx_0'; +XA PREPARE 'new_trx_0'; +disconnect conn_restart_0; +connection default; +connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'new_trx_1'; +INSERT INTO t SET a=1; +XA END 'new_trx_1'; +XA PREPARE 'new_trx_1'; +disconnect conn_restart_1; +connection default; +connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'new_trx_2'; +INSERT INTO t SET a=2; +XA END 'new_trx_2'; +XA PREPARE 'new_trx_2'; +disconnect conn_restart_2; +connection default; +connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'new_trx_3'; +INSERT INTO t SET a=3; +XA END 'new_trx_3'; +XA PREPARE 'new_trx_3'; +disconnect conn_restart_3; +connection default; +connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'new_trx_4'; +INSERT INTO t SET a=4; +XA END 'new_trx_4'; +XA PREPARE 'new_trx_4'; +disconnect conn_restart_4; +connection default; +connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'new_trx_5'; +INSERT INTO t SET a=5; +XA END 'new_trx_5'; +XA PREPARE 'new_trx_5'; +disconnect conn_restart_5; +connection default; +connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'new_trx_6'; +INSERT INTO t SET a=6; +XA END 'new_trx_6'; +XA PREPARE 'new_trx_6'; +disconnect conn_restart_6; +connection default; +connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'new_trx_7'; +INSERT INTO t SET a=7; +XA END 'new_trx_7'; +XA PREPARE 'new_trx_7'; +disconnect conn_restart_7; +connection default; +connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'new_trx_8'; +INSERT INTO t SET a=8; +XA END 'new_trx_8'; +XA PREPARE 'new_trx_8'; +disconnect conn_restart_8; +connection default; +connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'new_trx_9'; +INSERT INTO t SET a=9; +XA END 'new_trx_9'; +XA PREPARE 'new_trx_9'; +disconnect conn_restart_9; +connection default; +connection default; +XA COMMIT 'new_trx_0'; +XA COMMIT 'new_trx_1'; +XA COMMIT 'new_trx_2'; +XA COMMIT 'new_trx_3'; +XA COMMIT 'new_trx_4'; +XA COMMIT 'new_trx_5'; +XA COMMIT 'new_trx_6'; +XA COMMIT 'new_trx_7'; +XA COMMIT 'new_trx_8'; +XA COMMIT 'new_trx_9'; +XA START 'trx_10'; +ERROR XAE08: XAER_DUPID: The XID already exists +XA COMMIT 'trx_10'; +XA START 'trx_11'; +ERROR XAE08: XAER_DUPID: The XID already exists +XA COMMIT 'trx_11'; +XA START 'trx_12'; +ERROR XAE08: XAER_DUPID: The XID already exists +XA COMMIT 'trx_12'; +XA START 'trx_13'; +ERROR XAE08: XAER_DUPID: The XID already exists +XA COMMIT 'trx_13'; +XA START 'trx_14'; +ERROR XAE08: XAER_DUPID: The XID already exists +XA COMMIT 'trx_14'; +XA START 'trx_15'; +ERROR XAE08: XAER_DUPID: The XID already exists +XA ROLLBACK 'trx_15'; +XA START 'trx_16'; +ERROR XAE08: XAER_DUPID: The XID already exists +XA ROLLBACK 'trx_16'; +XA START 'trx_17'; +ERROR XAE08: XAER_DUPID: The XID already exists +XA ROLLBACK 'trx_17'; +XA START 'trx_18'; +ERROR XAE08: XAER_DUPID: The XID already exists +XA ROLLBACK 'trx_18'; +XA START 'trx_19'; +ERROR XAE08: XAER_DUPID: The XID already exists +XA ROLLBACK 'trx_19'; +SELECT * FROM t; +a +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +disconnect conn2tmp; +disconnect conn3tmp; +disconnect conn2ro; +disconnect conn3ro; +disconnect conn2empty; +disconnect conn3empty; +connection default; +XA ROLLBACK 'trx_20'; +ERROR XAE04: XAER_NOTA: Unknown XID +disconnect conn19; +connection default; +XA ROLLBACK 'trx_19'; +ERROR XAE04: XAER_NOTA: Unknown XID +disconnect conn18; +connection default; +XA ROLLBACK 'trx_18'; +ERROR XAE04: XAER_NOTA: Unknown XID +disconnect conn17; +connection default; +XA ROLLBACK 'trx_17'; +ERROR XAE04: XAER_NOTA: Unknown XID +disconnect conn16; +connection default; +XA ROLLBACK 'trx_16'; +ERROR XAE04: XAER_NOTA: Unknown XID +disconnect conn15; +connection default; +XA ROLLBACK 'trx_15'; +ERROR XAE04: XAER_NOTA: Unknown XID +disconnect conn14; +connection default; +XA ROLLBACK 'trx_14'; +ERROR XAE04: XAER_NOTA: Unknown XID +disconnect conn13; +connection default; +XA ROLLBACK 'trx_13'; +ERROR XAE04: XAER_NOTA: Unknown XID +disconnect conn12; +connection default; +XA ROLLBACK 'trx_12'; +ERROR XAE04: XAER_NOTA: Unknown XID +disconnect conn11; +connection default; +XA ROLLBACK 'trx_11'; +ERROR XAE04: XAER_NOTA: Unknown XID +disconnect conn10; +connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@sql_log_bin = OFF; +CREATE TEMPORARY TABLE tmp1 (a int) ENGINE=innodb; +XA START 'trx1tmp'; +INSERT INTO tmp1 SET a=1; +XA END 'trx1tmp'; +XA PREPARE 'trx1tmp'; +connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@sql_log_bin = OFF; +CREATE TEMPORARY TABLE tmp1 (a int) ENGINE=innodb; +XA START 'trx2tmp'; +INSERT INTO tmp1 SET a=1; +XA END 'trx2tmp'; +XA PREPARE 'trx2tmp'; +connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@sql_log_bin = OFF; +CREATE TEMPORARY TABLE tmp1 (a int) ENGINE=innodb; +XA START 'trx3tmp'; +INSERT INTO tmp1 SET a=1; +XA END 'trx3tmp'; +XA PREPARE 'trx3tmp'; +connection default; +XA COMMIT 'trx1tmp'; +ERROR XAE04: XAER_NOTA: Unknown XID +XA ROLLBACK 'trx1tmp'; +ERROR XAE04: XAER_NOTA: Unknown XID +XA START 'trx1tmp'; +ERROR XAE08: XAER_DUPID: The XID already exists +connection default; +*** 3 prepared transactions must be in the list *** +XA RECOVER; +formatID gtrid_length bqual_length data +1 LEN1 LEN2 TRX_N +1 LEN1 LEN2 TRX_N +1 LEN1 LEN2 TRX_N +connection conn1tmp; +disconnect conn1tmp; +connection default; +XA COMMIT 'trx1tmp'; +KILL connection CONN_ID; +XA COMMIT 'trx3tmp'; +connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'trx1ro'; +SELECT * from t ORDER BY a; +a +0 +1 +2 +3 +4 +5 +5 +6 +6 +7 +7 +8 +8 +9 +9 +10 +11 +12 +13 +14 +XA END 'trx1ro'; +XA PREPARE 'trx1ro'; +connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'trx2ro'; +SELECT * from t ORDER BY a; +a +0 +1 +2 +3 +4 +5 +5 +6 +6 +7 +7 +8 +8 +9 +9 +10 +11 +12 +13 +14 +XA END 'trx2ro'; +XA PREPARE 'trx2ro'; +connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'trx3ro'; +SELECT * from t ORDER BY a; +a +0 +1 +2 +3 +4 +5 +5 +6 +6 +7 +7 +8 +8 +9 +9 +10 +11 +12 +13 +14 +XA END 'trx3ro'; +XA PREPARE 'trx3ro'; +connection default; +*** 4 prepared transactions must be in the list *** +XA RECOVER; +formatID gtrid_length bqual_length data +1 LEN1 LEN2 TRX_N +1 LEN1 LEN2 TRX_N +1 LEN1 LEN2 TRX_N +1 LEN1 LEN2 TRX_N +connection conn1ro; +disconnect conn1ro; +connection default; +XA ROLLBACK 'trx1ro'; +KILL connection CONN_ID; +XA ROLLBACK 'trx3ro'; +connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'trx1empty'; +XA END 'trx1empty'; +XA PREPARE 'trx1empty'; +connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'trx2empty'; +XA END 'trx2empty'; +XA PREPARE 'trx2empty'; +connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'trx3empty'; +XA END 'trx3empty'; +XA PREPARE 'trx3empty'; +connection default; +*** 5 prepared transactions must be in the list *** +XA RECOVER; +formatID gtrid_length bqual_length data +1 LEN1 LEN2 TRX_N +1 LEN1 LEN2 TRX_N +1 LEN1 LEN2 TRX_N +1 LEN1 LEN2 TRX_N +1 LEN1 LEN2 TRX_N +connection conn1empty; +disconnect conn1empty; +connection default; +XA COMMIT 'trx1empty'; +KILL connection CONN_ID; +XA COMMIT 'trx3empty'; +connect conn1$type, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'trx1unprepared'; +INSERT INTO t set a=0; +XA END 'trx1unprepared'; +INSERT INTO t set a=0; +ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the IDLE state +XA START 'trx1unprepared'; +ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the IDLE state +XA START 'trx1unprepared'; +ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the IDLE state +disconnect conn1unprepared; +connection default; +XA COMMIT 'trx1unprepared'; +ERROR XAE04: XAER_NOTA: Unknown XID +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +XA START 'trx_0'; +INSERT INTO t SET a=0; +XA END 'trx_0'; +XA PREPARE 'trx_0'; +disconnect conn0; +connection default; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +SET @@binlog_format = ROW; +XA START 'trx_1'; +INSERT INTO t SET a=1; +XA END 'trx_1'; +XA PREPARE 'trx_1'; +disconnect conn1; +connection default; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +XA START 'trx_2'; +INSERT INTO t SET a=2; +XA END 'trx_2'; +XA PREPARE 'trx_2'; +disconnect conn2; +connection default; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +SET @@binlog_format = ROW; +XA START 'trx_3'; +INSERT INTO t SET a=3; +XA END 'trx_3'; +XA PREPARE 'trx_3'; +disconnect conn3; +connection default; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +XA START 'trx_4'; +INSERT INTO t SET a=4; +XA END 'trx_4'; +XA PREPARE 'trx_4'; +disconnect conn4; +connection default; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +SET @@binlog_format = ROW; +XA START 'trx_5'; +INSERT INTO t SET a=5; +XA END 'trx_5'; +XA PREPARE 'trx_5'; +disconnect conn5; +connection default; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +XA START 'trx_6'; +INSERT INTO t SET a=6; +XA END 'trx_6'; +XA PREPARE 'trx_6'; +disconnect conn6; +connection default; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +SET @@binlog_format = ROW; +XA START 'trx_7'; +INSERT INTO t SET a=7; +XA END 'trx_7'; +XA PREPARE 'trx_7'; +disconnect conn7; +connection default; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +XA START 'trx_8'; +INSERT INTO t SET a=8; +XA END 'trx_8'; +XA PREPARE 'trx_8'; +disconnect conn8; +connection default; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +SET @@binlog_format = ROW; +XA START 'trx_9'; +INSERT INTO t SET a=9; +XA END 'trx_9'; +XA PREPARE 'trx_9'; +disconnect conn9; +connection default; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +XA START 'trx_10'; +INSERT INTO t SET a=10; +XA END 'trx_10'; +XA PREPARE 'trx_10'; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +SET @@binlog_format = ROW; +XA START 'trx_11'; +INSERT INTO t SET a=11; +XA END 'trx_11'; +XA PREPARE 'trx_11'; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +XA START 'trx_12'; +INSERT INTO t SET a=12; +XA END 'trx_12'; +XA PREPARE 'trx_12'; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +SET @@binlog_format = ROW; +XA START 'trx_13'; +INSERT INTO t SET a=13; +XA END 'trx_13'; +XA PREPARE 'trx_13'; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +XA START 'trx_14'; +INSERT INTO t SET a=14; +XA END 'trx_14'; +XA PREPARE 'trx_14'; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +SET @@binlog_format = ROW; +XA START 'trx_15'; +INSERT INTO t SET a=15; +XA END 'trx_15'; +XA PREPARE 'trx_15'; +connection default; +KILL CONNECTION CONN_ID; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +XA START 'trx_16'; +INSERT INTO t SET a=16; +XA END 'trx_16'; +XA PREPARE 'trx_16'; +connection default; +KILL CONNECTION CONN_ID; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +SET @@binlog_format = ROW; +XA START 'trx_17'; +INSERT INTO t SET a=17; +XA END 'trx_17'; +XA PREPARE 'trx_17'; +connection default; +KILL CONNECTION CONN_ID; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +XA START 'trx_18'; +INSERT INTO t SET a=18; +XA END 'trx_18'; +XA PREPARE 'trx_18'; +connection default; +KILL CONNECTION CONN_ID; +connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,; +SET @@binlog_format = STATEMENT; +SET @@binlog_format = ROW; +XA START 'trx_19'; +INSERT INTO t SET a=19; +XA END 'trx_19'; +XA PREPARE 'trx_19'; +connection default; +KILL CONNECTION CONN_ID; +connection default; +XA ROLLBACK 'trx_0'; +XA ROLLBACK 'trx_1'; +XA ROLLBACK 'trx_2'; +XA ROLLBACK 'trx_3'; +XA ROLLBACK 'trx_4'; +XA COMMIT 'trx_5'; +XA COMMIT 'trx_6'; +XA COMMIT 'trx_7'; +XA COMMIT 'trx_8'; +XA COMMIT 'trx_9'; +# Kill and restart +connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'new_trx_0'; +INSERT INTO t SET a=0; +XA END 'new_trx_0'; +XA PREPARE 'new_trx_0'; +disconnect conn_restart_0; +connection default; +connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'new_trx_1'; +INSERT INTO t SET a=1; +XA END 'new_trx_1'; +XA PREPARE 'new_trx_1'; +disconnect conn_restart_1; +connection default; +connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'new_trx_2'; +INSERT INTO t SET a=2; +XA END 'new_trx_2'; +XA PREPARE 'new_trx_2'; +disconnect conn_restart_2; +connection default; +connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'new_trx_3'; +INSERT INTO t SET a=3; +XA END 'new_trx_3'; +XA PREPARE 'new_trx_3'; +disconnect conn_restart_3; +connection default; +connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'new_trx_4'; +INSERT INTO t SET a=4; +XA END 'new_trx_4'; +XA PREPARE 'new_trx_4'; +disconnect conn_restart_4; +connection default; +connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'new_trx_5'; +INSERT INTO t SET a=5; +XA END 'new_trx_5'; +XA PREPARE 'new_trx_5'; +disconnect conn_restart_5; +connection default; +connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'new_trx_6'; +INSERT INTO t SET a=6; +XA END 'new_trx_6'; +XA PREPARE 'new_trx_6'; +disconnect conn_restart_6; +connection default; +connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'new_trx_7'; +INSERT INTO t SET a=7; +XA END 'new_trx_7'; +XA PREPARE 'new_trx_7'; +disconnect conn_restart_7; +connection default; +connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'new_trx_8'; +INSERT INTO t SET a=8; +XA END 'new_trx_8'; +XA PREPARE 'new_trx_8'; +disconnect conn_restart_8; +connection default; +connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,; +XA START 'new_trx_9'; +INSERT INTO t SET a=9; +XA END 'new_trx_9'; +XA PREPARE 'new_trx_9'; +disconnect conn_restart_9; +connection default; +connection default; +XA COMMIT 'new_trx_0'; +XA COMMIT 'new_trx_1'; +XA COMMIT 'new_trx_2'; +XA COMMIT 'new_trx_3'; +XA COMMIT 'new_trx_4'; +XA COMMIT 'new_trx_5'; +XA COMMIT 'new_trx_6'; +XA COMMIT 'new_trx_7'; +XA COMMIT 'new_trx_8'; +XA COMMIT 'new_trx_9'; +XA START 'trx_10'; +ERROR XAE08: XAER_DUPID: The XID already exists +XA COMMIT 'trx_10'; +XA START 'trx_11'; +ERROR XAE08: XAER_DUPID: The XID already exists +XA COMMIT 'trx_11'; +XA START 'trx_12'; +ERROR XAE08: XAER_DUPID: The XID already exists +XA COMMIT 'trx_12'; +XA START 'trx_13'; +ERROR XAE08: XAER_DUPID: The XID already exists +XA COMMIT 'trx_13'; +XA START 'trx_14'; +ERROR XAE08: XAER_DUPID: The XID already exists +XA COMMIT 'trx_14'; +XA START 'trx_15'; +ERROR XAE08: XAER_DUPID: The XID already exists +XA ROLLBACK 'trx_15'; +XA START 'trx_16'; +ERROR XAE08: XAER_DUPID: The XID already exists +XA ROLLBACK 'trx_16'; +XA START 'trx_17'; +ERROR XAE08: XAER_DUPID: The XID already exists +XA ROLLBACK 'trx_17'; +XA START 'trx_18'; +ERROR XAE08: XAER_DUPID: The XID already exists +XA ROLLBACK 'trx_18'; +XA START 'trx_19'; +ERROR XAE08: XAER_DUPID: The XID already exists +XA ROLLBACK 'trx_19'; +SELECT * FROM t; +a +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +disconnect conn2tmp; +disconnect conn3tmp; +disconnect conn2ro; +disconnect conn3ro; +disconnect conn2empty; +disconnect conn3empty; +connection default; +XA ROLLBACK 'trx_20'; +ERROR XAE04: XAER_NOTA: Unknown XID +disconnect conn19; +connection default; +XA ROLLBACK 'trx_19'; +ERROR XAE04: XAER_NOTA: Unknown XID +disconnect conn18; +connection default; +XA ROLLBACK 'trx_18'; +ERROR XAE04: XAER_NOTA: Unknown XID +disconnect conn17; +connection default; +XA ROLLBACK 'trx_17'; +ERROR XAE04: XAER_NOTA: Unknown XID +disconnect conn16; +connection default; +XA ROLLBACK 'trx_16'; +ERROR XAE04: XAER_NOTA: Unknown XID +disconnect conn15; +connection default; +XA ROLLBACK 'trx_15'; +ERROR XAE04: XAER_NOTA: Unknown XID +disconnect conn14; +connection default; +XA ROLLBACK 'trx_14'; +ERROR XAE04: XAER_NOTA: Unknown XID +disconnect conn13; +connection default; +XA ROLLBACK 'trx_13'; +ERROR XAE04: XAER_NOTA: Unknown XID +disconnect conn12; +connection default; +XA ROLLBACK 'trx_12'; +ERROR XAE04: XAER_NOTA: Unknown XID +disconnect conn11; +connection default; +XA ROLLBACK 'trx_11'; +ERROR XAE04: XAER_NOTA: Unknown XID +disconnect conn10; +connection default; +XA START 'one_phase_trx_0'; +INSERT INTO t SET a=0; +XA END 'one_phase_trx_0'; +XA COMMIT 'one_phase_trx_0' ONE PHASE; +XA START 'one_phase_trx_1'; +INSERT INTO t SET a=1; +XA END 'one_phase_trx_1'; +XA COMMIT 'one_phase_trx_1' ONE PHASE; +XA START 'one_phase_trx_2'; +INSERT INTO t SET a=2; +XA END 'one_phase_trx_2'; +XA COMMIT 'one_phase_trx_2' ONE PHASE; +XA START 'one_phase_trx_3'; +INSERT INTO t SET a=3; +XA END 'one_phase_trx_3'; +XA COMMIT 'one_phase_trx_3' ONE PHASE; +XA START 'one_phase_trx_4'; +INSERT INTO t SET a=4; +XA END 'one_phase_trx_4'; +XA COMMIT 'one_phase_trx_4' ONE PHASE; +SELECT SUM(a) FROM t; +SUM(a) +290 +DROP TABLE t; +DROP VIEW v_processlist; +All transactions must be completed, to empty-list the following: +XA RECOVER; +formatID gtrid_length bqual_length data diff --git a/mysql-test/main/xa_prepared_binlog_off.test b/mysql-test/main/xa_prepared_binlog_off.test new file mode 100644 index 00000000000..edbfa7c2825 --- /dev/null +++ b/mysql-test/main/xa_prepared_binlog_off.test @@ -0,0 +1,11 @@ +############################################################################### +# MDEV-7974 (bug#12161 Xa recovery and client disconnection) +# Testing XA behaviour with binlog turned off. +############################################################################### + +--source include/not_valgrind.inc +--source include/not_embedded.inc + +# Common part with XA binlogging testing +call mtr.add_suppression("You need to use --log-bin to make --log-slave-updates work."); +--source suite/binlog/t/binlog_xa_prepared.inc diff --git a/mysql-test/main/xa_sync.result b/mysql-test/main/xa_sync.result index 1482ff5cacf..e7dd9b02847 100644 --- a/mysql-test/main/xa_sync.result +++ b/mysql-test/main/xa_sync.result @@ -18,6 +18,11 @@ disconnect con1; SET debug_sync='now SIGNAL go'; connection con2; ERROR XAE04: XAER_NOTA: Unknown XID +*** Must have 'xatest' in the list +XA RECOVER; +formatID gtrid_length bqual_length data +1 6 0 xatest +XA COMMIT 'xatest'; disconnect con2; connection default; SET debug_sync='RESET'; @@ -37,6 +42,11 @@ disconnect con1; SET debug_sync='now SIGNAL go'; connection con2; ERROR XAE04: XAER_NOTA: Unknown XID +*** Must have 'xatest' in the list +XA RECOVER; +formatID gtrid_length bqual_length data +1 6 0 xatest +XA ROLLBACK 'xatest'; disconnect con2; connection default; SET debug_sync='RESET'; diff --git a/mysql-test/main/xa_sync.test b/mysql-test/main/xa_sync.test index bb95af7c0ba..ad1243ce6f8 100644 --- a/mysql-test/main/xa_sync.test +++ b/mysql-test/main/xa_sync.test @@ -35,6 +35,11 @@ while ($i) connection con2; --error ER_XAER_NOTA reap; + --echo *** Must have 'xatest' in the list + XA RECOVER; + # second time yields no error + --error 0,1402 + --eval $op disconnect con2; connection default; diff --git a/mysql-test/main/xml.result b/mysql-test/main/xml.result index 14abf503b18..efaca961b4a 100644 --- a/mysql-test/main/xml.result +++ b/mysql-test/main/xml.result @@ -1309,3 +1309,16 @@ DROP TABLE t1; # # End of 10.2 tests # +# +# Start of 10.5 tests +# +# +# MDEV-20818 ER_CRASHED_ON_USAGE or Assertion `length <= column->length' failed in write_block_record on temporary table +# +SELECT 'foo' AS f UNION SELECT BINARY( UpdateXML('<a></a>', '/a', '<b></b>')) AS f; +f +foo +<b></b> +# +# Start of 10.5 tests +# diff --git a/mysql-test/main/xml.test b/mysql-test/main/xml.test index b567f03a431..3c7ecf6d060 100644 --- a/mysql-test/main/xml.test +++ b/mysql-test/main/xml.test @@ -782,3 +782,17 @@ DROP TABLE t1; --echo # --echo # End of 10.2 tests --echo # + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-20818 ER_CRASHED_ON_USAGE or Assertion `length <= column->length' failed in write_block_record on temporary table +--echo # + +SELECT 'foo' AS f UNION SELECT BINARY( UpdateXML('<a></a>', '/a', '<b></b>')) AS f; + +--echo # +--echo # Start of 10.5 tests +--echo # diff --git a/mysql-test/main/xtradb_mrr.result b/mysql-test/main/xtradb_mrr.result index 2f18a7c287f..34fd8300423 100644 --- a/mysql-test/main/xtradb_mrr.result +++ b/mysql-test/main/xtradb_mrr.result @@ -1,6 +1,6 @@ drop table if exists t1,t2,t3,t4; -set @save_storage_engine= @@storage_engine; -set storage_engine=InnoDB; +set @save_storage_engine= @@default_storage_engine; +set default_storage_engine=InnoDB; set @innodb_mrr_tmp=@@optimizer_switch; set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; create table t1(a int); @@ -296,7 +296,7 @@ NULL 7 0 NULL 9 0 NULL 9 0 drop table t1, t2; -set storage_engine= @save_storage_engine; +set default_storage_engine= @save_storage_engine; set @mrr_buffer_size_save= @@mrr_buffer_size; set mrr_buffer_size=64; Warnings: diff --git a/mysql-test/main/xtradb_mrr.test b/mysql-test/main/xtradb_mrr.test index 8dccd20796f..9de9b192b06 100644 --- a/mysql-test/main/xtradb_mrr.test +++ b/mysql-test/main/xtradb_mrr.test @@ -4,15 +4,15 @@ drop table if exists t1,t2,t3,t4; --enable_warnings -set @save_storage_engine= @@storage_engine; -set storage_engine=InnoDB; +set @save_storage_engine= @@default_storage_engine; +set default_storage_engine=InnoDB; set @innodb_mrr_tmp=@@optimizer_switch; set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; --source include/mrr_tests.inc -set storage_engine= @save_storage_engine; +set default_storage_engine= @save_storage_engine; # Try big rowid sizes set @mrr_buffer_size_save= @@mrr_buffer_size; |