Commit ab3ec013 authored by Jan Lindström's avatar Jan Lindström

MDEV-27123 : auto_increment_increment and auto_increment_offset reset to 1 in...

MDEV-27123 : auto_increment_increment and auto_increment_offset reset to 1 in current session after alter table on auto-increment column

Problem was that in ALTER TABLE execution variables were set
to 1 even when wsrep_auto_increment_control is OFF. We should
set them only when wsrep_auto_increment_control is ON.
parent 7be82a1f
connection node_2;
connection node_1;
show variables like 'auto_increment%';
Variable_name Value
auto_increment_increment 3
auto_increment_offset 3
create table t4 (c1 int primary key auto_increment) engine=innodb;
show variables like 'auto_increment%';
Variable_name Value
auto_increment_increment 3
auto_increment_offset 3
alter table t4 add (c2 varchar(50));
show variables like 'auto_increment%';
Variable_name Value
auto_increment_increment 3
auto_increment_offset 3
DROP TABLE t4;
--wsrep_auto_increment_control=OFF --auto_increment_increment=3 --auto_increment_offset=3
--source include/galera_cluster.inc
show variables like 'auto_increment%';
create table t4 (c1 int primary key auto_increment) engine=innodb;
show variables like 'auto_increment%';
alter table t4 add (c2 varchar(50));
show variables like 'auto_increment%';
DROP TABLE t4;
......@@ -486,8 +486,18 @@ bool Sql_cmd_alter_table::execute(THD *thd)
DBUG_RETURN(TRUE);
}
thd->variables.auto_increment_offset = 1;
thd->variables.auto_increment_increment = 1;
/*
It makes sense to set auto_increment_* to defaults in TOI operations.
Must be done before wsrep_TOI_begin() since Query_log_event encapsulating
TOI statement and auto inc variables for wsrep replication is constructed
there. Variables are reset back in THD::reset_for_next_command() before
processing of next command.
*/
if (wsrep_auto_increment_control)
{
thd->variables.auto_increment_offset = 1;
thd->variables.auto_increment_increment = 1;
}
}
#endif
......
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