From 06d77eb43a5f1e5bc24555e51d19d209d2b92615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 8 Feb 2018 14:55:01 +0200 Subject: [PATCH 1/9] MDEV-14427: encryption.innodb-bad-key-change failed in buildbot Timing problem as sometimes table is marked as encrypted but sometimes we are not sure and table is just marked missing. --- .../encryption/r/innodb-bad-key-change.result | 48 ------------------- .../encryption/t/innodb-bad-key-change.test | 42 +++++++--------- 2 files changed, 16 insertions(+), 74 deletions(-) diff --git a/mysql-test/suite/encryption/r/innodb-bad-key-change.result b/mysql-test/suite/encryption/r/innodb-bad-key-change.result index 4e4fd89d1ae..d581b98513d 100644 --- a/mysql-test/suite/encryption/r/innodb-bad-key-change.result +++ b/mysql-test/suite/encryption/r/innodb-bad-key-change.result @@ -28,14 +28,7 @@ foobar 2 # Restart server with keysbad3.txt SELECT * FROM t1; ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB -SHOW WARNINGS; -Level Code Message -Warning 192 Table test/t1 in tablespace is encrypted but encryption service or used key_id is not available. Can't continue reading table. -Warning 192 Table "test"."t1" in file ./test/t1.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table. -Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB DROP TABLE t1; -SHOW WARNINGS; -Level Code Message # Start server with keys3.txt SET GLOBAL innodb_default_encryption_key_id=5; CREATE TABLE t2 (c VARCHAR(8), id int not null primary key, b int, key(b)) ENGINE=InnoDB ENCRYPTED=YES; @@ -44,73 +37,32 @@ INSERT INTO t2 VALUES ('foobar',1,2); # Restart server with keys2.txt SELECT * FROM t2; ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB -SHOW WARNINGS; -Level Code Message -Warning 192 Table test/t2 in tablespace is encrypted but encryption service or used key_id is not available. Can't continue reading table. -Warning 192 Table "test"."t2" in file ./test/t2.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table. -Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB SELECT * FROM t2 where id = 1; ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB -SHOW WARNINGS; -Level Code Message -Warning 192 Table "test"."t2" in file ./test/t2.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table. -Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB SELECT * FROM t2 where b = 1; ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB -SHOW WARNINGS; -Level Code Message -Warning 192 Table "test"."t2" in file ./test/t2.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table. -Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB INSERT INTO t2 VALUES ('tmp',3,3); ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB -SHOW WARNINGS; -Level Code Message -Warning 192 Table "test"."t2" in file ./test/t2.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table. -Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB DELETE FROM t2 where b = 3; ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB -SHOW WARNINGS; -Level Code Message -Warning 192 Table "test"."t2" in file ./test/t2.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table. -Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB DELETE FROM t2 where id = 3; ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB -SHOW WARNINGS; -Level Code Message -Warning 192 Table "test"."t2" in file ./test/t2.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table. -Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB UPDATE t2 set b = b +1; ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB -SHOW WARNINGS; -Level Code Message -Warning 192 Table "test"."t2" in file ./test/t2.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table. -Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB OPTIMIZE TABLE t2; Table Op Msg_type Msg_text test.t2 optimize Warning Table "test"."t2" in file ./test/t2.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table. test.t2 optimize Error Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB test.t2 optimize error Corrupt -SHOW WARNINGS; -Level Code Message ALTER TABLE t2 ADD COLUMN d INT; ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB -SHOW WARNINGS; -Level Code Message -Warning 192 Table "test"."t2" in file ./test/t2.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table. -Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB ANALYZE TABLE t2; Table Op Msg_type Msg_text test.t2 analyze Warning Table "test"."t2" in file ./test/t2.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table. test.t2 analyze Error Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB test.t2 analyze error Corrupt -SHOW WARNINGS; -Level Code Message TRUNCATE TABLE t2; ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB -SHOW WARNINGS; -Level Code Message -Warning 192 Table "test"."t2" in file ./test/t2.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table. -Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB DROP TABLE t2; # Start server with keys2.txt diff --git a/mysql-test/suite/encryption/t/innodb-bad-key-change.test b/mysql-test/suite/encryption/t/innodb-bad-key-change.test index 66546872c25..6fa5fc9847f 100644 --- a/mysql-test/suite/encryption/t/innodb-bad-key-change.test +++ b/mysql-test/suite/encryption/t/innodb-bad-key-change.test @@ -40,18 +40,18 @@ SELECT * FROM t1; -- let $restart_parameters=--file-key-management-filename=$MYSQL_TEST_DIR/std_data/keysbad3.txt -- source include/restart_mysqld.inc +--disable_warnings --error ER_GET_ERRMSG SELECT * FROM t1; ---replace_regex /tablespace [0-9]*/tablespace / /key_id [0-9]*/key_id / -SHOW WARNINGS; +--enable_warnings -- let $restart_parameters=--file-key-management-filename=$MYSQL_TEST_DIR/std_data/keysbad3.txt -- source include/restart_mysqld.inc +--disable_warnings --replace_regex /tablespace [0-9]*/tablespace / DROP TABLE t1; ---replace_regex /tablespace [0-9]*/tablespace / /key_id [0-9]*/key_id / -SHOW WARNINGS; +--enable_warnings # # MDEV-8591: Database page corruption on disk or a failed space, Assertion failure in file buf0buf.cc @@ -71,51 +71,41 @@ INSERT INTO t2 VALUES ('foobar',1,2); -- let $restart_parameters=--file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt -- source include/restart_mysqld.inc +--disable_warnings --error ER_GET_ERRMSG SELECT * FROM t2; ---replace_regex /tablespace [0-9]*/tablespace / /key_id [0-9]*/key_id / -SHOW WARNINGS; + --error ER_GET_ERRMSG SELECT * FROM t2 where id = 1; ---replace_regex /tablespace [0-9]*/tablespace / /key_id [0-9]*/key_id / -SHOW WARNINGS; + --error ER_GET_ERRMSG SELECT * FROM t2 where b = 1; ---replace_regex /tablespace [0-9]*/tablespace / /key_id [0-9]*/key_id / -SHOW WARNINGS; + --replace_regex /tablespace [0-9]*/tablespace / --error ER_GET_ERRMSG INSERT INTO t2 VALUES ('tmp',3,3); ---replace_regex /tablespace [0-9]*/tablespace / /key_id [0-9]*/key_id / -SHOW WARNINGS; + --error ER_GET_ERRMSG DELETE FROM t2 where b = 3; ---replace_regex /tablespace [0-9]*/tablespace / /key_id [0-9]*/key_id / -SHOW WARNINGS; + --error ER_GET_ERRMSG DELETE FROM t2 where id = 3; ---replace_regex /tablespace [0-9]*/tablespace / /key_id [0-9]*/key_id / -SHOW WARNINGS; + --error ER_GET_ERRMSG UPDATE t2 set b = b +1; ---replace_regex /tablespace [0-9]*/tablespace / /key_id [0-9]*/key_id / -SHOW WARNINGS; + OPTIMIZE TABLE t2; ---replace_regex /tablespace [0-9]*/tablespace / /key_id [0-9]*/key_id / -SHOW WARNINGS; + --error ER_GET_ERRMSG ALTER TABLE t2 ADD COLUMN d INT; ---replace_regex /tablespace [0-9]*/tablespace / /key_id [0-9]*/key_id / -SHOW WARNINGS; + ANALYZE TABLE t2; ---replace_regex /tablespace [0-9]*/tablespace / /key_id [0-9]*/key_id / -SHOW WARNINGS; + --error ER_GET_ERRMSG TRUNCATE TABLE t2; ---replace_regex /tablespace [0-9]*/tablespace / /key_id [0-9]*/key_id / -SHOW WARNINGS; DROP TABLE t2; +--enable_warnings --echo --echo # Start server with keys2.txt From 6f0b316fbe83d2cf555f867dda262896d18fbbf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Thu, 8 Feb 2018 21:12:11 +0200 Subject: [PATCH 2/9] Update wrong xtradb version The update was lost during merge. --- storage/xtradb/include/univ.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/xtradb/include/univ.i b/storage/xtradb/include/univ.i index 96e67f88c8a..c9e5aa62d22 100644 --- a/storage/xtradb/include/univ.i +++ b/storage/xtradb/include/univ.i @@ -45,7 +45,7 @@ Created 1/20/1994 Heikki Tuuri #define INNODB_VERSION_MAJOR 5 #define INNODB_VERSION_MINOR 6 -#define INNODB_VERSION_BUGFIX 36 +#define INNODB_VERSION_BUGFIX 38 #ifndef PERCONA_INNODB_VERSION #define PERCONA_INNODB_VERSION 83.0 From 47d1679ac69e96b201622bc0f5b3e5526ba571f2 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 6 Feb 2018 20:26:59 +0100 Subject: [PATCH 3/9] fix encryption.tempfiles to check that encrypt_tmp_files is ON --- mysql-test/suite/encryption/r/tempfiles.result | 3 +++ mysql-test/suite/encryption/t/tempfiles.opt | 1 + mysql-test/suite/encryption/t/tempfiles.test | 2 ++ 3 files changed, 6 insertions(+) create mode 100644 mysql-test/suite/encryption/t/tempfiles.opt diff --git a/mysql-test/suite/encryption/r/tempfiles.result b/mysql-test/suite/encryption/r/tempfiles.result index a0b7596dd5a..168f79b60e9 100644 --- a/mysql-test/suite/encryption/r/tempfiles.result +++ b/mysql-test/suite/encryption/r/tempfiles.result @@ -1,3 +1,6 @@ +select @@encrypt_tmp_files; +@@encrypt_tmp_files +1 CREATE TABLE t1(a INT); INSERT INTO t1 VALUES(1),(2); DELETE FROM t1 WHERE a=1; diff --git a/mysql-test/suite/encryption/t/tempfiles.opt b/mysql-test/suite/encryption/t/tempfiles.opt new file mode 100644 index 00000000000..2b90f474428 --- /dev/null +++ b/mysql-test/suite/encryption/t/tempfiles.opt @@ -0,0 +1 @@ +--encrypt-tmp-files diff --git a/mysql-test/suite/encryption/t/tempfiles.test b/mysql-test/suite/encryption/t/tempfiles.test index 34dcbdf5963..fc718f4d2ab 100644 --- a/mysql-test/suite/encryption/t/tempfiles.test +++ b/mysql-test/suite/encryption/t/tempfiles.test @@ -11,6 +11,8 @@ source include/have_binlog_format_row.inc; # engine. But there's no need to run it twice for InnoDB and XtraDB. source include/have_xtradb.inc; +select @@encrypt_tmp_files; + # # MyISAM messing around with IO_CACHE::file # From 60dfe12be3adaa03a8d409ca2da58e78e6d0c972 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 7 Feb 2018 18:54:11 +0100 Subject: [PATCH 4/9] MDEV-14868 MariaDB server crashes after using ROLLBACK TO when encrypt_tmp_files=ON Fix reinit_io_cache(WRITE_CACHE) with non-zero seek_offset. Run encryption.tempfiles with and without binlog checksums. --- mysql-test/suite/encryption/t/tempfiles.combinations | 5 +++++ mysys/mf_iocache.c | 2 +- sql/mf_iocache_encr.cc | 5 +++-- 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 mysql-test/suite/encryption/t/tempfiles.combinations diff --git a/mysql-test/suite/encryption/t/tempfiles.combinations b/mysql-test/suite/encryption/t/tempfiles.combinations new file mode 100644 index 00000000000..7010d2c100d --- /dev/null +++ b/mysql-test/suite/encryption/t/tempfiles.combinations @@ -0,0 +1,5 @@ +[none] +binlog-checksum=NONE + +[crc32] +binlog-checksum=CRC32 diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index a0ddc3e40a5..56b1ae3fc6e 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -440,7 +440,7 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type, info->read_end= info->buffer; _my_b_encr_read(info, 0, 0); /* prefill the buffer */ info->write_pos= info->read_pos; - info->pos_in_file+= info->buffer_length; + info->seek_not_done=1; } } else diff --git a/sql/mf_iocache_encr.cc b/sql/mf_iocache_encr.cc index ae314d826a0..149e6feb605 100644 --- a/sql/mf_iocache_encr.cc +++ b/sql/mf_iocache_encr.cc @@ -145,9 +145,10 @@ static int my_b_encr_write(IO_CACHE *info, const uchar *Buffer, size_t Count) if (info->seek_not_done) { - DBUG_ASSERT(info->pos_in_file == 0); + DBUG_ASSERT(info->pos_in_file % info->buffer_length == 0); + size_t wpos= info->pos_in_file / info->buffer_length * crypt_data->block_length; - if ((mysql_file_seek(info->file, 0, MY_SEEK_SET, MYF(0)) == MY_FILEPOS_ERROR)) + if ((mysql_file_seek(info->file, wpos, MY_SEEK_SET, MYF(0)) == MY_FILEPOS_ERROR)) { info->error= -1; DBUG_RETURN(1); From b75d8453d4f41ff9ba0468747585d019ad7c4d0c Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 7 Feb 2018 19:08:53 +0100 Subject: [PATCH 5/9] MDEV-14868 MariaDB server crashes after using ROLLBACK TO when encrypt_tmp_files=ON add a test that restores the data from a binlog --- .../suite/encryption/r/tempfiles.result | 66 +++++++++++++++++-- mysql-test/suite/encryption/t/tempfiles.test | 22 +++++-- 2 files changed, 76 insertions(+), 12 deletions(-) diff --git a/mysql-test/suite/encryption/r/tempfiles.result b/mysql-test/suite/encryption/r/tempfiles.result index 168f79b60e9..658b7dc291b 100644 --- a/mysql-test/suite/encryption/r/tempfiles.result +++ b/mysql-test/suite/encryption/r/tempfiles.result @@ -28,6 +28,7 @@ h 10 i 10 j 10 drop table t1; +reset master; set global binlog_cache_size=8192; create table t1 (a text) engine=innodb; start transaction; @@ -36,14 +37,67 @@ commit; start transaction; insert t1 select repeat(seq, 1000) from seq_1_to_8; commit; -drop table t1; -create table t1 (a text) engine=innodb; +create table t2 (a text) engine=innodb; start transaction; -insert t1 select repeat(seq, 1000) from seq_1_to_15; +insert t2 select repeat(seq, 1000) from seq_1_to_15; savepoint foo; -insert t1 select repeat(seq, 1000) from seq_16_to_30; +insert t2 select repeat(seq, 1000) from seq_16_to_30; rollback to savepoint foo; -insert t1 select repeat(seq, 1000) from seq_31_to_40; +insert t2 select repeat(seq, 1000) from seq_31_to_40; commit; -drop table t1; +flush binary logs; +drop table t1, t2; set global binlog_cache_size=default; +select left(a, 10) from t1; +left(a, 10) +1111111111 +2222222222 +3333333333 +4444444444 +5555555555 +6666666666 +7777777777 +8888888888 +9999999999 +1010101010 +1111111111 +1212121212 +1313131313 +1414141414 +1515151515 +1111111111 +2222222222 +3333333333 +4444444444 +5555555555 +6666666666 +7777777777 +8888888888 +select left(a, 10) from t2; +left(a, 10) +1111111111 +2222222222 +3333333333 +4444444444 +5555555555 +6666666666 +7777777777 +8888888888 +9999999999 +1010101010 +1111111111 +1212121212 +1313131313 +1414141414 +1515151515 +3131313131 +3232323232 +3333333333 +3434343434 +3535353535 +3636363636 +3737373737 +3838383838 +3939393939 +4040404040 +drop table t1, t2; diff --git a/mysql-test/suite/encryption/t/tempfiles.test b/mysql-test/suite/encryption/t/tempfiles.test index fc718f4d2ab..5232bcb5d12 100644 --- a/mysql-test/suite/encryption/t/tempfiles.test +++ b/mysql-test/suite/encryption/t/tempfiles.test @@ -33,6 +33,7 @@ update t1 set c=v, t=v; select sql_big_result t,count(t) from t1 group by t limit 10; drop table t1; +reset master; set global binlog_cache_size=8192; connect con1, localhost, root; @@ -50,7 +51,6 @@ commit; start transaction; insert t1 select repeat(seq, 1000) from seq_1_to_8; commit; -drop table t1; disconnect con1; connect con2, localhost, root; @@ -60,17 +60,27 @@ connect con2, localhost, root; # Start a transaction, write until the cache goes to disk, # create a savepoint, write more blocks to disk, rollback to savepoint. # -create table t1 (a text) engine=innodb; +create table t2 (a text) engine=innodb; start transaction; -insert t1 select repeat(seq, 1000) from seq_1_to_15; +insert t2 select repeat(seq, 1000) from seq_1_to_15; savepoint foo; -insert t1 select repeat(seq, 1000) from seq_16_to_30; +insert t2 select repeat(seq, 1000) from seq_16_to_30; rollback to savepoint foo; -insert t1 select repeat(seq, 1000) from seq_31_to_40; +insert t2 select repeat(seq, 1000) from seq_31_to_40; commit; -drop table t1; disconnect con2; connection default; +flush binary logs; + +drop table t1, t2; + set global binlog_cache_size=default; + +let $MYSQLD_DATADIR= `select @@datadir`; +exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 | $MYSQL; + +select left(a, 10) from t1; +select left(a, 10) from t2; +drop table t1, t2; From 564891c5328c20089ba7d1ab450143a3abe3e0d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Fri, 9 Feb 2018 17:17:32 +0200 Subject: [PATCH 6/9] MDEV-14508: encryption.innodb-compressed-blob failed in buildbot, assertion in btr0cur.cc line 1398 Before that line there is call to buf_page_get_gen that could return block = NULL when decrypting a page fails. However, we should set error to be != DB_SUCCESS also. In error log there was error about decompression but in that code there is one case where error is not set correctly. --- storage/innobase/buf/buf0buf.cc | 2 ++ storage/xtradb/buf/buf0buf.cc | 2 ++ 2 files changed, 4 insertions(+) diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 369f62d6483..e3c2337659e 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -3453,6 +3453,8 @@ evict_from_pool: buf_block_unfix(fix_block); buf_pool_mutex_exit(buf_pool); rw_lock_x_unlock(&fix_block->lock); + + *err = DB_PAGE_CORRUPTED; return NULL; } } diff --git a/storage/xtradb/buf/buf0buf.cc b/storage/xtradb/buf/buf0buf.cc index 80ff1c14a64..83e38fbcc98 100644 --- a/storage/xtradb/buf/buf0buf.cc +++ b/storage/xtradb/buf/buf0buf.cc @@ -3369,6 +3369,8 @@ evict_from_pool: mutex_enter(&buf_pool->LRU_list_mutex); buf_block_unfix(fix_block); mutex_exit(&buf_pool->LRU_list_mutex); + + *err = DB_PAGE_CORRUPTED; return NULL; } } From b0a92333c00f8facd20c55cf7a8dfaf896b7f24d Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 9 Feb 2018 19:47:00 +0400 Subject: [PATCH 7/9] MDEV-15262 Wrong results for SELECT..WHERE non_indexed_datetime_column=indexed_time_column --- mysql-test/r/type_time_6065.result | 44 ++++++++++++++++++++++++++++++ mysql-test/t/type_time_6065.test | 23 ++++++++++++++++ sql/field.cc | 7 +++++ 3 files changed, 74 insertions(+) diff --git a/mysql-test/r/type_time_6065.result b/mysql-test/r/type_time_6065.result index db3efc3bcbb..1f64f9e90e2 100644 --- a/mysql-test/r/type_time_6065.result +++ b/mysql-test/r/type_time_6065.result @@ -2308,3 +2308,47 @@ col_int_nokey 1 DROP TABLE t1,t2,t3; SET TIMESTAMP=0; +# +# MDEV-15262 Wrong results for SELECT..WHERE non_indexed_datetime_column=indexed_time_column +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 (col_time_key TIME, KEY(col_time_key)); +CREATE TABLE t2 (col_datetime_key DATETIME); +INSERT INTO t1 VALUES ('-760:00:00'),('760:00:00'); +INSERT INTO t1 VALUES ('-770:00:00'),('770:00:00'); +INSERT INTO t2 SELECT * FROM t1; +SELECT * FROM t2 STRAIGHT_JOIN t1 IGNORE INDEX(col_time_key) WHERE col_time_key = col_datetime_key; +col_datetime_key col_time_key +2011-12-30 08:00:00 -760:00:00 +2012-03-02 16:00:00 760:00:00 +2011-12-29 22:00:00 -770:00:00 +2012-03-03 02:00:00 770:00:00 +SELECT * FROM t2 STRAIGHT_JOIN t1 FORCE INDEX (col_time_key) WHERE col_time_key = col_datetime_key; +col_datetime_key col_time_key +2011-12-29 22:00:00 -770:00:00 +2011-12-30 08:00:00 -760:00:00 +2012-03-02 16:00:00 760:00:00 +2012-03-03 02:00:00 770:00:00 +INSERT INTO t1 VALUES ('-838:59:59'),('838:59:59'); +INSERT INTO t2 VALUES (DATE_ADD(CURRENT_DATE, INTERVAL '-838:59:59' HOUR_SECOND)); +INSERT INTO t2 VALUES (DATE_ADD(CURRENT_DATE, INTERVAL '838:59:59' HOUR_SECOND)); +INSERT INTO t2 VALUES (DATE_ADD(CURRENT_DATE, INTERVAL '-839:00:00' HOUR_SECOND)); +INSERT INTO t2 VALUES (DATE_ADD(CURRENT_DATE, INTERVAL '839:00:00' HOUR_SECOND)); +SELECT * FROM t2 STRAIGHT_JOIN t1 IGNORE INDEX(col_time_key) WHERE col_time_key = col_datetime_key; +col_datetime_key col_time_key +2011-12-30 08:00:00 -760:00:00 +2012-03-02 16:00:00 760:00:00 +2011-12-29 22:00:00 -770:00:00 +2012-03-03 02:00:00 770:00:00 +2011-12-27 01:00:01 -838:59:59 +2012-03-05 22:59:59 838:59:59 +SELECT * FROM t2 STRAIGHT_JOIN t1 FORCE INDEX (col_time_key) WHERE col_time_key = col_datetime_key; +col_datetime_key col_time_key +2011-12-29 22:00:00 -770:00:00 +2011-12-30 08:00:00 -760:00:00 +2012-03-02 16:00:00 760:00:00 +2012-03-03 02:00:00 770:00:00 +2011-12-27 01:00:01 -838:59:59 +2012-03-05 22:59:59 838:59:59 +DROP TABLE t1, t2; +SET TIMESTAMP=DEFAULT; diff --git a/mysql-test/t/type_time_6065.test b/mysql-test/t/type_time_6065.test index 6e29b849be5..fc91c530760 100644 --- a/mysql-test/t/type_time_6065.test +++ b/mysql-test/t/type_time_6065.test @@ -172,6 +172,29 @@ eval $query; DROP TABLE t1,t2,t3; SET TIMESTAMP=0; # back to current time + +--echo # +--echo # MDEV-15262 Wrong results for SELECT..WHERE non_indexed_datetime_column=indexed_time_column +--echo # + +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 (col_time_key TIME, KEY(col_time_key)); +CREATE TABLE t2 (col_datetime_key DATETIME); +INSERT INTO t1 VALUES ('-760:00:00'),('760:00:00'); +INSERT INTO t1 VALUES ('-770:00:00'),('770:00:00'); +INSERT INTO t2 SELECT * FROM t1; +SELECT * FROM t2 STRAIGHT_JOIN t1 IGNORE INDEX(col_time_key) WHERE col_time_key = col_datetime_key; +SELECT * FROM t2 STRAIGHT_JOIN t1 FORCE INDEX (col_time_key) WHERE col_time_key = col_datetime_key; +INSERT INTO t1 VALUES ('-838:59:59'),('838:59:59'); +INSERT INTO t2 VALUES (DATE_ADD(CURRENT_DATE, INTERVAL '-838:59:59' HOUR_SECOND)); +INSERT INTO t2 VALUES (DATE_ADD(CURRENT_DATE, INTERVAL '838:59:59' HOUR_SECOND)); +INSERT INTO t2 VALUES (DATE_ADD(CURRENT_DATE, INTERVAL '-839:00:00' HOUR_SECOND)); +INSERT INTO t2 VALUES (DATE_ADD(CURRENT_DATE, INTERVAL '839:00:00' HOUR_SECOND)); +SELECT * FROM t2 STRAIGHT_JOIN t1 IGNORE INDEX(col_time_key) WHERE col_time_key = col_datetime_key; +SELECT * FROM t2 STRAIGHT_JOIN t1 FORCE INDEX (col_time_key) WHERE col_time_key = col_datetime_key; +DROP TABLE t1, t2; +SET TIMESTAMP=DEFAULT; + # # End of 10.0 tests # diff --git a/sql/field.cc b/sql/field.cc index c36fff06a07..a9a7d54929b 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5330,6 +5330,13 @@ static void calc_datetime_days_diff(MYSQL_TIME *ltime, long days) ltime->second) * 1000000LL + ltime->second_part); unpack_time(timediff, ltime); + /* + unpack_time() broke down hours into ltime members hour,day,month. + Mix them back to ltime->hour using the same factors + that pack_time()/unpack_time() use (i.e. 32 for month). + */ + ltime->hour+= (ltime->month * 32 + ltime->day) * 24; + ltime->month= ltime->day= 0; } ltime->time_type= MYSQL_TIMESTAMP_TIME; } From a2feeb3d6f0b994562d9ad7622438897b253ecd0 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Sat, 10 Feb 2018 21:51:24 +0400 Subject: [PATCH 8/9] After-merge fixes for "sys_vars.sysvars_innodb '32bit,xtradb'" test results. --- mysql-test/suite/sys_vars/r/sysvars_innodb,32bit,xtradb.rdiff | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit,xtradb.rdiff b/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit,xtradb.rdiff index a57fc12948c..f04fd5ed399 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit,xtradb.rdiff +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit,xtradb.rdiff @@ -1236,7 +1236,7 @@ VARIABLE_NAME INNODB_VERSION SESSION_VALUE NULL -GLOBAL_VALUE 5.6.37 -+GLOBAL_VALUE 5.6.36-83.0 ++GLOBAL_VALUE 5.6.38-83.0 GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE NULL VARIABLE_SCOPE GLOBAL From b88542681b884951308e49c99caa3435cb719f09 Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Sat, 10 Feb 2018 22:17:49 +0400 Subject: [PATCH 9/9] MDEV-14611 ALTER TABLE EXCHANGE PARTITION does not work properly when used with DATA DIRECTORY. When table is renamed, the InnoDB's dictionary cache didn't change the ib_table->data_dir_path accordingly. Now it's set to NULL. --- .../r/partition_basic_symlink_innodb.result | 193 ++++++++++++++++++ .../t/partition_basic_symlink_innodb.test | 143 ++++++++++++- storage/innobase/row/row0mysql.cc | 1 + storage/xtradb/row/row0mysql.cc | 1 + 4 files changed, 336 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/parts/r/partition_basic_symlink_innodb.result b/mysql-test/suite/parts/r/partition_basic_symlink_innodb.result index d7a77e5e54a..405511543bf 100644 --- a/mysql-test/suite/parts/r/partition_basic_symlink_innodb.result +++ b/mysql-test/suite/parts/r/partition_basic_symlink_innodb.result @@ -127,5 +127,198 @@ t1#P#p0.ibd t1#P#p1.ibd DROP TABLE t1; # +# MDEV-14611 ALTER TABLE EXCHANGE PARTITION does not work +# properly when used with DATA DIRECTORY +# +SET GLOBAL innodb_file_per_table = ON; +CREATE TABLE t1 +( +myid INT(11) NOT NULL, +myval VARCHAR(10), +PRIMARY KEY (myid) +) ENGINE=INNODB PARTITION BY KEY (myid) +( +PARTITION p0001 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = INNODB, +PARTITION p0002 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = INNODB, +PARTITION p0003 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = INNODB, +PARTITION p0004 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = INNODB +); +CREATE TABLE t2 +( +myid INT(11) NOT NULL, +myval VARCHAR(10), +PRIMARY KEY (myid) +) ENGINE=INNODB DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir'; +ALTER TABLE t1 EXCHANGE PARTITION p0001 WITH TABLE t2; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `myid` int(11) NOT NULL, + `myval` varchar(10) DEFAULT NULL, + PRIMARY KEY (`myid`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY KEY (myid) +(PARTITION p0001 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = InnoDB, + PARTITION p0002 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = InnoDB, + PARTITION p0003 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = InnoDB, + PARTITION p0004 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = InnoDB) */ +DROP TABLE t1, t2; +CREATE TABLE t1 +( +myid INT(11) NOT NULL, +myval VARCHAR(10), +PRIMARY KEY (myid) +) ENGINE=INNODB PARTITION BY RANGE (myid) +( +PARTITION p0001 VALUES LESS THAN (50) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = INNODB, +PARTITION p0002 VALUES LESS THAN (150) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = INNODB, +PARTITION p0003 VALUES LESS THAN (1050) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = INNODB, +PARTITION p0004 VALUES LESS THAN (10050) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = INNODB +); +CREATE TABLE t2 +( +myid INT(11) NOT NULL, +myval VARCHAR(10), +PRIMARY KEY (myid) +) ENGINE=INNODB DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir'; +insert into t1 values (1, 'one'); +insert into t2 values (2, 'two'), (3, 'threee'), (4, 'four'); +select * from t1; +myid myval +1 one +ALTER TABLE t1 EXCHANGE PARTITION p0001 WITH TABLE t2; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `myid` int(11) NOT NULL, + `myval` varchar(10) DEFAULT NULL, + PRIMARY KEY (`myid`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY RANGE (myid) +(PARTITION p0001 VALUES LESS THAN (50) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = InnoDB, + PARTITION p0002 VALUES LESS THAN (150) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = InnoDB, + PARTITION p0003 VALUES LESS THAN (1050) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = InnoDB, + PARTITION p0004 VALUES LESS THAN (10050) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = InnoDB) */ +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `myid` int(11) NOT NULL, + `myval` varchar(10) DEFAULT NULL, + PRIMARY KEY (`myid`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/mysql-test-data-dir/' +select * from t1; +myid myval +2 two +3 threee +4 four +select * from t2; +myid myval +1 one +DROP TABLE t1, t2; +CREATE TABLE t1 +( +myid INT(11) NOT NULL, +myval VARCHAR(10), +PRIMARY KEY (myid) +) ENGINE=INNODB PARTITION BY RANGE (myid) +( +PARTITION p0001 VALUES LESS THAN (50) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = INNODB, +PARTITION p0002 VALUES LESS THAN (150) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = INNODB, +PARTITION p0003 VALUES LESS THAN (1050) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = INNODB, +PARTITION p0004 VALUES LESS THAN (10050) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = INNODB +); +CREATE TABLE t2 +( +myid INT(11) NOT NULL, +myval VARCHAR(10), +PRIMARY KEY (myid) +) ENGINE=INNODB; +insert into t1 values (1, 'one'); +insert into t2 values (2, 'two'), (3, 'threee'), (4, 'four'); +select * from t1; +myid myval +1 one +ALTER TABLE t1 EXCHANGE PARTITION p0001 WITH TABLE t2; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `myid` int(11) NOT NULL, + `myval` varchar(10) DEFAULT NULL, + PRIMARY KEY (`myid`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY RANGE (myid) +(PARTITION p0001 VALUES LESS THAN (50) ENGINE = InnoDB, + PARTITION p0002 VALUES LESS THAN (150) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = InnoDB, + PARTITION p0003 VALUES LESS THAN (1050) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = InnoDB, + PARTITION p0004 VALUES LESS THAN (10050) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = InnoDB) */ +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `myid` int(11) NOT NULL, + `myval` varchar(10) DEFAULT NULL, + PRIMARY KEY (`myid`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/mysql-test-data-dir/' +select * from t1; +myid myval +2 two +3 threee +4 four +select * from t2; +myid myval +1 one +DROP TABLE t1, t2; +CREATE TABLE t1 +( +myid INT(11) NOT NULL, +myval VARCHAR(10), +PRIMARY KEY (myid) +) ENGINE=INNODB PARTITION BY RANGE (myid) +( +PARTITION p0001 VALUES LESS THAN (50) ENGINE = INNODB, +PARTITION p0002 VALUES LESS THAN (150) ENGINE = INNODB, +PARTITION p0003 VALUES LESS THAN (1050) ENGINE = INNODB, +PARTITION p0004 VALUES LESS THAN (10050) ENGINE = INNODB +); +CREATE TABLE t2 +( +myid INT(11) NOT NULL, +myval VARCHAR(10), +PRIMARY KEY (myid) +) ENGINE=INNODB DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir'; +insert into t1 values (1, 'one'); +insert into t2 values (2, 'two'), (3, 'threee'), (4, 'four'); +select * from t1; +myid myval +1 one +ALTER TABLE t1 EXCHANGE PARTITION p0001 WITH TABLE t2; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `myid` int(11) NOT NULL, + `myval` varchar(10) DEFAULT NULL, + PRIMARY KEY (`myid`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY RANGE (myid) +(PARTITION p0001 VALUES LESS THAN (50) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = InnoDB, + PARTITION p0002 VALUES LESS THAN (150) ENGINE = InnoDB, + PARTITION p0003 VALUES LESS THAN (1050) ENGINE = InnoDB, + PARTITION p0004 VALUES LESS THAN (10050) ENGINE = InnoDB) */ +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `myid` int(11) NOT NULL, + `myval` varchar(10) DEFAULT NULL, + PRIMARY KEY (`myid`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +select * from t1; +myid myval +2 two +3 threee +4 four +select * from t2; +myid myval +1 one +DROP TABLE t1, t2; +# # Cleanup # diff --git a/mysql-test/suite/parts/t/partition_basic_symlink_innodb.test b/mysql-test/suite/parts/t/partition_basic_symlink_innodb.test index 35dc2d5e004..31448c7a9fe 100644 --- a/mysql-test/suite/parts/t/partition_basic_symlink_innodb.test +++ b/mysql-test/suite/parts/t/partition_basic_symlink_innodb.test @@ -147,6 +147,147 @@ SHOW CREATE TABLE t1; DROP TABLE t1; +--echo # +--echo # MDEV-14611 ALTER TABLE EXCHANGE PARTITION does not work +--echo # properly when used with DATA DIRECTORY +--echo # +let $data_dir_path= $MYSQLTEST_VARDIR/mysql-test-data-dir; +let $alt_data_dir_path= $MYSQLTEST_VARDIR/mysql-test-idx-dir; +SET GLOBAL innodb_file_per_table = ON; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval CREATE TABLE t1 +( + myid INT(11) NOT NULL, + myval VARCHAR(10), + PRIMARY KEY (myid) +) ENGINE=INNODB PARTITION BY KEY (myid) + ( + PARTITION p0001 DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB, + PARTITION p0002 DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB, + PARTITION p0003 DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB, + PARTITION p0004 DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB + ); + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval CREATE TABLE t2 +( + myid INT(11) NOT NULL, + myval VARCHAR(10), + PRIMARY KEY (myid) +) ENGINE=INNODB DATA DIRECTORY = '$data_dir_path'; + +ALTER TABLE t1 EXCHANGE PARTITION p0001 WITH TABLE t2; + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +SHOW CREATE TABLE t1; +DROP TABLE t1, t2; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval CREATE TABLE t1 +( + myid INT(11) NOT NULL, + myval VARCHAR(10), + PRIMARY KEY (myid) +) ENGINE=INNODB PARTITION BY RANGE (myid) + ( + PARTITION p0001 VALUES LESS THAN (50) DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB, + PARTITION p0002 VALUES LESS THAN (150) DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB, + PARTITION p0003 VALUES LESS THAN (1050) DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB, + PARTITION p0004 VALUES LESS THAN (10050) DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB + ); + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval CREATE TABLE t2 +( + myid INT(11) NOT NULL, + myval VARCHAR(10), + PRIMARY KEY (myid) +) ENGINE=INNODB DATA DIRECTORY = '$alt_data_dir_path'; + +insert into t1 values (1, 'one'); +insert into t2 values (2, 'two'), (3, 'threee'), (4, 'four'); + +select * from t1; +ALTER TABLE t1 EXCHANGE PARTITION p0001 WITH TABLE t2; + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +SHOW CREATE TABLE t1; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +SHOW CREATE TABLE t2; +select * from t1; +select * from t2; +DROP TABLE t1, t2; + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval CREATE TABLE t1 +( + myid INT(11) NOT NULL, + myval VARCHAR(10), + PRIMARY KEY (myid) +) ENGINE=INNODB PARTITION BY RANGE (myid) + ( + PARTITION p0001 VALUES LESS THAN (50) DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB, + PARTITION p0002 VALUES LESS THAN (150) DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB, + PARTITION p0003 VALUES LESS THAN (1050) DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB, + PARTITION p0004 VALUES LESS THAN (10050) DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB + ); + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval CREATE TABLE t2 +( + myid INT(11) NOT NULL, + myval VARCHAR(10), + PRIMARY KEY (myid) +) ENGINE=INNODB; + +insert into t1 values (1, 'one'); +insert into t2 values (2, 'two'), (3, 'threee'), (4, 'four'); + +select * from t1; +ALTER TABLE t1 EXCHANGE PARTITION p0001 WITH TABLE t2; + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +SHOW CREATE TABLE t1; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +SHOW CREATE TABLE t2; +select * from t1; +select * from t2; +DROP TABLE t1, t2; + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval CREATE TABLE t1 +( + myid INT(11) NOT NULL, + myval VARCHAR(10), + PRIMARY KEY (myid) +) ENGINE=INNODB PARTITION BY RANGE (myid) + ( + PARTITION p0001 VALUES LESS THAN (50) ENGINE = INNODB, + PARTITION p0002 VALUES LESS THAN (150) ENGINE = INNODB, + PARTITION p0003 VALUES LESS THAN (1050) ENGINE = INNODB, + PARTITION p0004 VALUES LESS THAN (10050) ENGINE = INNODB + ); + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval CREATE TABLE t2 +( + myid INT(11) NOT NULL, + myval VARCHAR(10), + PRIMARY KEY (myid) +) ENGINE=INNODB DATA DIRECTORY = '$alt_data_dir_path'; + +insert into t1 values (1, 'one'); +insert into t2 values (2, 'two'), (3, 'threee'), (4, 'four'); + +select * from t1; +ALTER TABLE t1 EXCHANGE PARTITION p0001 WITH TABLE t2; + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +SHOW CREATE TABLE t1; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +SHOW CREATE TABLE t2; +select * from t1; +select * from t2; +DROP TABLE t1, t2; --echo # --echo # Cleanup --echo # @@ -160,5 +301,3 @@ EVAL SET GLOBAL innodb_file_per_table=$innodb_file_per_table_orig; EVAL SET SESSION innodb_strict_mode=$innodb_strict_mode_orig; --enable_query_log - - diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 36ca5c7767b..aa1dd98234b 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -5341,6 +5341,7 @@ end: trx_rollback_to_savepoint(trx, NULL); trx->error_state = DB_SUCCESS; } + table->data_dir_path= NULL; } funct_exit: diff --git a/storage/xtradb/row/row0mysql.cc b/storage/xtradb/row/row0mysql.cc index 549a19799b3..ce4fe7f53ea 100644 --- a/storage/xtradb/row/row0mysql.cc +++ b/storage/xtradb/row/row0mysql.cc @@ -5372,6 +5372,7 @@ end: trx_rollback_to_savepoint(trx, NULL); trx->error_state = DB_SUCCESS; } + table->data_dir_path= NULL; } funct_exit: