Commit 1fb71c78 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-19272: Assertion unireg_check..Field::NEXT_NUMBER failed

ha_innobase::check_if_supported_inplace_alter(): Relax a too strict
debug assertion when changing a column from NULL to NOT NULL.
InnoDB actually allows instant removal of an AUTO_INCREMENT attribute
since commit 8dffaaef (MDEV-12836).
parent 0604592a
......@@ -107,5 +107,15 @@ alter table t1 engine=innodb;
alter table t1 add column b int;
drop table t1,t2;
#
# MDEV-19272 Assertion unireg_check...Field::NEXT_NUMBER failed
#
CREATE TABLE t1 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB;
ALTER TABLE t1 MODIFY c INT NOT NULL, ALGORITHM=INPLACE;
DROP TABLE t1;
CREATE TABLE t1 (c TIMESTAMP AUTO_INCREMENT UNIQUE) ENGINE=InnoDB;
ERROR 42000: Incorrect column specifier for column 'c'
CREATE TABLE t1 (c DATETIME AUTO_INCREMENT UNIQUE) ENGINE=InnoDB;
ERROR 42000: Incorrect column specifier for column 'c'
#
# End of 10.4 tests
#
......@@ -109,6 +109,17 @@ alter table t1 engine=innodb;
alter table t1 add column b int;
drop table t1,t2;
--echo #
--echo # MDEV-19272 Assertion unireg_check...Field::NEXT_NUMBER failed
--echo #
CREATE TABLE t1 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB;
ALTER TABLE t1 MODIFY c INT NOT NULL, ALGORITHM=INPLACE;
DROP TABLE t1;
--error ER_WRONG_FIELD_SPEC
CREATE TABLE t1 (c TIMESTAMP AUTO_INCREMENT UNIQUE) ENGINE=InnoDB;
--error ER_WRONG_FIELD_SPEC
CREATE TABLE t1 (c DATETIME AUTO_INCREMENT UNIQUE) ENGINE=InnoDB;
--echo #
--echo # End of 10.4 tests
--echo #
......
......@@ -2408,6 +2408,13 @@ ha_innobase::check_if_supported_inplace_alter(
& ALTER_ADD_COLUMN));
if (const Field* f = cf.field) {
/* An AUTO_INCREMENT attribute can only
be added to an existing column by ALGORITHM=COPY,
but we can remove the attribute. */
ut_ad((MTYP_TYPENR((*af)->unireg_check)
!= Field::NEXT_NUMBER)
|| (MTYP_TYPENR(f->unireg_check)
== Field::NEXT_NUMBER));
if (!f->real_maybe_null() || (*af)->real_maybe_null())
goto next_column;
/* We are changing an existing column
......@@ -2416,7 +2423,6 @@ ha_innobase::check_if_supported_inplace_alter(
& ALTER_COLUMN_NOT_NULLABLE);
/* Virtual columns are never NOT NULL. */
DBUG_ASSERT(f->stored_in_db());
switch ((*af)->type()) {
case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_TIMESTAMP2:
......@@ -2436,14 +2442,7 @@ ha_innobase::check_if_supported_inplace_alter(
break;
default:
/* For any other data type, NULL
values are not converted.
(An AUTO_INCREMENT attribute cannot
be introduced to a column with
ALGORITHM=INPLACE.) */
ut_ad((MTYP_TYPENR((*af)->unireg_check)
== Field::NEXT_NUMBER)
== (MTYP_TYPENR(f->unireg_check)
== Field::NEXT_NUMBER));
values are not converted. */
goto next_column;
}
......
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