Skip to content

Commit

Permalink
MDEV-14681 Bogus ER_UNSUPPORTED_EXTENSION
Browse files Browse the repository at this point in the history
  • Loading branch information
kevgs committed Dec 20, 2017
1 parent 7eff208 commit b13f1cc
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
5 changes: 5 additions & 0 deletions mysql-test/suite/versioning/r/alter.result
Original file line number Diff line number Diff line change
Expand Up @@ -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;
6 changes: 6 additions & 0 deletions mysql-test/suite/versioning/t/alter.test
Original file line number Diff line number Diff line change
Expand Up @@ -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;
22 changes: 20 additions & 2 deletions sql/handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<Create_field> 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;
Expand All @@ -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())
{
Expand Down

0 comments on commit b13f1cc

Please sign in to comment.