From e49c1d1cef245b684eadf52e265675f88023eca8 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 24 Feb 2018 09:32:50 +0100 Subject: [PATCH 01/16] mtr: force-flush stderr and stdout prevents buffering in cases like ./mtr | tee log --- mysql-test/lib/My/Tee.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mysql-test/lib/My/Tee.pm b/mysql-test/lib/My/Tee.pm index ee82e6f45ae..5985fe33739 100644 --- a/mysql-test/lib/My/Tee.pm +++ b/mysql-test/lib/My/Tee.pm @@ -1,4 +1,5 @@ package My::Tee; +use IO::Handle; # see PerlIO::via @@ -16,6 +17,7 @@ sub WRITE { my ($obj, $buf, $fh) = @_; print $fh $buf; + $fh->flush; print $copyfh $buf; return length($buf); } From e826d1e64d4c03f2365763f64c180b67ed95bb53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Sat, 24 Feb 2018 18:03:41 +0200 Subject: [PATCH 02/16] MDEV-14814: encryption.innodb_encryption-page-compression failed in buildbot with timeout on wait condition Fix wrong wait condition. --- mysql-test/suite/encryption/disabled.def | 2 +- .../r/innodb_encryption-page-compression.result | 2 -- .../t/innodb_encryption-page-compression.test | 16 ++++++++++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/mysql-test/suite/encryption/disabled.def b/mysql-test/suite/encryption/disabled.def index 08f8bd8542b..9777a4ac99a 100644 --- a/mysql-test/suite/encryption/disabled.def +++ b/mysql-test/suite/encryption/disabled.def @@ -13,4 +13,4 @@ innodb_scrub : MDEV-8139 scrubbing does not work reliably innodb_scrub_background : MDEV-8139 scrubbing does not work reliably innodb-redo-badkey : MDEV-13893 / MDEV-12699 Improve crash recovery of corrupted data pages -innodb_encryption-page-compression : MDEV-14814 wait condition timeout + diff --git a/mysql-test/suite/encryption/r/innodb_encryption-page-compression.result b/mysql-test/suite/encryption/r/innodb_encryption-page-compression.result index 712690d2925..34eb9b0c6dd 100644 --- a/mysql-test/suite/encryption/r/innodb_encryption-page-compression.result +++ b/mysql-test/suite/encryption/r/innodb_encryption-page-compression.result @@ -1,5 +1,4 @@ SET GLOBAL innodb_encryption_threads = 4; -SET GLOBAL innodb_encrypt_tables = on; set global innodb_compression_algorithm = 1; create table innodb_normal (c1 int, b char(20)) engine=innodb; show warnings; @@ -165,7 +164,6 @@ innodb_page_compressed7, innodb_page_compressed8, innodb_page_compressed9 for export; unlock tables; # Wait until dirty pages are compressed and encrypted 2 -unlock tables; SELECT variable_value > 0 FROM information_schema.global_status WHERE variable_name = 'innodb_num_pages_decrypted'; variable_value > 0 1 diff --git a/mysql-test/suite/encryption/t/innodb_encryption-page-compression.test b/mysql-test/suite/encryption/t/innodb_encryption-page-compression.test index 4f8a3373fb2..bd14def69f9 100644 --- a/mysql-test/suite/encryption/t/innodb_encryption-page-compression.test +++ b/mysql-test/suite/encryption/t/innodb_encryption-page-compression.test @@ -2,8 +2,14 @@ -- source include/have_example_key_management_plugin.inc -- source include/not_embedded.inc +--disable_query_log +let $innodb_encrypt_tables_orig = `SELECT @@innodb_encrypt_tables`; +let $innodb_encryption_threads_orig = `SELECT @@innodb_encryption_threads`; +--enable_query_log + +--disable_warnings SET GLOBAL innodb_encryption_threads = 4; -SET GLOBAL innodb_encrypt_tables = on; +--enable_warnings # zlib set global innodb_compression_algorithm = 1; @@ -110,12 +116,12 @@ innodb_page_compressed3, innodb_page_compressed4, innodb_page_compressed5, innodb_page_compressed6, innodb_page_compressed7, innodb_page_compressed8, innodb_page_compressed9 for export; + unlock tables; --echo # Wait until dirty pages are compressed and encrypted 2 let $wait_condition= select variable_value > 0 from information_schema.global_status where variable_name = 'INNODB_NUM_PAGES_PAGE_COMPRESSED'; --source include/wait_condition.inc -unlock tables; let $wait_condition= select variable_value > 0 from information_schema.global_status where variable_name = 'INNODB_NUM_PAGES_DECRYPTED'; --source include/wait_condition.inc @@ -134,3 +140,9 @@ drop table innodb_page_compressed6; drop table innodb_page_compressed7; drop table innodb_page_compressed8; drop table innodb_page_compressed9; + +# reset system +--disable_query_log +EVAL SET GLOBAL innodb_encrypt_tables = $innodb_encrypt_tables_orig; +EVAL SET GLOBAL innodb_encryption_threads = $innodb_encryption_threads_orig; +--enable_query_log From d0cc7a52255fd39dda8b73828e26d3541e0b0c64 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Sun, 25 Feb 2018 23:59:01 +0400 Subject: [PATCH 03/16] MDEV-15420 Wrong result for CAST from TIME or DATETIME with zero integer part and non-zero microseconds to DECIMAL(X,Y) The loop in ull2dec() does not iterate if "from" is zero, so to->intg got erroneously set to 0 instead of 1. Because if this, my_decimal2seconds() wrote the fractional part into a wrong buf[x]. Catching the special case with zero "from" and properly initialize "to" using decimal_make_zero(). --- mysql-test/r/type_decimal.result | 16 ++++++++++++++++ mysql-test/t/type_decimal.test | 18 ++++++++++++++++++ strings/decimal.c | 6 ++++++ 3 files changed, 40 insertions(+) diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result index 0ead4ec9aa2..d5232ff92a8 100644 --- a/mysql-test/r/type_decimal.result +++ b/mysql-test/r/type_decimal.result @@ -1019,3 +1019,19 @@ cast('-0.0' as decimal(5,1)) < 0 # # End of 5.5 tests # +# +# Start of 10.2 tests +# +# +# MDEV-15420 Wrong result for CAST from TIME or DATETIME with zero integer part and non-zero microseconds to DECIMAL(X,Y) +# +SET sql_mode=''; +SELECT +CAST(TIMESTAMP'0000-00-00 00:00:00.123456' AS DECIMAL(10,6)) AS c1, +CAST(TIME'00:00:00.123456' AS DECIMAL(10,6)) AS c2; +c1 c2 +0.123456 0.123456 +SET sql_mode=DEFAULT; +# +# End of 10.2 tests +# diff --git a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test index 777bb2f23e5..e8b3ecbf0a9 100644 --- a/mysql-test/t/type_decimal.test +++ b/mysql-test/t/type_decimal.test @@ -612,3 +612,21 @@ select cast('-0.0' as decimal(5,1)) < 0; --echo # --echo # End of 5.5 tests --echo # + +--echo # +--echo # Start of 10.2 tests +--echo # + +--echo # +--echo # MDEV-15420 Wrong result for CAST from TIME or DATETIME with zero integer part and non-zero microseconds to DECIMAL(X,Y) +--echo # + +SET sql_mode=''; # Allow zero date +SELECT + CAST(TIMESTAMP'0000-00-00 00:00:00.123456' AS DECIMAL(10,6)) AS c1, + CAST(TIME'00:00:00.123456' AS DECIMAL(10,6)) AS c2; +SET sql_mode=DEFAULT; + +--echo # +--echo # End of 10.2 tests +--echo # diff --git a/strings/decimal.c b/strings/decimal.c index 7db5111fc84..029a85b3202 100644 --- a/strings/decimal.c +++ b/strings/decimal.c @@ -1000,6 +1000,12 @@ static int ull2dec(ulonglong from, decimal_t *to) sanity(to); + if (!from) + { + decimal_make_zero(to); + return E_DEC_OK; + } + for (intg1=1; from >= DIG_BASE; intg1++, from/=DIG_BASE) {} if (unlikely(intg1 > to->len)) { From 8f98835bb86550a68a6c412d8417cc169dfdc206 Mon Sep 17 00:00:00 2001 From: Elena Stepanova Date: Sat, 3 Mar 2018 01:59:52 +0200 Subject: [PATCH 04/16] MDEV-15448 Remove "innodb_additional_mem_pool_size" setting from my-innodb-heavy-4G.cnf file --- sql-bench/example | 4 ++-- support-files/my-huge.cnf.sh | 1 - support-files/my-innodb-heavy-4G.cnf.sh | 7 ------- support-files/my-large.cnf.sh | 1 - support-files/my-medium.cnf.sh | 1 - support-files/my-small.cnf.sh | 1 - 6 files changed, 2 insertions(+), 13 deletions(-) diff --git a/sql-bench/example b/sql-bench/example index 877fd080ac5..392edf21c57 100644 --- a/sql-bench/example +++ b/sql-bench/example @@ -6,9 +6,9 @@ machine="Linux-x64" # InnoDB tests -./run-all-tests --suffix=-innodb --comments="Engine=InnoDB --innodb_buffer_pool_size=256M --innodb_additional_mem_pool_size=20M --innodb_log_file_size=1000M --innodb_log_buffer_size=16M --innodb_lock_wait_timeout=50 --innodb_flush_log_at_trx_commit=1 --innodb_flush_method=O_DIRECT --innodb_log_files_in_group=2 --skip-innodb-doublewrite" --create-options="ENGINE=InnoDB" --hw="$hw" --optimization="$optimization" --machine="$machine" --log +./run-all-tests --suffix=-innodb --comments="Engine=InnoDB --innodb_buffer_pool_size=256M --innodb_log_file_size=1000M --innodb_log_buffer_size=16M --innodb_lock_wait_timeout=50 --innodb_flush_log_at_trx_commit=1 --innodb_flush_method=O_DIRECT --innodb_log_files_in_group=2 --skip-innodb-doublewrite" --create-options="ENGINE=InnoDB" --hw="$hw" --optimization="$optimization" --machine="$machine" --log -./run-all-tests --suffix=_fast-innodb --comments="Engine=InnoDB --innodb_buffer_pool_size=256M --innodb_additional_mem_pool_size=20M --innodb_log_file_size=1000M --innodb_log_buffer_size=16M --innodb_lock_wait_timeout=50 --innodb_flush_log_at_trx_commit=1 --innodb_flush_method=O_DIRECT --innodb_log_files_in_group=2 --skip-innodb-doublewrite" --create-options="ENGINE=InnoDB" --hw="$hw" --optimization="$optimization" --machine="$machine" --fast --log +./run-all-tests --suffix=_fast-innodb --comments="Engine=InnoDB --innodb_buffer_pool_size=256M --innodb_log_file_size=1000M --innodb_log_buffer_size=16M --innodb_lock_wait_timeout=50 --innodb_flush_log_at_trx_commit=1 --innodb_flush_method=O_DIRECT --innodb_log_files_in_group=2 --skip-innodb-doublewrite" --create-options="ENGINE=InnoDB" --hw="$hw" --optimization="$optimization" --machine="$machine" --fast --log # MyISAM tests diff --git a/support-files/my-huge.cnf.sh b/support-files/my-huge.cnf.sh index 4e083488285..597e66f2099 100644 --- a/support-files/my-huge.cnf.sh +++ b/support-files/my-huge.cnf.sh @@ -125,7 +125,6 @@ server-id = 1 # You can set .._buffer_pool_size up to 50 - 80 % # of RAM but beware of setting memory usage too high #innodb_buffer_pool_size = 384M -#innodb_additional_mem_pool_size = 20M # Set .._log_file_size to 25 % of buffer pool size #innodb_log_file_size = 100M #innodb_log_buffer_size = 8M diff --git a/support-files/my-innodb-heavy-4G.cnf.sh b/support-files/my-innodb-heavy-4G.cnf.sh index 2590ff5ddea..bf9ec7fa147 100644 --- a/support-files/my-innodb-heavy-4G.cnf.sh +++ b/support-files/my-innodb-heavy-4G.cnf.sh @@ -356,13 +356,6 @@ myisam_recover # and speed up some things. #skip-innodb -# Additional memory pool that is used by InnoDB to store metadata -# information. If InnoDB requires more memory for this purpose it will -# start to allocate it from the OS. As this is fast enough on most -# recent operating systems, you normally do not need to change this -# value. SHOW INNODB STATUS will display the current amount used. -innodb_additional_mem_pool_size = 16M - # InnoDB, unlike MyISAM, uses a buffer pool to cache both indexes and # row data. The bigger you set this the less disk I/O is needed to # access data in tables. On a dedicated database server you may set this diff --git a/support-files/my-large.cnf.sh b/support-files/my-large.cnf.sh index 6f8dab0b0e2..50f62e897ea 100644 --- a/support-files/my-large.cnf.sh +++ b/support-files/my-large.cnf.sh @@ -125,7 +125,6 @@ server-id = 1 # You can set .._buffer_pool_size up to 50 - 80 % # of RAM but beware of setting memory usage too high #innodb_buffer_pool_size = 256M -#innodb_additional_mem_pool_size = 20M # Set .._log_file_size to 25 % of buffer pool size #innodb_log_file_size = 64M #innodb_log_buffer_size = 8M diff --git a/support-files/my-medium.cnf.sh b/support-files/my-medium.cnf.sh index 19ab8dfb151..77d60b5d724 100644 --- a/support-files/my-medium.cnf.sh +++ b/support-files/my-medium.cnf.sh @@ -123,7 +123,6 @@ server-id = 1 # You can set .._buffer_pool_size up to 50 - 80 % # of RAM but beware of setting memory usage too high #innodb_buffer_pool_size = 16M -#innodb_additional_mem_pool_size = 2M # Set .._log_file_size to 25 % of buffer pool size #innodb_log_file_size = 5M #innodb_log_buffer_size = 8M diff --git a/support-files/my-small.cnf.sh b/support-files/my-small.cnf.sh index 8c78072c0a7..511a48627fd 100644 --- a/support-files/my-small.cnf.sh +++ b/support-files/my-small.cnf.sh @@ -65,7 +65,6 @@ server-id = 1 # You can set .._buffer_pool_size up to 50 - 80 % # of RAM but beware of setting memory usage too high #innodb_buffer_pool_size = 16M -#innodb_additional_mem_pool_size = 2M # Set .._log_file_size to 25 % of buffer pool size #innodb_log_file_size = 5M #innodb_log_buffer_size = 8M From 176d603cc7f2be0f5816a28c738cdd52ff6e3008 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 4 Mar 2018 18:59:29 +0100 Subject: [PATCH 05/16] MDEV-15462 TokuDB does not build on openSUSE fix 50359719f0d don't rely on any specific engine checking order --- storage/tokudb/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/storage/tokudb/CMakeLists.txt b/storage/tokudb/CMakeLists.txt index 1cd86eb5808..31374b1ff81 100644 --- a/storage/tokudb/CMakeLists.txt +++ b/storage/tokudb/CMakeLists.txt @@ -4,8 +4,9 @@ IF(CMAKE_VERSION VERSION_LESS "2.8.9") MESSAGE(STATUS "CMake 2.8.9 or higher is required by TokuDB") ELSEIF(NOT HAVE_DLOPEN) MESSAGE(STATUS "dlopen is required by TokuDB") -ELSEIF(NOT TARGET perfschema) +ELSEIF(PLUGIN_PERFSCHEMA MATCHES "^NO$") MESSAGE(STATUS "Performance Schema is required by TokuDB") + RETURN() ELSEIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64") # tokudb requires F_NOCACHE or O_DIRECT, and designated initializers From a050189773c911e0b9689aa212c44aaa0cea7b66 Mon Sep 17 00:00:00 2001 From: Ian Gilfillan Date: Tue, 6 Mar 2018 09:16:08 +0200 Subject: [PATCH 06/16] MDEV-15474 Update server.cnf section to mariadb-10.2 --- support-files/rpm/server.cnf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/support-files/rpm/server.cnf b/support-files/rpm/server.cnf index 9682d2b836f..3dd39510105 100644 --- a/support-files/rpm/server.cnf +++ b/support-files/rpm/server.cnf @@ -39,8 +39,8 @@ # you can put MariaDB-only options here [mariadb] -# This group is only read by MariaDB-10.1 servers. +# This group is only read by MariaDB-10.2 servers. # If you use the same .cnf file for MariaDB of different versions, # use this group for options that older servers don't understand -[mariadb-10.1] +[mariadb-10.2] From 8ef727b3d072c13788553f2174fd8bd70481f658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 7 Mar 2018 12:07:49 +0200 Subject: [PATCH 07/16] MDEV-14904 Backport innodb_default_row_format InnoDB in Debian uses utf8mb4 as default character set since version 10.0.20-2. This leads to major pain due to keys longer than 767 bytes. MariaDB 10.2 (and MySQL 5.7) introduced the setting innodb_default_row_format that is DYNAMIC by default. These versions also changed the default values of the parameters innodb_large_prefix=ON and innodb_file_format=Barracuda. This would allow longer column index prefixes to be created. The original purpose of these parameters was to allow InnoDB to be downgraded to MySQL 5.1, which is long out of support. Every InnoDB version since MySQL 5.5 does support operation with the relaxed limits. We backport the parameter innodb_default_row_format to MariaDB 10.1, but we will keep its default value at COMPACT. This allows MariaDB 10.1 to be configured so that CREATE TABLE is less likely to encounter a problem with the limitation: loose_innodb_large_prefix=ON loose_innodb_default_row_format=DYNAMIC (Note that the setting innodb_large_prefix was deprecated in MariaDB 10.2 and removed in MariaDB 10.3.) The only observable difference in the behaviour with the default settings should be that ROW_FORMAT=DYNAMIC tables can be created both in the system tablespace and in .ibd files, no matter what innodb_file_format has been assigned to. Unlike MariaDB 10.2, we are not changing the default value of innodb_file_format, so ROW_FORMAT=COMPRESSED tables cannot be created without changing the parameter. --- .../include/innodb_row_format.combinations | 8 + mysql-test/include/innodb_row_format.inc | 4 + .../suite/innodb/r/create-index-debug.result | 3 - .../innodb/r/default_row_format_alter.result | 85 +++++++++ .../r/default_row_format_compatibility.result | 100 +++++++++++ .../r/default_row_format_create,dynamic.rdiff | 11 ++ .../default_row_format_create,redundant.rdiff | 11 ++ .../innodb/r/default_row_format_create.result | 31 ++++ .../innodb/r/file_format_defaults.result | 56 ++++++ .../innodb/t/default_row_format_alter.test | 98 ++++++++++ .../t/default_row_format_compatibility.test | 167 ++++++++++++++++++ .../innodb/t/default_row_format_create.test | 28 +++ .../innodb/t/file_format_defaults-master.opt | 1 + .../suite/innodb/t/file_format_defaults.test | 73 ++++++++ .../innodb_zip/r/innodb-create-options.result | 34 ++-- .../suite/innodb_zip/r/innodb-zip.result | 19 +- .../innodb_zip/t/innodb-create-options.test | 14 +- mysql-test/suite/innodb_zip/t/innodb-zip.test | 9 +- mysql-test/suite/parts/r/longname.result | 9 - .../r/innodb_default_row_format_basic.result | 48 +++++ .../suite/sys_vars/r/sysvars_innodb.result | 14 ++ .../t/innodb_default_row_format_basic.test | 41 +++++ storage/innobase/dict/dict0crea.cc | 7 +- storage/innobase/handler/ha_innodb.cc | 94 +++++++--- storage/xtradb/dict/dict0crea.cc | 8 +- storage/xtradb/handler/ha_innodb.cc | 96 +++++++--- 26 files changed, 946 insertions(+), 123 deletions(-) create mode 100644 mysql-test/include/innodb_row_format.combinations create mode 100644 mysql-test/include/innodb_row_format.inc create mode 100644 mysql-test/suite/innodb/r/default_row_format_alter.result create mode 100644 mysql-test/suite/innodb/r/default_row_format_compatibility.result create mode 100644 mysql-test/suite/innodb/r/default_row_format_create,dynamic.rdiff create mode 100644 mysql-test/suite/innodb/r/default_row_format_create,redundant.rdiff create mode 100644 mysql-test/suite/innodb/r/default_row_format_create.result create mode 100644 mysql-test/suite/innodb/r/file_format_defaults.result create mode 100644 mysql-test/suite/innodb/t/default_row_format_alter.test create mode 100644 mysql-test/suite/innodb/t/default_row_format_compatibility.test create mode 100644 mysql-test/suite/innodb/t/default_row_format_create.test create mode 100644 mysql-test/suite/innodb/t/file_format_defaults-master.opt create mode 100644 mysql-test/suite/innodb/t/file_format_defaults.test create mode 100644 mysql-test/suite/sys_vars/r/innodb_default_row_format_basic.result create mode 100644 mysql-test/suite/sys_vars/t/innodb_default_row_format_basic.test diff --git a/mysql-test/include/innodb_row_format.combinations b/mysql-test/include/innodb_row_format.combinations new file mode 100644 index 00000000000..fb94d61dd42 --- /dev/null +++ b/mysql-test/include/innodb_row_format.combinations @@ -0,0 +1,8 @@ +[redundant] +innodb_default_row_format=redundant + +[compact] +innodb_default_row_format=compact + +[dynamic] +innodb_default_row_format=dynamic diff --git a/mysql-test/include/innodb_row_format.inc b/mysql-test/include/innodb_row_format.inc new file mode 100644 index 00000000000..8c6357e57d6 --- /dev/null +++ b/mysql-test/include/innodb_row_format.inc @@ -0,0 +1,4 @@ +# The goal of including this file is to enable innodb_default_row_format +# combinations (see include/innodb_row_format.combinations) + +--source include/have_innodb.inc diff --git a/mysql-test/suite/innodb/r/create-index-debug.result b/mysql-test/suite/innodb/r/create-index-debug.result index 99f6efe9bfe..9d266c68af3 100644 --- a/mysql-test/suite/innodb/r/create-index-debug.result +++ b/mysql-test/suite/innodb/r/create-index-debug.result @@ -10,9 +10,6 @@ CHAR(255) NOT NULL, f13 CHAR(255) NOT NULL, f14 CHAR(255) NOT NULL,f15 CHAR(255) NOT NULL, f16 CHAR(255) NOT NULL, f17 CHAR(255) NOT NULL,f18 CHAR(255) NOT NULL) ENGINE=INNODB ROW_FORMAT=DYNAMIC; -Warnings: -Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope. -Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT. INSERT INTO t1 VALUES('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r'); INSERT INTO t1 SELECT * FROM t1; diff --git a/mysql-test/suite/innodb/r/default_row_format_alter.result b/mysql-test/suite/innodb/r/default_row_format_alter.result new file mode 100644 index 00000000000..1f4f78ee670 --- /dev/null +++ b/mysql-test/suite/innodb/r/default_row_format_alter.result @@ -0,0 +1,85 @@ +SET @row_format = @@GLOBAL.innodb_default_row_format; +#################################### +# Check if table rebuilding alter isn't affect if table is created +# with explicit row_format +CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ROW_FORMAT=COMPACT ENGINE=INNODB; +INSERT INTO t1 VALUES (1, 'abc'); +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL row_format=COMPACT +SET GLOBAL innodb_default_row_format=DYNAMIC; +ALTER TABLE t1 DROP PRIMARY KEY, ADD COLUMN c INT PRIMARY KEY; +# Here we expect COMPACT because it was explicitly specified at CREATE +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL row_format=COMPACT +DROP TABLE t1; +#################################### +# Check if table rebuilding alter is affected when there is no +# row_format specified at CREATE TABLE. +SET GLOBAL innodb_default_row_format = COMPACT; +CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ENGINE=INNODB; +INSERT INTO t1 VALUES (1, 'abc'); +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL +SET GLOBAL innodb_default_row_format = DYNAMIC; +ALTER TABLE t1 DROP PRIMARY KEY, ADD COLUMN c INT PRIMARY KEY; +# Here we expect DYNAMIC because there is no explicit ROW_FORMAT and the +# default_row_format is changed to DYNAMIC just before ALTER +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Dynamic # # # # # # NULL # NULL NULL latin1_swedish_ci NULL +DROP TABLE t1; +#################################### +# Check the row_format effect on ALTER, ALGORITHM=COPY +SET GLOBAL innodb_default_row_format = REDUNDANT; +CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ENGINE=INNODB; +INSERT INTO t1 VALUES (1, REPEAT('abc',1000)); +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Redundant # # # # # # NULL # NULL NULL latin1_swedish_ci NULL +SET GLOBAL innoDB_default_row_format = COMPACT; +ALTER TABLE t1 ADD COLUMN c2 BLOB, ALGORITHM=COPY; +# Because of ALGORITHM=COPY, there is TABLE REBUILD and the table isn't +# created with explicit row_format, so we expect ROW_FORMAT=COMPACT +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL +DROP TABLE t1; + +################################### +# Check the row_format effect on ALTER, ALGORITH=COPY on +# create table with explicit row_format +CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ROW_FORMAT=REDUNDANT ENGINE=INNODB; +INSERT INTO t1 VALUES (1, REPEAT('abc',1000)); +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Redundant # # # # # # NULL # NULL NULL latin1_swedish_ci NULL row_format=REDUNDANT +SET GLOBAL innoDB_default_row_format = COMPACT; +ALTER TABLE t1 ADD COLUMN c2 BLOB, ALGORITHM=COPY; +# Because of ALGORITHM=COPY, there is TABLE REBUILD and the table is +# created with explicit row_format, so we expect original +# ROW_FORMAT=REDUNDANT +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Redundant # # # # # # NULL # NULL NULL latin1_swedish_ci NULL row_format=REDUNDANT +DROP TABLE t1; + +################################## +# Check row_format on ALTER ALGORITHM=INPLACE +SET GLOBAL innodb_default_row_format=COMPACT; +CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT, KEY k1(b(10))) ENGINE=INNODB; +INSERT INTO t1 VALUES (1, REPEAT('abc',1000)); +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL +SET GLOBAL innodb_default_row_format=DYNAMIC; +ALTER TABLE t1 DROP INDEX k1; +# Because it is in-place operation, there is no rebuild, so the +# original format has to be retained. +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL +DROP TABLE t1; +SET GLOBAL innodb_default_row_format = @row_format; diff --git a/mysql-test/suite/innodb/r/default_row_format_compatibility.result b/mysql-test/suite/innodb/r/default_row_format_compatibility.result new file mode 100644 index 00000000000..741241ddba0 --- /dev/null +++ b/mysql-test/suite/innodb/r/default_row_format_compatibility.result @@ -0,0 +1,100 @@ +SET @row_format = @@GLOBAL.innodb_default_row_format; +SET @large_prefix = @@GLOBAL.innodb_large_prefix; +SET @file_format = @@GLOBAL.innodb_file_format; +SET GLOBAL innodb_file_format = barracuda; +# ########################################################### +# Check with Import/Export tablespace with Default_row_format +SET GLOBAL innodb_default_row_format=Compact; +SELECT @@innodb_default_row_format; +@@innodb_default_row_format +compact +SELECT @@innodb_file_per_table; +@@innodb_file_per_table +1 +CREATE TABLE tab(a INT) ENGINE=InnoDB; +SHOW TABLE STATUS LIKE 'tab'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +tab InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL +INSERT INTO tab VALUES(1); +INSERT INTO tab VALUES(2); +SELECT * FROM tab; +a +1 +2 +FLUSH TABLE tab FOR EXPORT; +UNLOCK TABLES; +DROP TABLE tab; +SET GLOBAL innodb_default_row_format=Dynamic; +CREATE TABLE tab(a INT) ENGINE=InnoDB; +ALTER TABLE tab DISCARD TABLESPACE; +ALTER TABLE tab IMPORT TABLESPACE; +ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x21 and the meta-data file has 0x1) +DROP TABLE tab; +SET GLOBAL innodb_default_row_format=Compact; +SELECT @@innodb_default_row_format; +@@innodb_default_row_format +compact +CREATE TABLE tab(a INT) ENGINE=InnoDB; +SHOW TABLE STATUS LIKE 'tab'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +tab InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL +ALTER TABLE tab DISCARD TABLESPACE; +ALTER TABLE tab IMPORT TABLESPACE; +SELECT * FROM tab; +a +1 +2 +DROP TABLE tab; +# ########################################################### +SET GLOBAL innodb_default_row_format=Dynamic; +SET GLOBAL innodb_large_prefix=ON; +SELECT @@innodb_default_row_format; +@@innodb_default_row_format +dynamic +CREATE TABLE tab(a INT PRIMARY KEY, b VARCHAR(5000), KEY idx1(b(3070))) ENGINE= InnoDB; +SHOW TABLE STATUS LIKE 'tab'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +tab InnoDB # Dynamic # # # # # # NULL # NULL NULL latin1_swedish_ci NULL +INSERT INTO tab(a,b) VALUES(1,'Check with max column size'); +SELECT * FROM tab; +a b +1 Check with max column size +SET GLOBAL innodb_default_row_format=COMPACT; +ALTER TABLE tab ROW_FORMAT=COMPACT; +ERROR HY000: Index column size too large. The maximum column size is 767 bytes. +DROP TABLE tab; +SET GLOBAL innodb_default_row_format=Default; +SELECT @@innodb_default_row_format; +@@innodb_default_row_format +compact +SET GLOBAL innodb_default_row_format=Dynamic; +SELECT @@innodb_default_row_format; +@@innodb_default_row_format +dynamic +CREATE TABLE tab(a INT PRIMARY KEY, b VARCHAR(5000), KEY idx1(b(767))) ENGINE= InnoDB; +SHOW TABLE STATUS LIKE 'tab'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +tab InnoDB # Dynamic # # # # # # NULL # NULL NULL latin1_swedish_ci NULL +INSERT INTO tab(a,b) VALUES(1,'Check with max column size'); +SELECT * FROM tab; +a b +1 Check with max column size +ALTER TABLE tab ROW_FORMAT=COMPACT; +SHOW TABLE STATUS LIKE 'tab'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +tab InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL row_format=COMPACT +SELECT * FROM tab; +a b +1 Check with max column size +ALTER TABLE tab ROW_FORMAT=COMPRESSED; +SELECT * FROM tab; +a b +1 Check with max column size +ALTER TABLE tab ROW_FORMAT=Dynamic; +SHOW TABLE STATUS LIKE 'tab'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +tab InnoDB # Dynamic # # # # # # NULL # NULL NULL latin1_swedish_ci NULL row_format=DYNAMIC +DROP TABLE tab; +SET GLOBAL innodb_default_row_format = @row_format; +SET GLOBAL innodb_large_prefix = @large_prefix; +SET GLOBAL innodb_file_format = @file_format; diff --git a/mysql-test/suite/innodb/r/default_row_format_create,dynamic.rdiff b/mysql-test/suite/innodb/r/default_row_format_create,dynamic.rdiff new file mode 100644 index 00000000000..bb23b78213b --- /dev/null +++ b/mysql-test/suite/innodb/r/default_row_format_create,dynamic.rdiff @@ -0,0 +1,11 @@ +--- default_row_format_create.result ++++ default_row_format_create,dynamic.result +@@ -1,7 +1,7 @@ + CREATE TABLE t1(c1 TEXT,c2 BLOB) ENGINE=InnoDB; + SHOW TABLE STATUS LIKE 't1'; + Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +-t1 InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL ++t1 InnoDB # Dynamic # # # # # # NULL # NULL NULL latin1_swedish_ci NULL + DROP TABLE t1; + CREATE TABLE t1(c1 TEXT,c2 BLOB) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; + SHOW TABLE STATUS LIKE 't1'; diff --git a/mysql-test/suite/innodb/r/default_row_format_create,redundant.rdiff b/mysql-test/suite/innodb/r/default_row_format_create,redundant.rdiff new file mode 100644 index 00000000000..35aa402edd9 --- /dev/null +++ b/mysql-test/suite/innodb/r/default_row_format_create,redundant.rdiff @@ -0,0 +1,11 @@ +--- default_row_format_create.result ++++ default_row_format_create,redundant.result +@@ -1,7 +1,7 @@ + CREATE TABLE t1(c1 TEXT,c2 BLOB) ENGINE=InnoDB; + SHOW TABLE STATUS LIKE 't1'; + Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +-t1 InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL ++t1 InnoDB # Redundant # # # # # # NULL # NULL NULL latin1_swedish_ci NULL + DROP TABLE t1; + CREATE TABLE t1(c1 TEXT,c2 BLOB) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; + SHOW TABLE STATUS LIKE 't1'; diff --git a/mysql-test/suite/innodb/r/default_row_format_create.result b/mysql-test/suite/innodb/r/default_row_format_create.result new file mode 100644 index 00000000000..4e90922d70d --- /dev/null +++ b/mysql-test/suite/innodb/r/default_row_format_create.result @@ -0,0 +1,31 @@ +CREATE TABLE t1(c1 TEXT,c2 BLOB) ENGINE=InnoDB; +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL +DROP TABLE t1; +CREATE TABLE t1(c1 TEXT,c2 BLOB) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Dynamic # # # # # # NULL # NULL NULL latin1_swedish_ci NULL row_format=DYNAMIC +DROP TABLE t1; +CREATE TABLE t1(c1 TEXT,c2 BLOB) ENGINE=InnoDB ROW_FORMAT=COMPACT; +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL row_format=COMPACT +DROP TABLE t1; +CREATE TABLE t1(c1 TEXT,c2 BLOB) ENGINE=InnoDB ROW_FORMAT=REDUNDANT; +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Redundant # # # # # # NULL # NULL NULL latin1_swedish_ci NULL row_format=REDUNDANT +DROP TABLE t1; +CREATE TABLE t1(c1 TEXT,c2 BLOB) ENGINE=InnoDB +ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; +Warnings: +Warning 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_format > Antelope. +Warning 1478 InnoDB: ignoring KEY_BLOCK_SIZE=1. +Warning 1478 InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_format > Antelope. +Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT. +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL row_format=COMPRESSED key_block_size=1 +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/file_format_defaults.result b/mysql-test/suite/innodb/r/file_format_defaults.result new file mode 100644 index 00000000000..981188f00f7 --- /dev/null +++ b/mysql-test/suite/innodb/r/file_format_defaults.result @@ -0,0 +1,56 @@ +SELECT @@innodb_strict_mode; +@@innodb_strict_mode +0 +SELECT @@innodb_file_per_table; +@@innodb_file_per_table +1 +SET @file_format = @@GLOBAL.innodb_file_format; +SET GLOBAL innodb_large_prefix=ON; +SET SQL_MODE=strict_all_tables; +CREATE TABLE tab0 (c1 VARCHAR(65530), KEY(c1(3073))) ENGINE=InnoDB ROW_FORMAT=COMPRESSED; +Warnings: +Warning 1071 Specified key was too long; max key length is 3072 bytes +SHOW CREATE TABLE tab0; +Table Create Table +tab0 CREATE TABLE `tab0` ( + `c1` varchar(65530) DEFAULT NULL, + KEY `c1` (`c1`(3072)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPRESSED +DROP TABLE tab0; +CREATE TABLE tab0 (c1 VARCHAR(65530), KEY(c1(3073))) ENGINE=InnoDB KEY_BLOCK_SIZE=2; +ERROR 42000: Row size too large (> 8126). Changing some columns to TEXT or BLOB may help. In current row format, BLOB prefix of 0 bytes is stored inline. +SET GLOBAL innodb_file_format=Antelope; +CREATE TABLE tab0(c1 INT,c2 LONGBLOB ) ENGINE=InnoDB ROW_FORMAT=Dynamic; +DROP TABLE tab0; +SET GLOBAL innodb_file_format=Default; +SELECT @@innodb_file_format; +@@innodb_file_format +Antelope +SET GLOBAL innodb_strict_mode=OFF; +SET GLOBAL innodb_strict_mode=Default; +SELECT @@innodb_strict_mode; +@@innodb_strict_mode +0 +SET GLOBAL innodb_large_prefix=OFF; +SELECT @@innodb_large_prefix; +@@innodb_large_prefix +0 +SET GLOBAL innodb_large_prefix=Default; +SELECT @@innodb_large_prefix; +@@innodb_large_prefix +0 +SET GLOBAL innodb_file_format_max=Default; +SELECT @@innodb_file_format_max; +@@innodb_file_format_max +Antelope +CREATE TABLE tab1(c1 int ) ENGINE=InnoDB ROW_FORMAT=COMPRESSED; +Warnings: +Warning 1478 InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_format > Antelope. +Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT. +SELECT @@innodb_file_format_max; +@@innodb_file_format_max +Antelope +SET GLOBAL innodb_file_format_max=Default; +SET GLOBAL innodb_large_prefix=off; +SET GLOBAL innodb_file_format = @file_format; +DROP TABLE tab1; diff --git a/mysql-test/suite/innodb/t/default_row_format_alter.test b/mysql-test/suite/innodb/t/default_row_format_alter.test new file mode 100644 index 00000000000..03e6ec38060 --- /dev/null +++ b/mysql-test/suite/innodb/t/default_row_format_alter.test @@ -0,0 +1,98 @@ +--source include/have_innodb.inc + +SET @row_format = @@GLOBAL.innodb_default_row_format; + +--echo #################################### +--echo # Check if table rebuilding alter isn't affect if table is created +--echo # with explicit row_format +eval CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ROW_FORMAT=COMPACT ENGINE=INNODB; +INSERT INTO t1 VALUES (1, 'abc'); +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; + +SET GLOBAL innodb_default_row_format=DYNAMIC; +ALTER TABLE t1 DROP PRIMARY KEY, ADD COLUMN c INT PRIMARY KEY; + +--echo # Here we expect COMPACT because it was explicitly specified at CREATE +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; +DROP TABLE t1; + +--echo #################################### +--echo # Check if table rebuilding alter is affected when there is no +--echo # row_format specified at CREATE TABLE. +SET GLOBAL innodb_default_row_format = COMPACT; +eval CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ENGINE=INNODB; +INSERT INTO t1 VALUES (1, 'abc'); + +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; + +SET GLOBAL innodb_default_row_format = DYNAMIC; +ALTER TABLE t1 DROP PRIMARY KEY, ADD COLUMN c INT PRIMARY KEY; + +--echo # Here we expect DYNAMIC because there is no explicit ROW_FORMAT and the +--echo # default_row_format is changed to DYNAMIC just before ALTER +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; +DROP TABLE t1; + +--echo #################################### +--echo # Check the row_format effect on ALTER, ALGORITHM=COPY +SET GLOBAL innodb_default_row_format = REDUNDANT; +eval CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ENGINE=INNODB; +INSERT INTO t1 VALUES (1, REPEAT('abc',1000)); + +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; + +SET GLOBAL innoDB_default_row_format = COMPACT; +ALTER TABLE t1 ADD COLUMN c2 BLOB, ALGORITHM=COPY; + +--echo # Because of ALGORITHM=COPY, there is TABLE REBUILD and the table isn't +--echo # created with explicit row_format, so we expect ROW_FORMAT=COMPACT +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; +DROP TABLE t1; + +--echo +--echo ################################### +--echo # Check the row_format effect on ALTER, ALGORITH=COPY on +--echo # create table with explicit row_format +eval CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ROW_FORMAT=REDUNDANT ENGINE=INNODB; +INSERT INTO t1 VALUES (1, REPEAT('abc',1000)); + +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; + +SET GLOBAL innoDB_default_row_format = COMPACT; +ALTER TABLE t1 ADD COLUMN c2 BLOB, ALGORITHM=COPY; + +--echo # Because of ALGORITHM=COPY, there is TABLE REBUILD and the table is +--echo # created with explicit row_format, so we expect original +--echo # ROW_FORMAT=REDUNDANT +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; +DROP TABLE t1; + +--echo +--echo ################################## +--echo # Check row_format on ALTER ALGORITHM=INPLACE +SET GLOBAL innodb_default_row_format=COMPACT; + +eval CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT, KEY k1(b(10))) ENGINE=INNODB; +INSERT INTO t1 VALUES (1, REPEAT('abc',1000)); + +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; + +SET GLOBAL innodb_default_row_format=DYNAMIC; +ALTER TABLE t1 DROP INDEX k1; + +--echo # Because it is in-place operation, there is no rebuild, so the +--echo # original format has to be retained. +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; +DROP TABLE t1; + +SET GLOBAL innodb_default_row_format = @row_format; diff --git a/mysql-test/suite/innodb/t/default_row_format_compatibility.test b/mysql-test/suite/innodb/t/default_row_format_compatibility.test new file mode 100644 index 00000000000..17ab21ca06b --- /dev/null +++ b/mysql-test/suite/innodb/t/default_row_format_compatibility.test @@ -0,0 +1,167 @@ +--source include/have_innodb.inc + +SET @row_format = @@GLOBAL.innodb_default_row_format; +SET @large_prefix = @@GLOBAL.innodb_large_prefix; +SET @file_format = @@GLOBAL.innodb_file_format; +SET GLOBAL innodb_file_format = barracuda; + +# set the variables +let $MYSQLD_DATADIR = `SELECT @@datadir`; + +--echo # ########################################################### +--echo # Check with Import/Export tablespace with Default_row_format + +# Set row_format=Compact +SET GLOBAL innodb_default_row_format=Compact; + +# Check row_format=Compact +SELECT @@innodb_default_row_format; + +# Check file_per_table=1 +SELECT @@innodb_file_per_table; + +CREATE TABLE tab(a INT) ENGINE=InnoDB; +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 'tab'; + +INSERT INTO tab VALUES(1); +INSERT INTO tab VALUES(2); + +# Check the rows +SELECT * FROM tab; + +FLUSH TABLE tab FOR EXPORT; + +# Take the backup of the ibd and cfg files +--copy_file $MYSQLD_DATADIR/test/tab.cfg $MYSQLD_DATADIR/tab.cfg +--copy_file $MYSQLD_DATADIR/test/tab.ibd $MYSQLD_DATADIR/tab.ibd + +UNLOCK TABLES; + +# Cleanup +DROP TABLE tab; + +# Set the default_row_format=Dynamic +SET GLOBAL innodb_default_row_format=Dynamic; + +CREATE TABLE tab(a INT) ENGINE=InnoDB; + +# Remove the *.ibd file +ALTER TABLE tab DISCARD TABLESPACE; + +# Move the *.ibd,*.cfg file into orginal location +--move_file $MYSQLD_DATADIR/tab.cfg $MYSQLD_DATADIR/test/tab.cfg +--move_file $MYSQLD_DATADIR/tab.ibd $MYSQLD_DATADIR/test/tab.ibd + +--error ER_TABLE_SCHEMA_MISMATCH +ALTER TABLE tab IMPORT TABLESPACE; + +# Take the backup of the ibd and cfg files +--copy_file $MYSQLD_DATADIR/test/tab.cfg $MYSQLD_DATADIR/tab.cfg +--copy_file $MYSQLD_DATADIR/test/tab.ibd $MYSQLD_DATADIR/tab.ibd + +# Cleanup +DROP TABLE tab; + +# Remove orphan files +--remove_file $MYSQLD_DATADIR/test/tab.cfg +--remove_file $MYSQLD_DATADIR/test/tab.ibd + +# Set the default_row_format=Compact +SET GLOBAL innodb_default_row_format=Compact; + +# Check row_format=Compact +SELECT @@innodb_default_row_format; + +CREATE TABLE tab(a INT) ENGINE=InnoDB; +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 'tab'; + +# Remove the *.ibd file +ALTER TABLE tab DISCARD TABLESPACE; + +# Move the *ibd,*.cfg file into orginal location +--move_file $MYSQLD_DATADIR/tab.cfg $MYSQLD_DATADIR/test/tab.cfg +--move_file $MYSQLD_DATADIR/tab.ibd $MYSQLD_DATADIR/test/tab.ibd + +# Check import is successful (because same row_format) +ALTER TABLE tab IMPORT TABLESPACE; + +# Check the rows +SELECT * FROM tab; + +# Cleanup +DROP TABLE tab; + +--echo # ########################################################### +# Check when Index Column size (3070 bytes) is too long, Change row_format +# Check when Index Column size (767 bytes), Change row_format +# Dynamic to Compact to Dynamic + +# Set the default_row_format=Dynamic +SET GLOBAL innodb_default_row_format=Dynamic; +SET GLOBAL innodb_large_prefix=ON; + +SELECT @@innodb_default_row_format; + +CREATE TABLE tab(a INT PRIMARY KEY, b VARCHAR(5000), KEY idx1(b(3070))) ENGINE= InnoDB; +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 'tab'; + +INSERT INTO tab(a,b) VALUES(1,'Check with max column size'); + +# Check by SELECT, no errors +SELECT * FROM tab; + +# Change row_format to Compact +SET GLOBAL innodb_default_row_format=COMPACT; + +# Check error ERROR 1709 (HY000): Index column size too large +-- error ER_INDEX_COLUMN_TOO_LONG +ALTER TABLE tab ROW_FORMAT=COMPACT; + +# Cleanup +DROP TABLE tab; + +# Change the default_row_format to default +SET GLOBAL innodb_default_row_format=Default; +SELECT @@innodb_default_row_format; +SET GLOBAL innodb_default_row_format=Dynamic; + +# Change row_format to Dynamic +SELECT @@innodb_default_row_format; + +CREATE TABLE tab(a INT PRIMARY KEY, b VARCHAR(5000), KEY idx1(b(767))) ENGINE= InnoDB; +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 'tab'; + +INSERT INTO tab(a,b) VALUES(1,'Check with max column size'); + +# Check by SELECT, no errors +SELECT * FROM tab; + +# Check no errors because Compact allows 767 bytes +ALTER TABLE tab ROW_FORMAT=COMPACT; +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 'tab'; + +# Check by SELECT, no errors +SELECT * FROM tab; + +# Check no errors +ALTER TABLE tab ROW_FORMAT=COMPRESSED; + +# Check by SELECT, no errors +SELECT * FROM tab; + +# Check no errors +ALTER TABLE tab ROW_FORMAT=Dynamic; +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 'tab'; + +# Cleanup +DROP TABLE tab; + +SET GLOBAL innodb_default_row_format = @row_format; +SET GLOBAL innodb_large_prefix = @large_prefix; +SET GLOBAL innodb_file_format = @file_format; diff --git a/mysql-test/suite/innodb/t/default_row_format_create.test b/mysql-test/suite/innodb/t/default_row_format_create.test new file mode 100644 index 00000000000..e0981abf7eb --- /dev/null +++ b/mysql-test/suite/innodb/t/default_row_format_create.test @@ -0,0 +1,28 @@ +--source include/have_innodb.inc +--source include/innodb_row_format.inc + +CREATE TABLE t1(c1 TEXT,c2 BLOB) ENGINE=InnoDB; +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; +DROP TABLE t1; + +CREATE TABLE t1(c1 TEXT,c2 BLOB) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; +DROP TABLE t1; + +CREATE TABLE t1(c1 TEXT,c2 BLOB) ENGINE=InnoDB ROW_FORMAT=COMPACT; +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; +DROP TABLE t1; + +CREATE TABLE t1(c1 TEXT,c2 BLOB) ENGINE=InnoDB ROW_FORMAT=REDUNDANT; +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; +DROP TABLE t1; + +CREATE TABLE t1(c1 TEXT,c2 BLOB) ENGINE=InnoDB +ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/file_format_defaults-master.opt b/mysql-test/suite/innodb/t/file_format_defaults-master.opt new file mode 100644 index 00000000000..202ecee6d48 --- /dev/null +++ b/mysql-test/suite/innodb/t/file_format_defaults-master.opt @@ -0,0 +1 @@ +--innodb_large_prefix=OFF --innodb_file_format=barracuda --innodb-file-format-check=off --innodb-file-format-max=antelope diff --git a/mysql-test/suite/innodb/t/file_format_defaults.test b/mysql-test/suite/innodb/t/file_format_defaults.test new file mode 100644 index 00000000000..c16ca068e46 --- /dev/null +++ b/mysql-test/suite/innodb/t/file_format_defaults.test @@ -0,0 +1,73 @@ +#*********************************************************** +# WL#7703: +# Check the max key length 3072 when innodb_large_prefix=ON +# Check boundary value of max key length 3073 +# When innodb_file_format=Antelope, compress DDLs fails +# Check file_format_max becomes Barracuda on DDL operation +# on compression table. +#*********************************************************** +-- source include/have_innodb.inc +-- source include/have_innodb_16k.inc + +# Check some default settings +SELECT @@innodb_strict_mode; + +SELECT @@innodb_file_per_table; + +SET @file_format = @@GLOBAL.innodb_file_format; + +SET GLOBAL innodb_large_prefix=ON; +SET SQL_MODE=strict_all_tables; + +CREATE TABLE tab0 (c1 VARCHAR(65530), KEY(c1(3073))) ENGINE=InnoDB ROW_FORMAT=COMPRESSED; +SHOW CREATE TABLE tab0; +DROP TABLE tab0; + +--error ER_TOO_BIG_ROWSIZE +CREATE TABLE tab0 (c1 VARCHAR(65530), KEY(c1(3073))) ENGINE=InnoDB KEY_BLOCK_SIZE=2; + +SET GLOBAL innodb_file_format=Antelope; + +# WL#8307 Make ROW_FORMAT=DYNAMIC the default +# will allow ROW_FORMAT=DYNAMIC even if innodb_file_format=Antelope. +CREATE TABLE tab0(c1 INT,c2 LONGBLOB ) ENGINE=InnoDB ROW_FORMAT=Dynamic; +DROP TABLE tab0; + +SET GLOBAL innodb_file_format=Default; + +SELECT @@innodb_file_format; + +SET GLOBAL innodb_strict_mode=OFF; + +# Check with default value +SET GLOBAL innodb_strict_mode=Default; + +SELECT @@innodb_strict_mode; + +SET GLOBAL innodb_large_prefix=OFF; + +SELECT @@innodb_large_prefix; + +SET GLOBAL innodb_large_prefix=Default; + +# Check with default value +SELECT @@innodb_large_prefix; + +SET GLOBAL innodb_file_format_max=Default; + +# Check with default value +SELECT @@innodb_file_format_max; + +CREATE TABLE tab1(c1 int ) ENGINE=InnoDB ROW_FORMAT=COMPRESSED; + +# Check file format changed to Barracuda, on DDL operation +SELECT @@innodb_file_format_max; + +SET GLOBAL innodb_file_format_max=Default; + +# Restore to the value that we explicitly used at startup. +SET GLOBAL innodb_large_prefix=off; + +SET GLOBAL innodb_file_format = @file_format; + +DROP TABLE tab1; diff --git a/mysql-test/suite/innodb_zip/r/innodb-create-options.result b/mysql-test/suite/innodb_zip/r/innodb-create-options.result index fe3d799229d..e961d0ca7d0 100644 --- a/mysql-test/suite/innodb_zip/r/innodb-create-options.result +++ b/mysql-test/suite/innodb_zip/r/innodb-create-options.result @@ -282,12 +282,12 @@ Warning 1478 InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_format > Antelop Error 1005 Can't create table `test`.`t1` (errno: 140 "Wrong create options") Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB CREATE TABLE t1 ( i INT ) ROW_FORMAT=DYNAMIC; -ERROR HY000: Can't create table `test`.`t1` (errno: 140 "Wrong create options") SHOW WARNINGS; Level Code Message -Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope. -Error 1005 Can't create table `test`.`t1` (errno: 140 "Wrong create options") -Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +TABLE_NAME ROW_FORMAT CREATE_OPTIONS +t1 Dynamic row_format=DYNAMIC +DROP TABLE t1; CREATE TABLE t1 ( i INT ) ROW_FORMAT=REDUNDANT; SHOW WARNINGS; Level Code Message @@ -318,13 +318,10 @@ Level Code Message Warning 1478 InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_format > Antelope. Error 1478 Table storage engine 'InnoDB' does not support the create option 'ROW_FORMAT' ALTER TABLE t1 ROW_FORMAT=DYNAMIC; -ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'ROW_FORMAT' SHOW WARNINGS; Level Code Message -Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope. -Error 1478 Table storage engine 'InnoDB' does not support the create option 'ROW_FORMAT' SET GLOBAL innodb_file_format=Barracuda; -DROP TABLE IF EXISTS t1; +DROP TABLE t1; CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; SET GLOBAL innodb_file_format=Antelope; ALTER TABLE t1 ADD COLUMN f1 INT; @@ -369,12 +366,12 @@ Warning 1478 InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_per_table. Error 1005 Can't create table `test`.`t1` (errno: 140 "Wrong create options") Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB CREATE TABLE t1 ( i INT ) ROW_FORMAT=DYNAMIC; -ERROR HY000: Can't create table `test`.`t1` (errno: 140 "Wrong create options") SHOW WARNINGS; Level Code Message -Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_per_table. -Error 1005 Can't create table `test`.`t1` (errno: 140 "Wrong create options") -Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +TABLE_NAME ROW_FORMAT CREATE_OPTIONS +t1 Dynamic row_format=DYNAMIC +DROP TABLE t1; CREATE TABLE t1 ( i INT ) ROW_FORMAT=REDUNDANT; SHOW WARNINGS; Level Code Message @@ -405,11 +402,11 @@ Level Code Message Warning 1478 InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_per_table. Error 1478 Table storage engine 'InnoDB' does not support the create option 'ROW_FORMAT' ALTER TABLE t1 ROW_FORMAT=DYNAMIC; -ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'ROW_FORMAT' SHOW WARNINGS; Level Code Message -Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_per_table. -Error 1478 Table storage engine 'InnoDB' does not support the create option 'ROW_FORMAT' +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +TABLE_NAME ROW_FORMAT CREATE_OPTIONS +t1 Dynamic row_format=DYNAMIC ALTER TABLE t1 ROW_FORMAT=COMPACT; SHOW WARNINGS; Level Code Message @@ -789,16 +786,11 @@ TABLE_NAME ROW_FORMAT CREATE_OPTIONS t1 Dynamic row_format=DYNAMIC SET GLOBAL innodb_file_format=Antelope; ALTER TABLE t1 ADD COLUMN f1 INT; -Warnings: -Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope. -Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT. SHOW WARNINGS; Level Code Message -Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope. -Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT. SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; TABLE_NAME ROW_FORMAT CREATE_OPTIONS -t1 Compact row_format=DYNAMIC +t1 Dynamic row_format=DYNAMIC SET GLOBAL innodb_file_format=Barracuda; ALTER TABLE t1 ADD COLUMN f2 INT; SHOW WARNINGS; diff --git a/mysql-test/suite/innodb_zip/r/innodb-zip.result b/mysql-test/suite/innodb_zip/r/innodb-zip.result index 584a8a5d647..2695df64187 100644 --- a/mysql-test/suite/innodb_zip/r/innodb-zip.result +++ b/mysql-test/suite/innodb_zip/r/innodb-zip.result @@ -22,9 +22,6 @@ Warning 1478 InnoDB: ignoring KEY_BLOCK_SIZE=4. Warning 1478 InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_per_table. Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT. create table t1(a int primary key) engine=innodb row_format=dynamic; -Warnings: -Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_per_table. -Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT. create table t2(a int primary key) engine=innodb row_format=redundant; create table t3(a int primary key) engine=innodb row_format=compact; create table t4(a int primary key) engine=innodb key_block_size=9; @@ -75,7 +72,7 @@ SELECT table_schema, table_name, row_format, data_length, index_length FROM info table_schema table_name row_format data_length index_length mysqltest_innodb_zip t0 Compact {valid} 0 mysqltest_innodb_zip t00 Compact {valid} 0 -mysqltest_innodb_zip t1 Compact {valid} 0 +mysqltest_innodb_zip t1 Dynamic {valid} 0 mysqltest_innodb_zip t10 Dynamic {valid} 0 mysqltest_innodb_zip t11 Compressed 1024 0 mysqltest_innodb_zip t12 Compressed 1024 0 @@ -295,19 +292,16 @@ Warning 1478 InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_per_table. Error 1005 Can't create table `mysqltest_innodb_zip`.`t6` (errno: 140 "Wrong create options") Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB create table t7 (id int primary key) engine = innodb row_format = dynamic; -ERROR HY000: Can't create table `mysqltest_innodb_zip`.`t7` (errno: 140 "Wrong create options") show warnings; Level Code Message -Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_per_table. -Error 1005 Can't create table `mysqltest_innodb_zip`.`t7` (errno: 140 "Wrong create options") -Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB create table t8 (id int primary key) engine = innodb row_format = compact; create table t9 (id int primary key) engine = innodb row_format = redundant; SELECT table_schema, table_name, row_format, data_length, index_length FROM information_schema.tables WHERE engine='innodb' AND table_schema != 'mysql'; table_schema table_name row_format data_length index_length +mysqltest_innodb_zip t7 Dynamic {valid} 0 mysqltest_innodb_zip t8 Compact {valid} 0 mysqltest_innodb_zip t9 Redundant {valid} 0 -drop table t8, t9; +drop table t7, t8, t9; set global innodb_file_per_table = on; set global innodb_file_format = `0`; create table t1 (id int primary key) engine = innodb key_block_size = 1; @@ -339,19 +333,16 @@ Warning 1478 InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_format > Antelop Error 1005 Can't create table `mysqltest_innodb_zip`.`t6` (errno: 140 "Wrong create options") Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB create table t7 (id int primary key) engine = innodb row_format = dynamic; -ERROR HY000: Can't create table `mysqltest_innodb_zip`.`t7` (errno: 140 "Wrong create options") show warnings; Level Code Message -Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope. -Error 1005 Can't create table `mysqltest_innodb_zip`.`t7` (errno: 140 "Wrong create options") -Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB create table t8 (id int primary key) engine = innodb row_format = compact; create table t9 (id int primary key) engine = innodb row_format = redundant; SELECT table_schema, table_name, row_format, data_length, index_length FROM information_schema.tables WHERE engine='innodb' AND table_schema != 'mysql'; table_schema table_name row_format data_length index_length +mysqltest_innodb_zip t7 Dynamic {valid} 0 mysqltest_innodb_zip t8 Compact {valid} 0 mysqltest_innodb_zip t9 Redundant {valid} 0 -drop table t8, t9; +drop table t7, t8, t9; set global innodb_file_per_table=1; set global innodb_file_format=Antelope; set global innodb_file_per_table=on; diff --git a/mysql-test/suite/innodb_zip/t/innodb-create-options.test b/mysql-test/suite/innodb_zip/t/innodb-create-options.test index 53d739feccb..282b588c841 100644 --- a/mysql-test/suite/innodb_zip/t/innodb-create-options.test +++ b/mysql-test/suite/innodb_zip/t/innodb-create-options.test @@ -244,10 +244,10 @@ CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPRESSED; --replace_regex / - .*[0-9]*[)]/)/ SHOW WARNINGS; --replace_regex / - .*[0-9]*[)]/)/ ---error ER_CANT_CREATE_TABLE CREATE TABLE t1 ( i INT ) ROW_FORMAT=DYNAMIC; ---replace_regex / - .*[0-9]*[)]/)/ SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +DROP TABLE t1; CREATE TABLE t1 ( i INT ) ROW_FORMAT=REDUNDANT; SHOW WARNINGS; SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; @@ -264,11 +264,10 @@ SHOW WARNINGS; --error ER_ILLEGAL_HA_CREATE_OPTION ALTER TABLE t1 ROW_FORMAT=COMPRESSED; SHOW WARNINGS; ---error ER_ILLEGAL_HA_CREATE_OPTION ALTER TABLE t1 ROW_FORMAT=DYNAMIC; SHOW WARNINGS; SET GLOBAL innodb_file_format=Barracuda; -DROP TABLE IF EXISTS t1; +DROP TABLE t1; CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; SET GLOBAL innodb_file_format=Antelope; ALTER TABLE t1 ADD COLUMN f1 INT; @@ -296,11 +295,10 @@ SHOW WARNINGS; CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPRESSED; --replace_regex / - .*[0-9]*[)]/)/ SHOW WARNINGS; ---replace_regex / - .*[0-9]*[)]/)/ ---error ER_CANT_CREATE_TABLE CREATE TABLE t1 ( i INT ) ROW_FORMAT=DYNAMIC; ---replace_regex / - .*[0-9]*[)]/)/ SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +DROP TABLE t1; CREATE TABLE t1 ( i INT ) ROW_FORMAT=REDUNDANT; SHOW WARNINGS; SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; @@ -317,9 +315,9 @@ SHOW WARNINGS; --error ER_ILLEGAL_HA_CREATE_OPTION ALTER TABLE t1 ROW_FORMAT=COMPRESSED; SHOW WARNINGS; ---error ER_ILLEGAL_HA_CREATE_OPTION ALTER TABLE t1 ROW_FORMAT=DYNAMIC; SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; ALTER TABLE t1 ROW_FORMAT=COMPACT; SHOW WARNINGS; SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; diff --git a/mysql-test/suite/innodb_zip/t/innodb-zip.test b/mysql-test/suite/innodb_zip/t/innodb-zip.test index e8ba98f14ce..e9bac78f99e 100644 --- a/mysql-test/suite/innodb_zip/t/innodb-zip.test +++ b/mysql-test/suite/innodb_zip/t/innodb-zip.test @@ -275,16 +275,14 @@ create table t6 (id int primary key) engine = innodb row_format = compressed; --replace_regex / - .*[0-9]*[)]/)/ show warnings; --replace_regex / - .*[0-9]*[)]/)/ ---error ER_CANT_CREATE_TABLE create table t7 (id int primary key) engine = innodb row_format = dynamic; ---replace_regex / - .*[0-9]*[)]/)/ show warnings; create table t8 (id int primary key) engine = innodb row_format = compact; create table t9 (id int primary key) engine = innodb row_format = redundant; --replace_result 16384 {valid} 8192 {valid} 4096 {valid} --eval $query_i_s -drop table t8, t9; +drop table t7, t8, t9; #test valid values with innodb_file_format unset set global innodb_file_per_table = on; @@ -312,17 +310,14 @@ show warnings; create table t6 (id int primary key) engine = innodb row_format = compressed; --replace_regex / - .*[0-9]*[)]/)/ show warnings; ---replace_regex / - .*[0-9]*[)]/)/ ---error ER_CANT_CREATE_TABLE create table t7 (id int primary key) engine = innodb row_format = dynamic; ---replace_regex / - .*[0-9]*[)]/)/ show warnings; create table t8 (id int primary key) engine = innodb row_format = compact; create table t9 (id int primary key) engine = innodb row_format = redundant; --replace_result 16384 {valid} 8192 {valid} 4096 {valid} --eval $query_i_s -drop table t8, t9; +drop table t7, t8, t9; eval set global innodb_file_per_table=$per_table; eval set global innodb_file_format=$format; diff --git a/mysql-test/suite/parts/r/longname.result b/mysql-test/suite/parts/r/longname.result index 6424ba28297..5a223cf65fc 100644 --- a/mysql-test/suite/parts/r/longname.result +++ b/mysql-test/suite/parts/r/longname.result @@ -12,15 +12,6 @@ SUBPARTITION BY HASH ( id2 ) SUBPARTITIONS 2 ( PARTITION test_jfg_partition_name_with_60_chars_1234567890123456789012 VALUES LESS THAN (1000) ENGINE = InnoDB, PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE = InnoDB); -Warnings: -Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope. -Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT. -Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope. -Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT. -Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope. -Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT. -Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope. -Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT. select database_name, table_name, length(table_name) from mysql.innodb_table_stats where database_name = 'mysqltest1'; database_name table_name length(table_name) CREATE TABLE mysqltest1.éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé ( diff --git a/mysql-test/suite/sys_vars/r/innodb_default_row_format_basic.result b/mysql-test/suite/sys_vars/r/innodb_default_row_format_basic.result new file mode 100644 index 00000000000..971b8b9d243 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_default_row_format_basic.result @@ -0,0 +1,48 @@ +SELECT @@global.innodb_default_row_format; +@@global.innodb_default_row_format +compact +SET GLOBAL innodb_default_row_format = 'redundant'; +SELECT @@global.innodb_default_row_format; +@@global.innodb_default_row_format +redundant +SET GLOBAL innodb_default_row_format = 'dynamic'; +SELECT @@global.innodb_default_row_format; +@@global.innodb_default_row_format +dynamic +SET GLOBAL innodb_default_row_format = 'compact'; +SELECT @@global.innodb_default_row_format; +@@global.innodb_default_row_format +compact +SET GLOBAL innodb_default_row_format = 'compressed'; +ERROR 42000: Variable 'innodb_default_row_format' can't be set to the value of 'compressed' +SELECT @@global.innodb_default_row_format; +@@global.innodb_default_row_format +compact +SET GLOBAL innodb_default_row_format = 'foobar'; +ERROR 42000: Variable 'innodb_default_row_format' can't be set to the value of 'foobar' +SELECT @@global.innodb_default_row_format; +@@global.innodb_default_row_format +compact +SET GLOBAL innodb_default_row_format = 0; +SELECT @@global.innodb_default_row_format; +@@global.innodb_default_row_format +redundant +SET GLOBAL innodb_default_row_format = 1; +SELECT @@global.innodb_default_row_format; +@@global.innodb_default_row_format +compact +SET GLOBAL innodb_default_row_format = 2; +SELECT @@global.innodb_default_row_format; +@@global.innodb_default_row_format +dynamic +SET GLOBAL innodb_default_row_format = 3; +ERROR 42000: Variable 'innodb_default_row_format' can't be set to the value of '3' +SELECT @@global.innodb_default_row_format; +@@global.innodb_default_row_format +dynamic +SET GLOBAL innodb_default_row_format = 123; +ERROR 42000: Variable 'innodb_default_row_format' can't be set to the value of '123' +SELECT @@global.innodb_default_row_format; +@@global.innodb_default_row_format +dynamic +SET GLOBAL innodb_default_row_format = default; diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb.result b/mysql-test/suite/sys_vars/r/sysvars_innodb.result index 161f740dbfb..fd33338cbc8 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb.result +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb.result @@ -635,6 +635,20 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED +VARIABLE_NAME INNODB_DEFAULT_ROW_FORMAT +SESSION_VALUE NULL +GLOBAL_VALUE compact +GLOBAL_VALUE_ORIGIN COMPILE-TIME +DEFAULT_VALUE compact +VARIABLE_SCOPE GLOBAL +VARIABLE_TYPE ENUM +VARIABLE_COMMENT The default ROW FORMAT for all innodb tables created without explicit ROW_FORMAT. Possible values are REDUNDANT, COMPACT, and DYNAMIC. The ROW_FORMAT value COMPRESSED is not allowed +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL +ENUM_VALUE_LIST redundant,compact,dynamic +READ_ONLY NO +COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME INNODB_DEFRAGMENT SESSION_VALUE NULL GLOBAL_VALUE OFF diff --git a/mysql-test/suite/sys_vars/t/innodb_default_row_format_basic.test b/mysql-test/suite/sys_vars/t/innodb_default_row_format_basic.test new file mode 100644 index 00000000000..f9aabf49ba4 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_default_row_format_basic.test @@ -0,0 +1,41 @@ +--source include/have_innodb.inc + +# Check the default value +SELECT @@global.innodb_default_row_format; + +SET GLOBAL innodb_default_row_format = 'redundant'; +SELECT @@global.innodb_default_row_format; + +SET GLOBAL innodb_default_row_format = 'dynamic'; +SELECT @@global.innodb_default_row_format; + +SET GLOBAL innodb_default_row_format = 'compact'; +SELECT @@global.innodb_default_row_format; + +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL innodb_default_row_format = 'compressed'; +SELECT @@global.innodb_default_row_format; + +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL innodb_default_row_format = 'foobar'; +SELECT @@global.innodb_default_row_format; + +SET GLOBAL innodb_default_row_format = 0; +SELECT @@global.innodb_default_row_format; + +SET GLOBAL innodb_default_row_format = 1; +SELECT @@global.innodb_default_row_format; + +SET GLOBAL innodb_default_row_format = 2; +SELECT @@global.innodb_default_row_format; + +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL innodb_default_row_format = 3; +SELECT @@global.innodb_default_row_format; + +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL innodb_default_row_format = 123; +SELECT @@global.innodb_default_row_format; + + +SET GLOBAL innodb_default_row_format = default; diff --git a/storage/innobase/dict/dict0crea.cc b/storage/innobase/dict/dict0crea.cc index a2f79a400e2..057e2684eb8 100644 --- a/storage/innobase/dict/dict0crea.cc +++ b/storage/innobase/dict/dict0crea.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2018, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -326,10 +327,8 @@ dict_build_table_def_step( mtr_commit(&mtr); } else { - /* Create in the system tablespace: disallow Barracuda - features by keeping only the first bit which says whether - the row format is redundant or compact */ - table->flags &= DICT_TF_COMPACT; + /* Create in the system tablespace */ + ut_ad(table->space == TRX_SYS_SPACE); } row = dict_create_sys_tables_tuple(table, node->heap); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index b66f74873a9..4f76c568f17 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2000, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2017, MariaDB Corporation. +Copyright (c) 2013, 2018, MariaDB Corporation. Copyright (c) 2008, 2009 Google Inc. Copyright (c) 2009, Percona Inc. Copyright (c) 2012, Facebook Inc. @@ -314,6 +314,23 @@ static TYPELIB innodb_lock_schedule_algorithm_typelib = { NULL }; +/** Possible values for system variable "innodb_default_row_format". */ +static const char* innodb_default_row_format_names[] = { + "redundant", + "compact", + "dynamic", + NullS +}; + +/** Used to define an enumerate type of the system variable +innodb_default_row_format. */ +static TYPELIB innodb_default_row_format_typelib = { + array_elements(innodb_default_row_format_names) - 1, + "innodb_default_row_format_typelib", + innodb_default_row_format_names, + NULL +}; + /* The following counter is used to convey information to InnoDB about server activity: in case of normal DML ops it is not sensible to call srv_active_wake_master_thread after each @@ -334,6 +351,35 @@ static const char* innobase_change_buffering_values[IBUF_USE_COUNT] = { "all" /* IBUF_USE_ALL */ }; + +/** Note we cannot use rec_format_enum because we do not allow +COMPRESSED row format for innodb_default_row_format option. */ +enum default_row_format_enum { + DEFAULT_ROW_FORMAT_REDUNDANT = 0, + DEFAULT_ROW_FORMAT_COMPACT = 1, + DEFAULT_ROW_FORMAT_DYNAMIC = 2 +}; + +/** Convert an InnoDB ROW_FORMAT value. +@param[in] row_format row_format from "innodb_default_row_format" +@return converted ROW_FORMAT */ +static rec_format_t get_row_format(ulong row_format) +{ + switch (row_format) { + case DEFAULT_ROW_FORMAT_REDUNDANT: + return REC_FORMAT_REDUNDANT; + case DEFAULT_ROW_FORMAT_COMPACT: + return REC_FORMAT_COMPACT; + case DEFAULT_ROW_FORMAT_DYNAMIC: + return REC_FORMAT_DYNAMIC; + default: + ut_ad(0); + return REC_FORMAT_COMPACT; + } +} + +static ulong innodb_default_row_format; + /* Call back function array defined by MySQL and used to retrieve FTS results. */ const struct _ft_vft ft_vft_result = {NULL, @@ -11326,8 +11372,6 @@ create_options_are_invalid( CHECK_ERROR_ROW_TYPE_NEEDS_GT_ANTELOPE; break; case ROW_TYPE_DYNAMIC: - CHECK_ERROR_ROW_TYPE_NEEDS_FILE_PER_TABLE(use_tablespace); - CHECK_ERROR_ROW_TYPE_NEEDS_GT_ANTELOPE; /* ROW_FORMAT=DYNAMIC also shuns KEY_BLOCK_SIZE */ /* fall through */ case ROW_TYPE_COMPACT: @@ -11561,7 +11605,8 @@ innobase_table_flags( bool zip_allowed = true; ulint zip_ssize = 0; enum row_type row_format; - rec_format_t innodb_row_format = REC_FORMAT_COMPACT; + rec_format_t innodb_row_format = + get_row_format(innodb_default_row_format); bool use_data_dir; ha_table_option_struct *options= form->s->option_struct; @@ -11708,37 +11753,29 @@ index_bad: /* Validate the row format. Correct it if necessary */ switch (row_format) { + case ROW_TYPE_DEFAULT: + break; case ROW_TYPE_REDUNDANT: innodb_row_format = REC_FORMAT_REDUNDANT; break; - case ROW_TYPE_COMPRESSED: case ROW_TYPE_DYNAMIC: + innodb_row_format = REC_FORMAT_DYNAMIC; + break; + case ROW_TYPE_COMPRESSED: if (!use_tablespace) { push_warning_printf( thd, Sql_condition::WARN_LEVEL_WARN, ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: ROW_FORMAT=%s requires" - " innodb_file_per_table.", - get_row_format_name(row_format)); + "InnoDB: ROW_FORMAT=COMPRESSED requires" + " innodb_file_per_table."); } else if (file_format_allowed == UNIV_FORMAT_A) { push_warning_printf( thd, Sql_condition::WARN_LEVEL_WARN, ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: ROW_FORMAT=%s requires" - " innodb_file_format > Antelope.", - get_row_format_name(row_format)); + "InnoDB: ROW_FORMAT=COMPRESSED requires" + " innodb_file_format > Antelope."); } else { - switch(row_format) { - case ROW_TYPE_COMPRESSED: - innodb_row_format = REC_FORMAT_COMPRESSED; - break; - case ROW_TYPE_DYNAMIC: - innodb_row_format = REC_FORMAT_DYNAMIC; - break; - default: - /* Not possible, avoid compiler warning */ - break; - } + innodb_row_format = REC_FORMAT_COMPRESSED; break; /* Correct row_format */ } zip_allowed = FALSE; @@ -11752,10 +11789,8 @@ index_bad: ER_ILLEGAL_HA_CREATE_OPTION, "InnoDB: assuming ROW_FORMAT=COMPACT."); /* fall through */ - case ROW_TYPE_DEFAULT: - /* If we fell through, set row format to Compact. */ - row_format = ROW_TYPE_COMPACT; case ROW_TYPE_COMPACT: + innodb_row_format = REC_FORMAT_COMPACT; break; } @@ -19805,6 +19840,14 @@ static MYSQL_SYSVAR_BOOL(cmp_per_index_enabled, srv_cmp_per_index_enabled, "may have negative impact on performance (off by default)", NULL, innodb_cmp_per_index_update, FALSE); +static MYSQL_SYSVAR_ENUM(default_row_format, innodb_default_row_format, + PLUGIN_VAR_RQCMDARG, + "The default ROW FORMAT for all innodb tables created without explicit" + " ROW_FORMAT. Possible values are REDUNDANT, COMPACT, and DYNAMIC." + " The ROW_FORMAT value COMPRESSED is not allowed", + NULL, NULL, DEFAULT_ROW_FORMAT_COMPACT, + &innodb_default_row_format_typelib); + #ifdef UNIV_DEBUG static MYSQL_SYSVAR_UINT(trx_rseg_n_slots_debug, trx_rseg_n_slots_debug, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_NOCMDOPT, @@ -20174,6 +20217,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= { MYSQL_SYSVAR(sync_array_size), MYSQL_SYSVAR(compression_failure_threshold_pct), MYSQL_SYSVAR(compression_pad_pct_max), + MYSQL_SYSVAR(default_row_format), MYSQL_SYSVAR(simulate_comp_failures), #ifdef UNIV_DEBUG MYSQL_SYSVAR(trx_rseg_n_slots_debug), diff --git a/storage/xtradb/dict/dict0crea.cc b/storage/xtradb/dict/dict0crea.cc index 6d5b12474eb..2fe9f8af4ec 100644 --- a/storage/xtradb/dict/dict0crea.cc +++ b/storage/xtradb/dict/dict0crea.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, MariaDB Corporation. +Copyright (c) 2017, 2018, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -327,10 +327,8 @@ dict_build_table_def_step( mtr_commit(&mtr); } else { - /* Create in the system tablespace: disallow Barracuda - features by keeping only the first bit which says whether - the row format is redundant or compact */ - table->flags &= DICT_TF_COMPACT; + /* Create in the system tablespace */ + ut_ad(table->space == TRX_SYS_SPACE); } row = dict_create_sys_tables_tuple(table, node->heap); diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 65ac41c26de..9749bcecfe9 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2000, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2017, MariaDB Corporation. +Copyright (c) 2013, 2018, MariaDB Corporation. Copyright (c) 2008, 2009 Google Inc. Copyright (c) 2009, Percona Inc. Copyright (c) 2012, Facebook Inc. @@ -367,6 +367,23 @@ static TYPELIB innodb_lock_schedule_algorithm_typelib = { }; +/** Possible values for system variable "innodb_default_row_format". */ +static const char* innodb_default_row_format_names[] = { + "redundant", + "compact", + "dynamic", + NullS +}; + +/** Used to define an enumerate type of the system variable +innodb_default_row_format. */ +static TYPELIB innodb_default_row_format_typelib = { + array_elements(innodb_default_row_format_names) - 1, + "innodb_default_row_format_typelib", + innodb_default_row_format_names, + NULL +}; + /* The following counter is used to convey information to InnoDB about server activity: in case of normal DML ops it is not sensible to call srv_active_wake_master_thread after each @@ -387,6 +404,35 @@ static const char* innobase_change_buffering_values[IBUF_USE_COUNT] = { "all" /* IBUF_USE_ALL */ }; + +/** Note we cannot use rec_format_enum because we do not allow +COMPRESSED row format for innodb_default_row_format option. */ +enum default_row_format_enum { + DEFAULT_ROW_FORMAT_REDUNDANT = 0, + DEFAULT_ROW_FORMAT_COMPACT = 1, + DEFAULT_ROW_FORMAT_DYNAMIC = 2 +}; + +/** Convert an InnoDB ROW_FORMAT value. +@param[in] row_format row_format from "innodb_default_row_format" +@return converted ROW_FORMAT */ +static rec_format_t get_row_format(ulong row_format) +{ + switch (row_format) { + case DEFAULT_ROW_FORMAT_REDUNDANT: + return REC_FORMAT_REDUNDANT; + case DEFAULT_ROW_FORMAT_COMPACT: + return REC_FORMAT_COMPACT; + case DEFAULT_ROW_FORMAT_DYNAMIC: + return REC_FORMAT_DYNAMIC; + default: + ut_ad(0); + return REC_FORMAT_COMPACT; + } +} + +static ulong innodb_default_row_format; + /* Call back function array defined by MySQL and used to retrieve FTS results. */ const struct _ft_vft ft_vft_result = {NULL, @@ -11896,8 +11942,6 @@ create_options_are_invalid( CHECK_ERROR_ROW_TYPE_NEEDS_GT_ANTELOPE; break; case ROW_TYPE_DYNAMIC: - CHECK_ERROR_ROW_TYPE_NEEDS_FILE_PER_TABLE(use_tablespace); - CHECK_ERROR_ROW_TYPE_NEEDS_GT_ANTELOPE; /* ROW_FORMAT=DYNAMIC also shuns KEY_BLOCK_SIZE */ /* fall through */ case ROW_TYPE_COMPACT: @@ -12132,7 +12176,8 @@ innobase_table_flags( bool zip_allowed = true; ulint zip_ssize = 0; enum row_type row_format; - rec_format_t innodb_row_format = REC_FORMAT_COMPACT; + rec_format_t innodb_row_format = + get_row_format(innodb_default_row_format); bool use_data_dir; ha_table_option_struct *options= form->s->option_struct; @@ -12274,38 +12319,29 @@ index_bad: /* Validate the row format. Correct it if necessary */ switch (row_format) { + case ROW_TYPE_DEFAULT: + break; case ROW_TYPE_REDUNDANT: innodb_row_format = REC_FORMAT_REDUNDANT; break; - - case ROW_TYPE_COMPRESSED: case ROW_TYPE_DYNAMIC: + innodb_row_format = REC_FORMAT_DYNAMIC; + break; + case ROW_TYPE_COMPRESSED: if (!use_tablespace) { push_warning_printf( thd, Sql_condition::WARN_LEVEL_WARN, ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: ROW_FORMAT=%s requires" - " innodb_file_per_table.", - get_row_format_name(row_format)); + "InnoDB: ROW_FORMAT=COMPRESSED requires" + " innodb_file_per_table."); } else if (file_format_allowed == UNIV_FORMAT_A) { push_warning_printf( thd, Sql_condition::WARN_LEVEL_WARN, ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: ROW_FORMAT=%s requires" - " innodb_file_format > Antelope.", - get_row_format_name(row_format)); + "InnoDB: ROW_FORMAT=COMPRESSED requires" + " innodb_file_format > Antelope."); } else { - switch(row_format) { - case ROW_TYPE_COMPRESSED: - innodb_row_format = REC_FORMAT_COMPRESSED; - break; - case ROW_TYPE_DYNAMIC: - innodb_row_format = REC_FORMAT_DYNAMIC; - break; - default: - /* Not possible, avoid compiler warning */ - break; - } + innodb_row_format = REC_FORMAT_COMPRESSED; break; /* Correct row_format */ } zip_allowed = FALSE; @@ -12320,11 +12356,8 @@ index_bad: ER_ILLEGAL_HA_CREATE_OPTION, "InnoDB: assuming ROW_FORMAT=COMPACT."); /* fall through */ - case ROW_TYPE_DEFAULT: - /* If we fell through, set row format to Compact. */ - row_format = ROW_TYPE_COMPACT; - /* fall through */ case ROW_TYPE_COMPACT: + innodb_row_format = REC_FORMAT_COMPACT; break; } @@ -21115,6 +21148,14 @@ static MYSQL_SYSVAR_BOOL(cmp_per_index_enabled, srv_cmp_per_index_enabled, "may have negative impact on performance (off by default)", NULL, innodb_cmp_per_index_update, FALSE); +static MYSQL_SYSVAR_ENUM(default_row_format, innodb_default_row_format, + PLUGIN_VAR_RQCMDARG, + "The default ROW FORMAT for all innodb tables created without explicit" + " ROW_FORMAT. Possible values are REDUNDANT, COMPACT, and DYNAMIC." + " The ROW_FORMAT value COMPRESSED is not allowed", + NULL, NULL, DEFAULT_ROW_FORMAT_COMPACT, + &innodb_default_row_format_typelib); + #ifdef UNIV_DEBUG static MYSQL_SYSVAR_UINT(trx_rseg_n_slots_debug, trx_rseg_n_slots_debug, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_NOCMDOPT, @@ -21558,6 +21599,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= { MYSQL_SYSVAR(sync_array_size), MYSQL_SYSVAR(compression_failure_threshold_pct), MYSQL_SYSVAR(compression_pad_pct_max), + MYSQL_SYSVAR(default_row_format), #ifdef UNIV_DEBUG MYSQL_SYSVAR(trx_rseg_n_slots_debug), MYSQL_SYSVAR(limit_optimistic_insert_debug), From aec4734f615cb13c3687b205782020259ea5a743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 8 Mar 2018 12:25:01 +0200 Subject: [PATCH 08/16] MDEV-13935: INSERT INTO stuck at state "Unlocking tables" There were some differences on MariaDB compared with MySQL. Fix these differences. --- storage/innobase/include/trx0trx.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index 674eee572ed..412a35a14f4 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -1489,8 +1489,12 @@ private: } /* Avoid excessive mutex acquire/release */ - if (trx->in_depth++) { - /* The transaction is already inside InnoDB. */ + ++trx->in_depth; + + /* If trx->in_depth is greater than 1 then + transaction is already in InnoDB. */ + if (trx->in_depth > 1) { + return; } @@ -1518,7 +1522,10 @@ private: ut_ad(trx->in_depth > 0); - if (--trx->in_depth) { + --trx->in_depth; + + if (trx->in_depth > 0) { + return; } From 4a5c237c76232cdd054bca5cb4affc2b9c22b688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 9 Mar 2018 22:26:27 +0200 Subject: [PATCH 09/16] MDEV-14648 Restore fix for MySQL BUG#39053 - UNINSTALL PLUGIN does not allow the storage engine to cleanup open connections ha_close_connection(): Do invoke the method also for plugins for which UNINSTALL PLUGIN was deferred due to open connections. --- sql/handler.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index 07dc0cf04a9..631a9abbb54 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. - Copyright (c) 2009, 2016, MariaDB + Copyright (c) 2009, 2018, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -786,7 +786,9 @@ static my_bool closecon_handlerton(THD *thd, plugin_ref plugin, */ void ha_close_connection(THD* thd) { - plugin_foreach(thd, closecon_handlerton, MYSQL_STORAGE_ENGINE_PLUGIN, 0); + plugin_foreach_with_mask(thd, closecon_handlerton, + MYSQL_STORAGE_ENGINE_PLUGIN, + PLUGIN_IS_DELETED|PLUGIN_IS_READY, 0); } static my_bool kill_handlerton(THD *thd, plugin_ref plugin, From 1e4cb8403c297a9ca77ccc0af18fe21db1537976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 9 Mar 2018 13:25:28 +0200 Subject: [PATCH 10/16] buf_page_io_complete(): Minor code cleanup --- storage/innobase/buf/buf0buf.cc | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index d82e1413677..b15e8d431bc 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -6093,8 +6093,9 @@ database_corrupted: } } + BPageMutex* block_mutex = buf_page_get_mutex(bpage); buf_pool_mutex_enter(buf_pool); - mutex_enter(buf_page_get_mutex(bpage)); + mutex_enter(block_mutex); #ifdef UNIV_IBUF_COUNT_DEBUG if (io_type == BUF_IO_WRITE || uncompressed) { @@ -6112,8 +6113,7 @@ database_corrupted: buf_page_set_io_fix(bpage, BUF_IO_NONE); buf_page_monitor(bpage, io_type); - switch (io_type) { - case BUF_IO_READ: + if (io_type == BUF_IO_READ) { /* NOTE that the call to ibuf may have moved the ownership of the x-latch to this OS thread: do not let this confuse you in debugging! */ @@ -6127,11 +6127,8 @@ database_corrupted: BUF_IO_READ); } - mutex_exit(buf_page_get_mutex(bpage)); - - break; - - case BUF_IO_WRITE: + mutex_exit(block_mutex); + } else { /* Write means a flush operation: call the completion routine in the flush system */ @@ -6154,18 +6151,11 @@ database_corrupted: evict = true; } + mutex_exit(block_mutex); + if (evict) { - mutex_exit(buf_page_get_mutex(bpage)); buf_LRU_free_page(bpage, true); - } else { - mutex_exit(buf_page_get_mutex(bpage)); } - - - break; - - default: - ut_error; } DBUG_PRINT("ib_buf", ("%s page %u:%u", From 4fa18d52b58e0b5b2cc268cdfb273935bd7de76b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 9 Mar 2018 13:40:46 +0200 Subject: [PATCH 11/16] MDEV-15524 Do not write garbage for temporary tables fsp_init_file_page_low(): Always initialize the page. --- storage/innobase/fsp/fsp0fsp.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc index dd0148a3275..c8e71381491 100644 --- a/storage/innobase/fsp/fsp0fsp.cc +++ b/storage/innobase/fsp/fsp0fsp.cc @@ -600,17 +600,14 @@ fsp_init_file_page_low( buf_block_t* block) /*!< in: pointer to a page */ { page_t* page = buf_block_get_frame(block); - page_zip_des_t* page_zip= buf_block_get_page_zip(block); - if (!fsp_is_system_temporary(block->page.id.space())) { - memset(page, 0, UNIV_PAGE_SIZE); - } + memset(page, 0, UNIV_PAGE_SIZE); mach_write_to_4(page + FIL_PAGE_OFFSET, block->page.id.page_no()); mach_write_to_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, block->page.id.space()); - if (page_zip) { + if (page_zip_des_t* page_zip= buf_block_get_page_zip(block)) { memset(page_zip->data, 0, page_zip_get_size(page_zip)); memcpy(page_zip->data + FIL_PAGE_OFFSET, page + FIL_PAGE_OFFSET, 4); From 54765aaa4db8dacb5cca81d4628335c570e7798a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 9 Mar 2018 13:43:32 +0200 Subject: [PATCH 12/16] MDEV-15524 Do not disable page checksums for temporary tables buf_flush_init_for_writing(): Remove the parameter skip_checksum. --- extra/mariabackup/xtrabackup.cc | 4 +- storage/innobase/buf/buf0flu.cc | 195 +++++++++++++---------------- storage/innobase/include/buf0flu.h | 8 +- 3 files changed, 94 insertions(+), 113 deletions(-) diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 817412c8975..acc66238838 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -4044,7 +4044,7 @@ xb_space_create_file( const page_size_t page_size(flags); if (!page_size.is_compressed()) { - buf_flush_init_for_writing(NULL, page, NULL, 0, false); + buf_flush_init_for_writing(NULL, page, NULL, 0); ret = os_file_write(IORequestWrite, path, *file, page, 0, UNIV_PAGE_SIZE); @@ -4061,7 +4061,7 @@ xb_space_create_file( page_zip.m_end = page_zip.m_nonempty = page_zip.n_blobs = 0; - buf_flush_init_for_writing(NULL, page, &page_zip, 0, false); + buf_flush_init_for_writing(NULL, page, &page_zip, 0); ret = os_file_write(IORequestWrite, path, *file, page_zip.data, 0, zip_size); diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index e938c27cfec..76f1dd22aae 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -832,18 +832,14 @@ buf_flush_update_zip_checksum( @param[in] block buffer block; NULL if bypassing the buffer pool @param[in,out] page page frame @param[in,out] page_zip_ compressed page, or NULL if uncompressed -@param[in] newest_lsn newest modification LSN to the page -@param[in] skip_checksum whether to disable the page checksum */ +@param[in] newest_lsn newest modification LSN to the page */ void buf_flush_init_for_writing( const buf_block_t* block, byte* page, void* page_zip_, - lsn_t newest_lsn, - bool skip_checksum) + lsn_t newest_lsn) { - ib_uint32_t checksum = BUF_NO_CHECKSUM_MAGIC; - ut_ad(block == NULL || block->frame == page); ut_ad(block == NULL || page_zip_ == NULL || &block->page.zip == page_zip_); @@ -895,111 +891,97 @@ buf_flush_init_for_writing( mach_write_to_8(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM, newest_lsn); - if (skip_checksum) { - ut_ad(block == NULL - || block->page.id.space() == SRV_TMP_SPACE_ID); - ut_ad(page_get_space_id(page) == SRV_TMP_SPACE_ID); - mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, checksum); - } else { - if (block != NULL && UNIV_PAGE_SIZE == 16384) { - /* The page type could be garbage in old files - created before MySQL 5.5. Such files always - had a page size of 16 kilobytes. */ - ulint page_type = fil_page_get_type(page); - ulint reset_type = page_type; + if (block && srv_page_size == 16384) { + /* The page type could be garbage in old files + created before MySQL 5.5. Such files always + had a page size of 16 kilobytes. */ + ulint page_type = fil_page_get_type(page); + ulint reset_type = page_type; - switch (block->page.id.page_no() % 16384) { - case 0: - reset_type = block->page.id.page_no() == 0 - ? FIL_PAGE_TYPE_FSP_HDR - : FIL_PAGE_TYPE_XDES; + switch (block->page.id.page_no() % 16384) { + case 0: + reset_type = block->page.id.page_no() == 0 + ? FIL_PAGE_TYPE_FSP_HDR + : FIL_PAGE_TYPE_XDES; + break; + case 1: + reset_type = FIL_PAGE_IBUF_BITMAP; + break; + case FSP_TRX_SYS_PAGE_NO: + if (block->page.id.page_no() + == TRX_SYS_PAGE_NO + && block->page.id.space() + == TRX_SYS_SPACE) { + reset_type = FIL_PAGE_TYPE_TRX_SYS; break; - case 1: - reset_type = FIL_PAGE_IBUF_BITMAP; - break; - case FSP_TRX_SYS_PAGE_NO: - if (block->page.id.page_no() - == TRX_SYS_PAGE_NO - && block->page.id.space() - == TRX_SYS_SPACE) { - reset_type = FIL_PAGE_TYPE_TRX_SYS; - break; - } - /* fall through */ - default: - switch (page_type) { - case FIL_PAGE_INDEX: - case FIL_PAGE_RTREE: - case FIL_PAGE_UNDO_LOG: - case FIL_PAGE_INODE: - case FIL_PAGE_IBUF_FREE_LIST: - case FIL_PAGE_TYPE_ALLOCATED: - case FIL_PAGE_TYPE_SYS: - case FIL_PAGE_TYPE_TRX_SYS: - case FIL_PAGE_TYPE_BLOB: - case FIL_PAGE_TYPE_ZBLOB: - case FIL_PAGE_TYPE_ZBLOB2: - break; - case FIL_PAGE_TYPE_FSP_HDR: - case FIL_PAGE_TYPE_XDES: - case FIL_PAGE_IBUF_BITMAP: - /* These pages should have - predetermined page numbers - (see above). */ - default: - reset_type = FIL_PAGE_TYPE_UNKNOWN; - break; - } } - - if (UNIV_UNLIKELY(page_type != reset_type)) { - ib::info() - << "Resetting invalid page " - << block->page.id << " type " - << page_type << " to " - << reset_type << " when flushing."; - fil_page_set_type(page, reset_type); + /* fall through */ + default: + switch (page_type) { + case FIL_PAGE_INDEX: + case FIL_PAGE_RTREE: + case FIL_PAGE_UNDO_LOG: + case FIL_PAGE_INODE: + case FIL_PAGE_IBUF_FREE_LIST: + case FIL_PAGE_TYPE_ALLOCATED: + case FIL_PAGE_TYPE_SYS: + case FIL_PAGE_TYPE_TRX_SYS: + case FIL_PAGE_TYPE_BLOB: + case FIL_PAGE_TYPE_ZBLOB: + case FIL_PAGE_TYPE_ZBLOB2: + break; + case FIL_PAGE_TYPE_FSP_HDR: + case FIL_PAGE_TYPE_XDES: + case FIL_PAGE_IBUF_BITMAP: + /* These pages should have + predetermined page numbers + (see above). */ + default: + reset_type = FIL_PAGE_TYPE_UNKNOWN; + break; } } - switch ((srv_checksum_algorithm_t) srv_checksum_algorithm) { - case SRV_CHECKSUM_ALGORITHM_CRC32: - case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: - checksum = buf_calc_page_crc32(page); - mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, - checksum); - break; - case SRV_CHECKSUM_ALGORITHM_INNODB: - case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: - checksum = (ib_uint32_t) buf_calc_page_new_checksum( - page); - mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, - checksum); - checksum = (ib_uint32_t) buf_calc_page_old_checksum( - page); - break; - case SRV_CHECKSUM_ALGORITHM_NONE: - case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: - mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, - checksum); - break; - /* no default so the compiler will emit a warning if - new enum is added and not handled here */ + if (UNIV_UNLIKELY(page_type != reset_type)) { + ib::info() + << "Resetting invalid page " + << block->page.id << " type " + << page_type << " to " + << reset_type << " when flushing."; + fil_page_set_type(page, reset_type); } } - /* With the InnoDB checksum, we overwrite the first 4 bytes of - the end lsn field to store the old formula checksum. Since it - depends also on the field FIL_PAGE_SPACE_OR_CHKSUM, it has to - be calculated after storing the new formula checksum. + uint32_t checksum; - In other cases we write the same value to both fields. - If CRC32 is used then it is faster to use that checksum - (calculated above) instead of calculating another one. - We can afford to store something other than - buf_calc_page_old_checksum() or BUF_NO_CHECKSUM_MAGIC in - this field because the file will not be readable by old - versions of MySQL/InnoDB anyway (older than MySQL 5.6.3) */ + switch (srv_checksum_algorithm_t(srv_checksum_algorithm)) { + case SRV_CHECKSUM_ALGORITHM_INNODB: + case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: + checksum = buf_calc_page_new_checksum(page); + mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, + checksum); + /* With the InnoDB checksum, we overwrite the first 4 bytes of + the end lsn field to store the old formula checksum. Since it + depends also on the field FIL_PAGE_SPACE_OR_CHKSUM, it has to + be calculated after storing the new formula checksum. */ + checksum = buf_calc_page_old_checksum(page); + break; + case SRV_CHECKSUM_ALGORITHM_CRC32: + case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: + /* In other cases we write the same checksum to both fields. */ + checksum = buf_calc_page_crc32(page); + mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, + checksum); + break; + case SRV_CHECKSUM_ALGORITHM_NONE: + case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: + checksum = BUF_NO_CHECKSUM_MAGIC; + mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, + checksum); + break; + /* no default so the compiler will emit a warning if + new enum is added and not handled here */ + } mach_write_to_4(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM, checksum); @@ -1025,8 +1007,8 @@ buf_flush_write_block_low( ut_ad(space->purpose == FIL_TYPE_TEMPORARY || space->purpose == FIL_TYPE_IMPORT || space->purpose == FIL_TYPE_TABLESPACE); - const bool is_temp = space->purpose == FIL_TYPE_TEMPORARY; - ut_ad(is_temp == fsp_is_system_temporary(space->id)); + ut_ad((space->purpose == FIL_TYPE_TEMPORARY) + == fsp_is_system_temporary(space->id)); page_t* frame = NULL; #ifdef UNIV_DEBUG buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); @@ -1088,7 +1070,7 @@ buf_flush_write_block_low( reinterpret_cast(bpage), reinterpret_cast(bpage)->frame, bpage->zip.data ? &bpage->zip : NULL, - bpage->newest_modification, is_temp); + bpage->newest_modification); break; } @@ -1098,7 +1080,8 @@ buf_flush_write_block_low( Given the nature and load of temporary tablespace doublewrite buffer adds an overhead during flushing. */ - if (is_temp || space->atomic_write_supported + if (space->purpose == FIL_TYPE_TEMPORARY + || space->atomic_write_supported || !srv_use_doublewrite_buf || buf_dblwr == NULL) { @@ -1126,7 +1109,7 @@ buf_flush_write_block_low( are working on. */ if (sync) { ut_ad(flush_type == BUF_FLUSH_SINGLE_PAGE); - if (!is_temp) { + if (space->purpose != FIL_TYPE_TEMPORARY) { fil_flush(space); } diff --git a/storage/innobase/include/buf0flu.h b/storage/innobase/include/buf0flu.h index d77a7072cf6..ccf1d991b09 100644 --- a/storage/innobase/include/buf0flu.h +++ b/storage/innobase/include/buf0flu.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2014, 2017, MariaDB Corporation. +Copyright (c) 2014, 2018, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -80,15 +80,13 @@ buf_flush_write_complete( @param[in] block buffer block; NULL if bypassing the buffer pool @param[in,out] page page frame @param[in,out] page_zip_ compressed page, or NULL if uncompressed -@param[in] newest_lsn newest modification LSN to the page -@param[in] skip_checksum whether to disable the page checksum */ +@param[in] newest_lsn newest modification LSN to the page */ void buf_flush_init_for_writing( const buf_block_t* block, byte* page, void* page_zip_, - lsn_t newest_lsn, - bool skip_checksum = false); + lsn_t newest_lsn); # if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG /********************************************************************//** From 112df06996dd88ac1d858c4c0c321d4c6e7bbf90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 9 Mar 2018 21:25:20 +0200 Subject: [PATCH 13/16] MDEV-15529 IMPORT TABLESPACE unnecessarily uses the doublewrite buffer fil_space_t::atomic_write_supported: Always set this flag for TEMPORARY TABLESPACE and during IMPORT TABLESPACE. The page writes during these operations are by definition not crash-safe because they are not written to the redo log. fil_space_t::use_doublewrite(): Determine if doublewrite should be used. buf_dblwr_update(): Add assertions, and let the caller check whether doublewrite buffering is desired. buf_flush_write_block_low(): Disable the doublewrite buffer for the temporary tablespace and for IMPORT TABLESPACE. fil_space_set_imported(), fil_node_open_file(), fil_space_create(): Initialize or revise the space->atomic_write_supported flag. buf_page_io_complete(), buf_flush_write_complete(): Add the parameter dblwr, to indicate whether doublewrite was used for writes. buf_dblwr_sync_datafiles(): Remove an unnecessary flush of persistent tablespaces when flushing temporary tablespaces. (Move the call to buf_dblwr_flush_buffered_writes().) --- .../encryption/r/innodb-discard-import.result | 2 +- .../encryption/t/innodb-discard-import.test | 3 +- storage/innobase/buf/buf0buf.cc | 10 ++-- storage/innobase/buf/buf0dblwr.cc | 15 ++---- storage/innobase/buf/buf0flu.cc | 28 +++++------ storage/innobase/fil/fil0fil.cc | 46 +++++++++++++------ storage/innobase/include/buf0buf.h | 10 ++-- storage/innobase/include/buf0flu.h | 10 ++-- storage/innobase/include/fil0fil.h | 10 +++- 9 files changed, 75 insertions(+), 59 deletions(-) diff --git a/mysql-test/suite/encryption/r/innodb-discard-import.result b/mysql-test/suite/encryption/r/innodb-discard-import.result index 91314a77177..69641be92f1 100644 --- a/mysql-test/suite/encryption/r/innodb-discard-import.result +++ b/mysql-test/suite/encryption/r/innodb-discard-import.result @@ -129,6 +129,6 @@ NOT FOUND /barfoo/ in t2.ibd # t3 yes on expecting NOT FOUND NOT FOUND /tmpres/ in t3.ibd # t4 yes on expecting NOT FOUND -NOT FOUND /mysql/ in t4.ibd +# MDEV-15527 FIXME: Enable this test! DROP PROCEDURE innodb_insert_proc; DROP TABLE t1,t2,t3,t4; diff --git a/mysql-test/suite/encryption/t/innodb-discard-import.test b/mysql-test/suite/encryption/t/innodb-discard-import.test index e105cf82b67..9e78df813f9 100644 --- a/mysql-test/suite/encryption/t/innodb-discard-import.test +++ b/mysql-test/suite/encryption/t/innodb-discard-import.test @@ -111,7 +111,8 @@ SELECT COUNT(*) FROM t4; --let SEARCH_PATTERN=mysql --echo # t4 yes on expecting NOT FOUND -- let SEARCH_FILE=$t4_IBD --- source include/search_pattern_in_file.inc +--echo # MDEV-15527 FIXME: Enable this test! +#-- source include/search_pattern_in_file.inc DROP PROCEDURE innodb_insert_proc; DROP TABLE t1,t2,t3,t4; diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index b15e8d431bc..1326ec2ff71 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -5887,9 +5887,9 @@ buf_page_check_corrupt(buf_page_t* bpage, fil_space_t* space) } /** Complete a read or write request of a file page to or from the buffer pool. -@param[in,out] bpage Page to complete -@param[in] evict whether or not to evict the page - from LRU list. +@param[in,out] bpage page to complete +@param[in] dblwr whether the doublewrite buffer was used (on write) +@param[in] evict whether or not to evict the page from LRU list @return whether the operation succeeded @retval DB_SUCCESS always when writing, or if a read page was OK @retval DB_TABLESPACE_DELETED if the tablespace does not exist @@ -5899,7 +5899,7 @@ buf_page_check_corrupt(buf_page_t* bpage, fil_space_t* space) not match */ UNIV_INTERN dberr_t -buf_page_io_complete(buf_page_t* bpage, bool evict) +buf_page_io_complete(buf_page_t* bpage, bool dblwr, bool evict) { enum buf_io_fix io_type; buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); @@ -6132,7 +6132,7 @@ database_corrupted: /* Write means a flush operation: call the completion routine in the flush system */ - buf_flush_write_complete(bpage); + buf_flush_write_complete(bpage, dblwr); if (uncompressed) { rw_lock_sx_unlock_gen(&((buf_block_t*) bpage)->lock, diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc index 2bc3630d3f5..96000c4eb92 100644 --- a/storage/innobase/buf/buf0dblwr.cc +++ b/storage/innobase/buf/buf0dblwr.cc @@ -107,9 +107,6 @@ buf_dblwr_sync_datafiles() /* Wait that all async writes to tablespaces have been posted to the OS */ os_aio_wait_until_no_pending_writes(); - - /* Now we flush the data to disk (for example, with fsync) */ - fil_flush_file_spaces(FIL_TYPE_TABLESPACE); } /****************************************************************//** @@ -724,12 +721,9 @@ buf_dblwr_update( const buf_page_t* bpage, /*!< in: buffer block descriptor */ buf_flush_t flush_type)/*!< in: flush type */ { - if (!srv_use_doublewrite_buf - || buf_dblwr == NULL - || fsp_is_system_temporary(bpage->id.space())) { - return; - } - + ut_ad(srv_use_doublewrite_buf); + ut_ad(buf_dblwr); + ut_ad(!fsp_is_system_temporary(bpage->id.space())); ut_ad(!srv_read_only_mode); switch (flush_type) { @@ -957,6 +951,8 @@ buf_dblwr_flush_buffered_writes() if (!srv_use_doublewrite_buf || buf_dblwr == NULL) { /* Sync the writes to the disk. */ buf_dblwr_sync_datafiles(); + /* Now we flush the data to disk (for example, with fsync) */ + fil_flush_file_spaces(FIL_TYPE_TABLESPACE); return; } @@ -992,7 +988,6 @@ try_again: goto try_again; } - ut_a(!buf_dblwr->batch_running); ut_ad(buf_dblwr->first_free == buf_dblwr->b_reserved); /* Disallow anyone else to post to doublewrite buffer or to diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 76f1dd22aae..ca647368908 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -776,12 +776,10 @@ buf_flush_relocate_on_flush_list( buf_flush_list_mutex_exit(buf_pool); } -/********************************************************************//** -Updates the flush system data structures when a write is completed. */ -void -buf_flush_write_complete( -/*=====================*/ - buf_page_t* bpage) /*!< in: pointer to the block in question */ +/** Update the flush system data structures when a write is completed. +@param[in,out] bpage flushed page +@param[in] dblwr whether the doublewrite buffer was used */ +void buf_flush_write_complete(buf_page_t* bpage, bool dblwr) { buf_flush_t flush_type; buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); @@ -804,7 +802,9 @@ buf_flush_write_complete( os_event_set(buf_pool->no_flush[flush_type]); } - buf_dblwr_update(bpage, flush_type); + if (dblwr) { + buf_dblwr_update(bpage, flush_type); + } } /** Calculate the checksum of a page from compressed table and update @@ -1076,15 +1076,9 @@ buf_flush_write_block_low( frame = buf_page_encrypt_before_write(space, bpage, frame); - /* Disable use of double-write buffer for temporary tablespace. - Given the nature and load of temporary tablespace doublewrite buffer - adds an overhead during flushing. */ - - if (space->purpose == FIL_TYPE_TEMPORARY - || space->atomic_write_supported - || !srv_use_doublewrite_buf - || buf_dblwr == NULL) { - + ut_ad(space->purpose == FIL_TYPE_TABLESPACE + || space->atomic_write_supported); + if (!space->use_doublewrite()) { ulint type = IORequest::WRITE | IORequest::DO_NOT_WAKE; IORequest request(type, bpage); @@ -1124,7 +1118,7 @@ buf_flush_write_block_low( #endif /* true means we want to evict this page from the LRU list as well. */ - buf_page_io_complete(bpage, true); + buf_page_io_complete(bpage, space->use_doublewrite(), true); ut_ad(err == DB_SUCCESS); } diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index abcdb90c375..dc8952f8bdf 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -433,10 +433,15 @@ fil_space_set_imported( mutex_enter(&fil_system->mutex); fil_space_t* space = fil_space_get_by_id(id); + const fil_node_t* node = UT_LIST_GET_FIRST(space->chain); ut_ad(space->purpose == FIL_TYPE_IMPORT); space->purpose = FIL_TYPE_TABLESPACE; - + space->atomic_write_supported = node->atomic_write + && srv_use_atomic_writes + && my_test_if_atomic_write(node->handle, + int(page_size_t(space->flags) + .physical())); mutex_exit(&fil_system->mutex); } @@ -574,7 +579,7 @@ fil_node_open_file( ut_a(node->n_pending == 0); ut_a(!node->is_open()); - read_only_mode = !fsp_is_system_temporary(space->id) + read_only_mode = space->purpose != FIL_TYPE_TEMPORARY && srv_read_only_mode; const bool first_time_open = node->size == 0; @@ -582,8 +587,8 @@ fil_node_open_file( if (first_time_open || (space->purpose == FIL_TYPE_TABLESPACE && node == UT_LIST_GET_FIRST(space->chain) - && !undo::Truncate::was_tablespace_truncated(space->id) - && srv_startup_is_before_trx_rollback_phase)) { + && srv_startup_is_before_trx_rollback_phase + && !undo::Truncate::was_tablespace_truncated(space->id))) { /* We do not know the size of the file yet. First we open the file in the normal mode, no async I/O here, for simplicity. Then do some checks, and close the @@ -732,6 +737,11 @@ retry: if (first_time_open) { /* + For the temporary tablespace and during the + non-redo-logged adjustments in + IMPORT TABLESPACE, we do not care about + the atomicity of writes. + Atomic writes is supported if the file can be used with atomic_writes (not log file), O_DIRECT is used (tested in ha_innodb.cc) and the file is @@ -739,12 +749,14 @@ retry: for the given block size */ space->atomic_write_supported - = srv_use_atomic_writes - && node->atomic_write - && my_test_if_atomic_write( - node->handle, - int(page_size_t(space->flags) - .physical())); + = space->purpose == FIL_TYPE_TEMPORARY + || space->purpose == FIL_TYPE_IMPORT + || (node->atomic_write + && srv_use_atomic_writes + && my_test_if_atomic_write( + node->handle, + int(page_size_t(space->flags) + .physical()))); } } @@ -1552,6 +1564,13 @@ fil_space_create( if (space->purpose == FIL_TYPE_TEMPORARY) { ut_d(space->latch.set_temp_fsp()); + /* SysTablespace::open_or_create() would pass + size!=0 to fil_node_create(), so first_time_open + would not hold in fil_node_open_file(), and we + must assign this manually. We do not care about + the durability or atomicity of writes to the + temporary tablespace files. */ + space->atomic_write_supported = true; } HASH_INSERT(fil_space_t, hash, fil_system->spaces, id, space); @@ -5342,8 +5361,9 @@ fil_aio_wait( mutex_enter(&fil_system->mutex); fil_node_complete_io(node, type); - const fil_type_t purpose = node->space->purpose; - const ulint space_id = node->space->id; + const fil_type_t purpose = node->space->purpose; + const ulint space_id= node->space->id; + const bool dblwr = node->space->use_doublewrite(); mutex_exit(&fil_system->mutex); @@ -5373,7 +5393,7 @@ fil_aio_wait( } ulint offset = bpage->id.page_no(); - dberr_t err = buf_page_io_complete(bpage); + dberr_t err = buf_page_io_complete(bpage, dblwr); if (err == DB_SUCCESS) { return; } diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index 063eb6b6fab..1001f2ca807 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2017, MariaDB Corporation. +Copyright (c) 2013, 2018, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -1271,9 +1271,9 @@ buf_page_init_for_read( bool unzip); /** Complete a read or write request of a file page to or from the buffer pool. -@param[in,out] bpage Page to complete -@param[in] evict whether or not to evict the page - from LRU list. +@param[in,out] bpage page to complete +@param[in] dblwr whether the doublewrite buffer was used (on write) +@param[in] evict whether or not to evict the page from LRU list @return whether the operation succeeded @retval DB_SUCCESS always when writing, or if a read page was OK @retval DB_PAGE_CORRUPTED if the checksum fails on a page read @@ -1282,7 +1282,7 @@ buf_page_init_for_read( not match */ UNIV_INTERN dberr_t -buf_page_io_complete(buf_page_t* bpage, bool evict = false) +buf_page_io_complete(buf_page_t* bpage, bool dblwr = false, bool evict = false) MY_ATTRIBUTE((nonnull)); /********************************************************************//** diff --git a/storage/innobase/include/buf0flu.h b/storage/innobase/include/buf0flu.h index ccf1d991b09..c3b518c4295 100644 --- a/storage/innobase/include/buf0flu.h +++ b/storage/innobase/include/buf0flu.h @@ -70,12 +70,10 @@ buf_flush_relocate_on_flush_list( /*=============================*/ buf_page_t* bpage, /*!< in/out: control block being moved */ buf_page_t* dpage); /*!< in/out: destination block */ -/********************************************************************//** -Updates the flush system data structures when a write is completed. */ -void -buf_flush_write_complete( -/*=====================*/ - buf_page_t* bpage); /*!< in: pointer to the block in question */ +/** Update the flush system data structures when a write is completed. +@param[in,out] bpage flushed page +@param[in] dblwr whether the doublewrite buffer was used */ +void buf_flush_write_complete(buf_page_t* bpage, bool dblwr); /** Initialize a page for writing to the tablespace. @param[in] block buffer block; NULL if bypassing the buffer pool @param[in,out] page page frame diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index c2152ce11d0..249755f1ff6 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -36,9 +36,10 @@ Created 10/25/1995 Heikki Tuuri #include "ibuf0types.h" #include -#include // Forward declaration +extern ibool srv_use_doublewrite_buf; +extern struct buf_dblwr_t* buf_dblwr; struct trx_t; class page_id_t; class truncate_t; @@ -200,6 +201,13 @@ struct fil_space_t { { return stop_new_ops || is_being_truncated; } + + /** @return whether doublewrite buffering is needed */ + bool use_doublewrite() const + { + return !atomic_write_supported + && srv_use_doublewrite_buf && buf_dblwr; + } }; /** Value of fil_space_t::magic_n */ From 28777046b4dc3decd462a4a7a6d68c168b484635 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Thu, 8 Mar 2018 11:43:55 +0100 Subject: [PATCH 14/16] MDEV-15245: Assertion `false' failed in myrocks::ha_rocksdb::position Don't call handler->position() if the last call to read a row did not succeed. --- sql/sql_select.cc | 2 +- .../mysql-test/rocksdb/r/rocksdb_parts.result | 14 ++++++++++++++ .../mysql-test/rocksdb/t/rocksdb_parts.test | 19 +++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 4746f186fe7..6450eb03d4d 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -18724,7 +18724,7 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records) skip_over= FALSE; } - if (join_tab->keep_current_rowid) + if (join_tab->keep_current_rowid && !error) join_tab->table->file->position(join_tab->table->record[0]); rc= evaluate_join_record(join, join_tab, error); diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_parts.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_parts.result index 9ac7243071b..2fde11c2a08 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_parts.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_parts.result @@ -135,3 +135,17 @@ SELECT 1; 1 1 DROP TABLE t1; +# +# MDEV-15245: Assertion `false' failed in myrocks::ha_rocksdb::position +# +CREATE TABLE t1 (a INT) ENGINE=RocksDB; +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (b INT) ENGINE=RocksDB +PARTITION BY RANGE(b) +(PARTITION p0 VALUES LESS THAN (1), +PARTITION p1 VALUES LESS THAN MAXVALUE); +INSERT INTO t2 VALUES (NULL),(0); +CREATE ALGORITHM = MERGE VIEW v1 AS SELECT t2.* FROM t1, t2; +UPDATE v1 SET b = 5; +drop view v1; +drop table t1,t2; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_parts.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_parts.test index a0768667385..b8d41ae942a 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_parts.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_parts.test @@ -139,3 +139,22 @@ ALTER TABLE t1 ADD PARTITION PARTITIONS 2; SELECT 1; DROP TABLE t1; +--echo # +--echo # MDEV-15245: Assertion `false' failed in myrocks::ha_rocksdb::position +--echo # +CREATE TABLE t1 (a INT) ENGINE=RocksDB; +INSERT INTO t1 VALUES (1),(2); +# partitioning +CREATE TABLE t2 (b INT) ENGINE=RocksDB +PARTITION BY RANGE(b) +(PARTITION p0 VALUES LESS THAN (1), + PARTITION p1 VALUES LESS THAN MAXVALUE); + + +INSERT INTO t2 VALUES (NULL),(0); +CREATE ALGORITHM = MERGE VIEW v1 AS SELECT t2.* FROM t1, t2; +UPDATE v1 SET b = 5; + +drop view v1; +drop table t1,t2; + From cd109592ca50e881f49208b8bb01e18ee7e3f925 Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Mon, 12 Mar 2018 08:30:08 +0400 Subject: [PATCH 15/16] MDEV-15217 Assertion `thd->transaction.xid_state.xid.is_null()' failed in trans_xa_start. THD.transaction.xid_state.xid.rm_error should be cleaned as the thread ends. --- mysql-test/r/xa.result | 22 ++++++++++++++++++++++ mysql-test/t/xa.test | 37 ++++++++++++++++++++++++++++++++++++- sql/sql_class.cc | 1 + 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/xa.result b/mysql-test/r/xa.result index 0470c284a29..782be3834d1 100644 --- a/mysql-test/r/xa.result +++ b/mysql-test/r/xa.result @@ -270,3 +270,25 @@ XA ROLLBACK 'xid1'; connection default; DROP TABLE t1, t2; disconnect con2; +CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t2 (pk INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(2); +CREATE TABLE t3 (i INT) ENGINE=InnoDB; +XA BEGIN 'xid1'; +REPLACE INTO t1 SELECT * FROM t2; +connect con1,localhost,root,,test; +XA BEGIN 'xid2'; +INSERT INTO t1 SELECT * FROM t2; +connection default; +REPLACE INTO t2 SELECT * FROM t2; +connection con1; +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +disconnect con1; +connect con2,localhost,root,,test; +INSERT INTO t3 VALUES (1); +XA BEGIN 'xid3'; +disconnect con2; +connection default; +XA END 'xid1'; +XA ROLLBACK 'xid1'; +DROP TABLE t1, t2, t3; diff --git a/mysql-test/t/xa.test b/mysql-test/t/xa.test index 7303030921d..85a792822dd 100644 --- a/mysql-test/t/xa.test +++ b/mysql-test/t/xa.test @@ -394,6 +394,41 @@ DROP TABLE t1, t2; disconnect con2; -# Wait till all disconnects are completed +# +# MDEV 15217 Assertion `thd->transaction.xid_state.xid.is_null()' failed in trans_xa_start. +# +CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t2 (pk INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(2); +CREATE TABLE t3 (i INT) ENGINE=InnoDB; + +XA BEGIN 'xid1'; +REPLACE INTO t1 SELECT * FROM t2; + +--connect (con1,localhost,root,,test) +XA BEGIN 'xid2'; +--send +INSERT INTO t1 SELECT * FROM t2; + +--connection default +REPLACE INTO t2 SELECT * FROM t2; + +--connection con1 +--error ER_LOCK_DEADLOCK +--reap +--disconnect con1 + +--connect (con2,localhost,root,,test) +INSERT INTO t3 VALUES (1); +XA BEGIN 'xid3'; + + +#Cleanup +--disconnect con2 +--connection default +XA END 'xid1'; +XA ROLLBACK 'xid1'; +DROP TABLE t1, t2, t3; + --source include/wait_until_count_sessions.inc diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 1e07849db16..d854d6de110 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1462,6 +1462,7 @@ void THD::cleanup(void) close_temporary_tables(); transaction.xid_state.xa_state= XA_NOTR; + transaction.xid_state.rm_error= 0; trans_rollback(this); xid_cache_delete(this, &transaction.xid_state); From 4a35e76f645d0e5e8554f810e16aafa734584ed7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 12 Mar 2018 13:06:21 +0200 Subject: [PATCH 16/16] MDEV-14773 DROP TABLE hangs for InnoDB table with FULLTEXT index fts_sync(): If the dict_table_t::to_be_dropped flag is set, do not "goto begin_sync". Also, clean up the way how dict_index_t::index_fts_syncing is cleared. It looks like this regression was introduced by merging Oracle Bug #24938374 MYSQL CRASHED AFTER LONG WAIT ON DICT OPERATION LOCK WHILE SYNCING FTS INDEX https://github.com/mysql/mysql-server/commit/068f8261d4c1e134965383ff974ddf30c0758f51 from MySQL 5.6.38 into MariaDB 10.0.33, 10.1.29, 10.2.10. The same hang is present in MySQL 5.7.20. --- storage/innobase/fts/fts0fts.cc | 23 +++++------------------ storage/xtradb/fts/fts0fts.cc | 23 +++++------------------ 2 files changed, 10 insertions(+), 36 deletions(-) diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index 1d753e3657b..8ccc8afe7b4 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2011, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2017, MariaDB Corporation. +Copyright (c) 2016, 2018, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -4627,6 +4627,7 @@ begin_sync: ib_vector_get(cache->indexes, i)); if (index_cache->index->to_be_dropped + || index_cache->index->table->to_be_dropped || fts_sync_index_check(index_cache)) { continue; } @@ -4637,17 +4638,6 @@ begin_sync: end_sync: if (error == DB_SUCCESS && !sync->interrupted) { error = fts_sync_commit(sync); - if (error == DB_SUCCESS) { - for (i = 0; i < ib_vector_size(cache->indexes); ++i) { - fts_index_cache_t* index_cache; - index_cache = static_cast( - ib_vector_get(cache->indexes, i)); - if (index_cache->index->index_fts_syncing) { - index_cache->index->index_fts_syncing - = false; - } - } - } } else { fts_sync_rollback(sync); } @@ -4656,12 +4646,9 @@ end_sync: /* Clear fts syncing flags of any indexes incase sync is interrupeted */ for (i = 0; i < ib_vector_size(cache->indexes); ++i) { - fts_index_cache_t* index_cache; - index_cache = static_cast( - ib_vector_get(cache->indexes, i)); - if (index_cache->index->index_fts_syncing == true) { - index_cache->index->index_fts_syncing = false; - } + static_cast( + ib_vector_get(cache->indexes, i)) + ->index->index_fts_syncing = false; } sync->interrupted = false; diff --git a/storage/xtradb/fts/fts0fts.cc b/storage/xtradb/fts/fts0fts.cc index 8838404460f..49b1028bb5e 100644 --- a/storage/xtradb/fts/fts0fts.cc +++ b/storage/xtradb/fts/fts0fts.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2011, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2017, MariaDB Corporation. +Copyright (c) 2016, 2018, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -4627,6 +4627,7 @@ begin_sync: ib_vector_get(cache->indexes, i)); if (index_cache->index->to_be_dropped + || index_cache->index->table->to_be_dropped || fts_sync_index_check(index_cache)) { continue; } @@ -4637,17 +4638,6 @@ begin_sync: end_sync: if (error == DB_SUCCESS && !sync->interrupted) { error = fts_sync_commit(sync); - if (error == DB_SUCCESS) { - for (i = 0; i < ib_vector_size(cache->indexes); ++i) { - fts_index_cache_t* index_cache; - index_cache = static_cast( - ib_vector_get(cache->indexes, i)); - if (index_cache->index->index_fts_syncing) { - index_cache->index->index_fts_syncing - = false; - } - } - } } else { fts_sync_rollback(sync); } @@ -4656,12 +4646,9 @@ end_sync: /* Clear fts syncing flags of any indexes incase sync is interrupeted */ for (i = 0; i < ib_vector_size(cache->indexes); ++i) { - fts_index_cache_t* index_cache; - index_cache = static_cast( - ib_vector_get(cache->indexes, i)); - if (index_cache->index->index_fts_syncing == true) { - index_cache->index->index_fts_syncing = false; - } + static_cast( + ib_vector_get(cache->indexes, i)) + ->index->index_fts_syncing = false; } sync->interrupted = false;