Skip to content

Commit

Permalink
MDEV-33739 Check field type of the first field in check_sequence_fiel…
Browse files Browse the repository at this point in the history
…ds()

This avoids non-integral types breaking the call of
sequence_structure().
  • Loading branch information
mariadb-YuchenPei committed Mar 26, 2024
1 parent 593392b commit aba03ee
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mysql-test/suite/sql_sequence/alter.result
Expand Up @@ -739,5 +739,14 @@ next value for s
1001
drop sequence s;
#
# MDEV-33739 Assertion `0' failed in Type_handler_typelib::max_display_length_for_field
#
CREATE SEQUENCE s1 ;
ALTER table s1 CHANGE `next_not_cached_value` next_not_cached_value SET('1','2','3','4','5','6','7','8','9','10');
ERROR HY000: Sequence 'test.s1' table structure is invalid (next_not_cached_value)
ALTER table s1 CHANGE `next_not_cached_value` next_not_cached_value bool;
ERROR HY000: Sequence 'test.s1' table structure is invalid (next_not_cached_value)
drop sequence s1;
#
# End of 11.5 test
#
12 changes: 12 additions & 0 deletions mysql-test/suite/sql_sequence/alter.test
Expand Up @@ -410,6 +410,18 @@ alter sequence s maxvalue 9432738420582397432;
show create sequence s;
select next value for s;
drop sequence s;

--echo #
--echo # MDEV-33739 Assertion `0' failed in Type_handler_typelib::max_display_length_for_field
--echo #

CREATE SEQUENCE s1 ;
--error ER_SEQUENCE_INVALID_TABLE_STRUCTURE
ALTER table s1 CHANGE `next_not_cached_value` next_not_cached_value SET('1','2','3','4','5','6','7','8','9','10');
--error ER_SEQUENCE_INVALID_TABLE_STRUCTURE
ALTER table s1 CHANGE `next_not_cached_value` next_not_cached_value bool;
drop sequence s1;

--enable_ps2_protocol

--echo #
Expand Down
6 changes: 6 additions & 0 deletions sql/sql_sequence.cc
Expand Up @@ -349,6 +349,12 @@ bool check_sequence_fields(LEX *lex, List<Create_field> *fields,
reason= my_get_err_msg(ER_SEQUENCE_TABLE_HAS_WRONG_NUMBER_OF_COLUMNS);
goto err;
}
if (!sequence_definition::is_allowed_value_type(
fields->head()->type_handler()->field_type()))
{
reason= fields->head()->field_name.str;
goto err;
}
row_structure= sequence_structure(fields->head()->type_handler());
if (field_count != array_elements(row_structure.fields)-1)
{
Expand Down

0 comments on commit aba03ee

Please sign in to comment.