Skip to content

Commit aba03ee

Browse files
MDEV-33739 Check field type of the first field in check_sequence_fields()
This avoids non-integral types breaking the call of sequence_structure().
1 parent 593392b commit aba03ee

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

mysql-test/suite/sql_sequence/alter.result

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,5 +739,14 @@ next value for s
739739
1001
740740
drop sequence s;
741741
#
742+
# MDEV-33739 Assertion `0' failed in Type_handler_typelib::max_display_length_for_field
743+
#
744+
CREATE SEQUENCE s1 ;
745+
ALTER table s1 CHANGE `next_not_cached_value` next_not_cached_value SET('1','2','3','4','5','6','7','8','9','10');
746+
ERROR HY000: Sequence 'test.s1' table structure is invalid (next_not_cached_value)
747+
ALTER table s1 CHANGE `next_not_cached_value` next_not_cached_value bool;
748+
ERROR HY000: Sequence 'test.s1' table structure is invalid (next_not_cached_value)
749+
drop sequence s1;
750+
#
742751
# End of 11.5 test
743752
#

mysql-test/suite/sql_sequence/alter.test

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,18 @@ alter sequence s maxvalue 9432738420582397432;
410410
show create sequence s;
411411
select next value for s;
412412
drop sequence s;
413+
414+
--echo #
415+
--echo # MDEV-33739 Assertion `0' failed in Type_handler_typelib::max_display_length_for_field
416+
--echo #
417+
418+
CREATE SEQUENCE s1 ;
419+
--error ER_SEQUENCE_INVALID_TABLE_STRUCTURE
420+
ALTER table s1 CHANGE `next_not_cached_value` next_not_cached_value SET('1','2','3','4','5','6','7','8','9','10');
421+
--error ER_SEQUENCE_INVALID_TABLE_STRUCTURE
422+
ALTER table s1 CHANGE `next_not_cached_value` next_not_cached_value bool;
423+
drop sequence s1;
424+
413425
--enable_ps2_protocol
414426

415427
--echo #

sql/sql_sequence.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,12 @@ bool check_sequence_fields(LEX *lex, List<Create_field> *fields,
349349
reason= my_get_err_msg(ER_SEQUENCE_TABLE_HAS_WRONG_NUMBER_OF_COLUMNS);
350350
goto err;
351351
}
352+
if (!sequence_definition::is_allowed_value_type(
353+
fields->head()->type_handler()->field_type()))
354+
{
355+
reason= fields->head()->field_name.str;
356+
goto err;
357+
}
352358
row_structure= sequence_structure(fields->head()->type_handler());
353359
if (field_count != array_elements(row_structure.fields)-1)
354360
{

0 commit comments

Comments
 (0)