diff options
Diffstat (limited to 'mysql-test/main')
150 files changed, 5060 insertions, 610 deletions
diff --git a/mysql-test/main/alter_table.result b/mysql-test/main/alter_table.result index 7b9eab3f..2e7047f3 100644 --- a/mysql-test/main/alter_table.result +++ b/mysql-test/main/alter_table.result @@ -1999,8 +1999,7 @@ ALTER TABLE ti1 DROP FOREIGN KEY fi1; affected rows: 0 info: Records: 0 Duplicates: 0 Warnings: 0 ALTER TABLE tm1 DROP FOREIGN KEY fm1; -affected rows: 2 -info: Records: 2 Duplicates: 0 Warnings: 0 +ERROR 42000: Can't DROP FOREIGN KEY `fm1`; check that it exists ALTER TABLE ti1 RENAME TO ti3; affected rows: 0 ALTER TABLE tm1 RENAME TO tm3; diff --git a/mysql-test/main/alter_table.test b/mysql-test/main/alter_table.test index c6aba3fd..17d71d8e 100644 --- a/mysql-test/main/alter_table.test +++ b/mysql-test/main/alter_table.test @@ -1696,6 +1696,7 @@ ALTER TABLE ti1 DROP PRIMARY KEY; ALTER TABLE tm1 DROP PRIMARY KEY; ALTER TABLE ti1 DROP FOREIGN KEY fi1; +--error ER_CANT_DROP_FIELD_OR_KEY ALTER TABLE tm1 DROP FOREIGN KEY fm1; ALTER TABLE ti1 RENAME TO ti3; diff --git a/mysql-test/main/backup_interaction.result b/mysql-test/main/backup_interaction.result index a6fe7cf4..c775c5eb 100644 --- a/mysql-test/main/backup_interaction.result +++ b/mysql-test/main/backup_interaction.result @@ -95,7 +95,7 @@ drop table t1; # # BACKUP STAGE performs implicit commits # -create table t1(a int) engine=InnoDB; +create table t1(a int) stats_persistent=0, engine=InnoDB; begin; insert into t1 values(1); select lock_mode from information_schema.metadata_lock_info where thread_id>0; @@ -197,8 +197,9 @@ drop table t1; # CHECK: RO transaction under BACKUP STAGE is a potential deadlock # OTOH we most probably allow them under FTWRL as well # -CREATE TABLE t1 (col1 INT) ENGINE = InnoDB; +CREATE TABLE t1 (col1 INT)stats_persistent=0, ENGINE = InnoDB; insert into t1 values (1); +InnoDB 0 transactions not purged backup stage start; backup stage block_commit; begin; diff --git a/mysql-test/main/backup_interaction.test b/mysql-test/main/backup_interaction.test index c755bdf8..25f22f66 100644 --- a/mysql-test/main/backup_interaction.test +++ b/mysql-test/main/backup_interaction.test @@ -120,7 +120,7 @@ drop table t1; --echo # BACKUP STAGE performs implicit commits --echo # --disable_view_protocol -create table t1(a int) engine=InnoDB; +create table t1(a int) stats_persistent=0, engine=InnoDB; begin; insert into t1 values(1); select lock_mode from information_schema.metadata_lock_info where thread_id>0; @@ -221,8 +221,9 @@ drop table t1; --echo # OTOH we most probably allow them under FTWRL as well --echo # --disable_view_protocol -CREATE TABLE t1 (col1 INT) ENGINE = InnoDB; +CREATE TABLE t1 (col1 INT)stats_persistent=0, ENGINE = InnoDB; insert into t1 values (1); +--source ../suite/innodb/include/wait_all_purged.inc backup stage start; backup stage block_commit; begin; diff --git a/mysql-test/main/backup_lock.result b/mysql-test/main/backup_lock.result index 16806148..488e81fd 100644 --- a/mysql-test/main/backup_lock.result +++ b/mysql-test/main/backup_lock.result @@ -1,6 +1,7 @@ # # Testing which locks we get from all stages # +InnoDB 0 transactions not purged BACKUP STAGE START; SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info WHERE TABLE_NAME NOT LIKE 'innodb_%_stats'; @@ -34,7 +35,8 @@ connection default; # # testing if BACKUP STAGE FLUSH causes deadlocks with ALTER TABLE # -create table t1 (a int) engine=innodb; +create table t1 (a int) stats_persistent= 0, engine=innodb; +InnoDB 0 transactions not purged connection con2; backup stage start; connection default; @@ -104,7 +106,8 @@ drop table t1; # # testing if BACKUP STAGE FLUSH causes deadlocks with DROP TABLE # -create table t1 (a int) engine=innodb; +create table t1 (a int)stats_persistent=0, engine=innodb; +InnoDB 0 transactions not purged start transaction; insert into t1 values (1); connection con1; @@ -132,6 +135,7 @@ connection default; # Check if backup stage block_dll + concurrent drop table blocks select # create table t1 (a int) engine=innodb; +InnoDB 0 transactions not purged backup stage start; backup stage block_ddl; connection con1; diff --git a/mysql-test/main/backup_lock.test b/mysql-test/main/backup_lock.test index 5453e5b0..f86f2f36 100644 --- a/mysql-test/main/backup_lock.test +++ b/mysql-test/main/backup_lock.test @@ -15,6 +15,8 @@ let $mdl= LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info WHERE TABLE_NAME NOT LIKE 'innodb_%_stats'; +--source ../suite/innodb/include/wait_all_purged.inc + BACKUP STAGE START; eval SELECT $mdl; BACKUP STAGE FLUSH; @@ -39,7 +41,8 @@ connection default; --echo # testing if BACKUP STAGE FLUSH causes deadlocks with ALTER TABLE --echo # -create table t1 (a int) engine=innodb; +create table t1 (a int) stats_persistent= 0, engine=innodb; +--source ../suite/innodb/include/wait_all_purged.inc connection con2; backup stage start; @@ -129,7 +132,8 @@ drop table t1; --echo # testing if BACKUP STAGE FLUSH causes deadlocks with DROP TABLE --echo # -create table t1 (a int) engine=innodb; +create table t1 (a int)stats_persistent=0, engine=innodb; +--source ../suite/innodb/include/wait_all_purged.inc start transaction; # Acquires MDL lock insert into t1 values (1); @@ -165,6 +169,7 @@ connection default; --echo # create table t1 (a int) engine=innodb; +--source ../suite/innodb/include/wait_all_purged.inc backup stage start; backup stage block_ddl; connection con1; diff --git a/mysql-test/main/backup_locks.result b/mysql-test/main/backup_locks.result index 31aed5f3..4d5de53c 100644 --- a/mysql-test/main/backup_locks.result +++ b/mysql-test/main/backup_locks.result @@ -23,7 +23,7 @@ BACKUP UNLOCK; # connect con1,localhost,root,,; connection default; -create table t1 (a int) engine=innodb; +create table t1 (a int) stats_persistent=0,engine=innodb; insert into t1 values (1); backup lock t1; select * from t1; @@ -184,5 +184,82 @@ ERROR HY000: Can't execute the query because you have a conflicting read lock BACKUP UNLOCK; DROP TABLE t3; # +# MDEV-28367: BACKUP LOCKS on table to be accessible to those +# with database LOCK TABLES privileges +# +create database db1; +create table db1.t1(t int); +create user user1@localhost; +select user,host from mysql.user where user='user1'; +User Host +user1 localhost +connect(localhost,user1,,db1,MASTER_PORT,MASTER_SOCKET); +connect con1, localhost, user1, ,db1; +ERROR 42000: Access denied for user 'user1'@'localhost' to database 'db1' +grant reload on *.* to user1@localhost; +grant select on db1.* to user1@localhost; +show grants for user1@localhost; +Grants for user1@localhost +GRANT RELOAD ON *.* TO `user1`@`localhost` +GRANT SELECT ON `db1`.* TO `user1`@`localhost` +connect con1, localhost, user1, ,db1; +BACKUP UNLOCK; +BACKUP LOCK db1.t1; +SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info where table_name not like "innodb_%"; +LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME +MDL_SHARED_HIGH_PRIO Table metadata lock db1 t1 +BACKUP UNLOCK; +SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info where table_name not like "innodb_%"; +LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME +connection default; +disconnect con1; +grant lock tables on db1.* to user1@localhost; +show grants for user1@localhost; +Grants for user1@localhost +GRANT RELOAD ON *.* TO `user1`@`localhost` +GRANT SELECT, LOCK TABLES ON `db1`.* TO `user1`@`localhost` +connect con1, localhost, user1, ,db1; +BACKUP UNLOCK; +BACKUP LOCK db1.t1; +SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info where table_name not like "innodb_%"; +LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME +MDL_SHARED_HIGH_PRIO Table metadata lock db1 t1 +BACKUP UNLOCK; +SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info where table_name not like "innodb_%"; +LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME +connection default; +disconnect con1; +revoke reload on *.* from user1@localhost; +show grants for user1@localhost; +Grants for user1@localhost +GRANT USAGE ON *.* TO `user1`@`localhost` +GRANT SELECT, LOCK TABLES ON `db1`.* TO `user1`@`localhost` +connect con1, localhost, user1, ,db1; +BACKUP UNLOCK; +ERROR 42000: Access denied; you need (at least one of) the RELOAD, LOCK TABLES privilege(s) for this operation +BACKUP LOCK db1.t1; +SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info where table_name not like "innodb_%"; +LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME +MDL_SHARED_HIGH_PRIO Table metadata lock db1 t1 +BACKUP UNLOCK; +SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info where table_name not like "innodb_%"; +LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME +connection default; +disconnect con1; +revoke lock tables on db1.* from user1@localhost; +show grants for user1@localhost; +Grants for user1@localhost +GRANT USAGE ON *.* TO `user1`@`localhost` +GRANT SELECT ON `db1`.* TO `user1`@`localhost` +connect con1, localhost, user1, ,db1; +BACKUP LOCK db1.t1; +ERROR 42000: Access denied; you need (at least one of) the RELOAD, LOCK TABLES privilege(s) for this operation +BACKUP UNLOCK; +ERROR 42000: Access denied; you need (at least one of) the RELOAD, LOCK TABLES privilege(s) for this operation +connection default; +disconnect con1; +drop database db1; +drop user user1@localhost; +# # End of MariaDB 10.4 tests # diff --git a/mysql-test/main/backup_locks.test b/mysql-test/main/backup_locks.test index 2c2c226f..40f12bb7 100644 --- a/mysql-test/main/backup_locks.test +++ b/mysql-test/main/backup_locks.test @@ -29,7 +29,7 @@ BACKUP UNLOCK; connect (con1,localhost,root,,); connection default; -create table t1 (a int) engine=innodb; +create table t1 (a int) stats_persistent=0,engine=innodb; insert into t1 values (1); backup lock t1; select * from t1; @@ -214,7 +214,78 @@ LOCK TABLES t3 AS a2 WRITE, t3 AS a1 READ LOCAL; DROP TABLE t3; BACKUP UNLOCK; DROP TABLE t3; +--echo # +--echo # MDEV-28367: BACKUP LOCKS on table to be accessible to those +--echo # with database LOCK TABLES privileges +--echo # + +--source include/have_metadata_lock_info.inc +create database db1; +create table db1.t1(t int); +create user user1@localhost; +select user,host from mysql.user where user='user1'; +--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT +--error ER_DBACCESS_DENIED_ERROR +--connect (con1, localhost, user1, ,db1) + +grant reload on *.* to user1@localhost; +# To access DB one need select privileges +grant select on db1.* to user1@localhost; +show grants for user1@localhost; +--connect (con1, localhost, user1, ,db1) + +# This should work we have RELOAD privilege +BACKUP UNLOCK; +BACKUP LOCK db1.t1; +SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info where table_name not like "innodb_%"; +BACKUP UNLOCK; +SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info where table_name not like "innodb_%"; + +# Add LOCK TABLES DB privileges (all privileges for BACKUP LOCK are there) +connection default; +disconnect con1; +grant lock tables on db1.* to user1@localhost; +show grants for user1@localhost; +--connect (con1, localhost, user1, ,db1) +# This should work we have RELOAD & LOCK privilege +BACKUP UNLOCK; +BACKUP LOCK db1.t1; +SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info where table_name not like "innodb_%"; +BACKUP UNLOCK; +SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info where table_name not like "innodb_%"; + +# Remove reload privilege, leave only LOCK TABLES privilege +connection default; +disconnect con1; +revoke reload on *.* from user1@localhost; +show grants for user1@localhost; +--connect (con1, localhost, user1, ,db1) +# There is no reload priv needed for unlock and there is no mdl_backup_lock taken +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +BACKUP UNLOCK; +# BACKUP LOCK should work, since we have LOCK privilege +BACKUP LOCK db1.t1; +SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info where table_name not like "innodb_%"; +# This works since there was taken mdl_backup_lock before +BACKUP UNLOCK; +SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info where table_name not like "innodb_%"; + +# Remove LOCK TABLES privilege +connection default; +disconnect con1; +revoke lock tables on db1.* from user1@localhost; +show grants for user1@localhost; +--connect (con1, localhost, user1, ,db1) +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +BACKUP LOCK db1.t1; +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +BACKUP UNLOCK; + +connection default; +disconnect con1; +drop database db1; +drop user user1@localhost; --echo # --echo # End of MariaDB 10.4 tests --echo # diff --git a/mysql-test/main/backup_stages.result b/mysql-test/main/backup_stages.result index 823e5d7e..3fb912af 100644 --- a/mysql-test/main/backup_stages.result +++ b/mysql-test/main/backup_stages.result @@ -17,6 +17,7 @@ FROM information_schema.processlist WHERE id = @con1_id; ID USER COMMAND STATE INFO STAGE MAX_STAGE INFO_BINARY <con1_id> root Query Waiting for backup lock BACKUP STAGE START 0 0 BACKUP STAGE START BACKUP STAGE END; +InnoDB 0 transactions not purged connection con1; # The connection default has removed the backup lock. # And so the current connection con1 can reap for its BACKUP STAGE START diff --git a/mysql-test/main/backup_stages.test b/mysql-test/main/backup_stages.test index 77d410b6..56be6205 100644 --- a/mysql-test/main/backup_stages.test +++ b/mysql-test/main/backup_stages.test @@ -50,6 +50,7 @@ FROM information_schema.processlist WHERE id = @con1_id; # con1 uses @@global.lock_wait_timeout BACKUP STAGE END; +--source ../suite/innodb/include/wait_all_purged.inc --connection con1 --echo # The connection default has removed the backup lock. diff --git a/mysql-test/main/cast.result b/mysql-test/main/cast.result index 4f48e9e0..81ac3f3e 100644 --- a/mysql-test/main/cast.result +++ b/mysql-test/main/cast.result @@ -814,7 +814,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL, - `b` char(5) GENERATED ALWAYS AS (cast('a' as char(10) charset latin1) + `a`) VIRTUAL + `b` char(5) GENERATED ALWAYS AS (cast('a' as char(10) charset latin1 binary) + `a`) VIRTUAL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci drop table t1; select collation(cast("a" as char(10) binary)); diff --git a/mysql-test/main/cast.test b/mysql-test/main/cast.test index 478c59a5..5a0f87be 100644 --- a/mysql-test/main/cast.test +++ b/mysql-test/main/cast.test @@ -158,10 +158,9 @@ select cast(1 as double(64,63)); # set names binary; select cast(_latin1'test' as char character set latin2); -#enable after MDEV-32461 fix ---disable_view_protocol +--disable_service_connection select cast(_koi8r'ÔÅÓÔ' as char character set cp1251); ---enable_view_protocol +--enable_service_connection create table t1 select cast(_koi8r'ÔÅÓÔ' as char character set cp1251) as t; show create table t1; drop table t1; @@ -169,8 +168,7 @@ drop table t1; # # CAST to CHAR with/without length # -#enable after MDEV-32461 fix ---disable_view_protocol +--disable_service_connection select cast(_latin1'ab' AS char) as c1, cast(_latin1'a ' AS char) as c2, @@ -178,7 +176,7 @@ select cast(_latin1'a ' AS char(2)) as c4, hex(cast(_latin1'a' AS char(2))) as c5; select cast(1000 as CHAR(3)); ---enable_view_protocol +--enable_service_connection SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR create table t1 select @@ -239,15 +237,14 @@ select cast("1:2:3" as TIME) = "1:02:03"; # CREATE TABLE t1 (a enum ('aac','aab','aaa') not null); INSERT INTO t1 VALUES ('aaa'),('aab'),('aac'); -#enable after MDEV-32461 fix ---disable_view_protocol +--disable_service_connection # these two should be in enum order SELECT a, CAST(a AS CHAR) FROM t1 ORDER BY CAST(a AS UNSIGNED) ; SELECT a, CAST(a AS CHAR(3)) FROM t1 ORDER BY CAST(a AS CHAR(2)), a; # these two should be in alphabetic order SELECT a, CAST(a AS UNSIGNED) FROM t1 ORDER BY CAST(a AS CHAR) ; SELECT a, CAST(a AS CHAR(2)) FROM t1 ORDER BY CAST(a AS CHAR(3)), a; ---enable_view_protocol +--enable_service_connection DROP TABLE t1; # @@ -349,12 +346,11 @@ select cast(NULL as decimal(6)) as t1; # Bug #17903: cast to char results in binary # set names latin1; -#enable after MDEV-32461 fix ---disable_view_protocol +--disable_service_connection select hex(cast('a' as char(2) binary)); select hex(cast('a' as binary(2))); select hex(cast('a' as char(2) binary)); ---enable_view_protocol +--enable_service_connection # # Bug#29898: Item_date_typecast::val_int doesn't reset the null_value flag. @@ -484,14 +480,13 @@ drop table t1; # # CAST (... BINARY) # -#enable after MDEV-32461 fix ---disable_view_protocol +--disable_service_connection select collation(cast("a" as char(10) binary)); select collation(cast("a" as char(10) charset utf8 binary)); select collation(cast("a" as char(10) ascii binary)); select collation(cast("a" as char(10) binary charset utf8)); select collation(cast("a" as char(10) binary ascii)); ---enable_view_protocol +--enable_service_connection --echo # --echo # MDEV-11030 Assertion `precision > 0' failed in decimal_bin_size @@ -773,10 +768,7 @@ INSERT INTO t1 VALUES (-1.0); SELECT * FROM t1; DROP TABLE t1; -#enable after MDEV-32461 fix ---disable_view_protocol SELECT CAST(-1e0 AS UNSIGNED); ---enable_view_protocol CREATE TABLE t1 (a BIGINT UNSIGNED); INSERT INTO t1 VALUES (-1e0); SELECT * FROM t1; diff --git a/mysql-test/main/change_user.result b/mysql-test/main/change_user.result index fa934fbf..c91522dc 100644 --- a/mysql-test/main/change_user.result +++ b/mysql-test/main/change_user.result @@ -1,4 +1,6 @@ set global secure_auth=0; +Warnings: +Warning 1287 '@@secure_auth' is deprecated and will be removed in a future release create user test_nopw; grant select on test.* to test_nopw; create user test_oldpw identified by password "09301740536db389"; @@ -90,6 +92,8 @@ NULL FLUSH STATUS; Value of com_select did not change set global secure_auth=default; +Warnings: +Warning 1287 '@@secure_auth' is deprecated and will be removed in a future release set timestamp=unix_timestamp('2010-10-10 10:10:10'); select now(); now() diff --git a/mysql-test/main/column_compression.test b/mysql-test/main/column_compression.test index 642399be..5fa8192d 100644 --- a/mysql-test/main/column_compression.test +++ b/mysql-test/main/column_compression.test @@ -1,6 +1,6 @@ --source include/have_innodb.inc --source include/have_csv.inc ---source include/have_normal_bzip.inc +--source include/have_normal_zlib.inc let $MYSQLD_DATADIR= `select @@datadir`; diff --git a/mysql-test/main/column_compression_rpl.test b/mysql-test/main/column_compression_rpl.test index df8e8890..18992f33 100644 --- a/mysql-test/main/column_compression_rpl.test +++ b/mysql-test/main/column_compression_rpl.test @@ -1,6 +1,6 @@ --source include/have_innodb.inc +--source include/have_normal_zlib.inc --source include/master-slave.inc ---source include/have_normal_bzip.inc --let $engine_type= myisam --let $engine_type2= innodb diff --git a/mysql-test/main/connect.result b/mysql-test/main/connect.result index 74387168..6642b8a1 100644 --- a/mysql-test/main/connect.result +++ b/mysql-test/main/connect.result @@ -1,4 +1,6 @@ SET global secure_auth=0; +Warnings: +Warning 1287 '@@secure_auth' is deprecated and will be removed in a future release connect con1,localhost,root,,mysql; show tables; Tables_in_mysql @@ -412,6 +414,8 @@ test test drop procedure p1; SET global secure_auth=default; +Warnings: +Warning 1287 '@@secure_auth' is deprecated and will be removed in a future release # # MDEV-19282: Log more specific warning with log_warnings=2 if # connection is aborted prior to authentication diff --git a/mysql-test/main/create_or_replace.result b/mysql-test/main/create_or_replace.result index 4e96af97..4bc0afe9 100644 --- a/mysql-test/main/create_or_replace.result +++ b/mysql-test/main/create_or_replace.result @@ -260,6 +260,7 @@ 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; +InnoDB 0 transactions not purged select * from information_schema.metadata_lock_info; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_BACKUP_DDL NULL Backup lock diff --git a/mysql-test/main/create_or_replace.test b/mysql-test/main/create_or_replace.test index 05c5d25b..7c83f3e2 100644 --- a/mysql-test/main/create_or_replace.test +++ b/mysql-test/main/create_or_replace.test @@ -216,6 +216,7 @@ drop table if exists 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; +--source ../suite/innodb/include/wait_all_purged.inc --replace_column 1 # --sorted_result select * from information_schema.metadata_lock_info; diff --git a/mysql-test/main/cte_nonrecursive.result b/mysql-test/main/cte_nonrecursive.result index f7871d4f..67a38ce0 100644 --- a/mysql-test/main/cte_nonrecursive.result +++ b/mysql-test/main/cte_nonrecursive.result @@ -2339,4 +2339,342 @@ set sql_mode="oracle"; with data as (select 1 as id) select id into @myid from data; set sql_mode= @save_sql_mode; +# +# MDEV-31995 Bogus error executing PS for query using CTE with renaming of columns +# +create table t1 (a int, b int); +insert into t1 values (1,1),(1,2),(1,3),(2,1),(2,2); +create table t2 (a int, b int); +insert into t2 values (3,1),(3,2),(3,3),(4,1),(4,2); +with cte (c1,c2) as +(select a as col1, sum(b) as col2 from t1 group by col1) +select * from cte; +c1 c2 +1 6 +2 3 +prepare st from "with cte (c1,c2) as +(select a as col1, sum(b) as col2 from t1 group by col1) +select * from cte"; +execute st; +c1 c2 +1 6 +2 3 +execute st; +c1 c2 +1 6 +2 3 +drop prepare st; +create procedure sp() with cte (c1,c2) as +(select a as col1, sum(b) as col2 from t1 group by col1) +select * from cte; +call sp(); +c1 c2 +1 6 +2 3 +call sp(); +c1 c2 +1 6 +2 3 +drop procedure sp; +with cte (c1,c2) as +(select a as col1, sum(b) as col2 from t1 order by col1) +select * from cte; +c1 c2 +1 9 +prepare st from "with cte (c1,c2) as +(select a as col1, sum(b) as col2 from t1 order by col1) +select * from cte"; +execute st; +c1 c2 +1 9 +execute st; +c1 c2 +1 9 +drop prepare st; +create procedure sp() with cte (c1,c2) as +(select a as col1, sum(b) as col2 from t1 order by col1) +select * from cte; +call sp(); +c1 c2 +1 9 +call sp(); +c1 c2 +1 9 +drop procedure sp; +with cte (c1,c2) as +(select a as col1, sum(b) as col2 from t1 where a > 1 group by col1 +union select a as col3, sum(b) as col4 from t2 where b > 2 group by col3), +cte2 (c3, c4) as +(select a as col5, sum(b) as col6 from t1 where a <= 1 group by col5 +union select a as col7, sum(b) as col8 from t2 where b <= 2 group by col7) +select * from cte where c1=1 union select * from cte2 where c3=3; +c1 c2 +3 3 +prepare st from "with cte (c1,c2) as +(select a as col1, sum(b) as col2 from t1 where a > 1 group by col1 +union select a as col3, sum(b) as col4 from t2 where b > 2 group by col3), +cte2 (c3, c4) as +(select a as col5, sum(b) as col6 from t1 where a <= 1 group by col5 +union select a as col7, sum(b) as col8 from t2 where b <= 2 group by col7) +select * from cte where c1=1 union select * from cte2 where c3=3"; +execute st; +c1 c2 +3 3 +execute st; +c1 c2 +3 3 +drop prepare st; +create procedure sp() with cte (c1,c2) as +(select a as col1, sum(b) as col2 from t1 where a > 1 group by col1 +union select a as col3, sum(b) as col4 from t2 where b > 2 group by col3), +cte2 (c3, c4) as +(select a as col5, sum(b) as col6 from t1 where a <= 1 group by col5 +union select a as col7, sum(b) as col8 from t2 where b <= 2 group by col7) +select * from cte where c1=1 union select * from cte2 where c3=3; +call sp(); +c1 c2 +3 3 +call sp(); +c1 c2 +3 3 +drop procedure sp; +with cte (c1,c2) as (select * from t1) +select cte.c1+1 as col1 , cte.c2 as col2 from cte where cte.c1 > 1 +union +select cte.c1 as col3, cte.c2+1 as col4 from cte where cte.c1 < 0; +col1 col2 +3 1 +3 2 +prepare st from "with cte (c1,c2) as (select * from t1) +select cte.c1+1 as col1 , cte.c2 as col2 from cte where cte.c1 > 1 +union +select cte.c1 as col3, cte.c2+1 as col4 from cte where cte.c1 < 0"; +execute st; +col1 col2 +3 1 +3 2 +execute st; +col1 col2 +3 1 +3 2 +save this to the end to test errors >drop prepare st; +create procedure sp() with cte (c1,c2) as (select * from t1) +select cte.c1+1 as col1 , cte.c2 as col2 from cte where cte.c1 > 1 +union +select cte.c1 as col3, cte.c2+1 as col4 from cte where cte.c1 < 0; +call sp(); +col1 col2 +3 1 +3 2 +call sp(); +col1 col2 +3 1 +3 2 +drop procedure sp; +insert into t1 select * from t2; +with cte (c1, c2) +as (select a, sum(b) from t1 where b > 1 group by a having sum(b) < 5) +select * from cte where c1 < 4 and c2 > 1; +c1 c2 +2 2 +# Check pushdown conditions in JSON output +explain format=json with cte (c1, c2) +as (select a, sum(b) from t1 where b > 1 group by a having sum(b) < 5) +select * from cte where c1 < 4 and c2 > 1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 10, + "filtered": 100, + "attached_condition": "cte.c1 < 4 and cte.c2 > 1", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "sum(t1.b) < 5 and c2 > 1", + "filesort": { + "sort_key": "t1.a", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 10, + "filtered": 100, + "attached_condition": "t1.b > 1 and t1.a < 4" + } + } + ] + } + } + } + } + } + } + ] + } +} +alter table t1 add column c int; +execute st; +ERROR HY000: WITH column list and SELECT field list have different column counts +drop prepare st; +drop table t1,t2; +Test out recursive CTEs +create table distances (src char(1), dest char(1), distance int); +create table city_population (city char(1), population int); +INSERT INTO `distances` VALUES ('A','A',0),('B','A',593),('C','A',800), +('D','A',221),('E','A',707),('F','A',869),('G','A',225),('H','A',519), +('A','B',919),('B','B',0),('C','B',440),('D','B',79),('E','B',79), +('F','B',154),('G','B',537),('H','B',220),('A','C',491),('B','C',794), +('C','C',0),('D','C',100),('E','C',350),('F','C',748),('G','C',712), +('H','C',315),('A','D',440),('B','D',256),('C','D',958),('D','D',0), +('E','D',255),('F','D',161),('G','D',63),('H','D',831),('A','E',968), +('B','E',345),('C','E',823),('D','E',81),('E','E',0),('F','E',436), +('G','E',373),('H','E',558),('A','F',670),('B','F',677),('C','F',375), +('D','F',843),('E','F',90),('F','F',0),('G','F',328),('H','F',881), +('A','G',422),('B','G',467),('C','G',67),('D','G',936),('E','G',480), +('F','G',592),('G','G',0),('H','G',819),('A','H',537),('B','H',229), +('C','H',534),('D','H',984),('E','H',319),('F','H',643),('G','H',257), +('H','H',0); +insert into city_population values ('A', 5000), ('B', 6000), ('C', 100000), +('D', 80000), ('E', 7000), ('F', 1000), ('G', 100), ('H', -80000); +#find the biggest city within 300 kellikams of 'E' +with recursive travel (src, path, dest, distance, population) as ( +select city, cast('' as varchar(10)), city, +0, population +from city_population where city='E' + union all +select src.src, concat(src.path, dst.dest), dst.dest, +src.distance + dst.distance, dstc.population +from travel src +join distances dst on src.dest != dst.dest +join city_population dstc on dst.dest = dstc.city +where dst.src = src.dest and src.distance + dst.distance < 300 +and length(path) < 10 +) +select * from travel where dest != 'E' order by population desc, distance +limit 1; +src path dest distance population +E FD D 251 80000 +prepare st from "with recursive travel (src, path, dest, distance, population) as ( +select city, cast('' as varchar(10)), city, +0, population +from city_population where city='E' + union all +select src.src, concat(src.path, dst.dest), dst.dest, +src.distance + dst.distance, dstc.population +from travel src +join distances dst on src.dest != dst.dest +join city_population dstc on dst.dest = dstc.city +where dst.src = src.dest and src.distance + dst.distance < 300 +and length(path) < 10 +) +select * from travel where dest != 'E' order by population desc, distance +limit 1"; +execute st; +src path dest distance population +E FD D 251 80000 +execute st; +src path dest distance population +E FD D 251 80000 +drop prepare st; +create procedure sp() with recursive travel (src, path, dest, distance, population) as ( +select city, cast('' as varchar(10)), city, +0, population +from city_population where city='E' + union all +select src.src, concat(src.path, dst.dest), dst.dest, +src.distance + dst.distance, dstc.population +from travel src +join distances dst on src.dest != dst.dest +join city_population dstc on dst.dest = dstc.city +where dst.src = src.dest and src.distance + dst.distance < 300 +and length(path) < 10 +) +select * from travel where dest != 'E' order by population desc, distance +limit 1; +call sp(); +src path dest distance population +E FD D 251 80000 +call sp(); +src path dest distance population +E FD D 251 80000 +drop procedure sp; +drop table distances, city_population; +# +# MDEV-28615: Multi-table UPDATE over derived table containing +# row that uses subquery with hanging CTE +# +CREATE TABLE t1 (a int) ENGINE=MYISAM; +INSERT INTO t1 VALUES (3), (7), (1); +UPDATE +(SELECT (5, (WITH cte AS (SELECT 1) SELECT a FROM t1))) dt +JOIN t1 t +ON t.a=dt.a +SET t.a = 1; +ERROR 21000: Operand should contain 1 column(s) +UPDATE +(SELECT a FROM t1 +WHERE (5, (WITH cte AS (SELECT 1) SELECT a FROM t1 WHERE a > 4)) <= +(5,a)) dt +JOIN t1 t +ON t.a=dt.a +SET t.a = 1; +SELECT * FROM t1; +a +3 +1 +1 +DROP TABLE t1; +# +# MDEV-31657: CTE with the same name as base table used twice +# in another CTE +# +create table t (a int); +insert into t values (3), (7), (1); +with +t as (select * from t), +cte as (select t1.a as t1a, t2.a as t2a from t as t1, t as t2 where t1.a=t2.a) +select * from cte; +t1a t2a +3 3 +7 7 +1 1 +create table s (a int); +insert into s values (1), (4), (7); +with +t as (select * from t), +s as (select a-1 as a from s), +cte as (select t.a as ta, s.a as sa from t, s where t.a=s.a +union +select t.a+1, s.a+1 from t, s where t.a=s.a+1) +select * from cte; +ta sa +3 3 +2 1 +8 7 +with +t as (select * from t), +cte as (select t.a as ta, s.a as sa from t, s where t.a=s.a +union +select t.a+1, s.a+1 from t, s where t.a=s.a), +s as (select a+10 as a from s) +select * from cte; +ta sa +1 1 +7 7 +2 2 +8 8 +drop table t,s; +with +t as (select * from t), +cte as (select t1.a as t1a, t2.a as t2a from t as t1, t as t2 where t1.a=t2.a) +select * from cte; +ERROR 42S02: Table 'test.t' doesn't exist # End of 10.4 tests diff --git a/mysql-test/main/cte_nonrecursive.test b/mysql-test/main/cte_nonrecursive.test index c420a5e0..bebf02ea 100644 --- a/mysql-test/main/cte_nonrecursive.test +++ b/mysql-test/main/cte_nonrecursive.test @@ -1796,4 +1796,233 @@ with data as (select 1 as id) select id into @myid from data; set sql_mode= @save_sql_mode; +--echo # +--echo # MDEV-31995 Bogus error executing PS for query using CTE with renaming of columns +--echo # + +create table t1 (a int, b int); +insert into t1 values (1,1),(1,2),(1,3),(2,1),(2,2); +create table t2 (a int, b int); +insert into t2 values (3,1),(3,2),(3,3),(4,1),(4,2); + +let $q= +with cte (c1,c2) as + (select a as col1, sum(b) as col2 from t1 group by col1) +select * from cte; + +eval $q; + +eval prepare st from "$q"; +execute st; +execute st; +drop prepare st; + +eval create procedure sp() $q; +call sp(); +call sp(); +drop procedure sp; + +let $q= +with cte (c1,c2) as + (select a as col1, sum(b) as col2 from t1 order by col1) +select * from cte; + +eval $q; + +eval prepare st from "$q"; +execute st; +execute st; +drop prepare st; + +eval create procedure sp() $q; +call sp(); +call sp(); +drop procedure sp; + +let $q= +with cte (c1,c2) as + (select a as col1, sum(b) as col2 from t1 where a > 1 group by col1 + union select a as col3, sum(b) as col4 from t2 where b > 2 group by col3), +cte2 (c3, c4) as + (select a as col5, sum(b) as col6 from t1 where a <= 1 group by col5 + union select a as col7, sum(b) as col8 from t2 where b <= 2 group by col7) +select * from cte where c1=1 union select * from cte2 where c3=3; + +eval $q; + +eval prepare st from "$q"; +execute st; +execute st; +drop prepare st; + +eval create procedure sp() $q; +call sp(); +call sp(); +drop procedure sp; + +let $q= +with cte (c1,c2) as (select * from t1) +select cte.c1+1 as col1 , cte.c2 as col2 from cte where cte.c1 > 1 +union +select cte.c1 as col3, cte.c2+1 as col4 from cte where cte.c1 < 0; + +eval $q; + +eval prepare st from "$q"; +execute st; +execute st; +--echo save this to the end to test errors >drop prepare st; + +eval create procedure sp() $q; +call sp(); +call sp(); +drop procedure sp; + +insert into t1 select * from t2; + +let $q= +with cte (c1, c2) + as (select a, sum(b) from t1 where b > 1 group by a having sum(b) < 5) +select * from cte where c1 < 4 and c2 > 1; + +eval $q; + +--echo # Check pushdown conditions in JSON output +--source include/analyze-format.inc +eval explain format=json $q; + +alter table t1 add column c int; + +--error ER_WITH_COL_WRONG_LIST +execute st; + +drop prepare st; +drop table t1,t2; + +--echo Test out recursive CTEs + +create table distances (src char(1), dest char(1), distance int); +create table city_population (city char(1), population int); +INSERT INTO `distances` VALUES ('A','A',0),('B','A',593),('C','A',800), +('D','A',221),('E','A',707),('F','A',869),('G','A',225),('H','A',519), +('A','B',919),('B','B',0),('C','B',440),('D','B',79),('E','B',79), +('F','B',154),('G','B',537),('H','B',220),('A','C',491),('B','C',794), +('C','C',0),('D','C',100),('E','C',350),('F','C',748),('G','C',712), +('H','C',315),('A','D',440),('B','D',256),('C','D',958),('D','D',0), +('E','D',255),('F','D',161),('G','D',63),('H','D',831),('A','E',968), +('B','E',345),('C','E',823),('D','E',81),('E','E',0),('F','E',436), +('G','E',373),('H','E',558),('A','F',670),('B','F',677),('C','F',375), +('D','F',843),('E','F',90),('F','F',0),('G','F',328),('H','F',881), +('A','G',422),('B','G',467),('C','G',67),('D','G',936),('E','G',480), +('F','G',592),('G','G',0),('H','G',819),('A','H',537),('B','H',229), +('C','H',534),('D','H',984),('E','H',319),('F','H',643),('G','H',257), +('H','H',0); +insert into city_population values ('A', 5000), ('B', 6000), ('C', 100000), +('D', 80000), ('E', 7000), ('F', 1000), ('G', 100), ('H', -80000); + +--echo #find the biggest city within 300 kellikams of 'E' +let $q= +with recursive travel (src, path, dest, distance, population) as ( + select city, cast('' as varchar(10)), city, + 0, population + from city_population where city='E' + union all + select src.src, concat(src.path, dst.dest), dst.dest, + src.distance + dst.distance, dstc.population + from travel src + join distances dst on src.dest != dst.dest + join city_population dstc on dst.dest = dstc.city + where dst.src = src.dest and src.distance + dst.distance < 300 + and length(path) < 10 + ) +select * from travel where dest != 'E' order by population desc, distance +limit 1; + +eval $q; + +eval prepare st from "$q"; +execute st; +execute st; +drop prepare st; + +eval create procedure sp() $q; +call sp(); +call sp(); +drop procedure sp; + +drop table distances, city_population; + +--echo # +--echo # MDEV-28615: Multi-table UPDATE over derived table containing +--echo # row that uses subquery with hanging CTE +--echo # + +CREATE TABLE t1 (a int) ENGINE=MYISAM; +INSERT INTO t1 VALUES (3), (7), (1); + +--error ER_OPERAND_COLUMNS +UPDATE + (SELECT (5, (WITH cte AS (SELECT 1) SELECT a FROM t1))) dt + JOIN t1 t + ON t.a=dt.a +SET t.a = 1; + +UPDATE + (SELECT a FROM t1 + WHERE (5, (WITH cte AS (SELECT 1) SELECT a FROM t1 WHERE a > 4)) <= + (5,a)) dt + JOIN t1 t + ON t.a=dt.a +SET t.a = 1; + +SELECT * FROM t1; + +DROP TABLE t1; + +--echo # +--echo # MDEV-31657: CTE with the same name as base table used twice +--echo # in another CTE +--echo # + +create table t (a int); +insert into t values (3), (7), (1); + +let $q1= +with +t as (select * from t), +cte as (select t1.a as t1a, t2.a as t2a from t as t1, t as t2 where t1.a=t2.a) +select * from cte; + +eval $q1; + +create table s (a int); +insert into s values (1), (4), (7); + +let $q2= +with +t as (select * from t), +s as (select a-1 as a from s), +cte as (select t.a as ta, s.a as sa from t, s where t.a=s.a + union + select t.a+1, s.a+1 from t, s where t.a=s.a+1) +select * from cte; + +eval $q2; + +let $q3= +with +t as (select * from t), +cte as (select t.a as ta, s.a as sa from t, s where t.a=s.a + union + select t.a+1, s.a+1 from t, s where t.a=s.a), +s as (select a+10 as a from s) +select * from cte; + +eval $q3; + +drop table t,s; + +--ERROR ER_NO_SUCH_TABLE +eval $q1; + --echo # End of 10.4 tests diff --git a/mysql-test/main/ctype_collate.result b/mysql-test/main/ctype_collate.result index d53efe89..eafe7ff3 100644 --- a/mysql-test/main/ctype_collate.result +++ b/mysql-test/main/ctype_collate.result @@ -614,18 +614,24 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN SELECT * FROM t1 WHERE s2 BETWEEN 'a' AND 'b' COLLATE latin1_german1_ci; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL s2 NULL NULL NULL 10 Using where +Warnings: +Note 1105 Cannot use key `s2` part[0] for lookup: `test`.`t1`.`s2` of collation `latin1_swedish_ci` >= "'a'" of collation `latin1_german1_ci` EXPLAIN SELECT * FROM t1 WHERE s1 IN ('a','b' COLLATE latin1_german1_ci); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range s1 s1 11 NULL 2 Using index condition EXPLAIN SELECT * FROM t1 WHERE s2 IN ('a','b' COLLATE latin1_german1_ci); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL s2 NULL NULL NULL 10 Using where +Warnings: +Note 1105 Cannot use key `s2` part[0] for lookup: `test`.`t1`.`s2` of collation `latin1_swedish_ci` = "'a'" of collation `latin1_german1_ci` EXPLAIN SELECT * FROM t1 WHERE s1 LIKE 'a' COLLATE latin1_german1_ci; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range s1 s1 11 NULL 1 Using index condition EXPLAIN SELECT * FROM t1 WHERE s2 LIKE 'a' COLLATE latin1_german1_ci; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL s2 NULL NULL NULL 10 Using where +Warnings: +Note 1105 Cannot use key `s2` part[0] for lookup: `test`.`t1`.`s2` of collation `latin1_swedish_ci` like "'a' collate latin1_german1_ci" of collation `latin1_german1_ci` DROP TABLE t1; create table t1(f1 varchar(10) character set latin2 collate latin2_hungarian_ci, key(f1)); insert into t1 set f1=0x3F3F9DC73F; diff --git a/mysql-test/main/ctype_cp932.result b/mysql-test/main/ctype_cp932.result index 47b3cbc1..a66bf1da 100644 --- a/mysql-test/main/ctype_cp932.result +++ b/mysql-test/main/ctype_cp932.result @@ -888,7 +888,7 @@ 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' +ERROR HY000: Invalid cp932 character string: '\x81' # # SET SESSION (bad|good.bad|bad.good)=1 # @@ -897,7 +897,7 @@ 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' +ERROR HY000: Invalid cp932 character string: '\x81' # # SET (bad|good.bad|bad.good)=1 # @@ -906,7 +906,7 @@ 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' +ERROR HY000: Invalid cp932 character string: '\x81' # # Oracle SP call: BEGIN (bad|good.bad|bad.good)(params); END # @@ -916,7 +916,7 @@ 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' +ERROR HY000: Invalid cp932 character string: '\x81' # # Oracle assignment: (bad|good.bad|bad.good):= value # @@ -925,7 +925,7 @@ 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' +ERROR HY000: Invalid cp932 character string: '\x81' SET sql_mode=DEFAULT; # # End of 10.5 tests diff --git a/mysql-test/main/ctype_sjis.result b/mysql-test/main/ctype_sjis.result index ee760d9c..7a1f4cf5 100644 --- a/mysql-test/main/ctype_sjis.result +++ b/mysql-test/main/ctype_sjis.result @@ -19619,7 +19619,7 @@ 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' +ERROR HY000: Invalid sjis character string: '_x81' # # SET SESSION (bad|good.bad|bad.good)=1 # @@ -19628,7 +19628,7 @@ 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' +ERROR HY000: Invalid sjis character string: '_x81' # # SET (bad|good.bad|bad.good)=1 # @@ -19637,7 +19637,7 @@ 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' +ERROR HY000: Invalid sjis character string: '_x81' # # Oracle SP call: BEGIN (bad|good.bad|bad.good)(params); END # @@ -19647,7 +19647,7 @@ 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' +ERROR HY000: Invalid sjis character string: '_x81' # # Oracle assignment: (bad|good.bad|bad.good):= value # @@ -19656,7 +19656,7 @@ 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' +ERROR HY000: Invalid sjis character string: '_x81' SET sql_mode=DEFAULT; # # End of 10.5 tests diff --git a/mysql-test/main/derived_split_innodb.result b/mysql-test/main/derived_split_innodb.result index 31522379..b9ee3f0a 100644 --- a/mysql-test/main/derived_split_innodb.result +++ b/mysql-test/main/derived_split_innodb.result @@ -862,5 +862,20 @@ SELECT * FROM t1 JOIN t2 WHERE (t1.a, t2.b) IN (SELECT * FROM v); a b DROP VIEW v; DROP TABLE t1, t2, t3; +# +# MDEV-31279 Crash when lateral derived is guaranteed to return no rows +# +CREATE TABLE t1 (a CHAR(1)) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('1'),('2'); +CREATE TABLE t2 (b INT, KEY(b)) ENGINE=MyISAM; +ALTER TABLE t2 DISABLE KEYS; +INSERT INTO t2 VALUES (1),(2),(3); +ALTER TABLE t2 ENABLE KEYS; +CREATE TABLE t3 (c INT) ENGINE=MyISAM; +INSERT INTO t3 (c) SELECT seq FROM seq_1_to_101; +SELECT * FROM t1 WHERE t1.a IN (SELECT b FROM +(SELECT t2.b FROM t2 WHERE NOT EXISTS (SELECT 1 FROM t3) GROUP BY b) sq); +a +DROP TABLE t1, t2, t3; # End of 10.4 tests SET GLOBAL innodb_stats_persistent=@save_innodb_stats_persistent; diff --git a/mysql-test/main/derived_split_innodb.test b/mysql-test/main/derived_split_innodb.test index bccda42d..075d6e81 100644 --- a/mysql-test/main/derived_split_innodb.test +++ b/mysql-test/main/derived_split_innodb.test @@ -487,6 +487,24 @@ SELECT * FROM t1 JOIN t2 WHERE (t1.a, t2.b) IN (SELECT * FROM v); DROP VIEW v; DROP TABLE t1, t2, t3; +--echo # +--echo # MDEV-31279 Crash when lateral derived is guaranteed to return no rows +--echo # + +CREATE TABLE t1 (a CHAR(1)) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('1'),('2'); +CREATE TABLE t2 (b INT, KEY(b)) ENGINE=MyISAM; +ALTER TABLE t2 DISABLE KEYS; +INSERT INTO t2 VALUES (1),(2),(3); +ALTER TABLE t2 ENABLE KEYS; +CREATE TABLE t3 (c INT) ENGINE=MyISAM; +INSERT INTO t3 (c) SELECT seq FROM seq_1_to_101; + +SELECT * FROM t1 WHERE t1.a IN (SELECT b FROM + (SELECT t2.b FROM t2 WHERE NOT EXISTS (SELECT 1 FROM t3) GROUP BY b) sq); + +DROP TABLE t1, t2, t3; + --echo # End of 10.4 tests SET GLOBAL innodb_stats_persistent=@save_innodb_stats_persistent; diff --git a/mysql-test/main/derived_view.result b/mysql-test/main/derived_view.result index 6bc9b424..3ac06c20 100644 --- a/mysql-test/main/derived_view.result +++ b/mysql-test/main/derived_view.result @@ -4246,6 +4246,51 @@ a deallocate prepare stmt; drop view v; drop table t1,t2,t3; +# +# MDEV-32829 Crash when executing PS for query with eliminated subquery +# using view +# +create view v1 as select 1 as a; +prepare stmt from +'SELECT EXISTS (SELECT 1 FROM v1 GROUP BY a IN (SELECT a FROM v1))'; +execute stmt; +EXISTS (SELECT 1 FROM v1 GROUP BY a IN (SELECT a FROM v1)) +1 +drop view v1; +create table t1 (a int, b int); +insert into t1 values (1,2),(3,4),(5,6); +create view v1 as select * from t1; +create table t2 select * from t1; +prepare stmt from "select t2.a from t2 where exists +( +select * from t1 where t2.b = t1.b and t1.b != 6 +group by a in (select a from v1 where v1.a = t2.a) +)"; +execute stmt; +a +1 +3 +execute stmt; +a +1 +3 +deallocate prepare stmt; +create procedure aproc() select t2.a from t2 where exists +( +select * from t1 where t2.b = t1.b and t1.b != 6 +group by a in (select a from v1 where v1.a = t2.a) +); +call aproc(); +a +1 +3 +call aproc(); +a +1 +3 +drop table t1, t2; +drop view v1; +drop procedure aproc; # End of 10.4 tests # # MDEV-31143: view with ORDER BY used in query with rownum() in WHERE diff --git a/mysql-test/main/derived_view.test b/mysql-test/main/derived_view.test index 03565ae0..ddead30a 100644 --- a/mysql-test/main/derived_view.test +++ b/mysql-test/main/derived_view.test @@ -2759,6 +2759,42 @@ deallocate prepare stmt; drop view v; drop table t1,t2,t3; +--echo # +--echo # MDEV-32829 Crash when executing PS for query with eliminated subquery +--echo # using view +--echo # + +create view v1 as select 1 as a; +prepare stmt from + 'SELECT EXISTS (SELECT 1 FROM v1 GROUP BY a IN (SELECT a FROM v1))'; +execute stmt; +drop view v1; + +create table t1 (a int, b int); +insert into t1 values (1,2),(3,4),(5,6); +create view v1 as select * from t1; +create table t2 select * from t1; + +let $q= +select t2.a from t2 where exists +( + select * from t1 where t2.b = t1.b and t1.b != 6 + group by a in (select a from v1 where v1.a = t2.a) +); + +eval prepare stmt from "$q"; +execute stmt; +execute stmt; +deallocate prepare stmt; + +eval create procedure aproc() $q; +call aproc(); +call aproc(); + +drop table t1, t2; +drop view v1; +drop procedure aproc; + --echo # End of 10.4 tests --echo # diff --git a/mysql-test/main/disabled.def b/mysql-test/main/disabled.def index 02104f6a..8ba5b271 100644 --- a/mysql-test/main/disabled.def +++ b/mysql-test/main/disabled.def @@ -17,4 +17,3 @@ 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 diff --git a/mysql-test/main/dyncol.test b/mysql-test/main/dyncol.test index cb983bd3..8b316421 100644 --- a/mysql-test/main/dyncol.test +++ b/mysql-test/main/dyncol.test @@ -670,18 +670,16 @@ SELECT COLUMN_GET(`x`, 'y' AS DECIMAL(5,50)); --echo # --echo # creation test (names) set names utf8; -#enable after MDEV-32465 fix ---disable_view_protocol +--disable_service_connection select hex(column_create("адын", 1212)); ---enable_view_protocol +--enable_service_connection select hex(column_create("1212", 1212)); select hex(column_create(1212, 2, "www", 3)); select hex(column_create("1212", 2, "www", 3)); select hex(column_create("1212", 2, 3, 3)); -#enable after MDEV-32465 fix ---disable_view_protocol +--disable_service_connection select hex(column_create("1212", 2, "адын", 1, 3, 3)); ---enable_view_protocol +--enable_service_connection set names latin1; --echo # fetching column test (names) @@ -708,15 +706,14 @@ select column_exists(column_create("1212", 2, "адын", 1, 3, 3), "4") as ex; set names latin1; --echo # column changing test (names) -#enable after MDEV-32465 fix ---disable_view_protocol +--disable_service_connection select hex(column_add(column_create(1, "AAA"), "b", "BBB")) as ex; select hex(column_add(column_create("1", "AAA"), "b", "BBB")) as ex; select column_get(column_add(column_create(1, "AAA"), "b", "BBB"), 1 as char) as ex; select column_get(column_add(column_create(1, "AAA"), "b", "BBB"), "b" as char) as ex; select hex(column_add(column_create("a", "AAA"), 1, "BBB")) as ex; select hex(column_add(column_create("a", "AAA"), "1", "BBB")) as ex; ---enable_view_protocol +--enable_service_connection select hex(column_add(column_create("a", 1212 as integer), "b", "1212" as integer)) as ex; select hex(column_add(column_create("a", 1212 as integer), "a", "1212" as integer)) as ex; select hex(column_add(column_create("a", 1212 as integer), "a", NULL as integer)) as ex; diff --git a/mysql-test/main/enforce_storage_engine.result b/mysql-test/main/enforce_storage_engine.result index c761277a..cc91daa7 100644 --- a/mysql-test/main/enforce_storage_engine.result +++ b/mysql-test/main/enforce_storage_engine.result @@ -158,5 +158,12 @@ t3 CREATE TABLE `t3` ( PRIMARY KEY (`c1`) ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci DROP TABLE t3; +# +# MDEV-21618 CREATE UNIQUE INDEX fails with "ERROR 1286 (42000): Unknown storage engine 'partition'" +# +SET SESSION enforce_storage_engine=MyISAM; +CREATE TABLE t4 (a INT) ENGINE=MyISAM PARTITION BY HASH(a); +CREATE INDEX x on t4 (a); +DROP TABLE t4; SET SESSION enforce_storage_engine=NULL; SET GLOBAL enforce_storage_engine=NULL; diff --git a/mysql-test/main/enforce_storage_engine.test b/mysql-test/main/enforce_storage_engine.test index 6b422477..7768ed1b 100644 --- a/mysql-test/main/enforce_storage_engine.test +++ b/mysql-test/main/enforce_storage_engine.test @@ -1,4 +1,5 @@ --- source include/not_embedded.inc +--source include/not_embedded.inc +--source include/have_partition.inc set local sql_mode=""; set global sql_mode=""; @@ -107,5 +108,15 @@ ALTER TABLE t3 ADD COLUMN c3 INT; SHOW CREATE TABLE t3; DROP TABLE t3; +--echo # +--echo # MDEV-21618 CREATE UNIQUE INDEX fails with "ERROR 1286 (42000): Unknown storage engine 'partition'" +--echo # +SET SESSION enforce_storage_engine=MyISAM; + +CREATE TABLE t4 (a INT) ENGINE=MyISAM PARTITION BY HASH(a); +CREATE INDEX x on t4 (a); + +DROP TABLE t4; + SET SESSION enforce_storage_engine=NULL; -SET GLOBAL enforce_storage_engine=NULL;
\ No newline at end of file +SET GLOBAL enforce_storage_engine=NULL; diff --git a/mysql-test/main/execution_constants.test b/mysql-test/main/execution_constants.test index 285197cd..49b1da8f 100644 --- a/mysql-test/main/execution_constants.test +++ b/mysql-test/main/execution_constants.test @@ -1,5 +1,6 @@ # In embedded server we don't really have a control over stack usage -- source include/not_embedded.inc +-- source include/not_asan.inc # # Bug#21476: Lost Database Connection During Query diff --git a/mysql-test/main/explain.result b/mysql-test/main/explain.result index 8db5e9f5..75d46110 100644 --- a/mysql-test/main/explain.result +++ b/mysql-test/main/explain.result @@ -458,3 +458,43 @@ id select_type table type possible_keys key key_len ref rows Extra NULL UNION RESULT <union1,3> ALL NULL NULL NULL NULL NULL Warnings: Note 1249 Select 4 was reduced during optimization +# +# End of 10.4 tests +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (3),(4); +EXPLAIN SELECT * FROM t1, t2 WHERE t2.b IN (SELECT 5 UNION SELECT 6); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used +3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL +EXPLAIN DELETE t2 FROM t1, t2 WHERE t2.b IN (SELECT 5 UNION SELECT 6); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used +3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL +prepare stmt from "EXPLAIN DELETE t2 FROM t1, t2 WHERE t2.b IN (SELECT 5 UNION SELECT 6)"; +execute stmt; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used +3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL +execute stmt; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used +3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL +DROP TABLE t1, t2; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/explain.test b/mysql-test/main/explain.test index 36595ba7..5269fccf 100644 --- a/mysql-test/main/explain.test +++ b/mysql-test/main/explain.test @@ -372,3 +372,26 @@ drop table t1; explain VALUES ( (VALUES (2))) UNION VALUES ( (SELECT 3)); --enable_ps_protocol + +--echo # +--echo # End of 10.4 tests +--echo # + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (3),(4); + +EXPLAIN SELECT * FROM t1, t2 WHERE t2.b IN (SELECT 5 UNION SELECT 6); +EXPLAIN DELETE t2 FROM t1, t2 WHERE t2.b IN (SELECT 5 UNION SELECT 6); +prepare stmt from "EXPLAIN DELETE t2 FROM t1, t2 WHERE t2.b IN (SELECT 5 UNION SELECT 6)"; +execute stmt; +execute stmt; + +# Cleanup + +DROP TABLE t1, t2; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/func_compress.test b/mysql-test/main/func_compress.test index 221dddd5..d18af140 100644 --- a/mysql-test/main/func_compress.test +++ b/mysql-test/main/func_compress.test @@ -1,5 +1,5 @@ -- source include/have_compress.inc --- source include/have_normal_bzip.inc +-- source include/have_normal_zlib.inc # # Test for compress and uncompress functions: # diff --git a/mysql-test/main/func_in.result b/mysql-test/main/func_in.result index 4627208d..b3865bab 100644 --- a/mysql-test/main/func_in.result +++ b/mysql-test/main/func_in.result @@ -531,6 +531,8 @@ Warning 1292 Truncated incorrect DECIMAL value: 'b' explain select f1 from t1 where f1 in (2,1); 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 +Warnings: +Note 1105 Cannot use key `t1f1_idx` part[0] for lookup: `test`.`t1`.`f1` of type `char` = "2" of type `int` create table t2(f2 int, index t2f2(f2)); insert into t2 values(0),(1),(2); select f2 from t2 where f2 in ('a',2); diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result index 0336de08..ea1767af 100644 --- a/mysql-test/main/func_json.result +++ b/mysql-test/main/func_json.result @@ -1460,6 +1460,39 @@ f foo SET @@COLLATION_CONNECTION= @old_collation_connection; # +# MDEV-32587 JSON_VALID fail to validate integer zero in scientific notation +# +select JSON_VALID(' {"number": 1E-4}'); +JSON_VALID(' {"number": 1E-4}') +1 +select JSON_VALID(' {"number": 0E-4}'); +JSON_VALID(' {"number": 0E-4}') +1 +select JSON_VALID(' {"number": 0.0}'); +JSON_VALID(' {"number": 0.0}') +1 +select JSON_VALID(' {"number": 0.1E-4}'); +JSON_VALID(' {"number": 0.1E-4}') +1 +select JSON_VALID(' {"number": 0e-4}'); +JSON_VALID(' {"number": 0e-4}') +1 +select JSON_VALID(' {"number": -0E-4}'); +JSON_VALID(' {"number": -0E-4}') +1 +select JSON_VALUE(' {"number": 0E-4}', '$.number'); +JSON_VALUE(' {"number": 0E-4}', '$.number') +0E-4 +select JSON_VALID(' {"number": 00E-4}'); +JSON_VALID(' {"number": 00E-4}') +0 +select JSON_VALID(' {"number": 01E-4}'); +JSON_VALID(' {"number": 01E-4}') +0 +select JSON_VALID(' {"number": 0E-4.0}'); +JSON_VALID(' {"number": 0E-4.0}') +0 +# # End of 10.4 tests # # @@ -1646,6 +1679,17 @@ SELECT JSON_OBJECTAGG('\\', 1); JSON_OBJECTAGG('\\', 1) {"\\":1} # +# MDEV-24784 JSON_ARRAYAGG charset issue +# +set names utf8; +select json_arrayagg('ä'), json_objectagg(1, 'ä'); +json_arrayagg('ä') json_objectagg(1, 'ä') +["ä"] {"1":"ä"} +set names latin1; +select json_arrayagg('ä'), json_objectagg(1, 'ä'); +json_arrayagg('ä') json_objectagg(1, 'ä') +["ä"] {"1":"ä"} +# # End of 10.5 tests # # diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index 2218a976..f8a656c9 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -948,6 +948,22 @@ SELECT JSON_VALUE('["foo"]', '$**[0]') AS f; SET @@COLLATION_CONNECTION= @old_collation_connection; --echo # +--echo # MDEV-32587 JSON_VALID fail to validate integer zero in scientific notation +--echo # +# Passing +select JSON_VALID(' {"number": 1E-4}'); +select JSON_VALID(' {"number": 0E-4}'); +select JSON_VALID(' {"number": 0.0}'); +select JSON_VALID(' {"number": 0.1E-4}'); +select JSON_VALID(' {"number": 0e-4}'); +select JSON_VALID(' {"number": -0E-4}'); +select JSON_VALUE(' {"number": 0E-4}', '$.number'); +# Failing +select JSON_VALID(' {"number": 00E-4}'); +select JSON_VALID(' {"number": 01E-4}'); +select JSON_VALID(' {"number": 0E-4.0}'); + +--echo # --echo # End of 10.4 tests --echo # @@ -1112,6 +1128,16 @@ SELECT JSON_OBJECTAGG('\"', 1); SELECT JSON_OBJECTAGG('\\', 1); --echo # +--echo # MDEV-24784 JSON_ARRAYAGG charset issue +--echo # +--disable_service_connection +set names utf8; +select json_arrayagg('ä'), json_objectagg(1, 'ä'); +set names latin1; +select json_arrayagg('ä'), json_objectagg(1, 'ä'); +--enable_service_connection + +--echo # --echo # End of 10.5 tests --echo # diff --git a/mysql-test/main/func_regexp_pcre.result b/mysql-test/main/func_regexp_pcre.result index 9e51ced9..36f2fced 100644 --- a/mysql-test/main/func_regexp_pcre.result +++ b/mysql-test/main/func_regexp_pcre.result @@ -895,3 +895,12 @@ REGEXP_INSTR('a_kollision', 'o([lm])\\1') 4 SELECT a FROM (SELECT "aa" a) t WHERE a REGEXP '[0-9]'; a +# +# MDEV-11777 REGEXP_REPLACE converts utf8mb4 supplementary characters to '?' +# +select hex(regexp_replace(cast(x'F09F9881' as char character set 'utf8mb4'), _utf8mb4'a', _utf8mb4'b')) as Text; +Text +F09F9881 +# +# End of 10.6 tests +# diff --git a/mysql-test/main/func_regexp_pcre.test b/mysql-test/main/func_regexp_pcre.test index e6e356f4..8c2408f5 100644 --- a/mysql-test/main/func_regexp_pcre.test +++ b/mysql-test/main/func_regexp_pcre.test @@ -470,3 +470,11 @@ SELECT REGEXP_INSTR('a_kollision', 'o([lm])\\1'); # SELECT a FROM (SELECT "aa" a) t WHERE a REGEXP '[0-9]'; --enable_service_connection + +--echo # +--echo # MDEV-11777 REGEXP_REPLACE converts utf8mb4 supplementary characters to '?' +--echo # +select hex(regexp_replace(cast(x'F09F9881' as char character set 'utf8mb4'), _utf8mb4'a', _utf8mb4'b')) as Text; +--echo # +--echo # End of 10.6 tests +--echo # diff --git a/mysql-test/main/func_replace.result b/mysql-test/main/func_replace.result new file mode 100644 index 00000000..7f354d52 --- /dev/null +++ b/mysql-test/main/func_replace.result @@ -0,0 +1,124 @@ +# +# Start of 10.5 tests +# +# +# MDEV-17226 Column Data in Truncated on UNION to the length of the first value if using REPLACE +# +CREATE TABLE t1 ( +id INT UNSIGNED NOT NULL AUTO_INCREMENT, +col1 VARCHAR (2), +col2 VARCHAR (2), +PRIMARY KEY (id) +); +CREATE TABLE t2 ( +id INT UNSIGNED NOT NULL AUTO_INCREMENT, +col1 VARCHAR (1), +col2 VARCHAR (2), +PRIMARY KEY (id) +); +INSERT INTO t1 (col1, col2) VALUES ("a", "ba"); +INSERT INTO t2 (col1, col2) VALUES ("a", "ba"); +SELECT 'a' UNION ALL SELECT REPLACE('a', col1, col2) FROM t1; +a +a +ba +SELECT 'a' UNION ALL SELECT REPLACE('a', col1, col2) FROM t2; +a +a +ba +SELECT REPLACE('z', col1, col2) FROM t1 UNION ALL SELECT REPLACE('a', col1, col2) FROM t1; +REPLACE('z', col1, col2) +z +ba +SELECT REPLACE('z', col1, col2) FROM t2 UNION ALL SELECT REPLACE('a', col1, col2) FROM t2; +REPLACE('z', col1, col2) +z +ba +DROP TABLE t1, t2; +CREATE TABLE t1 ( +id INT UNSIGNED NOT NULL AUTO_INCREMENT, +col1 VARCHAR (2), +col2 VARCHAR (2), +PRIMARY KEY (id) +); +INSERT INTO t1 (col1, col2) VALUES ('a', 'ba'); +SELECT REPLACE('a', col1, col2) FROM t1; +REPLACE('a', col1, col2) +ba +CREATE TABLE t2 AS SELECT 'a' UNION ALL SELECT REPLACE('a', col1, col2) FROM t1; +SELECT * FROM t2; +a +a +ba +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +DROP TABLE t1, t2; +CREATE TABLE t1 ( +id INT UNSIGNED NOT NULL AUTO_INCREMENT, +col1 VARCHAR (1), +col2 VARCHAR (10), +PRIMARY KEY (id) +); +INSERT INTO t1 (col1, col2) VALUES ('a', '0123456789'); +SELECT REPLACE('aa', col1, col2) FROM t1; +REPLACE('aa', col1, col2) +01234567890123456789 +CREATE TABLE t2 AS SELECT 'a' UNION ALL SELECT REPLACE('aa', col1, col2) FROM t1; +SELECT * FROM t2; +a +a +01234567890123456789 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +DROP TABLE t1, t2; +CREATE TABLE t1 ( +id INT UNSIGNED NOT NULL AUTO_INCREMENT, +col1 VARCHAR (1), +col2 VARCHAR (20), +PRIMARY KEY (id) +); +INSERT INTO t1 (col1, col2) VALUES ('a', 'aaaaaaaaaabbbbbbbbbb'); +SELECT REPLACE('aa', col1, col2) FROM t1; +REPLACE('aa', col1, col2) +aaaaaaaaaabbbbbbbbbbaaaaaaaaaabbbbbbbbbb +CREATE TABLE t2 AS SELECT 'a' UNION ALL SELECT REPLACE('aa', col1, col2) FROM t1; +SELECT * FROM t2; +a +a +aaaaaaaaaabbbbbbbbbbaaaaaaaaaabbbbbbbbbb +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(40) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +DROP TABLE t1, t2; +CREATE TABLE t1 ( +id INT UNSIGNED NOT NULL AUTO_INCREMENT, +col1 VARCHAR (1), +col2 VARCHAR (30), +PRIMARY KEY (id) +); +INSERT INTO t1 (col1, col2) VALUES ('a', 'aaaaaaaaaabbbbbbbbbbcccccccccc'); +SELECT REPLACE('aaa', col1, col2) FROM t1; +REPLACE('aaa', col1, col2) +aaaaaaaaaabbbbbbbbbbccccccccccaaaaaaaaaabbbbbbbbbbccccccccccaaaaaaaaaabbbbbbbbbbcccccccccc +CREATE TABLE t2 AS SELECT 'a' UNION ALL SELECT REPLACE('aaa', col1, col2) FROM t1; +SELECT * FROM t2; +a +a +aaaaaaaaaabbbbbbbbbbccccccccccaaaaaaaaaabbbbbbbbbbccccccccccaaaaaaaaaabbbbbbbbbbcccccccccc +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(90) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +DROP TABLE t1, t2; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/func_replace.test b/mysql-test/main/func_replace.test new file mode 100644 index 00000000..f06ef992 --- /dev/null +++ b/mysql-test/main/func_replace.test @@ -0,0 +1,86 @@ +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-17226 Column Data in Truncated on UNION to the length of the first value if using REPLACE +--echo # + +CREATE TABLE t1 ( + id INT UNSIGNED NOT NULL AUTO_INCREMENT, + col1 VARCHAR (2), + col2 VARCHAR (2), + PRIMARY KEY (id) +); +CREATE TABLE t2 ( + id INT UNSIGNED NOT NULL AUTO_INCREMENT, + col1 VARCHAR (1), + col2 VARCHAR (2), + PRIMARY KEY (id) +); +INSERT INTO t1 (col1, col2) VALUES ("a", "ba"); +INSERT INTO t2 (col1, col2) VALUES ("a", "ba"); +SELECT 'a' UNION ALL SELECT REPLACE('a', col1, col2) FROM t1; +SELECT 'a' UNION ALL SELECT REPLACE('a', col1, col2) FROM t2; +SELECT REPLACE('z', col1, col2) FROM t1 UNION ALL SELECT REPLACE('a', col1, col2) FROM t1; +SELECT REPLACE('z', col1, col2) FROM t2 UNION ALL SELECT REPLACE('a', col1, col2) FROM t2; +DROP TABLE t1, t2; + + + +CREATE TABLE t1 ( + id INT UNSIGNED NOT NULL AUTO_INCREMENT, + col1 VARCHAR (2), + col2 VARCHAR (2), + PRIMARY KEY (id) +); +INSERT INTO t1 (col1, col2) VALUES ('a', 'ba'); +SELECT REPLACE('a', col1, col2) FROM t1; +CREATE TABLE t2 AS SELECT 'a' UNION ALL SELECT REPLACE('a', col1, col2) FROM t1; +SELECT * FROM t2; +SHOW CREATE TABLE t2; +DROP TABLE t1, t2; + +CREATE TABLE t1 ( + id INT UNSIGNED NOT NULL AUTO_INCREMENT, + col1 VARCHAR (1), + col2 VARCHAR (10), + PRIMARY KEY (id) +); +INSERT INTO t1 (col1, col2) VALUES ('a', '0123456789'); +SELECT REPLACE('aa', col1, col2) FROM t1; +CREATE TABLE t2 AS SELECT 'a' UNION ALL SELECT REPLACE('aa', col1, col2) FROM t1; +SELECT * FROM t2; +SHOW CREATE TABLE t2; +DROP TABLE t1, t2; + +CREATE TABLE t1 ( + id INT UNSIGNED NOT NULL AUTO_INCREMENT, + col1 VARCHAR (1), + col2 VARCHAR (20), + PRIMARY KEY (id) +); +INSERT INTO t1 (col1, col2) VALUES ('a', 'aaaaaaaaaabbbbbbbbbb'); +SELECT REPLACE('aa', col1, col2) FROM t1; +CREATE TABLE t2 AS SELECT 'a' UNION ALL SELECT REPLACE('aa', col1, col2) FROM t1; +SELECT * FROM t2; +SHOW CREATE TABLE t2; +DROP TABLE t1, t2; + +CREATE TABLE t1 ( + id INT UNSIGNED NOT NULL AUTO_INCREMENT, + col1 VARCHAR (1), + col2 VARCHAR (30), + PRIMARY KEY (id) +); +INSERT INTO t1 (col1, col2) VALUES ('a', 'aaaaaaaaaabbbbbbbbbbcccccccccc'); +SELECT REPLACE('aaa', col1, col2) FROM t1; +CREATE TABLE t2 AS SELECT 'a' UNION ALL SELECT REPLACE('aaa', col1, col2) FROM t1; +SELECT * FROM t2; +SHOW CREATE TABLE t2; +DROP TABLE t1, t2; + + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/func_str.result b/mysql-test/main/func_str.result index daf97dd8..0d46453c 100644 --- a/mysql-test/main/func_str.result +++ b/mysql-test/main/func_str.result @@ -5286,6 +5286,33 @@ ERROR 42000: Incorrect parameter count in the call to native function 'DECODE' # End of 10.4 tests # # +# Start of 10.5 tests +# +# +# MDEV-28651 quote(NULL) returns incorrect result in view ('NU' instead of 'NULL') +# +CREATE VIEW v1 AS SELECT quote(NULL); +SELECT * FROM v1; +quote(NULL) +NULL +DESCRIBE v1; +Field Type Null Key Default Extra +quote(NULL) varbinary(4) YES NULL +CREATE TABLE t1 AS SELECT * FROM v1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `quote(NULL)` varbinary(4) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT * FROM t1; +quote(NULL) +NULL +DROP TABLE t1; +DROP VIEW v1; +# +# End of 10.5 tests +# +# # MDEV-25704 Function random_bytes # create table t1 as select random_bytes(100); diff --git a/mysql-test/main/func_str.test b/mysql-test/main/func_str.test index bbd84fde..e939b21e 100644 --- a/mysql-test/main/func_str.test +++ b/mysql-test/main/func_str.test @@ -2334,6 +2334,28 @@ SELECT DECODE(NULL, NULL, NULL); --echo # --echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-28651 quote(NULL) returns incorrect result in view ('NU' instead of 'NULL') +--echo # + +CREATE VIEW v1 AS SELECT quote(NULL); +SELECT * FROM v1; +DESCRIBE v1; +CREATE TABLE t1 AS SELECT * FROM v1; +SHOW CREATE TABLE t1; +SELECT * FROM t1; +DROP TABLE t1; +DROP VIEW v1; + + +--echo # +--echo # End of 10.5 tests +--echo # + +--echo # --echo # MDEV-25704 Function random_bytes --echo # diff --git a/mysql-test/main/gis.result b/mysql-test/main/gis.result index 99d41aad..d8d42489 100644 --- a/mysql-test/main/gis.result +++ b/mysql-test/main/gis.result @@ -5328,5 +5328,112 @@ SELECT BIT_XOR(a) FROM t1; ERROR HY000: Illegal parameter data type geometry for operation 'bit_xor(' DROP TABLE t1; # +# MDEV-27666 User variable not parsed as geometry variable in geometry function. +# +set @g= point(1, 1); +select ST_AsWKT(GeometryCollection(Point(44, 6), @g)); +ST_AsWKT(GeometryCollection(Point(44, 6), @g)) +GEOMETRYCOLLECTION(POINT(44 6),POINT(1 1)) +set @g= "just a string"; +select ST_AsWKT(GeometryCollection(Point(44, 6), @g)); +ERROR HY000: Illegal parameter data type longblob for operation 'geometrycollection' +SET @g= LineString(Point(0,0), Point(0,1)); +SELECT AsText(PointN(@g, 1)); +AsText(PointN(@g, 1)) +POINT(0 0) +SELECT AsText(PointN(@g, 2)); +AsText(PointN(@g, 2)) +POINT(0 1) +SET @g= Point(1, 1); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `g` point DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT AsText(g) FROM t1; +AsText(g) +POINT(1 1) +DROP TABLE t1; +SET @g= MultiPoint(Point(1, 1), Point(-1,-1)); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `g` multipoint DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT AsText(g) FROM t1; +AsText(g) +MULTIPOINT(1 1,-1 -1) +DROP TABLE t1; +SET @g= LineString(Point(1, 1), Point(2,2)); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `g` linestring DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT AsText(g) FROM t1; +AsText(g) +LINESTRING(1 1,2 2) +DROP TABLE t1; +SET @g= MultiLineString(LineString(Point(1, 1), Point(2,2)), +LineString(Point(-1, -1), Point(-2,-2))); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `g` multilinestring DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT AsText(g) FROM t1; +AsText(g) +MULTILINESTRING((1 1,2 2),(-1 -1,-2 -2)) +DROP TABLE t1; +SET @g= Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0))); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `g` polygon DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT AsText(g) FROM t1; +AsText(g) +POLYGON((0 0,30 0,30 30,0 0)) +DROP TABLE t1; +SET @g= MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), +Point(3, 0), Point(0, 3)))); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `g` multipolygon DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT AsText(g) FROM t1; +AsText(g) +MULTIPOLYGON(((0 3,3 3,3 0,0 3))) +DROP TABLE t1; +SET @g= GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9))); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `g` geometrycollection DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT AsText(g) FROM t1; +AsText(g) +GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9)) +DROP TABLE t1; +SET @g= GeometryFromText('POINT(1 1)'); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `g` geometry DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT AsText(g) FROM t1; +AsText(g) +POINT(1 1) +DROP TABLE t1; +# # End of 10.5 tests # diff --git a/mysql-test/main/gis.test b/mysql-test/main/gis.test index e68b1f14..659636b1 100644 --- a/mysql-test/main/gis.test +++ b/mysql-test/main/gis.test @@ -1,5 +1,5 @@ -- source include/have_geometry.inc - +-- source include/not_embedded.inc # # Spatial objects @@ -3374,6 +3374,69 @@ SELECT BIT_OR(a) FROM t1; SELECT BIT_XOR(a) FROM t1; DROP TABLE t1; +--echo # +--echo # MDEV-27666 User variable not parsed as geometry variable in geometry function. +--echo # + +set @g= point(1, 1); +select ST_AsWKT(GeometryCollection(Point(44, 6), @g)); +set @g= "just a string"; +--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION +select ST_AsWKT(GeometryCollection(Point(44, 6), @g)); + +SET @g= LineString(Point(0,0), Point(0,1)); +SELECT AsText(PointN(@g, 1)); +SELECT AsText(PointN(@g, 2)); + +SET @g= Point(1, 1); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +SELECT AsText(g) FROM t1; +DROP TABLE t1; + +SET @g= MultiPoint(Point(1, 1), Point(-1,-1)); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +SELECT AsText(g) FROM t1; +DROP TABLE t1; + +SET @g= LineString(Point(1, 1), Point(2,2)); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +SELECT AsText(g) FROM t1; +DROP TABLE t1; + +SET @g= MultiLineString(LineString(Point(1, 1), Point(2,2)), + LineString(Point(-1, -1), Point(-2,-2))); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +SELECT AsText(g) FROM t1; +DROP TABLE t1; + +SET @g= Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0))); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +SELECT AsText(g) FROM t1; +DROP TABLE t1; + +SET @g= MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), + Point(3, 0), Point(0, 3)))); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +SELECT AsText(g) FROM t1; +DROP TABLE t1; + +SET @g= GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9))); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +SELECT AsText(g) FROM t1; +DROP TABLE t1; + +SET @g= GeometryFromText('POINT(1 1)'); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +SELECT AsText(g) FROM t1; +DROP TABLE t1; --echo # --echo # End of 10.5 tests diff --git a/mysql-test/main/grant.result b/mysql-test/main/grant.result index d89bf9f0..031ebbc9 100644 --- a/mysql-test/main/grant.result +++ b/mysql-test/main/grant.result @@ -1991,6 +1991,11 @@ GRANT EXECUTE ON mysqltest_db1.* TO mysqltest_u1@localhost; GRANT FILE ON *.* TO mysqltest_u1@localhost; GRANT CREATE USER ON *.* TO mysqltest_u1@localhost; GRANT PROCESS ON *.* TO mysqltest_u1@localhost; +GRANT RELOAD ON mysqltest_db1.* TO mysqltest_u1@localhost; +ERROR HY000: Incorrect usage of DB GRANT and GLOBAL PRIVILEGES +connect(localhost,mysqltest_u1,,db1,MASTER_PORT,MASTER_SOCKET); +connect con1, localhost, mysqltest_u1, ,db1; +ERROR 42000: Access denied for user 'mysqltest_u1'@'localhost' to database 'db1' GRANT RELOAD ON *.* TO mysqltest_u1@localhost; GRANT REPLICATION CLIENT ON *.* TO mysqltest_u1@localhost; GRANT REPLICATION SLAVE ON *.* TO mysqltest_u1@localhost; diff --git a/mysql-test/main/grant.test b/mysql-test/main/grant.test index 69bb0507..52f2f78b 100644 --- a/mysql-test/main/grant.test +++ b/mysql-test/main/grant.test @@ -1824,6 +1824,13 @@ GRANT EXECUTE ON mysqltest_db1.* TO mysqltest_u1@localhost; GRANT FILE ON *.* TO mysqltest_u1@localhost; GRANT CREATE USER ON *.* TO mysqltest_u1@localhost; GRANT PROCESS ON *.* TO mysqltest_u1@localhost; +# Global privileges should be granted to all schemas, not individual DB +--error ER_WRONG_USAGE +GRANT RELOAD ON mysqltest_db1.* TO mysqltest_u1@localhost; +# Select privilege is needed beside RELOAD privilege +--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT +--error ER_DBACCESS_DENIED_ERROR +--connect (con1, localhost, mysqltest_u1, ,db1) GRANT RELOAD ON *.* TO mysqltest_u1@localhost; GRANT REPLICATION CLIENT ON *.* TO mysqltest_u1@localhost; GRANT REPLICATION SLAVE ON *.* TO mysqltest_u1@localhost; diff --git a/mysql-test/main/group_min_max.result b/mysql-test/main/group_min_max.result index 88c56804..452088f3 100644 --- a/mysql-test/main/group_min_max.result +++ b/mysql-test/main/group_min_max.result @@ -3298,6 +3298,8 @@ explain SELECT b, min(a) FROM t1 WHERE a > ('0' = b) AND b = 'z' GROUP BY b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref b b 4 const 1 Using where; Using index +Warnings: +Note 1105 Cannot use key `b` part[1] for lookup: `test`.`t1`.`a` of type `varchar` > "'0' = 'z'" of type `boolean` SELECT b, min(a) FROM t1 WHERE a > ('0' = b) AND b = 'z' GROUP BY b; b min(a) explain @@ -3984,12 +3986,18 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a BETWEEN DATE'2001-01-04' AND DATE'2001-01-05' GROUP BY id; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL id 27 NULL 64 Using where; Using index +Warnings: +Note 1105 Cannot use key `id` part[1] for lookup: `test`.`t1`.`a` of type `varchar` >= "DATE'2001-01-04'" of type `date` EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a BETWEEN DATE'2001-01-04' AND '2001-01-05' GROUP BY id; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL id 27 NULL 64 Using where; Using index +Warnings: +Note 1105 Cannot use key `id` part[1] for lookup: `test`.`t1`.`a` of type `varchar` >= "DATE'2001-01-04'" of type `date` EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a BETWEEN '2001-01-04' AND DATE'2001-01-05' GROUP BY id; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL id 27 NULL 64 Using where; Using index +Warnings: +Note 1105 Cannot use key `id` part[1] for lookup: `test`.`t1`.`a` of type `varchar` >= "<cache>('2001-01-04')" of type `date` DROP TABLE t1; # # MIN() optimization didn't work correctly with BETWEEN when using too diff --git a/mysql-test/main/group_min_max_innodb.result b/mysql-test/main/group_min_max_innodb.result index fed3d30b..27656374 100644 --- a/mysql-test/main/group_min_max_innodb.result +++ b/mysql-test/main/group_min_max_innodb.result @@ -330,6 +330,113 @@ JOIN t1 ON dt.a=t1.b; a Australia DROP TABLES t1, t2; +# +# MDEV-15656: Assertion `is_last_prefix <= 0' failed in +# QUICK_GROUP_MIN_MAX_SELECT::get_next +# +SET @lru_depth.save= @@innodb_lru_scan_depth; +SET GLOBAL innodb_lru_scan_depth= 1024; +CREATE TABLE t1 ( +pk_part1 INT AUTO_INCREMENT, +a VARCHAR(4), +row_start timestamp(6) default current_timestamp, +PRIMARY KEY (pk_part1, row_start) +) ENGINE=InnoDB; +INSERT INTO t1 (a) VALUES +('foo'),('bar'),('foo'),('bar'),('foo'), +('foo'),('bar'),('foo'),('bar'),('foo'), +('foo'),('bar'),('foo'),('bar'),('foo'), +('foo'),('bar'),('foo'),('bar'),('foo'), +('foo'),('bar'),('foo'),('bar'),('foo'), +('foo'),('bar'),('foo'),('bar'),('foo'), +('foo'),('bar'),('foo'),('bar'),('foo'), +('foo'),('bar'),('foo'),('bar'),('foo'); +connect con1,localhost,root,,test; +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SELECT DISTINCT pk_part1 FROM t1; +connection default; +INSERT INTO t1 (pk_part1) VALUES (NULL); +connection con1; +SELECT DISTINCT pk_part1 FROM t1; +connection default; +INSERT INTO t1 (pk_part1) VALUES (NULL); +connection con1; +SELECT DISTINCT pk_part1 FROM t1; +connection default; +INSERT INTO t1 (pk_part1) VALUES (NULL); +connection con1; +SELECT DISTINCT pk_part1 FROM t1; +connection default; +INSERT INTO t1 (pk_part1) VALUES (NULL); +connection con1; +SELECT DISTINCT pk_part1 FROM t1; +connection default; +INSERT INTO t1 (pk_part1) VALUES (NULL); +connection con1; +SELECT DISTINCT pk_part1 FROM t1; +connection default; +INSERT INTO t1 (pk_part1) VALUES (NULL); +connection con1; +SELECT DISTINCT pk_part1 FROM t1; +connection default; +INSERT INTO t1 (pk_part1) VALUES (NULL); +connection con1; +SELECT DISTINCT pk_part1 FROM t1; +connection default; +INSERT INTO t1 (pk_part1) VALUES (NULL); +connection con1; +SELECT DISTINCT pk_part1 FROM t1; +connection default; +INSERT INTO t1 (pk_part1) VALUES (NULL); +connection con1; +SELECT DISTINCT pk_part1 FROM t1; +connection default; +INSERT INTO t1 (pk_part1) VALUES (NULL); +connection con1; +SELECT DISTINCT pk_part1 FROM t1; +connection default; +INSERT INTO t1 (pk_part1) VALUES (NULL); +connection con1; +SELECT DISTINCT pk_part1 FROM t1; +connection default; +INSERT INTO t1 (pk_part1) VALUES (NULL); +connection con1; +SELECT DISTINCT pk_part1 FROM t1; +connection default; +INSERT INTO t1 (pk_part1) VALUES (NULL); +connection con1; +SELECT DISTINCT pk_part1 FROM t1; +connection default; +INSERT INTO t1 (pk_part1) VALUES (NULL); +connection con1; +SELECT DISTINCT pk_part1 FROM t1; +connection default; +INSERT INTO t1 (pk_part1) VALUES (NULL); +connection con1; +SELECT DISTINCT pk_part1 FROM t1; +connection default; +INSERT INTO t1 (pk_part1) VALUES (NULL); +connection con1; +SELECT DISTINCT pk_part1 FROM t1; +connection default; +INSERT INTO t1 (pk_part1) VALUES (NULL); +connection con1; +SELECT DISTINCT pk_part1 FROM t1; +connection default; +INSERT INTO t1 (pk_part1) VALUES (NULL); +connection con1; +SELECT DISTINCT pk_part1 FROM t1; +connection default; +INSERT INTO t1 (pk_part1) VALUES (NULL); +connection con1; +SELECT DISTINCT pk_part1 FROM t1; +connection default; +INSERT INTO t1 (pk_part1) VALUES (NULL); +connection con1; +disconnect con1; +connection default; +DROP TABLE t1; +SET GLOBAL innodb_lru_scan_depth= @lru_depth.save; 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/group_min_max_innodb.test b/mysql-test/main/group_min_max_innodb.test index fcecbec4..33a3a888 100644 --- a/mysql-test/main/group_min_max_innodb.test +++ b/mysql-test/main/group_min_max_innodb.test @@ -273,6 +273,53 @@ eval $query; DROP TABLES t1, t2; +--echo # +--echo # MDEV-15656: Assertion `is_last_prefix <= 0' failed in +--echo # QUICK_GROUP_MIN_MAX_SELECT::get_next +--echo # +SET @lru_depth.save= @@innodb_lru_scan_depth; +SET GLOBAL innodb_lru_scan_depth= 1024; + +CREATE TABLE t1 ( + pk_part1 INT AUTO_INCREMENT, + a VARCHAR(4), + row_start timestamp(6) default current_timestamp, + PRIMARY KEY (pk_part1, row_start) +) ENGINE=InnoDB; + +INSERT INTO t1 (a) VALUES +('foo'),('bar'),('foo'),('bar'),('foo'), +('foo'),('bar'),('foo'),('bar'),('foo'), +('foo'),('bar'),('foo'),('bar'),('foo'), +('foo'),('bar'),('foo'),('bar'),('foo'), +('foo'),('bar'),('foo'),('bar'),('foo'), +('foo'),('bar'),('foo'),('bar'),('foo'), +('foo'),('bar'),('foo'),('bar'),('foo'), +('foo'),('bar'),('foo'),('bar'),('foo'); + +--connect (con1,localhost,root,,test) + +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; + +--let $run= 20 +--disable_result_log +while ($run) +{ + --send + SELECT DISTINCT pk_part1 FROM t1; + --connection default + INSERT INTO t1 (pk_part1) VALUES (NULL); + --connection con1 + --reap + --dec $run +} +--enable_result_log + +--disconnect con1 +--connection default +DROP TABLE t1; +SET GLOBAL innodb_lru_scan_depth= @lru_depth.save; + 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_ext_key,covering,innodb,on.rdiff b/mysql-test/main/innodb_ext_key,covering,innodb,on.rdiff new file mode 100644 index 00000000..0d8bcc6c --- /dev/null +++ b/mysql-test/main/innodb_ext_key,covering,innodb,on.rdiff @@ -0,0 +1,20 @@ +--- ./main/innodb_ext_key.result ++++ ./main/innodb_ext_key.reject +@@ -244,7 +244,7 @@ + Variable_name Value + Handler_read_first 0 + Handler_read_key 21 +-Handler_read_last 1 ++Handler_read_last 0 + Handler_read_next 0 + Handler_read_prev 0 + Handler_read_retry 0 +@@ -266,7 +266,7 @@ + Variable_name Value + Handler_read_first 0 + Handler_read_key 6 +-Handler_read_last 1 ++Handler_read_last 0 + Handler_read_next 0 + Handler_read_prev 0 + Handler_read_retry 0 diff --git a/mysql-test/main/innodb_ext_key,innodb,on,unoptimized.rdiff b/mysql-test/main/innodb_ext_key,innodb,on,unoptimized.rdiff new file mode 100644 index 00000000..0d8bcc6c --- /dev/null +++ b/mysql-test/main/innodb_ext_key,innodb,on,unoptimized.rdiff @@ -0,0 +1,20 @@ +--- ./main/innodb_ext_key.result ++++ ./main/innodb_ext_key.reject +@@ -244,7 +244,7 @@ + Variable_name Value + Handler_read_first 0 + Handler_read_key 21 +-Handler_read_last 1 ++Handler_read_last 0 + Handler_read_next 0 + Handler_read_prev 0 + Handler_read_retry 0 +@@ -266,7 +266,7 @@ + Variable_name Value + Handler_read_first 0 + Handler_read_key 6 +-Handler_read_last 1 ++Handler_read_last 0 + Handler_read_next 0 + Handler_read_prev 0 + Handler_read_retry 0 diff --git a/mysql-test/main/keywords.result b/mysql-test/main/keywords.result index 483a8f7e..4e246e38 100644 --- a/mysql-test/main/keywords.result +++ b/mysql-test/main/keywords.result @@ -500,21 +500,21 @@ SELECT @@global.rpad(); -- Unknown system variable 'rpad' -------- SELECT @@global.adddate(); -- Unknown system variable 'adddate' -------- -SELECT @@global.substr(); -- Unknown system variable 'substr' +SELECT @@global.substr(); -- ..syntax.. near 'substr()' at line 1 -------- -SELECT @@global.substring(); -- Unknown system variable 'substring' +SELECT @@global.substring(); -- ..syntax.. near 'substring()' at line 1 -------- SELECT @@global.trim_oracle(); -- Unknown system variable 'trim_oracle' -------- SELECT @@global.ascii(); -- Unknown system variable 'ascii' -------- -SELECT @@global.replace(); -- Unknown system variable 'replace' +SELECT @@global.replace(); -- ..syntax.. near 'replace()' at line 1 -------- SELECT @@global.weight_string(); -- Unknown system variable 'weight_string' -------- SELECT @@global.char(); -- Unknown system variable 'char' -------- -SELECT @@global.trim(); -- Unknown system variable 'trim' +SELECT @@global.trim(); -- ..syntax.. near 'trim()' at line 1 -------- SELECT @@global.year(); -- Unknown system variable 'year' -------- @@ -732,21 +732,21 @@ CREATE FUNCTION test.rpad() RETURNS OOPS; -- Unknown data type: 'OOPS' -------- CREATE FUNCTION test.adddate() RETURNS OOPS; -- Unknown data type: 'OOPS' -------- -CREATE FUNCTION test.substr() RETURNS OOPS; -- Unknown data type: 'OOPS' +CREATE FUNCTION test.substr() RETURNS OOPS; -- ..syntax.. near 'substr() RETURNS OOPS' -------- -CREATE FUNCTION test.substring() RETURNS OOPS; -- Unknown data type: 'OOPS' +CREATE FUNCTION test.substring() RETURNS OOPS; -- ..syntax.. near 'substring() RETURNS OOP -------- CREATE FUNCTION test.trim_oracle() RETURNS OOPS; -- Unknown data type: 'OOPS' -------- CREATE FUNCTION test.ascii() RETURNS OOPS; -- Unknown data type: 'OOPS' -------- -CREATE FUNCTION test.replace() RETURNS OOPS; -- Unknown data type: 'OOPS' +CREATE FUNCTION test.replace() RETURNS OOPS; -- ..syntax.. near 'replace() RETURNS OOPS' -------- CREATE FUNCTION test.weight_string() RETURNS OOPS; -- Unknown data type: 'OOPS' -------- CREATE FUNCTION test.char() RETURNS OOPS; -- Unknown data type: 'OOPS' -------- -CREATE FUNCTION test.trim() RETURNS OOPS; -- Unknown data type: 'OOPS' +CREATE FUNCTION test.trim() RETURNS OOPS; -- ..syntax.. near 'trim() RETURNS OOPS' at -------- CREATE FUNCTION test.year() RETURNS OOPS; -- Unknown data type: 'OOPS' -------- diff --git a/mysql-test/main/log_slow_debug.result b/mysql-test/main/log_slow_debug.result index 920b1641..bc934c04 100644 --- a/mysql-test/main/log_slow_debug.result +++ b/mysql-test/main/log_slow_debug.result @@ -287,15 +287,18 @@ SET @old_dbug= @@GLOBAL.debug_dbug; SET GLOBAL log_output= "TABLE"; SET GLOBAL slow_query_log= ON; SET SESSION long_query_time= 0; -SET GLOBAL debug_dbug="+d,debug_huge_number_of_examined_rows"; +SET debug_dbug="+d,debug_huge_number_of_examined_rows"; SELECT * FROM tab_MDEV_30820 ORDER BY 1; ID A 1 0 2 0 -SET GLOBAL debug_dbug=@old_dbug; +SET debug_dbug=@old_dbug; SET @@long_query_time= @old_long_query_time; SET @@global.log_output= @old_log_output; SET @@global.slow_query_log= @old_slow_query_log; +SELECT rows_examined, sql_text from mysql.slow_log where sql_text like "SELECT%FROM tab_MDEV_30820%"; +rows_examined sql_text +18446744073708551615 SELECT * FROM tab_MDEV_30820 ORDER BY 1 drop table tab_MDEV_30820; # # End of 10.4 test diff --git a/mysql-test/main/log_slow_debug.test b/mysql-test/main/log_slow_debug.test index ee040611..456b2953 100644 --- a/mysql-test/main/log_slow_debug.test +++ b/mysql-test/main/log_slow_debug.test @@ -170,16 +170,21 @@ SET GLOBAL log_output= "TABLE"; SET GLOBAL slow_query_log= ON; SET SESSION long_query_time= 0; -SET GLOBAL debug_dbug="+d,debug_huge_number_of_examined_rows"; +SET debug_dbug="+d,debug_huge_number_of_examined_rows"; +--disable_ps_protocol +--disable_view_protocol SELECT * FROM tab_MDEV_30820 ORDER BY 1; -SET GLOBAL debug_dbug=@old_dbug; - +--enable_view_protocol +--enable_ps_protocol +SET debug_dbug=@old_dbug; ## Reset to initial values SET @@long_query_time= @old_long_query_time; SET @@global.log_output= @old_log_output; SET @@global.slow_query_log= @old_slow_query_log; +SELECT rows_examined, sql_text from mysql.slow_log where sql_text like "SELECT%FROM tab_MDEV_30820%"; + drop table tab_MDEV_30820; --echo # diff --git a/mysql-test/main/log_tables.result b/mysql-test/main/log_tables.result index 1d642c0a..e64b71d4 100644 --- a/mysql-test/main/log_tables.result +++ b/mysql-test/main/log_tables.result @@ -1,14 +1,9 @@ SET SQL_MODE=""; -SET @old_general_log_state = @@global.general_log; SET @old_log_output= @@global.log_output; SET @old_slow_query_log= @@global.slow_query_log; SET @old_general_log= @@global.general_log; SET @old_long_query_time= @@session.long_query_time; use mysql; -SET @saved_long_query_time = @@long_query_time; -SET @saved_log_output = @@log_output; -SET @saved_general_log = @@GLOBAL.general_log; -SET @saved_slow_query_log = @@GLOBAL.slow_query_log; truncate table general_log; select * from general_log; event_time user_host thread_id server_id command_type argument @@ -120,6 +115,9 @@ show open tables; Database Table In_use Name_locked SET GLOBAL GENERAL_LOG=ON; SET GLOBAL SLOW_QUERY_LOG=ON; +# +# Bug#23924 general_log truncates queries with character set introducers. +# truncate table mysql.general_log; set names binary; select _koi8r'ÔÅÓÔ' as test; @@ -131,6 +129,9 @@ TIMESTAMP USER_HOST THREAD_ID 1 Query set names binary TIMESTAMP USER_HOST THREAD_ID 1 Query select _koi8r'\xD4\xC5\xD3\xD4' as test TIMESTAMP USER_HOST THREAD_ID 1 Query select * from mysql.general_log set names utf8; +# +# Bug #16905 Log tables: unicode statements are logged incorrectly +# truncate table mysql.general_log; set names utf8; create table bug16905 (s char(15) character set utf8 default 'пуÑто'); @@ -142,6 +143,9 @@ TIMESTAMP USER_HOST THREAD_ID 1 Query create table bug16905 (s char(15) characte TIMESTAMP USER_HOST THREAD_ID 1 Query insert into bug16905 values ('новое') TIMESTAMP USER_HOST THREAD_ID 1 Query select * from mysql.general_log drop table bug16905; +# +# Bug #17600: Invalid data logged into mysql.slow_log +# truncate table mysql.slow_log; set session long_query_time=1; select sleep(2); @@ -150,7 +154,11 @@ sleep(2) select * from mysql.slow_log; start_time user_host query_time lock_time rows_sent rows_examined db last_insert_id insert_id server_id sql_text thread_id rows_affected TIMESTAMP USER_HOST QUERY_TIME 00:00:00.000000 1 0 mysql 0 0 1 select sleep(2) THREAD_ID 0 -set @@session.long_query_time = @saved_long_query_time; +set @@session.long_query_time = @old_long_query_time; +# +# Bug #18559 log tables cannot change engine, and gets deadlocked when +# dropping w/ log on +# alter table mysql.general_log engine=myisam; ERROR HY000: You cannot 'ALTER' a log table if logging is enabled alter table mysql.slow_log engine=myisam; @@ -232,7 +240,7 @@ TIMESTAMP USER_HOST THREAD_ID 1 Query truncate table mysql.slow_log TIMESTAMP USER_HOST THREAD_ID 1 Query set session long_query_time=1 TIMESTAMP USER_HOST THREAD_ID 1 Query select sleep(2) TIMESTAMP USER_HOST THREAD_ID 1 Query select * from mysql.slow_log -TIMESTAMP USER_HOST THREAD_ID 1 Query set @@session.long_query_time = @saved_long_query_time +TIMESTAMP USER_HOST THREAD_ID 1 Query set @@session.long_query_time = @old_long_query_time TIMESTAMP USER_HOST THREAD_ID 1 Query alter table mysql.general_log engine=myisam TIMESTAMP USER_HOST THREAD_ID 1 Query alter table mysql.slow_log engine=myisam TIMESTAMP USER_HOST THREAD_ID 1 Query drop table mysql.general_log @@ -300,17 +308,20 @@ ON UPDATE CURRENT_TIMESTAMP, set global general_log='ON'; set global slow_query_log='ON'; use test; +# +# Bug #20139 Infinite loop after "FLUSH" and "LOCK tabX, general_log" +# flush tables with read lock; unlock tables; use mysql; lock tables general_log read local, help_category read local; ERROR HY000: You can't use locks with log tables unlock tables; +# +# Bug #17544 Cannot do atomic log rotate and +# Bug #21785 Server crashes after rename of the log table +# SET SESSION long_query_time = 1000; -drop table if exists mysql.renamed_general_log; -drop table if exists mysql.renamed_slow_log; -drop table if exists mysql.general_log_new; -drop table if exists mysql.slow_log_new; use mysql; RENAME TABLE general_log TO renamed_general_log; ERROR HY000: Cannot rename 'general_log'. When logging enabled, rename to/from log table must rename two tables: the log table to an archive table and another table back to 'general_log' @@ -356,13 +367,16 @@ set global slow_query_log='ON'; ERROR 42S02: Table 'mysql.slow_log' doesn't exist RENAME TABLE general_log2 TO general_log; RENAME TABLE slow_log2 TO slow_log; -SET SESSION long_query_time = @saved_long_query_time; +SET SESSION long_query_time = @old_long_query_time; set global general_log='ON'; set global slow_query_log='ON'; flush logs; flush logs; drop table renamed_general_log, renamed_slow_log; use test; +# +# Bug #21966 Strange warnings on repair of the log tables +# use mysql; repair table general_log; Table Op Msg_type Msg_text @@ -380,6 +394,10 @@ slow_log slow_log_new drop table slow_log_new, general_log_new; use test; +# +# Bug#69953 / MDEV-4851 +# Log tables should be modifable on LOG_OUTPUT != TABLE +# SET GLOBAL LOG_OUTPUT = 'FILE'; SET GLOBAL slow_query_log = 1; SET GLOBAL general_log = 1; @@ -388,6 +406,10 @@ ALTER TABLE mysql.general_log ADD COLUMN comment_text TEXT NOT NULL; SET GLOBAL LOG_OUTPUT = 'NONE'; ALTER TABLE mysql.slow_log DROP COLUMN comment_text; ALTER TABLE mysql.general_log DROP COLUMN comment_text; +# +# Bug#27857 (Log tables supplies the wrong value for generating +# AUTO_INCREMENT numbers) +# SET GLOBAL LOG_OUTPUT = 'TABLE'; SET GLOBAL general_log = 0; FLUSH LOGS; @@ -451,16 +473,15 @@ START_TIME USER_HOST QUERY_TIME 00:00:00.000000 1 0 test 0 0 1 SELECT "My own sl START_TIME USER_HOST QUERY_TIME 00:00:00.000000 1 0 test 0 0 1 SELECT "My own slow query", sleep(2) THREAD_ID 0 3 START_TIME USER_HOST QUERY_TIME 00:00:00.000000 1 0 test 0 0 1 SELECT "My own slow query", sleep(2) THREAD_ID 0 4 SET GLOBAL slow_query_log = 0; -SET SESSION long_query_time =@saved_long_query_time; +SET SESSION long_query_time =@old_long_query_time; FLUSH LOGS; ALTER TABLE mysql.slow_log DROP COLUMN seq; ALTER TABLE mysql.slow_log ENGINE = CSV; SET GLOBAL general_log = @old_general_log; SET GLOBAL slow_query_log = @old_slow_query_log; -drop procedure if exists proc25422_truncate_slow; -drop procedure if exists proc25422_truncate_general; -drop procedure if exists proc25422_alter_slow; -drop procedure if exists proc25422_alter_general; +# +# Bug#25422 (Hang with log tables) +# use test// create procedure proc25422_truncate_slow (loops int) begin @@ -485,26 +506,26 @@ end// create procedure proc25422_alter_slow (loops int) begin declare v1 int default 0; +declare old_log_state int default @@global.slow_query_log; declare ER_BAD_LOG_STATEMENT condition for 1575; declare continue handler for ER_BAD_LOG_STATEMENT begin end; while v1 < loops do -set @old_log_state = @@global.slow_query_log; set global slow_query_log = 'OFF'; alter table mysql.slow_log engine = CSV; -set global slow_query_log = @old_log_state; +set global slow_query_log = old_log_state; set v1 = v1 + 1; end while; end// create procedure proc25422_alter_general (loops int) begin declare v1 int default 0; +declare old_log_state int default @@global.general_log; declare ER_BAD_LOG_STATEMENT condition for 1575; declare continue handler for ER_BAD_LOG_STATEMENT begin end; while v1 < loops do -set @old_log_state = @@global.general_log; set global general_log = 'OFF'; alter table mysql.general_log engine = CSV; -set global general_log = @old_log_state; +set global general_log = old_log_state; set v1 = v1 + 1; end while; end// @@ -563,17 +584,19 @@ drop procedure proc25422_truncate_slow; drop procedure proc25422_truncate_general; drop procedure proc25422_alter_slow; drop procedure proc25422_alter_general; +# +# Bug#23044 (Warnings on flush of a log table) +# FLUSH TABLE mysql.general_log; show warnings; Level Code Message FLUSH TABLE mysql.slow_log; show warnings; Level Code Message -DROP TABLE IF EXISTS `db_17876.slow_log_data`; -DROP TABLE IF EXISTS `db_17876.general_log_data`; -DROP PROCEDURE IF EXISTS `db_17876.archiveSlowLog`; -DROP PROCEDURE IF EXISTS `db_17876.archiveGeneralLog`; -DROP DATABASE IF EXISTS `db_17876`; +# +# Bug#17876 (Truncating mysql.slow_log in a SP after using cursor locks the +# thread) +# CREATE DATABASE db_17876; CREATE TABLE `db_17876.slow_log_data` ( `start_time` timestamp(6) default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, @@ -686,6 +709,9 @@ DROP PROCEDURE IF EXISTS `db_17876.archiveGeneralLog`; DROP DATABASE IF EXISTS `db_17876`; SET GLOBAL general_log = @old_general_log; SET GLOBAL slow_query_log = @old_slow_query_log; +# +# Bug#21557 entries in the general query log truncated at 1000 characters. +# select CONNECTION_ID() into @thread_id; truncate table mysql.general_log; set global general_log = on; @@ -902,9 +928,9 @@ select '000 001 002 003 004 005 006 007 008 009010 011 012 013 014 015 016 017 0 set global general_log = off deallocate prepare long_query; set global general_log = @old_general_log; -DROP TABLE IF EXISTS log_count; -DROP TABLE IF EXISTS slow_log_copy; -DROP TABLE IF EXISTS general_log_copy; +# +# Bug#34306: Can't make copy of log tables when server binary log is enabled +# CREATE TABLE log_count (count BIGINT(21)); SET GLOBAL general_log = ON; SET GLOBAL slow_query_log = ON; @@ -926,9 +952,12 @@ CREATE TABLE general_log_copy SELECT * FROM mysql.general_log; INSERT INTO general_log_copy SELECT * FROM mysql.general_log; INSERT INTO log_count (count) VALUES ((SELECT count(*) FROM mysql.general_log)); DROP TABLE general_log_copy; -SET GLOBAL general_log = @saved_general_log; -SET GLOBAL slow_query_log = @saved_slow_query_log; +SET GLOBAL general_log = @old_general_log; +SET GLOBAL slow_query_log = @old_slow_query_log; DROP TABLE log_count; +# +# Bug #31700: thd->examined_row_count not incremented for 'const' type queries +# SET SESSION long_query_time = 0; SET GLOBAL slow_query_log = ON; FLUSH LOGS; @@ -954,9 +983,10 @@ TIMESTAMP 1 1 SELECT SQL_NO_CACHE 'Bug#31700 - KEY', f1,f2,f3,SLEEP(1.1) FROM t1 TIMESTAMP 1 1 SELECT SQL_NO_CACHE 'Bug#31700 - PK', f1,f2,f3,SLEEP(1.1) FROM t1 WHERE f1=2 DROP TABLE t1; TRUNCATE TABLE mysql.slow_log; +# +# Bug #47924 main.log_tables times out sporadically +# use mysql; -drop table if exists renamed_general_log; -drop table if exists renamed_slow_log; RENAME TABLE general_log TO renamed_general_log; ERROR HY000: Cannot rename 'general_log'. When logging enabled, rename to/from log table must rename two tables: the log table to an archive table and another table back to 'general_log' RENAME TABLE slow_log TO renamed_slow_log; @@ -964,7 +994,34 @@ ERROR HY000: Cannot rename 'slow_log'. When logging enabled, rename to/from log use test; flush tables with read lock; unlock tables; -SET @@session.long_query_time= @old_long_query_time; +# +# MDEV-33267 User with minimal permissions can intentionally corrupt mysql.slow_log table +# +truncate mysql.slow_log; +set global log_output= 'TABLE'; +create user u@localhost; +set slow_query_log=on, long_query_time=0.1; +select 'before evil-doing', sleep(0.2); +before evil-doing sleep(0.2) +before evil-doing 0 +connect con1,localhost,u,,; +set @@timestamp= 2147483647; +set slow_query_log=on, long_query_time=0.1; +select 'evil-doing', sleep(1.1); +evil-doing sleep(1.1) +evil-doing 0 +disconnect con1; +connection default; +select 'after evil-doing', sleep(0.2); +after evil-doing sleep(0.2) +after evil-doing 0 +select distinct sql_text from mysql.slow_log where sql_text like '%evil%'; +sql_text +select 'before evil-doing', sleep(0.2) +select 'evil-doing', sleep(1.1) +select 'after evil-doing', sleep(0.2) +set global log_output=default; +drop user u@localhost; SET @@global.log_output= @old_log_output; SET @@global.slow_query_log= @old_slow_query_log; SET @@global.general_log= @old_general_log; diff --git a/mysql-test/main/log_tables.test b/mysql-test/main/log_tables.test index 1eee6be0..37df8d46 100644 --- a/mysql-test/main/log_tables.test +++ b/mysql-test/main/log_tables.test @@ -1,13 +1,9 @@ # this test needs multithreaded mysqltest -- source include/not_embedded.inc -# -# Basic log tables test -# -# check that CSV engine was compiled in + --source include/have_csv.inc SET SQL_MODE=""; -SET @old_general_log_state = @@global.general_log; SET @old_log_output= @@global.log_output; SET @old_slow_query_log= @@global.slow_query_log; SET @old_general_log= @@global.general_log; @@ -16,16 +12,9 @@ SET @old_long_query_time= @@session.long_query_time; --disable_ps_protocol use mysql; -# Capture initial settings of system variables -# so that we can revert to old state after manipulation for testing -# NOTE: PLEASE USE THESE VALUES TO 'RESET' SYSTEM VARIABLES -# Capturing old values within the tests results in loss of values -# due to people not paying attention to previous tests' changes, captures -# or improper cleanup -SET @saved_long_query_time = @@long_query_time; -SET @saved_log_output = @@log_output; -SET @saved_general_log = @@GLOBAL.general_log; -SET @saved_slow_query_log = @@GLOBAL.slow_query_log; +# +# Basic log tables test +# # # Check that log tables work and we can do basic selects. This also @@ -147,9 +136,9 @@ show open tables; SET GLOBAL GENERAL_LOG=ON; SET GLOBAL SLOW_QUERY_LOG=ON; -# -# Bug#23924 general_log truncates queries with character set introducers. -# +--echo # +--echo # Bug#23924 general_log truncates queries with character set introducers. +--echo # truncate table mysql.general_log; set names binary; select _koi8r'ÔÅÓÔ' as test; @@ -157,9 +146,9 @@ select _koi8r'ÔÅÓÔ' as test; select * from mysql.general_log; set names utf8; -# -# Bug #16905 Log tables: unicode statements are logged incorrectly -# +--echo # +--echo # Bug #16905 Log tables: unicode statements are logged incorrectly +--echo # truncate table mysql.general_log; set names utf8; @@ -169,21 +158,21 @@ insert into bug16905 values ('новое'); select * from mysql.general_log; drop table bug16905; -# -# Bug #17600: Invalid data logged into mysql.slow_log -# +--echo # +--echo # Bug #17600: Invalid data logged into mysql.slow_log +--echo # truncate table mysql.slow_log; set session long_query_time=1; select sleep(2); --replace_column 1 TIMESTAMP 2 USER_HOST 3 QUERY_TIME 12 THREAD_ID select * from mysql.slow_log; -set @@session.long_query_time = @saved_long_query_time; +set @@session.long_query_time = @old_long_query_time; -# -# Bug #18559 log tables cannot change engine, and gets deadlocked when -# dropping w/ log on -# +--echo # +--echo # Bug #18559 log tables cannot change engine, and gets deadlocked when +--echo # dropping w/ log on +--echo # # check that appropriate error messages are given when one attempts to alter # or drop a log tables, while corresponding logs are enabled @@ -322,9 +311,9 @@ set global general_log='ON'; set global slow_query_log='ON'; use test; -# -# Bug #20139 Infinite loop after "FLUSH" and "LOCK tabX, general_log" -# +--echo # +--echo # Bug #20139 Infinite loop after "FLUSH" and "LOCK tabX, general_log" +--echo # flush tables with read lock; unlock tables; @@ -333,18 +322,12 @@ use mysql; lock tables general_log read local, help_category read local; unlock tables; -# -# Bug #17544 Cannot do atomic log rotate and -# Bug #21785 Server crashes after rename of the log table -# +--echo # +--echo # Bug #17544 Cannot do atomic log rotate and +--echo # Bug #21785 Server crashes after rename of the log table +--echo # SET SESSION long_query_time = 1000; ---disable_warnings -drop table if exists mysql.renamed_general_log; -drop table if exists mysql.renamed_slow_log; -drop table if exists mysql.general_log_new; -drop table if exists mysql.slow_log_new; ---enable_warnings use mysql; # Should result in error @@ -399,7 +382,7 @@ set global slow_query_log='ON'; RENAME TABLE general_log2 TO general_log; RENAME TABLE slow_log2 TO slow_log; -SET SESSION long_query_time = @saved_long_query_time; +SET SESSION long_query_time = @old_long_query_time; # this should work set global general_log='ON'; @@ -427,13 +410,6 @@ use test; # TODO: improve filtering of expected errors in master.err in # mysql-test-run.pl (based on the test name ?), and uncomment this test. -# --disable_warnings -# drop table if exists mysql.bad_general_log; -# drop table if exists mysql.bad_slow_log; -# drop table if exists mysql.general_log_hide; -# drop table if exists mysql.slow_log_hide; -# --enable_warnings -# # create table mysql.bad_general_log (a int) engine= CSV; # create table mysql.bad_slow_log (a int) engine= CSV; # @@ -459,9 +435,9 @@ use test; # drop table mysql.bad_general_log; # drop table mysql.bad_slow_log; -# -# Bug #21966 Strange warnings on repair of the log tables -# +--echo # +--echo # Bug #21966 Strange warnings on repair of the log tables +--echo # use mysql; # check that no warning occurs on repair of the log tables @@ -474,11 +450,10 @@ show tables like "%log%"; drop table slow_log_new, general_log_new; use test; -# -# Bug#69953 / MDEV-4851 -# Log tables should be modifable on LOG_OUTPUT != TABLE -# -# +--echo # +--echo # Bug#69953 / MDEV-4851 +--echo # Log tables should be modifable on LOG_OUTPUT != TABLE +--echo # SET GLOBAL LOG_OUTPUT = 'FILE'; SET GLOBAL slow_query_log = 1; @@ -492,10 +467,10 @@ ALTER TABLE mysql.slow_log DROP COLUMN comment_text; ALTER TABLE mysql.general_log DROP COLUMN comment_text; -# -# Bug#27857 (Log tables supplies the wrong value for generating -# AUTO_INCREMENT numbers) -# +--echo # +--echo # Bug#27857 (Log tables supplies the wrong value for generating +--echo # AUTO_INCREMENT numbers) +--echo # SET GLOBAL LOG_OUTPUT = 'TABLE'; @@ -554,7 +529,7 @@ SELECT "My own slow query", sleep(2); SELECT * FROM mysql.slow_log WHERE seq >= 2 LIMIT 3; SET GLOBAL slow_query_log = 0; -SET SESSION long_query_time =@saved_long_query_time; +SET SESSION long_query_time =@old_long_query_time; FLUSH LOGS; ALTER TABLE mysql.slow_log DROP COLUMN seq; @@ -563,16 +538,9 @@ ALTER TABLE mysql.slow_log ENGINE = CSV; SET GLOBAL general_log = @old_general_log; SET GLOBAL slow_query_log = @old_slow_query_log; -# -# Bug#25422 (Hang with log tables) -# - ---disable_warnings -drop procedure if exists proc25422_truncate_slow; -drop procedure if exists proc25422_truncate_general; -drop procedure if exists proc25422_alter_slow; -drop procedure if exists proc25422_alter_general; ---enable_warnings +--echo # +--echo # Bug#25422 (Hang with log tables) +--echo # delimiter //; @@ -602,14 +570,14 @@ end// create procedure proc25422_alter_slow (loops int) begin declare v1 int default 0; + declare old_log_state int default @@global.slow_query_log; declare ER_BAD_LOG_STATEMENT condition for 1575; declare continue handler for ER_BAD_LOG_STATEMENT begin end; while v1 < loops do - set @old_log_state = @@global.slow_query_log; set global slow_query_log = 'OFF'; alter table mysql.slow_log engine = CSV; - set global slow_query_log = @old_log_state; + set global slow_query_log = old_log_state; set v1 = v1 + 1; end while; end// @@ -617,14 +585,14 @@ end// create procedure proc25422_alter_general (loops int) begin declare v1 int default 0; + declare old_log_state int default @@global.general_log; declare ER_BAD_LOG_STATEMENT condition for 1575; declare continue handler for ER_BAD_LOG_STATEMENT begin end; while v1 < loops do - set @old_log_state = @@global.general_log; set global general_log = 'OFF'; alter table mysql.general_log engine = CSV; - set global general_log = @old_log_state; + set global general_log = old_log_state; set v1 = v1 + 1; end while; end// @@ -713,9 +681,9 @@ drop procedure proc25422_alter_general; --enable_ps_protocol -# -# Bug#23044 (Warnings on flush of a log table) -# +--echo # +--echo # Bug#23044 (Warnings on flush of a log table) +--echo # FLUSH TABLE mysql.general_log; show warnings; @@ -723,18 +691,10 @@ show warnings; FLUSH TABLE mysql.slow_log; show warnings; -# -# Bug#17876 (Truncating mysql.slow_log in a SP after using cursor locks the -# thread) -# - ---disable_warnings -DROP TABLE IF EXISTS `db_17876.slow_log_data`; -DROP TABLE IF EXISTS `db_17876.general_log_data`; -DROP PROCEDURE IF EXISTS `db_17876.archiveSlowLog`; -DROP PROCEDURE IF EXISTS `db_17876.archiveGeneralLog`; -DROP DATABASE IF EXISTS `db_17876`; ---enable_warnings +--echo # +--echo # Bug#17876 (Truncating mysql.slow_log in a SP after using cursor locks the +--echo # thread) +--echo # CREATE DATABASE db_17876; @@ -872,9 +832,9 @@ DROP DATABASE IF EXISTS `db_17876`; SET GLOBAL general_log = @old_general_log; SET GLOBAL slow_query_log = @old_slow_query_log; -# -# Bug#21557 entries in the general query log truncated at 1000 characters. -# +--echo # +--echo # Bug#21557 entries in the general query log truncated at 1000 characters. +--echo # select CONNECTION_ID() into @thread_id; --disable_ps_protocol @@ -993,15 +953,9 @@ AND (command_type = 'Query' OR command_type= 'Execute'); deallocate prepare long_query; set global general_log = @old_general_log; -# -# Bug#34306: Can't make copy of log tables when server binary log is enabled -# - ---disable_warnings -DROP TABLE IF EXISTS log_count; -DROP TABLE IF EXISTS slow_log_copy; -DROP TABLE IF EXISTS general_log_copy; ---enable_warnings +--echo # +--echo # Bug#34306: Can't make copy of log tables when server binary log is enabled +--echo # CREATE TABLE log_count (count BIGINT(21)); @@ -1031,14 +985,14 @@ INSERT INTO general_log_copy SELECT * FROM mysql.general_log; INSERT INTO log_count (count) VALUES ((SELECT count(*) FROM mysql.general_log)); DROP TABLE general_log_copy; -SET GLOBAL general_log = @saved_general_log; -SET GLOBAL slow_query_log = @saved_slow_query_log; +SET GLOBAL general_log = @old_general_log; +SET GLOBAL slow_query_log = @old_slow_query_log; DROP TABLE log_count; -# -# Bug #31700: thd->examined_row_count not incremented for 'const' type queries -# +--echo # +--echo # Bug #31700: thd->examined_row_count not incremented for 'const' type queries +--echo # SET SESSION long_query_time = 0; SET GLOBAL slow_query_log = ON; @@ -1065,16 +1019,12 @@ DROP TABLE t1; TRUNCATE TABLE mysql.slow_log; -# -# Bug #47924 main.log_tables times out sporadically -# +--echo # +--echo # Bug #47924 main.log_tables times out sporadically +--echo # use mysql; # Should result in error ---disable_warnings -drop table if exists renamed_general_log; -drop table if exists renamed_slow_log; ---enable_warnings --error ER_CANT_RENAME_LOG_TABLE RENAME TABLE general_log TO renamed_general_log; --error ER_CANT_RENAME_LOG_TABLE @@ -1084,7 +1034,24 @@ use test; flush tables with read lock; unlock tables; -SET @@session.long_query_time= @old_long_query_time; +--echo # +--echo # MDEV-33267 User with minimal permissions can intentionally corrupt mysql.slow_log table +--echo # +truncate mysql.slow_log; +set global log_output= 'TABLE'; +create user u@localhost; +set slow_query_log=on, long_query_time=0.1; +select 'before evil-doing', sleep(0.2); +--connect (con1,localhost,u,,) +set @@timestamp= 2147483647; +set slow_query_log=on, long_query_time=0.1; +select 'evil-doing', sleep(1.1); +--disconnect con1 +--connection default +select 'after evil-doing', sleep(0.2); +select distinct sql_text from mysql.slow_log where sql_text like '%evil%'; +set global log_output=default; +drop user u@localhost; SET @@global.log_output= @old_log_output; SET @@global.slow_query_log= @old_slow_query_log; diff --git a/mysql-test/main/long_host.result b/mysql-test/main/long_host.result index 52b479b6..c11dcd52 100644 --- a/mysql-test/main/long_host.result +++ b/mysql-test/main/long_host.result @@ -19,9 +19,9 @@ create table mariadbtestdb2.t2 (a int); create table mariadbtestdb.t3 (a int); SET @saved_dbug = @@GLOBAL.debug_dbug; set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_long_host,getaddrinfo_fake_good_ipv4"; +flush hosts; # check connect connect con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,"*NO-ONE*",$MASTER_MYPORT,; -connection con1; select current_user(); current_user() user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345 @@ -34,7 +34,6 @@ connection default; grant SELECT ON *.* TO user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; disconnect con1; connect con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,test,$MASTER_MYPORT,; -connection con1; select * from mariadbtestdb.t1; a b select * from mariadbtestdb2.t2; @@ -44,7 +43,6 @@ connection default; REVOKE ALL PRIVILEGES, GRANT OPTION FROM user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; disconnect con1; connect con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,"*NO-ONE*",$MASTER_MYPORT,; -connection con1; select * from mariadbtestdb.t1; ERROR 42000: SELECT command denied to user 'user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678'@'host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345' for table `mariadbtestdb`.`t1` select * from mariadbtestdb2.t2; @@ -54,7 +52,6 @@ connection default; grant SELECT ON mariadbtestdb.* TO user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; disconnect con1; connect con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,"*NO-ONE*",$MASTER_MYPORT,; -connection con1; select * from mariadbtestdb.t1; a b select * from mariadbtestdb2.t2; @@ -67,7 +64,6 @@ REVOKE ALL PRIVILEGES, GRANT OPTION FROM user5678901_345678902_345678903_3456789 grant SELECT ON mariadbtestdb.t1 TO user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; disconnect con1; connect con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,"*NO-ONE*",$MASTER_MYPORT,; -connection con1; select * from mariadbtestdb.t1; a b select * from mariadbtestdb2.t2; @@ -80,7 +76,6 @@ REVOKE ALL PRIVILEGES, GRANT OPTION FROM user5678901_345678902_345678903_3456789 grant SELECT (a) ON mariadbtestdb.t1 TO user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; disconnect con1; connect con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,"*NO-ONE*",$MASTER_MYPORT,; -connection con1; select * from mariadbtestdb.t1; ERROR 42000: SELECT command denied to user 'user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678'@'host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345' for table `mariadbtestdb`.`t1` select * from mariadbtestdb2.t2; @@ -100,7 +95,6 @@ GRANT CREATE ROUTINE on test.* to user5678901_345678902_345678903_345678904_3456 grant role5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678 to user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; disconnect con1; connect con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,test,$MASTER_MYPORT,; -connection con1; select * from mariadbtestdb.t1; ERROR 42000: SELECT command denied to user 'user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678'@'host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345' for table `mariadbtestdb`.`t1` select * from mariadbtestdb2.t2; diff --git a/mysql-test/main/long_host.test b/mysql-test/main/long_host.test index 301744a1..8ba1a120 100644 --- a/mysql-test/main/long_host.test +++ b/mysql-test/main/long_host.test @@ -33,11 +33,11 @@ create table mariadbtestdb.t3 (a int); SET @saved_dbug = @@GLOBAL.debug_dbug; set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_long_host,getaddrinfo_fake_good_ipv4"; +flush hosts; --echo # check connect connect (con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,"*NO-ONE*",$MASTER_MYPORT,); -connection con1; select current_user(); --echo # check global privileges @@ -51,7 +51,6 @@ connection default; grant SELECT ON *.* TO user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; disconnect con1; connect (con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,test,$MASTER_MYPORT,); -connection con1; select * from mariadbtestdb.t1; select * from mariadbtestdb2.t2; @@ -62,7 +61,6 @@ connection default; REVOKE ALL PRIVILEGES, GRANT OPTION FROM user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; disconnect con1; connect (con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,"*NO-ONE*",$MASTER_MYPORT,); -connection con1; --error ER_TABLEACCESS_DENIED_ERROR select * from mariadbtestdb.t1; --error ER_TABLEACCESS_DENIED_ERROR @@ -75,7 +73,6 @@ connection default; grant SELECT ON mariadbtestdb.* TO user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; disconnect con1; connect (con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,"*NO-ONE*",$MASTER_MYPORT,); -connection con1; select * from mariadbtestdb.t1; --error ER_TABLEACCESS_DENIED_ERROR select * from mariadbtestdb2.t2; @@ -88,7 +85,6 @@ REVOKE ALL PRIVILEGES, GRANT OPTION FROM user5678901_345678902_345678903_3456789 grant SELECT ON mariadbtestdb.t1 TO user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; disconnect con1; connect (con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,"*NO-ONE*",$MASTER_MYPORT,); -connection con1; select * from mariadbtestdb.t1; --error ER_TABLEACCESS_DENIED_ERROR select * from mariadbtestdb2.t2; @@ -102,7 +98,6 @@ REVOKE ALL PRIVILEGES, GRANT OPTION FROM user5678901_345678902_345678903_3456789 grant SELECT (a) ON mariadbtestdb.t1 TO user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; disconnect con1; connect (con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,"*NO-ONE*",$MASTER_MYPORT,); -connection con1; --error ER_TABLEACCESS_DENIED_ERROR select * from mariadbtestdb.t1; --error ER_TABLEACCESS_DENIED_ERROR @@ -132,7 +127,6 @@ grant role5678901_345678902_345678903_345678904_345678905_345678906_345678907_34 disconnect con1; connect (con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,test,$MASTER_MYPORT,); -connection con1; --error ER_TABLEACCESS_DENIED_ERROR select * from mariadbtestdb.t1; diff --git a/mysql-test/main/long_unique_bugs.result b/mysql-test/main/long_unique_bugs.result index ce44ae2b..b8fbd40b 100644 --- a/mysql-test/main/long_unique_bugs.result +++ b/mysql-test/main/long_unique_bugs.result @@ -574,5 +574,108 @@ insert into t1 values (1,10),(2,20); update t1 set b = 30 limit 1; drop table t1; # +# MDEV-32839 LONG UNIQUE gives error when used with REPLACE +# +create table t1 ( +f1 bigint(20) not null auto_increment primary key, +f2 varchar(30) default null, +f3 varchar(30) default null, +f4 varchar(255) default null, +f5 varchar(30) default null, +f6 varchar(255) default null, +f7 varchar(255) default null, +unique problem_key (f3,f5,f6,f2,f4,f7) using hash +) engine=myisam; +insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd'); +replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd'); +insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e'); +replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e'); +select * from t1; +f1 f2 f3 f4 f5 f6 f7 +2 00004 0001009089999 netstes psit d +4 00004 0001009089999 netstes psit e +drop table t1; +create table t1 ( +f1 bigint(20) not null auto_increment primary key, +f2 varchar(30) default null, +f3 varchar(30) default null, +f4 varchar(255) default null, +f5 varchar(30) default null, +f6 varchar(255) default null, +f7 varchar(255) default null, +unique problem_key (f3,f5,f6,f2,f4,f7) using hash +) engine=innodb; +insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd'); +replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd'); +insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e'); +replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e'); +select * from t1; +f1 f2 f3 f4 f5 f6 f7 +2 00004 0001009089999 netstes psit d +4 00004 0001009089999 netstes psit e +drop table t1; +create table t1 ( +f1 bigint(20) not null auto_increment primary key, +f2 varchar(30) default null, +f3 varchar(30) default null, +f4 varchar(255) default null, +f5 varchar(30) default null, +f6 varchar(255) default null, +f7 varchar(255) default null, +unique problem_key (f3,f5,f6,f2,f4,f7) using hash +) engine=myisam partition by key(f1) partitions 2; +insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd'); +replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd'); +insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e'); +replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e'); +select * from t1; +f1 f2 f3 f4 f5 f6 f7 +2 00004 0001009089999 netstes psit d +4 00004 0001009089999 netstes psit e +drop table t1; +create table t1 ( +f1 bigint(20) not null auto_increment primary key, +f2 varchar(30) default null, +f3 varchar(30) default null, +f4 varchar(255) default null, +f5 varchar(30) default null, +f6 varchar(255) default null, +f7 varchar(255) default null, +unique problem_key (f3,f5,f6,f2,f4,f7) using hash +) engine=innodb partition by key(f1) partitions 2; +insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd'); +replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd'); +insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e'); +replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e'); +select * from t1; +f1 f2 f3 f4 f5 f6 f7 +2 00004 0001009089999 netstes psit d +4 00004 0001009089999 netstes psit e +drop table t1; +# +# MDEV-29954 Unique hash key on column prefix is computed incorrectly +# +create table t1 (c char(10),unique key a using hash (c(1))); +insert into t1 values (0); +check table t1 extended; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; +# +# MDEV-32837 long unique does not work like unique key when using replace +# +CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c INT, UNIQUE KEY `test` (b,c) USING HASH) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,1,1),(2,2,2); +REPLACE INTO t1 VALUES (3,1,1); +SELECT * FROM t1 ORDER BY a; +a b c +2 2 2 +3 1 1 +REPLACE INTO t1 VALUES (3,2,2); +SELECT * FROM t1; +a b c +3 2 2 +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 c06b4169..01c3f736 100644 --- a/mysql-test/main/long_unique_bugs.test +++ b/mysql-test/main/long_unique_bugs.test @@ -564,5 +564,97 @@ update t1 set b = 30 limit 1; drop table t1; --echo # +--echo # MDEV-32839 LONG UNIQUE gives error when used with REPLACE +--echo # +create table t1 ( + f1 bigint(20) not null auto_increment primary key, + f2 varchar(30) default null, + f3 varchar(30) default null, + f4 varchar(255) default null, + f5 varchar(30) default null, + f6 varchar(255) default null, + f7 varchar(255) default null, + unique problem_key (f3,f5,f6,f2,f4,f7) using hash +) engine=myisam; +insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd'); +replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd'); +insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e'); +replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e'); +select * from t1; +drop table t1; + +create table t1 ( + f1 bigint(20) not null auto_increment primary key, + f2 varchar(30) default null, + f3 varchar(30) default null, + f4 varchar(255) default null, + f5 varchar(30) default null, + f6 varchar(255) default null, + f7 varchar(255) default null, + unique problem_key (f3,f5,f6,f2,f4,f7) using hash +) engine=innodb; +insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd'); +replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd'); +insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e'); +replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e'); +select * from t1; +drop table t1; + +create table t1 ( + f1 bigint(20) not null auto_increment primary key, + f2 varchar(30) default null, + f3 varchar(30) default null, + f4 varchar(255) default null, + f5 varchar(30) default null, + f6 varchar(255) default null, + f7 varchar(255) default null, + unique problem_key (f3,f5,f6,f2,f4,f7) using hash +) engine=myisam partition by key(f1) partitions 2; +insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd'); +replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd'); +insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e'); +replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e'); +select * from t1; +drop table t1; + +create table t1 ( + f1 bigint(20) not null auto_increment primary key, + f2 varchar(30) default null, + f3 varchar(30) default null, + f4 varchar(255) default null, + f5 varchar(30) default null, + f6 varchar(255) default null, + f7 varchar(255) default null, + unique problem_key (f3,f5,f6,f2,f4,f7) using hash +) engine=innodb partition by key(f1) partitions 2; +insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd'); +replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd'); +insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e'); +replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e'); +select * from t1; +drop table t1; + +--echo # +--echo # MDEV-29954 Unique hash key on column prefix is computed incorrectly +--echo # +create table t1 (c char(10),unique key a using hash (c(1))); +insert into t1 values (0); +check table t1 extended; +drop table t1; + + +--echo # +--echo # MDEV-32837 long unique does not work like unique key when using replace +--echo # + +CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c INT, UNIQUE KEY `test` (b,c) USING HASH) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,1,1),(2,2,2); +REPLACE INTO t1 VALUES (3,1,1); +SELECT * FROM t1 ORDER BY a; +REPLACE INTO t1 VALUES (3,2,2); +SELECT * FROM t1; +DROP TABLE t1; + +--echo # --echo # End of 10.5 tests --echo # diff --git a/mysql-test/main/long_unique_bugs_no_sp_protocol.result b/mysql-test/main/long_unique_bugs_no_sp_protocol.result new file mode 100644 index 00000000..0776a130 --- /dev/null +++ b/mysql-test/main/long_unique_bugs_no_sp_protocol.result @@ -0,0 +1,95 @@ +# +# Start of 10.5 tests +# +# +# MDEV-32837 long unique does not work like unique key when using replace +# +# +# Normal unique key + long unique key +# +CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c INT, UNIQUE KEY `test` (b,c) USING HASH) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,1,1),(2,2,2); +FLUSH STATUS; +REPLACE INTO t1 VALUES (3,1,1); +SHOW STATUS WHERE Variable_name LIKE 'handler%' AND Value>0; +Variable_name Value +Handler_delete 1 +Handler_read_key 2 +Handler_read_rnd 1 +Handler_write 1 +SELECT * FROM t1 ORDER BY a; +a b c +2 2 2 +3 1 1 +FLUSH STATUS; +REPLACE INTO t1 VALUES (3,2,2); +SHOW STATUS WHERE Variable_name LIKE 'handler%' AND Value>0; +Variable_name Value +Handler_delete 1 +Handler_read_key 3 +Handler_read_rnd 2 +Handler_update 1 +Handler_write 1 +SELECT * FROM t1; +a b c +3 2 2 +DROP TABLE t1; +# +# Two long unique keys +# +CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE KEY a (a) USING HASH,UNIQUE KEY `test` (b,c) USING HASH) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,1,1),(2,2,2); +FLUSH STATUS; +REPLACE INTO t1 VALUES (3,1,1); +SHOW STATUS WHERE Variable_name LIKE 'handler%' AND Value>0; +Variable_name Value +Handler_read_key 3 +Handler_read_rnd 1 +Handler_update 1 +SELECT * FROM t1 ORDER BY a; +a b c +2 2 2 +3 1 1 +FLUSH STATUS; +REPLACE INTO t1 VALUES (3,2,2); +SHOW STATUS WHERE Variable_name LIKE 'handler%' AND Value>0; +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 2 +Handler_update 1 +SELECT * FROM t1; +a b c +3 2 2 +DROP TABLE t1; +# +# One long unique key +# +CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE KEY `test` (b,c) USING HASH) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,1,1),(2,2,2); +FLUSH STATUS; +REPLACE INTO t1 VALUES (3,1,1); +SHOW STATUS WHERE Variable_name LIKE 'handler%' AND Value>0; +Variable_name Value +Handler_read_key 1 +Handler_read_rnd 1 +Handler_update 1 +SELECT * FROM t1 ORDER BY a; +a b c +2 2 2 +3 1 1 +FLUSH STATUS; +REPLACE INTO t1 VALUES (3,2,2); +SHOW STATUS WHERE Variable_name LIKE 'handler%' AND Value>0; +Variable_name Value +Handler_read_key 1 +Handler_read_rnd 1 +Handler_update 1 +SELECT * FROM t1; +a b c +3 1 1 +3 2 2 +DROP TABLE t1; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/long_unique_bugs_no_sp_protocol.test b/mysql-test/main/long_unique_bugs_no_sp_protocol.test new file mode 100644 index 00000000..6bfa6182 --- /dev/null +++ b/mysql-test/main/long_unique_bugs_no_sp_protocol.test @@ -0,0 +1,68 @@ +if (`SELECT $SP_PROTOCOL > 0`) +{ + --skip Test requires: sp-protocol disabled +} + + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-32837 long unique does not work like unique key when using replace +--echo # + +# This test produces different Handler commands in the SHOW STATUS output +# with --sp-protocol. So it's here, in this *.test file with --sp-protocol disabled. + +--echo # +--echo # Normal unique key + long unique key +--echo # + +CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c INT, UNIQUE KEY `test` (b,c) USING HASH) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,1,1),(2,2,2); +FLUSH STATUS; +REPLACE INTO t1 VALUES (3,1,1); +SHOW STATUS WHERE Variable_name LIKE 'handler%' AND Value>0; +SELECT * FROM t1 ORDER BY a; +FLUSH STATUS; +REPLACE INTO t1 VALUES (3,2,2); +SHOW STATUS WHERE Variable_name LIKE 'handler%' AND Value>0; +SELECT * FROM t1; +DROP TABLE t1; + +--echo # +--echo # Two long unique keys +--echo # + +CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE KEY a (a) USING HASH,UNIQUE KEY `test` (b,c) USING HASH) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,1,1),(2,2,2); +FLUSH STATUS; +REPLACE INTO t1 VALUES (3,1,1); +SHOW STATUS WHERE Variable_name LIKE 'handler%' AND Value>0; +SELECT * FROM t1 ORDER BY a; +FLUSH STATUS; +REPLACE INTO t1 VALUES (3,2,2); +SHOW STATUS WHERE Variable_name LIKE 'handler%' AND Value>0; +SELECT * FROM t1; +DROP TABLE t1; + +--echo # +--echo # One long unique key +--echo # + +CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE KEY `test` (b,c) USING HASH) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,1,1),(2,2,2); +FLUSH STATUS; +REPLACE INTO t1 VALUES (3,1,1); +SHOW STATUS WHERE Variable_name LIKE 'handler%' AND Value>0; +SELECT * FROM t1 ORDER BY a; +FLUSH STATUS; +REPLACE INTO t1 VALUES (3,2,2); +SHOW STATUS WHERE Variable_name LIKE 'handler%' AND Value>0; +SELECT * FROM t1; +DROP TABLE t1; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/lotofstack.result b/mysql-test/main/lotofstack.result new file mode 100644 index 00000000..553dcb3b --- /dev/null +++ b/mysql-test/main/lotofstack.result @@ -0,0 +1,101 @@ +create function bug10100f(prm int) returns int +begin +if prm > 1 then +return prm * bug10100f(prm - 1); +end if; +return 1; +end| +set statement sql_mode = '' for +create procedure bug10100p(prm int, inout res int) +begin +set res = res * prm; +if prm > 1 then +call bug10100p(prm - 1, res); +end if; +end| +set statement sql_mode = '' for +create procedure bug10100t(prm int) +begin +declare res int; +set res = 1; +call bug10100p(prm, res); +select res; +end| +create table t3 (a int)| +insert into t3 values (0)| +create view v1 as select a from t3| +create procedure bug10100pt(level int, lim int) +begin +if level < lim then +update t3 set a=level; +FLUSH TABLES; +call bug10100pt(level+1, lim); +else +select * from t3; +end if; +end| +create procedure bug10100pv(level int, lim int) +begin +if level < lim then +update v1 set a=level; +FLUSH TABLES; +call bug10100pv(level+1, lim); +else +select * from v1; +end if; +end| +prepare stmt2 from "select * from t3;"; +create procedure bug10100pd(level int, lim int) +begin +if level < lim then +select level; +prepare stmt1 from "update t3 set a=a+2"; +execute stmt1; +FLUSH TABLES; +execute stmt1; +FLUSH TABLES; +execute stmt1; +FLUSH TABLES; +deallocate prepare stmt1; +execute stmt2; +select * from t3; +call bug10100pd(level+1, lim); +else +execute stmt2; +end if; +end| +create procedure bug10100pc(level int, lim int) +begin +declare lv int; +declare c cursor for select a from t3; +open c; +if level < lim then +select level; +fetch c into lv; +select lv; +update t3 set a=level+lv; +FLUSH TABLES; +call bug10100pc(level+1, lim); +else +select * from t3; +end if; +close c; +end| +set @@max_sp_recursion_depth=255| +set @var=1| +call bug10100p(255, @var)| +call bug10100pt(1,255)| +call bug10100pv(1,255)| +call bug10100pd(1,255)| +call bug10100pc(1,255)| +set @@max_sp_recursion_depth=0| +deallocate prepare stmt2| +drop function bug10100f| +drop procedure bug10100p| +drop procedure bug10100t| +drop procedure bug10100pt| +drop procedure bug10100pv| +drop procedure bug10100pd| +drop procedure bug10100pc| +drop view v1| +drop table t3| diff --git a/mysql-test/main/lotofstack.test b/mysql-test/main/lotofstack.test new file mode 100644 index 00000000..a658fb00 --- /dev/null +++ b/mysql-test/main/lotofstack.test @@ -0,0 +1,133 @@ +# +# For tests that need a lot of stack - they likely won't work under ASAN +# +source include/not_asan.inc; +source include/not_embedded.inc; + +# +# Bug#10100 function (and stored procedure?) recursivity problem +# +# routines with simple recursion +delimiter |; +create function bug10100f(prm int) returns int +begin + if prm > 1 then + return prm * bug10100f(prm - 1); + end if; + return 1; +end| +set statement sql_mode = '' for +create procedure bug10100p(prm int, inout res int) +begin + set res = res * prm; + if prm > 1 then + call bug10100p(prm - 1, res); + end if; +end| +set statement sql_mode = '' for +create procedure bug10100t(prm int) +begin + declare res int; + set res = 1; + call bug10100p(prm, res); + select res; +end| + +# a procedure which use tables and recursion +create table t3 (a int)| +insert into t3 values (0)| +create view v1 as select a from t3| +create procedure bug10100pt(level int, lim int) +begin + if level < lim then + update t3 set a=level; + FLUSH TABLES; + call bug10100pt(level+1, lim); + else + select * from t3; + end if; +end| +# view & recursion +create procedure bug10100pv(level int, lim int) +begin + if level < lim then + update v1 set a=level; + FLUSH TABLES; + call bug10100pv(level+1, lim); + else + select * from v1; + end if; +end| +# dynamic sql & recursion +prepare stmt2 from "select * from t3;"; +create procedure bug10100pd(level int, lim int) +begin + if level < lim then + select level; + prepare stmt1 from "update t3 set a=a+2"; + execute stmt1; + FLUSH TABLES; + execute stmt1; + FLUSH TABLES; + execute stmt1; + FLUSH TABLES; + deallocate prepare stmt1; + execute stmt2; + select * from t3; + call bug10100pd(level+1, lim); + else + execute stmt2; + end if; +end| +# cursor & recursion +create procedure bug10100pc(level int, lim int) +begin + declare lv int; + declare c cursor for select a from t3; + open c; + if level < lim then + select level; + fetch c into lv; + select lv; + update t3 set a=level+lv; + FLUSH TABLES; + call bug10100pc(level+1, lim); + else + select * from t3; + end if; + close c; +end| + +# end of the stack checking +set @@max_sp_recursion_depth=255| +set @var=1| +# disable log because error about stack overrun contains numbers which +# depend on a system +-- disable_ps_protocol +-- disable_result_log +-- error ER_STACK_OVERRUN_NEED_MORE +call bug10100p(255, @var)| +-- error ER_STACK_OVERRUN_NEED_MORE +call bug10100pt(1,255)| +-- error ER_STACK_OVERRUN_NEED_MORE +call bug10100pv(1,255)| +-- error ER_STACK_OVERRUN_NEED_MORE +call bug10100pd(1,255)| +-- error ER_STACK_OVERRUN_NEED_MORE +call bug10100pc(1,255)| +-- enable_result_log +-- enable_ps_protocol +set @@max_sp_recursion_depth=0| + +deallocate prepare stmt2| + +drop function bug10100f| +drop procedure bug10100p| +drop procedure bug10100t| +drop procedure bug10100pt| +drop procedure bug10100pv| +drop procedure bug10100pd| +drop procedure bug10100pc| +drop view v1| +drop table t3| +delimiter ;| diff --git a/mysql-test/main/lowercase_table5.result b/mysql-test/main/lowercase_table5.result index f2b5bb0c..77318a8e 100644 --- a/mysql-test/main/lowercase_table5.result +++ b/mysql-test/main/lowercase_table5.result @@ -11,3 +11,39 @@ Database Create Database mysql_TEST CREATE DATABASE `mysql_TEST` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci */ DROP DATABASE mysql_test; DROP DATABASE mysql_TEST; +# +# Start of 10.4 tests +# +# +# MDEV-33019 The database part is not case sensitive in SP names +# +CREATE DATABASE DB1; +CREATE DATABASE db1; +CREATE PROCEDURE DB1.sp() SELECT 'This is DB1.sp' AS ret; +CREATE PROCEDURE db1.sp() SELECT 'This is db1.sp' AS ret; +CALL DB1.sp(); +ret +This is DB1.sp +CALL db1.sp(); +ret +This is db1.sp +DROP DATABASE DB1; +CALL DB1.sp(); +ERROR 42000: PROCEDURE DB1.sp does not exist +CALL db1.sp(); +ret +This is db1.sp +DROP DATABASE db1; +CREATE PROCEDURE SP() SELECT 'This is SP' AS ret; +CREATE PROCEDURE sp() SELECT 'This is sp' AS ret; +ERROR 42000: PROCEDURE sp already exists +CALL SP(); +ret +This is SP +CALL sp(); +ret +This is SP +DROP PROCEDURE SP; +# +# End of 10.4 tests +# diff --git a/mysql-test/main/lowercase_table5.test b/mysql-test/main/lowercase_table5.test index dfdfafcb..0103dbf5 100644 --- a/mysql-test/main/lowercase_table5.test +++ b/mysql-test/main/lowercase_table5.test @@ -18,3 +18,34 @@ DROP DATABASE mysql_test; DROP DATABASE mysql_TEST; # End of 10.0 tests + +--echo # +--echo # Start of 10.4 tests +--echo # + +--echo # +--echo # MDEV-33019 The database part is not case sensitive in SP names +--echo # + +CREATE DATABASE DB1; +CREATE DATABASE db1; +CREATE PROCEDURE DB1.sp() SELECT 'This is DB1.sp' AS ret; +CREATE PROCEDURE db1.sp() SELECT 'This is db1.sp' AS ret; +CALL DB1.sp(); +CALL db1.sp(); +DROP DATABASE DB1; +--error ER_SP_DOES_NOT_EXIST +CALL DB1.sp(); +CALL db1.sp(); +DROP DATABASE db1; + +CREATE PROCEDURE SP() SELECT 'This is SP' AS ret; +--error ER_SP_ALREADY_EXISTS +CREATE PROCEDURE sp() SELECT 'This is sp' AS ret; +CALL SP(); +CALL sp(); +DROP PROCEDURE SP; + +--echo # +--echo # End of 10.4 tests +--echo # diff --git a/mysql-test/main/mdl.result b/mysql-test/main/mdl.result index c0f5671c..dd3d9239 100644 --- a/mysql-test/main/mdl.result +++ b/mysql-test/main/mdl.result @@ -61,7 +61,7 @@ DROP TABLE t1,t3; # # Check MDL locks taken for different kind of tables by open # -CREATE TABLE t1(a INT) ENGINE=InnoDB; +CREATE TABLE t1(a INT) stats_persistent=0, ENGINE=InnoDB; CREATE TABLE t3(a INT) ENGINE=myisam; connect purge_control,localhost,root,,; START TRANSACTION WITH CONSISTENT SNAPSHOT; diff --git a/mysql-test/main/mdl.test b/mysql-test/main/mdl.test index 65d02d77..6b0c7690 100644 --- a/mysql-test/main/mdl.test +++ b/mysql-test/main/mdl.test @@ -43,7 +43,7 @@ DROP TABLE t1,t3; --echo # Check MDL locks taken for different kind of tables by open --echo # -CREATE TABLE t1(a INT) ENGINE=InnoDB; +CREATE TABLE t1(a INT) stats_persistent=0, ENGINE=InnoDB; CREATE TABLE t3(a INT) ENGINE=myisam; connect(purge_control,localhost,root,,); START TRANSACTION WITH CONSISTENT SNAPSHOT; diff --git a/mysql-test/main/mdl_sync.result b/mysql-test/main/mdl_sync.result index 0ffe2f74..0324c261 100644 --- a/mysql-test/main/mdl_sync.result +++ b/mysql-test/main/mdl_sync.result @@ -2403,6 +2403,7 @@ connection con2; SET DEBUG_SYNC= 'now WAIT_FOR table_opened'; # Check that FLUSH must wait to get the GRL # and let DROP PROCEDURE continue +InnoDB 0 transactions not purged SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info; LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME MDL_BACKUP_DDL Backup lock @@ -2427,7 +2428,7 @@ SET DEBUG_SYNC= 'RESET'; # UPDATE should wait for FTWRL with non transactional table second # create table t1 (a int) engine=myisam; -create table t2 (a int) engine=innodb; +create table t2 (a int) stats_persistent=0, engine=innodb; insert into t1 values (1); insert into t2 values (1); SET DEBUG_SYNC= 'after_open_table_mdl_shared SIGNAL table_opened WAIT_FOR grlwait execute 2'; diff --git a/mysql-test/main/mdl_sync.test b/mysql-test/main/mdl_sync.test index 3df19aca..7a928a4c 100644 --- a/mysql-test/main/mdl_sync.test +++ b/mysql-test/main/mdl_sync.test @@ -3085,6 +3085,7 @@ connection con2; SET DEBUG_SYNC= 'now WAIT_FOR table_opened'; --echo # Check that FLUSH must wait to get the GRL --echo # and let DROP PROCEDURE continue +--source ../suite/innodb/include/wait_all_purged.inc SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info; SET DEBUG_SYNC= 'mdl_acquire_lock_wait SIGNAL grlwait'; --send FLUSH TABLES WITH READ LOCK @@ -3110,7 +3111,7 @@ SET DEBUG_SYNC= 'RESET'; --echo # create table t1 (a int) engine=myisam; -create table t2 (a int) engine=innodb; +create table t2 (a int) stats_persistent=0, engine=innodb; insert into t1 values (1); insert into t2 values (1); diff --git a/mysql-test/main/mrr_icp_extra.result b/mysql-test/main/mrr_icp_extra.result index 1b33b008..48b3b91d 100644 --- a/mysql-test/main/mrr_icp_extra.result +++ b/mysql-test/main/mrr_icp_extra.result @@ -38,18 +38,24 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN SELECT * FROM t1 WHERE s2 BETWEEN 'a' AND 'b' COLLATE latin1_german1_ci; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL s2 NULL NULL NULL 10 Using where +Warnings: +Note 1105 Cannot use key `s2` part[0] for lookup: `test`.`t1`.`s2` of collation `latin1_swedish_ci` >= "'a'" of collation `latin1_german1_ci` EXPLAIN SELECT * FROM t1 WHERE s1 IN ('a','b' COLLATE latin1_german1_ci); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range s1 s1 11 NULL 2 Using index condition; Rowid-ordered scan EXPLAIN SELECT * FROM t1 WHERE s2 IN ('a','b' COLLATE latin1_german1_ci); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL s2 NULL NULL NULL 10 Using where +Warnings: +Note 1105 Cannot use key `s2` part[0] for lookup: `test`.`t1`.`s2` of collation `latin1_swedish_ci` = "'a'" of collation `latin1_german1_ci` EXPLAIN SELECT * FROM t1 WHERE s1 LIKE 'a' COLLATE latin1_german1_ci; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range s1 s1 11 NULL 1 Using index condition; Rowid-ordered scan EXPLAIN SELECT * FROM t1 WHERE s2 LIKE 'a' COLLATE latin1_german1_ci; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL s2 NULL NULL NULL 10 Using where +Warnings: +Note 1105 Cannot use key `s2` part[0] for lookup: `test`.`t1`.`s2` of collation `latin1_swedish_ci` like "'a' collate latin1_german1_ci" of collation `latin1_german1_ci` 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 cc42c16d..e28c2a0f 100644 --- a/mysql-test/main/myisam_explain_non_select_all.result +++ b/mysql-test/main/myisam_explain_non_select_all.result @@ -1506,7 +1506,7 @@ EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 26 Using where; Using filesort Warnings: -Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` >= "10" of type `int` +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` > "10" of type `int` Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` <= "18" of type `int` FLUSH STATUS; FLUSH TABLES; @@ -1514,7 +1514,7 @@ EXPLAIN EXTENDED DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort Warnings: -Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` >= "10" of type `int` +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` > "10" of type `int` Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` <= "18" of type `int` Note 1003 delete from `test`.`t1` where `test`.`t1`.`i` > 10 and `test`.`t1`.`i` <= 18 order by `test`.`t1`.`i` limit 5 # Status of EXPLAIN EXTENDED query @@ -1526,7 +1526,9 @@ EXPLAIN EXTENDED SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL i NULL NULL NULL 26 100.00 Using where; Using filesort Warnings: -Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` >= "10" of type `int` +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` > "10" of type `int` +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` <= "18" of type `int` +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` > "10" of type `int` Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` <= "18" of type `int` Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`i` AS `i` from `test`.`t1` where `test`.`t1`.`i` > 10 and `test`.`t1`.`i` <= 18 order by `test`.`t1`.`i` limit 5 # Status of EXPLAIN EXTENDED "equivalent" SELECT query execution @@ -1551,6 +1553,71 @@ Sort_rows 8 Sort_scan 1 DROP TABLE t1; +#30a +# +# MDEV-32957 Unusable key notes report wrong predicates for > and >= +# +CREATE TABLE t1(a INT, i CHAR(2), INDEX(i(1))); +INSERT INTO t1 (i) VALUES (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); +# +# query: DELETE FROM t1 WHERE i >= 10 AND i < 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t1 WHERE i >= 10 AND i < 18 ORDER BY i LIMIT 5 +# +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 DELETE FROM t1 WHERE i >= 10 AND i < 18 ORDER BY i LIMIT 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 26 Using where; Using filesort +Warnings: +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` >= "10" of type `int` +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` < "18" of type `int` +FLUSH STATUS; +FLUSH TABLES; +EXPLAIN EXTENDED DELETE FROM t1 WHERE i >= 10 AND i < 18 ORDER BY i LIMIT 5; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` >= "10" of type `int` +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` < "18" of type `int` +Note 1003 delete from `test`.`t1` where `test`.`t1`.`i` >= 10 and `test`.`t1`.`i` < 18 order by `test`.`t1`.`i` limit 5 +# Status of EXPLAIN EXTENDED query +Variable_name Value +Handler_read_key 4 +FLUSH STATUS; +FLUSH TABLES; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE i >= 10 AND i < 18 ORDER BY i LIMIT 5; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL i NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` >= "10" of type `int` +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` < "18" of type `int` +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` >= "10" of type `int` +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` < "18" of type `int` +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`i` AS `i` from `test`.`t1` where `test`.`t1`.`i` >= 10 and `test`.`t1`.`i` < 18 order by `test`.`t1`.`i` limit 5 +# Status of EXPLAIN EXTENDED "equivalent" SELECT query execution +Variable_name Value +Handler_read_key 4 +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 4 +Handler_read_rnd_next 27 +Sort_priority_queue_sorts 1 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 4 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 8 +Sort_scan 1 + +DROP TABLE t1; #31 CREATE TABLE t1 (i INT); INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), @@ -2057,7 +2124,7 @@ EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 26 Using where; Using filesort Warnings: -Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t2`.`i` of type `char` >= "10" of type `int` +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t2`.`i` of type `char` > "10" of type `int` Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t2`.`i` of type `char` <= "18" of type `int` FLUSH STATUS; FLUSH TABLES; @@ -2065,7 +2132,7 @@ EXPLAIN EXTENDED UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort Warnings: -Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t2`.`i` of type `char` >= "10" of type `int` +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t2`.`i` of type `char` > "10" of type `int` Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t2`.`i` of type `char` <= "18" of type `int` Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where `test`.`t2`.`i` > 10 and `test`.`t2`.`i` <= 18 order by `test`.`t2`.`i` limit 5 # Status of EXPLAIN EXTENDED query @@ -2077,7 +2144,9 @@ EXPLAIN EXTENDED SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 ALL i NULL NULL NULL 26 100.00 Using where; Using filesort Warnings: -Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t2`.`i` of type `char` >= "10" of type `int` +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t2`.`i` of type `char` > "10" of type `int` +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t2`.`i` of type `char` <= "18" of type `int` +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t2`.`i` of type `char` > "10" of type `int` Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t2`.`i` of type `char` <= "18" of type `int` Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where `test`.`t2`.`i` > 10 and `test`.`t2`.`i` <= 18 order by `test`.`t2`.`i` limit 5 # Status of EXPLAIN EXTENDED "equivalent" SELECT query execution diff --git a/mysql-test/main/mysql-interactive.result b/mysql-test/main/mysql-interactive.result new file mode 100644 index 00000000..a18c018b --- /dev/null +++ b/mysql-test/main/mysql-interactive.result @@ -0,0 +1,24 @@ +# +# regression introduced by MDEV-14448 +# +delimiter $
+select 1;
+$
+Welcome to the MariaDB monitor. Commands end with ; or \g.
+Your MariaDB connection id is X
+Server version: Y
+Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
+
+Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
+
+MariaDB [(none)]> delimiter $
+MariaDB [(none)]> select 1;
+ -> $
++---+
+| 1 |
++---+
+| 1 |
++---+
+1 row in set
+
+MariaDB [(none)]>
\ No newline at end of file diff --git a/mysql-test/main/mysql-interactive.test b/mysql-test/main/mysql-interactive.test new file mode 100644 index 00000000..2015e9d6 --- /dev/null +++ b/mysql-test/main/mysql-interactive.test @@ -0,0 +1,29 @@ +--echo # +--echo # regression introduced by MDEV-14448 +--echo # +source include/not_embedded.inc; +source include/not_windows.inc; + +error 0,1; +exec $MYSQL -V|grep -q readline; +if ($sys_errno == 1) +{ + # strangely enough + skip does not work with libedit; +} + +write_file $MYSQL_TMP_DIR/mysql_in; +delimiter $ +select 1; +$ +EOF +let TERM=dumb; +replace_regex /id is \d+/id is X/ /Server version: .*/Server version: Y/ / \(\d+\.\d+ sec\)//; +error 0,127; +exec socat EXEC:"$MYSQL",pty STDIO < $MYSQL_TMP_DIR/mysql_in; +if ($sys_errno == 127) +{ + remove_file $MYSQL_TMP_DIR/mysql_in; + skip no socat; +} +remove_file $MYSQL_TMP_DIR/mysql_in; diff --git a/mysql-test/main/mysql_connector_net.ps1 b/mysql-test/main/mysql_connector_net.ps1 new file mode 100644 index 00000000..159acf93 --- /dev/null +++ b/mysql-test/main/mysql_connector_net.ps1 @@ -0,0 +1,58 @@ +$assembly = [system.reflection.Assembly]::LoadWithPartialName("MySql.Data") +if ($assembly -eq $null) +{ + "Can't load assembly MySql.Data" + exit 100 +} + +try +{ + $connectionString =[string]::Format("server=127.0.0.1;uid=root;port={0};Connection Reset=true;",$Env:MASTER_MYPORT) + $connection = [MySql.Data.MySqlClient.MySqlConnection]@{ConnectionString=$connectionString} + $connection.Open() + + # Test ExecuteReader() + $command = New-Object MySql.Data.MySqlClient.MySqlCommand + $command.Connection = $connection + $command.CommandText = "SELECT @@old_mode" + $reader = $command.ExecuteReader() + $reader.GetName(0) + while ($reader.Read()) + { + $reader.GetValue(0) + } + + # Test connection reset + $connection.Close() + $connection.Open() + # Test ExecuteNonQuery() + $command.CommandText="do 1"; + $affected_rows = $command.ExecuteNonQuery() + if ($affected_rows -ne 0) + { + "Expected affected rows 0, actual $affected_rows" + exit 1 + } + # Test Prepared Statement + $command.CommandText = "SELECT @var"; + [void]$command.Parameters.AddWithValue("@var", 1); + $command.Prepare(); + $out = $command.ExecuteScalar(); + if ($out -ne 1) + { + "Expected output 1, actual $out" + exit 1 + } + $connection.Close() +} +catch +{ + # Dump exception + $_ + $inner = $PSItem.Exception.InnerException + if ($inner -ne $null) + { + $PSItem.Exception.InnerException.Message + $PSItem.Exception.InnerException.StackTrace + } +} diff --git a/mysql-test/main/mysql_connector_net.result b/mysql-test/main/mysql_connector_net.result new file mode 100644 index 00000000..f2fa39df --- /dev/null +++ b/mysql-test/main/mysql_connector_net.result @@ -0,0 +1,2 @@ +@@old_mode +UTF8_IS_UTF8MB3,NO_NULL_COLLATION_IDS diff --git a/mysql-test/main/mysql_connector_net.test b/mysql-test/main/mysql_connector_net.test new file mode 100644 index 00000000..c1dce65a --- /dev/null +++ b/mysql-test/main/mysql_connector_net.test @@ -0,0 +1,11 @@ +--source include/windows.inc +let $sys_errno=0; + +# Error 100 is returned by the powershell script +# if MySql.Data is not installed +--error 0,100 +--exec powershell -NoLogo -NoProfile -File main\mysql_connector_net.ps1 +if ($sys_errno != 0) +{ + --skip Connector/NET is not installed +} diff --git a/mysql-test/main/mysql_install_db_win.test b/mysql-test/main/mysql_install_db_win.test index f6113847..f0ce4805 100644 --- a/mysql-test/main/mysql_install_db_win.test +++ b/mysql-test/main/mysql_install_db_win.test @@ -24,7 +24,9 @@ rmdir $ddir; # MDEV-23052 # 1. mysql_install_db works on existing, empty directory mkdir $ddir; -exec $MYSQL_INSTALL_DB_EXE --datadir=$ddir --password=foo -R > /dev/null; +disable_result_log; +exec $MYSQL_INSTALL_DB_EXE --datadir=$ddir --password=foo -R --verbose-bootstrap; +enable_result_log; rmdir $ddir; # 2. mysql_install_db rejects existing, non-empty directory, and does not diff --git a/mysql-test/main/mysql_json_table_recreate.result b/mysql-test/main/mysql_json_table_recreate.result index 207dde9d..a61377fe 100644 --- a/mysql-test/main/mysql_json_table_recreate.result +++ b/mysql-test/main/mysql_json_table_recreate.result @@ -30,6 +30,12 @@ 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! +CREATE TABLE t2 AS 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! +CREATE TABLE t2 (a mysql_json /*new column*/) AS SELECT * FROM mysql_json_test; +ERROR HY000: 'MYSQL_JSON' is not allowed in this context +CREATE TABLE t2 (actual mysql_json /*existing column*/) AS SELECT * FROM mysql_json_test; +ERROR HY000: 'MYSQL_JSON' is not allowed in this context 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; @@ -169,3 +175,67 @@ Total_Number_of_Tests Succesful_Tests String_is_valid_JSON drop table tempty; drop table mysql_json_test; drop table mysql_json_test_big; +# +# MDEV-32790: Output result in show create table +# for mysql_json type should be longtext +# +create table t1(j json); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `j` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`j`)) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +drop table t1; +create table t1(j mysql_json); +ERROR HY000: 'MYSQL_JSON' is not allowed in this context +create table `testjson` ( +`t` json /* JSON from MySQL 5.7*/ CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +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 'CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL +) ENGINE=InnoDB DEFAULT CH...' at line 2 +create table `testjson` ( +`t` json /* JSON from MySQL 5.7*/ COLLATE utf8mb4_bin NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +show create table testjson; +Table Create Table +testjson CREATE TABLE `testjson` ( + `t` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`t`)) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +drop table testjson; +create table `testjson` ( +`t` longtext /* JSON from MySQL 5.7 */ CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +show create table testjson; +Table Create Table +testjson CREATE TABLE `testjson` ( + `t` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +drop table testjson; +# +# MDEV-32235: mysql_json cannot be used on newly created table +# +CREATE TABLE t(j mysql_json); +ERROR HY000: 'MYSQL_JSON' is not allowed in this context +CREATE TABLE IF NOT EXISTS t(j mysql_json); +ERROR HY000: 'MYSQL_JSON' is not allowed in this context +CREATE OR REPLACE TABLE t(j mysql_json); +ERROR HY000: 'MYSQL_JSON' is not allowed in this context +CREATE TEMPORARY TABLE t(j mysql_json); +ERROR HY000: 'MYSQL_JSON' is not allowed in this context +CREATE TABLE t1 (a TEXT); +ALTER TABLE t1 MODIFY a mysql_json; +ERROR HY000: 'MYSQL_JSON' is not allowed in this context +DROP TABLE t1; +CREATE FUNCTION f1() RETURNS mysql_json RETURN NULL; +ERROR HY000: 'MYSQL_JSON' is not allowed in this context +CREATE FUNCTION f1(a mysql_json) RETURNS INT RETURN 0; +ERROR HY000: 'MYSQL_JSON' is not allowed in this context +CREATE PROCEDURE p1() +BEGIN +DECLARE a mysql_json; +END; +$$ +ERROR HY000: 'MYSQL_JSON' is not allowed in this context +# +# End of 10.5 tests +# diff --git a/mysql-test/main/mysql_json_table_recreate.test b/mysql-test/main/mysql_json_table_recreate.test index a399b546..a6f1d319 100644 --- a/mysql-test/main/mysql_json_table_recreate.test +++ b/mysql-test/main/mysql_json_table_recreate.test @@ -52,6 +52,13 @@ show create table mysql_json_test; select * from mysql_json_test; --error ER_TABLE_NEEDS_REBUILD +CREATE TABLE t2 AS SELECT * FROM mysql_json_test; +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT +CREATE TABLE t2 (a mysql_json /*new column*/) AS SELECT * FROM mysql_json_test; +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT +CREATE TABLE t2 (actual mysql_json /*existing column*/) AS SELECT * FROM mysql_json_test; + +--error ER_TABLE_NEEDS_REBUILD LOCK TABLES mysql_json_test WRITE; alter table mysql_json_test force; @@ -88,3 +95,69 @@ from mysql_json_test_big; drop table tempty; drop table mysql_json_test; drop table mysql_json_test_big; + +--echo # +--echo # MDEV-32790: Output result in show create table +--echo # for mysql_json type should be longtext +--echo # + +create table t1(j json); +show create table t1; +drop table t1; +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT +create table t1(j mysql_json); +# `json` type should not have character set and collation other than utf8mb4_bin +--error ER_PARSE_ERROR +create table `testjson` ( + `t` json /* JSON from MySQL 5.7*/ CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; + +# By removing character set from `json` field query should work and +# expand to `longtext` with characterset +create table `testjson` ( + `t` json /* JSON from MySQL 5.7*/ COLLATE utf8mb4_bin NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +show create table testjson; +drop table testjson; + +# `longtext` that is alias can have character set +create table `testjson` ( + `t` longtext /* JSON from MySQL 5.7 */ CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +show create table testjson; +drop table testjson; + +--echo # +--echo # MDEV-32235: mysql_json cannot be used on newly created table +--echo # + +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT +CREATE TABLE t(j mysql_json); +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT +CREATE TABLE IF NOT EXISTS t(j mysql_json); +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT +CREATE OR REPLACE TABLE t(j mysql_json); +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT +CREATE TEMPORARY TABLE t(j mysql_json); + +CREATE TABLE t1 (a TEXT); +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT +ALTER TABLE t1 MODIFY a mysql_json; +DROP TABLE t1; + +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT +CREATE FUNCTION f1() RETURNS mysql_json RETURN NULL; +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT +CREATE FUNCTION f1(a mysql_json) RETURNS INT RETURN 0; +DELIMITER $$; +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT +CREATE PROCEDURE p1() +BEGIN + DECLARE a mysql_json; +END; +$$ +DELIMITER ;$$ + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/mysql_upgrade.result b/mysql-test/main/mysql_upgrade.result index bb37a889..e67a43d5 100644 --- a/mysql-test/main/mysql_upgrade.result +++ b/mysql-test/main/mysql_upgrade.result @@ -2505,6 +2505,14 @@ Phase 7/8: uninstalling plugins Phase 8/8: Running 'FLUSH PRIVILEGES' OK set global sql_safe_updates=@orig_sql_safe_updates; +# +# MDEV-32043 Remove plugins previously external that are now built in (unix_socket) +# +INSERT INTO mysql.plugin SELECT 'unix_socket', 'auth_socket.so' + FROM dual WHERE convert(@@version_compile_os using latin1) not in ('Win32', 'Win64', 'Windows'); +# mariadb-upgrade --force --silent 2>&1 +SELECT * FROM mysql.plugin WHERE name='unix_socket'; +name dl # End of 10.4 tests # # Check that mysql_upgrade can be run on mysqldump diff --git a/mysql-test/main/mysql_upgrade.test b/mysql-test/main/mysql_upgrade.test index 9bc809d6..70206213 100644 --- a/mysql-test/main/mysql_upgrade.test +++ b/mysql-test/main/mysql_upgrade.test @@ -496,6 +496,17 @@ set global sql_safe_updates=ON; --remove_file $MYSQLD_DATADIR/mysql_upgrade_info set global sql_safe_updates=@orig_sql_safe_updates; +--echo # +--echo # MDEV-32043 Remove plugins previously external that are now built in (unix_socket) +--echo # + +INSERT INTO mysql.plugin SELECT 'unix_socket', 'auth_socket.so' + FROM dual WHERE convert(@@version_compile_os using latin1) not in ('Win32', 'Win64', 'Windows'); +--echo # mariadb-upgrade --force --silent 2>&1 +--exec $MYSQL_UPGRADE --force --silent 2>&1 +SELECT * FROM mysql.plugin WHERE name='unix_socket'; +--remove_file $MYSQLD_DATADIR/mysql_upgrade_info + --echo # End of 10.4 tests # diff --git a/mysql-test/main/mysql_upgrade_file_leak.result b/mysql-test/main/mysql_upgrade_file_leak.result new file mode 100644 index 00000000..648a0c97 --- /dev/null +++ b/mysql-test/main/mysql_upgrade_file_leak.result @@ -0,0 +1,4 @@ +Running mysql_upgrade with --check-if-upgrade-is-needed +Checking for absence of temporary files by mysql_upgrade +No temporary files found +End of 10.4 tests diff --git a/mysql-test/main/mysql_upgrade_file_leak.test b/mysql-test/main/mysql_upgrade_file_leak.test new file mode 100644 index 00000000..44f17832 --- /dev/null +++ b/mysql-test/main/mysql_upgrade_file_leak.test @@ -0,0 +1,24 @@ +-- source include/mysql_upgrade_preparation.inc + +# +# MDEV-31925 mysqld_upgrade --check-if-upgrade-is-needed leaks files +# + +# Run mysql_upgrade with --check-if-upgrade-is-needed +--echo Running mysql_upgrade with --check-if-upgrade-is-needed +--exec $MYSQL_UPGRADE --check-if-upgrade-is-needed 2>&1 + +# Check if temporary files related to mysql_upgrade are cleared +--echo Checking for absence of temporary files by mysql_upgrade +--perl + +# Use the temporary directory path from the MySQL configuration +my $tmpdir = "$ENV{MYSQL_TMP_DIR}"; + +die "Test failed: Found temporary file left by mysql_upgrade\n" if (glob("$tmpdir/mysql_upgrade-*")); +print "No temporary files found\n"; +EOF + +let $MYSQLD_DATADIR= `select @@datadir`; +--remove_file $MYSQLD_DATADIR/mysql_upgrade_info +--echo End of 10.4 tests diff --git a/mysql-test/main/mysql_json_mysql_upgrade.result b/mysql-test/main/mysql_upgrade_mysql_json.result index 2b909594..2b909594 100644 --- a/mysql-test/main/mysql_json_mysql_upgrade.result +++ b/mysql-test/main/mysql_upgrade_mysql_json.result diff --git a/mysql-test/main/mysql_json_mysql_upgrade.test b/mysql-test/main/mysql_upgrade_mysql_json.test index 4380b004..4380b004 100644 --- a/mysql-test/main/mysql_json_mysql_upgrade.test +++ b/mysql-test/main/mysql_upgrade_mysql_json.test diff --git a/mysql-test/main/mysql_upgrade_mysql_json_system_tables.result b/mysql-test/main/mysql_upgrade_mysql_json_system_tables.result new file mode 100644 index 00000000..237b19c4 --- /dev/null +++ b/mysql-test/main/mysql_upgrade_mysql_json_system_tables.result @@ -0,0 +1,94 @@ +# +# MDEV-32462: mysql_upgrade -s still checks for non system tables +# +call mtr.add_suppression("Table rebuild required"); +SET NAMES utf8; +# mariadb_upgrade on system and user table +show tables from mysql like '%json%'; +Tables_in_mysql (%json%) +mysql_json_test +use mysql; +show create table mysql.mysql_json_test; +ERROR HY000: Unknown data type: 'MYSQL_JSON' +show create table test.mysql_json_test; +ERROR HY000: Unknown data type: 'MYSQL_JSON' +SET @old_general_log= @@global.general_log; +SET @old_log_output= @@global.log_output; +SET @@global.general_log = ON; +SET @@global.log_output = "TABLE"; +The --upgrade-system-tables option was used, user tables won't be touched. +Phase 1/8: 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.mysql_json_test +Error : Unknown data type: 'MYSQL_JSON' +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.mysql_json_test +Error : Unknown data type: 'MYSQL_JSON' +error : Corrupt +mysql.transaction_registry +Error : Unknown storage engine 'InnoDB' +error : Corrupt +Phase 2/8: Installing used storage engines... Skipped +Phase 3/8: Running 'mysql_fix_privilege_tables' +Phase 4/8: Fixing views... Skipped +Phase 5/8: Fixing table and database names ... Skipped +Phase 6/8: Checking and upgrading tables... Skipped +Phase 7/8: uninstalling plugins +Phase 8/8: Running 'FLUSH PRIVILEGES' +OK +SET @@global.general_log = @old_general_log; +SET @@global.log_output = @old_log_output; +select command_type, argument from mysql.general_log where argument like "%SELECT table_comment FROM information_schema.tables%"; +command_type argument +show create table mysql.mysql_json_test; +ERROR HY000: Unknown data type: 'MYSQL_JSON' +show create table test.mysql_json_test; +ERROR HY000: Unknown data type: 'MYSQL_JSON' +drop table mysql.mysql_json_test; +drop table test.mysql_json_test; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/mysql_upgrade_mysql_json_system_tables.test b/mysql-test/main/mysql_upgrade_mysql_json_system_tables.test new file mode 100644 index 00000000..6ae3e8dd --- /dev/null +++ b/mysql-test/main/mysql_upgrade_mysql_json_system_tables.test @@ -0,0 +1,52 @@ +--echo # +--echo # MDEV-32462: mysql_upgrade -s still checks for non system tables +--echo # + +# Let's now load plugin first +--source include/have_utf8.inc +--source include/not_embedded.inc + +--source include/mysql_upgrade_preparation.inc +call mtr.add_suppression("Table rebuild required"); + +SET NAMES utf8; + +let $MYSQLD_DATADIR= `select @@datadir`; + +--echo # mariadb_upgrade on system and user table +--copy_file std_data/mysql_json/mysql_json_test.frm $MYSQLD_DATADIR/mysql/mysql_json_test.frm +--copy_file std_data/mysql_json/mysql_json_test.MYI $MYSQLD_DATADIR/mysql/mysql_json_test.MYI +--copy_file std_data/mysql_json/mysql_json_test.MYD $MYSQLD_DATADIR/mysql/mysql_json_test.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 + +show tables from mysql like '%json%'; +use mysql; +--error ER_UNKNOWN_DATA_TYPE +show create table mysql.mysql_json_test; +--error ER_UNKNOWN_DATA_TYPE +show create table test.mysql_json_test; + +SET @old_general_log= @@global.general_log; +SET @old_log_output= @@global.log_output; +SET @@global.general_log = ON; +SET @@global.log_output = "TABLE"; +--exec $MYSQL_UPGRADE -s --force 2>&1 +--remove_file $MYSQLD_DATADIR/mysql_upgrade_info +SET @@global.general_log = @old_general_log; +SET @@global.log_output = @old_log_output; + +select command_type, argument from mysql.general_log where argument like "%SELECT table_comment FROM information_schema.tables%"; + +# User table is not upgraded in `mysql\test` DB, so we cannot see it. +--error ER_UNKNOWN_DATA_TYPE +show create table mysql.mysql_json_test; +--error ER_UNKNOWN_DATA_TYPE +show create table test.mysql_json_test; +drop table mysql.mysql_json_test; +drop table test.mysql_json_test; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/mysql_json_mysql_upgrade_with_plugin_loaded.result b/mysql-test/main/mysql_upgrade_mysql_json_with_plugin_loaded.result index 7bc2808a..7bc2808a 100644 --- a/mysql-test/main/mysql_json_mysql_upgrade_with_plugin_loaded.result +++ b/mysql-test/main/mysql_upgrade_mysql_json_with_plugin_loaded.result diff --git a/mysql-test/main/mysql_json_mysql_upgrade_with_plugin_loaded.test b/mysql-test/main/mysql_upgrade_mysql_json_with_plugin_loaded.test index f3e9c2e5..f3e9c2e5 100644 --- a/mysql-test/main/mysql_json_mysql_upgrade_with_plugin_loaded.test +++ b/mysql-test/main/mysql_upgrade_mysql_json_with_plugin_loaded.test diff --git a/mysql-test/main/mysqlbinlog_row_compressed.test b/mysql-test/main/mysqlbinlog_row_compressed.test index be973634..03868d3e 100644 --- a/mysql-test/main/mysqlbinlog_row_compressed.test +++ b/mysql-test/main/mysqlbinlog_row_compressed.test @@ -4,7 +4,7 @@ --source include/have_log_bin.inc --source include/have_binlog_format_row.inc ---source include/have_normal_bzip.inc +--source include/have_normal_zlib.inc # # diff --git a/mysql-test/main/mysqlbinlog_stmt_compressed.test b/mysql-test/main/mysqlbinlog_stmt_compressed.test index 08db2009..4a651243 100644 --- a/mysql-test/main/mysqlbinlog_stmt_compressed.test +++ b/mysql-test/main/mysqlbinlog_stmt_compressed.test @@ -4,7 +4,7 @@ --source include/have_log_bin.inc --source include/have_binlog_format_statement.inc ---source include/have_normal_bzip.inc +--source include/have_normal_zlib.inc # # # mysqlbinlog: compressed query event diff --git a/mysql-test/main/mysqld--help,win.rdiff b/mysql-test/main/mysqld--help,win.rdiff index 3e9541d7..a42c0c6f 100644 --- a/mysql-test/main/mysqld--help,win.rdiff +++ b/mysql-test/main/mysqld--help,win.rdiff @@ -1,4 +1,6 @@ -@@ -180,6 +180,7 @@ +--- main/mysqld--help.result 2023-11-30 02:21:51.951132200 +0100 ++++ main/mysqld--help,win.reject 2023-11-30 02:35:44.404612300 +0100 +@@ -191,6 +191,7 @@ --console Write error output on screen; don't remove the console window on windows. --core-file Write core on crashes @@ -6,7 +8,7 @@ -h, --datadir=name Path to the database root directory --date-format=name The DATE format (ignored) --datetime-format=name -@@ -650,6 +651,7 @@ +@@ -696,6 +697,7 @@ Use MySQL-5.6 (instead of MariaDB-5.3) format for TIME, DATETIME, TIMESTAMP columns. (Defaults to on; use --skip-mysql56-temporal-format to disable.) @@ -14,7 +16,7 @@ --net-buffer-length=# Buffer length for TCP/IP and socket communication --net-read-timeout=# -@@ -1327,6 +1328,10 @@ +@@ -1351,6 +1353,10 @@ Alias for log_slow_query_file. Log slow queries to given log file. Defaults logging to 'hostname'-slow.log. Must be enabled to activate other slow log options @@ -25,7 +27,7 @@ --socket=name Socket file to use for connection --sort-buffer-size=# Each thread that needs to do a sort allocates a buffer of -@@ -1351,6 +1356,7 @@ +@@ -1376,6 +1382,7 @@ 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.) @@ -33,7 +35,7 @@ --standard-compliant-cte Allow only CTEs compliant to SQL standard (Defaults to on; use --skip-standard-compliant-cte to disable.) -@@ -1426,6 +1432,11 @@ +@@ -1454,6 +1461,11 @@ --thread-pool-max-threads=# Maximum allowed number of worker threads in the thread pool @@ -45,7 +47,7 @@ --thread-pool-oversubscribe=# How many additional active worker threads in a group are allowed. -@@ -1464,8 +1475,8 @@ +@@ -1493,8 +1505,8 @@ automatically convert it to an on-disk MyISAM or Aria table. -t, --tmpdir=name Path for temporary files. Several paths may be specified, @@ -56,7 +58,7 @@ --transaction-alloc-block-size=# Allocation block size for transactions to be stored in binary log -@@ -1685,6 +1696,7 @@ +@@ -1716,6 +1728,7 @@ myisam-stats-method NULLS_UNEQUAL myisam-use-mmap FALSE mysql56-temporal-format TRUE @@ -64,7 +66,7 @@ net-buffer-length 16384 net-read-timeout 30 net-retry-count 10 -@@ -1841,6 +1853,7 @@ +@@ -1874,6 +1887,7 @@ slave-type-conversions slow-launch-time 2 slow-query-log FALSE @@ -72,7 +74,7 @@ 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 -@@ -1867,6 +1880,8 @@ +@@ -1901,6 +1915,8 @@ thread-pool-exact-stats FALSE thread-pool-idle-timeout 60 thread-pool-max-threads 65536 diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result index d271f1a3..2a3a9f00 100644 --- a/mysql-test/main/mysqld--help.result +++ b/mysql-test/main/mysqld--help.result @@ -565,9 +565,8 @@ The following specify which files/extra groups are read (specified before remain when binary log is disabled). --log-tc-size=# Size of transaction coordinator log. -W, --log-warnings[=#] - Log some not critical warnings to the general log - file.Value can be between 0 and 11. Higher values mean - more verbosity + Log some non critical warnings to the error log.Value can + be between 0 and 11. Higher values mean more verbosity --long-query-time=# Alias for log_slow_query_time. Log all queries that have taken more than long_query_time seconds to execute to the slow query log file. The argument will be treated as a @@ -721,7 +720,8 @@ The following specify which files/extra groups are read (specified before remain MySQL versions. Any combination of: NO_DUP_KEY_WARNINGS_WITH_IGNORE, NO_PROGRESS_INFO, ZERO_DATE_TIME_CAST, UTF8_IS_UTF8MB3, - IGNORE_INDEX_ONLY_FOR_JOIN, COMPAT_5_1_CHECKSUM + IGNORE_INDEX_ONLY_FOR_JOIN, COMPAT_5_1_CHECKSUM, + NO_NULL_COLLATION_IDS Use 'ALL' to set all combinations. --old-passwords Use old password encryption method (needed for 4.0 and older clients) @@ -736,6 +736,13 @@ 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-adjust-secondary-key-costs=# + 0 = No changes. 1 = Update secondary key costs for ranges + to be at least 5x of clustered primary key costs. 2 = + Remove 'max_seek optimization' for secondary keys and + slight adjustment of filter cost. This option will be + deleted in MariaDB 11.0 as it is not needed with the new + 11.0 optimizer. --optimizer-extra-pruning-depth=# If the optimizer needs to enumerate join prefix of this size or larger, then it will try aggressively prune away @@ -1167,7 +1174,7 @@ The following specify which files/extra groups are read (specified before remain The tracing level for semi-sync replication. --rpl-semi-sync-master-wait-no-slave Wait until timeout when no semi-synchronous replication - slave available (enabled by default). + slave is available. (Defaults to on; use --skip-rpl-semi-sync-master-wait-no-slave to disable.) --rpl-semi-sync-master-wait-point=name Should transaction wait for semi-sync ack after having @@ -1725,6 +1732,7 @@ old-alter-table DEFAULT old-mode UTF8_IS_UTF8MB3 old-passwords FALSE old-style-user-limits FALSE +optimizer-adjust-secondary-key-costs 0 optimizer-extra-pruning-depth 8 optimizer-max-sel-arg-weight 32000 optimizer-max-sel-args 16000 diff --git a/mysql-test/main/old-mode.result b/mysql-test/main/old-mode.result index daa2a4dc..cb87c45a 100644 --- a/mysql-test/main/old-mode.result +++ b/mysql-test/main/old-mode.result @@ -257,3 +257,13 @@ Warning 1264 Out of range value for column 'a' at row 2 DROP TABLE t1; SET @@time_zone=DEFAULT; SET TIMESTAMP=DEFAULT; +# +# MDEV-31608 - Connector/NET fails to connect since 10.10 +# +select count(*) > 0 from information_schema.collations where id IS NULL; +count(*) > 0 +1 +SET old_mode=no_null_collation_ids; +select count(*) > 0 from information_schema.collations where id IS NULL; +count(*) > 0 +0 diff --git a/mysql-test/main/old-mode.test b/mysql-test/main/old-mode.test index e4928329..177e00ed 100644 --- a/mysql-test/main/old-mode.test +++ b/mysql-test/main/old-mode.test @@ -169,3 +169,11 @@ DROP TABLE t1; SET @@time_zone=DEFAULT; SET TIMESTAMP=DEFAULT; + +--echo # +--echo # MDEV-31608 - Connector/NET fails to connect since 10.10 +--echo # +select count(*) > 0 from information_schema.collations where id IS NULL; +SET old_mode=no_null_collation_ids; +select count(*) > 0 from information_schema.collations where id IS NULL; + diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result index 43989025..aeaff29a 100644 --- a/mysql-test/main/opt_trace.result +++ b/mysql-test/main/opt_trace.result @@ -10746,6 +10746,18 @@ json_detailed(json_extract(trace, '$**.in_to_subquery_conversion')) set in_predicate_conversion_threshold=@tmp; drop table t0; # +# MDEV-29298: INSERT ... SELECT Does not produce an optimizer trace +# +create table t1 (a int, b int); +create table t2 (a int, b int); +insert into t1 values (1,1), (2,2), (3,3), (4,4), (5,5); +set optimizer_trace=1; +insert into t2 select * from t1 where a<= b and a>4; +select QUERY, LENGTH(trace)>1 from information_schema.optimizer_trace; +QUERY LENGTH(trace)>1 +insert into t2 select * from t1 where a<= b and a>4 1 +drop table t1, t2; +# # End of 10.5 tests # # diff --git a/mysql-test/main/opt_trace.test b/mysql-test/main/opt_trace.test index 29b72fcd..7b0ee5be 100644 --- a/mysql-test/main/opt_trace.test +++ b/mysql-test/main/opt_trace.test @@ -875,6 +875,20 @@ drop table t0; --enable_view_protocol --echo # +--echo # MDEV-29298: INSERT ... SELECT Does not produce an optimizer trace +--echo # +create table t1 (a int, b int); +create table t2 (a int, b int); +insert into t1 values (1,1), (2,2), (3,3), (4,4), (5,5); +set optimizer_trace=1; + +insert into t2 select * from t1 where a<= b and a>4; + +select QUERY, LENGTH(trace)>1 from information_schema.optimizer_trace; + +drop table t1, t2; + +--echo # --echo # End of 10.5 tests --echo # diff --git a/mysql-test/main/order_by.result b/mysql-test/main/order_by.result index bc65f67f..9d587c06 100644 --- a/mysql-test/main/order_by.result +++ b/mysql-test/main/order_by.result @@ -3733,6 +3733,126 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.t2.b 1 Using where DROP TABLE t1,t2; +# +# MDEV-29681 Server crashes when optimizing SQL with ORDER BY +# +CREATE TABLE t1 (b INT); +CREATE TABLE t2 (a INT, c INT); +# First test empty tables +EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b LIMIT 3) ORDER BY a+1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY <derived2> system NULL NULL NULL NULL 0 0.00 Const row not found +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `b`,NULL AS `a`,NULL AS `c` from ((/* select#2 */ select NULL AS `b`,NULL AS `a`,NULL AS `c` from `test`.`t1` join `test`.`t2` where 0 limit 3)) `__2` order by NULL + 1 +EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b LIMIT 3) ORDER BY a=2; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY <derived2> system NULL NULL NULL NULL 0 0.00 Const row not found +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `b`,NULL AS `a`,NULL AS `c` from ((/* select#2 */ select NULL AS `b`,NULL AS `a`,NULL AS `c` from `test`.`t1` join `test`.`t2` where 0 limit 3)) `__2` order by NULL = 2 +EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b LIMIT 3) +ORDER BY a+1, a-b DESC, c<>a; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY <derived2> system NULL NULL NULL NULL 0 0.00 Const row not found +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `b`,NULL AS `a`,NULL AS `c` from ((/* select#2 */ select NULL AS `b`,NULL AS `a`,NULL AS `c` from `test`.`t1` join `test`.`t2` where 0 limit 3)) `__2` order by NULL + 1,NULL - NULL desc,NULL <> NULL +# Insert some data +INSERT INTO t1 VALUES (1),(2),(3),(4); +INSERT INTO t2 VALUES (1,1),(2,2),(3,3),(4,4); +(SELECT * FROM t1 JOIN t2 ON a=b LIMIT 3) ORDER BY a=b, a-10 DESC, b+a, c+a+a+b; +b a c +1 1 1 +2 2 2 +3 3 3 +(SELECT * FROM t1 JOIN t2 ON a=b LIMIT 3) ORDER BY a=2; +b a c +1 1 1 +2 2 2 +3 3 3 +EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b LIMIT 3) +ORDER BY a=b, a-10, b+a, c+a+a+b; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 100.00 Using filesort +2 DERIVED t1 ALL NULL NULL NULL NULL 4 100.00 +2 DERIVED t2 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join) +Warnings: +Note 1003 /* select#1 */ select `__2`.`b` AS `b`,`__2`.`a` AS `a`,`__2`.`c` AS `c` from ((/* select#2 */ select `test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`b` limit 3)) `__2` order by `__2`.`a` = `__2`.`b`,`__2`.`a` - 10,`__2`.`b` + `__2`.`a`,`__2`.`c` + `__2`.`a` + `__2`.`a` + `__2`.`b` +# When there is no LIMIT clause the derived table must be merged +(SELECT * FROM t1 JOIN t2 ON a=b) ORDER BY a+16, b+a, c<>b; +b a c +1 1 1 +2 2 2 +3 3 3 +4 4 4 +EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b) ORDER BY a+16 DESC, b+a, c<>b; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00 Using temporary; Using filesort +1 SIMPLE t2 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join) +Warnings: +Note 1003 (select `test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`b` order by `test`.`t2`.`a` + 16 desc,`test`.`t1`.`b` + `test`.`t2`.`a`,`test`.`t2`.`c` <> `test`.`t1`.`b`) +# Test UNIONs: +(SELECT * FROM t1 JOIN t2 ON a=b UNION +SELECT * FROM t1 JOIN t2 ON a!=b +LIMIT 3) +ORDER BY a+16, b+a, c<>b; +b a c +1 1 1 +2 2 2 +3 3 3 +EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b UNION +SELECT * FROM t1 JOIN t2 ON a!=b +LIMIT 3) +ORDER BY a+16, b+a, c<>b; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 32 100.00 Using filesort +2 DERIVED t1 ALL NULL NULL NULL NULL 4 100.00 +2 DERIVED t2 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join) +3 UNION t1 ALL NULL NULL NULL NULL 4 100.00 +3 UNION t2 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join) +NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `__3`.`b` AS `b`,`__3`.`a` AS `a`,`__3`.`c` AS `c` from (/* select#2 */ select `test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`b` union /* select#3 */ select `test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`a` <> `test`.`t1`.`b` limit 3) `__3` order by `__3`.`a` + 16,`__3`.`b` + `__3`.`a`,`__3`.`c` <> `__3`.`b` +(SELECT * FROM t1 JOIN t2 ON a=b UNION +SELECT NULL, NULL, NULL +LIMIT 3) +ORDER BY b-a-c; +b a c +1 1 1 +2 2 2 +3 3 3 +EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b UNION +SELECT NULL, NULL, NULL +LIMIT 3) +ORDER BY b-a-c; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 16 100.00 Using filesort +2 DERIVED t1 ALL NULL NULL NULL NULL 4 100.00 +2 DERIVED t2 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join) +3 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `__3`.`b` AS `b`,`__3`.`a` AS `a`,`__3`.`c` AS `c` from (/* select#2 */ select `test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`b` union /* select#3 */ select NULL AS `NULL`,NULL AS `NULL`,NULL AS `NULL` limit 3) `__3` order by `__3`.`b` - `__3`.`a` - `__3`.`c` +(SELECT * FROM t1 JOIN t2 ON a=b UNION +SELECT NULL, NULL, NULL +ORDER BY a LIMIT 3) +ORDER BY b-a-c LIMIT 1; +b a c +NULL NULL NULL +EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b UNION +SELECT NULL, NULL, NULL +ORDER BY a LIMIT 3) +ORDER BY b-a-c LIMIT 1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 16 100.00 Using filesort +2 DERIVED t1 ALL NULL NULL NULL NULL 4 100.00 +2 DERIVED t2 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join) +3 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Using filesort +Warnings: +Note 1003 /* select#1 */ select `__3`.`b` AS `b`,`__3`.`a` AS `a`,`__3`.`c` AS `c` from (/* select#2 */ select `test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`b` union /* select#3 */ select NULL AS `NULL`,NULL AS `NULL`,NULL AS `NULL` order by `a` limit 3) `__3` order by `__3`.`b` - `__3`.`a` - `__3`.`c` limit 1 +DROP TABLE t1, t2; # End of 10.4 tests # # MDEV-21655: Server crashes in my_qsort2 / Filesort_buffer::sort_buffer diff --git a/mysql-test/main/order_by.test b/mysql-test/main/order_by.test index f6df090c..14e50cb2 100644 --- a/mysql-test/main/order_by.test +++ b/mysql-test/main/order_by.test @@ -2462,6 +2462,65 @@ EXPLAIN SELECT (SELECT 1 FROM t1 WHERE t1.a=t2.b ORDER BY t1.b LIMIT 1) AS c FRO DROP TABLE t1,t2; +--echo # +--echo # MDEV-29681 Server crashes when optimizing SQL with ORDER BY +--echo # +CREATE TABLE t1 (b INT); +CREATE TABLE t2 (a INT, c INT); + +--echo # First test empty tables +EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b LIMIT 3) ORDER BY a+1; +EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b LIMIT 3) ORDER BY a=2; +EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b LIMIT 3) + ORDER BY a+1, a-b DESC, c<>a; + +--echo # Insert some data +INSERT INTO t1 VALUES (1),(2),(3),(4); +INSERT INTO t2 VALUES (1,1),(2,2),(3,3),(4,4); + +--sorted_result +(SELECT * FROM t1 JOIN t2 ON a=b LIMIT 3) ORDER BY a=b, a-10 DESC, b+a, c+a+a+b; +--sorted_result +(SELECT * FROM t1 JOIN t2 ON a=b LIMIT 3) ORDER BY a=2; + +EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b LIMIT 3) + ORDER BY a=b, a-10, b+a, c+a+a+b; + +--echo # When there is no LIMIT clause the derived table must be merged +--sorted_result +(SELECT * FROM t1 JOIN t2 ON a=b) ORDER BY a+16, b+a, c<>b; +EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b) ORDER BY a+16 DESC, b+a, c<>b; + +--echo # Test UNIONs: +--sorted_result +(SELECT * FROM t1 JOIN t2 ON a=b UNION + SELECT * FROM t1 JOIN t2 ON a!=b + LIMIT 3) + ORDER BY a+16, b+a, c<>b; +EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b UNION + SELECT * FROM t1 JOIN t2 ON a!=b + LIMIT 3) + ORDER BY a+16, b+a, c<>b; +--sorted_result +(SELECT * FROM t1 JOIN t2 ON a=b UNION + SELECT NULL, NULL, NULL + LIMIT 3) + ORDER BY b-a-c; +EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b UNION + SELECT NULL, NULL, NULL + LIMIT 3) + ORDER BY b-a-c; +--sorted_result +(SELECT * FROM t1 JOIN t2 ON a=b UNION + SELECT NULL, NULL, NULL + ORDER BY a LIMIT 3) + ORDER BY b-a-c LIMIT 1; +EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b UNION + SELECT NULL, NULL, NULL + ORDER BY a LIMIT 3) + ORDER BY b-a-c LIMIT 1; +DROP TABLE t1, t2; + --echo # End of 10.4 tests --echo # diff --git a/mysql-test/main/parser.result b/mysql-test/main/parser.result index 89732e20..bf9b8e4b 100644 --- a/mysql-test/main/parser.result +++ b/mysql-test/main/parser.result @@ -1507,7 +1507,7 @@ BEGIN NOT ATOMIC DECLARE history INT; SET history=10; SELECT history; END SELECT history FROM t1 SELECT history 'alias' FROM t1 SELECT history() -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 '()' at line 1 +Error 1630 FUNCTION test.history does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT history.history() Error 1630 FUNCTION history.history does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT history DATE FROM t1 @@ -1530,7 +1530,7 @@ BEGIN NOT ATOMIC DECLARE next INT; SET next=10; SELECT next; END SELECT next FROM t1 SELECT next 'alias' FROM t1 SELECT next() -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 '()' at line 1 +Error 1630 FUNCTION test.next does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT next.next() Error 1630 FUNCTION next.next does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT next DATE FROM t1 @@ -1577,7 +1577,7 @@ BEGIN NOT ATOMIC DECLARE previous INT; SET previous=10; SELECT previous; END SELECT previous FROM t1 SELECT previous 'alias' FROM t1 SELECT previous() -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 '()' at line 1 +Error 1630 FUNCTION test.previous does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT previous.previous() Error 1630 FUNCTION previous.previous does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT previous DATE FROM t1 @@ -1601,7 +1601,7 @@ BEGIN NOT ATOMIC DECLARE system INT; SET system=10; SELECT system; END SELECT system FROM t1 SELECT system 'alias' FROM t1 SELECT system() -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 '()' at line 1 +Error 1630 FUNCTION test.system does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT system.system() Error 1630 FUNCTION system.system does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT system DATE FROM t1 @@ -1624,7 +1624,7 @@ BEGIN NOT ATOMIC DECLARE system_time INT; SET system_time=10; SELECT system_time SELECT system_time FROM t1 SELECT system_time 'alias' FROM t1 SELECT system_time() -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 '()' at line 1 +Error 1630 FUNCTION test.system_time does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT system_time.system_time() Error 1630 FUNCTION system_time.system_time does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT system_time DATE FROM t1 @@ -1695,7 +1695,7 @@ BEGIN NOT ATOMIC DECLARE transaction INT; SET transaction=10; SELECT transaction SELECT transaction FROM t1 SELECT transaction 'alias' FROM t1 SELECT transaction() -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 '()' at line 1 +Error 1630 FUNCTION test.transaction does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT transaction.transaction() Error 1630 FUNCTION transaction.transaction does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT transaction DATE FROM t1 @@ -1741,7 +1741,7 @@ BEGIN NOT ATOMIC DECLARE versioning INT; SET versioning=10; SELECT versioning; E SELECT versioning FROM t1 SELECT versioning 'alias' FROM t1 SELECT versioning() -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 '()' at line 1 +Error 1630 FUNCTION test.versioning does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT versioning.versioning() Error 1630 FUNCTION versioning.versioning does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT versioning DATE FROM t1 @@ -1764,7 +1764,7 @@ BEGIN NOT ATOMIC DECLARE without INT; SET without=10; SELECT without; END SELECT without FROM t1 SELECT without 'alias' FROM t1 SELECT without() -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 '()' at line 1 +Error 1630 FUNCTION test.without does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT without.without() Error 1630 FUNCTION without.without does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT without DATE FROM t1 diff --git a/mysql-test/main/partition_innodb.result b/mysql-test/main/partition_innodb.result index 95ca989e..cbaec550 100644 --- a/mysql-test/main/partition_innodb.result +++ b/mysql-test/main/partition_innodb.result @@ -198,6 +198,10 @@ INSERT INTO t1 VALUES (100); ERROR HY000: Table has no partition for value 100 insert INTO t1 VALUES (110); ERROR HY000: Table has no partition for value 110 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 90; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables @@ -401,7 +405,7 @@ t1 InnoDB 10 Dynamic 2 8192 16384 0 0 0 NULL Create_time NULL NULL latin1_swedis insert into t1 values (0), (1), (2), (3); show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary -t1 InnoDB 10 Dynamic 4 4096 16384 0 0 0 NULL Create_time Update_time NULL latin1_swedish_ci NULL partitioned 0 N +t1 InnoDB 10 Dynamic Rows Avg_row_length 16384 0 0 0 NULL Create_time Update_time NULL latin1_swedish_ci NULL partitioned 0 N drop table t1; create table t1 (a int auto_increment primary key) engine = innodb @@ -412,11 +416,11 @@ t1 InnoDB 10 Dynamic 2 8192 16384 0 0 0 1 Create_time NULL NULL latin1_swedish_c insert into t1 values (NULL), (NULL), (NULL), (NULL); show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary -t1 InnoDB 10 Dynamic 4 4096 16384 0 0 0 5 Create_time Update_time NULL latin1_swedish_ci NULL partitioned 0 N +t1 InnoDB 10 Dynamic Rows Avg_row_length 16384 0 0 0 5 Create_time Update_time NULL latin1_swedish_ci NULL partitioned 0 N insert into t1 values (NULL), (NULL), (NULL), (NULL); show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary -t1 InnoDB 10 Dynamic 8 2048 16384 0 0 0 9 Create_time Update_time NULL latin1_swedish_ci NULL partitioned 0 N +t1 InnoDB 10 Dynamic Rows Avg_row_length 16384 0 0 0 9 Create_time Update_time NULL latin1_swedish_ci NULL partitioned 0 N drop table t1; create table t1 (a int) partition by key (a) @@ -567,7 +571,7 @@ test.t1 optimize note Table does not support optimize, doing recreate + analyze test.t1 optimize error Invalid default value for 'b' test.t1 optimize status Operation failed Warnings: -Warning 1265 Data truncated for column 'b' at row 1 +Warning 1265 Data truncated for column 'b' at row 0 Error 1067 Invalid default value for 'b' SET SESSION sql_mode = @old_mode; DROP TABLE t1; diff --git a/mysql-test/main/partition_innodb.test b/mysql-test/main/partition_innodb.test index 563a750b..e9771811 100644 --- a/mysql-test/main/partition_innodb.test +++ b/mysql-test/main/partition_innodb.test @@ -208,6 +208,7 @@ INSERT INTO t1 VALUES (90); INSERT INTO t1 VALUES (100); --error ER_NO_PARTITION_FOR_GIVEN_VALUE insert INTO t1 VALUES (110); +ANALYZE TABLE t1; EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 90; EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 90; EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 90; @@ -420,7 +421,9 @@ partition by key (a); --replace_column 12 Create_time show table status; insert into t1 values (0), (1), (2), (3); ---replace_column 12 Create_time 13 Update_time +# Mask `Rows`, as it can fluctuate slightly if background statistics are +# running simultaneously with insert (MDEV-20169). +--replace_column 5 Rows 6 Avg_row_length 12 Create_time 13 Update_time show table status; drop table t1; @@ -430,10 +433,10 @@ partition by key (a); --replace_column 12 Create_time show table status; insert into t1 values (NULL), (NULL), (NULL), (NULL); ---replace_column 12 Create_time 13 Update_time +--replace_column 5 Rows 6 Avg_row_length 12 Create_time 13 Update_time show table status; insert into t1 values (NULL), (NULL), (NULL), (NULL); ---replace_column 12 Create_time 13 Update_time +--replace_column 5 Rows 6 Avg_row_length 12 Create_time 13 Update_time show table status; drop table t1; diff --git a/mysql-test/main/ps.result b/mysql-test/main/ps.result index a2aa76a7..7fd30f3e 100644 --- a/mysql-test/main/ps.result +++ b/mysql-test/main/ps.result @@ -5802,5 +5802,15 @@ END; $ ERROR 42000: EXECUTE..USING does not support subqueries or stored functions # +# MDEV-32965: Assertion `thd->active_stmt_arena_to_use()-> is_stmt_prepare_or_first_sp_execute() || thd->active_stmt_arena_to_use()-> is_conventional() || thd->active_stmt_arena_to_use()->state == Query_arena::STMT_SP_QUERY_ARGUMENTS' failed +# +CREATE TABLE t (f VARCHAR(8)) CHARACTER SET utf8; +INSERT INTO t VALUES ('foo'),('bar'); +EXECUTE IMMEDIATE 'SELECT GROUP_CONCAT(@x) FROM t GROUP BY @x := f'; +GROUP_CONCAT(@x) +0 +0 +DROP TABLE t; +# # End of 10.4 tests # diff --git a/mysql-test/main/ps.test b/mysql-test/main/ps.test index 0043d3aa..675c5102 100644 --- a/mysql-test/main/ps.test +++ b/mysql-test/main/ps.test @@ -5237,5 +5237,17 @@ $ delimiter ;$ --echo # +--echo # MDEV-32965: Assertion `thd->active_stmt_arena_to_use()-> is_stmt_prepare_or_first_sp_execute() || thd->active_stmt_arena_to_use()-> is_conventional() || thd->active_stmt_arena_to_use()->state == Query_arena::STMT_SP_QUERY_ARGUMENTS' failed +--echo # +CREATE TABLE t (f VARCHAR(8)) CHARACTER SET utf8; + +INSERT INTO t VALUES ('foo'),('bar'); +EXECUTE IMMEDIATE 'SELECT GROUP_CONCAT(@x) FROM t GROUP BY @x := f'; + +# Cleanup + +DROP TABLE t; + +--echo # --echo # End of 10.4 tests --echo # diff --git a/mysql-test/main/ps_mem_leaks.result b/mysql-test/main/ps_mem_leaks.result index 8d66a025..2ddf47a9 100644 --- a/mysql-test/main/ps_mem_leaks.result +++ b/mysql-test/main/ps_mem_leaks.result @@ -3,6 +3,20 @@ # CREATE TABLE t1 (a VARCHAR(10)) ENGINE=MYISAM; CREATE TABLE t2 (b VARCHAR(10) CHARACTER SET utf8) ENGINE=MYISAM; +INSERT INTO t1 VALUES ('b'), ('a'), ('c'); +INSERT INTO t2 VALUES ('c'), ('d'), ('b'); +PREPARE stmt FROM "SELECT t1.a FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2)"; +EXECUTE stmt; +a +c +b +EXECUTE stmt; +a +c +b +DEALLOCATE PREPARE stmt; +DELETE FROM t1; +DELETE FROM t2; INSERT INTO t1 VALUES ('b'); INSERT INTO t2 VALUES ('b'); PREPARE stmt FROM "SELECT t1.a FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2)"; @@ -14,3 +28,64 @@ a b DEALLOCATE PREPARE stmt; DROP TABLE t1, t2; +# +# MDEV-32569: Failure when executing PS for query using IN subquery +# +CREATE TABLE t1 (a varchar(10)) ENGINE=MYISAM; +CREATE TABLE t2 (b varchar(10) CHARACTER SET utf8) ENGINE=MYISAM; +INSERT INTO t1 VALUES ('b'); +INSERT INTO t2 VALUES ('b'); +PREPARE stmt FROM +"SELECT STRAIGHT_JOIN t1.a FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2)"; +EXECUTE stmt; +a +b +EXECUTE stmt; +a +b +DEALLOCATE PREPARE stmt; +DROP TABLE t1,t2; +# +# MDEV-32733: Two JSON related tests running in PS mode fail on server +# built with -DWITH_PROTECT_STATEMENT_MEMROOT=YES +# +PREPARE stmt FROM "select json_contains_path('{\"key1\":1}', 'oNE', '$.key2[1]') as exp"; +EXECUTE stmt; +exp +0 +EXECUTE stmt; +exp +0 +DEALLOCATE PREPARE stmt; +# +# MDEV-32466: Potential memory leak on execuing of create view statement +# +CREATE FUNCTION f1 () RETURNS VARCHAR(1) +BEGIN +DECLARE rec1 ROW TYPE OF v1; +SELECT z INTO rec1 FROM v1; +RETURN 1; +END| +CREATE FUNCTION f2 () RETURNS VARCHAR(1) RETURN '!'; +CREATE VIEW v1 AS SELECT f2() z; +PREPARE stmt FROM "SELECT f1()"; +EXECUTE stmt; +f1() +1 +EXECUTE stmt; +f1() +1 +DEALLOCATE PREPARE stmt; +DROP FUNCTION f1; +DROP VIEW v1; +DROP FUNCTION f2; +# +# MDEV-32867: ASAN errors in Item_func_json_contains_path::val_int upon PS execution +# +CREATE TABLE t1 (f BLOB) ENGINE=MyISAM; +PREPARE stmt FROM "SELECT * FROM t1 WHERE JSON_EXISTS(JSON_ARRAY('[true,1234567890]'), '$**.*') != JSON_CONTAINS_PATH(JSON_INSERT('{}', '$[1]', NULL), 'all', '$[1]')"; +EXECUTE stmt; +f +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of 10.4 tests diff --git a/mysql-test/main/ps_mem_leaks.test b/mysql-test/main/ps_mem_leaks.test index 2e357f94..dacb4eca 100644 --- a/mysql-test/main/ps_mem_leaks.test +++ b/mysql-test/main/ps_mem_leaks.test @@ -13,6 +13,19 @@ CREATE TABLE t1 (a VARCHAR(10)) ENGINE=MYISAM; CREATE TABLE t2 (b VARCHAR(10) CHARACTER SET utf8) ENGINE=MYISAM; +INSERT INTO t1 VALUES ('b'), ('a'), ('c'); +INSERT INTO t2 VALUES ('c'), ('d'), ('b'); + +PREPARE stmt FROM "SELECT t1.a FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2)"; + +EXECUTE stmt; +EXECUTE stmt; + +DEALLOCATE PREPARE stmt; + +DELETE FROM t1; +DELETE FROM t2; + INSERT INTO t1 VALUES ('b'); INSERT INTO t2 VALUES ('b'); @@ -25,3 +38,75 @@ DEALLOCATE PREPARE stmt; DROP TABLE t1, t2; +--echo # +--echo # MDEV-32569: Failure when executing PS for query using IN subquery +--echo # + +CREATE TABLE t1 (a varchar(10)) ENGINE=MYISAM; +CREATE TABLE t2 (b varchar(10) CHARACTER SET utf8) ENGINE=MYISAM; + +INSERT INTO t1 VALUES ('b'); +INSERT INTO t2 VALUES ('b'); + +PREPARE stmt FROM +"SELECT STRAIGHT_JOIN t1.a FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2)"; + +EXECUTE stmt; +EXECUTE stmt; + +DEALLOCATE PREPARE stmt; + +DROP TABLE t1,t2; + +--echo # +--echo # MDEV-32733: Two JSON related tests running in PS mode fail on server +--echo # built with -DWITH_PROTECT_STATEMENT_MEMROOT=YES +--echo # +PREPARE stmt FROM "select json_contains_path('{\"key1\":1}', 'oNE', '$.key2[1]') as exp"; + +EXECUTE stmt; +EXECUTE stmt; + +DEALLOCATE PREPARE stmt; + +--echo # +--echo # MDEV-32466: Potential memory leak on execuing of create view statement +--echo # + +--delimiter | + +CREATE FUNCTION f1 () RETURNS VARCHAR(1) +BEGIN + DECLARE rec1 ROW TYPE OF v1; + SELECT z INTO rec1 FROM v1; + RETURN 1; +END| +--delimiter ; + +CREATE FUNCTION f2 () RETURNS VARCHAR(1) RETURN '!'; +CREATE VIEW v1 AS SELECT f2() z; + +PREPARE stmt FROM "SELECT f1()"; +EXECUTE stmt; +EXECUTE stmt; + +DEALLOCATE PREPARE stmt; + +# Clean up +DROP FUNCTION f1; +DROP VIEW v1; +DROP FUNCTION f2; + +--echo # +--echo # MDEV-32867: ASAN errors in Item_func_json_contains_path::val_int upon PS execution +--echo # +CREATE TABLE t1 (f BLOB) ENGINE=MyISAM; + +PREPARE stmt FROM "SELECT * FROM t1 WHERE JSON_EXISTS(JSON_ARRAY('[true,1234567890]'), '$**.*') != JSON_CONTAINS_PATH(JSON_INSERT('{}', '$[1]', NULL), 'all', '$[1]')"; +EXECUTE stmt; + +# Clean up +DEALLOCATE PREPARE stmt; +DROP TABLE t1; + +--echo # End of 10.4 tests diff --git a/mysql-test/main/rpl_mysqldump_slave.result b/mysql-test/main/rpl_mysqldump_slave.result index 903b6711..9f93e3c4 100644 --- a/mysql-test/main/rpl_mysqldump_slave.result +++ b/mysql-test/main/rpl_mysqldump_slave.result @@ -65,4 +65,20 @@ SET GLOBAL gtid_slave_pos='0-2-1003'; -- CHANGE MASTER TO MASTER_LOG_FILE='slave-bin.000001', MASTER_LOG_POS=BINLOG_START; CHANGE MASTER TO MASTER_USE_GTID=slave_pos; SET GLOBAL gtid_slave_pos='0-2-1003'; +connection master; +CREATE TABLE t ( +id int +); +insert into t values (1); +insert into t values (2); +drop table t; +connection slave; +include/stop_slave.inc +change master to master_use_gtid=slave_pos; +connection master; +# Ensuring the binlog dump thread is killed on primary... +-- CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000002', MASTER_LOG_POS=BINLOG_START; +-- SET GLOBAL gtid_slave_pos='0-1-1005'; +connection slave; +include/start_slave.inc include/rpl_end.inc diff --git a/mysql-test/main/rpl_mysqldump_slave.test b/mysql-test/main/rpl_mysqldump_slave.test index 345bdb82..0273e196 100644 --- a/mysql-test/main/rpl_mysqldump_slave.test +++ b/mysql-test/main/rpl_mysqldump_slave.test @@ -83,6 +83,76 @@ DROP TABLE t2; --replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/ --exec $MYSQL_DUMP_SLAVE --compact --master-data --single-transaction --gtid test +# +# MDEV-32611 Added test for mysqldump --delete-master-logs option. +# This options is alias of +# get binlogs: show master status -> flush logs -> purge binary logs to <new_binlog> +# sequence and this test is derived using the same pattern. +# + +connection master; + +CREATE TABLE t ( + id int +); + +insert into t values (1); +insert into t values (2); +drop table t; + +--sync_slave_with_master + +# MDEV-32953: Because --delete-master-logs immediately purges logs after +# flushing, it is possible the binlog dump threads will still be using the old +# log when the purge executes, disallowing the file from being deleted. +# Therefore, we temporarily stop the slave so there is no chance the old binlog +# is still being referenced. master_use_gtid=Slave_pos is necessary to still +# appear up-to-date to the master on restart after the master has flushed the +# logs (while the slave is offline). Otherwise (i.e. if using binlog file/pos), +# the slave would point to a purged log file, and receive an error immediately +# upon connecting to the master. +--source include/stop_slave.inc +change master to master_use_gtid=slave_pos; + +connection master; + +--echo # Ensuring the binlog dump thread is killed on primary... +--disable_query_log +--let $binlog_dump_thd_tid= `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE COMMAND LIKE 'Binlog Dump'` +if ($binlog_dump_thd_tid) +{ + --eval kill $binlog_dump_thd_tid +} +--let $wait_condition= SELECT COUNT(*)=0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE COMMAND LIKE 'Binlog Dump' +--source include/wait_condition.inc +--enable_query_log + +--let $predump_binlog_filename= query_get_value(SHOW MASTER STATUS, File, 1) + +# Execute mysqldump with delete-master-logs option +--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/ +--exec $MYSQL_DUMP --compact --no-create-info --no-data --delete-master-logs test + +--let $postdump_binlog_filename= query_get_value(SHOW MASTER STATUS, File, 1) + +--let $postdump_first_binary_log_filename= query_get_value(SHOW BINARY LOGS, Log_name, 1) + +if ($predump_binlog_filename == $postdump_binlog_filename) +{ + --echo # predump_binlog_filename: $predump_binlog_filename + --echo # postdump_binlog_filename: $postdump_binlog_filename + --die Master state didn't change after mariadb-dump with --delete-master-logs. +} + +if ($postdump_first_binary_log_filename != $postdump_binlog_filename) +{ + --echo # postdump_first_binary_log_filename: $postdump_first_binary_log_filename + --echo # postdump_binlog_filename: $postdump_binlog_filename + --die Master binlog wasn't deleted after mariadb-dump with --delete-master-logs. +} + +connection slave; +--source include/start_slave.inc --source include/rpl_end.inc diff --git a/mysql-test/main/secondary_key_costs.result b/mysql-test/main/secondary_key_costs.result new file mode 100644 index 00000000..55c84705 --- /dev/null +++ b/mysql-test/main/secondary_key_costs.result @@ -0,0 +1,82 @@ +create table t1 ( +pk int primary key auto_increment, +nm varchar(32), +fl1 tinyint default 0, +fl2 tinyint default 0, +index idx1(nm, fl1), +index idx2(fl2) +) engine=myisam; +create table name ( +pk int primary key auto_increment, +nm bigint +) engine=myisam; +create table flag2 ( +pk int primary key auto_increment, +fl2 tinyint +) engine=myisam; +insert into name(nm) select seq from seq_1_to_1000 order by rand(17); +insert into flag2(fl2) select seq mod 2 from seq_1_to_1000 order by rand(19); +insert into t1(nm,fl2) +select nm, fl2 from name, flag2 where name.pk = flag2.pk; +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status Table is already up to date +set optimizer_trace="enabled=on"; +set optimizer_switch='rowid_filter=on'; +set statement optimizer_adjust_secondary_key_costs=0 for +explain select * from t1 where nm like '500%' AND fl2 = 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range idx1,idx2 idx1 35 NULL 1 Using index condition; Using where +set @trace=(select trace from information_schema.optimizer_trace); +select json_detailed(json_extract(@trace, '$**.considered_access_paths')); +json_detailed(json_extract(@trace, '$**.considered_access_paths')) +[ + [ + { + "access_type": "ref", + "index": "idx2", + "used_range_estimates": true, + "rowid_filter_skipped": "worst/max seeks clipping", + "rows": 492, + "cost": 492.3171406, + "chosen": true + }, + { + "access_type": "range", + "resulting_rows": 0.492, + "cost": 1.448699097, + "chosen": true + } + ] +] + +The following trace should have a different rowid_filter_key cost + +set statement optimizer_adjust_secondary_key_costs=2 for +explain select * from t1 where nm like '500%' AND fl2 = 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range idx1,idx2 idx1 35 NULL 1 Using index condition; Using where +set @trace=(select trace from information_schema.optimizer_trace); +select json_detailed(json_extract(@trace, '$**.considered_access_paths')); +json_detailed(json_extract(@trace, '$**.considered_access_paths')) +[ + [ + { + "access_type": "ref", + "index": "idx2", + "used_range_estimates": true, + "rowid_filter_key": "idx1", + "rows": 492, + "cost": 3.814364688, + "chosen": true + }, + { + "access_type": "range", + "resulting_rows": 0.492, + "cost": 1.448699097, + "chosen": true + } + ] +] +drop table t1, name, flag2; diff --git a/mysql-test/main/secondary_key_costs.test b/mysql-test/main/secondary_key_costs.test new file mode 100644 index 00000000..d3db1376 --- /dev/null +++ b/mysql-test/main/secondary_key_costs.test @@ -0,0 +1,53 @@ +--source include/have_sequence.inc +--source include/not_embedded.inc + +# +# Show the costs for rowid filter +# + +create table t1 ( + pk int primary key auto_increment, + nm varchar(32), + fl1 tinyint default 0, + fl2 tinyint default 0, + index idx1(nm, fl1), + index idx2(fl2) +) engine=myisam; + +create table name ( + pk int primary key auto_increment, + nm bigint +) engine=myisam; + +create table flag2 ( + pk int primary key auto_increment, + fl2 tinyint +) engine=myisam; + +insert into name(nm) select seq from seq_1_to_1000 order by rand(17); +insert into flag2(fl2) select seq mod 2 from seq_1_to_1000 order by rand(19); + +insert into t1(nm,fl2) + select nm, fl2 from name, flag2 where name.pk = flag2.pk; + +analyze table t1 persistent for all; + +--disable_ps_protocol +set optimizer_trace="enabled=on"; +set optimizer_switch='rowid_filter=on'; +set statement optimizer_adjust_secondary_key_costs=0 for +explain select * from t1 where nm like '500%' AND fl2 = 0; +set @trace=(select trace from information_schema.optimizer_trace); +select json_detailed(json_extract(@trace, '$**.considered_access_paths')); + +--echo +--echo The following trace should have a different rowid_filter_key cost +--echo +set statement optimizer_adjust_secondary_key_costs=2 for +explain select * from t1 where nm like '500%' AND fl2 = 0; +set @trace=(select trace from information_schema.optimizer_trace); +select json_detailed(json_extract(@trace, '$**.considered_access_paths')); + +--enable_ps_protocol + +drop table t1, name, flag2; diff --git a/mysql-test/main/set_password.result b/mysql-test/main/set_password.result index a3d8683e..19ca628f 100644 --- a/mysql-test/main/set_password.result +++ b/mysql-test/main/set_password.result @@ -1,4 +1,6 @@ set global secure_auth=0; +Warnings: +Warning 1287 '@@secure_auth' is deprecated and will be removed in a future release create user natauth@localhost identified via 'mysql_native_password' using '*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29'; create user invalidauth@localhost identified via 'mysql_native_password' using 'invalid'; create user newpass@localhost identified by password '*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29'; @@ -186,6 +188,8 @@ drop user natauth@localhost, newpass@localhost, newpassnat@localhost; drop user invalidauth@localhost, invalidpass@localhost, invalidpassnat@localhost,invalidmysql57auth@localhost; drop user oldauth@localhost, oldpass@localhost, oldpassold@localhost; set global secure_auth=default; +Warnings: +Warning 1287 '@@secure_auth' is deprecated and will be removed in a future release # switching from mysql.global_priv to mysql.user create user foo@localhost identified with mysql_native_password; update mysql.user set authentication_string=password('foo'), plugin='mysql_native_password' where user='foo' and host='localhost'; diff --git a/mysql-test/main/show_check.result b/mysql-test/main/show_check.result index 5058f6d6..30637e12 100644 --- a/mysql-test/main/show_check.result +++ b/mysql-test/main/show_check.result @@ -104,19 +104,19 @@ drop table t1; show variables like "wait_timeout%"; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr def information_schema SESSION_VARIABLES SESSION_VARIABLES VARIABLE_NAME Variable_name 253 64 12 N 4097 0 8 -def information_schema SESSION_VARIABLES SESSION_VARIABLES VARIABLE_VALUE Value 253 2048 5 N 4097 0 8 +def information_schema SESSION_VARIABLES SESSION_VARIABLES VARIABLE_VALUE Value 253 4096 5 N 4097 0 8 Variable_name Value wait_timeout 28800 show variables like "WAIT_timeout%"; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr def information_schema SESSION_VARIABLES SESSION_VARIABLES VARIABLE_NAME Variable_name 253 64 12 N 4097 0 8 -def information_schema SESSION_VARIABLES SESSION_VARIABLES VARIABLE_VALUE Value 253 2048 5 N 4097 0 8 +def information_schema SESSION_VARIABLES SESSION_VARIABLES VARIABLE_VALUE Value 253 4096 5 N 4097 0 8 Variable_name Value wait_timeout 28800 show variables like "this_doesn't_exists%"; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr def information_schema SESSION_VARIABLES SESSION_VARIABLES VARIABLE_NAME Variable_name 253 64 0 N 4097 0 8 -def information_schema SESSION_VARIABLES SESSION_VARIABLES VARIABLE_VALUE Value 253 2048 0 N 4097 0 8 +def information_schema SESSION_VARIABLES SESSION_VARIABLES VARIABLE_VALUE Value 253 4096 0 N 4097 0 8 Variable_name Value show table status from test like "this_doesn't_exists%"; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr diff --git a/mysql-test/main/show_explain.result b/mysql-test/main/show_explain.result index 6bdc773a..22ac7de6 100644 --- a/mysql-test/main/show_explain.result +++ b/mysql-test/main/show_explain.result @@ -244,9 +244,7 @@ set @foo= (select max(a) from t0 where sin(a) >0); connection default; show explain for $thr2; ERROR HY000: Target is not executing an operation with a query plan -kill query $thr2; connection con1; -ERROR 70100: Query execution was interrupted SET debug_dbug=@old_debug; # # Attempt SHOW EXPLAIN for an UPDATE @@ -568,9 +566,14 @@ SELECT * FROM v1, t2; connection default; show explain for $thr2; ERROR HY000: Target is not executing an operation with a query plan -kill query $thr2; connection con1; -ERROR 70100: Query execution was interrupted +a b +8 4 +8 5 +8 6 +8 7 +8 8 +8 9 SET debug_dbug=@old_debug; DROP VIEW v1; DROP TABLE t2, t3; diff --git a/mysql-test/main/show_explain.test b/mysql-test/main/show_explain.test index e6cf3971..749c08b1 100644 --- a/mysql-test/main/show_explain.test +++ b/mysql-test/main/show_explain.test @@ -273,9 +273,7 @@ connection default; --source include/wait_condition.inc --error ER_TARGET_NOT_EXPLAINABLE evalp show explain for $thr2; -evalp kill query $thr2; connection con1; ---error ER_QUERY_INTERRUPTED reap; SET debug_dbug=@old_debug; @@ -504,9 +502,7 @@ connection default; --source include/wait_condition.inc --error ER_TARGET_NOT_EXPLAINABLE evalp show explain for $thr2; -evalp kill query $thr2; connection con1; ---error ER_QUERY_INTERRUPTED reap; SET debug_dbug=@old_debug; DROP VIEW v1; diff --git a/mysql-test/main/sp.result b/mysql-test/main/sp.result index 670a039b..522c2ced 100644 --- a/mysql-test/main/sp.result +++ b/mysql-test/main/sp.result @@ -8955,6 +8955,21 @@ DROP FUNCTION f1; DROP FUNCTION f2; DROP FUNCTION f3; DROP VIEW v1; +# +# MDEV-33270: Call of SP invoking another SP with a parameter +# requiring type conversion +# +SET NAMES latin1; +CREATE PROCEDURE p1 (a text) BEGIN SELECT a; END | +CREATE PROCEDURE p2 () CALL p1(concat('x',_utf8'x')) | +CALL p2(); +a +xx +CALL p2(); +a +xx +DROP PROCEDURE p1; +DROP PROCEDURE p2; # End of 10.4 tests # # @@ -9008,6 +9023,79 @@ BEGIN NOT ATOMIC DECLARE r ROW TYPE OF t1 DEFAULT (SELECT * FROM t1); SELECT r.a r.a 1 SET SESSION log_slow_verbosity= @tmp; +# +# MDEV-31616 Problems with a stored function EMPTY() on upgrade to 10.6. +# +CREATE OR REPLACE FUNCTION empty(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +Warnings: +Note 1585 This function 'empty' has the same name as a native function +SELECT empty('1'); +empty('1') +0 +Warnings: +Note 1585 This function 'empty' has the same name as a native function +DROP FUNCTION empty; +CREATE OR REPLACE FUNCTION json_table(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +Warnings: +Note 1585 This function 'json_table' has the same name as a native function +SELECT json_table('1'); +json_table('1') +0 +Warnings: +Note 1585 This function 'json_table' has the same name as a native function +DROP FUNCTION json_table; +CREATE OR REPLACE FUNCTION nested(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +Warnings: +Note 1585 This function 'nested' has the same name as a native function +SELECT nested('1'); +nested('1') +0 +Warnings: +Note 1585 This function 'nested' has the same name as a native function +DROP FUNCTION nested; +CREATE OR REPLACE FUNCTION ordinality(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +Warnings: +Note 1585 This function 'ordinality' has the same name as a native function +SELECT ordinality('1'); +ordinality('1') +0 +Warnings: +Note 1585 This function 'ordinality' has the same name as a native function +DROP FUNCTION ordinality; +CREATE OR REPLACE FUNCTION path(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +Warnings: +Note 1585 This function 'path' has the same name as a native function +SELECT path('1'); +path('1') +0 +Warnings: +Note 1585 This function 'path' has the same name as a native function +DROP FUNCTION path; +CREATE OR REPLACE FUNCTION fast(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +Warnings: +Note 1585 This function 'fast' has the same name as a native function +SELECT fast('1'); +fast('1') +0 +Warnings: +Note 1585 This function 'fast' has the same name as a native function +DROP FUNCTION fast; +CREATE OR REPLACE FUNCTION relay(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +Warnings: +Note 1585 This function 'relay' has the same name as a native function +SELECT relay('1'); +relay('1') +0 +Warnings: +Note 1585 This function 'relay' has the same name as a native function +DROP FUNCTION relay; +CREATE OR REPLACE FUNCTION database() RETURNS int RETURN 333; +Warnings: +Note 1585 This function 'database' has the same name as a native function +SELECT database(); +database() +test +DROP FUNCTION database; DROP TABLE t1; # # MDEV-28129: MariaDB UAF issue at lex_end_nops(LEX*) diff --git a/mysql-test/main/sp.test b/mysql-test/main/sp.test index 9d2ea3cf..4e9b4c78 100644 --- a/mysql-test/main/sp.test +++ b/mysql-test/main/sp.test @@ -10566,6 +10566,26 @@ DROP FUNCTION f2; DROP FUNCTION f3; DROP VIEW v1; +--echo # +--echo # MDEV-33270: Call of SP invoking another SP with a parameter +--echo # requiring type conversion +--echo # + +SET NAMES latin1; + +--delimiter | + +CREATE PROCEDURE p1 (a text) BEGIN SELECT a; END | +CREATE PROCEDURE p2 () CALL p1(concat('x',_utf8'x')) | + +--delimiter ; + +CALL p2(); +CALL p2(); + +DROP PROCEDURE p1; +DROP PROCEDURE p2; + --echo # End of 10.4 tests --echo # @@ -10618,6 +10638,44 @@ BEGIN NOT ATOMIC DECLARE r ROW TYPE OF t1 DEFAULT (SELECT * FROM t1); SELECT r.a --delimiter ; SET SESSION log_slow_verbosity= @tmp; + +--echo # +--echo # MDEV-31616 Problems with a stored function EMPTY() on upgrade to 10.6. +--echo # +CREATE OR REPLACE FUNCTION empty(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +SELECT empty('1'); +DROP FUNCTION empty; + +CREATE OR REPLACE FUNCTION json_table(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +SELECT json_table('1'); +DROP FUNCTION json_table; + +CREATE OR REPLACE FUNCTION nested(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +SELECT nested('1'); +DROP FUNCTION nested; + +CREATE OR REPLACE FUNCTION ordinality(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +SELECT ordinality('1'); +DROP FUNCTION ordinality; + +CREATE OR REPLACE FUNCTION path(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +SELECT path('1'); +DROP FUNCTION path; + + +CREATE OR REPLACE FUNCTION fast(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +SELECT fast('1'); +DROP FUNCTION fast; + +CREATE OR REPLACE FUNCTION relay(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +SELECT relay('1'); +DROP FUNCTION relay; + +CREATE OR REPLACE FUNCTION database() RETURNS int RETURN 333; +SELECT database(); +DROP FUNCTION database; + + # Cleanup DROP TABLE t1; diff --git a/mysql-test/main/sp_notembedded.result b/mysql-test/main/sp_notembedded.result index e0336159..927e03d2 100644 --- a/mysql-test/main/sp_notembedded.result +++ b/mysql-test/main/sp_notembedded.result @@ -1,7 +1,5 @@ set @old_concurrent_insert= @@global.concurrent_insert; set @@global.concurrent_insert= 0; -drop table if exists t1,t3; -drop procedure if exists bug4902| create procedure bug4902() begin show grants for 'root'@'localhost'; @@ -15,7 +13,6 @@ Grants for root@localhost GRANT ALL PRIVILEGES ON *.* TO `root`@`localhost` WITH GRANT OPTION GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION drop procedure bug4902| -drop procedure if exists bug4902_2| create procedure bug4902_2() begin show processlist; @@ -23,13 +20,10 @@ end| call bug4902_2()| show warnings| Level Code Message -Note 1305 PROCEDURE test.bug4902_2 does not exist call bug4902_2()| show warnings| Level Code Message -Note 1305 PROCEDURE test.bug4902_2 does not exist drop procedure bug4902_2| -drop procedure if exists bug6807| create procedure bug6807() begin declare a int; @@ -42,116 +36,6 @@ ERROR 70100: Query execution was interrupted call bug6807()| ERROR 70100: Query execution was interrupted drop procedure bug6807| -drop function if exists bug10100f| -drop procedure if exists bug10100p| -drop procedure if exists bug10100t| -drop procedure if exists bug10100pt| -drop procedure if exists bug10100pv| -drop procedure if exists bug10100pd| -drop procedure if exists bug10100pc| -create function bug10100f(prm int) returns int -begin -if prm > 1 then -return prm * bug10100f(prm - 1); -end if; -return 1; -end| -set statement sql_mode = '' for -create procedure bug10100p(prm int, inout res int) -begin -set res = res * prm; -if prm > 1 then -call bug10100p(prm - 1, res); -end if; -end| -set statement sql_mode = '' for -create procedure bug10100t(prm int) -begin -declare res int; -set res = 1; -call bug10100p(prm, res); -select res; -end| -create table t3 (a int)| -insert into t3 values (0)| -create view v1 as select a from t3| -create procedure bug10100pt(level int, lim int) -begin -if level < lim then -update t3 set a=level; -FLUSH TABLES; -call bug10100pt(level+1, lim); -else -select * from t3; -end if; -end| -create procedure bug10100pv(level int, lim int) -begin -if level < lim then -update v1 set a=level; -FLUSH TABLES; -call bug10100pv(level+1, lim); -else -select * from v1; -end if; -end| -prepare stmt2 from "select * from t3;"; -create procedure bug10100pd(level int, lim int) -begin -if level < lim then -select level; -prepare stmt1 from "update t3 set a=a+2"; -execute stmt1; -FLUSH TABLES; -execute stmt1; -FLUSH TABLES; -execute stmt1; -FLUSH TABLES; -deallocate prepare stmt1; -execute stmt2; -select * from t3; -call bug10100pd(level+1, lim); -else -execute stmt2; -end if; -end| -create procedure bug10100pc(level int, lim int) -begin -declare lv int; -declare c cursor for select a from t3; -open c; -if level < lim then -select level; -fetch c into lv; -select lv; -update t3 set a=level+lv; -FLUSH TABLES; -call bug10100pc(level+1, lim); -else -select * from t3; -end if; -close c; -end| -set @@max_sp_recursion_depth=255| -set @var=1| -call bug10100p(255, @var)| -call bug10100pt(1,255)| -call bug10100pv(1,255)| -call bug10100pd(1,255)| -call bug10100pc(1,255)| -set @@max_sp_recursion_depth=0| -deallocate prepare stmt2| -drop function bug10100f| -drop procedure bug10100p| -drop procedure bug10100t| -drop procedure bug10100pt| -drop procedure bug10100pv| -drop procedure bug10100pd| -drop procedure bug10100pc| -drop view v1| -drop table t3| -drop procedure if exists bug15298_1; -drop procedure if exists bug15298_2; create user 'mysqltest_1'@'localhost'; grant all privileges on test.* to 'mysqltest_1'@'localhost'; create procedure 15298_1 () sql security definer show grants for current_user; @@ -170,8 +54,6 @@ disconnect con1; drop user mysqltest_1@localhost; drop procedure 15298_1; drop procedure 15298_2; -drop table if exists t1; -drop procedure if exists p1; create table t1 (value varchar(15)); create procedure p1() update t1 set value='updated' where value='old'; call p1(); @@ -283,7 +165,6 @@ disconnect con2; # functions in databases which names contained dot. # connection default; -DROP DATABASE IF EXISTS `my.db`; create database `my.db`; use `my.db`; CREATE FUNCTION f1(a int) RETURNS INT RETURN a; diff --git a/mysql-test/main/sp_notembedded.test b/mysql-test/main/sp_notembedded.test index 12bacff4..9aca03fb 100644 --- a/mysql-test/main/sp_notembedded.test +++ b/mysql-test/main/sp_notembedded.test @@ -7,19 +7,12 @@ set @@global.concurrent_insert= 0; # Save the initial number of concurrent sessions --source include/count_sessions.inc ---disable_warnings -drop table if exists t1,t3; ---enable_warnings delimiter |; - # # Bug#4902 Stored procedure with SHOW WARNINGS leads to packet error # # Added tests for show grants command ---disable_warnings -drop procedure if exists bug4902| ---enable_warnings create procedure bug4902() begin show grants for 'root'@'localhost'; @@ -38,9 +31,6 @@ call bug4902()| drop procedure bug4902| # We need separate SP for SHOW PROCESSLIST since we want use replace_column ---disable_warnings -drop procedure if exists bug4902_2| ---enable_warnings create procedure bug4902_2() begin show processlist; @@ -58,9 +48,6 @@ drop procedure bug4902_2| # # Bug#6807 Stored procedure crash if CREATE PROCEDURE ... KILL QUERY # ---disable_warnings -drop procedure if exists bug6807| ---enable_warnings create procedure bug6807() begin declare a int; @@ -77,152 +64,11 @@ call bug6807()| drop procedure bug6807| - -# -# Bug#10100 function (and stored procedure?) recursivity problem -# ---disable_warnings -drop function if exists bug10100f| -drop procedure if exists bug10100p| -drop procedure if exists bug10100t| -drop procedure if exists bug10100pt| -drop procedure if exists bug10100pv| -drop procedure if exists bug10100pd| -drop procedure if exists bug10100pc| ---enable_warnings -# routines with simple recursion -create function bug10100f(prm int) returns int -begin - if prm > 1 then - return prm * bug10100f(prm - 1); - end if; - return 1; -end| -set statement sql_mode = '' for -create procedure bug10100p(prm int, inout res int) -begin - set res = res * prm; - if prm > 1 then - call bug10100p(prm - 1, res); - end if; -end| -set statement sql_mode = '' for -create procedure bug10100t(prm int) -begin - declare res int; - set res = 1; - call bug10100p(prm, res); - select res; -end| - -# a procedure which use tables and recursion -create table t3 (a int)| -insert into t3 values (0)| -create view v1 as select a from t3| -create procedure bug10100pt(level int, lim int) -begin - if level < lim then - update t3 set a=level; - FLUSH TABLES; - call bug10100pt(level+1, lim); - else - select * from t3; - end if; -end| -# view & recursion -create procedure bug10100pv(level int, lim int) -begin - if level < lim then - update v1 set a=level; - FLUSH TABLES; - call bug10100pv(level+1, lim); - else - select * from v1; - end if; -end| -# dynamic sql & recursion -prepare stmt2 from "select * from t3;"; -create procedure bug10100pd(level int, lim int) -begin - if level < lim then - select level; - prepare stmt1 from "update t3 set a=a+2"; - execute stmt1; - FLUSH TABLES; - execute stmt1; - FLUSH TABLES; - execute stmt1; - FLUSH TABLES; - deallocate prepare stmt1; - execute stmt2; - select * from t3; - call bug10100pd(level+1, lim); - else - execute stmt2; - end if; -end| -# cursor & recursion -create procedure bug10100pc(level int, lim int) -begin - declare lv int; - declare c cursor for select a from t3; - open c; - if level < lim then - select level; - fetch c into lv; - select lv; - update t3 set a=level+lv; - FLUSH TABLES; - call bug10100pc(level+1, lim); - else - select * from t3; - end if; - close c; -end| - -# end of the stack checking -set @@max_sp_recursion_depth=255| -set @var=1| -# disable log because error about stack overrun contains numbers which -# depend on a system --- disable_ps_protocol --- disable_result_log --- error ER_STACK_OVERRUN_NEED_MORE -call bug10100p(255, @var)| --- error ER_STACK_OVERRUN_NEED_MORE -call bug10100pt(1,255)| --- error ER_STACK_OVERRUN_NEED_MORE -call bug10100pv(1,255)| --- error ER_STACK_OVERRUN_NEED_MORE -call bug10100pd(1,255)| --- error ER_STACK_OVERRUN_NEED_MORE -call bug10100pc(1,255)| --- enable_result_log --- enable_ps_protocol -set @@max_sp_recursion_depth=0| - -deallocate prepare stmt2| - -drop function bug10100f| -drop procedure bug10100p| -drop procedure bug10100t| -drop procedure bug10100pt| -drop procedure bug10100pv| -drop procedure bug10100pd| -drop procedure bug10100pc| -drop view v1| -drop table t3| - delimiter ;| - # # Bug#15298 SHOW GRANTS FOR CURRENT_USER: Incorrect output in DEFINER context # ---disable_warnings -drop procedure if exists bug15298_1; -drop procedure if exists bug15298_2; ---enable_warnings create user 'mysqltest_1'@'localhost'; grant all privileges on test.* to 'mysqltest_1'@'localhost'; create procedure 15298_1 () sql security definer show grants for current_user; @@ -242,11 +88,6 @@ drop procedure 15298_2; # Bug#29936 Stored Procedure DML ignores low_priority_updates setting # ---disable_warnings -drop table if exists t1; -drop procedure if exists p1; ---enable_warnings - create table t1 (value varchar(15)); create procedure p1() update t1 set value='updated' where value='old'; @@ -411,10 +252,6 @@ DROP FUNCTION f1; connection default; ---disable_warnings -DROP DATABASE IF EXISTS `my.db`; ---enable_warnings - create database `my.db`; use `my.db`; diff --git a/mysql-test/main/ssl.result b/mysql-test/main/ssl.result index 794830e5..4f8ce517 100644 --- a/mysql-test/main/ssl.result +++ b/mysql-test/main/ssl.result @@ -1,4 +1,22 @@ connect ssl_con,localhost,root,,,,,SSL; +select variable_name from performance_schema.status_by_thread where VARIABLE_NAME LIKE 'Ssl%'; +variable_name +Ssl_cipher +Ssl_cipher_list +Ssl_default_timeout +Ssl_server_not_after +Ssl_server_not_before +Ssl_verify_depth +Ssl_verify_mode +Ssl_version +Ssl_cipher +Ssl_cipher_list +Ssl_default_timeout +Ssl_server_not_after +Ssl_server_not_before +Ssl_verify_depth +Ssl_verify_mode +Ssl_version SELECT (VARIABLE_VALUE <> '') AS have_ssl FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_cipher'; have_ssl 1 diff --git a/mysql-test/main/ssl.test b/mysql-test/main/ssl.test index d3830bb7..642af380 100644 --- a/mysql-test/main/ssl.test +++ b/mysql-test/main/ssl.test @@ -10,9 +10,12 @@ --source include/count_sessions.inc --source include/default_charset.inc +--source include/have_perfschema.inc connect (ssl_con,localhost,root,,,,,SSL); +select variable_name from performance_schema.status_by_thread where VARIABLE_NAME LIKE 'Ssl%'; + # Check ssl turned on SELECT (VARIABLE_VALUE <> '') AS have_ssl FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_cipher'; diff --git a/mysql-test/main/strict.result b/mysql-test/main/strict.result index 31630599..d9d92402 100644 --- a/mysql-test/main/strict.result +++ b/mysql-test/main/strict.result @@ -897,7 +897,7 @@ ERROR 22003: Out of range value for column 'col1' at row 1 INSERT INTO t1 (col2) VALUES ('-1.2E-3'); ERROR 22003: Out of range value for column 'col2' at row 1 UPDATE t1 SET col1 =col1 * 5000 WHERE col1 > 0; -ERROR 22003: DOUBLE value is out of range in '"test"."t1"."col1" * 5000' +Got one of the listed errors UPDATE t1 SET col2 =col2 / 0 WHERE col2 > 0; ERROR 22012: Division by 0 UPDATE t1 SET col2= MOD(col2,0) WHERE col2 > 0; diff --git a/mysql-test/main/strict.test b/mysql-test/main/strict.test index 830f051a..1819f399 100644 --- a/mysql-test/main/strict.test +++ b/mysql-test/main/strict.test @@ -824,7 +824,7 @@ INSERT INTO t1 (col2) VALUES (-1.1E-3); INSERT INTO t1 (col1) VALUES ('+1.8E+309'); --error 1264 INSERT INTO t1 (col2) VALUES ('-1.2E-3'); ---error ER_DATA_OUT_OF_RANGE +--error ER_DATA_OUT_OF_RANGE, ER_WARN_DATA_OUT_OF_RANGE UPDATE t1 SET col1 =col1 * 5000 WHERE col1 > 0; --error 1365 UPDATE t1 SET col2 =col2 / 0 WHERE col2 > 0; diff --git a/mysql-test/main/subselect.result b/mysql-test/main/subselect.result index 32652244..9fbf36e3 100644 --- a/mysql-test/main/subselect.result +++ b/mysql-test/main/subselect.result @@ -1318,7 +1318,7 @@ a SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` int(3) DEFAULT NULL + `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci drop table t1; create table t1 (a int); @@ -7161,23 +7161,26 @@ drop table t1; # # MDEV-7565: Server crash with Signal 6 (part 2) # +create table t1 (id int not null primary key); Select -(Select Sum(`TestCase`.Revenue) From mysql.slow_log E -Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2) +(Select Sum(`TestCase`.Revenue) From t1 E +Where TestCase.TemplateID not in (Select 1 from t1 where 2=2) ) As `ControlRev` From (Select 3 as Revenue, 4 as TemplateID) As `TestCase` Group By TestCase.Revenue, TestCase.TemplateID; ControlRev NULL +drop table t1; # # MDEV-7445:Server crash with Signal 6 # +create table t1 (id int not null primary key); CREATE PROCEDURE procedure2() BEGIN Select -(Select Sum(`TestCase`.Revenue) From mysql.slow_log E -Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2) +(Select Sum(`TestCase`.Revenue) From t1 E +Where TestCase.TemplateID not in (Select 1 from t1 where 2=2) ) As `ControlRev` From (Select 3 as Revenue, 4 as TemplateID) As `TestCase` @@ -7190,6 +7193,7 @@ call procedure2(); ControlRev NULL drop procedure procedure2; +drop table t1; # # MDEV-7846:Server crashes in Item_subselect::fix #_fields or fails with Thread stack overrun @@ -7495,6 +7499,45 @@ ERROR HY000: Illegal parameter data types row and boolean for operation '=' SELECT ROW(1,2) = (1 = ANY (SELECT 1 UNION SELECT 2)); ERROR HY000: Illegal parameter data types row and boolean for operation '=' # +# MDEV-29070 SIGSEGV in my_decimal::operator= and Assertion `0' failed +# in Item_type_holder::val_decimal on SELECT +# +CREATE TABLE t1(a INT UNIQUE); +INSERT INTO t1(a) VALUES (1); +SELECT a FROM t1 WHERE (SELECT a, a UNION SELECT 1, a FROM t1) IN (SELECT 1, 1); +a +1 +SELECT a FROM t1 WHERE (SELECT a, a UNION SELECT 1, a FROM t1) IN (SELECT a, a); +a +1 +UPDATE t1 SET a = 0 +WHERE (SELECT a, a WHERE a < 0 INTERSECT +SELECT +1 / +1, a FROM t1 WHERE a > -0+1) IN (SELECT a, a); +SELECT a FROM t1 WHERE (SELECT a, a WHERE a < 0 INTERSECT +SELECT + 1 / + 1, a FROM t1 +WHERE a > -0 + 1) IN (SELECT a, a); +a +CREATE TABLE x (x INT); +INSERT INTO x (x) VALUES (1); +UPDATE x SET x = 1 WHERE x = 1; +INSERT INTO x (x) VALUES (1), (1); +WITH RECURSIVE x (x) AS ( +SELECT 1 INTERSECT +SELECT -(SELECT 1.000000 AS x +UNION +SELECT 1.000000 ORDER BY NOT x < 'x', +-(SELECT 1 + x/1.000000 IN (1, 1) FROM x +WHERE x ORDER BY 1 - x) DESC LIMIT 1 OFFSET 1 +) + 1 FROM x +) +SELECT DISTINCT x, 1, NULL, 1.000000 +FROM x +WHERE (SELECT (SELECT x WHERE x IN (SELECT x FROM x))) > +(SELECT (SELECT x ORDER BY x = x OR (x = 1 AND x = 1) DESC)) +ORDER BY x ASC, x DESC, x; +ERROR HY000: Restrictions imposed on recursive definitions are violated for table 'x' +DROP TABLE t1, x; +# # End of 10.4 tests # # diff --git a/mysql-test/main/subselect.test b/mysql-test/main/subselect.test index 97869a70..002d5ced 100644 --- a/mysql-test/main/subselect.test +++ b/mysql-test/main/subselect.test @@ -1180,8 +1180,10 @@ create table t1 (a int, b decimal(13, 3)); insert into t1 values (1, 0.123); let $outfile_abs= $MYSQLTEST_VARDIR/tmp/subselect.out.file.1; let $outfile_rel= ../../tmp/subselect.out.file.1; +--disable_warnings --error 0,1 --remove_file $outfile_abs +--enable_warnings eval select a, (select max(b) from t1) into outfile "$outfile_rel" from t1; delete from t1; eval load data infile "$outfile_rel" into table t1; @@ -6000,24 +6002,28 @@ drop table t1; --echo # --echo # MDEV-7565: Server crash with Signal 6 (part 2) --echo # + +create table t1 (id int not null primary key); Select - (Select Sum(`TestCase`.Revenue) From mysql.slow_log E - Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2) + (Select Sum(`TestCase`.Revenue) From t1 E + Where TestCase.TemplateID not in (Select 1 from t1 where 2=2) ) As `ControlRev` From (Select 3 as Revenue, 4 as TemplateID) As `TestCase` Group By TestCase.Revenue, TestCase.TemplateID; +drop table t1; --echo # --echo # MDEV-7445:Server crash with Signal 6 --echo # +create table t1 (id int not null primary key); --delimiter | CREATE PROCEDURE procedure2() BEGIN Select - (Select Sum(`TestCase`.Revenue) From mysql.slow_log E - Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2) + (Select Sum(`TestCase`.Revenue) From t1 E + Where TestCase.TemplateID not in (Select 1 from t1 where 2=2) ) As `ControlRev` From (Select 3 as Revenue, 4 as TemplateID) As `TestCase` @@ -6029,6 +6035,7 @@ call procedure2(); call procedure2(); drop procedure procedure2; +drop table t1; --echo # @@ -6351,6 +6358,50 @@ SELECT ROW(1,2) = 1 IN (SELECT 1 UNION SELECT 2); SELECT ROW(1,2) = (1 = ANY (SELECT 1 UNION SELECT 2)); --echo # +--echo # MDEV-29070 SIGSEGV in my_decimal::operator= and Assertion `0' failed +--echo # in Item_type_holder::val_decimal on SELECT +--echo # + +CREATE TABLE t1(a INT UNIQUE); +INSERT INTO t1(a) VALUES (1); + +SELECT a FROM t1 WHERE (SELECT a, a UNION SELECT 1, a FROM t1) IN (SELECT 1, 1); + +SELECT a FROM t1 WHERE (SELECT a, a UNION SELECT 1, a FROM t1) IN (SELECT a, a); + +UPDATE t1 SET a = 0 + WHERE (SELECT a, a WHERE a < 0 INTERSECT + SELECT +1 / +1, a FROM t1 WHERE a > -0+1) IN (SELECT a, a); + +SELECT a FROM t1 WHERE (SELECT a, a WHERE a < 0 INTERSECT + SELECT + 1 / + 1, a FROM t1 + WHERE a > -0 + 1) IN (SELECT a, a); + +CREATE TABLE x (x INT); +INSERT INTO x (x) VALUES (1); +UPDATE x SET x = 1 WHERE x = 1; +INSERT INTO x (x) VALUES (1), (1); +let $q= WITH RECURSIVE x (x) AS ( + SELECT 1 INTERSECT + SELECT -(SELECT 1.000000 AS x + UNION + SELECT 1.000000 ORDER BY NOT x < 'x', + -(SELECT 1 + x/1.000000 IN (1, 1) FROM x + WHERE x ORDER BY 1 - x) DESC LIMIT 1 OFFSET 1 + ) + 1 FROM x + ) + SELECT DISTINCT x, 1, NULL, 1.000000 + FROM x + WHERE (SELECT (SELECT x WHERE x IN (SELECT x FROM x))) > + (SELECT (SELECT x ORDER BY x = x OR (x = 1 AND x = 1) DESC)) + ORDER BY x ASC, x DESC, x; + +--error ER_NOT_STANDARD_COMPLIANT_RECURSIVE +eval $q; + +DROP TABLE t1, x; + +--echo # --echo # End of 10.4 tests --echo # diff --git a/mysql-test/main/subselect4.result b/mysql-test/main/subselect4.result index a041d76e..6d1e0dac 100644 --- a/mysql-test/main/subselect4.result +++ b/mysql-test/main/subselect4.result @@ -1892,6 +1892,8 @@ id select_type table type possible_keys key key_len ref rows Extra 2 SUBQUERY SUBQUERY2_t1 index NULL col_int_key 5 NULL 2 Using index 2 SUBQUERY SUBQUERY2_t2 ALL col_varchar_key NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) 3 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 +Warnings: +Note 1105 Cannot use key `col_varchar_key` part[0] for lookup: `test`.`t1`.`col_varchar_key` of type `varchar` < "0" of type `bigint` SELECT col_int_key FROM t2 WHERE (SELECT SUBQUERY2_t1.col_int_key @@ -1917,6 +1919,8 @@ id select_type table type possible_keys key key_len ref rows Extra 2 SUBQUERY SUBQUERY2_t1 index NULL col_int_key 5 NULL 2 Using index 2 SUBQUERY SUBQUERY2_t2 ALL col_varchar_key NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) 3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where +Warnings: +Note 1105 Cannot use key `col_varchar_key` part[0] for lookup: `test`.`t1`.`col_varchar_key` of type `varchar` < "0" of type `bigint` SELECT col_int_key FROM t2 WHERE (SELECT SUBQUERY2_t1.col_int_key @@ -3235,4 +3239,95 @@ FROM x ) ); ERROR 21000: Operand should contain 2 column(s) +# +# MDEV-29362: Constant subquery used as left part of IN subquery +# +CREATE TABLE t1 (a int) ENGINE=MyISAM; +INSERT INTO t1 VALUES (15), (1), (2); +CREATE TABLE t2 (b int) ENGINE=MyISAM; +INSERT INTO t2 VALUES (15), (1); +CREATE TABLE t3 (c int) ENGINE=MyISAM; +INSERT INTO t3 VALUES (15), (1); +SET optimizer_switch='condition_pushdown_from_having=off'; +SELECT a FROM t1 GROUP BY a +HAVING a = ( (SELECT b FROM t2 where b=1) IN (SELECT c FROM t3) ) + 1; +a +2 +SELECT a FROM t1 GROUP BY a +HAVING a IN ( (SELECT b FROM t2 where b=1) IN (SELECT c FROM t3) ); +a +1 +SET optimizer_switch='condition_pushdown_from_having=on'; +SELECT a FROM t1 GROUP BY a +HAVING a = ( (SELECT b FROM t2 where b=1) IN (SELECT c FROM t3) ) + 1; +a +2 +SELECT a FROM t1 GROUP BY a +HAVING a IN ( (SELECT b FROM t2 where b=1) IN (SELECT c FROM t3) ); +a +1 +EXPLAIN FORMAT=JSON SELECT a FROM t1 GROUP BY a +HAVING a = ( (SELECT b FROM t2 where b=1) IN (SELECT c FROM t3) ) + 1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t1.a = <cache>((<in_optimizer>((subquery#2),<exists>(subquery#3))) + 1)" + } + } + ], + "subqueries": [ + { + "query_block": { + "select_id": 3, + "having_condition": "trigcond(t3.c is null)", + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "trigcond(1 = t3.c or t3.c is null)" + } + } + ] + } + }, + { + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "t2.b = 1" + } + } + ] + } + } + ] + } +} +PREPARE stmt FROM "SELECT a FROM t1 GROUP BY a +HAVING a = ( (SELECT b FROM t2 where b=1) IN (SELECT c FROM t3) ) + 1"; +EXECUTE stmt; +a +2 +EXECUTE stmt; +a +2 +DEALLOCATE PREPARE stmt; +DROP TABLE t1,t2,t3; # End of 10.4 tests diff --git a/mysql-test/main/subselect4.test b/mysql-test/main/subselect4.test index d1ad903c..41fa9066 100644 --- a/mysql-test/main/subselect4.test +++ b/mysql-test/main/subselect4.test @@ -2633,6 +2633,42 @@ SELECT ) ); +--echo # +--echo # MDEV-29362: Constant subquery used as left part of IN subquery +--echo # + +CREATE TABLE t1 (a int) ENGINE=MyISAM; +INSERT INTO t1 VALUES (15), (1), (2); +CREATE TABLE t2 (b int) ENGINE=MyISAM; +INSERT INTO t2 VALUES (15), (1); +CREATE TABLE t3 (c int) ENGINE=MyISAM; +INSERT INTO t3 VALUES (15), (1); + +let $q1= +SELECT a FROM t1 GROUP BY a + HAVING a = ( (SELECT b FROM t2 where b=1) IN (SELECT c FROM t3) ) + 1; +let $q2= +SELECT a FROM t1 GROUP BY a + HAVING a IN ( (SELECT b FROM t2 where b=1) IN (SELECT c FROM t3) ); + +SET optimizer_switch='condition_pushdown_from_having=off'; + +eval $q1; +eval $q2; + +SET optimizer_switch='condition_pushdown_from_having=on'; + +eval $q1; +eval $q2; + +eval EXPLAIN FORMAT=JSON $q1; + +eval PREPARE stmt FROM "$q1"; +EXECUTE stmt; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; + +DROP TABLE t1,t2,t3; --echo # End of 10.4 tests diff --git a/mysql-test/main/subselect_no_exists_to_in.result b/mysql-test/main/subselect_no_exists_to_in.result index 2f9b36d1..0fdd573b 100644 --- a/mysql-test/main/subselect_no_exists_to_in.result +++ b/mysql-test/main/subselect_no_exists_to_in.result @@ -1322,7 +1322,7 @@ a SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` int(3) DEFAULT NULL + `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci drop table t1; create table t1 (a int); @@ -7161,23 +7161,26 @@ drop table t1; # # MDEV-7565: Server crash with Signal 6 (part 2) # +create table t1 (id int not null primary key); Select -(Select Sum(`TestCase`.Revenue) From mysql.slow_log E -Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2) +(Select Sum(`TestCase`.Revenue) From t1 E +Where TestCase.TemplateID not in (Select 1 from t1 where 2=2) ) As `ControlRev` From (Select 3 as Revenue, 4 as TemplateID) As `TestCase` Group By TestCase.Revenue, TestCase.TemplateID; ControlRev NULL +drop table t1; # # MDEV-7445:Server crash with Signal 6 # +create table t1 (id int not null primary key); CREATE PROCEDURE procedure2() BEGIN Select -(Select Sum(`TestCase`.Revenue) From mysql.slow_log E -Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2) +(Select Sum(`TestCase`.Revenue) From t1 E +Where TestCase.TemplateID not in (Select 1 from t1 where 2=2) ) As `ControlRev` From (Select 3 as Revenue, 4 as TemplateID) As `TestCase` @@ -7190,6 +7193,7 @@ call procedure2(); ControlRev NULL drop procedure procedure2; +drop table t1; # # MDEV-7846:Server crashes in Item_subselect::fix #_fields or fails with Thread stack overrun @@ -7495,6 +7499,45 @@ ERROR HY000: Illegal parameter data types row and boolean for operation '=' SELECT ROW(1,2) = (1 = ANY (SELECT 1 UNION SELECT 2)); ERROR HY000: Illegal parameter data types row and boolean for operation '=' # +# MDEV-29070 SIGSEGV in my_decimal::operator= and Assertion `0' failed +# in Item_type_holder::val_decimal on SELECT +# +CREATE TABLE t1(a INT UNIQUE); +INSERT INTO t1(a) VALUES (1); +SELECT a FROM t1 WHERE (SELECT a, a UNION SELECT 1, a FROM t1) IN (SELECT 1, 1); +a +1 +SELECT a FROM t1 WHERE (SELECT a, a UNION SELECT 1, a FROM t1) IN (SELECT a, a); +a +1 +UPDATE t1 SET a = 0 +WHERE (SELECT a, a WHERE a < 0 INTERSECT +SELECT +1 / +1, a FROM t1 WHERE a > -0+1) IN (SELECT a, a); +SELECT a FROM t1 WHERE (SELECT a, a WHERE a < 0 INTERSECT +SELECT + 1 / + 1, a FROM t1 +WHERE a > -0 + 1) IN (SELECT a, a); +a +CREATE TABLE x (x INT); +INSERT INTO x (x) VALUES (1); +UPDATE x SET x = 1 WHERE x = 1; +INSERT INTO x (x) VALUES (1), (1); +WITH RECURSIVE x (x) AS ( +SELECT 1 INTERSECT +SELECT -(SELECT 1.000000 AS x +UNION +SELECT 1.000000 ORDER BY NOT x < 'x', +-(SELECT 1 + x/1.000000 IN (1, 1) FROM x +WHERE x ORDER BY 1 - x) DESC LIMIT 1 OFFSET 1 +) + 1 FROM x +) +SELECT DISTINCT x, 1, NULL, 1.000000 +FROM x +WHERE (SELECT (SELECT x WHERE x IN (SELECT x FROM x))) > +(SELECT (SELECT x ORDER BY x = x OR (x = 1 AND x = 1) DESC)) +ORDER BY x ASC, x DESC, x; +ERROR HY000: Restrictions imposed on recursive definitions are violated for table 'x' +DROP TABLE t1, x; +# # End of 10.4 tests # # diff --git a/mysql-test/main/subselect_no_mat.result b/mysql-test/main/subselect_no_mat.result index 7e692c1a..5183d50c 100644 --- a/mysql-test/main/subselect_no_mat.result +++ b/mysql-test/main/subselect_no_mat.result @@ -1325,7 +1325,7 @@ a SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` int(3) DEFAULT NULL + `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci drop table t1; create table t1 (a int); @@ -7154,23 +7154,26 @@ drop table t1; # # MDEV-7565: Server crash with Signal 6 (part 2) # +create table t1 (id int not null primary key); Select -(Select Sum(`TestCase`.Revenue) From mysql.slow_log E -Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2) +(Select Sum(`TestCase`.Revenue) From t1 E +Where TestCase.TemplateID not in (Select 1 from t1 where 2=2) ) As `ControlRev` From (Select 3 as Revenue, 4 as TemplateID) As `TestCase` Group By TestCase.Revenue, TestCase.TemplateID; ControlRev NULL +drop table t1; # # MDEV-7445:Server crash with Signal 6 # +create table t1 (id int not null primary key); CREATE PROCEDURE procedure2() BEGIN Select -(Select Sum(`TestCase`.Revenue) From mysql.slow_log E -Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2) +(Select Sum(`TestCase`.Revenue) From t1 E +Where TestCase.TemplateID not in (Select 1 from t1 where 2=2) ) As `ControlRev` From (Select 3 as Revenue, 4 as TemplateID) As `TestCase` @@ -7183,6 +7186,7 @@ call procedure2(); ControlRev NULL drop procedure procedure2; +drop table t1; # # MDEV-7846:Server crashes in Item_subselect::fix #_fields or fails with Thread stack overrun @@ -7488,6 +7492,45 @@ ERROR HY000: Illegal parameter data types row and boolean for operation '=' SELECT ROW(1,2) = (1 = ANY (SELECT 1 UNION SELECT 2)); ERROR HY000: Illegal parameter data types row and boolean for operation '=' # +# MDEV-29070 SIGSEGV in my_decimal::operator= and Assertion `0' failed +# in Item_type_holder::val_decimal on SELECT +# +CREATE TABLE t1(a INT UNIQUE); +INSERT INTO t1(a) VALUES (1); +SELECT a FROM t1 WHERE (SELECT a, a UNION SELECT 1, a FROM t1) IN (SELECT 1, 1); +a +1 +SELECT a FROM t1 WHERE (SELECT a, a UNION SELECT 1, a FROM t1) IN (SELECT a, a); +a +1 +UPDATE t1 SET a = 0 +WHERE (SELECT a, a WHERE a < 0 INTERSECT +SELECT +1 / +1, a FROM t1 WHERE a > -0+1) IN (SELECT a, a); +SELECT a FROM t1 WHERE (SELECT a, a WHERE a < 0 INTERSECT +SELECT + 1 / + 1, a FROM t1 +WHERE a > -0 + 1) IN (SELECT a, a); +a +CREATE TABLE x (x INT); +INSERT INTO x (x) VALUES (1); +UPDATE x SET x = 1 WHERE x = 1; +INSERT INTO x (x) VALUES (1), (1); +WITH RECURSIVE x (x) AS ( +SELECT 1 INTERSECT +SELECT -(SELECT 1.000000 AS x +UNION +SELECT 1.000000 ORDER BY NOT x < 'x', +-(SELECT 1 + x/1.000000 IN (1, 1) FROM x +WHERE x ORDER BY 1 - x) DESC LIMIT 1 OFFSET 1 +) + 1 FROM x +) +SELECT DISTINCT x, 1, NULL, 1.000000 +FROM x +WHERE (SELECT (SELECT x WHERE x IN (SELECT x FROM x))) > +(SELECT (SELECT x ORDER BY x = x OR (x = 1 AND x = 1) DESC)) +ORDER BY x ASC, x DESC, x; +ERROR HY000: Restrictions imposed on recursive definitions are violated for table 'x' +DROP TABLE t1, x; +# # End of 10.4 tests # # diff --git a/mysql-test/main/subselect_no_opts.result b/mysql-test/main/subselect_no_opts.result index 790e0f84..603958d2 100644 --- a/mysql-test/main/subselect_no_opts.result +++ b/mysql-test/main/subselect_no_opts.result @@ -1321,7 +1321,7 @@ a SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` int(3) DEFAULT NULL + `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci drop table t1; create table t1 (a int); @@ -7152,23 +7152,26 @@ drop table t1; # # MDEV-7565: Server crash with Signal 6 (part 2) # +create table t1 (id int not null primary key); Select -(Select Sum(`TestCase`.Revenue) From mysql.slow_log E -Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2) +(Select Sum(`TestCase`.Revenue) From t1 E +Where TestCase.TemplateID not in (Select 1 from t1 where 2=2) ) As `ControlRev` From (Select 3 as Revenue, 4 as TemplateID) As `TestCase` Group By TestCase.Revenue, TestCase.TemplateID; ControlRev NULL +drop table t1; # # MDEV-7445:Server crash with Signal 6 # +create table t1 (id int not null primary key); CREATE PROCEDURE procedure2() BEGIN Select -(Select Sum(`TestCase`.Revenue) From mysql.slow_log E -Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2) +(Select Sum(`TestCase`.Revenue) From t1 E +Where TestCase.TemplateID not in (Select 1 from t1 where 2=2) ) As `ControlRev` From (Select 3 as Revenue, 4 as TemplateID) As `TestCase` @@ -7181,6 +7184,7 @@ call procedure2(); ControlRev NULL drop procedure procedure2; +drop table t1; # # MDEV-7846:Server crashes in Item_subselect::fix #_fields or fails with Thread stack overrun @@ -7486,6 +7490,45 @@ ERROR HY000: Illegal parameter data types row and boolean for operation '=' SELECT ROW(1,2) = (1 = ANY (SELECT 1 UNION SELECT 2)); ERROR HY000: Illegal parameter data types row and boolean for operation '=' # +# MDEV-29070 SIGSEGV in my_decimal::operator= and Assertion `0' failed +# in Item_type_holder::val_decimal on SELECT +# +CREATE TABLE t1(a INT UNIQUE); +INSERT INTO t1(a) VALUES (1); +SELECT a FROM t1 WHERE (SELECT a, a UNION SELECT 1, a FROM t1) IN (SELECT 1, 1); +a +1 +SELECT a FROM t1 WHERE (SELECT a, a UNION SELECT 1, a FROM t1) IN (SELECT a, a); +a +1 +UPDATE t1 SET a = 0 +WHERE (SELECT a, a WHERE a < 0 INTERSECT +SELECT +1 / +1, a FROM t1 WHERE a > -0+1) IN (SELECT a, a); +SELECT a FROM t1 WHERE (SELECT a, a WHERE a < 0 INTERSECT +SELECT + 1 / + 1, a FROM t1 +WHERE a > -0 + 1) IN (SELECT a, a); +a +CREATE TABLE x (x INT); +INSERT INTO x (x) VALUES (1); +UPDATE x SET x = 1 WHERE x = 1; +INSERT INTO x (x) VALUES (1), (1); +WITH RECURSIVE x (x) AS ( +SELECT 1 INTERSECT +SELECT -(SELECT 1.000000 AS x +UNION +SELECT 1.000000 ORDER BY NOT x < 'x', +-(SELECT 1 + x/1.000000 IN (1, 1) FROM x +WHERE x ORDER BY 1 - x) DESC LIMIT 1 OFFSET 1 +) + 1 FROM x +) +SELECT DISTINCT x, 1, NULL, 1.000000 +FROM x +WHERE (SELECT (SELECT x WHERE x IN (SELECT x FROM x))) > +(SELECT (SELECT x ORDER BY x = x OR (x = 1 AND x = 1) DESC)) +ORDER BY x ASC, x DESC, x; +ERROR HY000: Restrictions imposed on recursive definitions are violated for table 'x' +DROP TABLE t1, x; +# # End of 10.4 tests # # diff --git a/mysql-test/main/subselect_no_scache.result b/mysql-test/main/subselect_no_scache.result index 96d68a94..67d738a8 100644 --- a/mysql-test/main/subselect_no_scache.result +++ b/mysql-test/main/subselect_no_scache.result @@ -1324,7 +1324,7 @@ a SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` int(3) DEFAULT NULL + `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci drop table t1; create table t1 (a int); @@ -7167,23 +7167,26 @@ drop table t1; # # MDEV-7565: Server crash with Signal 6 (part 2) # +create table t1 (id int not null primary key); Select -(Select Sum(`TestCase`.Revenue) From mysql.slow_log E -Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2) +(Select Sum(`TestCase`.Revenue) From t1 E +Where TestCase.TemplateID not in (Select 1 from t1 where 2=2) ) As `ControlRev` From (Select 3 as Revenue, 4 as TemplateID) As `TestCase` Group By TestCase.Revenue, TestCase.TemplateID; ControlRev NULL +drop table t1; # # MDEV-7445:Server crash with Signal 6 # +create table t1 (id int not null primary key); CREATE PROCEDURE procedure2() BEGIN Select -(Select Sum(`TestCase`.Revenue) From mysql.slow_log E -Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2) +(Select Sum(`TestCase`.Revenue) From t1 E +Where TestCase.TemplateID not in (Select 1 from t1 where 2=2) ) As `ControlRev` From (Select 3 as Revenue, 4 as TemplateID) As `TestCase` @@ -7196,6 +7199,7 @@ call procedure2(); ControlRev NULL drop procedure procedure2; +drop table t1; # # MDEV-7846:Server crashes in Item_subselect::fix #_fields or fails with Thread stack overrun @@ -7501,6 +7505,45 @@ ERROR HY000: Illegal parameter data types row and boolean for operation '=' SELECT ROW(1,2) = (1 = ANY (SELECT 1 UNION SELECT 2)); ERROR HY000: Illegal parameter data types row and boolean for operation '=' # +# MDEV-29070 SIGSEGV in my_decimal::operator= and Assertion `0' failed +# in Item_type_holder::val_decimal on SELECT +# +CREATE TABLE t1(a INT UNIQUE); +INSERT INTO t1(a) VALUES (1); +SELECT a FROM t1 WHERE (SELECT a, a UNION SELECT 1, a FROM t1) IN (SELECT 1, 1); +a +1 +SELECT a FROM t1 WHERE (SELECT a, a UNION SELECT 1, a FROM t1) IN (SELECT a, a); +a +1 +UPDATE t1 SET a = 0 +WHERE (SELECT a, a WHERE a < 0 INTERSECT +SELECT +1 / +1, a FROM t1 WHERE a > -0+1) IN (SELECT a, a); +SELECT a FROM t1 WHERE (SELECT a, a WHERE a < 0 INTERSECT +SELECT + 1 / + 1, a FROM t1 +WHERE a > -0 + 1) IN (SELECT a, a); +a +CREATE TABLE x (x INT); +INSERT INTO x (x) VALUES (1); +UPDATE x SET x = 1 WHERE x = 1; +INSERT INTO x (x) VALUES (1), (1); +WITH RECURSIVE x (x) AS ( +SELECT 1 INTERSECT +SELECT -(SELECT 1.000000 AS x +UNION +SELECT 1.000000 ORDER BY NOT x < 'x', +-(SELECT 1 + x/1.000000 IN (1, 1) FROM x +WHERE x ORDER BY 1 - x) DESC LIMIT 1 OFFSET 1 +) + 1 FROM x +) +SELECT DISTINCT x, 1, NULL, 1.000000 +FROM x +WHERE (SELECT (SELECT x WHERE x IN (SELECT x FROM x))) > +(SELECT (SELECT x ORDER BY x = x OR (x = 1 AND x = 1) DESC)) +ORDER BY x ASC, x DESC, x; +ERROR HY000: Restrictions imposed on recursive definitions are violated for table 'x' +DROP TABLE t1, x; +# # End of 10.4 tests # # diff --git a/mysql-test/main/subselect_no_semijoin.result b/mysql-test/main/subselect_no_semijoin.result index 46894d3c..09073c99 100644 --- a/mysql-test/main/subselect_no_semijoin.result +++ b/mysql-test/main/subselect_no_semijoin.result @@ -1321,7 +1321,7 @@ a SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` int(3) DEFAULT NULL + `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci drop table t1; create table t1 (a int); @@ -7152,23 +7152,26 @@ drop table t1; # # MDEV-7565: Server crash with Signal 6 (part 2) # +create table t1 (id int not null primary key); Select -(Select Sum(`TestCase`.Revenue) From mysql.slow_log E -Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2) +(Select Sum(`TestCase`.Revenue) From t1 E +Where TestCase.TemplateID not in (Select 1 from t1 where 2=2) ) As `ControlRev` From (Select 3 as Revenue, 4 as TemplateID) As `TestCase` Group By TestCase.Revenue, TestCase.TemplateID; ControlRev NULL +drop table t1; # # MDEV-7445:Server crash with Signal 6 # +create table t1 (id int not null primary key); CREATE PROCEDURE procedure2() BEGIN Select -(Select Sum(`TestCase`.Revenue) From mysql.slow_log E -Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2) +(Select Sum(`TestCase`.Revenue) From t1 E +Where TestCase.TemplateID not in (Select 1 from t1 where 2=2) ) As `ControlRev` From (Select 3 as Revenue, 4 as TemplateID) As `TestCase` @@ -7181,6 +7184,7 @@ call procedure2(); ControlRev NULL drop procedure procedure2; +drop table t1; # # MDEV-7846:Server crashes in Item_subselect::fix #_fields or fails with Thread stack overrun @@ -7486,6 +7490,45 @@ ERROR HY000: Illegal parameter data types row and boolean for operation '=' SELECT ROW(1,2) = (1 = ANY (SELECT 1 UNION SELECT 2)); ERROR HY000: Illegal parameter data types row and boolean for operation '=' # +# MDEV-29070 SIGSEGV in my_decimal::operator= and Assertion `0' failed +# in Item_type_holder::val_decimal on SELECT +# +CREATE TABLE t1(a INT UNIQUE); +INSERT INTO t1(a) VALUES (1); +SELECT a FROM t1 WHERE (SELECT a, a UNION SELECT 1, a FROM t1) IN (SELECT 1, 1); +a +1 +SELECT a FROM t1 WHERE (SELECT a, a UNION SELECT 1, a FROM t1) IN (SELECT a, a); +a +1 +UPDATE t1 SET a = 0 +WHERE (SELECT a, a WHERE a < 0 INTERSECT +SELECT +1 / +1, a FROM t1 WHERE a > -0+1) IN (SELECT a, a); +SELECT a FROM t1 WHERE (SELECT a, a WHERE a < 0 INTERSECT +SELECT + 1 / + 1, a FROM t1 +WHERE a > -0 + 1) IN (SELECT a, a); +a +CREATE TABLE x (x INT); +INSERT INTO x (x) VALUES (1); +UPDATE x SET x = 1 WHERE x = 1; +INSERT INTO x (x) VALUES (1), (1); +WITH RECURSIVE x (x) AS ( +SELECT 1 INTERSECT +SELECT -(SELECT 1.000000 AS x +UNION +SELECT 1.000000 ORDER BY NOT x < 'x', +-(SELECT 1 + x/1.000000 IN (1, 1) FROM x +WHERE x ORDER BY 1 - x) DESC LIMIT 1 OFFSET 1 +) + 1 FROM x +) +SELECT DISTINCT x, 1, NULL, 1.000000 +FROM x +WHERE (SELECT (SELECT x WHERE x IN (SELECT x FROM x))) > +(SELECT (SELECT x ORDER BY x = x OR (x = 1 AND x = 1) DESC)) +ORDER BY x ASC, x DESC, x; +ERROR HY000: Restrictions imposed on recursive definitions are violated for table 'x' +DROP TABLE t1, x; +# # End of 10.4 tests # # diff --git a/mysql-test/main/subselect_nulls_innodb.result b/mysql-test/main/subselect_nulls_innodb.result new file mode 100644 index 00000000..2cab4176 --- /dev/null +++ b/mysql-test/main/subselect_nulls_innodb.result @@ -0,0 +1,27 @@ +# +# MDEV-32090 Index does not handle null-safe equals operator correctly in join +# +CREATE TEMPORARY TABLE t1 ( +`id` int(10) unsigned NOT NULL, +`number` int(10) unsigned DEFAULT 0, +`name` varchar(47) DEFAULT NULL, +`street` mediumint(8) unsigned DEFAULT NULL, +PRIMARY KEY (`id`), +KEY `streetNumber` (`street`,`number`,`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +INSERT INTO t1 (id, number, name, street) VALUES (100733476, 14, NULL, 1115569); +SELECT +b1.id +FROM +t1 b1 +INNER JOIN t1 b2 ON ( +b1.street = b2.street +AND b1.number <=> b2.number +AND b1.name <=> b2.name +); +id +100733476 +DROP TABLE t1; +# +# End of 10.11 tests +# diff --git a/mysql-test/main/subselect_nulls_innodb.test b/mysql-test/main/subselect_nulls_innodb.test new file mode 100644 index 00000000..79d572a2 --- /dev/null +++ b/mysql-test/main/subselect_nulls_innodb.test @@ -0,0 +1,32 @@ +--source include/have_innodb.inc + +--echo # +--echo # MDEV-32090 Index does not handle null-safe equals operator correctly in join +--echo # + +CREATE TEMPORARY TABLE t1 ( + `id` int(10) unsigned NOT NULL, + `number` int(10) unsigned DEFAULT 0, + `name` varchar(47) DEFAULT NULL, + `street` mediumint(8) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `streetNumber` (`street`,`number`,`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT INTO t1 (id, number, name, street) VALUES (100733476, 14, NULL, 1115569); + +SELECT + b1.id +FROM + t1 b1 + INNER JOIN t1 b2 ON ( + b1.street = b2.street + AND b1.number <=> b2.number + AND b1.name <=> b2.name + ); + +DROP TABLE t1; + +--echo # +--echo # End of 10.11 tests +--echo # diff --git a/mysql-test/main/temp_table.result b/mysql-test/main/temp_table.result index 7f005bde..23052e03 100644 --- a/mysql-test/main/temp_table.result +++ b/mysql-test/main/temp_table.result @@ -600,6 +600,22 @@ DROP TEMPORARY TABLE t1; # # End of 10.2 tests # +# +# MDEV-31523: Using two temporary tables in OPTIMIZE TABLE lead to crash +# +CREATE TEMPORARY TABLE t1 (c INT) ENGINE=MyISAM; +CREATE TEMPORARY TABLE t2 (c INT) ENGINE=MyISAM; +optimize TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 optimize status Table is already up to date +test.t2 optimize status Table is already up to date +SHOW TABLES; +Tables_in_test +# in 11.2 and above here should be listed above used temporary tables +DROP TEMPORARY TABLE t1, t2; +# +# End of 10.4 tests +# create function f1() returns int begin drop temporary table t1, t2; diff --git a/mysql-test/main/temp_table.test b/mysql-test/main/temp_table.test index 6ed5dbd8..11a66743 100644 --- a/mysql-test/main/temp_table.test +++ b/mysql-test/main/temp_table.test @@ -657,6 +657,22 @@ DROP TEMPORARY TABLE t1; --echo # End of 10.2 tests --echo # +--echo # +--echo # MDEV-31523: Using two temporary tables in OPTIMIZE TABLE lead to crash +--echo # + +CREATE TEMPORARY TABLE t1 (c INT) ENGINE=MyISAM; +CREATE TEMPORARY TABLE t2 (c INT) ENGINE=MyISAM; +optimize TABLE t1,t2; +SHOW TABLES; +--echo # in 11.2 and above here should be listed above used temporary tables + +DROP TEMPORARY TABLE t1, t2; + +--echo # +--echo # End of 10.4 tests +--echo # + # # DROP TEMPORARY TABLE fails in the middle # diff --git a/mysql-test/main/type_float.result b/mysql-test/main/type_float.result index 68f74f09..2df714af 100644 --- a/mysql-test/main/type_float.result +++ b/mysql-test/main/type_float.result @@ -1173,6 +1173,43 @@ d 50 fdbl 123.456.789,12345678000000000000000000000000000000 fdec 123.456.789,12345678900000000000000000000000000000 # +# MDEV-32645 CAST(AS UNSIGNED) fails with --view-protocol +# +SELECT +CAST(-1e0 AS UNSIGNED), +CAST(--2e0 AS UNSIGNED), +CAST(---3e0 AS UNSIGNED), +CAST(----4e0 AS UNSIGNED); +CAST(-1e0 AS UNSIGNED) CAST(--2e0 AS UNSIGNED) CAST(---3e0 AS UNSIGNED) CAST(----4e0 AS UNSIGNED) +0 2 0 4 +Warnings: +Note 1916 Got overflow when converting '-1' to UNSIGNED BIGINT. Value truncated +Note 1916 Got overflow when converting '-3' to UNSIGNED BIGINT. Value truncated +EXPLAIN EXTENDED SELECT +CAST(-1e0 AS UNSIGNED), +CAST(--2e0 AS UNSIGNED), +CAST(---3e0 AS UNSIGNED), +CAST(----4e0 AS UNSIGNED); +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 cast(-1e0 as unsigned) AS `CAST(-1e0 AS UNSIGNED)`,cast(2e0 as unsigned) AS `CAST(--2e0 AS UNSIGNED)`,cast(-3e0 as unsigned) AS `CAST(---3e0 AS UNSIGNED)`,cast(4e0 as unsigned) AS `CAST(----4e0 AS UNSIGNED)` +CREATE VIEW v1 AS SELECT +CAST(-1e0 AS UNSIGNED), +CAST(--2e0 AS UNSIGNED), +CAST(---3e0 AS UNSIGNED), +CAST(----4e0 AS UNSIGNED); +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 cast(-1e0 as unsigned) AS `CAST(-1e0 AS UNSIGNED)`,cast(2e0 as unsigned) AS `CAST(--2e0 AS UNSIGNED)`,cast(-3e0 as unsigned) AS `CAST(---3e0 AS UNSIGNED)`,cast(4e0 as unsigned) AS `CAST(----4e0 AS UNSIGNED)` latin1 latin1_swedish_ci +SELECT * FROM v1; +CAST(-1e0 AS UNSIGNED) CAST(--2e0 AS UNSIGNED) CAST(---3e0 AS UNSIGNED) CAST(----4e0 AS UNSIGNED) +0 2 0 4 +Warnings: +Note 1916 Got overflow when converting '-1' to UNSIGNED BIGINT. Value truncated +Note 1916 Got overflow when converting '-3' to UNSIGNED BIGINT. Value truncated +DROP VIEW v1; +# # End of 10.4 tests # # diff --git a/mysql-test/main/type_float.test b/mysql-test/main/type_float.test index 12e3f070..c90d8b8a 100644 --- a/mysql-test/main/type_float.test +++ b/mysql-test/main/type_float.test @@ -717,6 +717,32 @@ DELIMITER ;$$ --horizontal_results --echo # +--echo # MDEV-32645 CAST(AS UNSIGNED) fails with --view-protocol +--echo # + +SELECT + CAST(-1e0 AS UNSIGNED), + CAST(--2e0 AS UNSIGNED), + CAST(---3e0 AS UNSIGNED), + CAST(----4e0 AS UNSIGNED); + +EXPLAIN EXTENDED SELECT + CAST(-1e0 AS UNSIGNED), + CAST(--2e0 AS UNSIGNED), + CAST(---3e0 AS UNSIGNED), + CAST(----4e0 AS UNSIGNED); + +CREATE VIEW v1 AS SELECT + CAST(-1e0 AS UNSIGNED), + CAST(--2e0 AS UNSIGNED), + CAST(---3e0 AS UNSIGNED), + CAST(----4e0 AS UNSIGNED); + +SHOW CREATE VIEW v1; +SELECT * FROM v1; +DROP VIEW v1; + +--echo # --echo # End of 10.4 tests --echo # diff --git a/mysql-test/main/type_ranges.result b/mysql-test/main/type_ranges.result index 02b6c79b..efd83423 100644 --- a/mysql-test/main/type_ranges.result +++ b/mysql-test/main/type_ranges.result @@ -144,8 +144,10 @@ alter short drop default, DROP INDEX utiny, DROP INDEX ushort, DROP PRIMARY KEY, -DROP FOREIGN KEY any_name, +DROP FOREIGN KEY IF EXISTS any_name, ADD INDEX (auto); +Warnings: +Note 1091 Can't DROP FOREIGN KEY `any_name`; check that it exists LOCK TABLES t1 WRITE; ALTER TABLE t1 RENAME as t2, diff --git a/mysql-test/main/type_ranges.test b/mysql-test/main/type_ranges.test index 7bf29321..a69e3ac5 100644 --- a/mysql-test/main/type_ranges.test +++ b/mysql-test/main/type_ranges.test @@ -76,7 +76,7 @@ alter short drop default, DROP INDEX utiny, DROP INDEX ushort, DROP PRIMARY KEY, -DROP FOREIGN KEY any_name, +DROP FOREIGN KEY IF EXISTS any_name, ADD INDEX (auto); LOCK TABLES t1 WRITE; diff --git a/mysql-test/main/type_timestamp.result b/mysql-test/main/type_timestamp.result index 1c0fd23a..243d223c 100644 --- a/mysql-test/main/type_timestamp.result +++ b/mysql-test/main/type_timestamp.result @@ -1368,7 +1368,7 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci drop table t1; # -# End of 10.10 tests +# End of 10.5 tests # # # MDEV-32203 Raise notes when an index cannot be used on data type mismatch @@ -1489,3 +1489,4 @@ indexed_col not_indexed_col DROP TABLE t2; DROP TABLE t1; SET note_verbosity=DEFAULT; +# End of 10.6 tests diff --git a/mysql-test/main/type_timestamp.test b/mysql-test/main/type_timestamp.test index 76589f1f..b3dfa192 100644 --- a/mysql-test/main/type_timestamp.test +++ b/mysql-test/main/type_timestamp.test @@ -921,7 +921,7 @@ show create table t1; drop table t1; --echo # ---echo # End of 10.10 tests +--echo # End of 10.5 tests --echo # --echo # @@ -941,3 +941,5 @@ DELIMITER ;$$ --source unusable_keys_joins.inc DROP TABLE t1; SET note_verbosity=DEFAULT; + +--echo # End of 10.6 tests diff --git a/mysql-test/main/type_varchar.result b/mysql-test/main/type_varchar.result index 39225c4c..c7bf59ba 100644 --- a/mysql-test/main/type_varchar.result +++ b/mysql-test/main/type_varchar.result @@ -952,3 +952,232 @@ Note 1105 Cannot use key parts with `test`.`t1`.`indexed_col` in the rewritten c DROP TABLE t2; DROP TABLE t1; SET note_verbosity=DEFAULT; +# +# MDEV-32957 Unusable key notes report wrong predicates for > and >= +# +SET note_verbosity=unusable_keys; +CREATE TABLE t1 (a INT, i CHAR(32), KEY(i)); +FOR i IN 1..31 +DO +INSERT INTO t1 VALUES (i, 10+i); +END FOR; +$$ +EXPLAIN SELECT * FROM t1 WHERE i>30 ORDER BY i LIMIT 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL i NULL NULL NULL 31 Using where; Using filesort +Warnings: +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` > "30" of type `int` +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` > "30" of type `int` +EXPLAIN SELECT * FROM t1 WHERE i>=30 ORDER BY i LIMIT 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL i NULL NULL NULL 31 Using where; Using filesort +Warnings: +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` >= "30" of type `int` +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` >= "30" of type `int` +DROP TABLE t1; +SET note_verbosity=DEFAULT; +# +# MDEV-32958 Unusable key notes do not get reported for some operations +# +SET note_verbosity=unusable_keys; +CREATE TABLE t1 (c1 varchar(10), KEY(c1)) CHARACTER SET latin1; +INSERT INTO t1 VALUES ('a'); +INSERT INTO t1 VALUES ('b'); +INSERT INTO t1 VALUES ('c'); +INSERT INTO t1 VALUES ('d'); +INSERT INTO t1 VALUES ('e'); +INSERT INTO t1 VALUES ('f'); +INSERT INTO t1 VALUES ('g'); +INSERT INTO t1 VALUES ('h'); +INSERT INTO t1 VALUES ('i'); +INSERT INTO t1 VALUES ('j'); +EXPLAIN SELECT * FROM t1 WHERE c1=10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index c1 c1 13 NULL 10 Using where; Using index +Warnings: +Note 1105 Cannot use key `c1` part[0] for lookup: `test`.`t1`.`c1` of type `varchar` = "10" of type `int` +SELECT * FROM t1 WHERE c1=10; +c1 +Warnings: +Note 1105 Cannot use key `c1` part[0] for lookup: `test`.`t1`.`c1` of type `varchar` = "10" of type `int` +Warning 1292 Truncated incorrect DECIMAL value: 'a' +Warning 1292 Truncated incorrect DECIMAL value: 'b' +Warning 1292 Truncated incorrect DECIMAL value: 'c' +Warning 1292 Truncated incorrect DECIMAL value: 'd' +Warning 1292 Truncated incorrect DECIMAL value: 'e' +Warning 1292 Truncated incorrect DECIMAL value: 'f' +Warning 1292 Truncated incorrect DECIMAL value: 'g' +Warning 1292 Truncated incorrect DECIMAL value: 'h' +Warning 1292 Truncated incorrect DECIMAL value: 'i' +Warning 1292 Truncated incorrect DECIMAL value: 'j' +EXPLAIN SELECT * FROM t1 WHERE c1<10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index c1 c1 13 NULL 10 Using where; Using index +Warnings: +Note 1105 Cannot use key `c1` part[0] for lookup: `test`.`t1`.`c1` of type `varchar` < "10" of type `int` +SELECT * FROM t1 WHERE c1<10; +c1 +a +b +c +d +e +f +g +h +i +j +Warnings: +Note 1105 Cannot use key `c1` part[0] for lookup: `test`.`t1`.`c1` of type `varchar` < "10" of type `int` +Warning 1292 Truncated incorrect DECIMAL value: 'a' +Warning 1292 Truncated incorrect DECIMAL value: 'b' +Warning 1292 Truncated incorrect DECIMAL value: 'c' +Warning 1292 Truncated incorrect DECIMAL value: 'd' +Warning 1292 Truncated incorrect DECIMAL value: 'e' +Warning 1292 Truncated incorrect DECIMAL value: 'f' +Warning 1292 Truncated incorrect DECIMAL value: 'g' +Warning 1292 Truncated incorrect DECIMAL value: 'h' +Warning 1292 Truncated incorrect DECIMAL value: 'i' +Warning 1292 Truncated incorrect DECIMAL value: 'j' +EXPLAIN SELECT * FROM t1 WHERE c1 BETWEEN 10 AND 11; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index c1 c1 13 NULL 10 Using where; Using index +Warnings: +Note 1105 Cannot use key `c1` part[0] for lookup: `test`.`t1`.`c1` of type `varchar` >= "10" of type `int` +SELECT * FROM t1 WHERE c1 BETWEEN 10 AND 11; +c1 +Warnings: +Note 1105 Cannot use key `c1` part[0] for lookup: `test`.`t1`.`c1` of type `varchar` >= "10" of type `int` +Warning 1292 Truncated incorrect DECIMAL value: 'a' +Warning 1292 Truncated incorrect DECIMAL value: 'b' +Warning 1292 Truncated incorrect DECIMAL value: 'c' +Warning 1292 Truncated incorrect DECIMAL value: 'd' +Warning 1292 Truncated incorrect DECIMAL value: 'e' +Warning 1292 Truncated incorrect DECIMAL value: 'f' +Warning 1292 Truncated incorrect DECIMAL value: 'g' +Warning 1292 Truncated incorrect DECIMAL value: 'h' +Warning 1292 Truncated incorrect DECIMAL value: 'i' +Warning 1292 Truncated incorrect DECIMAL value: 'j' +EXPLAIN SELECT * FROM t1 WHERE c1 BETWEEN 10 AND '11'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index c1 c1 13 NULL 10 Using where; Using index +Warnings: +Note 1105 Cannot use key `c1` part[0] for lookup: `test`.`t1`.`c1` of type `varchar` >= "10" of type `int` +SELECT * FROM t1 WHERE c1 BETWEEN 10 AND '11'; +c1 +Warnings: +Note 1105 Cannot use key `c1` part[0] for lookup: `test`.`t1`.`c1` of type `varchar` >= "10" of type `int` +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'c' +Warning 1292 Truncated incorrect DOUBLE value: 'd' +Warning 1292 Truncated incorrect DOUBLE value: 'e' +Warning 1292 Truncated incorrect DOUBLE value: 'f' +Warning 1292 Truncated incorrect DOUBLE value: 'g' +Warning 1292 Truncated incorrect DOUBLE value: 'h' +Warning 1292 Truncated incorrect DOUBLE value: 'i' +Warning 1292 Truncated incorrect DOUBLE value: 'j' +EXPLAIN SELECT * FROM t1 WHERE c1 IN (10,20); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index c1 c1 13 NULL 10 Using where; Using index +Warnings: +Note 1105 Cannot use key `c1` part[0] for lookup: `test`.`t1`.`c1` of type `varchar` = "10" of type `int` +SELECT * FROM t1 WHERE c1 IN (10,20); +c1 +Warnings: +Note 1105 Cannot use key `c1` part[0] for lookup: `test`.`t1`.`c1` of type `varchar` = "10" of type `int` +Warning 1292 Truncated incorrect DECIMAL value: 'a' +Warning 1292 Truncated incorrect DECIMAL value: 'b' +Warning 1292 Truncated incorrect DECIMAL value: 'c' +Warning 1292 Truncated incorrect DECIMAL value: 'd' +Warning 1292 Truncated incorrect DECIMAL value: 'e' +Warning 1292 Truncated incorrect DECIMAL value: 'f' +Warning 1292 Truncated incorrect DECIMAL value: 'g' +Warning 1292 Truncated incorrect DECIMAL value: 'h' +Warning 1292 Truncated incorrect DECIMAL value: 'i' +Warning 1292 Truncated incorrect DECIMAL value: 'j' +EXPLAIN SELECT * FROM t1 WHERE c1 IN (_latin1'a' COLLATE latin1_german2_ci,'b'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index c1 c1 13 NULL 10 Using where; Using index +Warnings: +Note 1105 Cannot use key `c1` part[0] for lookup: `test`.`t1`.`c1` of collation `latin1_swedish_ci` = "_latin1'a' collate latin1_german2_ci" of collation `latin1_german2_ci` +SELECT * FROM t1 WHERE c1 IN (_latin1'a' COLLATE latin1_german2_ci,'b'); +c1 +a +b +Warnings: +Note 1105 Cannot use key `c1` part[0] for lookup: `test`.`t1`.`c1` of collation `latin1_swedish_ci` = "_latin1'a' collate latin1_german2_ci" of collation `latin1_german2_ci` +EXPLAIN SELECT * FROM t1 WHERE c1 IN ('a',_latin1'b' COLLATE latin1_german2_ci); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index c1 c1 13 NULL 10 Using where; Using index +Warnings: +Note 1105 Cannot use key `c1` part[0] for lookup: `test`.`t1`.`c1` of collation `latin1_swedish_ci` = "'a'" of collation `latin1_german2_ci` +SELECT * FROM t1 WHERE c1 IN ('a',_latin1'b' COLLATE latin1_german2_ci); +c1 +a +b +Warnings: +Note 1105 Cannot use key `c1` part[0] for lookup: `test`.`t1`.`c1` of collation `latin1_swedish_ci` = "'a'" of collation `latin1_german2_ci` +DROP TABLE t1; +CREATE TABLE t1(a INT, i CHAR(2), INDEX(i(1))); +INSERT INTO t1 (i) VALUES (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); +EXPLAIN SELECT * FROM t1 WHERE i >= 10 ORDER BY i LIMIT 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL i NULL NULL NULL 26 Using where; Using filesort +Warnings: +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` >= "10" of type `int` +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` >= "10" of type `int` +SELECT * FROM t1 WHERE i >= 10 ORDER BY i LIMIT 5; +a i +NULL 10 +NULL 11 +NULL 12 +NULL 13 +NULL 14 +Warnings: +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` >= "10" of type `int` +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` >= "10" of type `int` +EXPLAIN UPDATE t1 SET a = 1 WHERE i = 10 ORDER BY a, i LIMIT 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 26 Using where; Using filesort +Warnings: +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` = "10" of type `int` +EXPLAIN UPDATE t1 SET a = 1 WHERE i < 10 ORDER BY a, i LIMIT 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 26 Using where; Using filesort +Warnings: +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` < "10" of type `int` +EXPLAIN DELETE FROM t1 WHERE i = 10 ORDER BY a, i LIMIT 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 26 Using where; Using filesort +Warnings: +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` = "10" of type `int` +EXPLAIN DELETE FROM t1 WHERE i < 10 ORDER BY a, i LIMIT 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 26 Using where; Using filesort +Warnings: +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` < "10" of type `int` +EXPLAIN UPDATE t1 SET a = 1 WHERE i = 10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 26 Using where +Warnings: +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` = "10" of type `int` +EXPLAIN UPDATE t1 SET a = 1 WHERE i < 10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 26 Using where +Warnings: +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` < "10" of type `int` +EXPLAIN DELETE FROM t1 WHERE i = 10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 26 Using where +Warnings: +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` = "10" of type `int` +EXPLAIN DELETE FROM t1 WHERE i < 10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 26 Using where +Warnings: +Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` < "10" of type `int` +DROP TABLE t1; +SET note_verbosity=DEFAULT; diff --git a/mysql-test/main/type_varchar.test b/mysql-test/main/type_varchar.test index 46b37554..feb27027 100644 --- a/mysql-test/main/type_varchar.test +++ b/mysql-test/main/type_varchar.test @@ -415,3 +415,86 @@ DELIMITER ;$$ --source unusable_keys_joins.inc DROP TABLE t1; SET note_verbosity=DEFAULT; + + +--echo # +--echo # MDEV-32957 Unusable key notes report wrong predicates for > and >= +--echo # + +SET note_verbosity=unusable_keys; +CREATE TABLE t1 (a INT, i CHAR(32), KEY(i)); +DELIMITER $$; +FOR i IN 1..31 +DO + INSERT INTO t1 VALUES (i, 10+i); +END FOR; +$$ +DELIMITER ;$$ +EXPLAIN SELECT * FROM t1 WHERE i>30 ORDER BY i LIMIT 5; +EXPLAIN SELECT * FROM t1 WHERE i>=30 ORDER BY i LIMIT 5; +DROP TABLE t1; +SET note_verbosity=DEFAULT; + + +--echo # +--echo # MDEV-32958 Unusable key notes do not get reported for some operations +--echo # + +SET note_verbosity=unusable_keys; +CREATE TABLE t1 (c1 varchar(10), KEY(c1)) CHARACTER SET latin1; +INSERT INTO t1 VALUES ('a'); +INSERT INTO t1 VALUES ('b'); +INSERT INTO t1 VALUES ('c'); +INSERT INTO t1 VALUES ('d'); +INSERT INTO t1 VALUES ('e'); +INSERT INTO t1 VALUES ('f'); +INSERT INTO t1 VALUES ('g'); +INSERT INTO t1 VALUES ('h'); +INSERT INTO t1 VALUES ('i'); +INSERT INTO t1 VALUES ('j'); + +EXPLAIN SELECT * FROM t1 WHERE c1=10; +SELECT * FROM t1 WHERE c1=10; + +EXPLAIN SELECT * FROM t1 WHERE c1<10; +SELECT * FROM t1 WHERE c1<10; + +EXPLAIN SELECT * FROM t1 WHERE c1 BETWEEN 10 AND 11; +SELECT * FROM t1 WHERE c1 BETWEEN 10 AND 11; + +EXPLAIN SELECT * FROM t1 WHERE c1 BETWEEN 10 AND '11'; +SELECT * FROM t1 WHERE c1 BETWEEN 10 AND '11'; + +EXPLAIN SELECT * FROM t1 WHERE c1 IN (10,20); +SELECT * FROM t1 WHERE c1 IN (10,20); + +EXPLAIN SELECT * FROM t1 WHERE c1 IN (_latin1'a' COLLATE latin1_german2_ci,'b'); +SELECT * FROM t1 WHERE c1 IN (_latin1'a' COLLATE latin1_german2_ci,'b'); + +EXPLAIN SELECT * FROM t1 WHERE c1 IN ('a',_latin1'b' COLLATE latin1_german2_ci); +SELECT * FROM t1 WHERE c1 IN ('a',_latin1'b' COLLATE latin1_german2_ci); + +DROP TABLE t1; + + +CREATE TABLE t1(a INT, i CHAR(2), INDEX(i(1))); +INSERT INTO t1 (i) VALUES (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); + +EXPLAIN SELECT * FROM t1 WHERE i >= 10 ORDER BY i LIMIT 5; +SELECT * FROM t1 WHERE i >= 10 ORDER BY i LIMIT 5; + +EXPLAIN UPDATE t1 SET a = 1 WHERE i = 10 ORDER BY a, i LIMIT 5; +EXPLAIN UPDATE t1 SET a = 1 WHERE i < 10 ORDER BY a, i LIMIT 5; +EXPLAIN DELETE FROM t1 WHERE i = 10 ORDER BY a, i LIMIT 5; +EXPLAIN DELETE FROM t1 WHERE i < 10 ORDER BY a, i LIMIT 5; + +EXPLAIN UPDATE t1 SET a = 1 WHERE i = 10; +EXPLAIN UPDATE t1 SET a = 1 WHERE i < 10; +EXPLAIN DELETE FROM t1 WHERE i = 10; +EXPLAIN DELETE FROM t1 WHERE i < 10; + +DROP TABLE t1; + +SET note_verbosity=DEFAULT; diff --git a/mysql-test/main/view.result b/mysql-test/main/view.result index 0f47c47b..9cab1b5f 100644 --- a/mysql-test/main/view.result +++ b/mysql-test/main/view.result @@ -4422,12 +4422,14 @@ SELECT * FROM v1 WHERE a > 'JJ' OR a <> 0 AND a = 'VV'; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 range a a 13 NULL 4 100.00 Using where; Using index Warnings: +Note 1105 Cannot use key `a` part[0] for lookup: `test`.`t1`.`a` of type `varchar` < "0" of type `int` Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` > 'JJ' or `test`.`t1`.`a` = 'VV' and `test`.`t1`.`a` <> 0 EXPLAIN EXTENDED SELECT * FROM t1 WHERE a > 'JJ' OR a <> 0 AND a = 'VV'; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 range a a 13 NULL 4 100.00 Using where; Using index Warnings: +Note 1105 Cannot use key `a` part[0] for lookup: `test`.`t1`.`a` of type `varchar` < "0" of type `int` Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` > 'JJ' or `test`.`t1`.`a` = 'VV' and `test`.`t1`.`a` <> 0 # t1 and v1 should return the same result set SELECT * FROM v1 WHERE a > 'JJ' OR a AND a = 'VV'; @@ -4448,12 +4450,14 @@ SELECT * FROM v1 WHERE a > 'JJ' OR a AND a = 'VV'; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 range a a 13 NULL 4 100.00 Using where; Using index Warnings: +Note 1105 Cannot use key `a` part[0] for lookup: `test`.`t1`.`a` of type `varchar` < "0" of type `int` Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` > 'JJ' or `test`.`t1`.`a` = 'VV' and `test`.`t1`.`a` <> 0 EXPLAIN EXTENDED SELECT * FROM t1 WHERE a > 'JJ' OR a AND a = 'VV'; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 range a a 13 NULL 4 100.00 Using where; Using index Warnings: +Note 1105 Cannot use key `a` part[0] for lookup: `test`.`t1`.`a` of type `varchar` < "0" of type `int` Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` > 'JJ' or `test`.`t1`.`a` = 'VV' and `test`.`t1`.`a` <> 0 DROP VIEW v1; DROP TABLE t1; @@ -7025,3 +7029,49 @@ DROP TABLE t1, t2; # # End of 10.6 tests # +# +# MDEV-29587: Allowing insert into a view with columns that +# are not part the table +# +# view with 2 the same fields +CREATE TABLE table1 (x INT); +CREATE VIEW view1 AS SELECT x, x as x1 FROM table1; +INSERT INTO view1(x) VALUES (1); +INSERT INTO view1(x1) VALUES (1); +INSERT INTO view1(x1,x) VALUES (1,1); +ERROR HY000: The target table view1 of the INSERT is not insertable-into +DROP VIEW view1; +DROP TABLE table1; +# view with a field and expression over the field +CREATE TABLE table1 (x INT); +CREATE VIEW view1 AS SELECT x, x + 1 as x1 FROM table1; +INSERT INTO view1(x) VALUES (1); +INSERT INTO view1(x1) VALUES (1); +ERROR HY000: The target table view1 of the INSERT is not insertable-into +INSERT INTO view1(x1,x) VALUES (1,1); +ERROR HY000: The target table view1 of the INSERT is not insertable-into +DROP VIEW view1; +DROP TABLE table1; +# view with a field and collation expression over the field +CREATE TABLE table1 (x char(20)); +CREATE VIEW view1 AS SELECT x, x collate latin1_german1_ci as x1 FROM table1; +INSERT INTO view1(x) VALUES ("ua"); +# we can insert in the field with collation +INSERT INTO view1(x1) VALUES ("ua"); +INSERT INTO view1(x1,x) VALUES ("ua","ua"); +ERROR HY000: The target table view1 of the INSERT is not insertable-into +DROP VIEW view1; +DROP TABLE table1; +# view with a field and expression over other field +CREATE TABLE table1 (x INT, y INT); +CREATE VIEW view1 AS SELECT x, y + 1 as x1 FROM table1; +INSERT INTO view1(x) VALUES (1); +INSERT INTO view1(x1) VALUES (1); +ERROR HY000: The target table view1 of the INSERT is not insertable-into +INSERT INTO view1(x1,x) VALUES (1,1); +ERROR HY000: The target table view1 of the INSERT is not insertable-into +DROP VIEW view1; +DROP TABLE table1; +# +# End of 10.11 test +# diff --git a/mysql-test/main/view.test b/mysql-test/main/view.test index a4fe17a8..4c2d71d4 100644 --- a/mysql-test/main/view.test +++ b/mysql-test/main/view.test @@ -6792,3 +6792,56 @@ DROP TABLE t1, t2; --echo # --echo # End of 10.6 tests --echo # + + +--echo # +--echo # MDEV-29587: Allowing insert into a view with columns that +--echo # are not part the table +--echo # + +--echo # view with 2 the same fields +CREATE TABLE table1 (x INT); +CREATE VIEW view1 AS SELECT x, x as x1 FROM table1; +INSERT INTO view1(x) VALUES (1); +INSERT INTO view1(x1) VALUES (1); +--error ER_NON_INSERTABLE_TABLE +INSERT INTO view1(x1,x) VALUES (1,1); +DROP VIEW view1; +DROP TABLE table1; + +--echo # view with a field and expression over the field +CREATE TABLE table1 (x INT); +CREATE VIEW view1 AS SELECT x, x + 1 as x1 FROM table1; +INSERT INTO view1(x) VALUES (1); +--error ER_NON_INSERTABLE_TABLE +INSERT INTO view1(x1) VALUES (1); +--error ER_NON_INSERTABLE_TABLE +INSERT INTO view1(x1,x) VALUES (1,1); +DROP VIEW view1; +DROP TABLE table1; + +--echo # view with a field and collation expression over the field +CREATE TABLE table1 (x char(20)); +CREATE VIEW view1 AS SELECT x, x collate latin1_german1_ci as x1 FROM table1; +INSERT INTO view1(x) VALUES ("ua"); +--echo # we can insert in the field with collation +INSERT INTO view1(x1) VALUES ("ua"); +--error ER_NON_INSERTABLE_TABLE +INSERT INTO view1(x1,x) VALUES ("ua","ua"); +DROP VIEW view1; +DROP TABLE table1; + +--echo # view with a field and expression over other field +CREATE TABLE table1 (x INT, y INT); +CREATE VIEW view1 AS SELECT x, y + 1 as x1 FROM table1; +INSERT INTO view1(x) VALUES (1); +--error ER_NON_INSERTABLE_TABLE +INSERT INTO view1(x1) VALUES (1); +--error ER_NON_INSERTABLE_TABLE +INSERT INTO view1(x1,x) VALUES (1,1); +DROP VIEW view1; +DROP TABLE table1; + +--echo # +--echo # End of 10.11 test +--echo # diff --git a/mysql-test/main/win.result b/mysql-test/main/win.result index a1f20a62..1c3be0bd 100644 --- a/mysql-test/main/win.result +++ b/mysql-test/main/win.result @@ -4496,5 +4496,18 @@ NULL DROP FUNCTION f; DROP TABLE t; # +# MDEV-31296: Crash in Item_func::fix_fields when prepared statement +# with subqueries and window function is executed with +# sql_mode = ONLY_FULL_GROUP_BY +# +CREATE TABLE t1 ( a INT, i INT) ; +CREATE TABLE t2 ( a INT); +INSERT INTO t2 VALUES (4000); +SET SESSION sql_mode = "ONLY_FULL_GROUP_BY"; +EXECUTE IMMEDIATE "SELECT SUM(i) OVER (ORDER BY i) FROM t1 NATURAL JOIN t2"; +SUM(i) OVER (ORDER BY i) +# Clean up +DROP TABLE t1, t2; +# # End of 10.6 tests # diff --git a/mysql-test/main/win.test b/mysql-test/main/win.test index 0c610f35..2eed8783 100644 --- a/mysql-test/main/win.test +++ b/mysql-test/main/win.test @@ -2899,5 +2899,19 @@ DROP FUNCTION f; DROP TABLE t; --echo # +--echo # MDEV-31296: Crash in Item_func::fix_fields when prepared statement +--echo # with subqueries and window function is executed with +--echo # sql_mode = ONLY_FULL_GROUP_BY +--echo # +CREATE TABLE t1 ( a INT, i INT) ; +CREATE TABLE t2 ( a INT); +INSERT INTO t2 VALUES (4000); +SET SESSION sql_mode = "ONLY_FULL_GROUP_BY"; +EXECUTE IMMEDIATE "SELECT SUM(i) OVER (ORDER BY i) FROM t1 NATURAL JOIN t2"; + +--echo # Clean up +DROP TABLE t1, t2; + +--echo # --echo # End of 10.6 tests --echo # |