Commit 2db80c37 authored by Marko Mäkelä's avatar Marko Mäkelä

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.
parent d96433ad
...@@ -58,10 +58,13 @@ CREATE TABLE t(c INT) ENGINE=InnoDB page_compressed=1; ...@@ -58,10 +58,13 @@ CREATE TABLE t(c INT) ENGINE=InnoDB page_compressed=1;
DROP TABLE IF EXISTS t; DROP TABLE IF EXISTS t;
SET GLOBAL innodb_compression_level=1; SET GLOBAL innodb_compression_level=1;
CREATE TABLE t(a INT)ENGINE=InnoDB ROW_FORMAT=DYNAMIC page_compressed=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; SET GLOBAL innodb_compression_level=0;
ALTER TABLE t FORCE, ROW_FORMAT=DEFAULT, ALGORITHM=INPLACE; ALTER TABLE t FORCE, ROW_FORMAT=DEFAULT, ALGORITHM=INPLACE;
ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'PAGE_COMPRESSED' ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'PAGE_COMPRESSED'
ALTER TABLE t FORCE, ROW_FORMAT=DEFAULT, ALGORITHM=COPY; ALTER TABLE t FORCE, ROW_FORMAT=DEFAULT, ALGORITHM=COPY;
ERROR HY000: Can't create table `test`.`t` (errno: 140 "Wrong create options") ERROR HY000: Can't create table `test`.`t` (errno: 140 "Wrong create options")
DROP TABLE t; DROP TABLE t;
TRUNCATE tt;
SET GLOBAL innodb_compression_level=@save_level; SET GLOBAL innodb_compression_level=@save_level;
...@@ -69,10 +69,13 @@ DROP TABLE IF EXISTS t; ...@@ -69,10 +69,13 @@ DROP TABLE IF EXISTS t;
SET GLOBAL innodb_compression_level=1; SET GLOBAL innodb_compression_level=1;
CREATE TABLE t(a INT)ENGINE=InnoDB ROW_FORMAT=DYNAMIC page_compressed=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; SET GLOBAL innodb_compression_level=0;
--error ER_ILLEGAL_HA_CREATE_OPTION --error ER_ILLEGAL_HA_CREATE_OPTION
ALTER TABLE t FORCE, ROW_FORMAT=DEFAULT, ALGORITHM=INPLACE; ALTER TABLE t FORCE, ROW_FORMAT=DEFAULT, ALGORITHM=INPLACE;
--error ER_CANT_CREATE_TABLE --error ER_CANT_CREATE_TABLE
ALTER TABLE t FORCE, ROW_FORMAT=DEFAULT, ALGORITHM=COPY; ALTER TABLE t FORCE, ROW_FORMAT=DEFAULT, ALGORITHM=COPY;
DROP TABLE t; DROP TABLE t;
TRUNCATE tt;
SET GLOBAL innodb_compression_level=@save_level; SET GLOBAL innodb_compression_level=@save_level;
...@@ -11776,13 +11776,16 @@ bool create_table_info_t::innobase_table_flags() ...@@ -11776,13 +11776,16 @@ bool create_table_info_t::innobase_table_flags()
zip_ssize = 0; zip_ssize = 0;
} }
ulint level = 0;
if (is_temp) { if (is_temp) {
m_flags2 |= DICT_TF2_TEMPORARY; m_flags2 |= DICT_TF2_TEMPORARY;
} else if (m_use_file_per_table) { } else {
if (m_use_file_per_table) {
m_flags2 |= DICT_TF2_USE_FILE_PER_TABLE; m_flags2 |= DICT_TF2_USE_FILE_PER_TABLE;
} }
ulint level = ulint(options->page_compression_level); level = ulint(options->page_compression_level);
if (!level) { if (!level) {
level = page_zip_level; level = page_zip_level;
if (!level && options->page_compressed) { if (!level && options->page_compressed) {
...@@ -11795,10 +11798,11 @@ bool create_table_info_t::innobase_table_flags() ...@@ -11795,10 +11798,11 @@ bool create_table_info_t::innobase_table_flags()
DBUG_RETURN(false); DBUG_RETURN(false);
} }
} }
}
/* Set the table flags */ /* Set the table flags */
dict_tf_set(&m_flags, innodb_row_format, zip_ssize, 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) { if (m_form->s->table_type == TABLE_TYPE_SEQUENCE) {
m_flags |= DICT_TF_MASK_NO_ROLLBACK; m_flags |= DICT_TF_MASK_NO_ROLLBACK;
...@@ -13856,6 +13860,7 @@ int ha_innobase::truncate() ...@@ -13856,6 +13860,7 @@ int ha_innobase::truncate()
int err = create(ib_table->name.m_name, table, &info, true, int err = create(ib_table->name.m_name, table, &info, true,
trx); trx);
ut_ad(!err);
if (!err) { if (!err) {
err = open(ib_table->name.m_name, 0, 0); err = open(ib_table->name.m_name, 0, 0);
m_prebuilt->stored_select_lock_type = stored_lock; m_prebuilt->stored_select_lock_type = stored_lock;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment