summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2022-03-01 17:52:45 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2022-03-01 17:52:45 +0200
commit2db80c377328b696120c77bf20c3bfa923137e47 (patch)
treee7865ad1bd5475377fac422813c511e12c3d0c8f
parentd96433ad2088526ada21dc2e29336254ad64e825 (diff)
downloadmariadb-git-2db80c377328b696120c77bf20c3bfa923137e47.tar.gz
MDEV-27973 SIGSEGV in ha_innobase::reset() after TRUNCATE of TEMPORARY TABLE
create_table_info_t::innobase_table_flags(): Ignore page_compressed and page_compression_level on TEMPORARY tables. ha_innobase::truncate(): Add a debug assertion that create() must succeed on temporary tables.
-rw-r--r--mysql-test/suite/innodb/r/default_row_format_create.result3
-rw-r--r--mysql-test/suite/innodb/t/default_row_format_create.test3
-rw-r--r--storage/innobase/handler/ha_innodb.cc35
3 files changed, 26 insertions, 15 deletions
diff --git a/mysql-test/suite/innodb/r/default_row_format_create.result b/mysql-test/suite/innodb/r/default_row_format_create.result
index 50adc757b62..a1334101b61 100644
--- a/mysql-test/suite/innodb/r/default_row_format_create.result
+++ b/mysql-test/suite/innodb/r/default_row_format_create.result
@@ -58,10 +58,13 @@ CREATE TABLE t(c INT) ENGINE=InnoDB page_compressed=1;
DROP TABLE IF EXISTS t;
SET GLOBAL innodb_compression_level=1;
CREATE TABLE t(a INT)ENGINE=InnoDB ROW_FORMAT=DYNAMIC page_compressed=1;
+CREATE TEMPORARY TABLE tt(a INT PRIMARY KEY)
+ROW_FORMAT=DYNAMIC page_compressed=1 ENGINE=InnoDB;
SET GLOBAL innodb_compression_level=0;
ALTER TABLE t FORCE, ROW_FORMAT=DEFAULT, ALGORITHM=INPLACE;
ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'PAGE_COMPRESSED'
ALTER TABLE t FORCE, ROW_FORMAT=DEFAULT, ALGORITHM=COPY;
ERROR HY000: Can't create table `test`.`t` (errno: 140 "Wrong create options")
DROP TABLE t;
+TRUNCATE tt;
SET GLOBAL innodb_compression_level=@save_level;
diff --git a/mysql-test/suite/innodb/t/default_row_format_create.test b/mysql-test/suite/innodb/t/default_row_format_create.test
index 0b3e0d25f00..cd497d74de7 100644
--- a/mysql-test/suite/innodb/t/default_row_format_create.test
+++ b/mysql-test/suite/innodb/t/default_row_format_create.test
@@ -69,10 +69,13 @@ DROP TABLE IF EXISTS t;
SET GLOBAL innodb_compression_level=1;
CREATE TABLE t(a INT)ENGINE=InnoDB ROW_FORMAT=DYNAMIC page_compressed=1;
+CREATE TEMPORARY TABLE tt(a INT PRIMARY KEY)
+ROW_FORMAT=DYNAMIC page_compressed=1 ENGINE=InnoDB;
SET GLOBAL innodb_compression_level=0;
--error ER_ILLEGAL_HA_CREATE_OPTION
ALTER TABLE t FORCE, ROW_FORMAT=DEFAULT, ALGORITHM=INPLACE;
--error ER_CANT_CREATE_TABLE
ALTER TABLE t FORCE, ROW_FORMAT=DEFAULT, ALGORITHM=COPY;
DROP TABLE t;
+TRUNCATE tt;
SET GLOBAL innodb_compression_level=@save_level;
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 7025986b9e5..bfed36e9a85 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -11776,29 +11776,33 @@ index_bad:
zip_ssize = 0;
}
+ ulint level = 0;
+
if (is_temp) {
m_flags2 |= DICT_TF2_TEMPORARY;
- } else if (m_use_file_per_table) {
- m_flags2 |= DICT_TF2_USE_FILE_PER_TABLE;
- }
+ } else {
+ if (m_use_file_per_table) {
+ m_flags2 |= DICT_TF2_USE_FILE_PER_TABLE;
+ }
- ulint level = ulint(options->page_compression_level);
- if (!level) {
- level = page_zip_level;
- if (!level && options->page_compressed) {
- push_warning_printf(
- m_thd, Sql_condition::WARN_LEVEL_WARN,
- ER_ILLEGAL_HA_CREATE_OPTION,
- "InnoDB: PAGE_COMPRESSED requires"
- " PAGE_COMPRESSION_LEVEL or"
- " innodb_compression_level > 0");
- DBUG_RETURN(false);
+ level = ulint(options->page_compression_level);
+ if (!level) {
+ level = page_zip_level;
+ if (!level && options->page_compressed) {
+ push_warning_printf(
+ m_thd, Sql_condition::WARN_LEVEL_WARN,
+ ER_ILLEGAL_HA_CREATE_OPTION,
+ "InnoDB: PAGE_COMPRESSED requires"
+ " PAGE_COMPRESSION_LEVEL or"
+ " innodb_compression_level > 0");
+ DBUG_RETURN(false);
+ }
}
}
/* Set the table flags */
dict_tf_set(&m_flags, innodb_row_format, zip_ssize,
- m_use_data_dir, options->page_compressed, level);
+ m_use_data_dir, level && options->page_compressed, level);
if (m_form->s->table_type == TABLE_TYPE_SEQUENCE) {
m_flags |= DICT_TF_MASK_NO_ROLLBACK;
@@ -13856,6 +13860,7 @@ int ha_innobase::truncate()
int err = create(ib_table->name.m_name, table, &info, true,
trx);
+ ut_ad(!err);
if (!err) {
err = open(ib_table->name.m_name, 0, 0);
m_prebuilt->stored_select_lock_type = stored_lock;