From 9ff9d2303dc6ccb856a66664af625990efaf172b Mon Sep 17 00:00:00 2001 From: Takashi Sasaki Date: Sun, 28 Oct 2018 22:50:49 +0900 Subject: [PATCH 01/20] test framework manual is moved --- client/mysqltest.cc | 2 +- mysql-test/lib/v1/mysql-test-run.pl | 2 +- mysql-test/mysql-test-run.pl | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 43dbff981d3..e41118d742d 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -20,7 +20,7 @@ Tool used for executing a .test file See the "MySQL Test framework manual" for more information - http://dev.mysql.com/doc/mysqltest/en/index.html + https://mariadb.com/kb/en/library/mysqltest/ Please keep the test framework tools identical in all versions! diff --git a/mysql-test/lib/v1/mysql-test-run.pl b/mysql-test/lib/v1/mysql-test-run.pl index 109e580a2b3..98328ad4e39 100755 --- a/mysql-test/lib/v1/mysql-test-run.pl +++ b/mysql-test/lib/v1/mysql-test-run.pl @@ -23,7 +23,7 @@ # Tool used for executing a suite of .test file # # See the "MySQL Test framework manual" for more information -# http://dev.mysql.com/doc/mysqltest/en/index.html +# https://mariadb.com/kb/en/library/mysqltest/ # # Please keep the test framework tools identical in all versions! # diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 8253af5fbbd..5587f918d92 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -25,7 +25,7 @@ # Tool used for executing a suite of .test files # # See the "MySQL Test framework manual" for more information -# http://dev.mysql.com/doc/mysqltest/en/index.html +# https://mariadb.com/kb/en/library/mysqltest/ # # ############################################################################## From c32f7ed235f12d4e63f3145d09d5a57fb948d947 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 31 Oct 2018 18:18:48 +0100 Subject: [PATCH 02/20] MDEV-17377 invalid gap in auto-increment values after LOAD DATA reset lex->many_values for LOAD DATA, as it's used for auto-inc range size estimation. --- mysql-test/r/auto_increment_ranges_innodb.result | 14 ++++++++++++++ mysql-test/t/auto_increment_ranges_innodb.test | 11 +++++++++++ sql/sql_yacc.yy | 1 + 3 files changed, 26 insertions(+) diff --git a/mysql-test/r/auto_increment_ranges_innodb.result b/mysql-test/r/auto_increment_ranges_innodb.result index fb936ddfd2b..961f8b870ec 100644 --- a/mysql-test/r/auto_increment_ranges_innodb.result +++ b/mysql-test/r/auto_increment_ranges_innodb.result @@ -264,3 +264,17 @@ delete from t1 where a=32767; insert into t1 values(NULL); ERROR 22003: Out of range value for column 'a' at row 1 drop table t1; +create table t1 (pk int auto_increment primary key, f varchar(20)); +insert t1 (f) values ('a'), ('b'), ('c'), ('d'); +select null, f into outfile 'load.data' from t1 limit 1; +load data infile 'load.data' into table t1; +insert t1 (f) values ('<==='); +select * from t1; +pk f +1 a +2 b +3 c +4 d +5 a +6 <=== +drop table t1; diff --git a/mysql-test/t/auto_increment_ranges_innodb.test b/mysql-test/t/auto_increment_ranges_innodb.test index c2afee7ac66..3317153c31a 100644 --- a/mysql-test/t/auto_increment_ranges_innodb.test +++ b/mysql-test/t/auto_increment_ranges_innodb.test @@ -5,3 +5,14 @@ --source include/have_innodb.inc set default_storage_engine=innodb; --source auto_increment_ranges.inc + +# +# MDEV-17377 invalid gap in auto-increment values after LOAD DATA +# +create table t1 (pk int auto_increment primary key, f varchar(20)); +insert t1 (f) values ('a'), ('b'), ('c'), ('d'); +select null, f into outfile 'load.data' from t1 limit 1; +load data infile 'load.data' into table t1; +insert t1 (f) values ('<==='); +select * from t1; +drop table t1; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index bf47153c0c1..34f7c6e3481 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -12073,6 +12073,7 @@ load: lex->field_list.empty(); lex->update_list.empty(); lex->value_list.empty(); + lex->many_values.empty(); } opt_load_data_charset { Lex->exchange->cs= $14; } From b7eca63620df2d4626faa54a171cf0a190cf6924 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 1 Nov 2018 18:47:53 +0100 Subject: [PATCH 03/20] fix the test to clean after itself followup for c32f7ed235f --- mysql-test/t/auto_increment_ranges_innodb.test | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mysql-test/t/auto_increment_ranges_innodb.test b/mysql-test/t/auto_increment_ranges_innodb.test index 3317153c31a..016ca16bd91 100644 --- a/mysql-test/t/auto_increment_ranges_innodb.test +++ b/mysql-test/t/auto_increment_ranges_innodb.test @@ -16,3 +16,5 @@ load data infile 'load.data' into table t1; insert t1 (f) values ('<==='); select * from t1; drop table t1; +--let $datadir=`select @@datadir` +--remove_file $datadir/test/load.data From b68d8a05d326bed43aefa73d717c0307278ca6bb Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Fri, 12 Oct 2018 09:07:05 +0200 Subject: [PATCH 04/20] MDEV-17401: LOAD DATA from very big file into MyISAM table results in EOF error and corrupt index my_read fixed as in higher versions. my_pread made as my_read aware of partial read of huge chunks of files MY_FULL_IO enabled for file operations --- mysys/mf_iocache.c | 4 ++++ mysys/my_pread.c | 26 ++++++++++++++++------- mysys/my_read.c | 52 +++++++++++++++++++++++++--------------------- 3 files changed, 51 insertions(+), 31 deletions(-) diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index bd71e2ae527..9a051cf6a9e 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -282,6 +282,10 @@ int init_io_cache(IO_CACHE *info, File file, size_t cachesize, } info->inited=info->aio_result.pending=0; #endif + if (type == READ_CACHE || type == WRITE_CACHE || type == SEQ_READ_APPEND) + info->myflags|= MY_FULL_IO; + else + info->myflags&= ~MY_FULL_IO; DBUG_RETURN(0); } /* init_io_cache */ diff --git a/mysys/my_pread.c b/mysys/my_pread.c index 51b4c5f5599..52d5c382960 100644 --- a/mysys/my_pread.c +++ b/mysys/my_pread.c @@ -47,8 +47,7 @@ size_t my_pread(File Filedes, uchar *Buffer, size_t Count, my_off_t offset, myf MyFlags) { - size_t readbytes; - int error= 0; + size_t readbytes, save_count= 0; DBUG_ENTER("my_pread"); @@ -66,11 +65,10 @@ size_t my_pread(File Filedes, uchar *Buffer, size_t Count, my_off_t offset, #else readbytes= pread(Filedes, Buffer, Count, offset); #endif - error = (readbytes != Count); - if (error) + if (readbytes != Count) { - my_errno= errno ? errno : -1; + my_errno= errno; if (errno == 0 || (readbytes != (size_t) -1 && (MyFlags & (MY_NABP | MY_FNABP)))) my_errno= HA_ERR_FILE_TOO_SHORT; @@ -82,6 +80,18 @@ size_t my_pread(File Filedes, uchar *Buffer, size_t Count, my_off_t offset, (int) readbytes)); continue; /* Interrupted */ } + + /* Do a read retry if we didn't get enough data on first read */ + if (readbytes != (size_t) -1 && readbytes != 0 && + (MyFlags & MY_FULL_IO)) + { + Buffer+= readbytes; + Count-= readbytes; + save_count+= readbytes; + offset+= readbytes; + continue; + } + if (MyFlags & (MY_WME | MY_FAE | MY_FNABP)) { if (readbytes == (size_t) -1) @@ -97,8 +107,10 @@ size_t my_pread(File Filedes, uchar *Buffer, size_t Count, my_off_t offset, DBUG_RETURN(MY_FILE_ERROR); /* Return with error */ } if (MyFlags & (MY_NABP | MY_FNABP)) - DBUG_RETURN(0); /* Read went ok; Return 0 */ - DBUG_RETURN(readbytes); /* purecov: inspected */ + readbytes= 0; /* Read went ok; Return 0 */ + else + readbytes+= save_count; + DBUG_RETURN(readbytes); } } /* my_pread */ diff --git a/mysys/my_read.c b/mysys/my_read.c index 883a1c5fdc7..47f2d725f65 100644 --- a/mysys/my_read.c +++ b/mysys/my_read.c @@ -35,17 +35,16 @@ size_t my_read(File Filedes, uchar *Buffer, size_t Count, myf MyFlags) { - size_t readbytes, save_count; + size_t readbytes, save_count= 0; DBUG_ENTER("my_read"); - DBUG_PRINT("my",("fd: %d Buffer: %p Count: %lu MyFlags: %d", - Filedes, Buffer, (ulong) Count, MyFlags)); - save_count= Count; + DBUG_PRINT("my",("fd: %d Buffer: %p Count: %lu MyFlags: %lu", + Filedes, Buffer, (ulong) Count, (ulong) MyFlags)); if (!(MyFlags & (MY_WME | MY_FAE | MY_FNABP))) MyFlags|= my_global_flags; for (;;) { - errno= 0; /* Linux, Windows don't reset this on EOF/success */ + errno= 0; /* Linux, Windows don't reset this on EOF/success */ #ifdef _WIN32 readbytes= my_win_read(Filedes, Buffer, Count); #else @@ -61,47 +60,52 @@ size_t my_read(File Filedes, uchar *Buffer, size_t Count, myf MyFlags) if (readbytes != Count) { - my_errno= errno; - if (errno == 0 || (readbytes != (size_t) -1 && - (MyFlags & (MY_NABP | MY_FNABP)))) - my_errno= HA_ERR_FILE_TOO_SHORT; + int got_errno= my_errno= errno; DBUG_PRINT("warning",("Read only %d bytes off %lu from %d, errno: %d", (int) readbytes, (ulong) Count, Filedes, - my_errno)); + got_errno)); - if ((readbytes == 0 || (int) readbytes == -1) && errno == EINTR) - { + if (got_errno == 0 || (readbytes != (size_t) -1 && + (MyFlags & (MY_NABP | MY_FNABP)))) + my_errno= HA_ERR_FILE_TOO_SHORT; + + if ((readbytes == 0 || (int) readbytes == -1) && got_errno == EINTR) + { DBUG_PRINT("debug", ("my_read() was interrupted and returned %ld", (long) readbytes)); continue; /* Interrupted */ } + /* Do a read retry if we didn't get enough data on first read */ + if (readbytes != (size_t) -1 && readbytes != 0 && + (MyFlags & MY_FULL_IO)) + { + Buffer+= readbytes; + Count-= readbytes; + save_count+= readbytes; + continue; + } + if (MyFlags & (MY_WME | MY_FAE | MY_FNABP)) { if (readbytes == (size_t) -1) my_error(EE_READ, MYF(ME_BELL | ME_WAITTANG | (MyFlags & (ME_JUST_INFO | ME_NOREFRESH))), - my_filename(Filedes),my_errno); + my_filename(Filedes), got_errno); else if (MyFlags & (MY_NABP | MY_FNABP)) my_error(EE_EOFERR, MYF(ME_BELL | ME_WAITTANG | (MyFlags & (ME_JUST_INFO | ME_NOREFRESH))), - my_filename(Filedes),my_errno); + my_filename(Filedes), got_errno); } if (readbytes == (size_t) -1 || ((MyFlags & (MY_FNABP | MY_NABP)) && !(MyFlags & MY_FULL_IO))) - DBUG_RETURN(MY_FILE_ERROR); /* Return with error */ - if (readbytes != (size_t) -1 && (MyFlags & MY_FULL_IO)) - { - Buffer+= readbytes; - Count-= readbytes; - continue; - } + DBUG_RETURN(MY_FILE_ERROR); /* Return with error */ } if (MyFlags & (MY_NABP | MY_FNABP)) - readbytes= 0; /* Ok on read */ - else if (MyFlags & MY_FULL_IO) - readbytes= save_count; + readbytes= 0; /* Ok on read */ + else + readbytes+= save_count; break; } DBUG_RETURN(readbytes); From ef40018535b71f0a4387fa6c1cc22e9991dfc0db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Wed, 10 Oct 2018 18:25:53 +0300 Subject: [PATCH 05/20] MDEV-17230: encryption_key_id from alter is ignored by encryption threads Background: Used encryption key_id is stored to encryption metadata i.e. crypt_data that is stored on page 0 of the tablespace of the table. crypt_data is created only if implicit encryption/not encryption is requested i.e. ENCRYPTED=[YES|NO] table option is used fil_create_new_single_table_tablespace on fil0fil.cc. Later if encryption is enabled all tables that use default encryption mode (i.e. no encryption table option is set) are encrypted with default encryption key_id that is 1. See fil_crypt_start_encrypting_space on fil0crypt.cc. ha_innobase::check_table_options() If default encryption is used and encryption is disabled, you may not use nondefault encryption_key_id as it is not stored anywhere. --- .../r/innodb-encryption-alter.result | 37 +++++++++++++++++++ .../encryption/t/innodb-encryption-alter.test | 24 ++++++++++++ storage/innobase/handler/ha_innodb.cc | 25 ++++++------- storage/xtradb/handler/ha_innodb.cc | 25 ++++++------- 4 files changed, 83 insertions(+), 28 deletions(-) diff --git a/mysql-test/suite/encryption/r/innodb-encryption-alter.result b/mysql-test/suite/encryption/r/innodb-encryption-alter.result index 9ff0f492034..5245d1da7d0 100644 --- a/mysql-test/suite/encryption/r/innodb-encryption-alter.result +++ b/mysql-test/suite/encryption/r/innodb-encryption-alter.result @@ -50,3 +50,40 @@ Warning 140 InnoDB: ENCRYPTION_KEY_ID 99 not available 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; +SET GLOBAL innodb_encrypt_tables=OFF; +CREATE TABLE t1 (a int not null primary key) engine=innodb; +ALTER TABLE t1 ENCRYPTION_KEY_ID=4; +ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'ENCRYPTION_KEY_ID' +SHOW WARNINGS; +Level Code Message +Warning 140 InnoDB: innodb_encrypt_tables=OFF only allows ENCRYPTION_KEY_ID=1 +Error 1478 Table storage engine 'InnoDB' does not support the create option 'ENCRYPTION_KEY_ID' +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t2 (a int not null primary key) engine=innodb; +ALTER TABLE t2 ENCRYPTION_KEY_ID=4, ALGORITHM=COPY; +ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 140 "Wrong create options") +SHOW WARNINGS; +Level Code Message +Warning 140 InnoDB: innodb_encrypt_tables=OFF only allows ENCRYPTION_KEY_ID=1 +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 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t2; +CREATE TABLE t3 (a int not null primary key) engine=innodb ENCRYPTION_KEY_ID=4; +ERROR HY000: Can't create table `test`.`t3` (errno: 140 "Wrong create options") +SHOW WARNINGS; +Level Code Message +Warning 140 InnoDB: innodb_encrypt_tables=OFF only allows ENCRYPTION_KEY_ID=1 +Error 1005 Can't create table `test`.`t3` (errno: 140 "Wrong create options") +Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB diff --git a/mysql-test/suite/encryption/t/innodb-encryption-alter.test b/mysql-test/suite/encryption/t/innodb-encryption-alter.test index 9420fb74a4c..9465226dd96 100644 --- a/mysql-test/suite/encryption/t/innodb-encryption-alter.test +++ b/mysql-test/suite/encryption/t/innodb-encryption-alter.test @@ -87,6 +87,30 @@ connection default; drop table t1,t2; +# +# MDEV-17230: encryption_key_id from alter is ignored by encryption threads +# +SET GLOBAL innodb_encrypt_tables=OFF; +CREATE TABLE t1 (a int not null primary key) engine=innodb; +--error ER_ILLEGAL_HA_CREATE_OPTION +ALTER TABLE t1 ENCRYPTION_KEY_ID=4; +SHOW WARNINGS; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t2 (a int not null primary key) engine=innodb; +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ +--error ER_CANT_CREATE_TABLE +ALTER TABLE t2 ENCRYPTION_KEY_ID=4, ALGORITHM=COPY; +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ +SHOW WARNINGS; +SHOW CREATE TABLE t2; +DROP TABLE t2; + +--error ER_CANT_CREATE_TABLE +CREATE TABLE t3 (a int not null primary key) engine=innodb ENCRYPTION_KEY_ID=4; +SHOW WARNINGS; + # reset system --disable_query_log EVAL SET GLOBAL innodb_file_per_table = $innodb_file_per_table_orig; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 8baee1d30fc..b3a830e47c3 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -11958,21 +11958,18 @@ ha_innobase::check_table_options( options->encryption_key_id = FIL_DEFAULT_ENCRYPTION_KEY; } - /* If default encryption is used make sure that used kay is found - from key file. */ - if (encrypt == FIL_ENCRYPTION_DEFAULT && - !srv_encrypt_tables && - options->encryption_key_id != FIL_DEFAULT_ENCRYPTION_KEY) { - if (!encryption_key_id_exists((unsigned int)options->encryption_key_id)) { - push_warning_printf( - thd, Sql_condition::WARN_LEVEL_WARN, - HA_WRONG_CREATE_OPTION, - "InnoDB: ENCRYPTION_KEY_ID %u not available", - (uint)options->encryption_key_id + /* If default encryption is used and encryption is disabled, you may + not use nondefault encryption_key_id as it is not stored anywhere. */ + if (encrypt == FIL_ENCRYPTION_DEFAULT + && !srv_encrypt_tables + && options->encryption_key_id != FIL_DEFAULT_ENCRYPTION_KEY) { + compile_time_assert(FIL_DEFAULT_ENCRYPTION_KEY == 1); + push_warning_printf( + thd, Sql_condition::WARN_LEVEL_WARN, + HA_WRONG_CREATE_OPTION, + "InnoDB: innodb_encrypt_tables=OFF only allows ENCRYPTION_KEY_ID=1" ); - return "ENCRYPTION_KEY_ID"; - - } + return "ENCRYPTION_KEY_ID"; } /* Check atomic writes requirements */ diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index a4434cd0d77..05066512db9 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -12525,21 +12525,18 @@ ha_innobase::check_table_options( options->encryption_key_id = FIL_DEFAULT_ENCRYPTION_KEY; } - /* If default encryption is used make sure that used kay is found - from key file. */ - if (encrypt == FIL_ENCRYPTION_DEFAULT && - !srv_encrypt_tables && - options->encryption_key_id != FIL_DEFAULT_ENCRYPTION_KEY) { - if (!encryption_key_id_exists((unsigned int)options->encryption_key_id)) { - push_warning_printf( - thd, Sql_condition::WARN_LEVEL_WARN, - HA_WRONG_CREATE_OPTION, - "InnoDB: ENCRYPTION_KEY_ID %u not available", - (uint)options->encryption_key_id + /* If default encryption is used and encryption is disabled, you may + not use nondefault encryption_key_id as it is not stored anywhere. */ + if (encrypt == FIL_ENCRYPTION_DEFAULT + && !srv_encrypt_tables + && options->encryption_key_id != FIL_DEFAULT_ENCRYPTION_KEY) { + compile_time_assert(FIL_DEFAULT_ENCRYPTION_KEY == 1); + push_warning_printf( + thd, Sql_condition::WARN_LEVEL_WARN, + HA_WRONG_CREATE_OPTION, + "InnoDB: innodb_encrypt_tables=OFF only allows ENCRYPTION_KEY_ID=1" ); - return "ENCRYPTION_KEY_ID"; - - } + return "ENCRYPTION_KEY_ID"; } /* Check atomic writes requirements */ From 9c026273a923f3433ad622124d7a008ce6b5c487 Mon Sep 17 00:00:00 2001 From: Anel Husakovic Date: Tue, 6 Nov 2018 10:58:02 +0000 Subject: [PATCH 06/20] Add implementation in .h and delete unneccessery printing --- storage/innobase/handler/ha_innodb.cc | 11 ----------- storage/innobase/handler/ha_innodb.h | 2 +- storage/xtradb/handler/ha_innodb.cc | 11 ----------- storage/xtradb/handler/ha_innodb.h | 2 +- 4 files changed, 2 insertions(+), 24 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 2092cd113a5..85c5529a096 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -9039,17 +9039,6 @@ next_record: return(HA_ERR_END_OF_FILE); } -/************************************************************************* -*/ - -void -ha_innobase::ft_end() -{ - fprintf(stderr, "ft_end()\n"); - - rnd_end(); -} - /*********************************************************************//** Stores a reference to the current row to 'ref' field of the handle. Note that in the case where we have generated the clustered index for the diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h index f9e98d5dfe6..e09d2d81e35 100644 --- a/storage/innobase/handler/ha_innodb.h +++ b/storage/innobase/handler/ha_innodb.h @@ -153,7 +153,7 @@ class ha_innobase: public handler int rnd_pos(uchar * buf, uchar *pos); int ft_init(); - void ft_end(); + void ft_end() { rnd_end(); } FT_INFO *ft_init_ext(uint flags, uint inx, String* key); int ft_read(uchar* buf); diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 127309a6b65..52ef0b01534 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -9810,17 +9810,6 @@ next_record: return(HA_ERR_END_OF_FILE); } -/************************************************************************* -*/ - -void -ha_innobase::ft_end() -{ - fprintf(stderr, "ft_end()\n"); - - rnd_end(); -} - /*********************************************************************//** Stores a reference to the current row to 'ref' field of the handle. Note that in the case where we have generated the clustered index for the diff --git a/storage/xtradb/handler/ha_innodb.h b/storage/xtradb/handler/ha_innodb.h index e65e0964f9d..87267789ab3 100644 --- a/storage/xtradb/handler/ha_innodb.h +++ b/storage/xtradb/handler/ha_innodb.h @@ -156,7 +156,7 @@ class ha_innobase: public handler int rnd_pos(uchar * buf, uchar *pos); int ft_init(); - void ft_end(); + void ft_end() { rnd_end(); } FT_INFO *ft_init_ext(uint flags, uint inx, String* key); int ft_read(uchar* buf); From 9bf8568c042c2119c93a29e4ef89a63e76a84813 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 9 Oct 2018 18:10:48 +0200 Subject: [PATCH 07/20] fix an old typo --- sql/table.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/table.cc b/sql/table.cc index ccb580badf3..1e09bb83210 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -2433,7 +2433,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, if (!(key_part->key_part_flag & (HA_BLOB_PART | HA_VAR_LENGTH_PART | HA_BIT_PART)) && key_part->type != HA_KEYTYPE_FLOAT && - key_part->type == HA_KEYTYPE_DOUBLE) + key_part->type != HA_KEYTYPE_DOUBLE) key_part->key_part_flag|= HA_CAN_MEMCMP; } keyinfo->usable_key_parts= usable_parts; // Filesort From 4990b0e1ee463d98c773429e0007b11eb335ae79 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 19 Oct 2018 12:51:57 +0200 Subject: [PATCH 08/20] MDEV-17496 aws plugin is no longer built for debian/ubuntu ping is not a reliable way to detect github's availability --- debian/autobake-deb.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/autobake-deb.sh b/debian/autobake-deb.sh index 4d488767a97..4e66f13615f 100755 --- a/debian/autobake-deb.sh +++ b/debian/autobake-deb.sh @@ -102,7 +102,7 @@ fi # AWS SDK also requires the build machine to have network access and git, so # it cannot be part of the base version included in Linux distros, but a pure # custom built plugin. -if [[ $GCCVERSION -gt 40800 ]] && [[ ! $TRAVIS ]] && ping -c 1 github.com +if [[ $GCCVERSION -gt 40800 ]] && [[ ! $TRAVIS ]] && wget --timeout 15 --tries 1 --quiet --output-document /dev/null https://github.com/ then cat <> debian/control From 564a63b5a35b644dc038965b4cf3b0cbfdc398af Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Mon, 15 Oct 2018 12:06:00 +0200 Subject: [PATCH 09/20] MDEV-14429 sql_safe_updates in my.cnf not work --- mysql-test/main/mysqld--help.result | 5 +++++ .../suite/sys_vars/r/sysvars_server_notembedded.result | 2 +- sql/sys_vars.cc | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result index 5a7153f32d3..1c7e9cd839d 100644 --- a/mysql-test/main/mysqld--help.result +++ b/mysql-test/main/mysqld--help.result @@ -1209,6 +1209,10 @@ The following specify which files/extra groups are read (specified before remain NO_AUTO_CREATE_USER, HIGH_NOT_PRECEDENCE, NO_ENGINE_SUBSTITUTION, PAD_CHAR_TO_FULL_LENGTH, EMPTY_STRING_IS_NULL, SIMULTANEOUS_ASSIGNMENT + --sql-safe-updates If set to 1, UPDATEs and DELETEs need either a key in the + WHERE clause, or a LIMIT clause, or else they will + aborted. Prevents the common mistake of accidentally + deleting or updating every row in a table. --stack-trace Print a symbolic stack trace on failure (Defaults to on; use --skip-stack-trace to disable.) --standard-compliant-cte @@ -1664,6 +1668,7 @@ slow-launch-time 2 slow-query-log FALSE sort-buffer-size 2097152 sql-mode STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION +sql-safe-updates FALSE stack-trace TRUE standard-compliant-cte TRUE stored-program-cache 256 diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result index e8e4d671eb9..47df962b7c4 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result @@ -4799,7 +4799,7 @@ NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL ENUM_VALUE_LIST OFF,ON READ_ONLY NO -COMMAND_LINE_ARGUMENT NULL +COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME SQL_SELECT_LIMIT SESSION_VALUE 18446744073709551615 GLOBAL_VALUE 18446744073709551615 diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 6d4c135683a..369c9a6222a 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -4119,7 +4119,7 @@ static Sys_var_bit Sys_safe_updates( "sql_safe_updates", "If set to 1, UPDATEs and DELETEs need either a key in " "the WHERE clause, or a LIMIT clause, or else they will aborted. Prevents " "the common mistake of accidentally deleting or updating every row in a table.", - SESSION_VAR(option_bits), NO_CMD_LINE, OPTION_SAFE_UPDATES, + SESSION_VAR(option_bits), CMD_LINE(OPT_ARG), OPTION_SAFE_UPDATES, DEFAULT(FALSE)); static Sys_var_bit Sys_buffer_results( From 89a87e8e422bc342ed31764fa858898dabbf0be4 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 20 Oct 2018 14:05:33 +0200 Subject: [PATCH 10/20] MDEV-14429 sql_safe_updates in my.cnf not work add a test case --- mysql-test/include/mtr_warnings.sql | 2 +- mysql-test/main/sql_safe_updates.opt | 1 + mysql-test/main/sql_safe_updates.result | 3 +++ mysql-test/main/sql_safe_updates.test | 4 ++++ 4 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 mysql-test/main/sql_safe_updates.opt create mode 100644 mysql-test/main/sql_safe_updates.result create mode 100644 mysql-test/main/sql_safe_updates.test diff --git a/mysql-test/include/mtr_warnings.sql b/mysql-test/include/mtr_warnings.sql index b7b2a316dfb..524ea0f4859 100644 --- a/mysql-test/include/mtr_warnings.sql +++ b/mysql-test/include/mtr_warnings.sql @@ -242,7 +242,7 @@ BEGIN DECLARE `pos` bigint unsigned; -- Don't write these queries to binlog - SET SQL_LOG_BIN=0; + SET SQL_LOG_BIN=0, SQL_SAFE_UPDATES=0; -- -- Remove mark from lines that are suppressed by global suppressions diff --git a/mysql-test/main/sql_safe_updates.opt b/mysql-test/main/sql_safe_updates.opt new file mode 100644 index 00000000000..7ffaa462d01 --- /dev/null +++ b/mysql-test/main/sql_safe_updates.opt @@ -0,0 +1 @@ +--enable-sql-safe-updates diff --git a/mysql-test/main/sql_safe_updates.result b/mysql-test/main/sql_safe_updates.result new file mode 100644 index 00000000000..356cd36bad9 --- /dev/null +++ b/mysql-test/main/sql_safe_updates.result @@ -0,0 +1,3 @@ +select @@sql_safe_updates; +@@sql_safe_updates +1 diff --git a/mysql-test/main/sql_safe_updates.test b/mysql-test/main/sql_safe_updates.test new file mode 100644 index 00000000000..18decd0ff2c --- /dev/null +++ b/mysql-test/main/sql_safe_updates.test @@ -0,0 +1,4 @@ +# +# MDEV-14429 sql_safe_updates in my.cnf not work +# +select @@sql_safe_updates; From 7dfcb871079ce03c4ad0f6562f94b5a3cd0e1ecb Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Tue, 6 Nov 2018 17:23:39 +0300 Subject: [PATCH 11/20] Disable rocksdb.com_rpc_tx test It tests SQL-level feature that is available in FB/MySQL and not in MariaDB --- storage/rocksdb/mysql-test/rocksdb/t/disabled.def | 1 + 1 file changed, 1 insertion(+) diff --git a/storage/rocksdb/mysql-test/rocksdb/t/disabled.def b/storage/rocksdb/mysql-test/rocksdb/t/disabled.def index 6237afaa283..72cf650ca3e 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/disabled.def +++ b/storage/rocksdb/mysql-test/rocksdb/t/disabled.def @@ -24,6 +24,7 @@ select_for_update_skip_locked_nowait: MDEV-11481 create_no_primary_key_table: MariaDB doesn't have --block_create_no_primary_key explicit_snapshot: MariaDB doesn't support Shared/Explicit snapshots percona_nonflushing_analyze_debug : Requires Percona Server's Non-flushing ANALYZE feature +com_rpc_tx : Requires connection attributes and detached sessions ## ## Tests that do not fit MariaDB's test environment. Upstream seems to test From 54b8856b87629e9fec075e3a71179eefc7fa02ac Mon Sep 17 00:00:00 2001 From: Igor Mazur Date: Sat, 11 Nov 2017 22:32:39 +0200 Subject: [PATCH 12/20] MDEV-14528 Track master timestamp in case rolling back to serial replication When replicated events are from Master unaware of MariaDB GTID their handling by the Parallel slave misses Seconds_Behind_Master updating. In the bug condition the Show-Slave-Status' field remains unchanged. Because in such case event execution is sequential the bug is fixed with deploying the same logics as in the explicit single-threaded mode with is to set Relay_log_event::last_master_timestamp member early at the end of event reading from the relay log. --- mysql-test/suite/rpl/r/rpl_old_master.result | 3 +++ mysql-test/suite/rpl/t/rpl_old_master.test | 8 ++++++++ sql/slave.cc | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/mysql-test/suite/rpl/r/rpl_old_master.result b/mysql-test/suite/rpl/r/rpl_old_master.result index dd3de4d327b..f985bee6832 100644 --- a/mysql-test/suite/rpl/r/rpl_old_master.result +++ b/mysql-test/suite/rpl/r/rpl_old_master.result @@ -9,7 +9,10 @@ connection slave; SET @old_parallel= @@GLOBAL.slave_parallel_threads; SET GLOBAL slave_parallel_threads=10; CHANGE MASTER TO master_host='127.0.0.1', master_port=SERVER_MYPORT_1, master_user='root', master_log_file='master-bin.000001', master_log_pos=4; +FLUSH TABLES WITH READ LOCK; include/start_slave.inc +include/wait_for_slave_param.inc [Seconds_Behind_Master] +UNLOCK TABLES; connection master; CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t2 VALUES (1); diff --git a/mysql-test/suite/rpl/t/rpl_old_master.test b/mysql-test/suite/rpl/t/rpl_old_master.test index 8f61d6979cd..6ddc227fc14 100644 --- a/mysql-test/suite/rpl/t/rpl_old_master.test +++ b/mysql-test/suite/rpl/t/rpl_old_master.test @@ -27,7 +27,15 @@ SET @old_parallel= @@GLOBAL.slave_parallel_threads; SET GLOBAL slave_parallel_threads=10; --replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1 eval CHANGE MASTER TO master_host='127.0.0.1', master_port=$SERVER_MYPORT_1, master_user='root', master_log_file='master-bin.000001', master_log_pos=4; + +# Block execution yet when the blocked query timestamp has been already accounted +FLUSH TABLES WITH READ LOCK; --source include/start_slave.inc +--let $slave_param = Seconds_Behind_Master +--let $slave_param_value = 1 +--let $slave_param_comparison= >= +--source include/wait_for_slave_param.inc +UNLOCK TABLES; --connection master CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB; diff --git a/sql/slave.cc b/sql/slave.cc index 7e52822ca51..d6223453a5b 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3960,6 +3960,11 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli, This is the case for pre-10.0 events without GTID, and for handling slave_skip_counter. */ + if (!(ev->is_artificial_event() || ev->is_relay_log_event() || (ev->when == 0))) + { + rli->last_master_timestamp= ev->when + (time_t) ev->exec_time; + DBUG_ASSERT(rli->last_master_timestamp >= 0); + } } if (typ == GTID_EVENT) From 04789ec801b6d0955c70b0387973f017424062b4 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Tue, 6 Nov 2018 09:29:41 +0100 Subject: [PATCH 13/20] MDEV-14781 - threadpool slowdown with slow ssl handshake. Fix is not to use blocking socket IO during SSL handshake. With non-blocking socket IO, threadpool is able to utilize the wait notification callbacks, that vio_io_wait() is calling whenever socket would block. --- vio/viossl.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/vio/viossl.c b/vio/viossl.c index 000a526a892..f65a0622f3d 100644 --- a/vio/viossl.c +++ b/vio/viossl.c @@ -124,6 +124,9 @@ static my_bool ssl_should_retry(Vio *vio, int ret, enum enum_vio_io_event *event default: should_retry= FALSE; ssl_set_sys_error(ssl_error); +#ifndef HAVE_YASSL + ERR_clear_error(); +#endif break; } @@ -315,21 +318,16 @@ static int ssl_do(struct st_VioSSLFd *ptr, Vio *vio, long timeout, { int r; SSL *ssl; - my_bool unused; - my_bool was_blocking; my_socket sd= mysql_socket_getfd(vio->mysql_socket); DBUG_ENTER("ssl_do"); DBUG_PRINT("enter", ("ptr: %p, sd: %d ctx: %p", ptr, (int)sd, ptr->ssl_context)); - /* Set socket to blocking if not already set */ - vio_blocking(vio, 1, &was_blocking); if (!(ssl= SSL_new(ptr->ssl_context))) { DBUG_PRINT("error", ("SSL_new failure")); *errptr= ERR_get_error(); - vio_blocking(vio, was_blocking, &unused); DBUG_RETURN(1); } DBUG_PRINT("info", ("ssl: %p timeout: %ld", ssl, timeout)); @@ -360,7 +358,6 @@ static int ssl_do(struct st_VioSSLFd *ptr, Vio *vio, long timeout, DBUG_PRINT("error", ("SSL_connect/accept failure")); *errptr= SSL_errno(ssl, r); SSL_free(ssl); - vio_blocking(vio, was_blocking, &unused); DBUG_RETURN(1); } @@ -371,7 +368,6 @@ static int ssl_do(struct st_VioSSLFd *ptr, Vio *vio, long timeout, */ if (vio_reset(vio, VIO_TYPE_SSL, SSL_get_fd(ssl), ssl, 0)) { - vio_blocking(vio, was_blocking, &unused); DBUG_RETURN(1); } From 54b2e1c1bea357ca37ce537e24c6c120a43f5958 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Thu, 5 Jul 2018 17:49:44 +0200 Subject: [PATCH 14/20] MDEV-16697: Fix difference between 32bit/windows and 64bit systems in allowed select nest level --- include/my_global.h | 1 - mysql-test/main/parser.result | 21 +++++++++++++++++++++ mysql-test/main/parser.test | 17 +++++++++++++++++ sql/item_subselect.cc | 3 +-- sql/item_sum.cc | 24 +++++++++++++----------- sql/sql_base.cc | 3 +-- sql/sql_const.h | 2 +- sql/sql_delete.cc | 2 +- sql/sql_lex.cc | 4 ++-- sql/sql_lex.h | 4 ++++ sql/sql_partition.cc | 2 +- sql/sql_prepare.cc | 2 +- sql/sql_select.cc | 12 ++++++------ sql/sql_update.cc | 2 +- 14 files changed, 70 insertions(+), 29 deletions(-) diff --git a/include/my_global.h b/include/my_global.h index 7904eed3dfc..2922b74192a 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -986,7 +986,6 @@ typedef unsigned long my_off_t; TODO Convert these to use Bitmap class. */ typedef ulonglong table_map; /* Used for table bits in join */ -typedef ulong nesting_map; /* Used for flags of nesting constructs */ /* often used type names - opaque declarations */ typedef const struct charset_info_st CHARSET_INFO; diff --git a/mysql-test/main/parser.result b/mysql-test/main/parser.result index 2394c958b47..32055538700 100644 --- a/mysql-test/main/parser.result +++ b/mysql-test/main/parser.result @@ -1680,3 +1680,24 @@ SELECT without VERSIONING FROM t1 SELECT without WITHOUT FROM t1 DROP PROCEDURE p2; DROP PROCEDURE p1; +# +# MDEV-16697: Fix difference between 32bit/windows and 64bit +# systems in allowed select nest level +# +SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT +(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT +(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT +(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT +(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT +(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT +(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT +(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT +1 +))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))); +(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT +(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT +(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT +(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT +(SELECT +1 +End of 10.3 tests diff --git a/mysql-test/main/parser.test b/mysql-test/main/parser.test index 8faab613a0c..65db9c3cda3 100644 --- a/mysql-test/main/parser.test +++ b/mysql-test/main/parser.test @@ -1443,3 +1443,20 @@ CALL p2('without'); DROP PROCEDURE p2; DROP PROCEDURE p1; + + +--echo # +--echo # MDEV-16697: Fix difference between 32bit/windows and 64bit +--echo # systems in allowed select nest level +--echo # + SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT +(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT +(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT +(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT +(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT +(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT +(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT +(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT +1 +))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))); +--echo End of 10.3 tests diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 1947a45186a..207aa9a25c9 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -1983,8 +1983,7 @@ bool Item_allany_subselect::transform_into_max_min(JOIN *join) print_where(item, "rewrite with MIN/MAX", QT_ORDINARY);); save_allow_sum_func= thd->lex->allow_sum_func; - thd->lex->allow_sum_func|= - (nesting_map)1 << thd->lex->current_select->nest_level; + thd->lex->allow_sum_func.set_bit(thd->lex->current_select->nest_level); /* Item_sum_(max|min) can't substitute other item => we can use 0 as reference, also Item_sum_(max|min) can't be fixed after creation, so diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 3163fb9ea2e..44e5a86c863 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -72,14 +72,15 @@ size_t Item_sum::ram_limitation(THD *thd) bool Item_sum::init_sum_func_check(THD *thd) { SELECT_LEX *curr_sel= thd->lex->current_select; - if (curr_sel && !curr_sel->name_visibility_map) + if (curr_sel && curr_sel->name_visibility_map.is_clear_all()) { for (SELECT_LEX *sl= curr_sel; sl; sl= sl->context.outer_select()) { - curr_sel->name_visibility_map|= (1 << sl-> nest_level); + curr_sel->name_visibility_map.set_bit(sl->nest_level); } } - if (!curr_sel || !(thd->lex->allow_sum_func & curr_sel->name_visibility_map)) + if (!curr_sel || + !(thd->lex->allow_sum_func.is_overlapping(curr_sel->name_visibility_map))) { my_message(ER_INVALID_GROUP_FUNC_USE, ER_THD(thd, ER_INVALID_GROUP_FUNC_USE), MYF(0)); @@ -155,10 +156,11 @@ bool Item_sum::init_sum_func_check(THD *thd) bool Item_sum::check_sum_func(THD *thd, Item **ref) { SELECT_LEX *curr_sel= thd->lex->current_select; - nesting_map allow_sum_func= (thd->lex->allow_sum_func & - curr_sel->name_visibility_map); + nesting_map allow_sum_func(thd->lex->allow_sum_func); + allow_sum_func.intersect(curr_sel->name_visibility_map); bool invalid= FALSE; - DBUG_ASSERT(curr_sel->name_visibility_map); // should be set already + // should be set already + DBUG_ASSERT(!curr_sel->name_visibility_map.is_clear_all()); /* Window functions can not be used as arguments to sum functions. @@ -189,10 +191,10 @@ bool Item_sum::check_sum_func(THD *thd, Item **ref) If it is there under a construct where it is not allowed we report an error. */ - invalid= !(allow_sum_func & ((nesting_map)1 << max_arg_level)); + invalid= !(allow_sum_func.is_set(max_arg_level)); } else if (max_arg_level >= 0 || - !(allow_sum_func & ((nesting_map)1 << nest_level))) + !(allow_sum_func.is_set(nest_level))) { /* The set function can be aggregated only in outer subqueries. @@ -202,7 +204,7 @@ bool Item_sum::check_sum_func(THD *thd, Item **ref) if (register_sum_func(thd, ref)) return TRUE; invalid= aggr_level < 0 && - !(allow_sum_func & ((nesting_map)1 << nest_level)); + !(allow_sum_func.is_set(nest_level)); if (!invalid && thd->variables.sql_mode & MODE_ANSI) invalid= aggr_level < 0 && max_arg_level < nest_level; } @@ -354,14 +356,14 @@ bool Item_sum::register_sum_func(THD *thd, Item **ref) sl= sl->context.outer_select()) { if (aggr_level < 0 && - (allow_sum_func & ((nesting_map)1 << sl->nest_level))) + (allow_sum_func.is_set(sl->nest_level))) { /* Found the most nested subquery where the function can be aggregated */ aggr_level= sl->nest_level; aggr_sel= sl; } } - if (sl && (allow_sum_func & ((nesting_map)1 << sl->nest_level))) + if (sl && (allow_sum_func.is_set(sl->nest_level))) { /* We reached the subquery of level max_arg_level and checked diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 52259e4b9e2..cf9a15dec68 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -7372,8 +7372,7 @@ bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array, thd->column_usage= column_usage; DBUG_PRINT("info", ("thd->column_usage: %d", thd->column_usage)); if (allow_sum_func) - thd->lex->allow_sum_func|= - (nesting_map)1 << thd->lex->current_select->nest_level; + thd->lex->allow_sum_func.set_bit(thd->lex->current_select->nest_level); thd->where= THD::DEFAULT_WHERE; save_is_item_list_lookup= thd->lex->current_select->is_item_list_lookup; thd->lex->current_select->is_item_list_lookup= 0; diff --git a/sql/sql_const.h b/sql/sql_const.h index e28a0649f04..be26de872df 100644 --- a/sql/sql_const.h +++ b/sql/sql_const.h @@ -84,7 +84,7 @@ #define MAX_FIELDS 4096 /* Limit in the .frm file */ #define MAX_PARTITIONS 8192 -#define MAX_SELECT_NESTING (sizeof(nesting_map)*8-1) +#define MAX_SELECT_NESTING (SELECT_NESTING_MAP_SIZE - 1) #define MAX_SORT_MEMORY 2048*1024 #define MIN_SORT_MEMORY 1024 diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index fc400252397..6cf89ed09fc 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -936,7 +936,7 @@ int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, List all_fields; *delete_while_scanning= true; - thd->lex->allow_sum_func= 0; + thd->lex->allow_sum_func.clear_all(); if (setup_tables_and_check_access(thd, &thd->lex->select_lex.context, &thd->lex->select_lex.top_join_list, table_list, diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 11bb50a4231..e5bfccfed29 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -734,7 +734,7 @@ void LEX::start(THD *thd_arg) profile_options= PROFILE_NONE; nest_level=0 ; select_lex.nest_level_base= &unit; - allow_sum_func= 0; + allow_sum_func.clear_all(); in_sum_func= NULL; used_tables= 0; @@ -2335,7 +2335,7 @@ void st_select_lex::init_select() m_non_agg_field_used= false; m_agg_func_used= false; m_custom_agg_func_used= false; - name_visibility_map= 0; + name_visibility_map.clear_all(); with_dep= 0; join= 0; lock_type= TL_READ_DEFAULT; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 48363fdd670..ea2f61c3992 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -33,6 +33,10 @@ #include "sql_tvc.h" #include "item.h" +/* Used for flags of nesting constructs */ +#define SELECT_NESTING_MAP_SIZE 64 +typedef Bitmap nesting_map; + /* YACC and LEX Definitions */ diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 151b94d1187..9e6c333d3c9 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -857,7 +857,7 @@ static bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table, const bool save_agg_field= thd->lex->current_select->non_agg_field_used(); const bool save_agg_func= thd->lex->current_select->agg_func_used(); const nesting_map saved_allow_sum_func= thd->lex->allow_sum_func; - thd->lex->allow_sum_func= 0; + thd->lex->allow_sum_func.clear_all(); if (likely(!(error= func_expr->fix_fields_if_needed(thd, (Item**)&func_expr)))) func_expr->walk(&Item::post_fix_fields_part_expr_processor, 0, NULL); diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index c4871bdcc80..5324b2dd305 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -3041,7 +3041,7 @@ void reinit_stmt_before_use(THD *thd, LEX *lex) lex->result->cleanup(); lex->result->set_thd(thd); } - lex->allow_sum_func= 0; + lex->allow_sum_func.clear_all(); lex->in_sum_func= NULL; DBUG_VOID_RETURN; } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index f1230666026..f3e69ba2ead 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -645,7 +645,7 @@ setup_without_group(THD *thd, Ref_ptr_array ref_pointer_array, const bool saved_non_agg_field_used= select->non_agg_field_used(); DBUG_ENTER("setup_without_group"); - thd->lex->allow_sum_func&= ~((nesting_map)1 << select->nest_level); + thd->lex->allow_sum_func.clear_bit(select->nest_level); res= setup_conds(thd, tables, leaves, conds); if (thd->lex->current_select->first_cond_optimization) { @@ -658,18 +658,18 @@ setup_without_group(THD *thd, Ref_ptr_array ref_pointer_array, /* it's not wrong to have non-aggregated columns in a WHERE */ select->set_non_agg_field_used(saved_non_agg_field_used); - thd->lex->allow_sum_func|= (nesting_map)1 << select->nest_level; + thd->lex->allow_sum_func.set_bit(select->nest_level); save_place= thd->lex->current_select->context_analysis_place; thd->lex->current_select->context_analysis_place= IN_ORDER_BY; res= res || setup_order(thd, ref_pointer_array, tables, fields, all_fields, order); - thd->lex->allow_sum_func&= ~((nesting_map)1 << select->nest_level); + thd->lex->allow_sum_func.clear_bit(select->nest_level); thd->lex->current_select->context_analysis_place= IN_GROUP_BY; res= res || setup_group(thd, ref_pointer_array, tables, fields, all_fields, group, hidden_group_fields); thd->lex->current_select->context_analysis_place= save_place; - thd->lex->allow_sum_func|= (nesting_map)1 << select->nest_level; + thd->lex->allow_sum_func.set_bit(select->nest_level); res= res || setup_windows(thd, ref_pointer_array, tables, fields, all_fields, win_specs, win_funcs); thd->lex->allow_sum_func= save_allow_sum_func; @@ -1117,7 +1117,7 @@ JOIN::prepare(TABLE_LIST *tables_init, select_lex->master_unit()->global_parameters()) { nesting_map save_allow_sum_func= thd->lex->allow_sum_func; - thd->lex->allow_sum_func|= (nesting_map)1 << select_lex->nest_level; + thd->lex->allow_sum_func.set_bit(select_lex->nest_level); thd->where= "order clause"; for (ORDER *order= select_lex->order_list.first; order; order= order->next) { @@ -1135,7 +1135,7 @@ JOIN::prepare(TABLE_LIST *tables_init, { nesting_map save_allow_sum_func= thd->lex->allow_sum_func; thd->where="having clause"; - thd->lex->allow_sum_func|= (nesting_map)1 << select_lex_arg->nest_level; + thd->lex->allow_sum_func.set_bit(select_lex_arg->nest_level); select_lex->having_fix_field= 1; /* Wrap alone field in HAVING clause in case it will be outer field diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 7a496172aed..1651faf7c87 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -1255,7 +1255,7 @@ bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list, table_list->register_want_access(SELECT_ACL); #endif - thd->lex->allow_sum_func= 0; + thd->lex->allow_sum_func.clear_all(); /* We do not call DT_MERGE_FOR_INSERT because it has no sense for simple From e82ebb8f06674a22d959b91415c084ed34fe994d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 7 Nov 2018 13:08:00 +0200 Subject: [PATCH 15/20] MDEV-14528: Disable a failing test --- mysql-test/suite/rpl/disabled.def | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/rpl/disabled.def b/mysql-test/suite/rpl/disabled.def index e37ad842790..3b740cbf974 100644 --- a/mysql-test/suite/rpl/disabled.def +++ b/mysql-test/suite/rpl/disabled.def @@ -17,3 +17,4 @@ rpl_row_binlog_max_cache_size : MDEV-11092 rpl_blackhole : MDEV-11094 rpl_row_mysqlbinlog : MDEV-11095 rpl_row_index_choice : MDEV-11666 +rpl_delayed_slave : MDEV-14528 From 6567a94c71b0bdb8b5c31011cec04972a353b05d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 7 Nov 2018 17:42:41 +0200 Subject: [PATCH 16/20] MDEV-13134: Merge tests to innodb.alter_algorithm Remove the separate test innodb.alter_instant, because it can be easily mistaken for innodb.instant_alter, which in turn is covering various instant ALTER TABLE operations. --- .../suite/innodb/include/alter_nocopy.inc | 33 ----- .../innodb/include/alter_nocopy_fail.inc | 51 ------- .../innodb/r/alter_algorithm,INPLACE.rdiff | 63 ++++++++- .../innodb/r/alter_algorithm,INSTANT.rdiff | 63 ++++++++- .../innodb/r/alter_algorithm,NOCOPY.rdiff | 63 ++++++++- .../suite/innodb/r/alter_algorithm.result | 54 +++++++- .../suite/innodb/r/alter_instant,COPY.rdiff | 61 --------- .../innodb/r/alter_instant,INPLACE.rdiff | 11 -- .../innodb/r/alter_instant,INSTANT.rdiff | 11 -- .../suite/innodb/r/alter_instant.result | 50 ------- .../suite/innodb/t/alter_algorithm.test | 127 +++++++++++++++++- mysql-test/suite/innodb/t/alter_instant.test | 45 ------- 12 files changed, 348 insertions(+), 284 deletions(-) delete mode 100644 mysql-test/suite/innodb/include/alter_nocopy.inc delete mode 100644 mysql-test/suite/innodb/include/alter_nocopy_fail.inc delete mode 100644 mysql-test/suite/innodb/r/alter_instant,COPY.rdiff delete mode 100644 mysql-test/suite/innodb/r/alter_instant,INPLACE.rdiff delete mode 100644 mysql-test/suite/innodb/r/alter_instant,INSTANT.rdiff delete mode 100644 mysql-test/suite/innodb/r/alter_instant.result delete mode 100644 mysql-test/suite/innodb/t/alter_instant.test diff --git a/mysql-test/suite/innodb/include/alter_nocopy.inc b/mysql-test/suite/innodb/include/alter_nocopy.inc deleted file mode 100644 index 00cab8c47e5..00000000000 --- a/mysql-test/suite/innodb/include/alter_nocopy.inc +++ /dev/null @@ -1,33 +0,0 @@ -CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL, - f3 INT AS (f2 * f2) VIRTUAL, - f4 INT NOT NULL UNIQUE, - f5 INT NOT NULL, - INDEX`idx`(f2))ENGINE=INNODB; - -CREATE TABLE t2(f1 INT NOT NULL, f2 INT NOT NULL, - INDEX(f1), - FOREIGN KEY `fidx` (f1) REFERENCES t1(f1))ENGINE=INNODB; - -INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4); - -SELECT @@alter_algorithm; - ---enable_info ---error $error_code ---eval ALTER TABLE t1 ADD INDEX idx1(f4), page_compressed=1 - ---error $error_code ---eval ALTER TABLE t1 DROP INDEX idx, page_compression_level=5 - ---error $error_code ---eval ALTER TABLE t1 ADD UNIQUE INDEX u1(f2) - ---error $error_code ---eval ALTER TABLE t1 DROP INDEX f4, page_compression_level=9 - -SET foreign_key_checks = 0; ---error $error_code ---eval ALTER TABLE t1 ADD FOREIGN KEY(f5) REFERENCES t2(f1) - -DROP TABLE t2, t1; ---disable_info diff --git a/mysql-test/suite/innodb/include/alter_nocopy_fail.inc b/mysql-test/suite/innodb/include/alter_nocopy_fail.inc deleted file mode 100644 index a075cf96e3c..00000000000 --- a/mysql-test/suite/innodb/include/alter_nocopy_fail.inc +++ /dev/null @@ -1,51 +0,0 @@ -CREATE TABLE t1(f1 INT NOT NULL, - f2 INT NOT NULL, - f3 INT NULL, - f4 INT as (f2) STORED, - f5 INT as (f3) STORED, - PRIMARY KEY(f1))ROW_FORMAT=COMPRESSED, ENGINE=INNODB; -INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1); - -SELECT @@alter_algorithm; - ---enable_info ---echo # All the following cases needs table rebuild - ---echo # Add and Drop primary key ---error $error_code ---eval ALTER TABLE t1 ADD COLUMN col1 INT NOT NULL,DROP PRIMARY KEY,ADD PRIMARY KEY(col1) - ---echo # Make existing column NULLABLE ---error $error_code ---eval ALTER TABLE t1 MODIFY f2 INT - ---echo # Make existing column NON-NULLABLE ---error $error_code ---eval ALTER TABLE t1 MODIFY f3 INT NOT NULL - ---echo # Drop Stored Column ---error $error_code ---eval ALTER TABLE t1 DROP COLUMN f5 - ---echo # Add base non-generated column as a last column in the compressed table ---error $error_code ---eval ALTER TABLE t1 ADD COLUMN f6 INT NOT NULL - ---echo # Add base non-generated column but not in the last position ---error $error_code ---eval ALTER TABLE t1 ADD COLUMN f7 INT NOT NULL after f3 - ---echo # Force the table to rebuild ---error $error_code ---eval ALTER TABLE t1 FORCE - ---echo # Row format changes ---error $error_code ---eval ALTER TABLE t1 ROW_FORMAT=COMPRESSED - ---echo # Engine table ---error $error_code ---eval ALTER TABLE t1 ENGINE=INNODB - -DROP TABLE t1; ---disable_info diff --git a/mysql-test/suite/innodb/r/alter_algorithm,INPLACE.rdiff b/mysql-test/suite/innodb/r/alter_algorithm,INPLACE.rdiff index 8178e9ea58e..a1fa20c2ba1 100644 --- a/mysql-test/suite/innodb/r/alter_algorithm,INPLACE.rdiff +++ b/mysql-test/suite/innodb/r/alter_algorithm,INPLACE.rdiff @@ -64,12 +64,9 @@ DROP TABLE t1; affected rows: 0 CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL, -@@ -58,23 +58,23 @@ +@@ -57,22 +57,22 @@ + FOREIGN KEY fidx(f1) REFERENCES t1(f1))ENGINE=INNODB; INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4); - SELECT @@alter_algorithm; - @@alter_algorithm --COPY -+INPLACE ALTER TABLE t1 ADD INDEX idx1(f4), page_compressed=1; -affected rows: 1 -info: Records: 1 Duplicates: 0 Warnings: 0 @@ -99,3 +96,59 @@ +info: Records: 0 Duplicates: 0 Warnings: 0 DROP TABLE t2, t1; affected rows: 0 + CREATE TABLE t1(f1 INT NOT NULL, +@@ -85,27 +85,27 @@ + INSERT INTO t1(f1, f2) VALUES(1, 1); + # Add column at the end of the table + ALTER TABLE t1 ADD COLUMN f4 char(100) default 'BIG WALL'; +-affected rows: 1 +-info: Records: 1 Duplicates: 0 Warnings: 0 ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + # Change virtual column expression + ALTER TABLE t1 CHANGE f3 f3 INT AS (f2 * f2) VIRTUAL; +-affected rows: 1 +-info: Records: 1 Duplicates: 0 Warnings: 0 ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + # Add virtual column + ALTER TABLE t1 ADD COLUMN f5 INT AS (f2) VIRTUAL; +-affected rows: 1 +-info: Records: 1 Duplicates: 0 Warnings: 0 ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + # Rename Column + ALTER TABLE t1 CHANGE f3 vcol INT AS (f2) VIRTUAL; +-affected rows: 1 +-info: Records: 1 Duplicates: 0 Warnings: 0 ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + # Rename table + ALTER TABLE t1 RENAME t3; + affected rows: 0 + # Drop Virtual Column + ALTER TABLE t3 DROP COLUMN vcol; +-affected rows: 1 +-info: Records: 1 Duplicates: 0 Warnings: 0 ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + # Column length varies + ALTER TABLE t2 CHANGE f3 f3 VARCHAR(20); + affected rows: 0 +@@ -113,12 +113,12 @@ + SET foreign_key_checks = 0; + affected rows: 0 + ALTER TABLE t3 ADD FOREIGN KEY fidx(f2) REFERENCES t2(f1); +-affected rows: 1 +-info: Records: 1 Duplicates: 0 Warnings: 0 ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + SET foreign_key_checks = 1; + affected rows: 0 + ALTER TABLE t3 DROP FOREIGN KEY fidx; +-affected rows: 1 +-info: Records: 1 Duplicates: 0 Warnings: 0 ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + DROP TABLE t3, t2; + affected rows: 0 diff --git a/mysql-test/suite/innodb/r/alter_algorithm,INSTANT.rdiff b/mysql-test/suite/innodb/r/alter_algorithm,INSTANT.rdiff index ce2e240bb35..879bba43932 100644 --- a/mysql-test/suite/innodb/r/alter_algorithm,INSTANT.rdiff +++ b/mysql-test/suite/innodb/r/alter_algorithm,INSTANT.rdiff @@ -55,12 +55,9 @@ DROP TABLE t1; affected rows: 0 CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL, -@@ -58,23 +49,18 @@ +@@ -57,22 +48,17 @@ + FOREIGN KEY fidx(f1) REFERENCES t1(f1))ENGINE=INNODB; INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4); - SELECT @@alter_algorithm; - @@alter_algorithm --COPY -+INSTANT ALTER TABLE t1 ADD INDEX idx1(f4), page_compressed=1; -affected rows: 1 -info: Records: 1 Duplicates: 0 Warnings: 0 @@ -85,3 +82,59 @@ +ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: ADD INDEX. Try ALGORITHM=NOCOPY DROP TABLE t2, t1; affected rows: 0 + CREATE TABLE t1(f1 INT NOT NULL, +@@ -85,27 +71,27 @@ + INSERT INTO t1(f1, f2) VALUES(1, 1); + # Add column at the end of the table + ALTER TABLE t1 ADD COLUMN f4 char(100) default 'BIG WALL'; +-affected rows: 1 +-info: Records: 1 Duplicates: 0 Warnings: 0 ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + # Change virtual column expression + ALTER TABLE t1 CHANGE f3 f3 INT AS (f2 * f2) VIRTUAL; +-affected rows: 1 +-info: Records: 1 Duplicates: 0 Warnings: 0 ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + # Add virtual column + ALTER TABLE t1 ADD COLUMN f5 INT AS (f2) VIRTUAL; +-affected rows: 1 +-info: Records: 1 Duplicates: 0 Warnings: 0 ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + # Rename Column + ALTER TABLE t1 CHANGE f3 vcol INT AS (f2) VIRTUAL; +-affected rows: 1 +-info: Records: 1 Duplicates: 0 Warnings: 0 ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + # Rename table + ALTER TABLE t1 RENAME t3; + affected rows: 0 + # Drop Virtual Column + ALTER TABLE t3 DROP COLUMN vcol; +-affected rows: 1 +-info: Records: 1 Duplicates: 0 Warnings: 0 ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + # Column length varies + ALTER TABLE t2 CHANGE f3 f3 VARCHAR(20); + affected rows: 0 +@@ -113,12 +99,12 @@ + SET foreign_key_checks = 0; + affected rows: 0 + ALTER TABLE t3 ADD FOREIGN KEY fidx(f2) REFERENCES t2(f1); +-affected rows: 1 +-info: Records: 1 Duplicates: 0 Warnings: 0 ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + SET foreign_key_checks = 1; + affected rows: 0 + ALTER TABLE t3 DROP FOREIGN KEY fidx; +-affected rows: 1 +-info: Records: 1 Duplicates: 0 Warnings: 0 ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + DROP TABLE t3, t2; + affected rows: 0 diff --git a/mysql-test/suite/innodb/r/alter_algorithm,NOCOPY.rdiff b/mysql-test/suite/innodb/r/alter_algorithm,NOCOPY.rdiff index 5d462e0012d..6db0f2af347 100644 --- a/mysql-test/suite/innodb/r/alter_algorithm,NOCOPY.rdiff +++ b/mysql-test/suite/innodb/r/alter_algorithm,NOCOPY.rdiff @@ -55,12 +55,9 @@ DROP TABLE t1; affected rows: 0 CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL, -@@ -58,23 +49,23 @@ +@@ -57,22 +48,22 @@ + FOREIGN KEY fidx(f1) REFERENCES t1(f1))ENGINE=INNODB; INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4); - SELECT @@alter_algorithm; - @@alter_algorithm --COPY -+NOCOPY ALTER TABLE t1 ADD INDEX idx1(f4), page_compressed=1; -affected rows: 1 -info: Records: 1 Duplicates: 0 Warnings: 0 @@ -90,3 +87,59 @@ +info: Records: 0 Duplicates: 0 Warnings: 0 DROP TABLE t2, t1; affected rows: 0 + CREATE TABLE t1(f1 INT NOT NULL, +@@ -85,27 +76,27 @@ + INSERT INTO t1(f1, f2) VALUES(1, 1); + # Add column at the end of the table + ALTER TABLE t1 ADD COLUMN f4 char(100) default 'BIG WALL'; +-affected rows: 1 +-info: Records: 1 Duplicates: 0 Warnings: 0 ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + # Change virtual column expression + ALTER TABLE t1 CHANGE f3 f3 INT AS (f2 * f2) VIRTUAL; +-affected rows: 1 +-info: Records: 1 Duplicates: 0 Warnings: 0 ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + # Add virtual column + ALTER TABLE t1 ADD COLUMN f5 INT AS (f2) VIRTUAL; +-affected rows: 1 +-info: Records: 1 Duplicates: 0 Warnings: 0 ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + # Rename Column + ALTER TABLE t1 CHANGE f3 vcol INT AS (f2) VIRTUAL; +-affected rows: 1 +-info: Records: 1 Duplicates: 0 Warnings: 0 ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + # Rename table + ALTER TABLE t1 RENAME t3; + affected rows: 0 + # Drop Virtual Column + ALTER TABLE t3 DROP COLUMN vcol; +-affected rows: 1 +-info: Records: 1 Duplicates: 0 Warnings: 0 ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + # Column length varies + ALTER TABLE t2 CHANGE f3 f3 VARCHAR(20); + affected rows: 0 +@@ -113,12 +104,12 @@ + SET foreign_key_checks = 0; + affected rows: 0 + ALTER TABLE t3 ADD FOREIGN KEY fidx(f2) REFERENCES t2(f1); +-affected rows: 1 +-info: Records: 1 Duplicates: 0 Warnings: 0 ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + SET foreign_key_checks = 1; + affected rows: 0 + ALTER TABLE t3 DROP FOREIGN KEY fidx; +-affected rows: 1 +-info: Records: 1 Duplicates: 0 Warnings: 0 ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + DROP TABLE t3, t2; + affected rows: 0 diff --git a/mysql-test/suite/innodb/r/alter_algorithm.result b/mysql-test/suite/innodb/r/alter_algorithm.result index cbefcad5986..3d3a7e85444 100644 --- a/mysql-test/suite/innodb/r/alter_algorithm.result +++ b/mysql-test/suite/innodb/r/alter_algorithm.result @@ -51,14 +51,11 @@ CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL, f3 INT AS (f2 * f2) VIRTUAL, f4 INT NOT NULL UNIQUE, f5 INT NOT NULL, -INDEX`idx`(f2))ENGINE=INNODB; +INDEX idx(f2))ENGINE=INNODB; CREATE TABLE t2(f1 INT NOT NULL, f2 INT NOT NULL, INDEX(f1), -FOREIGN KEY `fidx` (f1) REFERENCES t1(f1))ENGINE=INNODB; +FOREIGN KEY fidx(f1) REFERENCES t1(f1))ENGINE=INNODB; INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4); -SELECT @@alter_algorithm; -@@alter_algorithm -COPY ALTER TABLE t1 ADD INDEX idx1(f4), page_compressed=1; affected rows: 1 info: Records: 1 Duplicates: 0 Warnings: 0 @@ -78,3 +75,50 @@ affected rows: 1 info: Records: 1 Duplicates: 0 Warnings: 0 DROP TABLE t2, t1; affected rows: 0 +CREATE TABLE t1(f1 INT NOT NULL, +f2 INT NOT NULL, +f3 INT AS (f2 * f2) VIRTUAL, +INDEX idx (f2))engine=innodb; +CREATE TABLE t2(f1 INT NOT NULL, f2 INT NOT NULL, +f3 VARCHAR(10), +INDEX(f1))ENGINE=INNODB; +INSERT INTO t1(f1, f2) VALUES(1, 1); +# Add column at the end of the table +ALTER TABLE t1 ADD COLUMN f4 char(100) default 'BIG WALL'; +affected rows: 1 +info: Records: 1 Duplicates: 0 Warnings: 0 +# Change virtual column expression +ALTER TABLE t1 CHANGE f3 f3 INT AS (f2 * f2) VIRTUAL; +affected rows: 1 +info: Records: 1 Duplicates: 0 Warnings: 0 +# Add virtual column +ALTER TABLE t1 ADD COLUMN f5 INT AS (f2) VIRTUAL; +affected rows: 1 +info: Records: 1 Duplicates: 0 Warnings: 0 +# Rename Column +ALTER TABLE t1 CHANGE f3 vcol INT AS (f2) VIRTUAL; +affected rows: 1 +info: Records: 1 Duplicates: 0 Warnings: 0 +# Rename table +ALTER TABLE t1 RENAME t3; +affected rows: 0 +# Drop Virtual Column +ALTER TABLE t3 DROP COLUMN vcol; +affected rows: 1 +info: Records: 1 Duplicates: 0 Warnings: 0 +# Column length varies +ALTER TABLE t2 CHANGE f3 f3 VARCHAR(20); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SET foreign_key_checks = 0; +affected rows: 0 +ALTER TABLE t3 ADD FOREIGN KEY fidx(f2) REFERENCES t2(f1); +affected rows: 1 +info: Records: 1 Duplicates: 0 Warnings: 0 +SET foreign_key_checks = 1; +affected rows: 0 +ALTER TABLE t3 DROP FOREIGN KEY fidx; +affected rows: 1 +info: Records: 1 Duplicates: 0 Warnings: 0 +DROP TABLE t3, t2; +affected rows: 0 diff --git a/mysql-test/suite/innodb/r/alter_instant,COPY.rdiff b/mysql-test/suite/innodb/r/alter_instant,COPY.rdiff deleted file mode 100644 index cb4a72614b9..00000000000 --- a/mysql-test/suite/innodb/r/alter_instant,COPY.rdiff +++ /dev/null @@ -1,61 +0,0 @@ ---- alter_instant.result 2018-04-10 11:19:46.299868465 +0530 -+++ alter_instant.reject 2018-04-10 11:21:19.648918489 +0530 -@@ -8,30 +8,30 @@ - INSERT INTO t1(f1, f2) VALUES(1, 1); - select @@alter_algorithm; - @@alter_algorithm --NOCOPY -+COPY - # Add column at the end of the table - ALTER TABLE t1 ADD COLUMN f4 char(100) default "BIG WALL"; --affected rows: 0 --info: Records: 0 Duplicates: 0 Warnings: 0 -+affected rows: 1 -+info: Records: 1 Duplicates: 0 Warnings: 0 - # Change virtual column expression - ALTER TABLE t1 CHANGE f3 f3 INT AS (f2 * f2) VIRTUAL; --affected rows: 0 --info: Records: 0 Duplicates: 0 Warnings: 0 -+affected rows: 1 -+info: Records: 1 Duplicates: 0 Warnings: 0 - # Add virtual column - ALTER TABLE t1 ADD COLUMN f5 INT AS (f2) VIRTUAL; --affected rows: 0 --info: Records: 0 Duplicates: 0 Warnings: 0 -+affected rows: 1 -+info: Records: 1 Duplicates: 0 Warnings: 0 - # Rename Column - ALTER TABLE t1 CHANGE f3 vcol INT AS (f2) VIRTUAL; --affected rows: 0 --info: Records: 0 Duplicates: 0 Warnings: 0 -+affected rows: 1 -+info: Records: 1 Duplicates: 0 Warnings: 0 - # Rename table - ALTER TABLE t1 RENAME t3; - affected rows: 0 - # Drop Virtual Column - ALTER TABLE t3 DROP COLUMN vcol; --affected rows: 0 --info: Records: 0 Duplicates: 0 Warnings: 0 -+affected rows: 1 -+info: Records: 1 Duplicates: 0 Warnings: 0 - # Column length varies - ALTER TABLE t2 CHANGE f3 f3 VARCHAR(20); - affected rows: 0 -@@ -39,12 +39,12 @@ - SET foreign_key_checks = 0; - affected rows: 0 - ALTER TABLE t3 ADD FOREIGN KEY `fidx`(f2) REFERENCES t2(f1); --affected rows: 0 --info: Records: 0 Duplicates: 0 Warnings: 0 -+affected rows: 1 -+info: Records: 1 Duplicates: 0 Warnings: 0 - SET foreign_key_checks = 1; - affected rows: 0 - ALTER TABLE t3 DROP FOREIGN KEY `fidx`; --affected rows: 0 --info: Records: 0 Duplicates: 0 Warnings: 0 -+affected rows: 1 -+info: Records: 1 Duplicates: 0 Warnings: 0 - DROP TABLE t3, t2; - affected rows: 0 diff --git a/mysql-test/suite/innodb/r/alter_instant,INPLACE.rdiff b/mysql-test/suite/innodb/r/alter_instant,INPLACE.rdiff deleted file mode 100644 index ec80e1d8ef0..00000000000 --- a/mysql-test/suite/innodb/r/alter_instant,INPLACE.rdiff +++ /dev/null @@ -1,11 +0,0 @@ ---- alter_instant.result 2018-04-10 11:19:46.299868465 +0530 -+++ alter_instant.reject 2018-04-10 11:22:19.433617807 +0530 -@@ -8,7 +8,7 @@ - INSERT INTO t1(f1, f2) VALUES(1, 1); - select @@alter_algorithm; - @@alter_algorithm --NOCOPY -+INPLACE - # Add column at the end of the table - ALTER TABLE t1 ADD COLUMN f4 char(100) default "BIG WALL"; - affected rows: 0 diff --git a/mysql-test/suite/innodb/r/alter_instant,INSTANT.rdiff b/mysql-test/suite/innodb/r/alter_instant,INSTANT.rdiff deleted file mode 100644 index cf2f8a2d719..00000000000 --- a/mysql-test/suite/innodb/r/alter_instant,INSTANT.rdiff +++ /dev/null @@ -1,11 +0,0 @@ ---- alter_instant.result 2018-04-10 11:19:46.299868465 +0530 -+++ alter_instant.reject 2018-04-10 11:22:47.281949905 +0530 -@@ -8,7 +8,7 @@ - INSERT INTO t1(f1, f2) VALUES(1, 1); - select @@alter_algorithm; - @@alter_algorithm --NOCOPY -+INSTANT - # Add column at the end of the table - ALTER TABLE t1 ADD COLUMN f4 char(100) default "BIG WALL"; - affected rows: 0 diff --git a/mysql-test/suite/innodb/r/alter_instant.result b/mysql-test/suite/innodb/r/alter_instant.result deleted file mode 100644 index ec64e41cd01..00000000000 --- a/mysql-test/suite/innodb/r/alter_instant.result +++ /dev/null @@ -1,50 +0,0 @@ -CREATE TABLE t1(f1 INT NOT NULL, -f2 INT NOT NULL, -f3 INT AS (f2 * f2) VIRTUAL, -INDEX idx (f2))engine=innodb; -CREATE TABLE t2(f1 INT NOT NULL, f2 INT NOT NULL, -f3 VARCHAR(10), -INDEX(f1))ENGINE=INNODB; -INSERT INTO t1(f1, f2) VALUES(1, 1); -select @@alter_algorithm; -@@alter_algorithm -NOCOPY -# Add column at the end of the table -ALTER TABLE t1 ADD COLUMN f4 char(100) default "BIG WALL"; -affected rows: 0 -info: Records: 0 Duplicates: 0 Warnings: 0 -# Change virtual column expression -ALTER TABLE t1 CHANGE f3 f3 INT AS (f2 * f2) VIRTUAL; -affected rows: 0 -info: Records: 0 Duplicates: 0 Warnings: 0 -# Add virtual column -ALTER TABLE t1 ADD COLUMN f5 INT AS (f2) VIRTUAL; -affected rows: 0 -info: Records: 0 Duplicates: 0 Warnings: 0 -# Rename Column -ALTER TABLE t1 CHANGE f3 vcol INT AS (f2) VIRTUAL; -affected rows: 0 -info: Records: 0 Duplicates: 0 Warnings: 0 -# Rename table -ALTER TABLE t1 RENAME t3; -affected rows: 0 -# Drop Virtual Column -ALTER TABLE t3 DROP COLUMN vcol; -affected rows: 0 -info: Records: 0 Duplicates: 0 Warnings: 0 -# Column length varies -ALTER TABLE t2 CHANGE f3 f3 VARCHAR(20); -affected rows: 0 -info: Records: 0 Duplicates: 0 Warnings: 0 -SET foreign_key_checks = 0; -affected rows: 0 -ALTER TABLE t3 ADD FOREIGN KEY `fidx`(f2) REFERENCES t2(f1); -affected rows: 0 -info: Records: 0 Duplicates: 0 Warnings: 0 -SET foreign_key_checks = 1; -affected rows: 0 -ALTER TABLE t3 DROP FOREIGN KEY `fidx`; -affected rows: 0 -info: Records: 0 Duplicates: 0 Warnings: 0 -DROP TABLE t3, t2; -affected rows: 0 diff --git a/mysql-test/suite/innodb/t/alter_algorithm.test b/mysql-test/suite/innodb/t/alter_algorithm.test index 23cddd46225..7cb706e865a 100644 --- a/mysql-test/suite/innodb/t/alter_algorithm.test +++ b/mysql-test/suite/innodb/t/alter_algorithm.test @@ -10,7 +10,57 @@ if ($algorithm == "INSTANT") { let $error_code = ER_ALTER_OPERATION_NOT_SUPPORTED, ER_ALTER_OPERATION_NOT_SUPPORTED_REASON; } ---source include/alter_nocopy_fail.inc +CREATE TABLE t1(f1 INT NOT NULL, + f2 INT NOT NULL, + f3 INT NULL, + f4 INT as (f2) STORED, + f5 INT as (f3) STORED, + PRIMARY KEY(f1))ROW_FORMAT=COMPRESSED, ENGINE=INNODB; +INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1); + +SELECT @@alter_algorithm; + +--enable_info +--echo # All the following cases needs table rebuild + +--echo # Add and Drop primary key +--error $error_code +ALTER TABLE t1 ADD COLUMN col1 INT NOT NULL,DROP PRIMARY KEY,ADD PRIMARY KEY(col1); + +--echo # Make existing column NULLABLE +--error $error_code +ALTER TABLE t1 MODIFY f2 INT; + +--echo # Make existing column NON-NULLABLE +--error $error_code +ALTER TABLE t1 MODIFY f3 INT NOT NULL; + +--echo # Drop Stored Column +--error $error_code +ALTER TABLE t1 DROP COLUMN f5; + +--echo # Add base non-generated column as a last column in the compressed table +--error $error_code +ALTER TABLE t1 ADD COLUMN f6 INT NOT NULL; + +--echo # Add base non-generated column but not in the last position +--error $error_code +ALTER TABLE t1 ADD COLUMN f7 INT NOT NULL after f3; + +--echo # Force the table to rebuild +--error $error_code +ALTER TABLE t1 FORCE; + +--echo # Row format changes +--error $error_code +ALTER TABLE t1 ROW_FORMAT=COMPRESSED; + +--echo # Engine table +--error $error_code +ALTER TABLE t1 ENGINE=INNODB; + +DROP TABLE t1; +--disable_info if ($algorithm == "NOCOPY") { let $error_code = 0; @@ -19,4 +69,77 @@ if ($algorithm == "NOCOPY") { if ($algorithm == "INSTANT") { let $error_code = ER_ALTER_OPERATION_NOT_SUPPORTED_REASON; } ---source include/alter_nocopy.inc + +CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL, + f3 INT AS (f2 * f2) VIRTUAL, + f4 INT NOT NULL UNIQUE, + f5 INT NOT NULL, + INDEX idx(f2))ENGINE=INNODB; + +CREATE TABLE t2(f1 INT NOT NULL, f2 INT NOT NULL, + INDEX(f1), + FOREIGN KEY fidx(f1) REFERENCES t1(f1))ENGINE=INNODB; + +INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4); + +--enable_info +--error $error_code +ALTER TABLE t1 ADD INDEX idx1(f4), page_compressed=1; + +--error $error_code +ALTER TABLE t1 DROP INDEX idx, page_compression_level=5; + +--error $error_code +ALTER TABLE t1 ADD UNIQUE INDEX u1(f2); + +--error $error_code +ALTER TABLE t1 DROP INDEX f4, page_compression_level=9; + +SET foreign_key_checks = 0; +--error $error_code +ALTER TABLE t1 ADD FOREIGN KEY(f5) REFERENCES t2(f1); + +DROP TABLE t2, t1; +--disable_info + +CREATE TABLE t1(f1 INT NOT NULL, + f2 INT NOT NULL, + f3 INT AS (f2 * f2) VIRTUAL, + INDEX idx (f2))engine=innodb; + +CREATE TABLE t2(f1 INT NOT NULL, f2 INT NOT NULL, + f3 VARCHAR(10), + INDEX(f1))ENGINE=INNODB; + +INSERT INTO t1(f1, f2) VALUES(1, 1); + +--enable_info +--echo # Add column at the end of the table +ALTER TABLE t1 ADD COLUMN f4 char(100) default 'BIG WALL'; + +--echo # Change virtual column expression +ALTER TABLE t1 CHANGE f3 f3 INT AS (f2 * f2) VIRTUAL; + +--echo # Add virtual column +ALTER TABLE t1 ADD COLUMN f5 INT AS (f2) VIRTUAL; + +--echo # Rename Column +ALTER TABLE t1 CHANGE f3 vcol INT AS (f2) VIRTUAL; + +--echo # Rename table +ALTER TABLE t1 RENAME t3; + +--echo # Drop Virtual Column +ALTER TABLE t3 DROP COLUMN vcol; + +--echo # Column length varies +ALTER TABLE t2 CHANGE f3 f3 VARCHAR(20); + +SET foreign_key_checks = 0; +ALTER TABLE t3 ADD FOREIGN KEY fidx(f2) REFERENCES t2(f1); + +SET foreign_key_checks = 1; +ALTER TABLE t3 DROP FOREIGN KEY fidx; + +DROP TABLE t3, t2; +--disable_info diff --git a/mysql-test/suite/innodb/t/alter_instant.test b/mysql-test/suite/innodb/t/alter_instant.test deleted file mode 100644 index dddb7b8ce27..00000000000 --- a/mysql-test/suite/innodb/t/alter_instant.test +++ /dev/null @@ -1,45 +0,0 @@ ---source alter_algorithm.inc - -CREATE TABLE t1(f1 INT NOT NULL, - f2 INT NOT NULL, - f3 INT AS (f2 * f2) VIRTUAL, - INDEX idx (f2))engine=innodb; - -CREATE TABLE t2(f1 INT NOT NULL, f2 INT NOT NULL, - f3 VARCHAR(10), - INDEX(f1))ENGINE=INNODB; - -INSERT INTO t1(f1, f2) VALUES(1, 1); - -select @@alter_algorithm; - ---enable_info ---echo # Add column at the end of the table ---eval ALTER TABLE t1 ADD COLUMN f4 char(100) default "BIG WALL" - ---echo # Change virtual column expression ---eval ALTER TABLE t1 CHANGE f3 f3 INT AS (f2 * f2) VIRTUAL - ---echo # Add virtual column ---eval ALTER TABLE t1 ADD COLUMN f5 INT AS (f2) VIRTUAL - ---echo # Rename Column ---eval ALTER TABLE t1 CHANGE f3 vcol INT AS (f2) VIRTUAL - ---echo # Rename table ---eval ALTER TABLE t1 RENAME t3 - ---echo # Drop Virtual Column ---eval ALTER TABLE t3 DROP COLUMN vcol - ---echo # Column length varies ---eval ALTER TABLE t2 CHANGE f3 f3 VARCHAR(20) - -SET foreign_key_checks = 0; ---eval ALTER TABLE t3 ADD FOREIGN KEY `fidx`(f2) REFERENCES t2(f1) - -SET foreign_key_checks = 1; ---eval ALTER TABLE t3 DROP FOREIGN KEY `fidx` - -DROP TABLE t3, t2; ---disable_info From a91109846c74a69bfa0fef054954ac9ae675765e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 7 Nov 2018 20:21:12 +0200 Subject: [PATCH 17/20] Merge an .inc file to .test --- .../suite/innodb/include/alter_not_null.inc | 94 ------------------- mysql-test/suite/innodb/t/alter_not_null.test | 94 ++++++++++++++++++- 2 files changed, 93 insertions(+), 95 deletions(-) delete mode 100644 mysql-test/suite/innodb/include/alter_not_null.inc diff --git a/mysql-test/suite/innodb/include/alter_not_null.inc b/mysql-test/suite/innodb/include/alter_not_null.inc deleted file mode 100644 index 109fad38d16..00000000000 --- a/mysql-test/suite/innodb/include/alter_not_null.inc +++ /dev/null @@ -1,94 +0,0 @@ ---source include/have_innodb.inc - -CREATE TABLE t1(f1 INT)ENGINE=INNODB; -INSERT INTO t1 VALUES(NULL); -SELECT * FROM t1; ---enable_info ---error $error_code -ALTER TABLE t1 CHANGE f1 f1 INT NOT NULL; ---disable_info -SELECT * FROM t1; -DROP TABLE t1; - -CREATE TABLE t1(f1 CHAR(10))ENGINE=INNODB; -INSERT INTO t1 VALUES(NULL); -SELECT * FROM t1; ---enable_info ---error $error_code -ALTER TABLE t1 CHANGE f1 f1 CHAR(10) NOT NULL; ---disable_info -SELECT * FROM t1; -DROP TABLE t1; - -CREATE TABLE t1(f1 VARCHAR(10))ENGINE=INNODB; -INSERT INTO t1 VALUES(NULL); -SELECT * FROM t1; ---enable_info ---error $error_code -ALTER TABLE t1 CHANGE f1 f1 VARCHAR(20) NOT NULL; ---disable_info -SELECT * FROM t1; -DROP TABLE t1; - -CREATE TABLE t1(f1 TEXT)ENGINE=INNODB; -INSERT INTO t1 VALUES(NULL); -SELECT * FROM t1; ---enable_info ---error $error_code -ALTER TABLE t1 CHANGE f1 f1 TEXT NOT NULL DEFAULT 'abc'; ---disable_info -SELECT * FROM t1; -DROP TABLE t1; - -CREATE TABLE t1(f1 INT NOT NULL, f2 INT NOT NULL, f3 INT)ENGINE=INNODB; -INSERT INTO t1 VALUES(2, 2, NULL); -SELECT * FROM t1; ---enable_info ---error $error_code -ALTER TABLE t1 CHANGE f3 f3 INT NOT NULL DEFAULT (f1 + f2); ---disable_info -SELECT * FROM t1; -DROP TABLE t1; - -CREATE TABLE t1(f1 INT NOT NULL DEFAULT 0, b TINYINT)ENGINE=InnoDB; -INSERT INTO t1 VALUES(10, NULL); -SELECT * FROM t1; ---enable_info ---error $error_code -ALTER TABLE t1 CHANGE b b TINYINT NOT NULL DEFAULT if(unix_timestamp()>1,1000,0); ---disable_info -SELECT * FROM t1; -DROP TABLE t1; - -CREATE TABLE t1(a INT, v INT AS (a), c INT, d INT NOT NULL, e INT) ENGINE=InnoDB; ---enable_info -ALTER TABLE t1 DROP COLUMN c, CHANGE COLUMN e e INT NOT NULL; ---disable_info -DROP TABLE t1; - -CREATE TABLE t1 (a INT, v INT AS (a), d INT NOT NULL, e INT) ENGINE=InnoDB; ---enable_info -ALTER TABLE t1 FORCE; ---disable_info -DROP TABLE t1; - -# Alter ignore should work irrespective of sql mode - -CREATE TABLE t1(c1 INT NOT NULL, c2 INT, PRIMARY KEY(c1))ENGINE=INNODB; -INSERT INTO t1 VALUES(1, NULL); ---enable_info -ALTER IGNORE TABLE t1 CHANGE c2 c2 INT NOT NULL DEFAULT 2; ---disable_info -SELECT * FROM t1; -DROP TABLE t1; - ---echo # ---echo # MDEV-16126 Crash or ASAN heap-buffer-overflow in ---echo # mach_read_from_n_little_endian upon ALTER TABLE with blob ---echo # - -CREATE TABLE t1(a INT, v INT AS (a), b INT, c BLOB) ENGINE=InnoDB; ---enable_info -ALTER TABLE t1 ADD PRIMARY KEY(b); ---disable_info -DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/alter_not_null.test b/mysql-test/suite/innodb/t/alter_not_null.test index 839d7f18a5e..646838593e2 100644 --- a/mysql-test/suite/innodb/t/alter_not_null.test +++ b/mysql-test/suite/innodb/t/alter_not_null.test @@ -1,3 +1,4 @@ +--source include/have_innodb.inc --source alter_sql_mode.inc let $sql_mode = `SELECT @@SQL_MODE`; @@ -7,4 +8,95 @@ if ($sql_mode == "STRICT_TRANS_TABLES") { let $error_code = WARN_DATA_TRUNCATED; } ---source include/alter_not_null.inc +CREATE TABLE t1(f1 INT)ENGINE=INNODB; +INSERT INTO t1 VALUES(NULL); +SELECT * FROM t1; +--enable_info +--error $error_code +ALTER TABLE t1 CHANGE f1 f1 INT NOT NULL; +--disable_info +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1(f1 CHAR(10))ENGINE=INNODB; +INSERT INTO t1 VALUES(NULL); +SELECT * FROM t1; +--enable_info +--error $error_code +ALTER TABLE t1 CHANGE f1 f1 CHAR(10) NOT NULL; +--disable_info +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1(f1 VARCHAR(10))ENGINE=INNODB; +INSERT INTO t1 VALUES(NULL); +SELECT * FROM t1; +--enable_info +--error $error_code +ALTER TABLE t1 CHANGE f1 f1 VARCHAR(20) NOT NULL; +--disable_info +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1(f1 TEXT)ENGINE=INNODB; +INSERT INTO t1 VALUES(NULL); +SELECT * FROM t1; +--enable_info +--error $error_code +ALTER TABLE t1 CHANGE f1 f1 TEXT NOT NULL DEFAULT 'abc'; +--disable_info +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1(f1 INT NOT NULL, f2 INT NOT NULL, f3 INT)ENGINE=INNODB; +INSERT INTO t1 VALUES(2, 2, NULL); +SELECT * FROM t1; +--enable_info +--error $error_code +ALTER TABLE t1 CHANGE f3 f3 INT NOT NULL DEFAULT (f1 + f2); +--disable_info +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1(f1 INT NOT NULL DEFAULT 0, b TINYINT)ENGINE=InnoDB; +INSERT INTO t1 VALUES(10, NULL); +SELECT * FROM t1; +--enable_info +--error $error_code +ALTER TABLE t1 CHANGE b b TINYINT NOT NULL DEFAULT if(unix_timestamp()>1,1000,0); +--disable_info +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1(a INT, v INT AS (a), c INT, d INT NOT NULL, e INT) ENGINE=InnoDB; +--enable_info +ALTER TABLE t1 DROP COLUMN c, CHANGE COLUMN e e INT NOT NULL; +--disable_info +DROP TABLE t1; + +CREATE TABLE t1 (a INT, v INT AS (a), d INT NOT NULL, e INT) ENGINE=InnoDB; +--enable_info +ALTER TABLE t1 FORCE; +--disable_info +DROP TABLE t1; + +# Alter ignore should work irrespective of sql mode + +CREATE TABLE t1(c1 INT NOT NULL, c2 INT, PRIMARY KEY(c1))ENGINE=INNODB; +INSERT INTO t1 VALUES(1, NULL); +--enable_info +ALTER IGNORE TABLE t1 CHANGE c2 c2 INT NOT NULL DEFAULT 2; +--disable_info +SELECT * FROM t1; +DROP TABLE t1; + +--echo # +--echo # MDEV-16126 Crash or ASAN heap-buffer-overflow in +--echo # mach_read_from_n_little_endian upon ALTER TABLE with blob +--echo # + +CREATE TABLE t1(a INT, v INT AS (a), b INT, c BLOB) ENGINE=InnoDB; +--enable_info +ALTER TABLE t1 ADD PRIMARY KEY(b); +--disable_info +DROP TABLE t1; From c565622c6c6f2cb5e1dbc034a934a91f9ff08fa4 Mon Sep 17 00:00:00 2001 From: Andrei Elkin Date: Wed, 7 Nov 2018 15:24:30 +0200 Subject: [PATCH 18/20] MDEV-14528 followup. There was a failure in rpl_delayed_slave after recent MDEV-14528 commit. The parallel applier should not set its Relay_log::last_master_timestamp from Format-descriptor log event. The latter may reflect a deep past so Seconds-behind-master will be computed through it and displayed all time while the first possibly "slow" group of events is executed. The main MDEV-14528 is refined, rpl_delayed_slave now passes also in the parallel mode. --- mysql-test/suite/rpl/disabled.def | 1 - sql/slave.cc | 10 +++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/rpl/disabled.def b/mysql-test/suite/rpl/disabled.def index 3b740cbf974..e37ad842790 100644 --- a/mysql-test/suite/rpl/disabled.def +++ b/mysql-test/suite/rpl/disabled.def @@ -17,4 +17,3 @@ rpl_row_binlog_max_cache_size : MDEV-11092 rpl_blackhole : MDEV-11094 rpl_row_mysqlbinlog : MDEV-11095 rpl_row_index_choice : MDEV-11666 -rpl_delayed_slave : MDEV-14528 diff --git a/sql/slave.cc b/sql/slave.cc index d6223453a5b..f3e08f14213 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3962,7 +3962,15 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli, */ if (!(ev->is_artificial_event() || ev->is_relay_log_event() || (ev->when == 0))) { - rli->last_master_timestamp= ev->when + (time_t) ev->exec_time; + /* + Ignore FD's timestamp as it does not reflect the slave execution + state but likely to reflect a deep past. Consequently when the first + data modification event execution last long all this time + Seconds_Behind_Master is zero. + */ + if (ev->get_type_code() != FORMAT_DESCRIPTION_EVENT) + rli->last_master_timestamp= ev->when + (time_t) ev->exec_time; + DBUG_ASSERT(rli->last_master_timestamp >= 0); } } From 4142589207649e3317adc8c0d371897b7cb53733 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Wed, 7 Nov 2018 12:07:32 -0800 Subject: [PATCH 19/20] MDEV-17635 Server hangs after the query with recursive CTE This bug in the code of the function With_element::check_unrestricted_recursive() could force a recursive CTE to be executed in a non-standard compliant mode in which recursive UNION ALL could lead to an infinite execution. This problem could occur only in the case when this CTE was used by another recursive CTE at least twice. --- mysql-test/r/cte_recursive.result | 159 ++++++++++++++++++++++++++++++ mysql-test/t/cte_recursive.test | 55 +++++++++++ sql/sql_cte.cc | 2 +- 3 files changed, 215 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/cte_recursive.result b/mysql-test/r/cte_recursive.result index de23d54694e..78530261efc 100644 --- a/mysql-test/r/cte_recursive.result +++ b/mysql-test/r/cte_recursive.result @@ -3441,3 +3441,162 @@ expired_date purchase_date quantity p_id purchase_processed unresolved 2014-11-08 NULL 0 2 5 1 2014-11-08 2014-11-03 1 2 4 0 DROP TABLE purchases, expired; +# +# MDEV-17635: Two recursive CTEs, the second using the first +# +WITH RECURSIVE +x AS (SELECT 0 as k UNION ALL SELECT k + 1 FROM x WHERE k < 1), +z AS +( SELECT k1 AS cx, k2 AS cy, k1, k2 +FROM (SELECT k AS k1 FROM x) x1 JOIN (SELECT k AS k2 FROM x) y1 +UNION +SELECT 1,1,1,1 FROM z) +SELECT * FROM z; +cx cy k1 k2 +0 0 0 0 +1 0 1 0 +0 1 0 1 +1 1 1 1 +# https://wiki.postgresql.org/wiki/Mandelbrot_set: +WITH RECURSIVE x(i) AS ( +SELECT CAST(0 AS DECIMAL(13, 10)) +UNION ALL +SELECT i + 1 +FROM x +WHERE i < 101 +), +Z(Ix, Iy, Cx, Cy, X, Y, I) AS ( +SELECT Ix, Iy, X, Y, X, Y, 0 +FROM (SELECT CAST(-2.2 + 0.031 * i AS DECIMAL(13, 10)) AS X, +i AS Ix FROM x) AS xgen +CROSS JOIN ( +SELECT CAST(-1.5 + 0.031 * i AS DECIMAL(13, 10)) AS Y, +i AS iY FROM x +) AS ygen +UNION ALL +SELECT Ix, Iy, Cx, Cy, +CAST(X * X - Y * Y + Cx AS DECIMAL(13, 10)) AS X, +CAST(Y * X * 2 + Cy AS DECIMAL(13, 10)), I + 1 +FROM Z +WHERE X * X + Y * Y < 16.0 +AND I < 27 +), +Zt (Ix, Iy, I) AS ( +SELECT Ix, Iy, MAX(I) AS I +FROM Z +GROUP BY Iy, Ix +ORDER BY Iy, Ix +) +SELECT GROUP_CONCAT( +SUBSTRING( +' .,,,-----++++%%%%@@@@#### ', +GREATEST(I, 1), +1 +) ORDER BY Ix SEPARATOR '' + ) AS 'Mandelbrot Set' + FROM Zt +GROUP BY Iy +ORDER BY Iy; +Mandelbrot Set + .................................................................................... + ....................................................................................... + ......................................................................................... + ........................................................................................... + ....................................................,,,,,,,,,................................. + ................................................,,,,,,,,,,,,,,,,,,............................. + ..............................................,,,,,,,,,,,,,,,,,,,,,,,,.......................... + ............................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,........................ + ..........................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,...................... + .........................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.................... + ........................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,................... + .......................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,................. + .......................................,,,,,,,,,,,,,,,,,,,,,,,,--,,,,,,,,,,,,,,,,,,,,................ +......................................,,,,,,,,,,,,,,,,,,,,,,,,,,-+--,,,,,,,,,,,,,,,,,,,............... +....................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----,,,,,,,,,,,,,,,,,,,.............. +...................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,--- -----,,,,,,,,,,,,,,,,,............. +.................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---++--++,,,,,,,,,,,,,,,,,,............ +................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----%++---,,,,,,,,,,,,,,,,,............ +..............................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----+%----,,,,,,,,,,,,,,,,,,........... +.............................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----- %%+----,,,,,,,,,,,,,,,,,,.......... +...........................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---%-+% ----,,,,,,,,,,,,,,,,,,,......... +..........................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---+ +## %+%---,,,,,,,,,,,,,,,,,,......... +........................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----# # +---,,,,,,,,,,,,,,,,,,........ +.......................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-------% %-----,,,,,,,,,,,,,,,,,........ +.....................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---------+ ------,,,,,,,,,,,,,,,,,....... +....................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----------+@ +-----------,,,,,,,,,,,,....... +..................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----@-------++ ++-----------,,,,,,,,,,,,...... +.................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,--+@% ---+ +@%%@ %%+@+@%------+-,,,,,,,,,,,...... +................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---- # ++% % @-----++--,,,,,,,,,,,..... +..............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----+ % %%++ %+%@-,,,,,,,,,,,..... +.............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----+# #% ++-,,,,,,,,,,,,.... +............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,------+ @---,,,,,,,,,,,,.... +..........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-------++% ---,,,,,,,,,,,,.... +.........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,--------+ + %+---,,,,,,,,,,,,,... +........,,,,,,,,,,,,,,,,,,,,,--------------------@ +----,,,,,,,,,,,,... +.......,,,,,,,,,,,,,,,,,,,,,,- +-----------------+ ----,,,,,,,,,,,,... +.......,,,,,,,,,,,,,,,,,,,,,--++------+---------+% +++--,,,,,,,,,,,,.. +......,,,,,,,,,,,,,,,,,,,,,,--%+-----++--------- #+-,,,,,,,,,,,,.. +.....,,,,,,,,,,,,,,,,,,,,,,----#%++--+@ -+-----+% --,,,,,,,,,,,,.. +.....,,,,,,,,,,,,,,,,,,,,,,-----+## ++@ + +----% +--,,,,,,,,,,,,,.. +....,,,,,,,,,,,,,,,,,,,,,,------+@ @ @@++++# +--,,,,,,,,,,,,,.. +....,,,,,,,,,,,,,,,,,,,,,-------% #++% -,,,,,,,,,,,,,.. +...,,,,,,,,,,,,,,,,,,,,,------++%# %%@ %-,,,,,,,,,,,,,,. +...,,,,,,,,,,,,,,,,,,,--------+ % +--,,,,,,,,,,,,,,. +...,,,,,,,,,,,,,,,,,,-----+--++@ # --,,,,,,,,,,,,,,. +..,,,,,,,,,,,,,,,,,-------%+++% @--,,,,,,,,,,,,,,,. +..,,,,,,,,,,,-------------+ @#@ ---,,,,,,,,,,,,,,,. +..,,,,,,,,,---@--------@-+% +---,,,,,,,,,,,,,,,. +..,,,,,------- +-++++-+%%% +----,,,,,,,,,,,,,,,. +..,,,,,,------%--------++% +----,,,,,,,,,,,,,,,. +..,,,,,,,,,,--+----------++# ---,,,,,,,,,,,,,,,. +..,,,,,,,,,,,,------------+@@@% +--,,,,,,,,,,,,,,,. +..,,,,,,,,,,,,,,,,,------- +++% %--,,,,,,,,,,,,,,,. +...,,,,,,,,,,,,,,,,,,---------+@ @ --,,,,,,,,,,,,,,. +...,,,,,,,,,,,,,,,,,,,,------- # %@ +--,,,,,,,,,,,,,,. +...,,,,,,,,,,,,,,,,,,,,,-------++@ %+ %-,,,,,,,,,,,,,,. +....,,,,,,,,,,,,,,,,,,,,,------- %++% %-,,,,,,,,,,,,,.. +....,,,,,,,,,,,,,,,,,,,,,,------+# %# #@ ++++ +--,,,,,,,,,,,,,.. +.....,,,,,,,,,,,,,,,,,,,,,,-----+ %%++% +@+----+ +--,,,,,,,,,,,,,.. +.....,,,,,,,,,,,,,,,,,,,,,,,---%+++--+#+--------% #--,,,,,,,,,,,,.. +......,,,,,,,,,,,,,,,,,,,,,,--++-----%%--------- @#--,,,,,,,,,,,,.. +.......,,,,,,,,,,,,,,,,,,,,,---------------------+@ +-++,,,,,,,,,,,,... +........,,,,,,,,,,,,,,,,,,,,,--------------------+ ----,,,,,,,,,,,,... +.........,,,,,,,,,,,,,,,,,,,,----,,,------------- #+----,,,,,,,,,,,,... +..........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-------+ + +---,,,,,,,,,,,,,... +...........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,--------+%# #---,,,,,,,,,,,,.... +............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,------+# @ @---,,,,,,,,,,,,.... +.............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----+# + @--,,,,,,,,,,,,.... +..............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---+% %+@ %+-+ +++%-,,,,,,,,,,,..... +................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----% %@++ # % -----++-,,,,,,,,,,,,..... +.................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-- ++ ---+ + +%@ %++++++------%-,,,,,,,,,,,...... +...................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---- -------++ +------------,,,,,,,,,,,,...... +....................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----------+% +--------,,,,,,,,,,,,,,,....... +......................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,--------+# -----,,,,,,,,,,,,,,,,,,....... +.......................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-------+ #----,,,,,,,,,,,,,,,,,,........ +.........................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----+% %#---,,,,,,,,,,,,,,,,,,,........ +..........................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---+%+%@ %+%%--,,,,,,,,,,,,,,,,,,......... +............................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---+-+% %----,,,,,,,,,,,,,,,,,,.......... +.............................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----+%@+---,,,,,,,,,,,,,,,,,,,.......... +...............................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----+%----,,,,,,,,,,,,,,,,,,........... +................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----%+ +--,,,,,,,,,,,,,,,,,............ +..................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---++----,,,,,,,,,,,,,,,,,............. +...................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,---@-----,,,,,,,,,,,,,,,,,............. +.....................................,,,,,,,,,,,,,,,,,,,,,,,,,,,-----,,,,,,,,,,,,,,,,,,,.............. + .....................................,,,,,,,,,,,,,,,,,,,,,,,,,,--%,,,,,,,,,,,,,,,,,,,,............... + .......................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,................. + ........................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.................. + ........................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,................... + .........................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.................... + ..........................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,...................... + ............................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,........................ + .............................................,,,,,,,,,,,,,,,,,,,,,,,,.......................... + ................................................,,,,,,,,,,,,,,,,,............................. + .....................................................,,,,.................................... + ........................................................................................... + ......................................................................................... + ...................................................................................... + .................................................................................... + ................................................................................. + .............................................................................. + ........................................................................... + ........................................................................ diff --git a/mysql-test/t/cte_recursive.test b/mysql-test/t/cte_recursive.test index acaf95beda7..3c5bc62ae1a 100644 --- a/mysql-test/t/cte_recursive.test +++ b/mysql-test/t/cte_recursive.test @@ -2440,3 +2440,58 @@ WITH RECURSIVE expired_map AS ( SELECT * FROM expired_map; DROP TABLE purchases, expired; + +--echo # +--echo # MDEV-17635: Two recursive CTEs, the second using the first +--echo # + +WITH RECURSIVE +x AS (SELECT 0 as k UNION ALL SELECT k + 1 FROM x WHERE k < 1), +z AS + ( SELECT k1 AS cx, k2 AS cy, k1, k2 + FROM (SELECT k AS k1 FROM x) x1 JOIN (SELECT k AS k2 FROM x) y1 + UNION + SELECT 1,1,1,1 FROM z) +SELECT * FROM z; + +--echo # https://wiki.postgresql.org/wiki/Mandelbrot_set: + +WITH RECURSIVE x(i) AS ( + SELECT CAST(0 AS DECIMAL(13, 10)) + UNION ALL + SELECT i + 1 + FROM x + WHERE i < 101 +), +Z(Ix, Iy, Cx, Cy, X, Y, I) AS ( + SELECT Ix, Iy, X, Y, X, Y, 0 + FROM (SELECT CAST(-2.2 + 0.031 * i AS DECIMAL(13, 10)) AS X, + i AS Ix FROM x) AS xgen + CROSS JOIN ( + SELECT CAST(-1.5 + 0.031 * i AS DECIMAL(13, 10)) AS Y, + i AS iY FROM x + ) AS ygen + UNION ALL + SELECT Ix, Iy, Cx, Cy, + CAST(X * X - Y * Y + Cx AS DECIMAL(13, 10)) AS X, + CAST(Y * X * 2 + Cy AS DECIMAL(13, 10)), I + 1 + FROM Z + WHERE X * X + Y * Y < 16.0 + AND I < 27 +), +Zt (Ix, Iy, I) AS ( + SELECT Ix, Iy, MAX(I) AS I + FROM Z + GROUP BY Iy, Ix + ORDER BY Iy, Ix +) +SELECT GROUP_CONCAT( + SUBSTRING( + ' .,,,-----++++%%%%@@@@#### ', + GREATEST(I, 1), + 1 + ) ORDER BY Ix SEPARATOR '' + ) AS 'Mandelbrot Set' + FROM Zt +GROUP BY Iy +ORDER BY Iy; diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc index 5a590bfea93..5d4c2b20872 100644 --- a/sql/sql_cte.cc +++ b/sql/sql_cte.cc @@ -1263,7 +1263,7 @@ bool With_element::check_unrestricted_recursive(st_select_lex *sel, With_element *with_elem= unit->with_element; if (encountered & with_elem->get_elem_map()) unrestricted|= with_elem->mutually_recursive; - else + else if (with_elem ==this) encountered|= with_elem->get_elem_map(); } } From bac2ec3a5b28ed590826b20a4cf27fd788903bbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 8 Nov 2018 09:44:29 +0200 Subject: [PATCH 20/20] After-merge fixes to the Oracle compatibility parser The following merges changed sql_yacc.yy but not sql_yacc_ora.yy: commit 862af4d255cade35f9b1f65fd11dba30874fd8fc commit df563e0c037f9b2cdb22e145575f92a121b4b529 Apply the same fixes to the other parser. --- sql/sql_yacc_ora.yy | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy index aaac4ba3e54..d575fd497bc 100644 --- a/sql/sql_yacc_ora.yy +++ b/sql/sql_yacc_ora.yy @@ -14540,9 +14540,18 @@ delete_domain_id_list: ; delete_domain_id: - ulong_num + ulonglong_num { - insert_dynamic(&Lex->delete_gtid_domain, (uchar*) &($1)); + uint32 value= (uint32) $1; + if ($1 > UINT_MAX32) + { + my_printf_error(ER_BINLOG_CANT_DELETE_GTID_DOMAIN, + "The value of gtid domain being deleted ('%llu') " + "exceeds its maximum size " + "of 32 bit unsigned integer", MYF(0), $1); + MYSQL_YYABORT; + } + insert_dynamic(&Lex->delete_gtid_domain, (uchar*) &value); } ; @@ -14717,6 +14726,7 @@ load: lex->field_list.empty(); lex->update_list.empty(); lex->value_list.empty(); + lex->many_values.empty(); } opt_load_data_charset { Lex->exchange->cs= $15; }