summaryrefslogtreecommitdiff
path: root/sql/sql_table.cc
diff options
context:
space:
mode:
authorunknown <sergefp@mysql.com>2005-11-07 09:23:43 +0300
committerunknown <sergefp@mysql.com>2005-11-07 09:23:43 +0300
commit467deb4cb7aeb456086838cadcdf10b25b667a36 (patch)
tree43568722102eea9419ddf527772823b778977743 /sql/sql_table.cc
parent3a5a518de42c8c23b7b80d1ae716424e23748463 (diff)
downloadmariadb-git-467deb4cb7aeb456086838cadcdf10b25b667a36.tar.gz
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.
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r--sql/sql_table.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index dcbc2018b49..40777682251 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -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;