diff --git a/mysql-test/suite/versioning/r/alter.result b/mysql-test/suite/versioning/r/alter.result index a3ddb63fad9..279dfb7d10d 100644 --- a/mysql-test/suite/versioning/r/alter.result +++ b/mysql-test/suite/versioning/r/alter.result @@ -422,5 +422,10 @@ create or replace table t(x int, y int) with system versioning engine=innodb; alter table t modify y int without system versioning; insert into t values(1, 1); update t set y=2; +# MDEV-14681 Bogus ER_UNSUPPORTED_EXTENSION +create or replace table t1 (pk int auto_increment unique) with system versioning; +insert into t1 values (1); +delete from t1; +alter table t1 engine=myisam; drop database test; create database test; diff --git a/mysql-test/suite/versioning/t/alter.test b/mysql-test/suite/versioning/t/alter.test index 46027b21b0f..2d88b7ad6f0 100644 --- a/mysql-test/suite/versioning/t/alter.test +++ b/mysql-test/suite/versioning/t/alter.test @@ -365,5 +365,11 @@ alter table t modify y int without system versioning; insert into t values(1, 1); update t set y=2; +--echo # MDEV-14681 Bogus ER_UNSUPPORTED_EXTENSION +create or replace table t1 (pk int auto_increment unique) with system versioning; +insert into t1 values (1); +delete from t1; +alter table t1 engine=myisam; + drop database test; create database test; diff --git a/sql/handler.cc b/sql/handler.cc index 68831d499c4..921ac14e969 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -3046,6 +3046,25 @@ prev_insert_id(ulonglong nr, struct system_variables *variables) #define AUTO_INC_DEFAULT_NB_MAX_BITS 16 #define AUTO_INC_DEFAULT_NB_MAX ((1 << AUTO_INC_DEFAULT_NB_MAX_BITS) - 1) +// check for ADD COLUMN ... AUTO_INCREMENT query +static bool is_add_auto_increment(THD *thd) +{ + DBUG_ASSERT(thd->lex->sql_command == SQLCOM_ALTER_TABLE); + + bool add_auto_inc= false; + List_iterator_fast it(thd->lex->alter_info.create_list); + while (Create_field *f= it++) + { + if (f->flags & AUTO_INCREMENT_FLAG) + { + add_auto_inc= true; + break; + } + } + + return add_auto_inc; +} + int handler::update_auto_increment() { ulonglong nr, nb_reserved_values; @@ -3056,8 +3075,7 @@ int handler::update_auto_increment() enum enum_check_fields save_count_cuted_fields; DBUG_ENTER("handler::update_auto_increment"); - // ALTER TABLE ... ADD COLUMN ... AUTO_INCREMENT - if (thd->lex->sql_command == SQLCOM_ALTER_TABLE) + if (thd->lex->sql_command == SQLCOM_ALTER_TABLE && is_add_auto_increment(thd)) { if (table->versioned()) {