mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
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 8dffaaef72
(MDEV-12836).
This commit is contained in:
@ -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 @@ innodb_instant_alter_column_allowed_reason:
|
||||
& 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 @@ innodb_instant_alter_column_allowed_reason:
|
||||
& 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 @@ innodb_instant_alter_column_allowed_reason:
|
||||
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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user