diff --git a/.travis.yml b/.travis.yml index 2541cc2c4d1..f1ffdbb5dfc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ language: cpp os: - linux - osx -osx_image: xcode8.3 +osx_image: xcode9.1 compiler: - gcc - clang diff --git a/client/mysql.cc b/client/mysql.cc index 62a4de7a10e..fa824d598e6 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1092,7 +1092,7 @@ inline bool is_delimiter_command(char *name, ulong len) only name(first DELIMITER_NAME_LEN bytes) is checked. */ return (len >= DELIMITER_NAME_LEN && - !my_strnncoll(charset_info, (uchar*) name, DELIMITER_NAME_LEN, + !my_strnncoll(&my_charset_latin1, (uchar*) name, DELIMITER_NAME_LEN, (uchar *) DELIMITER_NAME, DELIMITER_NAME_LEN)); } diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index a6215d0a977..771fb947e73 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -965,8 +965,9 @@ static int install_used_engines(void) { char buf[512]; DYNAMIC_STRING ds_result; - const char *query = "SELECT DISTINCT LOWER(engine) FROM information_schema.tables" - " WHERE table_comment LIKE 'Unknown storage engine%'"; + const char *query = "SELECT DISTINCT LOWER(engine) AS c1 FROM information_schema.tables" + " WHERE table_comment LIKE 'Unknown storage engine%'" + " ORDER BY c1"; if (opt_systables_only || !from_before_10_1()) { diff --git a/extra/mariabackup/backup_copy.cc b/extra/mariabackup/backup_copy.cc index bc37f347532..0b501970efa 100644 --- a/extra/mariabackup/backup_copy.cc +++ b/extra/mariabackup/backup_copy.cc @@ -46,6 +46,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include #include #include +#include #include #include #include @@ -1680,26 +1681,30 @@ copy_back() ut_crc32_init(); /* copy undo tablespaces */ - if (srv_undo_tablespaces > 0) { - dst_dir = (srv_undo_dir && *srv_undo_dir) - ? srv_undo_dir : mysql_data_home; - ds_data = ds_create(dst_dir, DS_TYPE_LOCAL); + dst_dir = (srv_undo_dir && *srv_undo_dir) + ? srv_undo_dir : mysql_data_home; - for (ulong i = 1; i <= srv_undo_tablespaces; i++) { - char filename[20]; - sprintf(filename, "undo%03lu", i); - if (!(ret = copy_or_move_file(filename, filename, - dst_dir, 1))) { - goto cleanup; - } + ds_data = ds_create(dst_dir, DS_TYPE_LOCAL); + + for (uint i = 1; i <= TRX_SYS_MAX_UNDO_SPACES; i++) { + char filename[20]; + sprintf(filename, "undo%03u", i); + if (!file_exists(filename)) { + break; + } + if (!(ret = copy_or_move_file(filename, filename, + dst_dir, 1))) { + goto cleanup; } - - ds_destroy(ds_data); - ds_data = NULL; } + ds_destroy(ds_data); + ds_data = NULL; + + /* copy redo logs */ + dst_dir = (srv_log_group_home_dir && *srv_log_group_home_dir) ? srv_log_group_home_dir : mysql_data_home; @@ -1825,7 +1830,7 @@ copy_back() } } - /* copy buufer pool dump */ + /* copy buffer pool dump */ if (innobase_buffer_pool_filename) { const char *src_name; diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 320f9bcbeba..af00173a4de 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -2836,7 +2836,7 @@ static dberr_t enumerate_ibd_files(process_single_tablespace_func_t callback) /* We found a symlink or a file */ if (strlen(fileinfo.name) > 4) { bool is_isl= false; - if (ends_with(fileinfo.name, ".ibd") || ((is_isl = ends_with(fileinfo.name, ".ibd")))) + if (ends_with(fileinfo.name, ".ibd") || ((is_isl = ends_with(fileinfo.name, ".isl")))) (*callback)(dbinfo.name, fileinfo.name, is_isl); } } diff --git a/include/my_alloc.h b/include/my_alloc.h index 85ac75fc666..b461065eb7c 100644 --- a/include/my_alloc.h +++ b/include/my_alloc.h @@ -43,6 +43,7 @@ typedef struct st_mem_root /* if block have less memory it will be put in 'used' list */ size_t min_malloc; size_t block_size; /* initial block size */ + size_t total_alloc; unsigned int block_num; /* allocated blocks counter */ /* first free block in queue test counter (if it exceed diff --git a/include/mysql.h.pp b/include/mysql.h.pp index 4a196b3c772..b87316946a4 100644 --- a/include/mysql.h.pp +++ b/include/mysql.h.pp @@ -238,6 +238,7 @@ typedef struct st_mem_root USED_MEM *pre_alloc; size_t min_malloc; size_t block_size; + size_t total_alloc; unsigned int block_num; unsigned int first_block_usage; void (*error_handler)(void); diff --git a/include/source_revision.h.in b/include/source_revision.h.in index 5b657d0940e..991df992e2f 100644 --- a/include/source_revision.h.in +++ b/include/source_revision.h.in @@ -1 +1 @@ -#cmakedefine SOURCE_REVISION "@SOURCE_REVISION@" +#define SOURCE_REVISION "@SOURCE_REVISION@" diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt index ed10262de50..e4c860a5157 100644 --- a/libmysqld/CMakeLists.txt +++ b/libmysqld/CMakeLists.txt @@ -118,6 +118,7 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc ../sql/temporary_tables.cc ../sql/session_tracker.cc ../sql/proxy_protocol.cc + ../sql/sql_tvc.cc ../sql/sql_tvc.h ../sql/item_vers.cc ../sql/vtmd.cc ${GEN_SOURCES} diff --git a/mysql-test/extra/binlog_tests/binlog_index.inc b/mysql-test/extra/binlog_tests/binlog_index.inc index 50215aef9a9..b930386a0ba 100644 --- a/mysql-test/extra/binlog_tests/binlog_index.inc +++ b/mysql-test/extra/binlog_tests/binlog_index.inc @@ -18,7 +18,7 @@ call mtr.add_suppression('Attempting backtrace'); call mtr.add_suppression('MYSQL_BIN_LOG::purge_logs failed to process registered files that would be purged.'); call mtr.add_suppression('MYSQL_BIN_LOG::open failed to sync the index file'); call mtr.add_suppression('Turning logging off for the whole duration of the MySQL server process.'); -call mtr.add_suppression('Could not open .*'); +call mtr.add_suppression('Could not use .*'); call mtr.add_suppression('MYSQL_BIN_LOG::purge_logs failed to clean registers before purging logs.'); flush tables; diff --git a/mysql-test/extra/rpl_tests/rpl_binlog_errors.inc b/mysql-test/extra/rpl_tests/rpl_binlog_errors.inc index 49ab4f386bf..46c76f2b04c 100644 --- a/mysql-test/extra/rpl_tests/rpl_binlog_errors.inc +++ b/mysql-test/extra/rpl_tests/rpl_binlog_errors.inc @@ -286,7 +286,7 @@ SET GLOBAL debug_dbug=@old_debug; ### file or failure to write the rotate event. call mtr.add_suppression("MYSQL_BIN_LOG::open failed to sync the index file."); -call mtr.add_suppression("Could not open .*"); +call mtr.add_suppression("Could not use .*"); RESET MASTER; SHOW WARNINGS; @@ -392,7 +392,7 @@ RESET MASTER; call mtr.add_suppression("Slave I/O: Relay log write failure: could not queue event from master.*"); call mtr.add_suppression("Error writing file .*"); -call mtr.add_suppression("Could not open .*"); +call mtr.add_suppression("Could not use .*"); call mtr.add_suppression("MYSQL_BIN_LOG::open failed to sync the index file."); call mtr.add_suppression("Can't generate a unique log-filename .*"); -- echo ###################### TEST #13 diff --git a/mysql-test/include/check-testcase.test b/mysql-test/include/check-testcase.test index 3b2c2a46590..a282201857e 100644 --- a/mysql-test/include/check-testcase.test +++ b/mysql-test/include/check-testcase.test @@ -82,6 +82,8 @@ call mtr.check_testcase(); let $datadir=`select @@datadir`; list_files $datadir mysql_upgrade_info; +list_files $datadir/test #sql*; +list_files $datadir/mysql #sql*; --enable_query_log diff --git a/mysql-test/include/mtr_check.sql b/mysql-test/include/mtr_check.sql index 89f9f66ae1d..f2c0b70e192 100644 --- a/mysql-test/include/mtr_check.sql +++ b/mysql-test/include/mtr_check.sql @@ -39,12 +39,14 @@ BEGIN -- Dump all databases, there should be none -- except those that was created during bootstrap - SELECT * FROM INFORMATION_SCHEMA.SCHEMATA; + SELECT * FROM INFORMATION_SCHEMA.SCHEMATA ORDER BY BINARY SCHEMA_NAME; -- and the mtr_wsrep_notify schema which is populated by the std_data/wsrep_notify.sh script -- and the suite/galera/t/galera_var_notify_cmd.test -- and the wsrep_schema schema that may be created by Galera - SELECT * FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME NOT IN ('mtr_wsrep_notify', 'wsrep_schema'); + SELECT * FROM INFORMATION_SCHEMA.SCHEMATA + WHERE SCHEMA_NAME NOT IN ('mtr_wsrep_notify', 'wsrep_schema') + ORDER BY BINARY SCHEMA_NAME; -- The test database should not contain any tables SELECT table_name AS tables_in_test FROM INFORMATION_SCHEMA.TABLES diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index a3f2d98d18e..12e397c02d7 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1917,10 +1917,10 @@ sub collect_mysqld_features_from_running_server () #print "Major: $1 Minor: $2 Build: $3\n"; $mysql_version_id= $1*10000 + $2*100 + $3; #print "mysql_version_id: $mysql_version_id\n"; - mtr_report("MySQL Version $1.$2.$3"); + mtr_report("MariaDB Version $1.$2.$3"); $mysql_version_extra= $4; } - mtr_error("Could not find version of MySQL") unless $mysql_version_id; + mtr_error("Could not find version of MariaDBL") unless $mysql_version_id; } sub find_mysqld { @@ -2210,7 +2210,7 @@ sub environment_setup { $ENV{'UMASK_DIR'}= "0770"; # The octal *string* # - # MySQL tests can produce output in various character sets + # MariaDB tests can produce output in various character sets # (especially, ctype_xxx.test). To avoid confusing Perl # with output which is incompatible with the current locale # settings, we reset the current values of LC_ALL and LC_CTYPE to "C". @@ -2541,7 +2541,7 @@ sub setup_vardir() { if (check_socket_path_length("$opt_tmpdir/testsocket.sock")){ mtr_error("Socket path '$opt_tmpdir' too long, it would be ", "truncated and thus not possible to use for connection to ", - "MySQL Server. Set a shorter with --tmpdir= option"); + "MariaDB Server. Set a shorter with --tmpdir= option"); } # copy all files from std_data into var/std_data @@ -4397,12 +4397,12 @@ sub extract_warning_lines ($$) { qr/Slave I\/O: error reconnecting to master '.*' - retry-time: [1-3] retries/, qr/Slave I\/0: Master command COM_BINLOG_DUMP failed/, qr/Error reading packet/, - qr/Lost connection to MySQL server at 'reading initial communication packet'/, + qr/Lost connection to MariaDB server at 'reading initial communication packet'/, qr/Failed on request_dump/, qr/Slave: Can't drop database.* database doesn't exist/, qr/Slave: Operation DROP USER failed for 'create_rout_db'/, qr|Checking table: '\..mtr.test_suppressions'|, - qr|Table \./test/bug53592 has a primary key in InnoDB data dictionary, but not in MySQL|, + qr|Table \./test/bug53592 has a primary key in InnoDB data dictionary, but not in|, qr|Table '\..mtr.test_suppressions' is marked as crashed and should be repaired|, qr|Table 'test_suppressions' is marked as crashed and should be repaired|, qr|Can't open shared library|, diff --git a/mysql-test/r/compound.result b/mysql-test/r/compound.result index 49ad567a055..a54faff4562 100644 --- a/mysql-test/r/compound.result +++ b/mysql-test/r/compound.result @@ -112,7 +112,8 @@ select @a| /**/ while (select count(*) from information_schema.tables where table_schema='test') do select concat('drop table ', table_name) into @a -from information_schema.tables where table_schema='test' limit 1; +from information_schema.tables where table_schema='test' + order by table_name limit 1; select @a as 'executing:'; prepare dt from @a; execute dt; diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 7459936eabb..239a9dce05a 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -1173,6 +1173,7 @@ t1 CREATE TABLE `t1` ( `MAX_STAGE` tinyint(2) NOT NULL DEFAULT 0, `PROGRESS` decimal(7,3) NOT NULL DEFAULT 0.000, `MEMORY_USED` bigint(7) NOT NULL DEFAULT 0, + `MAX_MEMORY_USED` bigint(7) NOT NULL DEFAULT 0, `EXAMINED_ROWS` int(7) NOT NULL DEFAULT 0, `QUERY_ID` bigint(4) NOT NULL DEFAULT 0, `INFO_BINARY` blob DEFAULT NULL, @@ -1196,6 +1197,7 @@ t1 CREATE TEMPORARY TABLE `t1` ( `MAX_STAGE` tinyint(2) NOT NULL DEFAULT 0, `PROGRESS` decimal(7,3) NOT NULL DEFAULT 0.000, `MEMORY_USED` bigint(7) NOT NULL DEFAULT 0, + `MAX_MEMORY_USED` bigint(7) NOT NULL DEFAULT 0, `EXAMINED_ROWS` int(7) NOT NULL DEFAULT 0, `QUERY_ID` bigint(4) NOT NULL DEFAULT 0, `INFO_BINARY` blob DEFAULT NULL, diff --git a/mysql-test/r/cte_nonrecursive.result b/mysql-test/r/cte_nonrecursive.result index 3ad6fb8fabe..d0e42cf4042 100644 --- a/mysql-test/r/cte_nonrecursive.result +++ b/mysql-test/r/cte_nonrecursive.result @@ -1079,3 +1079,71 @@ id select_type table type possible_keys key key_len ref rows Extra 3 DERIVED t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) NULL UNION RESULT ALL NULL NULL NULL NULL NULL DROP TABLE t1,t2; +# +# MDEV-13780: tower of embedding CTEs with multiple usage of them +# +create table t1 (a int); +insert into t1 values (3), (2), (4), (7), (1), (2), (5); +with cte_e as +( +with cte_o as +( +with cte_i as (select * from t1 where a < 7) +select * from cte_i where a > 1 +) +select * from cte_o as cto_o1 where a < 3 +union +select * from cte_o as cto_o2 where a > 4 +) +select * from cte_e as cte_e1 where a > 1 +union +select * from cte_e as cte_e2; +a +2 +5 +explain extended with cte_e as +( +with cte_o as +( +with cte_i as (select * from t1 where a < 7) +select * from cte_i where a > 1 +) +select * from cte_o as cto_o1 where a < 3 +union +select * from cte_o as cto_o2 where a > 4 +) +select * from cte_e as cte_e1 where a > 1 +union +select * from cte_e as cte_e2; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ALL NULL NULL NULL NULL 14 100.00 Using where +2 DERIVED t1 ALL NULL NULL NULL NULL 7 100.00 Using where +5 UNION t1 ALL NULL NULL NULL NULL 7 100.00 Using where +NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL +6 UNION ALL NULL NULL NULL NULL 14 100.00 +9 DERIVED t1 ALL NULL NULL NULL NULL 7 100.00 Using where +12 UNION t1 ALL NULL NULL NULL NULL 7 100.00 Using where +NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL +NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 with cte_e as (with cte_o as (with cte_i as (/* select#4 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` < 7)/* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` > 1)/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` < 3 and `test`.`t1`.`a` > 1 and `test`.`t1`.`a` < 7 and `test`.`t1`.`a` > 1 union /* select#5 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` > 4 and `test`.`t1`.`a` > 1 and `test`.`t1`.`a` < 7 and `test`.`t1`.`a` > 1)/* select#1 */ select `cte_e1`.`a` AS `a` from `cte_e` `cte_e1` where `cte_e1`.`a` > 1 union /* select#6 */ select `cte_e2`.`a` AS `a` from `cte_e` `cte_e2` +drop table t1; +# +# MDEV-13753: embedded CTE in a VIEW created in prepared statement +# +SET @sql_query = " + CREATE OR REPLACE VIEW cte_test AS + WITH cte1 AS ( SELECT 1 as a from dual ) + , cte2 AS ( SELECT * FROM cte1 ) + SELECT * FROM cte2; +"; +PREPARE stmt FROM @sql_query; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +SHOW CREATE VIEW cte_test; +View Create View character_set_client collation_connection +cte_test CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `cte_test` AS with cte1 as (select 1 AS `a`), cte2 as (select `cte1`.`a` AS `a` from `cte1`)select `cte2`.`a` AS `a` from `cte2` latin1 latin1_swedish_ci +SELECT * FROM cte_test; +a +1 +DROP VIEW cte_test; diff --git a/mysql-test/r/cte_recursive.result b/mysql-test/r/cte_recursive.result index a4f32927cf1..b902333ddc4 100644 --- a/mysql-test/r/cte_recursive.result +++ b/mysql-test/r/cte_recursive.result @@ -2881,3 +2881,48 @@ f 2 set standard_compliant_cte=default; DROP TABLE t; +# +# mdev-14184: recursive CTE embedded into CTE with multiple references +# +WITH +cte1 AS ( +SELECT n FROM ( +WITH RECURSIVE rec_cte(n) AS ( +SELECT 1 as n1 +UNION ALL +SELECT n+1 as n2 FROM rec_cte WHERE n < 3 +) SELECT n FROM rec_cte +) AS X +), +cte2 as ( +SELECT 2 FROM cte1 +) +SELECT * +FROM cte1; +n +1 +2 +3 +# +# MDEV-14217 [db crash] Recursive CTE when SELECT includes new field +# +CREATE TEMPORARY TABLE a_tbl ( +a VARCHAR(33) PRIMARY KEY, +b VARCHAR(33) +); +INSERT INTO a_tbl VALUES ('block0', 'block0'), ('block1', NULL); +WITH RECURSIVE Q0 AS ( +SELECT T0.a, T0.b, 5 +FROM a_tbl T0 +WHERE b IS NULL +UNION ALL +SELECT T1.a, T1.b +FROM Q0 +JOIN a_tbl T1 +ON T1.a=Q0.a +) SELECT distinct(Q0.a), Q0.b +FROM Q0; +ERROR 21000: The used SELECT statements have a different number of columns +DROP TABLE a_tbl; +WITH RECURSIVE x AS (SELECT 1,2 UNION ALL SELECT 1 FROM x) SELECT * FROM x; +ERROR 21000: The used SELECT statements have a different number of columns diff --git a/mysql-test/r/default.result b/mysql-test/r/default.result index a03da4f8df1..3b1912f4a55 100644 --- a/mysql-test/r/default.result +++ b/mysql-test/r/default.result @@ -232,7 +232,7 @@ CREATE TABLE t1 (a INT DEFAULT 10); INSERT INTO t1 VALUES (11); CREATE VIEW v1 AS SELECT a AS a FROM t1; CREATE VIEW v2 AS SELECT DEFAULT(a) AS a FROM t1; -CREATE VIEW v3 AS SELECT VALUES(a) AS a FROM t1; +CREATE VIEW v3 AS SELECT VALUE(a) AS a FROM t1; SELECT * FROM v1; a 11 @@ -546,8 +546,8 @@ CREATE PROCEDURE p1() CREATE TABLE t1 (a INT DEFAULT par); CALL p1; ERROR 42S22: Unknown column 'par' in 'DEFAULT' DROP PROCEDURE p1; -CREATE TABLE t1 (a INT DEFAULT VALUES(a)); -ERROR HY000: Function or expression 'values()' cannot be used in the DEFAULT clause of `a` +CREATE TABLE t1 (a INT DEFAULT VALUE(a)); +ERROR HY000: Function or expression 'value()' cannot be used in the DEFAULT clause of `a` CREATE TABLE t1 (a INT); CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW CREATE TABLE t2 (a INT DEFAULT NEW.a); ERROR HY000: Function or expression 'NEW.a' cannot be used in the DEFAULT clause of `a` diff --git a/mysql-test/r/delimiter_command_case_sensitivity.result b/mysql-test/r/delimiter_command_case_sensitivity.result new file mode 100644 index 00000000000..6ed281c757a --- /dev/null +++ b/mysql-test/r/delimiter_command_case_sensitivity.result @@ -0,0 +1,2 @@ +1 +1 diff --git a/mysql-test/r/derived_cond_pushdown.result b/mysql-test/r/derived_cond_pushdown.result index 9001c5fef43..d8d03d6d062 100644 --- a/mysql-test/r/derived_cond_pushdown.result +++ b/mysql-test/r/derived_cond_pushdown.result @@ -8783,6 +8783,47 @@ EXPLAIN DROP VIEW v2; DROP TABLE t1,t2; # +# MDEV-14237: derived with regexp_substr() in select list +# +create table t1 (a char(8)); +insert into t1 values ('b'), ('a'), ('xx'); +select * +from ( select distinct regexp_substr(t1.a,'^[A-Za-z]+') as f from t1) as t +where t.f = 'a' or t.f = 'b'; +f +b +a +explain format=json select * +from ( select distinct regexp_substr(t1.a,'^[A-Za-z]+') as f from t1) as t +where t.f = 'a' or t.f = 'b'; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "table_name": "", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t.f = 'a' or t.f = 'b'", + "materialized": { + "query_block": { + "select_id": 2, + "temporary_table": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + } + } + } + } +} +drop table t1; +# # MDEV-10855: Pushdown into derived with window functions # set @save_optimizer_switch= @@optimizer_switch; diff --git a/mysql-test/r/errors.result b/mysql-test/r/errors.result index bcc171e404d..ba05a2b37d4 100644 --- a/mysql-test/r/errors.result +++ b/mysql-test/r/errors.result @@ -150,17 +150,17 @@ ERROR 22003: BIGINT value is out of range in '-73 * -2465717823867977728' # CREATE TABLE t1 (a INT); CREATE TABLE t2(a INT PRIMARY KEY, b INT); -SELECT '' AS b FROM t1 GROUP BY VALUES(b); +SELECT '' AS b FROM t1 GROUP BY VALUE(b); ERROR 42S22: Unknown column '' in 'VALUES() function' -REPLACE t2(b) SELECT '' AS b FROM t1 GROUP BY VALUES(b); +REPLACE t2(b) SELECT '' AS b FROM t1 GROUP BY VALUE(b); ERROR 42S22: Unknown column '' in 'VALUES() function' -UPDATE t2 SET a=(SELECT '' AS b FROM t1 GROUP BY VALUES(b)); +UPDATE t2 SET a=(SELECT '' AS b FROM t1 GROUP BY VALUE(b)); ERROR 42S22: Unknown column '' in 'VALUES() function' INSERT INTO t2 VALUES (1,0) ON DUPLICATE KEY UPDATE -b=(SELECT '' AS b FROM t1 GROUP BY VALUES(b)); +b=(SELECT '' AS b FROM t1 GROUP BY VALUE(b)); ERROR 42S22: Unknown column '' in 'VALUES() function' INSERT INTO t2(a,b) VALUES (1,0) ON DUPLICATE KEY UPDATE -b=(SELECT VALUES(a)+2 FROM t1); +b=(SELECT VALUE(a)+2 FROM t1); DROP TABLE t1, t2; # # MDEV-492: incorrect error check before sending OK in mysql_update @@ -174,3 +174,11 @@ set max_session_mem_used = 50000; select * from seq_1_to_1000; set max_session_mem_used = 8192; select * from seq_1_to_1000; +# +# MDEV-14269 errors.test fails with valgrind (Conditional jump or move depends on uninitialised value) +# +SET NAMES utf8; +SELECT UPDATEXML(-73 * -2465717823867977728,@@global.auto_increment_increment,null); +ERROR 22003: BIGINT value is out of range in '-73 * -2465717823867977728' +SELECT UPDATEXML(-73 * -2465717823867977728,@@global.long_query_time,null); +ERROR 22003: BIGINT value is out of range in '-73 * -2465717823867977728' diff --git a/mysql-test/r/except.result b/mysql-test/r/except.result index fdaa625ea65..594bb7118eb 100644 --- a/mysql-test/r/except.result +++ b/mysql-test/r/except.result @@ -525,3 +525,13 @@ t3 CREATE TABLE `t3` ( `b1` blob DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop tables t1,t2,t3; +# +# MDEV-13723: Server crashes in ha_heap::find_unique_row or +# Assertion `0' failed in st_select_lex_unit::optimize with INTERSECT +# +CREATE TABLE t (i INT); +INSERT INTO t VALUES (1),(2); +SELECT * FROM t WHERE i != ANY ( SELECT 3 EXCEPT SELECT 3 ); +i +drop table t; +# End of 10.3 tests diff --git a/mysql-test/r/func_group_innodb.result b/mysql-test/r/func_group_innodb.result index 52d5922df95..e340c04107d 100644 --- a/mysql-test/r/func_group_innodb.result +++ b/mysql-test/r/func_group_innodb.result @@ -226,7 +226,7 @@ create table y select 1 b; select 1 from y group by b; 1 1 -select 1 from y group by values(b); +select 1 from y group by value(b); 1 1 drop table y; diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result index 299b6344192..982856e980a 100644 --- a/mysql-test/r/func_misc.result +++ b/mysql-test/r/func_misc.result @@ -286,11 +286,11 @@ NAME_CONST('a', -(1)) OR 1 CREATE TABLE t1 (a INT, b INT) ENGINE=MyISAM; INSERT INTO t1 VALUES (1,10); CREATE VIEW v1 AS SELECT * FROM t1; -EXPLAIN EXTENDED SELECT VALUES(b) FROM v1; +EXPLAIN EXTENDED SELECT VALUE(b) FROM v1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 Warnings: -Note 1003 select values(10) AS `VALUES(b)` from dual +Note 1003 select value(10) AS `VALUE(b)` from dual drop view v1; drop table t1; End of 5.3 tests @@ -1458,6 +1458,20 @@ CONCAT(NAME_CONST('name',15),'오') 15오 SET NAMES latin1; # +# MDEV-14116 INET6_NTOA output is set as null to varchar(39) variable +# +CREATE PROCEDURE p1() +BEGIN +DECLARE ip_full_addr varchar(39) DEFAULT ""; +SELECT INET6_NTOA(UNHEX('20000000000000000000000000000000')) into ip_full_addr; +SELECT ip_full_addr; +END; +$$ +CALL p1(); +ip_full_addr +2000:: +DROP PROCEDURE p1; +# # Start of 10.2 tests # # diff --git a/mysql-test/r/group_by_null.result b/mysql-test/r/group_by_null.result index 01053514cb0..1ae090fdc63 100644 --- a/mysql-test/r/group_by_null.result +++ b/mysql-test/r/group_by_null.result @@ -1,6 +1,6 @@ create table t1 (a int); insert into t1 values (1),(2); -select max('foo') from t1 group by values(a), extractvalue('bar','qux') order by "v"; +select max('foo') from t1 group by value(a), extractvalue('bar','qux') order by "v"; max('foo') foo drop table t1; diff --git a/mysql-test/r/having.result b/mysql-test/r/having.result index 4a429e1b119..8a8d6e7b2aa 100644 --- a/mysql-test/r/having.result +++ b/mysql-test/r/having.result @@ -727,3 +727,76 @@ A COUNT(*) DROP VIEW v1; DROP TABLE t1; End of 10.1 tests +# +# MDEV-14093: GROUP BY with HAVING over function + ORDER BY +# +CREATE TABLE _authors ( +id MEDIUMINT(8) UNSIGNED AUTO_INCREMENT, +name VARCHAR(100), +some_field MEDIUMINT(8) UNSIGNED, +PRIMARY KEY (id), +index(some_field) +); +CREATE TABLE _books ( +id MEDIUMINT(8) UNSIGNED AUTO_INCREMENT, +title VARCHAR(100), +PRIMARY KEY (id) +); +CREATE TABLE _books2authors ( +author_id MEDIUMINT(8) DEFAULT 0, +book_id MEDIUMINT(8) DEFAULT 0, +index(author_id), +index(book_id) +); +INSERT INTO _authors (name, some_field) VALUES +('author1', 1),('author2', 2),('author3', 3); +INSERT INTO _books (title) VALUES +('book1'),('book2'),('book3'); +INSERT INTO _books2authors (author_id, book_id) VALUES +(2,1),(3,2),(3,3); +SELECT A.id, +GROUP_CONCAT(B.title ORDER BY B.title DESC SEPARATOR ',') AS books, +some_field-1 AS having_field +FROM _authors A +LEFT JOIN _books2authors B2A FORCE INDEX(author_id) +ON B2A.author_id = A.id +LEFT JOIN +_books B ON B.id = B2A.book_id +GROUP BY A.id +HAVING having_field < 1 +ORDER BY having_field ASC; +id books having_field +1 NULL 0 +DROP TABLE _authors, _books, _books2authors; +# +# Bug#17055185: WRONG RESULTS WHEN RUNNING A SELECT THAT INCLUDE +# A HAVING BASED ON A FUNCTION. +# +CREATE TABLE series ( +val INT(10) UNSIGNED NOT NULL +); +INSERT INTO series VALUES(1); +CREATE FUNCTION next_seq_value() RETURNS INT +BEGIN +DECLARE next_val INT; +SELECT val INTO next_val FROM series; +UPDATE series SET val=mod(val + 1, 2); +RETURN next_val; +END; +| +CREATE TABLE t1 (t INT, u INT, KEY(t)); +INSERT INTO t1 VALUES(10, 10), (11, 11), (12, 12), (12, 13),(14, 15), (15, 16), +(16, 17), (17, 17); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT t, next_seq_value() r FROM t1 FORCE INDEX(t) +GROUP BY t HAVING r = 1 ORDER BY t1.u; +t r +10 1 +12 1 +15 1 +17 1 +DROP TABLE t1; +DROP FUNCTION next_seq_value; +DROP TABLE series; diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 6f25e264d9e..edc8794c1c5 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -588,8 +588,8 @@ select s1 from t1 where s1 in (select version from information_schema.tables) union select version from information_schema.tables; s1 -11 10 +11 drop table t1; SHOW CREATE TABLE INFORMATION_SCHEMA.character_sets; Table Create Table @@ -773,11 +773,18 @@ table_name v2 v3 select column_name from information_schema.columns -where table_schema='test'; +where table_schema='test' and table_name='t4'; column_name f1 +select column_name from information_schema.columns +where table_schema='test' and table_name='v2'; +column_name Warnings: Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +select column_name from information_schema.columns +where table_schema='test' and table_name='v3'; +column_name +Warnings: Warning 1356 View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them select index_name from information_schema.statistics where table_schema='test'; index_name @@ -842,7 +849,8 @@ drop view a2, a1; drop table t_crashme; select table_schema,table_name, column_name from information_schema.columns -where data_type = 'longtext' and table_schema != 'performance_schema'; +where data_type = 'longtext' and table_schema != 'performance_schema' +order by binary table_name, ordinal_position; table_schema table_name column_name information_schema ALL_PLUGINS PLUGIN_DESCRIPTION information_schema COLUMNS COLUMN_DEFAULT @@ -863,7 +871,8 @@ information_schema TRIGGERS ACTION_CONDITION information_schema TRIGGERS ACTION_STATEMENT information_schema VIEWS VIEW_DEFINITION select table_name, column_name, data_type from information_schema.columns -where data_type = 'datetime' and table_name not like 'innodb_%'; +where data_type = 'datetime' and table_name not like 'innodb_%' +order by binary table_name, ordinal_position; table_name column_name data_type EVENTS EXECUTE_AT datetime EVENTS STARTS datetime @@ -1278,7 +1287,7 @@ sql security definer view v2 as select 1; connect con16681,localhost,mysqltest_1,,test; connection con16681; select * from information_schema.views -where table_name='v1' or table_name='v2'; +where table_name='v1' or table_name='v2' order by table_name; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION ALGORITHM def test v1 NONE YES root@localhost DEFINER latin1 latin1_swedish_ci UNDEFINED def test v2 select 1 AS `1` NONE NO mysqltest_1@localhost DEFINER latin1 latin1_swedish_ci UNDEFINED @@ -1291,7 +1300,7 @@ set @a:= '.'; create table t1(f1 char(5)); create table t2(f1 char(5)); select concat(@a, table_name), @a, table_name -from information_schema.tables where table_schema = 'test'; +from information_schema.tables where table_schema = 'test' order by table_name; concat(@a, table_name) @a table_name .t1 . t1 .t2 . t2 @@ -1378,7 +1387,8 @@ create table t2 (f1 int(11), f2 int(11)); select table_name from information_schema.tables where table_schema = 'test' and table_name not in (select table_name from information_schema.columns -where table_schema = 'test' and column_name = 'f3'); +where table_schema = 'test' and column_name = 'f3') +order by table_name; table_name t1 t2 @@ -1387,7 +1397,7 @@ create table t1(f1 int); create view v1 as select f1+1 as a from t1; create table t2 (f1 int, f2 int); create view v2 as select f1+1 as a, f2 as b from t2; -select table_name, is_updatable from information_schema.views; +select table_name, is_updatable from information_schema.views order by table_name; table_name is_updatable v1 NO v2 YES @@ -1846,12 +1856,12 @@ rename table t2 to t3; connection default; # These statements should not be blocked by pending lock requests select table_name, column_name, data_type from information_schema.columns -where table_schema = 'test' and table_name in ('t1', 't2'); +where table_schema = 'test' and table_name in ('t1', 't2') order by table_name, column_name; table_name column_name data_type t1 i int t2 j int select table_name, auto_increment from information_schema.tables -where table_schema = 'test' and table_name in ('t1', 't2'); +where table_schema = 'test' and table_name in ('t1', 't2') order by table_name; table_name auto_increment t1 NULL t2 1 @@ -2000,7 +2010,7 @@ connect con12828477_2, localhost, root,,mysqltest; # Wait while the above RENAME is blocked. # Issue query to I_S which will open 't0' and get # blocked on 't1' because of RENAME. -select table_name, auto_increment from information_schema.tables where table_schema='mysqltest'; +select table_name, auto_increment from information_schema.tables where table_schema='mysqltest' and table_name='t0' union select table_name, auto_increment from information_schema.tables where table_schema='mysqltest' and table_name<>'t0' order by table_name; connect con12828477_3, localhost, root,,mysqltest; # Wait while the above SELECT is blocked. # diff --git a/mysql-test/r/information_schema2.result b/mysql-test/r/information_schema2.result index 7e9bdd7088f..e23e81b885c 100644 --- a/mysql-test/r/information_schema2.result +++ b/mysql-test/r/information_schema2.result @@ -11,7 +11,7 @@ create table t2 (x int); create table t3 (x int); create table t4 AS select table_name from information_schema.TABLES where table_schema = database() and table_type = 'BASE TABLE' ; delete from t4 where table_name not in (select table_name from information_schema.TABLES where table_schema = database() and table_type = 'BASE TABLE'); -select * from t4; +select * from t4 order by table_name; table_name t1 t2 diff --git a/mysql-test/r/information_schema_db.result b/mysql-test/r/information_schema_db.result index ca1ab45b98b..45ade65c502 100644 --- a/mysql-test/r/information_schema_db.result +++ b/mysql-test/r/information_schema_db.result @@ -72,14 +72,14 @@ create function f2 () returns int return (select max(i) from t2); create view v2 as select f2(); drop table t2; select table_name, table_type, table_comment from information_schema.tables -where table_schema='test'; +where table_schema='test' order by table_name; table_name table_type table_comment t1 BASE TABLE v1 VIEW VIEW v2 VIEW VIEW drop table t1; select table_name, table_type, table_comment from information_schema.tables -where table_schema='test'; +where table_schema='test' order by table_name; table_name table_type table_comment v1 VIEW VIEW v2 VIEW VIEW diff --git a/mysql-test/r/information_schema_inno.result b/mysql-test/r/information_schema_inno.result index 7755d112f8e..d952e4372ca 100644 --- a/mysql-test/r/information_schema_inno.result +++ b/mysql-test/r/information_schema_inno.result @@ -10,18 +10,18 @@ TABLE_SCHEMA= "test"; CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE def test PRIMARY test t1 PRIMARY KEY def test PRIMARY test t2 PRIMARY KEY +def test PRIMARY test t3 PRIMARY KEY def test t2_ibfk_1 test t2 FOREIGN KEY def test t2_ibfk_2 test t2 FOREIGN KEY -def test PRIMARY test t3 PRIMARY KEY def test t3_ibfk_1 test t3 FOREIGN KEY select * from information_schema.KEY_COLUMN_USAGE where TABLE_SCHEMA= "test"; CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME def test PRIMARY def test t1 id 1 NULL NULL NULL NULL def test PRIMARY def test t2 id 1 NULL NULL NULL NULL +def test PRIMARY def test t3 id 1 NULL NULL NULL NULL def test t2_ibfk_1 def test t2 t1_id 1 1 test t1 id def test t2_ibfk_2 def test t2 t1_id 1 1 test t1 id -def test PRIMARY def test t3 id 1 NULL NULL NULL NULL def test t3_ibfk_1 def test t3 id 1 1 test t2 t1_id def test t3_ibfk_1 def test t3 t2_id 2 2 test t2 id drop table t3, t2, t1; @@ -72,11 +72,12 @@ constraint fk_t1_1 foreign key (idtype) references `t-2` (id) use test; select referenced_table_schema, referenced_table_name from information_schema.key_column_usage -where constraint_schema = 'db-1'; +where constraint_schema = 'db-1' +order by referenced_table_schema, referenced_table_name; referenced_table_schema referenced_table_name NULL NULL -db-1 t-2 NULL NULL +db-1 t-2 drop database `db-1`; create table t1(id int primary key) engine = Innodb; create table t2(pid int, foreign key (pid) references t1(id)) engine = Innodb; diff --git a/mysql-test/r/information_schema_part.result b/mysql-test/r/information_schema_part.result index 081631a512f..4c0bb8908da 100644 --- a/mysql-test/r/information_schema_part.result +++ b/mysql-test/r/information_schema_part.result @@ -61,7 +61,7 @@ partition x2 values less than (5) ( subpartition x21 tablespace t1, subpartition x22 tablespace t2) ); -select * from information_schema.partitions where table_schema="test"; +select * from information_schema.partitions where table_schema="test" order by table_name, partition_name; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME def test t1 x1 x11 1 1 RANGE HASH `a` `a` + `b` 1 0 0 0 # 1024 0 # # NULL NULL default t1 def test t1 x1 x12 1 2 RANGE HASH `a` `a` + `b` 1 0 0 0 # 1024 0 # # NULL NULL default t2 diff --git a/mysql-test/r/insert_update.result b/mysql-test/r/insert_update.result index e8e6e16fe5a..68a1003ad85 100644 --- a/mysql-test/r/insert_update.result +++ b/mysql-test/r/insert_update.result @@ -49,23 +49,23 @@ a b c 5 0 30 8 9 60 INSERT t1 VALUES (2,1,11), (7,4,40) ON DUPLICATE KEY UPDATE c=c+VALUES(a); -SELECT *, VALUES(a) FROM t1; -a b c VALUES(a) +SELECT *, VALUE(a) FROM t1; +a b c VALUE(a) 1 2 10 NULL 3 4 127 NULL 5 0 30 NULL 8 9 60 NULL 2 1 11 NULL -explain extended SELECT *, VALUES(a) FROM t1; +explain extended SELECT *, VALUE(a) FROM t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Warnings: -Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,values(`test`.`t1`.`a`) AS `VALUES(a)` from `test`.`t1` -explain extended select * from t1 where values(a); +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,value(`test`.`t1`.`a`) AS `VALUE(a)` from `test`.`t1` +explain extended select * from t1 where value(a); id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where values(`test`.`t1`.`a`) +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where value(`test`.`t1`.`a`) DROP TABLE t1; create table t1(a int primary key, b int); insert into t1 values(1,1),(2,2),(3,3),(4,4),(5,5); @@ -160,8 +160,8 @@ a b c INSERT t1 SELECT a,b,c FROM t2 WHERE d=2 ON DUPLICATE KEY UPDATE c=c+VALUES(a); ERROR 23000: Column 'c' in field list is ambiguous INSERT t1 SELECT a,b,c FROM t2 WHERE d=2 ON DUPLICATE KEY UPDATE c=t1.c+VALUES(t1.a); -SELECT *, VALUES(a) FROM t1; -a b c VALUES(a) +SELECT *, VALUE(a) FROM t1; +a b c VALUE(a) 1 2 10 NULL 3 4 127 NULL 5 0 30 NULL diff --git a/mysql-test/r/intersect.result b/mysql-test/r/intersect.result index 5dfb7fb6875..7a0301a23e6 100644 --- a/mysql-test/r/intersect.result +++ b/mysql-test/r/intersect.result @@ -689,3 +689,4 @@ View Create View character_set_client collation_connection v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS (select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) union select `__3`.`c` AS `c`,`__3`.`d` AS `d` from ((select `test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2`) intersect (select `test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t3`)) `__3` union (select 4 AS `4`,4 AS `4`) latin1 latin1_swedish_ci drop view v1; drop tables t1,t2,t3; +# End of 10.3 tests diff --git a/mysql-test/r/mysql_upgrade_noengine.result b/mysql-test/r/mysql_upgrade_noengine.result index 582147d09df..cadd30d3555 100644 --- a/mysql-test/r/mysql_upgrade_noengine.result +++ b/mysql-test/r/mysql_upgrade_noengine.result @@ -2,7 +2,7 @@ install soname 'ha_blackhole'; install soname 'ha_archive'; create table t1 (a int) engine=blackhole; create table t2 (a int) engine=archive; -select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test'; +select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test' and table_name='t1'; table_catalog def table_schema test table_name t1 @@ -12,6 +12,7 @@ row_format Fixed table_rows 0 data_length 0 table_comment +select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test' and table_name='t2'; table_catalog def table_schema test table_name t2 @@ -24,7 +25,7 @@ table_comment flush tables; uninstall plugin blackhole; uninstall plugin archive; -select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test'; +select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test' and table_name='t1'; table_catalog def table_schema test table_name t1 @@ -34,6 +35,11 @@ row_format NULL table_rows NULL data_length NULL table_comment Unknown storage engine 'BLACKHOLE' +Warnings: +Level Warning +Code 1286 +Message Unknown storage engine 'BLACKHOLE' +select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test' and table_name='t2'; table_catalog def table_schema test table_name t2 @@ -46,9 +52,6 @@ table_comment Unknown storage engine 'ARCHIVE' Warnings: Level Warning Code 1286 -Message Unknown storage engine 'BLACKHOLE' -Level Warning -Code 1286 Message Unknown storage engine 'ARCHIVE' Phase 1/7: Checking and upgrading mysql database Processing databases @@ -110,7 +113,7 @@ Error : Unknown storage engine 'ARCHIVE' error : Corrupt Phase 7/7: Running 'FLUSH PRIVILEGES' OK -select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test'; +select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test' and table_name='t1'; table_catalog def table_schema test table_name t1 @@ -120,6 +123,11 @@ row_format NULL table_rows NULL data_length NULL table_comment Unknown storage engine 'BLACKHOLE' +Warnings: +Level Warning +Code 1286 +Message Unknown storage engine 'BLACKHOLE' +select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test' and table_name='t2'; table_catalog def table_schema test table_name t2 @@ -132,9 +140,6 @@ table_comment Unknown storage engine 'ARCHIVE' Warnings: Level Warning Code 1286 -Message Unknown storage engine 'BLACKHOLE' -Level Warning -Code 1286 Message Unknown storage engine 'ARCHIVE' alter table mysql.user drop column default_role, drop column max_statement_time; Phase 1/7: Checking and upgrading mysql database @@ -197,7 +202,7 @@ Error : Unknown storage engine 'ARCHIVE' error : Corrupt Phase 7/7: Running 'FLUSH PRIVILEGES' OK -select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test'; +select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test' and table_name='t1'; table_catalog def table_schema test table_name t1 @@ -207,6 +212,11 @@ row_format NULL table_rows NULL data_length NULL table_comment Unknown storage engine 'BLACKHOLE' +Warnings: +Level Warning +Code 1286 +Message Unknown storage engine 'BLACKHOLE' +select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test' and table_name='t2'; table_catalog def table_schema test table_name t2 @@ -219,9 +229,6 @@ table_comment Unknown storage engine 'ARCHIVE' Warnings: Level Warning Code 1286 -Message Unknown storage engine 'BLACKHOLE' -Level Warning -Code 1286 Message Unknown storage engine 'ARCHIVE' alter table mysql.user drop column default_role, drop column max_statement_time; Phase 1/7: Checking and upgrading mysql database @@ -259,8 +266,8 @@ mysql.vtmd_template OK Upgrading from a version before MariaDB-10.1 Phase 2/7: Installing used storage engines Checking for tables with unknown storage engine -installing plugin for 'blackhole' storage engine installing plugin for 'archive' storage engine +installing plugin for 'blackhole' storage engine Phase 3/7: Fixing views Phase 4/7: Running 'mysql_fix_privilege_tables' Phase 5/7: Fixing table and database names @@ -276,7 +283,7 @@ test.t1 OK test.t2 OK Phase 7/7: Running 'FLUSH PRIVILEGES' OK -select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test'; +select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test' and table_name='t1'; table_catalog def table_schema test table_name t1 @@ -286,6 +293,7 @@ row_format Fixed table_rows 0 data_length 0 table_comment +select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test' and table_name='t2'; table_catalog def table_schema test table_name t2 diff --git a/mysql-test/r/mysqld--help.result b/mysql-test/r/mysqld--help.result index 0037511b741..b5d68d6bee2 100644 --- a/mysql-test/r/mysqld--help.result +++ b/mysql-test/r/mysqld--help.result @@ -334,6 +334,10 @@ The following options may be given as the first argument: Specifies a directory to add to the ignore list when collecting database names from the datadir. Put a blank argument to reset the list accumulated so far. + --in-subquery-conversion-threshold[=#] + The minimum number of scalar elements in the value list + of IN predicate that triggers its conversion to IN + subquery --init-connect=name Command(s) that are executed for each new connection (unless the user has SUPER privilege) --init-file=name Read SQL commands from this file at startup @@ -475,8 +479,9 @@ The following options may be given as the first argument: file.Value can be between 0 and 11. Higher values mean more verbosity --long-query-time=# Log all queries that have taken more than long_query_time - seconds to execute to file. The argument will be treated - as a decimal value with microsecond precision + seconds to execute to the slow query log file. The + argument will be treated as a decimal value with + microsecond precision --low-priority-updates INSERT/DELETE/UPDATE has lower priority than selects --lower-case-table-names[=#] @@ -1354,6 +1359,7 @@ idle-transaction-timeout 0 idle-write-transaction-timeout 0 ignore-builtin-innodb FALSE ignore-db-dirs +in-subquery-conversion-threshold 1000 init-connect init-file (No default value) init-rpl-role MASTER @@ -1490,7 +1496,7 @@ performance-schema-max-rwlock-classes 40 performance-schema-max-rwlock-instances -1 performance-schema-max-socket-classes 10 performance-schema-max-socket-instances -1 -performance-schema-max-stage-classes 150 +performance-schema-max-stage-classes 160 performance-schema-max-statement-classes 191 performance-schema-max-table-handles -1 performance-schema-max-table-instances -1 diff --git a/mysql-test/r/opt_tvc.result b/mysql-test/r/opt_tvc.result new file mode 100644 index 00000000000..3b03bd4ffaf --- /dev/null +++ b/mysql-test/r/opt_tvc.result @@ -0,0 +1,616 @@ +create table t1 (a int, b int); +insert into t1 +values (1,2), (4,6), (9,7), +(1,1), (2,5), (7,8); +create table t2 (a int, b int, c int); +insert into t2 +values (1,2,3), (5,1,2), (4,3,7), +(8,9,0), (10,7,1), (5,5,1); +create table t3 (a int, b varchar(16), index idx(a)); +insert into t3 values +(1, "abc"), (3, "egh"), (8, "axxx"), (10, "abc"), +(2, "ccw"), (8, "wqqe"), (7, "au"), (9, "waa"), +(3, "rass"), (9, "ert"), (9, "lok"), (8, "aww"), +(1, "todd"), (3, "rew"), (8, "aww"), (3, "sw"), +(11, "llk"), (7, "rbw"), (1, "sm"), (2, "jyp"), +(4, "yq"), (5, "pled"), (12, "ligin"), (12, "toww"), +(6, "mxm"), (15, "wanone"), (9, "sunqq"), (2, "abe"); +# optimization is not used +select * from t1 where a in (1,2); +a b +1 2 +1 1 +2 5 +explain extended select * from t1 where a in (1,2); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 6 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` in (1,2) +# set minimum number of values in VALUEs list when optimization works to 2 +set @@in_subquery_conversion_threshold= 2; +# single IN-predicate in WHERE-part +select * from t1 where a in (1,2); +a b +1 2 +1 1 +2 5 +select * from t1 +where a in +( +select * +from (values (1),(2)) as tvc_0 +); +a b +1 2 +1 1 +2 5 +explain extended select * from t1 where a in (1,2); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ALL distinct_key NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join) +2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`1` +explain extended select * from t1 +where a in +( +select * +from (values (1),(2)) as tvc_0 +); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ALL distinct_key NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join) +2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`1` +# AND-condition with IN-predicates in WHERE-part +select * from t1 +where a in (1,2) and +b in (1,5); +a b +1 1 +2 5 +select * from t1 +where a in +( +select * +from (values (1),(2)) as tvc_0 +) +and b in +( +select * +from (values (1),(5)) as tvc_1 +); +a b +1 1 +2 5 +explain extended select * from t1 +where a in (1,2) and +b in (1,5); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ALL distinct_key NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join) +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 +4 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) semi join ((values (1),(5)) `tvc_1`) where `test`.`t1`.`b` = `tvc_1`.`1` +explain extended select * from t1 +where a in +( +select * +from (values (1),(2)) as tvc_0 +) +and b in +( +select * +from (values (1),(5)) as tvc_1 +); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ALL distinct_key NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join) +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 +4 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) semi join ((values (1),(5)) `tvc_1`) where `test`.`t1`.`b` = `tvc_1`.`1` +# subquery with IN-predicate +select * from t1 +where a in +( +select a +from t2 where b in (3,4) +); +a b +4 6 +select * from t1 +where a in +( +select a from t2 +where b in +( +select * +from (values (3),(4)) as tvc_0 +) +); +a b +4 6 +explain extended select * from t1 +where a in +( +select a +from t2 where b in (3,4) +); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 +2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join) +4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (3),(4)) `tvc_0` join `test`.`t2`) where `test`.`t2`.`b` = `tvc_0`.`3` +explain extended select * from t1 +where a in +( +select a from t2 +where b in +( +select * +from (values (3),(4)) as tvc_0 +) +); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 +2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join) +4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (3),(4)) `tvc_0` join `test`.`t2`) where `test`.`t2`.`b` = `tvc_0`.`3` +# derived table with IN-predicate +select * from +( +select * +from t1 +where a in (1,2) +) as dr_table; +a b +1 2 +1 1 +2 5 +select * from +( +select * +from t1 +where a in +( +select * +from (values (1),(2)) +as tvc_0 +) +) as dr_table; +a b +1 2 +1 1 +2 5 +explain extended select * from +( +select * +from t1 +where a in (1,2) +) as dr_table; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ALL distinct_key NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join) +3 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`1` +explain extended select * from +( +select * +from t1 +where a in +( +select * +from (values (1),(2)) +as tvc_0 +) +) as dr_table; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ALL distinct_key NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join) +3 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`1` +# non-recursive CTE with IN-predicate +with tvc_0 as +( +select * +from t1 +where a in (1,2) +) +select * from tvc_0; +a b +1 2 +1 1 +2 5 +select * from +( +select * +from t1 +where a in +( +select * +from (values (1),(2)) +as tvc_0 +) +) as dr_table; +a b +1 2 +1 1 +2 5 +explain extended with tvc_0 as +( +select * +from t1 +where a in (1,2) +) +select * from tvc_0; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ALL distinct_key NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join) +3 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 with tvc_0 as (/* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` in (1,2))/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`1` +explain extended select * from +( +select * +from t1 +where a in +( +select * +from (values (1),(2)) +as tvc_0 +) +) as dr_table; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ALL distinct_key NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join) +3 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`1` +# VIEW with IN-predicate +create view v1 as +select * +from t1 +where a in (1,2); +create view v2 as +select * +from t1 +where a in +( +select * +from (values (1),(2)) +as tvc_0 +) +; +select * from v1; +a b +1 2 +1 1 +2 5 +select * from v2; +a b +1 2 +1 1 +2 5 +explain extended select * from v1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ALL distinct_key NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join) +3 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`1` +explain extended select * from v2; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ALL distinct_key NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join) +3 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`1` +drop view v1,v2; +# subselect defined by derived table with IN-predicate +select * from t1 +where a in +( +select 1 +from +( +select * +from t1 +where a in (1,2) +) +as dr_table +); +a b +1 2 +1 1 +select * from t1 +where a in +( +select 1 +from +( +select * +from t1 +where a in +( +select * +from (values (1),(2)) +as tvc_0 +) +) +as dr_table +); +a b +1 2 +1 1 +explain extended select * from t1 +where a in +( +select 1 +from +( +select * +from t1 +where a in (1,2) +) +as dr_table +); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 +2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +2 MATERIALIZED t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join) +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0` join `test`.`t1`) where `test`.`t1`.`a` = 1 and `test`.`t1`.`a` = `tvc_0`.`1` +explain extended select * from t1 +where a in +( +select 1 +from +( +select * +from t1 +where a in +( +select * +from (values (1),(2)) +as tvc_0 +) +) +as dr_table +); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 +2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +2 MATERIALIZED t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join) +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0` join `test`.`t1`) where `test`.`t1`.`a` = 1 and `test`.`t1`.`a` = `tvc_0`.`1` +# derived table with IN-predicate and group by +select * from +( +select max(a),b +from t1 +where b in (3,5) +group by b +) as dr_table; +max(a) b +2 5 +select * from +( +select max(a),b +from t1 +where b in +( +select * +from (values (3),(5)) +as tvc_0 +) +group by b +) as dr_table; +max(a) b +2 5 +explain extended select * from +( +select max(a),b +from t1 +where b in (3,5) +group by b +) as dr_table; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ALL NULL NULL NULL NULL 12 100.00 +2 DERIVED t1 ALL NULL NULL NULL NULL 6 100.00 Using temporary; Using filesort +2 DERIVED eq_ref distinct_key distinct_key 4 func 1 100.00 +3 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `dr_table`.`max(a)` AS `max(a)`,`dr_table`.`b` AS `b` from (/* select#2 */ select max(`test`.`t1`.`a`) AS `max(a)`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (3),(5)) `tvc_0`) where 1 group by `test`.`t1`.`b`) `dr_table` +explain extended select * from +( +select max(a),b +from t1 +where b in +( +select * +from (values (3),(5)) +as tvc_0 +) +group by b +) as dr_table; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ALL NULL NULL NULL NULL 12 100.00 +2 DERIVED t1 ALL NULL NULL NULL NULL 6 100.00 Using temporary; Using filesort +2 DERIVED eq_ref distinct_key distinct_key 4 func 1 100.00 +3 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `dr_table`.`max(a)` AS `max(a)`,`dr_table`.`b` AS `b` from (/* select#2 */ select max(`test`.`t1`.`a`) AS `max(a)`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (3),(5)) `tvc_0`) where 1 group by `test`.`t1`.`b`) `dr_table` +# prepare statement +prepare stmt from "select * from t1 where a in (1,2)"; +execute stmt; +a b +1 2 +1 1 +2 5 +execute stmt; +a b +1 2 +1 1 +2 5 +deallocate prepare stmt; +# use inside out access from tvc rows +set @@in_subquery_conversion_threshold= default; +select * from t3 where a in (1,4,10); +a b +1 abc +1 todd +1 sm +4 yq +10 abc +explain extended select * from t3 where a in (1,4,10); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 range idx idx 5 NULL 5 100.00 Using index condition +Warnings: +Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where `test`.`t3`.`a` in (1,4,10) +set @@in_subquery_conversion_threshold= 2; +select * from t3 where a in (1,4,10); +a b +1 abc +1 todd +1 sm +4 yq +10 abc +explain extended select * from t3 where a in (1,4,10); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ALL distinct_key NULL NULL NULL 2 100.00 +1 PRIMARY t3 ref idx idx 5 tvc_0.1 3 100.00 +2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` semi join ((values (1),(4),(10)) `tvc_0`) where `test`.`t3`.`a` = `tvc_0`.`1` +# use vectors in IN predeicate +set @@in_subquery_conversion_threshold= 4; +select * from t1 where (a,b) in ((1,2),(3,4)); +a b +1 2 +explain extended select * from t1 where (a,b) in ((1,2),(3,4)); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ALL distinct_key NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join) +2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1,2),(3,4)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`1` and `test`.`t1`.`b` = `tvc_0`.`2` +set @@in_subquery_conversion_threshold= 2; +# trasformation works for the one IN predicate and doesn't work for the other +set @@in_subquery_conversion_threshold= 5; +select * from t2 +where (a,b) in ((1,2),(8,9)) and +(a,c) in ((1,3),(8,0),(5,1)); +a b c +1 2 3 +8 9 0 +explain extended select * from t2 +where (a,b) in ((1,2),(8,9)) and +(a,c) in ((1,3),(8,0),(5,1)); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ALL distinct_key NULL NULL NULL 2 100.00 +1 PRIMARY t2 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join) +2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` semi join ((values (1,3),(8,0),(5,1)) `tvc_0`) where `test`.`t2`.`a` = `tvc_0`.`1` and `test`.`t2`.`c` = `tvc_0`.`3` and (`tvc_0`.`1`,`test`.`t2`.`b`) in (((1,2)),((8,9))) +set @@in_subquery_conversion_threshold= 2; +# +# mdev-14281: conversion of NOT IN predicate into subquery predicate +# +select * from t1 +where (a,b) not in ((1,2),(8,9), (5,1)); +a b +4 6 +9 7 +1 1 +2 5 +7 8 +select * from t1 +where (a,b) not in (select * from (values (1,2),(8,9), (5,1)) as tvc_0); +a b +4 6 +9 7 +1 1 +2 5 +7 8 +explain extended select * from t1 +where (a,b) not in ((1,2),(8,9), (5,1)); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<`test`.`t1`.`a`,`test`.`t1`.`b`>(((`test`.`t1`.`a`,`test`.`t1`.`b`),(`test`.`t1`.`a`,`test`.`t1`.`b`) in ( (/* select#2 */ select `tvc_0`.`1`,`tvc_0`.`2` from (values (1,2),(8,9),(5,1)) `tvc_0` ), (`test`.`t1`.`a` in on distinct_key where `test`.`t1`.`a` = ``.`1` and `test`.`t1`.`b` = ``.`2`)))) +explain extended select * from t1 +where (a,b) not in (select * from (values (1,2),(8,9), (5,1)) as tvc_0); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<`test`.`t1`.`a`,`test`.`t1`.`b`>(((`test`.`t1`.`a`,`test`.`t1`.`b`),(`test`.`t1`.`a`,`test`.`t1`.`b`) in ( (/* select#2 */ select `tvc_0`.`1`,`tvc_0`.`2` from (values (1,2),(8,9),(5,1)) `tvc_0` ), (`test`.`t1`.`a` in on distinct_key where `test`.`t1`.`a` = ``.`1` and `test`.`t1`.`b` = ``.`2`)))) +select * from t1 +where b < 7 and (a,b) not in ((1,2),(8,9), (5,1)); +a b +4 6 +1 1 +2 5 +explain extended select * from t1 +where b < 7 and (a,b) not in ((1,2),(8,9), (5,1)); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` < 7 and !<`test`.`t1`.`a`,`test`.`t1`.`b`>(((`test`.`t1`.`a`,`test`.`t1`.`b`),(`test`.`t1`.`a`,`test`.`t1`.`b`) in ( (/* select#2 */ select `tvc_0`.`1`,`tvc_0`.`2` from (values (1,2),(8,9),(5,1)) `tvc_0` ), (`test`.`t1`.`a` in on distinct_key where `test`.`t1`.`a` = ``.`1` and `test`.`t1`.`b` = ``.`2`)))) +select * from t2 +where (a,c) not in ((1,2),(8,9), (5,1)); +a b c +1 2 3 +5 1 2 +4 3 7 +8 9 0 +10 7 1 +explain extended select * from t2 +where (a,c) not in ((1,2),(8,9), (5,1)); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 ALL NULL NULL NULL NULL 6 100.00 Using where +2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where !<`test`.`t2`.`a`,`test`.`t2`.`c`>(((`test`.`t2`.`a`,`test`.`t2`.`c`),(`test`.`t2`.`a`,`test`.`t2`.`c`) in ( (/* select#2 */ select `tvc_0`.`1`,`tvc_0`.`2` from (values (1,2),(8,9),(5,1)) `tvc_0` ), (`test`.`t2`.`a` in on distinct_key where `test`.`t2`.`a` = ``.`1` and `test`.`t2`.`c` = ``.`2`)))) +drop table t1, t2, t3; +set @@in_subquery_conversion_threshold= default; diff --git a/mysql-test/r/partition_exchange.result b/mysql-test/r/partition_exchange.result index f37ba183560..3bce5aec8e2 100644 --- a/mysql-test/r/partition_exchange.result +++ b/mysql-test/r/partition_exchange.result @@ -40,7 +40,8 @@ Create Table CREATE TABLE `t2` ( ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT SELECT TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, CREATE_OPTIONS FROM INFORMATION_SCHEMA.TABLES -WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2'); +WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2') +ORDER BY TABLE_NAME; TABLE_NAME t1 TABLE_TYPE BASE TABLE ENGINE InnoDB @@ -76,7 +77,8 @@ Create Table CREATE TABLE `t2` ( ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT SELECT TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, CREATE_OPTIONS FROM INFORMATION_SCHEMA.TABLES -WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2'); +WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2') +ORDER BY TABLE_NAME; TABLE_NAME t1 TABLE_TYPE BASE TABLE ENGINE InnoDB @@ -124,7 +126,8 @@ Create Table CREATE TABLE `t2` ( ) ENGINE=InnoDB DEFAULT CHARSET=latin1 SELECT TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, CREATE_OPTIONS FROM INFORMATION_SCHEMA.TABLES -WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2'); +WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2') +ORDER BY TABLE_NAME; TABLE_NAME t1 TABLE_TYPE BASE TABLE ENGINE InnoDB @@ -184,7 +187,8 @@ Create Table CREATE TABLE `t2` ( ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT SELECT TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, CREATE_OPTIONS FROM INFORMATION_SCHEMA.TABLES -WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2'); +WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2') +ORDER BY TABLE_NAME; TABLE_NAME t1 TABLE_TYPE BASE TABLE ENGINE InnoDB @@ -244,7 +248,8 @@ Create Table CREATE TABLE `t2` ( ) ENGINE=InnoDB DEFAULT CHARSET=latin1 SELECT TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, CREATE_OPTIONS FROM INFORMATION_SCHEMA.TABLES -WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2'); +WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2') +ORDER BY TABLE_NAME; TABLE_NAME t1 TABLE_TYPE BASE TABLE ENGINE InnoDB @@ -304,7 +309,8 @@ Create Table CREATE TABLE `t2` ( ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=REDUNDANT SELECT TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, CREATE_OPTIONS FROM INFORMATION_SCHEMA.TABLES -WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2'); +WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2') +ORDER BY TABLE_NAME; TABLE_NAME t1 TABLE_TYPE BASE TABLE ENGINE InnoDB @@ -361,7 +367,8 @@ Create Table CREATE TABLE `t2` ( ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=REDUNDANT SELECT TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, CREATE_OPTIONS FROM INFORMATION_SCHEMA.TABLES -WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2'); +WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2') +ORDER BY TABLE_NAME; TABLE_NAME t1 TABLE_TYPE BASE TABLE ENGINE InnoDB @@ -418,7 +425,8 @@ Create Table CREATE TABLE `t2` ( ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=REDUNDANT SELECT TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, CREATE_OPTIONS FROM INFORMATION_SCHEMA.TABLES -WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2'); +WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2') +ORDER BY TABLE_NAME; TABLE_NAME t1 TABLE_TYPE BASE TABLE ENGINE InnoDB diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index f16d2928c2e..86d0f959edc 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -4795,7 +4795,7 @@ EXECUTE IMMEDIATE MAX('SELECT 1 AS c'); ERROR HY000: Invalid use of group function EXECUTE IMMEDIATE DEFAULT(a); ERROR 42S22: Unknown column 'a' in 'field list' -EXECUTE IMMEDIATE VALUES(a); +EXECUTE IMMEDIATE VALUE(a); ERROR 42S22: Unknown column 'a' in 'field list' CREATE FUNCTION f1() RETURNS VARCHAR(64) RETURN 't1'; EXECUTE IMMEDIATE f1(); diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index 735a0069ba0..80aef096828 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -1,3 +1,4 @@ +set in_subquery_conversion_threshold=10000; drop table if exists t1, t2, t3, t10, t100; CREATE TABLE t1 ( event_date date DEFAULT '0000-00-00' NOT NULL, @@ -3006,3 +3007,4 @@ drop table t1,t2,t3; # # End of 10.2 tests # +set in_subquery_conversion_threshold=default; diff --git a/mysql-test/r/range_mrr_icp.result b/mysql-test/r/range_mrr_icp.result index afce3c66c21..b0672eed54e 100644 --- a/mysql-test/r/range_mrr_icp.result +++ b/mysql-test/r/range_mrr_icp.result @@ -1,5 +1,6 @@ set @mrr_icp_extra_tmp=@@optimizer_switch; set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +set in_subquery_conversion_threshold=10000; drop table if exists t1, t2, t3, t10, t100; CREATE TABLE t1 ( event_date date DEFAULT '0000-00-00' NOT NULL, @@ -3018,4 +3019,5 @@ drop table t1,t2,t3; # # End of 10.2 tests # +set in_subquery_conversion_threshold=default; set optimizer_switch=@mrr_icp_extra_tmp; diff --git a/mysql-test/r/selectivity.result b/mysql-test/r/selectivity.result index 79b46183b60..7400dff3958 100644 --- a/mysql-test/r/selectivity.result +++ b/mysql-test/r/selectivity.result @@ -400,7 +400,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 SUBQUERY customer ALL NULL NULL NULL NULL 150 100.00 Using where Warnings: Note 1276 Field or reference 'dbt3_s001.customer.c_custkey' of SELECT #4 was resolved in SELECT #2 -Note 1003 /* select#1 */ select substr(`dbt3_s001`.`customer`.`c_phone`,1,2) AS `cntrycode`,count(0) AS `numcust`,sum(`dbt3_s001`.`customer`.`c_acctbal`) AS `totacctbal` from `dbt3_s001`.`customer` where substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25') and `dbt3_s001`.`customer`.`c_acctbal` > (/* select#3 */ select avg(`dbt3_s001`.`customer`.`c_acctbal`) from `dbt3_s001`.`customer` where `dbt3_s001`.`customer`.`c_acctbal` > 0.00 and substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25')) and !(1,exists(/* select#4 */ select 1 from `dbt3_s001`.`orders` where `dbt3_s001`.`orders`.`o_custkey` = `dbt3_s001`.`customer`.`c_custkey`)) group by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) order by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) +Note 1003 /* select#1 */ select substr(`dbt3_s001`.`customer`.`c_phone`,1,2) AS `cntrycode`,count(0) AS `numcust`,sum(`dbt3_s001`.`customer`.`c_acctbal`) AS `totacctbal` from `dbt3_s001`.`customer` where substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25') and `dbt3_s001`.`customer`.`c_acctbal` > (/* select#3 */ select avg(`dbt3_s001`.`customer`.`c_acctbal`) from `dbt3_s001`.`customer` where `dbt3_s001`.`customer`.`c_acctbal` > 0.00 and substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25')) and !(1,<`dbt3_s001`.`customer`.`c_custkey`>(exists(/* select#4 */ select 1 from `dbt3_s001`.`orders` where `dbt3_s001`.`orders`.`o_custkey` = `dbt3_s001`.`customer`.`c_custkey`))) group by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) order by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) select cntrycode, count(*) as numcust, sum(c_acctbal) as totacctbal from ( select substr(c_phone, 1, 2) as cntrycode, c_acctbal @@ -441,7 +441,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 SUBQUERY customer ALL NULL NULL NULL NULL 150 91.00 Using where Warnings: Note 1276 Field or reference 'dbt3_s001.customer.c_custkey' of SELECT #4 was resolved in SELECT #2 -Note 1003 /* select#1 */ select substr(`dbt3_s001`.`customer`.`c_phone`,1,2) AS `cntrycode`,count(0) AS `numcust`,sum(`dbt3_s001`.`customer`.`c_acctbal`) AS `totacctbal` from `dbt3_s001`.`customer` where substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25') and `dbt3_s001`.`customer`.`c_acctbal` > (/* select#3 */ select avg(`dbt3_s001`.`customer`.`c_acctbal`) from `dbt3_s001`.`customer` where `dbt3_s001`.`customer`.`c_acctbal` > 0.00 and substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25')) and !(1,exists(/* select#4 */ select 1 from `dbt3_s001`.`orders` where `dbt3_s001`.`orders`.`o_custkey` = `dbt3_s001`.`customer`.`c_custkey`)) group by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) order by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) +Note 1003 /* select#1 */ select substr(`dbt3_s001`.`customer`.`c_phone`,1,2) AS `cntrycode`,count(0) AS `numcust`,sum(`dbt3_s001`.`customer`.`c_acctbal`) AS `totacctbal` from `dbt3_s001`.`customer` where substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25') and `dbt3_s001`.`customer`.`c_acctbal` > (/* select#3 */ select avg(`dbt3_s001`.`customer`.`c_acctbal`) from `dbt3_s001`.`customer` where `dbt3_s001`.`customer`.`c_acctbal` > 0.00 and substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25')) and !(1,<`dbt3_s001`.`customer`.`c_custkey`>(exists(/* select#4 */ select 1 from `dbt3_s001`.`orders` where `dbt3_s001`.`orders`.`o_custkey` = `dbt3_s001`.`customer`.`c_custkey`))) group by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) order by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) select cntrycode, count(*) as numcust, sum(c_acctbal) as totacctbal from ( select substr(c_phone, 1, 2) as cntrycode, c_acctbal diff --git a/mysql-test/r/selectivity_innodb.result b/mysql-test/r/selectivity_innodb.result index 71657288c66..960a873c854 100644 --- a/mysql-test/r/selectivity_innodb.result +++ b/mysql-test/r/selectivity_innodb.result @@ -403,7 +403,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 SUBQUERY customer ALL NULL NULL NULL NULL 150 100.00 Using where Warnings: Note 1276 Field or reference 'dbt3_s001.customer.c_custkey' of SELECT #4 was resolved in SELECT #2 -Note 1003 /* select#1 */ select substr(`dbt3_s001`.`customer`.`c_phone`,1,2) AS `cntrycode`,count(0) AS `numcust`,sum(`dbt3_s001`.`customer`.`c_acctbal`) AS `totacctbal` from `dbt3_s001`.`customer` where substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25') and `dbt3_s001`.`customer`.`c_acctbal` > (/* select#3 */ select avg(`dbt3_s001`.`customer`.`c_acctbal`) from `dbt3_s001`.`customer` where `dbt3_s001`.`customer`.`c_acctbal` > 0.00 and substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25')) and !(1,exists(/* select#4 */ select 1 from `dbt3_s001`.`orders` where `dbt3_s001`.`orders`.`o_custkey` = `dbt3_s001`.`customer`.`c_custkey`)) group by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) order by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) +Note 1003 /* select#1 */ select substr(`dbt3_s001`.`customer`.`c_phone`,1,2) AS `cntrycode`,count(0) AS `numcust`,sum(`dbt3_s001`.`customer`.`c_acctbal`) AS `totacctbal` from `dbt3_s001`.`customer` where substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25') and `dbt3_s001`.`customer`.`c_acctbal` > (/* select#3 */ select avg(`dbt3_s001`.`customer`.`c_acctbal`) from `dbt3_s001`.`customer` where `dbt3_s001`.`customer`.`c_acctbal` > 0.00 and substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25')) and !(1,<`dbt3_s001`.`customer`.`c_custkey`>(exists(/* select#4 */ select 1 from `dbt3_s001`.`orders` where `dbt3_s001`.`orders`.`o_custkey` = `dbt3_s001`.`customer`.`c_custkey`))) group by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) order by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) select cntrycode, count(*) as numcust, sum(c_acctbal) as totacctbal from ( select substr(c_phone, 1, 2) as cntrycode, c_acctbal @@ -444,7 +444,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 SUBQUERY customer ALL NULL NULL NULL NULL 150 91.00 Using where Warnings: Note 1276 Field or reference 'dbt3_s001.customer.c_custkey' of SELECT #4 was resolved in SELECT #2 -Note 1003 /* select#1 */ select substr(`dbt3_s001`.`customer`.`c_phone`,1,2) AS `cntrycode`,count(0) AS `numcust`,sum(`dbt3_s001`.`customer`.`c_acctbal`) AS `totacctbal` from `dbt3_s001`.`customer` where substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25') and `dbt3_s001`.`customer`.`c_acctbal` > (/* select#3 */ select avg(`dbt3_s001`.`customer`.`c_acctbal`) from `dbt3_s001`.`customer` where `dbt3_s001`.`customer`.`c_acctbal` > 0.00 and substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25')) and !(1,exists(/* select#4 */ select 1 from `dbt3_s001`.`orders` where `dbt3_s001`.`orders`.`o_custkey` = `dbt3_s001`.`customer`.`c_custkey`)) group by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) order by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) +Note 1003 /* select#1 */ select substr(`dbt3_s001`.`customer`.`c_phone`,1,2) AS `cntrycode`,count(0) AS `numcust`,sum(`dbt3_s001`.`customer`.`c_acctbal`) AS `totacctbal` from `dbt3_s001`.`customer` where substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25') and `dbt3_s001`.`customer`.`c_acctbal` > (/* select#3 */ select avg(`dbt3_s001`.`customer`.`c_acctbal`) from `dbt3_s001`.`customer` where `dbt3_s001`.`customer`.`c_acctbal` > 0.00 and substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25')) and !(1,<`dbt3_s001`.`customer`.`c_custkey`>(exists(/* select#4 */ select 1 from `dbt3_s001`.`orders` where `dbt3_s001`.`orders`.`o_custkey` = `dbt3_s001`.`customer`.`c_custkey`))) group by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) order by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) select cntrycode, count(*) as numcust, sum(c_acctbal) as totacctbal from ( select substr(c_phone, 1, 2) as cntrycode, c_acctbal diff --git a/mysql-test/r/show_explain_ps.result b/mysql-test/r/show_explain_ps.result index 71c8f117fa2..fae432e830e 100644 --- a/mysql-test/r/show_explain_ps.result +++ b/mysql-test/r/show_explain_ps.result @@ -4,7 +4,7 @@ drop table if exists t0, t1; select * from performance_schema.setup_instruments where name like '%show_explain%'; NAME ENABLED TIMED wait/synch/cond/sql/show_explain YES YES -stage/sql/show explain YES YES +stage/sql/Show explain YES YES statement/sql/show_explain YES YES # We've got no instances select * from performance_schema.cond_instances where name like '%show_explain%'; @@ -38,5 +38,5 @@ thread_id in(select thread_id from performance_schema.events_statements_history_long where EVENT_NAME='statement/sql/show_explain'); event_name -stage/sql/show explain +stage/sql/Show explain drop table t0; diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index cb2237699fb..b66faec260f 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -4440,7 +4440,7 @@ create table t3 (id int not null primary key, county varchar(25))| insert into t3 (id, county) values (1, 'York')| create procedure bug15441(c varchar(25)) begin -update t3 set id=2, county=values(c); +update t3 set id=2, county=value(c); end| call bug15441('county')| ERROR 42S22: Unknown column 'c' in 'field list' @@ -4451,7 +4451,7 @@ declare c varchar(25) default "hello"; insert into t3 (id, county) values (1, county) on duplicate key update county= values(county); select * from t3; -update t3 set id=2, county=values(id); +update t3 set id=2, county=value(id); select * from t3; end| call bug15441('Yale')| @@ -4810,8 +4810,8 @@ select routine_name,routine_schema from information_schema.routines where routine_schema like 'bug18344%'| routine_name routine_schema bug18344 bug18344_012345678901 -bug18344_2 bug18344_012345678901 bug18344 bug18344_0123456789012 +bug18344_2 bug18344_012345678901 bug18344_2 bug18344_0123456789012 drop database bug18344_012345678901| drop database bug18344_0123456789012| diff --git a/mysql-test/r/status.result b/mysql-test/r/status.result index 9a8a5bd8f93..9b82c7896cb 100644 --- a/mysql-test/r/status.result +++ b/mysql-test/r/status.result @@ -386,6 +386,29 @@ Handler_tmp_write 2 Handler_update 0 Handler_write 0 drop table t1; +# +# MDEV-11153 - Introduce status variables for table cache monitoring and +# tuning +# +SET @old_table_open_cache= @@table_open_cache; +SET @@global.table_open_cache=10; +FLUSH TABLES; +FLUSH STATUS; +SHOW STATUS LIKE 'Table_open_cache%'; +Variable_name Value +Table_open_cache_active_instances 1 +Table_open_cache_hits 0 +Table_open_cache_misses 0 +Table_open_cache_overflows 0 +SHOW STATUS LIKE 'Table_open_cache%'; +Variable_name Value +Table_open_cache_active_instances 1 +Table_open_cache_hits 30 +Table_open_cache_misses 15 +Table_open_cache_overflows 5 +FLUSH TABLES; +FLUSH STATUS; +SET @@global.table_open_cache= @old_table_open_cache; connection default; set @@global.concurrent_insert= @old_concurrent_insert; SET GLOBAL log_output = @old_log_output; diff --git a/mysql-test/r/subselect_exists2in.result b/mysql-test/r/subselect_exists2in.result index 8b525436c2f..95fc1c19b82 100644 --- a/mysql-test/r/subselect_exists2in.result +++ b/mysql-test/r/subselect_exists2in.result @@ -934,5 +934,42 @@ f2 foo set optimizer_switch= @optimizer_switch_save; DROP TABLE t1; +# +# MDEV-14164: Unknown column error when adding aggregate to function +# in oracle style procedure FOR loop +# +CREATE TABLE t1(id INT, val INT); +CREATE PROCEDURE p1() +BEGIN +DECLARE cur1 CURSOR FOR SELECT * FROM ( +SELECT DISTINCT id FROM t1) a +WHERE NOT EXISTS (SELECT * FROM ( SELECT id FROM t1) b +WHERE a.id=b.id); +OPEN cur1; +CLOSE cur1; +OPEN cur1; +CLOSE cur1; +END; +// +CALL p1(); +DROP PROCEDURE p1; +DROP TABLE t1; +CREATE TABLE t1(id INT, val INT); +CREATE PROCEDURE p1() +BEGIN +SELECT * FROM (SELECT DISTINCT id FROM t1) a +WHERE NOT a.id IN (SELECT b.id FROM t1 b); +SELECT * FROM (SELECT DISTINCT id FROM t1) a +WHERE NOT EXISTS (SELECT * FROM t1 b WHERE a.id=b.id); +END; +// +CALL p1(); +id +id +CALL p1(); +id +id +DROP PROCEDURE p1; +DROP TABLE t1; # End of 10.0 tests set optimizer_switch=default; diff --git a/mysql-test/r/subselect_sj.result b/mysql-test/r/subselect_sj.result index a601dac5337..9631192da33 100644 --- a/mysql-test/r/subselect_sj.result +++ b/mysql-test/r/subselect_sj.result @@ -2800,8 +2800,8 @@ CREATE TABLE t1 (db VARCHAR(64) DEFAULT NULL); INSERT INTO t1 VALUES ('mysql'),('information_schema'); SELECT * FROM t1 WHERE db IN (SELECT `SCHEMA_NAME` FROM information_schema.SCHEMATA); db -mysql information_schema +mysql DROP TABLE t1; # # MDEV-5581: Server crashes in in JOIN::prepare on 2nd execution of PS with materialization+semijoin diff --git a/mysql-test/r/table_elim.result b/mysql-test/r/table_elim.result index 04a9b47b6c9..cf9a4a38779 100644 --- a/mysql-test/r/table_elim.result +++ b/mysql-test/r/table_elim.result @@ -143,7 +143,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT SUBQUERY t2 ref PRIMARY PRIMARY 4 test.a2.id 2 100.00 Using index Warnings: Note 1276 Field or reference 'test.a2.id' of SELECT #3 was resolved in SELECT #2 -Note 1003 /* select#1 */ select `f`.`id` AS `id` from `test`.`t0` `f` join `test`.`t2` `a2` where `f`.`id` = `a2`.`id` and `a2`.`attr2` between 12 and 14 and `a2`.`fromdate` = (/* select#3 */ select max(`test`.`t2`.`fromdate`) from `test`.`t2` where `test`.`t2`.`id` = `a2`.`id`) +Note 1003 /* select#1 */ select `f`.`id` AS `id` from `test`.`t0` `f` join `test`.`t2` `a2` where `f`.`id` = `a2`.`id` and `a2`.`attr2` between 12 and 14 and `a2`.`fromdate` = <`a2`.`id`>((/* select#3 */ select max(`test`.`t2`.`fromdate`) from `test`.`t2` where `test`.`t2`.`id` = `a2`.`id`)) This should use one table: explain select id from v2 where id=2; id select_type table type possible_keys key key_len ref rows Extra @@ -171,7 +171,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT SUBQUERY t2 ref PRIMARY PRIMARY 4 test.f.id 2 100.00 Using index Warnings: Note 1276 Field or reference 'test.f.id' of SELECT #3 was resolved in SELECT #2 -Note 1003 /* select#1 */ select `f`.`id` AS `id` from `test`.`t0` `f` join `test`.`t2` `a2` where `f`.`id` = `a2`.`id` and `a2`.`attr2` between 12 and 14 and `a2`.`fromdate` = (/* select#3 */ select max(`test`.`t2`.`fromdate`) from `test`.`t2` where `test`.`t2`.`id` = `f`.`id`) +Note 1003 /* select#1 */ select `f`.`id` AS `id` from `test`.`t0` `f` join `test`.`t2` `a2` where `f`.`id` = `a2`.`id` and `a2`.`attr2` between 12 and 14 and `a2`.`fromdate` = <`f`.`id`>((/* select#3 */ select max(`test`.`t2`.`fromdate`) from `test`.`t2` where `test`.`t2`.`id` = `f`.`id`)) drop view v1, v2; drop table t0, t1, t2; create table t1 (a int); diff --git a/mysql-test/r/table_value_constr.result b/mysql-test/r/table_value_constr.result new file mode 100644 index 00000000000..39caba331ef --- /dev/null +++ b/mysql-test/r/table_value_constr.result @@ -0,0 +1,2073 @@ +create table t1 (a int, b int); +insert into t1 values (1,2),(4,6),(9,7), +(1,1),(2,5),(7,8); +# just VALUES +values (1,2); +1 2 +1 2 +values (1,2), (3,4), (5.6,0); +1 2 +1.0 2 +3.0 4 +5.6 0 +values ("abc", "def"); +abc def +abc def +# UNION that uses VALUES structure(s) +select 1,2 +union +values (1,2); +1 2 +1 2 +values (1,2) +union +select 1,2; +1 2 +1 2 +select 1,2 +union +values (1,2),(3,4),(5,6),(7,8); +1 2 +1 2 +3 4 +5 6 +7 8 +select 3,7 +union +values (1,2),(3,4),(5,6); +3 7 +3 7 +1 2 +3 4 +5 6 +select 3,7,4 +union +values (1,2,5),(4,5,6); +3 7 4 +3 7 4 +1 2 5 +4 5 6 +select 1,2 +union +values (1,7),(3,6.5); +1 2 +1 2.0 +1 7.0 +3 6.5 +select 1,2 +union +values (1,2.0),(3,6); +1 2 +1 2.0 +3 6.0 +select 1.8,2 +union +values (1,2),(3,6); +1.8 2 +1.8 2 +1.0 2 +3.0 6 +values (1,2.4),(3,6) +union +select 2.8,9; +1 2.4 +1.0 2.4 +3.0 6.0 +2.8 9.0 +values (1,2),(3,4),(5,6),(7,8) +union +select 5,6; +1 2 +1 2 +3 4 +5 6 +7 8 +select "ab","cdf" +union +values ("al","zl"),("we","q"); +ab cdf +ab cdf +al zl +we q +values ("ab", "cdf") +union +select "ab","cdf"; +ab cdf +ab cdf +values (1,2) +union +values (1,2),(5,6); +1 2 +1 2 +5 6 +values (1,2) +union +values (3,4),(5,6); +1 2 +1 2 +3 4 +5 6 +values (1,2) +union +values (1,2) +union values (4,5); +1 2 +1 2 +4 5 +# UNION ALL that uses VALUES structure +values (1,2),(3,4) +union all +select 5,6; +1 2 +1 2 +3 4 +5 6 +values (1,2),(3,4) +union all +select 1,2; +1 2 +1 2 +3 4 +1 2 +select 5,6 +union all +values (1,2),(3,4); +5 6 +5 6 +1 2 +3 4 +select 1,2 +union all +values (1,2),(3,4); +1 2 +1 2 +1 2 +3 4 +values (1,2) +union all +values (1,2),(5,6); +1 2 +1 2 +1 2 +5 6 +values (1,2) +union all +values (3,4),(5,6); +1 2 +1 2 +3 4 +5 6 +values (1,2) +union all +values (1,2) +union all +values (4,5); +1 2 +1 2 +1 2 +4 5 +values (1,2) +union all +values (1,2) +union values (1,2); +1 2 +1 2 +values (1,2) +union +values (1,2) +union all +values (1,2); +1 2 +1 2 +1 2 +# EXCEPT that uses VALUES structure(s) +select 1,2 +except +values (3,4),(5,6); +1 2 +1 2 +select 1,2 +except +values (1,2),(3,4); +1 2 +values (1,2),(3,4) +except +select 5,6; +1 2 +1 2 +3 4 +values (1,2),(3,4) +except +select 1,2; +1 2 +3 4 +values (1,2),(3,4) +except +values (5,6); +1 2 +1 2 +3 4 +values (1,2),(3,4) +except +values (1,2); +1 2 +3 4 +# INTERSECT that uses VALUES structure(s) +select 1,2 +intersect +values (3,4),(5,6); +1 2 +select 1,2 +intersect +values (1,2),(3,4); +1 2 +1 2 +values (1,2),(3,4) +intersect +select 5,6; +1 2 +values (1,2),(3,4) +intersect +select 1,2; +1 2 +1 2 +values (1,2),(3,4) +intersect +values (5,6); +1 2 +values (1,2),(3,4) +intersect +values (1,2); +1 2 +1 2 +# combination of different structures that uses VALUES structures : UNION + EXCEPT +values (1,2),(3,4) +except +select 1,2 +union values (1,2); +1 2 +1 2 +3 4 +values (1,2),(3,4) +except +values (1,2) +union +values (1,2); +1 2 +1 2 +3 4 +values (1,2),(3,4) +except +values (1,2) +union +values (3,4); +1 2 +3 4 +values (1,2),(3,4) +union +values (1,2) +except +values (1,2); +1 2 +3 4 +# combination of different structures that uses VALUES structures : UNION ALL + EXCEPT +values (1,2),(3,4) +except +select 1,2 +union all +values (1,2); +1 2 +1 2 +3 4 +values (1,2),(3,4) +except +values (1,2) +union all +values (1,2); +1 2 +1 2 +3 4 +values (1,2),(3,4) +except +values (1,2) +union all +values (3,4); +1 2 +3 4 +3 4 +values (1,2),(3,4) +union all +values (1,2) +except +values (1,2); +1 2 +3 4 +# combination of different structures that uses VALUES structures : UNION + INTERSECT +values (1,2),(3,4) +intersect +select 1,2 +union +values (1,2); +1 2 +1 2 +values (1,2),(3,4) +intersect +values (1,2) +union +values (1,2); +1 2 +1 2 +values (1,2),(3,4) +intersect +values (1,2) +union +values (3,4); +1 2 +1 2 +3 4 +values (1,2),(3,4) +union +values (1,2) +intersect +values (1,2); +1 2 +1 2 +3 4 +# combination of different structures that uses VALUES structures : UNION ALL + INTERSECT +values (1,2),(3,4) +intersect +select 1,2 +union all +values (1,2); +1 2 +1 2 +1 2 +values (1,2),(3,4) +intersect +values (1,2) +union all +values (1,2); +1 2 +1 2 +1 2 +values (1,2),(3,4) +intersect +values (1,2) +union all +values (3,4); +1 2 +1 2 +3 4 +values (1,2),(3,4) +union all +values (1,2) +intersect +values (1,2); +1 2 +1 2 +3 4 +1 2 +# combination of different structures that uses VALUES structures : UNION + UNION ALL +values (1,2),(3,4) +union all +select 1,2 +union +values (1,2); +1 2 +1 2 +3 4 +values (1,2),(3,4) +union all +values (1,2) +union +values (1,2); +1 2 +1 2 +3 4 +values (1,2),(3,4) +union all +values (1,2) +union +values (3,4); +1 2 +1 2 +3 4 +values (1,2),(3,4) +union +values (1,2) +union all +values (1,2); +1 2 +1 2 +3 4 +1 2 +values (1,2) +union +values (1,2) +union all +values (1,2); +1 2 +1 2 +1 2 +# CTE that uses VALUES structure(s) : non-recursive CTE +with t2 as +( +values (1,2),(3,4) +) +select * from t2; +1 2 +1 2 +3 4 +with t2 as +( +select 1,2 +union +values (1,2) +) +select * from t2; +1 2 +1 2 +with t2 as +( +select 1,2 +union +values (1,2),(3,4) +) +select * from t2; +1 2 +1 2 +3 4 +with t2 as +( +values (1,2) +union +select 1,2 +) +select * from t2; +1 2 +1 2 +with t2 as +( +values (1,2),(3,4) +union +select 1,2 +) +select * from t2; +1 2 +1 2 +3 4 +with t2 as +( +values (5,6) +union +values (1,2),(3,4) +) +select * from t2; +5 6 +5 6 +1 2 +3 4 +with t2 as +( +values (1,2) +union +values (1,2),(3,4) +) +select * from t2; +1 2 +1 2 +3 4 +with t2 as +( +select 1,2 +union all +values (1,2),(3,4) +) +select * from t2; +1 2 +1 2 +1 2 +3 4 +with t2 as +( +values (1,2),(3,4) +union all +select 1,2 +) +select * from t2; +1 2 +1 2 +3 4 +1 2 +with t2 as +( +values (1,2) +union all +values (1,2),(3,4) +) +select * from t2; +1 2 +1 2 +1 2 +3 4 +# recursive CTE that uses VALUES structure(s) : singe VALUES structure as anchor +with recursive t2(a,b) as +( +values(1,1) +union +select t1.a, t1.b +from t1,t2 +where t1.a=t2.a +) +select * from t2; +a b +1 1 +1 2 +with recursive t2(a,b) as +( +values(1,1) +union +select t1.a+1, t1.b +from t1,t2 +where t1.a=t2.a +) +select * from t2; +a b +1 1 +2 2 +2 1 +3 5 +# recursive CTE that uses VALUES structure(s) : several VALUES structures as anchors +with recursive t2(a,b) as +( +values(1,1) +union +values (3,4) +union +select t2.a+1, t1.b +from t1,t2 +where t1.a=t2.a +) +select * from t2; +a b +1 1 +3 4 +2 2 +2 1 +3 5 +# recursive CTE that uses VALUES structure(s) : that uses UNION ALL +with recursive t2(a,b,st) as +( +values(1,1,1) +union all +select t2.a, t1.b, t2.st+1 +from t1,t2 +where t1.a=t2.a and st<3 +) +select * from t2; +a b st +1 1 1 +1 2 2 +1 1 2 +1 2 3 +1 2 3 +1 1 3 +1 1 3 +# recursive CTE that uses VALUES structure(s) : computation of factorial (first 10 elements) +with recursive fact(n,f) as +( +values(1,1) +union +select n+1,f*n from fact where n < 10 +) +select * from fact; +n f +1 1 +2 1 +3 2 +4 6 +5 24 +6 120 +7 720 +8 5040 +9 40320 +10 362880 +# Derived table that uses VALUES structure(s) : singe VALUES structure +select * from (values (1,2),(3,4)) as t2; +1 2 +1 2 +3 4 +# Derived table that uses VALUES structure(s) : UNION with VALUES structure(s) +select * from (select 1,2 union values (1,2)) as t2; +1 2 +1 2 +select * from (select 1,2 union values (1,2),(3,4)) as t2; +1 2 +1 2 +3 4 +select * from (values (1,2) union select 1,2) as t2; +1 2 +1 2 +select * from (values (1,2),(3,4) union select 1,2) as t2; +1 2 +1 2 +3 4 +select * from (values (5,6) union values (1,2),(3,4)) as t2; +5 6 +5 6 +1 2 +3 4 +select * from (values (1,2) union values (1,2),(3,4)) as t2; +1 2 +1 2 +3 4 +# Derived table that uses VALUES structure(s) : UNION ALL with VALUES structure(s) +select * from (select 1,2 union all values (1,2),(3,4)) as t2; +1 2 +1 2 +1 2 +3 4 +select * from (values (1,2),(3,4) union all select 1,2) as t2; +1 2 +1 2 +3 4 +1 2 +select * from (values (1,2) union all values (1,2),(3,4)) as t2; +1 2 +1 2 +1 2 +3 4 +# CREATE VIEW that uses VALUES structure(s) : singe VALUES structure +create view v1 as values (1,2),(3,4); +select * from v1; +1 2 +1 2 +3 4 +drop view v1; +# CREATE VIEW that uses VALUES structure(s) : UNION with VALUES structure(s) +create view v1 as +select 1,2 +union +values (1,2); +select * from v1; +1 2 +1 2 +drop view v1; +create view v1 as +select 1,2 +union +values (1,2),(3,4); +select * from v1; +1 2 +1 2 +3 4 +drop view v1; +create view v1 as +values (1,2) +union +select 1,2; +select * from v1; +1 2 +1 2 +drop view v1; +create view v1 as +values (1,2),(3,4) +union +select 1,2; +select * from v1; +1 2 +1 2 +3 4 +drop view v1; +create view v1 as +values (5,6) +union +values (1,2),(3,4); +select * from v1; +5 6 +5 6 +1 2 +3 4 +drop view v1; +# CREATE VIEW that uses VALUES structure(s) : UNION ALL with VALUES structure(s) +create view v1 as +values (1,2) +union +values (1,2),(3,4); +select * from v1; +1 2 +1 2 +3 4 +drop view v1; +create view v1 as +select 1,2 +union all +values (1,2),(3,4); +select * from v1; +1 2 +1 2 +1 2 +3 4 +drop view v1; +create view v1 as +values (1,2),(3,4) +union all +select 1,2; +select * from v1; +1 2 +1 2 +3 4 +1 2 +drop view v1; +create view v1 as +values (1,2) +union all +values (1,2),(3,4); +select * from v1; +1 2 +1 2 +1 2 +3 4 +drop view v1; +# IN-subquery with VALUES structure(s) : simple case +select * from t1 +where a in (values (1)); +a b +1 2 +1 1 +select * from t1 +where a in (select * from (values (1)) as tvc_0); +a b +1 2 +1 1 +explain extended select * from t1 +where a in (values (1)); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ALL distinct_key NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join) +3 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`1` +explain extended select * from t1 +where a in (select * from (values (1)) as tvc_0); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ALL distinct_key NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join) +2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`1` +# IN-subquery with VALUES structure(s) : UNION with VALUES on the first place +select * from t1 +where a in (values (1) union select 2); +a b +1 2 +1 1 +2 5 +select * from t1 +where a in (select * from (values (1)) as tvc_0 union +select 2); +a b +1 2 +1 1 +2 5 +explain extended select * from t1 +where a in (values (1) union select 2); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +4 DEPENDENT SUBQUERY ref key0 key0 4 func 2 100.00 +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where <`test`.`t1`.`a`>((`test`.`t1`.`a`,(/* select#4 */ select `tvc_0`.`1` from (values (1)) `tvc_0` where (`test`.`t1`.`a`) = `tvc_0`.`1` union /* select#3 */ select 2 having (`test`.`t1`.`a`) = (2)))) +explain extended select * from t1 +where a in (select * from (values (1)) as tvc_0 union +select 2); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +2 DEPENDENT SUBQUERY ref key0 key0 4 func 2 100.00 +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +4 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where <`test`.`t1`.`a`>((`test`.`t1`.`a`,(/* select#2 */ select `tvc_0`.`1` from (values (1)) `tvc_0` where (`test`.`t1`.`a`) = `tvc_0`.`1` union /* select#4 */ select 2 having (`test`.`t1`.`a`) = (2)))) +# IN-subquery with VALUES structure(s) : UNION with VALUES on the second place +select * from t1 +where a in (select 2 union values (1)); +a b +1 2 +1 1 +2 5 +select * from t1 +where a in (select 2 union +select * from (values (1)) tvc_0); +a b +1 2 +1 1 +2 5 +explain extended select * from t1 +where a in (select 2 union values (1)); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used +4 DEPENDENT UNION ref key0 key0 4 func 2 100.00 +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where <`test`.`t1`.`a`>((`test`.`t1`.`a`,(/* select#2 */ select 2 having (`test`.`t1`.`a`) = (2) union /* select#4 */ select `tvc_0`.`1` from (values (1)) `tvc_0` where (`test`.`t1`.`a`) = `tvc_0`.`1`))) +explain extended select * from t1 +where a in (select 2 union +select * from (values (1)) tvc_0); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used +3 DEPENDENT UNION ref key0 key0 4 func 2 100.00 +4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where <`test`.`t1`.`a`>((`test`.`t1`.`a`,(/* select#2 */ select 2 having (`test`.`t1`.`a`) = (2) union /* select#3 */ select `tvc_0`.`1` from (values (1)) `tvc_0` where (`test`.`t1`.`a`) = `tvc_0`.`1`))) +# IN-subquery with VALUES structure(s) : UNION ALL +select * from t1 +where a in (values (1) union all select b from t1); +a b +1 2 +1 1 +2 5 +7 8 +select * from t1 +where a in (select * from (values (1)) as tvc_0 union all +select b from t1); +a b +1 2 +1 1 +2 5 +7 8 +explain extended select * from t1 +where a in (values (1) union all select b from t1); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +4 DEPENDENT SUBQUERY ref key0 key0 4 func 2 100.00 +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +3 DEPENDENT UNION t1 ALL NULL NULL NULL NULL 6 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where <`test`.`t1`.`a`>((`test`.`t1`.`a`,(/* select#4 */ select `tvc_0`.`1` from (values (1)) `tvc_0` where (`test`.`t1`.`a`) = `tvc_0`.`1` union all /* select#3 */ select `test`.`t1`.`b` from `test`.`t1` where (`test`.`t1`.`a`) = `test`.`t1`.`b`))) +explain extended select * from t1 +where a in (select * from (values (1)) as tvc_0 union all +select b from t1); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +2 DEPENDENT SUBQUERY ref key0 key0 4 func 2 100.00 +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +4 DEPENDENT UNION t1 ALL NULL NULL NULL NULL 6 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where <`test`.`t1`.`a`>((`test`.`t1`.`a`,(/* select#2 */ select `tvc_0`.`1` from (values (1)) `tvc_0` where (`test`.`t1`.`a`) = `tvc_0`.`1` union all /* select#4 */ select `test`.`t1`.`b` from `test`.`t1` where (`test`.`t1`.`a`) = `test`.`t1`.`b`))) +# NOT IN subquery with VALUES structure(s) : simple case +select * from t1 +where a not in (values (1),(2)); +a b +4 6 +9 7 +7 8 +select * from t1 +where a not in (select * from (values (1),(2)) as tvc_0); +a b +4 6 +9 7 +7 8 +explain extended select * from t1 +where a not in (values (1),(2)); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +3 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<`test`.`t1`.`a`>((`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#3 */ select `tvc_0`.`1` from (values (1),(2)) `tvc_0` ), (`test`.`t1`.`a` in on distinct_key where `test`.`t1`.`a` = ``.`1`)))) +explain extended select * from t1 +where a not in (select * from (values (1),(2)) as tvc_0); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<`test`.`t1`.`a`>((`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select `tvc_0`.`1` from (values (1),(2)) `tvc_0` ), (`test`.`t1`.`a` in on distinct_key where `test`.`t1`.`a` = ``.`1`)))) +# NOT IN subquery with VALUES structure(s) : UNION with VALUES on the first place +select * from t1 +where a not in (values (1) union select 2); +a b +4 6 +9 7 +7 8 +select * from t1 +where a not in (select * from (values (1)) as tvc_0 union +select 2); +a b +4 6 +9 7 +7 8 +explain extended select * from t1 +where a not in (values (1) union select 2); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +4 DEPENDENT SUBQUERY ALL NULL NULL NULL NULL 2 100.00 Using where +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<`test`.`t1`.`a`>((`test`.`t1`.`a`,(/* select#4 */ select `tvc_0`.`1` from (values (1)) `tvc_0` where trigcond((`test`.`t1`.`a`) = `tvc_0`.`1`) union /* select#3 */ select 2 having trigcond((`test`.`t1`.`a`) = (2))))) +explain extended select * from t1 +where a not in (select * from (values (1)) as tvc_0 union +select 2); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +2 DEPENDENT SUBQUERY ALL NULL NULL NULL NULL 2 100.00 Using where +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +4 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<`test`.`t1`.`a`>((`test`.`t1`.`a`,(/* select#2 */ select `tvc_0`.`1` from (values (1)) `tvc_0` where trigcond((`test`.`t1`.`a`) = `tvc_0`.`1`) union /* select#4 */ select 2 having trigcond((`test`.`t1`.`a`) = (2))))) +# NOT IN subquery with VALUES structure(s) : UNION with VALUES on the second place +select * from t1 +where a not in (select 2 union values (1)); +a b +4 6 +9 7 +7 8 +select * from t1 +where a not in (select 2 union +select * from (values (1)) as tvc_0); +a b +4 6 +9 7 +7 8 +explain extended select * from t1 +where a not in (select 2 union values (1)); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used +4 DEPENDENT UNION ALL NULL NULL NULL NULL 2 100.00 Using where +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<`test`.`t1`.`a`>((`test`.`t1`.`a`,(/* select#2 */ select 2 having trigcond((`test`.`t1`.`a`) = (2)) union /* select#4 */ select `tvc_0`.`1` from (values (1)) `tvc_0` where trigcond((`test`.`t1`.`a`) = `tvc_0`.`1`)))) +explain extended select * from t1 +where a not in (select 2 union +select * from (values (1)) as tvc_0); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used +3 DEPENDENT UNION ALL NULL NULL NULL NULL 2 100.00 Using where +4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<`test`.`t1`.`a`>((`test`.`t1`.`a`,(/* select#2 */ select 2 having trigcond((`test`.`t1`.`a`) = (2)) union /* select#3 */ select `tvc_0`.`1` from (values (1)) `tvc_0` where trigcond((`test`.`t1`.`a`) = `tvc_0`.`1`)))) +# ANY-subquery with VALUES structure(s) : simple case +select * from t1 +where a = any (values (1),(2)); +a b +1 2 +1 1 +2 5 +select * from t1 +where a = any (select * from (values (1),(2)) as tvc_0); +a b +1 2 +1 1 +2 5 +explain extended select * from t1 +where a = any (values (1),(2)); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ALL distinct_key NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join) +3 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`1` +explain extended select * from t1 +where a = any (select * from (values (1),(2)) as tvc_0); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ALL distinct_key NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join) +2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`1` +# ANY-subquery with VALUES structure(s) : UNION with VALUES on the first place +select * from t1 +where a = any (values (1) union select 2); +a b +1 2 +1 1 +2 5 +select * from t1 +where a = any (select * from (values (1)) as tvc_0 union +select 2); +a b +1 2 +1 1 +2 5 +explain extended select * from t1 +where a = any (values (1) union select 2); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +4 DEPENDENT SUBQUERY ref key0 key0 4 func 2 100.00 +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where <`test`.`t1`.`a`>((`test`.`t1`.`a`,(/* select#4 */ select `tvc_0`.`1` from (values (1)) `tvc_0` where (`test`.`t1`.`a`) = `tvc_0`.`1` union /* select#3 */ select 2 having (`test`.`t1`.`a`) = (2)))) +explain extended select * from t1 +where a = any (select * from (values (1)) as tvc_0 union +select 2); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +2 DEPENDENT SUBQUERY ref key0 key0 4 func 2 100.00 +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +4 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where <`test`.`t1`.`a`>((`test`.`t1`.`a`,(/* select#2 */ select `tvc_0`.`1` from (values (1)) `tvc_0` where (`test`.`t1`.`a`) = `tvc_0`.`1` union /* select#4 */ select 2 having (`test`.`t1`.`a`) = (2)))) +# ANY-subquery with VALUES structure(s) : UNION with VALUES on the second place +select * from t1 +where a = any (select 2 union values (1)); +a b +1 2 +1 1 +2 5 +select * from t1 +where a = any (select 2 union +select * from (values (1)) as tvc_0); +a b +1 2 +1 1 +2 5 +explain extended select * from t1 +where a = any (select 2 union values (1)); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used +4 DEPENDENT UNION ref key0 key0 4 func 2 100.00 +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where <`test`.`t1`.`a`>((`test`.`t1`.`a`,(/* select#2 */ select 2 having (`test`.`t1`.`a`) = (2) union /* select#4 */ select `tvc_0`.`1` from (values (1)) `tvc_0` where (`test`.`t1`.`a`) = `tvc_0`.`1`))) +explain extended select * from t1 +where a = any (select 2 union +select * from (values (1)) as tvc_0); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used +3 DEPENDENT UNION ref key0 key0 4 func 2 100.00 +4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where <`test`.`t1`.`a`>((`test`.`t1`.`a`,(/* select#2 */ select 2 having (`test`.`t1`.`a`) = (2) union /* select#3 */ select `tvc_0`.`1` from (values (1)) `tvc_0` where (`test`.`t1`.`a`) = `tvc_0`.`1`))) +# ALL-subquery with VALUES structure(s) : simple case +select * from t1 +where a = all (values (1)); +a b +1 2 +1 1 +select * from t1 +where a = all (select * from (values (1)) as tvc_0); +a b +1 2 +1 1 +explain extended select * from t1 +where a = all (values (1)); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +3 DEPENDENT SUBQUERY ALL NULL NULL NULL NULL 2 100.00 Using where +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (<`test`.`t1`.`a`>((`test`.`t1`.`a`,(/* select#3 */ select `tvc_0`.`1` from (values (1)) `tvc_0` where trigcond((`test`.`t1`.`a`) <> `tvc_0`.`1`))))) +explain extended select * from t1 +where a = all (select * from (values (1)) as tvc_0); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +2 DEPENDENT SUBQUERY ALL NULL NULL NULL NULL 2 100.00 Using where +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (<`test`.`t1`.`a`>((`test`.`t1`.`a`,(/* select#2 */ select `tvc_0`.`1` from (values (1)) `tvc_0` where trigcond((`test`.`t1`.`a`) <> `tvc_0`.`1`))))) +# ALL-subquery with VALUES structure(s) : UNION with VALUES on the first place +select * from t1 +where a = all (values (1) union select 1); +a b +1 2 +1 1 +select * from t1 +where a = all (select * from (values (1)) as tvc_0 union +select 1); +a b +1 2 +1 1 +explain extended select * from t1 +where a = all (values (1) union select 1); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +4 DEPENDENT SUBQUERY ALL NULL NULL NULL NULL 2 100.00 Using where +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (<`test`.`t1`.`a`>((`test`.`t1`.`a`,(/* select#4 */ select `tvc_0`.`1` from (values (1)) `tvc_0` where trigcond((`test`.`t1`.`a`) <> `tvc_0`.`1`) union /* select#3 */ select 1 having trigcond((`test`.`t1`.`a`) <> (1)))))) +explain extended select * from t1 +where a = all (select * from (values (1)) as tvc_0 union +select 1); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +2 DEPENDENT SUBQUERY ALL NULL NULL NULL NULL 2 100.00 Using where +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +4 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (<`test`.`t1`.`a`>((`test`.`t1`.`a`,(/* select#2 */ select `tvc_0`.`1` from (values (1)) `tvc_0` where trigcond((`test`.`t1`.`a`) <> `tvc_0`.`1`) union /* select#4 */ select 1 having trigcond((`test`.`t1`.`a`) <> (1)))))) +# ALL-subquery with VALUES structure(s) : UNION with VALUES on the second place +select * from t1 +where a = any (select 1 union values (1)); +a b +1 2 +1 1 +select * from t1 +where a = any (select 1 union +select * from (values (1)) as tvc_0); +a b +1 2 +1 1 +explain extended select * from t1 +where a = any (select 1 union values (1)); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used +4 DEPENDENT UNION ref key0 key0 4 func 2 100.00 +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where <`test`.`t1`.`a`>((`test`.`t1`.`a`,(/* select#2 */ select 1 having (`test`.`t1`.`a`) = (1) union /* select#4 */ select `tvc_0`.`1` from (values (1)) `tvc_0` where (`test`.`t1`.`a`) = `tvc_0`.`1`))) +explain extended select * from t1 +where a = any (select 1 union +select * from (values (1)) as tvc_0); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used +3 DEPENDENT UNION ref key0 key0 4 func 2 100.00 +4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where <`test`.`t1`.`a`>((`test`.`t1`.`a`,(/* select#2 */ select 1 having (`test`.`t1`.`a`) = (1) union /* select#3 */ select `tvc_0`.`1` from (values (1)) `tvc_0` where (`test`.`t1`.`a`) = `tvc_0`.`1`))) +# prepare statement that uses VALUES structure(s): single VALUES structure +prepare stmt1 from " +values (1,2); +"; +execute stmt1; +1 2 +1 2 +execute stmt1; +1 2 +1 2 +deallocate prepare stmt1; +# prepare statement that uses VALUES structure(s): UNION with VALUES structure(s) +prepare stmt1 from " + select 1,2 + union + values (1,2),(3,4); +"; +execute stmt1; +1 2 +1 2 +3 4 +execute stmt1; +1 2 +1 2 +3 4 +deallocate prepare stmt1; +prepare stmt1 from " + values (1,2),(3,4) + union + select 1,2; +"; +execute stmt1; +1 2 +1 2 +3 4 +execute stmt1; +1 2 +1 2 +3 4 +deallocate prepare stmt1; +prepare stmt1 from " + select 1,2 + union + values (3,4) + union + values (1,2); +"; +execute stmt1; +1 2 +1 2 +3 4 +execute stmt1; +1 2 +1 2 +3 4 +deallocate prepare stmt1; +prepare stmt1 from " + values (5,6) + union + values (1,2),(3,4); +"; +execute stmt1; +5 6 +5 6 +1 2 +3 4 +execute stmt1; +5 6 +5 6 +1 2 +3 4 +deallocate prepare stmt1; +# prepare statement that uses VALUES structure(s): UNION ALL with VALUES structure(s) +prepare stmt1 from " + select 1,2 + union + values (1,2),(3,4); +"; +execute stmt1; +1 2 +1 2 +3 4 +execute stmt1; +1 2 +1 2 +3 4 +deallocate prepare stmt1; +prepare stmt1 from " + values (1,2),(3,4) + union all + select 1,2; +"; +execute stmt1; +1 2 +1 2 +3 4 +1 2 +execute stmt1; +1 2 +1 2 +3 4 +1 2 +deallocate prepare stmt1; +prepare stmt1 from " + select 1,2 + union all + values (3,4) + union all + values (1,2); +"; +execute stmt1; +1 2 +1 2 +3 4 +1 2 +execute stmt1; +1 2 +1 2 +3 4 +1 2 +deallocate prepare stmt1; +prepare stmt1 from " + values (1,2) + union all + values (1,2),(3,4); +"; +execute stmt1; +1 2 +1 2 +1 2 +3 4 +execute stmt1; +1 2 +1 2 +1 2 +3 4 +deallocate prepare stmt1; +# explain query that uses VALUES structure(s): single VALUES structure +explain +values (1,2); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used +explain format=json +values (1,2); +EXPLAIN +{ + "query_block": { + "union_result": { + "table_name": "", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 1, + "table": { + "message": "No tables used" + } + } + } + ] + } + } +} +# explain query that uses VALUES structure(s): UNION with VALUES structure(s) +explain +select 1,2 +union +values (1,2),(3,4); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used +2 UNION NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL +explain +values (1,2),(3,4) +union +select 1,2; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used +2 UNION NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL +explain +values (5,6) +union +values (1,2),(3,4); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used +2 UNION NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL +explain format=json +select 1,2 +union +values (1,2),(3,4); +EXPLAIN +{ + "query_block": { + "union_result": { + "table_name": "", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 1, + "table": { + "message": "No tables used" + } + } + }, + { + "query_block": { + "select_id": 2, + "operation": "UNION", + "table": { + "message": "No tables used" + } + } + } + ] + } + } +} +explain format=json +values (1,2),(3,4) +union +select 1,2; +EXPLAIN +{ + "query_block": { + "union_result": { + "table_name": "", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 1, + "table": { + "message": "No tables used" + } + } + }, + { + "query_block": { + "select_id": 2, + "operation": "UNION", + "table": { + "message": "No tables used" + } + } + } + ] + } + } +} +explain format=json +values (5,6) +union +values (1,2),(3,4); +EXPLAIN +{ + "query_block": { + "union_result": { + "table_name": "", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 1, + "table": { + "message": "No tables used" + } + } + }, + { + "query_block": { + "select_id": 2, + "operation": "UNION", + "table": { + "message": "No tables used" + } + } + } + ] + } + } +} +explain +select 1,2 +union +values (3,4) +union +values (1,2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used +2 UNION NULL NULL NULL NULL NULL NULL NULL No tables used +3 UNION NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL +explain format=json +select 1,2 +union +values (3,4) +union +values (1,2); +EXPLAIN +{ + "query_block": { + "union_result": { + "table_name": "", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 1, + "table": { + "message": "No tables used" + } + } + }, + { + "query_block": { + "select_id": 2, + "operation": "UNION", + "table": { + "message": "No tables used" + } + } + }, + { + "query_block": { + "select_id": 3, + "operation": "UNION", + "table": { + "message": "No tables used" + } + } + } + ] + } + } +} +# explain query that uses VALUES structure(s): UNION ALL with VALUES structure(s) +explain +select 1,2 +union +values (1,2),(3,4); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used +2 UNION NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL +explain +values (1,2),(3,4) +union all +select 1,2; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used +2 UNION NULL NULL NULL NULL NULL NULL NULL No tables used +explain +values (1,2) +union all +values (1,2),(3,4); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used +2 UNION NULL NULL NULL NULL NULL NULL NULL No tables used +explain format=json +values (1,2),(3,4) +union all +select 1,2; +EXPLAIN +{ + "query_block": { + "union_result": { + "table_name": "", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 1, + "table": { + "message": "No tables used" + } + } + }, + { + "query_block": { + "select_id": 2, + "operation": "UNION", + "table": { + "message": "No tables used" + } + } + } + ] + } + } +} +explain format=json +select 1,2 +union +values (1,2),(3,4); +EXPLAIN +{ + "query_block": { + "union_result": { + "table_name": "", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 1, + "table": { + "message": "No tables used" + } + } + }, + { + "query_block": { + "select_id": 2, + "operation": "UNION", + "table": { + "message": "No tables used" + } + } + } + ] + } + } +} +explain format=json +values (1,2) +union all +values (1,2),(3,4); +EXPLAIN +{ + "query_block": { + "union_result": { + "table_name": "", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 1, + "table": { + "message": "No tables used" + } + } + }, + { + "query_block": { + "select_id": 2, + "operation": "UNION", + "table": { + "message": "No tables used" + } + } + } + ] + } + } +} +explain +select 1,2 +union all +values (3,4) +union all +values (1,2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used +2 UNION NULL NULL NULL NULL NULL NULL NULL No tables used +3 UNION NULL NULL NULL NULL NULL NULL NULL No tables used +explain format=json +select 1,2 +union all +values (3,4) +union all +values (1,2); +EXPLAIN +{ + "query_block": { + "union_result": { + "table_name": "", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 1, + "table": { + "message": "No tables used" + } + } + }, + { + "query_block": { + "select_id": 2, + "operation": "UNION", + "table": { + "message": "No tables used" + } + } + }, + { + "query_block": { + "select_id": 3, + "operation": "UNION", + "table": { + "message": "No tables used" + } + } + } + ] + } + } +} +# analyze query that uses VALUES structure(s): single VALUES structure +analyze +values (1,2); +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +analyze format=json +values (1,2); +ANALYZE +{ + "query_block": { + "union_result": { + "table_name": "", + "access_type": "ALL", + "r_loops": 0, + "r_rows": null, + "query_specifications": [ + { + "query_block": { + "select_id": 1, + "table": { + "message": "No tables used" + } + } + } + ] + } + } +} +# analyze query that uses VALUES structure(s): UNION with VALUES structure(s) +analyze +select 1,2 +union +values (1,2),(3,4); +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +2 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL 2.00 NULL NULL +analyze +values (1,2),(3,4) +union +select 1,2; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +2 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL 2.00 NULL NULL +analyze +values (5,6) +union +values (1,2),(3,4); +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +2 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL 3.00 NULL NULL +analyze format=json +select 1,2 +union +values (1,2),(3,4); +ANALYZE +{ + "query_block": { + "union_result": { + "table_name": "", + "access_type": "ALL", + "r_loops": 1, + "r_rows": 2, + "query_specifications": [ + { + "query_block": { + "select_id": 1, + "table": { + "message": "No tables used" + } + } + }, + { + "query_block": { + "select_id": 2, + "operation": "UNION", + "table": { + "message": "No tables used" + } + } + } + ] + } + } +} +analyze format=json +values (1,2),(3,4) +union +select 1,2; +ANALYZE +{ + "query_block": { + "union_result": { + "table_name": "", + "access_type": "ALL", + "r_loops": 1, + "r_rows": 2, + "query_specifications": [ + { + "query_block": { + "select_id": 1, + "table": { + "message": "No tables used" + } + } + }, + { + "query_block": { + "select_id": 2, + "operation": "UNION", + "table": { + "message": "No tables used" + } + } + } + ] + } + } +} +analyze format=json +values (5,6) +union +values (1,2),(3,4); +ANALYZE +{ + "query_block": { + "union_result": { + "table_name": "", + "access_type": "ALL", + "r_loops": 1, + "r_rows": 3, + "query_specifications": [ + { + "query_block": { + "select_id": 1, + "table": { + "message": "No tables used" + } + } + }, + { + "query_block": { + "select_id": 2, + "operation": "UNION", + "table": { + "message": "No tables used" + } + } + } + ] + } + } +} +analyze +select 1,2 +union +values (3,4) +union +values (1,2); +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +2 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +3 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL 2.00 NULL NULL +analyze format=json +select 1,2 +union +values (3,4) +union +values (1,2); +ANALYZE +{ + "query_block": { + "union_result": { + "table_name": "", + "access_type": "ALL", + "r_loops": 1, + "r_rows": 2, + "query_specifications": [ + { + "query_block": { + "select_id": 1, + "table": { + "message": "No tables used" + } + } + }, + { + "query_block": { + "select_id": 2, + "operation": "UNION", + "table": { + "message": "No tables used" + } + } + }, + { + "query_block": { + "select_id": 3, + "operation": "UNION", + "table": { + "message": "No tables used" + } + } + } + ] + } + } +} +# analyze query that uses VALUES structure(s): UNION ALL with VALUES structure(s) +analyze +select 1,2 +union +values (1,2),(3,4); +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +2 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL 2.00 NULL NULL +analyze +values (1,2),(3,4) +union all +select 1,2; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +2 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +analyze +values (1,2) +union all +values (1,2),(3,4); +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +2 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +analyze format=json +values (1,2),(3,4) +union all +select 1,2; +ANALYZE +{ + "query_block": { + "union_result": { + "table_name": "", + "access_type": "ALL", + "r_loops": 0, + "r_rows": null, + "query_specifications": [ + { + "query_block": { + "select_id": 1, + "table": { + "message": "No tables used" + } + } + }, + { + "query_block": { + "select_id": 2, + "operation": "UNION", + "table": { + "message": "No tables used" + } + } + } + ] + } + } +} +analyze format=json +select 1,2 +union +values (1,2),(3,4); +ANALYZE +{ + "query_block": { + "union_result": { + "table_name": "", + "access_type": "ALL", + "r_loops": 1, + "r_rows": 2, + "query_specifications": [ + { + "query_block": { + "select_id": 1, + "table": { + "message": "No tables used" + } + } + }, + { + "query_block": { + "select_id": 2, + "operation": "UNION", + "table": { + "message": "No tables used" + } + } + } + ] + } + } +} +analyze format=json +values (1,2) +union all +values (1,2),(3,4); +ANALYZE +{ + "query_block": { + "union_result": { + "table_name": "", + "access_type": "ALL", + "r_loops": 0, + "r_rows": null, + "query_specifications": [ + { + "query_block": { + "select_id": 1, + "table": { + "message": "No tables used" + } + } + }, + { + "query_block": { + "select_id": 2, + "operation": "UNION", + "table": { + "message": "No tables used" + } + } + } + ] + } + } +} +analyze +select 1,2 +union all +values (3,4) +union all +values (1,2); +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +2 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +3 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +analyze format=json +select 1,2 +union all +values (3,4) +union all +values (1,2); +ANALYZE +{ + "query_block": { + "union_result": { + "table_name": "", + "access_type": "ALL", + "r_loops": 0, + "r_rows": null, + "query_specifications": [ + { + "query_block": { + "select_id": 1, + "table": { + "message": "No tables used" + } + } + }, + { + "query_block": { + "select_id": 2, + "operation": "UNION", + "table": { + "message": "No tables used" + } + } + }, + { + "query_block": { + "select_id": 3, + "operation": "UNION", + "table": { + "message": "No tables used" + } + } + } + ] + } + } +} +# different number of values in TVC +values (1,2),(3,4,5); +ERROR HY000: The used table value constructor has a different number of values +# illegal parameter data types in TVC +values (1,point(1,1)),(1,1); +ERROR HY000: Illegal parameter data types geometry and int for operation 'TABLE VALUE CONSTRUCTOR' +values (1,point(1,1)+1); +ERROR HY000: Illegal parameter data types geometry and int for operation '+' +# field reference in TVC +select * from (values (1), (b), (2)) as new_tvc; +ERROR HY000: Field reference 'b' can't be used in table value constructor +select * from (values (1), (t1.b), (2)) as new_tvc; +ERROR HY000: Field reference 't1.b' can't be used in table value constructor +drop table t1; diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index b751632307a..2b843f68499 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -2125,7 +2125,7 @@ SHOW TRIGGERS IN db1; Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation trg1 INSERT t2 CREATE DEFINER=`root`@`localhost` TRIGGER trg1 BEFORE INSERT ON t2 FOR EACH ROW INSERTINTOt1 VALUES (1) BEFORE # STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION latin1 latin1_swedish_ci latin1_swedish_ci INSERT INTO t2 VALUES (1); -ERROR 42000: Trigger 'trg1' has an error in its body: '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 'VALUES (1)' at line 1' +ERROR 42000: Trigger 'trg1' has an error in its body: 'You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(1)' at line 1' SELECT * FROM t1; b # Work around Bug#45235 diff --git a/mysql-test/r/type_bit.result b/mysql-test/r/type_bit.result index b2067907391..30cd94c9277 100644 --- a/mysql-test/r/type_bit.result +++ b/mysql-test/r/type_bit.result @@ -806,3 +806,27 @@ SUM(a) NULL DROP TABLE t1; End of 5.1 tests +# +# Start of 10.1 tests +# +# +# MDEV-8867 Wrong field type or metadata for COALESCE(bit_column, 1) +# +CREATE TABLE t1 (val bit(1)); +INSERT INTO t1 VALUES (0); +CREATE TABLE t2 AS SELECT COALESCE(val, 1) AS c FROM t1; +SELECT * FROM t2; +c +0 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c` decimal(1,0) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t2; +SELECT COALESCE(val, 1) FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def COALESCE(val, 1) 246 2 1 Y 32896 0 63 +COALESCE(val, 1) +0 +DROP TABLE t1; diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result index d56fac962fe..69bdf569787 100644 --- a/mysql-test/r/type_date.result +++ b/mysql-test/r/type_date.result @@ -852,6 +852,17 @@ Warning 1292 Incorrect datetime value: '1' Warning 1292 Incorrect datetime value: '1' DROP TABLE t1; # +# MDEV-14221 Assertion `0' failed in Item::field_type_for_temporal_comparison +# +CREATE TABLE t1 (d DATE); +INSERT INTO t1 VALUES ('1985-05-13'),('1989-12-24'); +SELECT d, COUNT(*) FROM t1 GROUP BY d WITH ROLLUP HAVING CASE d WHEN '2017-05-25' THEN 0 ELSE 1 END; +d COUNT(*) +1985-05-13 1 +1989-12-24 1 +NULL 2 +DROP TABLE t1; +# # End of 10.1 tests # # diff --git a/mysql-test/r/type_time.result b/mysql-test/r/type_time.result index 1600732cec3..89718ea8363 100644 --- a/mysql-test/r/type_time.result +++ b/mysql-test/r/type_time.result @@ -1245,6 +1245,20 @@ a b c 2070 00:00:00 00:00:00 DROP TABLE t1,t2; # +# MDEV-10817 CAST(MAX(DATE'2001-01-01') AS TIME) returns a wrong result +# +SELECT CAST(DATE'2001-01-01' AS TIME); +CAST(DATE'2001-01-01' AS TIME) +00:00:00 +SELECT CAST(MAX(DATE'2001-01-01') AS TIME); +CAST(MAX(DATE'2001-01-01') AS TIME) +00:00:00 +CREATE FUNCTION f1() RETURNS DATE RETURN DATE'2001-01-01'; +SELECT CAST(f1() AS TIME); +CAST(f1() AS TIME) +00:00:00 +DROP FUNCTION f1; +# # End of 10.2 tests # # diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index a0683e400ef..5a451982510 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -1624,7 +1624,7 @@ set session collation_database=2048; ERROR HY000: Unknown collation: '2048' set session rand_seed1=DEFAULT; ERROR 42000: Variable 'rand_seed1' doesn't have a default value -set autocommit = values(v); +set autocommit = value(v); ERROR 42S22: Unknown column 'v' in 'field list' set session sql_mode=ansi_quotes; select * from information_schema.session_variables where variable_name='sql_mode'; diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 6eead303c7a..635323a5867 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -5637,7 +5637,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 6 100.00 Using where Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,(/* select#3 */ select max(`test`.`t2`.`b`) from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`) AS `c` from `test`.`t1` +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,<`test`.`t1`.`a`>((/* select#3 */ select max(`test`.`t2`.`b`) from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`)) AS `c` from `test`.`t1` select * from v1; a c 1 2 @@ -5654,7 +5654,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 6 100.00 Using where Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 -Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,(/* select#3 */ select max(`test`.`t2`.`b`) from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`) AS `c` from `test`.`t2` join `test`.`t1` where `test`.`t1`.`a` = `test`.`t2`.`a` +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,<`test`.`t1`.`a`>((/* select#3 */ select max(`test`.`t2`.`b`) from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`)) AS `c` from `test`.`t2` join `test`.`t1` where `test`.`t1`.`a` = `test`.`t2`.`a` select * from t2, v1 where t2.a=v1.a; a b a c 1 2 1 2 @@ -5673,7 +5673,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 6 100.00 Using where Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`a` AS `a`,(/* select#3 */ select max(`test`.`t2`.`b`) from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`) AS `c` from `test`.`t1` join `test`.`t1` where `test`.`t1`.`a` = `test`.`t1`.`a` +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`a` AS `a`,<`test`.`t1`.`a`>((/* select#3 */ select max(`test`.`t2`.`b`) from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`)) AS `c` from `test`.`t1` join `test`.`t1` where `test`.`t1`.`a` = `test`.`t1`.`a` select * from t1, v1 where t1.a=v1.a; a b a c 1 2 1 2 @@ -5692,7 +5692,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 6 100.00 Using where Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`a` AS `a`,(/* select#3 */ select max(`test`.`t2`.`b`) from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`) AS `c` from `test`.`t1` join `test`.`t1` where `test`.`t1`.`b` = (/* select#3 */ select max(`test`.`t2`.`b`) from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`) +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`a` AS `a`,<`test`.`t1`.`a`>((/* select#3 */ select max(`test`.`t2`.`b`) from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`)) AS `c` from `test`.`t1` join `test`.`t1` where `test`.`t1`.`b` = <`test`.`t1`.`a`>((/* select#3 */ select max(`test`.`t2`.`b`) from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`)) select * from t1, v1 where t1.b=v1.c; a b a c 1 2 1 2 @@ -5710,7 +5710,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 6 100.00 Using where Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 -Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`a` AS `a`,(/* select#3 */ select max(`test`.`t2`.`b`) from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`) AS `c` from `test`.`t2` join `test`.`t1` join `test`.`t1` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`a` = `test`.`t2`.`a` +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`a` AS `a`,<`test`.`t1`.`a`>((/* select#3 */ select max(`test`.`t2`.`b`) from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`)) AS `c` from `test`.`t2` join `test`.`t1` join `test`.`t1` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`a` = `test`.`t2`.`a` select * from t2, t1, v1 where t1.a=t2.a and t1.a=v1.a; a b a b a c 1 2 1 2 1 2 diff --git a/mysql-test/r/win_percentile.result b/mysql-test/r/win_percentile.result new file mode 100644 index 00000000000..c51e2e6bd51 --- /dev/null +++ b/mysql-test/r/win_percentile.result @@ -0,0 +1,326 @@ +CREATE TABLE t1 (name CHAR(10), test double, score DECIMAL(19,4)); +INSERT INTO t1 VALUES +('Chun', 0, 3), ('Chun', 0, 7), +('Kaolin', 0.5, 3), ('Kaolin', 0.6, 7), +('Kaolin', 0.5, 4), +('Tatiana', 0.8, 4), ('Tata', 0.8, 4); +# +# Test invalid syntax +# +# Order by clause has more than one element +select percentile_disc(0.5) within group(order by score,test) over (partition by name) from t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'test) over (partition by name) from t1' at line 1 +select percentile_cont(0.5) within group(order by score,test) over (partition by name) from t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'test) over (partition by name) from t1' at line 1 +# Order by clause has no element +select percentile_disc(0.5) within group() over (partition by name) from t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') over (partition by name) from t1' at line 1 +select percentile_cont(0.5) within group() over (partition by name) from t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') over (partition by name) from t1' at line 1 +# No parameters to the percentile functions +select percentile_disc() within group() over (partition by name) from t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') within group() over (partition by name) from t1' at line 1 +select percentile_cont() within group() over (partition by name) from t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') within group() over (partition by name) from t1' at line 1 +# +# Test simple syntax +# +select name, percentile_cont(0.5) within group(order by score) over (partition by name) as c from t1; +name c +Chun 5.0000000000 +Chun 5.0000000000 +Kaolin 4.0000000000 +Kaolin 4.0000000000 +Kaolin 4.0000000000 +Tatiana 4.0000000000 +Tata 4.0000000000 +select name, percentile_disc(0.5) within group(order by score) over (partition by name) as c from t1; +name c +Chun 3.0000000000 +Chun 3.0000000000 +Kaolin 4.0000000000 +Kaolin 4.0000000000 +Kaolin 4.0000000000 +Tatiana 4.0000000000 +Tata 4.0000000000 +# no partition clause +select name, percentile_disc(0.5) within group(order by score) over () from t1; +name percentile_disc(0.5) within group(order by score) over () +Chun 4.0000000000 +Chun 4.0000000000 +Kaolin 4.0000000000 +Kaolin 4.0000000000 +Kaolin 4.0000000000 +Tatiana 4.0000000000 +Tata 4.0000000000 +select name, percentile_cont(0.5) within group(order by score) over () from t1; +name percentile_cont(0.5) within group(order by score) over () +Chun 4.0000000000 +Chun 4.0000000000 +Kaolin 4.0000000000 +Kaolin 4.0000000000 +Kaolin 4.0000000000 +Tatiana 4.0000000000 +Tata 4.0000000000 +# argument set to null +select name, percentile_cont(null) within group(order by score) over (partition by name) from t1; +ERROR HY000: percentile_cont function only accepts arguments that can be converted to numerical types +select name, percentile_disc(null) within group(order by score) over (partition by name) from t1; +ERROR HY000: percentile_disc function only accepts arguments that can be converted to numerical types +#subqueries having percentile functions +select * from ( select name , percentile_cont(0.5) within group ( order by score) over (partition by name ) from t1 ) as t; +name percentile_cont(0.5) within group ( order by score) over (partition by name ) +Chun 5.0000000000 +Chun 5.0000000000 +Kaolin 4.0000000000 +Kaolin 4.0000000000 +Kaolin 4.0000000000 +Tatiana 4.0000000000 +Tata 4.0000000000 +select * from ( select name , percentile_disc(0.5) within group ( order by score) over (partition by name ) from t1 ) as t; +name percentile_disc(0.5) within group ( order by score) over (partition by name ) +Chun 3.0000000000 +Chun 3.0000000000 +Kaolin 4.0000000000 +Kaolin 4.0000000000 +Kaolin 4.0000000000 +Tatiana 4.0000000000 +Tata 4.0000000000 +select name from t1 a where (select percentile_disc(0.5) within group (order by score) over (partition by name) from t1 b limit 1) >= 0.5; +name +Chun +Chun +Kaolin +Kaolin +Kaolin +Tatiana +Tata +#disallowed fields in order by +select score, percentile_cont(0.5) within group(order by name) over (partition by score) from t1; +ERROR HY000: Numeric datatype is required for percentile_cont function +select score, percentile_disc(0.5) within group(order by name) over (partition by score) from t1; +ERROR HY000: Numeric datatype is required for percentile_disc function +#parameter value should be in the range of [0,1] +select percentile_disc(1.5) within group(order by score) over (partition by name) from t1; +ERROR HY000: Argument to the percentile_disc function does not belong to the range [0,1] +select percentile_cont(1.5) within group(order by score) over (partition by name) from t1; +ERROR HY000: Argument to the percentile_cont function does not belong to the range [0,1] +#Argument should remain constant for the entire partition +select name,percentile_cont(test) within group(order by score) over (partition by name) from t1; +ERROR HY000: Argument to the percentile_cont function is not a constant for a partition +select name, percentile_disc(test) within group(order by score) over (partition by name) from t1; +ERROR HY000: Argument to the percentile_disc function is not a constant for a partition +#only numerical types are allowed as argument to percentile functions +select name, percentile_cont(name) within group(order by score) over (partition by name) from t1; +ERROR HY000: percentile_cont function only accepts arguments that can be converted to numerical types +select name, percentile_disc(name) within group(order by score) over (partition by name) from t1; +ERROR HY000: percentile_disc function only accepts arguments that can be converted to numerical types +#complete query with partition column +select name,cume_dist() over (partition by name order by score), percentile_disc(0.5) within group(order by score) over (partition by name) as c from t1; +name cume_dist() over (partition by name order by score) c +Chun 0.5000000000 3.0000000000 +Chun 1.0000000000 3.0000000000 +Kaolin 0.3333333333 4.0000000000 +Kaolin 1.0000000000 4.0000000000 +Kaolin 0.6666666667 4.0000000000 +Tatiana 1.0000000000 4.0000000000 +Tata 1.0000000000 4.0000000000 +select name, percentile_cont(0.5) within group(order by score) over (partition by name) as c from t1; +name c +Chun 5.0000000000 +Chun 5.0000000000 +Kaolin 4.0000000000 +Kaolin 4.0000000000 +Kaolin 4.0000000000 +Tatiana 4.0000000000 +Tata 4.0000000000 +select name,cume_dist() over (partition by name order by score) as b, percentile_disc(0.1) within group(order by score) over (partition by name) as c from t1; +name b c +Chun 0.5000000000 3.0000000000 +Chun 1.0000000000 3.0000000000 +Kaolin 0.3333333333 3.0000000000 +Kaolin 1.0000000000 3.0000000000 +Kaolin 0.6666666667 3.0000000000 +Tatiana 1.0000000000 4.0000000000 +Tata 1.0000000000 4.0000000000 +select name,cume_dist() over (partition by name order by score) as b, percentile_disc(0.2) within group(order by score) over (partition by name) as c from t1; +name b c +Chun 0.5000000000 3.0000000000 +Chun 1.0000000000 3.0000000000 +Kaolin 0.3333333333 3.0000000000 +Kaolin 1.0000000000 3.0000000000 +Kaolin 0.6666666667 3.0000000000 +Tatiana 1.0000000000 4.0000000000 +Tata 1.0000000000 4.0000000000 +select name,cume_dist() over (partition by name order by score) as b, percentile_disc(0.3) within group(order by score) over (partition by name) as c from t1; +name b c +Chun 0.5000000000 3.0000000000 +Chun 1.0000000000 3.0000000000 +Kaolin 0.3333333333 3.0000000000 +Kaolin 1.0000000000 3.0000000000 +Kaolin 0.6666666667 3.0000000000 +Tatiana 1.0000000000 4.0000000000 +Tata 1.0000000000 4.0000000000 +select name,cume_dist() over (partition by name order by score) as b, percentile_disc(0.4) within group(order by score) over (partition by name) as c from t1; +name b c +Chun 0.5000000000 3.0000000000 +Chun 1.0000000000 3.0000000000 +Kaolin 0.3333333333 4.0000000000 +Kaolin 1.0000000000 4.0000000000 +Kaolin 0.6666666667 4.0000000000 +Tatiana 1.0000000000 4.0000000000 +Tata 1.0000000000 4.0000000000 +select name,cume_dist() over (partition by name order by score) as b, percentile_disc(0.5) within group(order by score) over (partition by name) as c from t1; +name b c +Chun 0.5000000000 3.0000000000 +Chun 1.0000000000 3.0000000000 +Kaolin 0.3333333333 4.0000000000 +Kaolin 1.0000000000 4.0000000000 +Kaolin 0.6666666667 4.0000000000 +Tatiana 1.0000000000 4.0000000000 +Tata 1.0000000000 4.0000000000 +select name,cume_dist() over (partition by name order by score) as b, percentile_disc(0.6) within group(order by score) over (partition by name) as c from t1; +name b c +Chun 0.5000000000 7.0000000000 +Chun 1.0000000000 7.0000000000 +Kaolin 0.3333333333 4.0000000000 +Kaolin 1.0000000000 4.0000000000 +Kaolin 0.6666666667 4.0000000000 +Tatiana 1.0000000000 4.0000000000 +Tata 1.0000000000 4.0000000000 +select name,cume_dist() over (partition by name order by score) as b, percentile_disc(0.7) within group(order by score) over (partition by name) as c from t1; +name b c +Chun 0.5000000000 7.0000000000 +Chun 1.0000000000 7.0000000000 +Kaolin 0.3333333333 7.0000000000 +Kaolin 1.0000000000 7.0000000000 +Kaolin 0.6666666667 7.0000000000 +Tatiana 1.0000000000 4.0000000000 +Tata 1.0000000000 4.0000000000 +select name,cume_dist() over (partition by name order by score) as b, percentile_disc(0.8) within group(order by score) over (partition by name) as c from t1; +name b c +Chun 0.5000000000 7.0000000000 +Chun 1.0000000000 7.0000000000 +Kaolin 0.3333333333 7.0000000000 +Kaolin 1.0000000000 7.0000000000 +Kaolin 0.6666666667 7.0000000000 +Tatiana 1.0000000000 4.0000000000 +Tata 1.0000000000 4.0000000000 +select name,cume_dist() over (partition by name order by score) as b, percentile_disc(0.9) within group(order by score) over (partition by name) as c from t1; +name b c +Chun 0.5000000000 7.0000000000 +Chun 1.0000000000 7.0000000000 +Kaolin 0.3333333333 7.0000000000 +Kaolin 1.0000000000 7.0000000000 +Kaolin 0.6666666667 7.0000000000 +Tatiana 1.0000000000 4.0000000000 +Tata 1.0000000000 4.0000000000 +select name,cume_dist() over (partition by name order by score) as b, percentile_disc(1) within group(order by score) over (partition by name) as c from t1; +name b c +Chun 0.5000000000 7.0000000000 +Chun 1.0000000000 7.0000000000 +Kaolin 0.3333333333 7.0000000000 +Kaolin 1.0000000000 7.0000000000 +Kaolin 0.6666666667 7.0000000000 +Tatiana 1.0000000000 4.0000000000 +Tata 1.0000000000 4.0000000000 +select median(score) over (partition by name), percentile_cont(0) within group(order by score) over (partition by name) as c from t1; +median(score) over (partition by name) c +5.0000000000 3.0000000000 +5.0000000000 3.0000000000 +4.0000000000 3.0000000000 +4.0000000000 3.0000000000 +4.0000000000 3.0000000000 +4.0000000000 4.0000000000 +4.0000000000 4.0000000000 +select median(score) over (partition by name), percentile_cont(0.1) within group(order by score) over (partition by name) as c from t1; +median(score) over (partition by name) c +5.0000000000 3.4000000000 +5.0000000000 3.4000000000 +4.0000000000 3.2000000000 +4.0000000000 3.2000000000 +4.0000000000 3.2000000000 +4.0000000000 4.0000000000 +4.0000000000 4.0000000000 +select median(score) over (partition by name), percentile_cont(0.2) within group(order by score) over (partition by name) as c from t1; +median(score) over (partition by name) c +5.0000000000 3.8000000000 +5.0000000000 3.8000000000 +4.0000000000 3.4000000000 +4.0000000000 3.4000000000 +4.0000000000 3.4000000000 +4.0000000000 4.0000000000 +4.0000000000 4.0000000000 +select median(score) over (partition by name), percentile_cont(0.3) within group(order by score) over (partition by name) as c from t1; +median(score) over (partition by name) c +5.0000000000 4.2000000000 +5.0000000000 4.2000000000 +4.0000000000 3.6000000000 +4.0000000000 3.6000000000 +4.0000000000 3.6000000000 +4.0000000000 4.0000000000 +4.0000000000 4.0000000000 +select median(score) over (partition by name), percentile_cont(0.4) within group(order by score) over (partition by name) as c from t1; +median(score) over (partition by name) c +5.0000000000 4.6000000000 +5.0000000000 4.6000000000 +4.0000000000 3.8000000000 +4.0000000000 3.8000000000 +4.0000000000 3.8000000000 +4.0000000000 4.0000000000 +4.0000000000 4.0000000000 +select median(score) over (partition by name), percentile_cont(0.5) within group(order by score) over (partition by name) as c from t1; +median(score) over (partition by name) c +5.0000000000 5.0000000000 +5.0000000000 5.0000000000 +4.0000000000 4.0000000000 +4.0000000000 4.0000000000 +4.0000000000 4.0000000000 +4.0000000000 4.0000000000 +4.0000000000 4.0000000000 +select median(score) over (partition by name), percentile_cont(0.6) within group(order by score) over (partition by name) as c from t1; +median(score) over (partition by name) c +5.0000000000 5.4000000000 +5.0000000000 5.4000000000 +4.0000000000 4.6000000000 +4.0000000000 4.6000000000 +4.0000000000 4.6000000000 +4.0000000000 4.0000000000 +4.0000000000 4.0000000000 +select median(score) over (partition by name), percentile_cont(0.7) within group(order by score) over (partition by name) as c from t1; +median(score) over (partition by name) c +5.0000000000 5.8000000000 +5.0000000000 5.8000000000 +4.0000000000 5.2000000000 +4.0000000000 5.2000000000 +4.0000000000 5.2000000000 +4.0000000000 4.0000000000 +4.0000000000 4.0000000000 +select median(score) over (partition by name), percentile_cont(0.8) within group(order by score) over (partition by name) as c from t1; +median(score) over (partition by name) c +5.0000000000 6.2000000000 +5.0000000000 6.2000000000 +4.0000000000 5.8000000000 +4.0000000000 5.8000000000 +4.0000000000 5.8000000000 +4.0000000000 4.0000000000 +4.0000000000 4.0000000000 +select median(score) over (partition by name), percentile_cont(0.9) within group(order by score) over (partition by name) as c from t1; +median(score) over (partition by name) c +5.0000000000 6.6000000000 +5.0000000000 6.6000000000 +4.0000000000 6.4000000000 +4.0000000000 6.4000000000 +4.0000000000 6.4000000000 +4.0000000000 4.0000000000 +4.0000000000 4.0000000000 +select median(score) over (partition by name), percentile_cont(1) within group(order by score) over (partition by name) as c from t1; +median(score) over (partition by name) c +5.0000000000 7.0000000000 +5.0000000000 7.0000000000 +4.0000000000 7.0000000000 +4.0000000000 7.0000000000 +4.0000000000 7.0000000000 +4.0000000000 4.0000000000 +4.0000000000 4.0000000000 +drop table t1; diff --git a/mysql-test/suite/binlog/r/binlog_index.result b/mysql-test/suite/binlog/r/binlog_index.result index bb5d9ff74f1..02af5e40aab 100644 --- a/mysql-test/suite/binlog/r/binlog_index.result +++ b/mysql-test/suite/binlog/r/binlog_index.result @@ -2,7 +2,7 @@ call mtr.add_suppression('Attempting backtrace'); call mtr.add_suppression('MYSQL_BIN_LOG::purge_logs failed to process registered files that would be purged.'); call mtr.add_suppression('MYSQL_BIN_LOG::open failed to sync the index file'); call mtr.add_suppression('Turning logging off for the whole duration of the MySQL server process.'); -call mtr.add_suppression('Could not open .*'); +call mtr.add_suppression('Could not use .*'); call mtr.add_suppression('MYSQL_BIN_LOG::purge_logs failed to clean registers before purging logs.'); flush tables; RESET MASTER; diff --git a/mysql-test/suite/binlog_encryption/binlog_index.result b/mysql-test/suite/binlog_encryption/binlog_index.result index bb5d9ff74f1..02af5e40aab 100644 --- a/mysql-test/suite/binlog_encryption/binlog_index.result +++ b/mysql-test/suite/binlog_encryption/binlog_index.result @@ -2,7 +2,7 @@ call mtr.add_suppression('Attempting backtrace'); call mtr.add_suppression('MYSQL_BIN_LOG::purge_logs failed to process registered files that would be purged.'); call mtr.add_suppression('MYSQL_BIN_LOG::open failed to sync the index file'); call mtr.add_suppression('Turning logging off for the whole duration of the MySQL server process.'); -call mtr.add_suppression('Could not open .*'); +call mtr.add_suppression('Could not use .*'); call mtr.add_suppression('MYSQL_BIN_LOG::purge_logs failed to clean registers before purging logs.'); flush tables; RESET MASTER; diff --git a/mysql-test/suite/binlog_encryption/rpl_binlog_errors.result b/mysql-test/suite/binlog_encryption/rpl_binlog_errors.result index 06be72d523b..eb58dd06997 100644 --- a/mysql-test/suite/binlog_encryption/rpl_binlog_errors.result +++ b/mysql-test/suite/binlog_encryption/rpl_binlog_errors.result @@ -173,7 +173,7 @@ SET SQL_LOG_BIN=1; SET GLOBAL debug_dbug=@old_debug; ###################### TEST #10 call mtr.add_suppression("MYSQL_BIN_LOG::open failed to sync the index file."); -call mtr.add_suppression("Could not open .*"); +call mtr.add_suppression("Could not use .*"); RESET MASTER; SHOW WARNINGS; Level Code Message @@ -233,7 +233,7 @@ include/rpl_reset.inc connection slave; call mtr.add_suppression("Slave I/O: Relay log write failure: could not queue event from master.*"); call mtr.add_suppression("Error writing file .*"); -call mtr.add_suppression("Could not open .*"); +call mtr.add_suppression("Could not use .*"); call mtr.add_suppression("MYSQL_BIN_LOG::open failed to sync the index file."); call mtr.add_suppression("Can't generate a unique log-filename .*"); ###################### TEST #13 diff --git a/mysql-test/suite/encryption/disabled.def b/mysql-test/suite/encryption/disabled.def index d92d3495cb8..9d9d1cd9df9 100644 --- a/mysql-test/suite/encryption/disabled.def +++ b/mysql-test/suite/encryption/disabled.def @@ -12,3 +12,4 @@ innodb_scrub : MDEV-8139 scrubbing does not work reliably innodb_scrub_background : MDEV-8139 scrubbing does not work reliably +innodb-redo-badkey : MDEV-13893 / MDEV-12699 Improve crash recovery of corrupted data pages diff --git a/mysql-test/suite/encryption/r/encryption_force.result b/mysql-test/suite/encryption/r/encryption_force.result index 730a32a4b27..c71a9885455 100644 --- a/mysql-test/suite/encryption/r/encryption_force.result +++ b/mysql-test/suite/encryption/r/encryption_force.result @@ -34,11 +34,11 @@ t4 CREATE TABLE `t4` ( PARTITION BY HASH (`a`) PARTITIONS 2 alter table t1 encrypted=no; -ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 140 "Wrong create options") +ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'ENCRYPTED' alter table t2 encrypted=yes; alter table t3 encrypted=default; alter table t4 encrypted=no; -ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 140 "Wrong create options") +ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'ENCRYPTED' show create table t1; Table Create Table t1 CREATE TABLE `t1` ( diff --git a/mysql-test/suite/encryption/r/filekeys_encfile.result b/mysql-test/suite/encryption/r/filekeys_encfile.result index add6f312fda..6d5baa1b7ff 100644 --- a/mysql-test/suite/encryption/r/filekeys_encfile.result +++ b/mysql-test/suite/encryption/r/filekeys_encfile.result @@ -14,7 +14,7 @@ t1 CREATE TABLE `t1` ( `b` char(200) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 `encrypted`=yes `encryption_key_id`=2 alter table t1 encryption_key_id=3; -ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 140 "Wrong create options") +ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'ENCRYPTION_KEY_ID' show create table t1; Table Create Table t1 CREATE TABLE `t1` ( diff --git a/mysql-test/suite/encryption/r/filekeys_encfile_file.result b/mysql-test/suite/encryption/r/filekeys_encfile_file.result index add6f312fda..6d5baa1b7ff 100644 --- a/mysql-test/suite/encryption/r/filekeys_encfile_file.result +++ b/mysql-test/suite/encryption/r/filekeys_encfile_file.result @@ -14,7 +14,7 @@ t1 CREATE TABLE `t1` ( `b` char(200) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 `encrypted`=yes `encryption_key_id`=2 alter table t1 encryption_key_id=3; -ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 140 "Wrong create options") +ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'ENCRYPTION_KEY_ID' show create table t1; Table Create Table t1 CREATE TABLE `t1` ( diff --git a/mysql-test/suite/encryption/r/innodb-encryption-alter.result b/mysql-test/suite/encryption/r/innodb-encryption-alter.result index 06e4172bbae..fcc87493976 100644 --- a/mysql-test/suite/encryption/r/innodb-encryption-alter.result +++ b/mysql-test/suite/encryption/r/innodb-encryption-alter.result @@ -41,11 +41,10 @@ CREATE TABLE t2 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNOD Warnings: Warning 140 InnoDB: Ignored ENCRYPTION_KEY_ID 1 when encryption is disabled ALTER TABLE t1 ENCRYPTION_KEY_ID=99; -ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 140 "Wrong create options") +ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'ENCRYPTION_KEY_ID' SHOW WARNINGS; Level Code Message Warning 140 InnoDB: ENCRYPTION_KEY_ID 99 not available -Error 1005 Can't create table `test`.`#sql-temporary` (errno: 140 "Wrong create options") -Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB +Error 1478 Table storage engine 'InnoDB' does not support the create option 'ENCRYPTION_KEY_ID' set innodb_default_encryption_key_id = 1; drop table t1,t2; diff --git a/mysql-test/suite/encryption/r/innodb-spatial-index.result b/mysql-test/suite/encryption/r/innodb-spatial-index.result index 3efea81acc8..9ca6dbd2137 100644 --- a/mysql-test/suite/encryption/r/innodb-spatial-index.result +++ b/mysql-test/suite/encryption/r/innodb-spatial-index.result @@ -5,7 +5,7 @@ ERROR HY000: Can't create table `test`.`t1` (errno: 140 "Wrong create options") CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256), coordinate POINT NOT NULL, SPATIAL index(coordinate)) ENGINE=INNODB; ALTER TABLE t1 ENCRYPTED=YES; -ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 140 "Wrong create options") +ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'ENCRYPTED' DROP TABLE t1; CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256), coordinate POINT NOT NULL) ENCRYPTED=YES ENGINE=INNODB; diff --git a/mysql-test/suite/encryption/t/encryption_force.test b/mysql-test/suite/encryption/t/encryption_force.test index 3e09dd91839..3c6f039184b 100644 --- a/mysql-test/suite/encryption/t/encryption_force.test +++ b/mysql-test/suite/encryption/t/encryption_force.test @@ -22,13 +22,11 @@ show create table t2; show create table t3; show create table t4; ---replace_regex /#sql-[0-9a-f_]*/#sql-temporary/ ---error ER_CANT_CREATE_TABLE +--error ER_ILLEGAL_HA_CREATE_OPTION alter table t1 encrypted=no; alter table t2 encrypted=yes; alter table t3 encrypted=default; ---replace_regex /#sql-[0-9a-f_]*/#sql-temporary/ ---error ER_CANT_CREATE_TABLE +--error ER_ILLEGAL_HA_CREATE_OPTION alter table t4 encrypted=no; show create table t1; diff --git a/mysql-test/suite/encryption/t/filekeys_goodtest.inc b/mysql-test/suite/encryption/t/filekeys_goodtest.inc index 12a79c13d2a..252060796fe 100644 --- a/mysql-test/suite/encryption/t/filekeys_goodtest.inc +++ b/mysql-test/suite/encryption/t/filekeys_goodtest.inc @@ -7,8 +7,7 @@ insert t1 values (12345, repeat('1234567890', 20)); alter table t1 encryption_key_id=2; show create table t1; ---replace_regex /#sql-[0-9a-f_]*/#sql-temporary/ ---error ER_CANT_CREATE_TABLE +--error ER_ILLEGAL_HA_CREATE_OPTION alter table t1 encryption_key_id=3; show create table t1; alter table t1 encryption_key_id=33; @@ -17,4 +16,3 @@ alter table t1 encryption_key_id=4; show create table t1; drop table t1; - diff --git a/mysql-test/suite/encryption/t/innodb-encryption-alter.test b/mysql-test/suite/encryption/t/innodb-encryption-alter.test index cb7d5a47975..af1c749d8a9 100644 --- a/mysql-test/suite/encryption/t/innodb-encryption-alter.test +++ b/mysql-test/suite/encryption/t/innodb-encryption-alter.test @@ -27,10 +27,8 @@ DROP TABLE t1; CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB; SHOW CREATE TABLE t1; CREATE TABLE t2 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB ENCRYPTED=NO ENCRYPTION_KEY_ID=1; ---replace_regex /#sql-[0-9a-f_]*/#sql-temporary/ ---error 1005 +--error ER_ILLEGAL_HA_CREATE_OPTION ALTER TABLE t1 ENCRYPTION_KEY_ID=99; ---replace_regex /#sql-[0-9a-f_]*/#sql-temporary/ SHOW WARNINGS; set innodb_default_encryption_key_id = 1; diff --git a/mysql-test/suite/encryption/t/innodb-spatial-index.test b/mysql-test/suite/encryption/t/innodb-spatial-index.test index 6b6191c69cb..8eb6a803765 100644 --- a/mysql-test/suite/encryption/t/innodb-spatial-index.test +++ b/mysql-test/suite/encryption/t/innodb-spatial-index.test @@ -20,10 +20,8 @@ ENCRYPTED=YES; # CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256), coordinate POINT NOT NULL, SPATIAL index(coordinate)) ENGINE=INNODB; ---replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ ---error ER_CANT_CREATE_TABLE +--error ER_ILLEGAL_HA_CREATE_OPTION ALTER TABLE t1 ENCRYPTED=YES; ---replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ DROP TABLE t1; # diff --git a/mysql-test/suite/funcs_1/datadict/is_key_column_usage.inc b/mysql-test/suite/funcs_1/datadict/is_key_column_usage.inc index 71030a2b1d8..ba390dfb4f5 100644 --- a/mysql-test/suite/funcs_1/datadict/is_key_column_usage.inc +++ b/mysql-test/suite/funcs_1/datadict/is_key_column_usage.inc @@ -75,7 +75,8 @@ eval SHOW COLUMNS FROM information_schema.$is_table; SELECT constraint_catalog, constraint_schema, constraint_name, table_catalog, table_schema, table_name, column_name FROM information_schema.key_column_usage -WHERE constraint_catalog IS NOT NULL OR table_catalog IS NOT NULL; +WHERE constraint_catalog IS NOT NULL OR table_catalog IS NOT NULL +ORDER BY BINARY table_schema, BINARY table_name, BINARY column_name, BINARY constraint_name; --echo ######################################################################################## diff --git a/mysql-test/suite/funcs_1/datadict/is_schemata.inc b/mysql-test/suite/funcs_1/datadict/is_schemata.inc index 18c759b91d1..0a3f0e726b3 100644 --- a/mysql-test/suite/funcs_1/datadict/is_schemata.inc +++ b/mysql-test/suite/funcs_1/datadict/is_schemata.inc @@ -59,7 +59,8 @@ eval SHOW COLUMNS FROM information_schema.$is_table; # Show that CATALOG_NAME and SQL_PATH are always NULL. SELECT catalog_name, schema_name, sql_path FROM information_schema.schemata -WHERE catalog_name IS NOT NULL or sql_path IS NOT NULL; +WHERE catalog_name IS NOT NULL or sql_path IS NOT NULL +ORDER BY schema_name; --echo ############################################################################### diff --git a/mysql-test/suite/funcs_1/datadict/is_triggers.inc b/mysql-test/suite/funcs_1/datadict/is_triggers.inc index b2ce1e2de00..3a449c93c4b 100644 --- a/mysql-test/suite/funcs_1/datadict/is_triggers.inc +++ b/mysql-test/suite/funcs_1/datadict/is_triggers.inc @@ -85,7 +85,8 @@ eval SHOW COLUMNS FROM information_schema.$is_table; SELECT * FROM information_schema.triggers WHERE trigger_catalog IS NOT NULL OR event_object_catalog IS NOT NULL OR action_condition IS NOT NULL OR action_reference_old_table IS NOT NULL - OR action_reference_new_table IS NOT NULL; + OR action_reference_new_table IS NOT NULL +ORDER BY trigger_schema, trigger_name; --echo ################################################################################## diff --git a/mysql-test/suite/funcs_1/datadict/is_views.inc b/mysql-test/suite/funcs_1/datadict/is_views.inc index bdba03f3632..cb3444e308a 100644 --- a/mysql-test/suite/funcs_1/datadict/is_views.inc +++ b/mysql-test/suite/funcs_1/datadict/is_views.inc @@ -159,12 +159,14 @@ CREATE USER 'testuser1'@'localhost'; # Check just created VIEW SELECT * FROM information_schema.views -WHERE table_name LIKE 't1_%'; +WHERE table_name LIKE 't1_%' +ORDER BY table_schema, table_name; CREATE VIEW test.t1_view AS SELECT DISTINCT f1 FROM test.t1_table; CREATE ALGORITHM=MERGE VIEW test.t1_view1 AS SELECT f1 FROM test.t1_table; CREATE ALGORITHM=TEMPTABLE VIEW test.t1_view2 AS SELECT f1 FROM test.t1_table; SELECT * FROM information_schema.views -WHERE table_name LIKE 't1_%'; +WHERE table_name LIKE 't1_%' +ORDER BY table_schema, table_name; DROP VIEW test.t1_view1; DROP VIEW test.t1_view2; diff --git a/mysql-test/suite/funcs_1/datadict/processlist_priv.inc b/mysql-test/suite/funcs_1/datadict/processlist_priv.inc index cd060e7a370..ae46dfd31c8 100644 --- a/mysql-test/suite/funcs_1/datadict/processlist_priv.inc +++ b/mysql-test/suite/funcs_1/datadict/processlist_priv.inc @@ -158,7 +158,7 @@ WHERE DB = 'information_schema' AND COMMAND = 'Sleep' AND USER = 'ddicttestuser1 eval SHOW CREATE TABLE $table; --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS eval SHOW $table; ---replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID +--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID eval SELECT * FROM $table $select_where ORDER BY id; --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID eval SELECT $columns FROM $table $select_where ORDER BY id; @@ -178,7 +178,7 @@ connection con100; eval SHOW CREATE TABLE $table; --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS eval SHOW $table; ---replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID +--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID eval SELECT * FROM $table $select_where ORDER BY id; --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID eval SELECT $columns FROM $table $select_where ORDER BY id; @@ -204,7 +204,7 @@ connection con100; SHOW GRANTS; --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; ---replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID +--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID SELECT * FROM information_schema.processlist; --real_sleep 0.3 @@ -216,7 +216,7 @@ connect (con101,localhost,ddicttestuser1,ddictpass,information_schema); SHOW GRANTS; --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; ---replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID +--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID SELECT * FROM information_schema.processlist; --real_sleep 0.3 @@ -239,7 +239,7 @@ connect (anonymous1,localhost,"''",,information_schema); SHOW GRANTS; --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; ---replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID +--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID SELECT * FROM information_schema.processlist; --real_sleep 0.3 @@ -261,7 +261,7 @@ connect (con102,localhost,ddicttestuser1,ddictpass,information_schema); SHOW GRANTS; --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; ---replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID +--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID SELECT * FROM information_schema.processlist; --real_sleep 0.3 @@ -287,7 +287,7 @@ if ($fixed_bug_30395) --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; } ---replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID +--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID SELECT * FROM information_schema.processlist; --real_sleep 0.3 @@ -308,7 +308,7 @@ connect (con103,localhost,ddicttestuser1,ddictpass,information_schema); SHOW GRANTS FOR 'ddicttestuser1'@'localhost'; --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; ---replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID +--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID SELECT * FROM information_schema.processlist; --real_sleep 0.3 @@ -330,7 +330,7 @@ connect (con104,localhost,ddicttestuser1,ddictpass,information_schema); SHOW GRANTS FOR 'ddicttestuser1'@'localhost'; --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; ---replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID +--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID SELECT * FROM information_schema.processlist; --real_sleep 0.3 @@ -377,7 +377,7 @@ connect (con200,localhost,ddicttestuser2,ddictpass,information_schema); SHOW GRANTS FOR 'ddicttestuser2'@'localhost'; --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; ---replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID +--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID SELECT * FROM information_schema.processlist; --real_sleep 0.3 @@ -398,7 +398,7 @@ connect (con201,localhost,ddicttestuser2,ddictpass,information_schema); SHOW GRANTS; --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; ---replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID +--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID SELECT * FROM information_schema.processlist; --real_sleep 0.3 @@ -421,7 +421,7 @@ SHOW GRANTS FOR 'ddicttestuser1'@'localhost'; GRANT PROCESS ON *.* TO 'ddicttestuser2'@'localhost'; --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; ---replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID +--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID SELECT * FROM information_schema.processlist; --real_sleep 0.3 @@ -445,7 +445,7 @@ connect (con108,localhost,ddicttestuser1,ddictpass,information_schema); SHOW GRANTS FOR 'ddicttestuser1'@'localhost'; --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; ---replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID +--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID SELECT * FROM information_schema.processlist; --real_sleep 0.3 diff --git a/mysql-test/suite/funcs_1/datadict/processlist_val.inc b/mysql-test/suite/funcs_1/datadict/processlist_val.inc index cfc3c5e751a..24f3eb76a1c 100644 --- a/mysql-test/suite/funcs_1/datadict/processlist_val.inc +++ b/mysql-test/suite/funcs_1/datadict/processlist_val.inc @@ -92,7 +92,7 @@ echo # - INFO must contain the corresponding SHOW/SELECT PROCESSLIST # # 1. Just dump what we get ---replace_column 1 3 6