1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

BUG#14480, attempt2: In CREATE ... SELECT ..., don't count the same field twice

when calculating table->null_fields.


mysql-test/r/create.result:
  Testcase for BUG#14480
mysql-test/t/create.test:
  Testcase for BUG#14480
sql/sql_table.cc:
  BUG#14480: For CREATE ... SELECT ... a field list passed to mysql_prepare_table() contains
  instances of create_field for both create-list and select-list. mysql_prepare_table() 
  matches elements that refer to the same field, and joins them together. When the "join"  
  is performed, both of create_field structures has already been counted in "null_fields". 
  
  This fix makes sure that "null_fields" contains the correct value after two create_field 
  structures have been joined.
This commit is contained in:
unknown
2005-11-07 09:23:43 +03:00
parent 3a5a518de4
commit 467deb4cb7
3 changed files with 138 additions and 3 deletions

View File

@ -647,8 +647,15 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
sql_field->pack_length= dup_field->pack_length;
sql_field->create_length_to_internal_length();
sql_field->decimals= dup_field->decimals;
sql_field->flags= dup_field->flags;
sql_field->unireg_check= dup_field->unireg_check;
/*
We're making one field from two, the result field will have
dup_field->flags as flags. If we've incremented null_fields
because of sql_field->flags, decrement it back.
*/
if (!(sql_field->flags & NOT_NULL_FLAG))
null_fields--;
sql_field->flags= dup_field->flags;
it2.remove(); // Remove first (create) definition
select_field_pos--;
break;