summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2018-11-26 16:39:36 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2018-11-26 16:41:09 +0200
commit971e1d8677be58cd51e558ef80042c76a5c21e1a (patch)
tree17ec5fd316269be69bf98eca71f95f34e40cc5c0
parent9669536c2355efb6f71babc9d2e615e9125c816b (diff)
downloadmariadb-git-971e1d8677be58cd51e558ef80042c76a5c21e1a.tar.gz
MDEV-17831 TRUNCATE TABLE removes ROW_FORMAT=COMPRESSED
If a table had a KEY_BLOCK_SIZE attribute, but no ROW_FORMAT, it would be created as ROW_FORMAT=COMPRESSED in InnoDB. However, TRUNCATE TABLE would lose the KEY_BLOCK_SIZE attribute and create the table with the innodb_default_row_format (DYNAMIC). This is a regression that was introduced by MDEV-13564. update_create_info_from_table(): Copy also KEY_BLOCK_SIZE.
-rw-r--r--mysql-test/suite/innodb/r/truncate.result9
-rw-r--r--mysql-test/suite/innodb/t/truncate.test9
-rw-r--r--sql/table.cc1
3 files changed, 19 insertions, 0 deletions
diff --git a/mysql-test/suite/innodb/r/truncate.result b/mysql-test/suite/innodb/r/truncate.result
index c8a81256d79..e25cd6a0bea 100644
--- a/mysql-test/suite/innodb/r/truncate.result
+++ b/mysql-test/suite/innodb/r/truncate.result
@@ -18,3 +18,12 @@ SELECT * FROM t1;
c
character
DROP TABLE t1;
+#
+# MDEV-17831 TRUNCATE TABLE removes ROW_FORMAT=COMPRESSED
+#
+CREATE TABLE t1 (a SERIAL) ENGINE=InnoDB KEY_BLOCK_SIZE=4;
+TRUNCATE TABLE t1;
+SHOW TABLE STATUS;
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
+t1 InnoDB # Compressed # # # # # # 1 # # NULL latin1_swedish_ci NULL key_block_size=4
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/t/truncate.test b/mysql-test/suite/innodb/t/truncate.test
index f0cfd3a5be1..16a3b06a8ae 100644
--- a/mysql-test/suite/innodb/t/truncate.test
+++ b/mysql-test/suite/innodb/t/truncate.test
@@ -27,3 +27,12 @@ ALTER TABLE t1 ROW_FORMAT=REDUNDANT;
TRUNCATE TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-17831 TRUNCATE TABLE removes ROW_FORMAT=COMPRESSED
+--echo #
+CREATE TABLE t1 (a SERIAL) ENGINE=InnoDB KEY_BLOCK_SIZE=4;
+TRUNCATE TABLE t1;
+--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
+SHOW TABLE STATUS;
+DROP TABLE t1;
diff --git a/sql/table.cc b/sql/table.cc
index 2b278288784..0cf88aed4f6 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -3830,6 +3830,7 @@ void update_create_info_from_table(HA_CREATE_INFO *create_info, TABLE *table)
create_info->table_options= share->db_create_options;
create_info->avg_row_length= share->avg_row_length;
create_info->row_type= share->row_type;
+ create_info->key_block_size= share->key_block_size;
create_info->default_table_charset= share->table_charset;
create_info->table_charset= 0;
create_info->comment= share->comment;