Commit ca276a0f authored by Yuchen Pei's avatar Yuchen Pei

MDEV-33169 Reset sequence used fields after check in alter sequence

The bitmap is temporarily flipped to ~0 for the sake of checking all
fields. It needs to be restored because it will be reused in second
and subsequent ps execution.
parent f7573e7a
...@@ -252,3 +252,52 @@ SELECT NEXTVAL(s); ...@@ -252,3 +252,52 @@ SELECT NEXTVAL(s);
NEXTVAL(s) NEXTVAL(s)
1 1
DROP SEQUENCE s; DROP SEQUENCE s;
#
# MDEV-33169 Alter sequence 2nd ps fails while alter sequence 2nd time (no ps) succeeds
#
create sequence s;
show create sequence s;
Table Create Table
s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM
alter sequence s maxvalue 123;
show create sequence s;
Table Create Table
s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 123 increment by 1 cache 1000 nocycle ENGINE=MyISAM
alter sequence s maxvalue 123;
show create sequence s;
Table Create Table
s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 123 increment by 1 cache 1000 nocycle ENGINE=MyISAM
drop sequence s;
create sequence s;
show create sequence s;
Table Create Table
s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM
prepare stmt from 'alter sequence s maxvalue 123';
execute stmt;
show create sequence s;
Table Create Table
s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 123 increment by 1 cache 1000 nocycle ENGINE=MyISAM
execute stmt;
show create sequence s;
Table Create Table
s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 123 increment by 1 cache 1000 nocycle ENGINE=MyISAM
deallocate prepare stmt;
drop sequence s;
create sequence s;
show create sequence s;
Table Create Table
s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM
create procedure p() alter sequence s maxvalue 123;
call p;
show create sequence s;
Table Create Table
s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 123 increment by 1 cache 1000 nocycle ENGINE=MyISAM
call p;
show create sequence s;
Table Create Table
s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 123 increment by 1 cache 1000 nocycle ENGINE=MyISAM
drop procedure p;
drop sequence s;
#
# End of 10.4 tests
#
...@@ -167,3 +167,38 @@ ALTER TABLE s ORDER BY cache_size; ...@@ -167,3 +167,38 @@ ALTER TABLE s ORDER BY cache_size;
SELECT NEXTVAL(s); SELECT NEXTVAL(s);
DROP SEQUENCE s; DROP SEQUENCE s;
--enable_ps2_protocol --enable_ps2_protocol
--echo #
--echo # MDEV-33169 Alter sequence 2nd ps fails while alter sequence 2nd time (no ps) succeeds
--echo #
create sequence s;
show create sequence s;
alter sequence s maxvalue 123;
show create sequence s;
alter sequence s maxvalue 123;
show create sequence s;
drop sequence s;
create sequence s;
show create sequence s;
prepare stmt from 'alter sequence s maxvalue 123';
execute stmt;
show create sequence s;
execute stmt;
show create sequence s;
deallocate prepare stmt;
drop sequence s;
create sequence s;
show create sequence s;
create procedure p() alter sequence s maxvalue 123;
call p;
show create sequence s;
call p;
show create sequence s;
drop procedure p;
drop sequence s;
--echo #
--echo # End of 10.4 tests
--echo #
...@@ -924,6 +924,7 @@ bool Sql_cmd_alter_sequence::execute(THD *thd) ...@@ -924,6 +924,7 @@ bool Sql_cmd_alter_sequence::execute(THD *thd)
TABLE_LIST *first_table= lex->query_tables; TABLE_LIST *first_table= lex->query_tables;
TABLE *table; TABLE *table;
sequence_definition *new_seq= lex->create_info.seq_create_info; sequence_definition *new_seq= lex->create_info.seq_create_info;
uint saved_used_fields= new_seq->used_fields;
SEQUENCE *seq; SEQUENCE *seq;
No_such_table_error_handler no_such_table_handler; No_such_table_error_handler no_such_table_handler;
DBUG_ENTER("Sql_cmd_alter_sequence::execute"); DBUG_ENTER("Sql_cmd_alter_sequence::execute");
...@@ -1043,5 +1044,6 @@ bool Sql_cmd_alter_sequence::execute(THD *thd) ...@@ -1043,5 +1044,6 @@ bool Sql_cmd_alter_sequence::execute(THD *thd)
my_ok(thd); my_ok(thd);
end: end:
new_seq->used_fields= saved_used_fields;
DBUG_RETURN(error); DBUG_RETURN(error);
} }
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