Skip to content

Commit 19896d4

Browse files
author
Alexey Botchkov
committed
MDEV-10274 Bundling insert with create statement for table with unsigned Decimal primary key issues warning 1194.
Flags are important for key_length calculations, so them should be set before it, not after.
1 parent 2f6fede commit 19896d4

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

mysql-test/r/create.result

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2498,4 +2498,11 @@ end|
24982498
create table t1 as select f1();
24992499
ERROR 42S02: Table 'test.t1' doesn't exist
25002500
drop function f1;
2501+
#
2502+
# MDEV-10274 Bundling insert with create statement
2503+
# for table with unsigned Decimal primary key issues warning 1194
2504+
#
2505+
create table t1(ID decimal(2,1) unsigned NOT NULL, PRIMARY KEY (ID))engine=memory
2506+
select 2.1 ID;
2507+
drop table t1;
25012508
End of 5.5 tests

mysql-test/t/create.test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2081,4 +2081,13 @@ DELIMITER ;|
20812081
create table t1 as select f1();
20822082
drop function f1;
20832083

2084+
--echo #
2085+
--echo # MDEV-10274 Bundling insert with create statement
2086+
--echo # for table with unsigned Decimal primary key issues warning 1194
2087+
--echo #
2088+
2089+
create table t1(ID decimal(2,1) unsigned NOT NULL, PRIMARY KEY (ID))engine=memory
2090+
select 2.1 ID;
2091+
drop table t1;
2092+
20842093
--echo End of 5.5 tests

sql/sql_table.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3167,7 +3167,6 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
31673167
sql_field->pack_length= dup_field->pack_length;
31683168
sql_field->key_length= dup_field->key_length;
31693169
sql_field->decimals= dup_field->decimals;
3170-
sql_field->create_length_to_internal_length();
31713170
sql_field->unireg_check= dup_field->unireg_check;
31723171
/*
31733172
We're making one field from two, the result field will have
@@ -3177,6 +3176,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
31773176
if (!(sql_field->flags & NOT_NULL_FLAG))
31783177
null_fields--;
31793178
sql_field->flags= dup_field->flags;
3179+
sql_field->create_length_to_internal_length();
31803180
sql_field->interval= dup_field->interval;
31813181
sql_field->vcol_info= dup_field->vcol_info;
31823182
sql_field->stored_in_db= dup_field->stored_in_db;

0 commit comments

Comments
 (0)