Skip to content
/ server Public
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions mysql-test/main/type_enum.result
Original file line number Diff line number Diff line change
Expand Up @@ -2570,3 +2570,17 @@ Note 1105 Cannot use key parts with `test`.`t1`.`indexed_col` in the rewritten c
DROP TABLE t2;
DROP TABLE t1;
SET note_verbosity=DEFAULT;
#
# MDEV-39043 ENUM can be set to empty string by giving an index value as string "0"
#
set sql_mode=STRICT_ALL_TABLES;
create table t1 (a enum('Value1', 'Value2') NOT NULL DEFAULT 'Value1');
insert into t1 values ('0');
ERROR 01000: Data truncated for column 'a' at row 1
select * from t1;
a
drop table t1;
set sql_mode=default;
#
# End of 10.6 tests
#
Expand Down
15 changes: 15 additions & 0 deletions mysql-test/main/type_enum.test
Original file line number Diff line number Diff line change
Expand Up @@ -580,3 +580,18 @@ DELIMITER ;$$
--source unusable_keys_joins.inc
DROP TABLE t1;
SET note_verbosity=DEFAULT;

--echo #
--echo # MDEV-39043 ENUM can be set to empty string by giving an index value as string "0"
--echo #
set sql_mode=STRICT_ALL_TABLES;
create table t1 (a enum('Value1', 'Value2') NOT NULL DEFAULT 'Value1');
--error WARN_DATA_TRUNCATED
insert into t1 values ('0');
select * from t1;
drop table t1;
set sql_mode=default;

--echo #
--echo # End of 10.6 tests
--echo #
Expand Down
2 changes: 1 addition & 1 deletion sql/field.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9401,7 +9401,7 @@ int Field_enum::store(const char *from,size_t length,CHARSET_INFO *cs)
/* This is for reading numbers with LOAD DATA INFILE */
char *end;
tmp=(uint) cs->strntoul(from,length,10,&end,&err);
if (err || end != from+length || tmp > typelib->count)
if (err || end != from+length || !tmp || tmp > typelib->count)
{
tmp=0;
set_warning(WARN_DATA_TRUNCATED, 1);
Expand Down