Skip to content

Commit 2db80c3

Browse files
committed
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.
1 parent d96433a commit 2db80c3

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

mysql-test/suite/innodb/r/default_row_format_create.result

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,13 @@ CREATE TABLE t(c INT) ENGINE=InnoDB page_compressed=1;
5858
DROP TABLE IF EXISTS t;
5959
SET GLOBAL innodb_compression_level=1;
6060
CREATE TABLE t(a INT)ENGINE=InnoDB ROW_FORMAT=DYNAMIC page_compressed=1;
61+
CREATE TEMPORARY TABLE tt(a INT PRIMARY KEY)
62+
ROW_FORMAT=DYNAMIC page_compressed=1 ENGINE=InnoDB;
6163
SET GLOBAL innodb_compression_level=0;
6264
ALTER TABLE t FORCE, ROW_FORMAT=DEFAULT, ALGORITHM=INPLACE;
6365
ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'PAGE_COMPRESSED'
6466
ALTER TABLE t FORCE, ROW_FORMAT=DEFAULT, ALGORITHM=COPY;
6567
ERROR HY000: Can't create table `test`.`t` (errno: 140 "Wrong create options")
6668
DROP TABLE t;
69+
TRUNCATE tt;
6770
SET GLOBAL innodb_compression_level=@save_level;

mysql-test/suite/innodb/t/default_row_format_create.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,13 @@ DROP TABLE IF EXISTS t;
6969

7070
SET GLOBAL innodb_compression_level=1;
7171
CREATE TABLE t(a INT)ENGINE=InnoDB ROW_FORMAT=DYNAMIC page_compressed=1;
72+
CREATE TEMPORARY TABLE tt(a INT PRIMARY KEY)
73+
ROW_FORMAT=DYNAMIC page_compressed=1 ENGINE=InnoDB;
7274
SET GLOBAL innodb_compression_level=0;
7375
--error ER_ILLEGAL_HA_CREATE_OPTION
7476
ALTER TABLE t FORCE, ROW_FORMAT=DEFAULT, ALGORITHM=INPLACE;
7577
--error ER_CANT_CREATE_TABLE
7678
ALTER TABLE t FORCE, ROW_FORMAT=DEFAULT, ALGORITHM=COPY;
7779
DROP TABLE t;
80+
TRUNCATE tt;
7881
SET GLOBAL innodb_compression_level=@save_level;

storage/innobase/handler/ha_innodb.cc

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11776,29 +11776,33 @@ bool create_table_info_t::innobase_table_flags()
1177611776
zip_ssize = 0;
1177711777
}
1177811778

11779+
ulint level = 0;
11780+
1177911781
if (is_temp) {
1178011782
m_flags2 |= DICT_TF2_TEMPORARY;
11781-
} else if (m_use_file_per_table) {
11782-
m_flags2 |= DICT_TF2_USE_FILE_PER_TABLE;
11783-
}
11783+
} else {
11784+
if (m_use_file_per_table) {
11785+
m_flags2 |= DICT_TF2_USE_FILE_PER_TABLE;
11786+
}
1178411787

11785-
ulint level = ulint(options->page_compression_level);
11786-
if (!level) {
11787-
level = page_zip_level;
11788-
if (!level && options->page_compressed) {
11789-
push_warning_printf(
11790-
m_thd, Sql_condition::WARN_LEVEL_WARN,
11791-
ER_ILLEGAL_HA_CREATE_OPTION,
11792-
"InnoDB: PAGE_COMPRESSED requires"
11793-
" PAGE_COMPRESSION_LEVEL or"
11794-
" innodb_compression_level > 0");
11795-
DBUG_RETURN(false);
11788+
level = ulint(options->page_compression_level);
11789+
if (!level) {
11790+
level = page_zip_level;
11791+
if (!level && options->page_compressed) {
11792+
push_warning_printf(
11793+
m_thd, Sql_condition::WARN_LEVEL_WARN,
11794+
ER_ILLEGAL_HA_CREATE_OPTION,
11795+
"InnoDB: PAGE_COMPRESSED requires"
11796+
" PAGE_COMPRESSION_LEVEL or"
11797+
" innodb_compression_level > 0");
11798+
DBUG_RETURN(false);
11799+
}
1179611800
}
1179711801
}
1179811802

1179911803
/* Set the table flags */
1180011804
dict_tf_set(&m_flags, innodb_row_format, zip_ssize,
11801-
m_use_data_dir, options->page_compressed, level);
11805+
m_use_data_dir, level && options->page_compressed, level);
1180211806

1180311807
if (m_form->s->table_type == TABLE_TYPE_SEQUENCE) {
1180411808
m_flags |= DICT_TF_MASK_NO_ROLLBACK;
@@ -13856,6 +13860,7 @@ int ha_innobase::truncate()
1385613860

1385713861
int err = create(ib_table->name.m_name, table, &info, true,
1385813862
trx);
13863+
ut_ad(!err);
1385913864
if (!err) {
1386013865
err = open(ib_table->name.m_name, 0, 0);
1386113866
m_prebuilt->stored_select_lock_type = stored_lock;

0 commit comments

Comments
 (0)