diff options
-rw-r--r-- | mysql-test/suite/innodb/r/innodb-alter-timestamp.result | 12 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/innodb-alter-timestamp.test | 12 | ||||
-rw-r--r-- | storage/innobase/handler/handler0alter.cc | 1 |
3 files changed, 25 insertions, 0 deletions
diff --git a/mysql-test/suite/innodb/r/innodb-alter-timestamp.result b/mysql-test/suite/innodb/r/innodb-alter-timestamp.result index 6934484a488..280ab3ebee4 100644 --- a/mysql-test/suite/innodb/r/innodb-alter-timestamp.result +++ b/mysql-test/suite/innodb/r/innodb-alter-timestamp.result @@ -139,3 +139,15 @@ ALTER TABLE t1 ADD f3 DATE NOT NULL, ALGORITHM=INPLACE; ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY DROP TABLE t1; disconnect purge_control; +# +# MDEV-26458 SIGSEGV in innobase_table_is_empty() on ALTER TABLE +# +CREATE TABLE t(a INT PRIMARY KEY) ENGINE=InnoDB; +ALTER TABLE t DISCARD TABLESPACE; +SET sql_mode='NO_ZERO_DATE'; +ALTER TABLE t ADD c DATE NOT NULL; +Warnings: +Warning 1814 Tablespace has been discarded for table `t` +SET sql_mode=DEFAULT; +DROP TABLE t; +# End of 10.3 tests diff --git a/mysql-test/suite/innodb/t/innodb-alter-timestamp.test b/mysql-test/suite/innodb/t/innodb-alter-timestamp.test index 28b09b18e10..e1c263dc5d0 100644 --- a/mysql-test/suite/innodb/t/innodb-alter-timestamp.test +++ b/mysql-test/suite/innodb/t/innodb-alter-timestamp.test @@ -103,3 +103,15 @@ INSERT INTO t1 VALUES (1, now()); ALTER TABLE t1 ADD f3 DATE NOT NULL, ALGORITHM=INPLACE; DROP TABLE t1; disconnect purge_control; + +--echo # +--echo # MDEV-26458 SIGSEGV in innobase_table_is_empty() on ALTER TABLE +--echo # +CREATE TABLE t(a INT PRIMARY KEY) ENGINE=InnoDB; +ALTER TABLE t DISCARD TABLESPACE; +SET sql_mode='NO_ZERO_DATE'; +ALTER TABLE t ADD c DATE NOT NULL; +SET sql_mode=DEFAULT; +DROP TABLE t; + +--echo # End of 10.3 tests diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index ff7c355f2dd..8418ad7316c 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -1164,6 +1164,7 @@ ha_innobase::check_if_supported_inplace_alter( /* '0000-00-00' value isn't allowed for datetime datatype for newly added column when table is not empty */ if (ha_alter_info->error_if_not_empty + && m_prebuilt->table->space && !innobase_table_is_empty(m_prebuilt->table)) { DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED); } |