mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-26458 Crash on ALTER TABLE after DISCARD TABLESPACE
ha_innobase::check_if_supported_inplace_alter(): Do not invoke
innobase_table_is_empty() if the tablespace has been discarded.
That is, native ALTER TABLE in InnoDB will treat an empty table
in the same way as a tablespace whose tablespace has been discarded.
(Note: ALTER TABLE...ALGORITHM=COPY will fail if the tablespace
has been discarded.)
This fixes a crash that was introduced
in commit c755974775
(MDEV-19611).
This commit is contained in:
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user