Commit 1ec594dd authored by Karthik Kamath's avatar Karthik Kamath

BUG#21902059: "CREATE TEMPORARY TABLE SELECT ..." AND BIT(1)

               COLUMNS

ANALYSIS:
=========
A valgrind error is reported when CREATE TABLE .. SELECT
involving BIT columns triggers a column type redefinition.

In general the pack_flag is set for BIT columns in
'mysql_prepare_create_table()'. However, during the above
operation, redefined column types was handled after the
special handling for BIT columns and thus pack_flag ended
up not being set correctly triggering the valgrind error.

FIX:
====
The patch fixes this problem by setting pack_flag correctly
for BIT columns in the case of column type redefinition.
parent 3c9ba967
...@@ -3081,8 +3081,31 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, ...@@ -3081,8 +3081,31 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
else else
{ {
/* Field redefined */ /* Field redefined */
/*
If we are replacing a BIT field, revert the increment
of total_uneven_bit_length that was done above.
*/
if (sql_field->sql_type == MYSQL_TYPE_BIT &&
file->ha_table_flags() & HA_CAN_BIT_FIELD)
total_uneven_bit_length-= sql_field->length & 7;
sql_field->def= dup_field->def; sql_field->def= dup_field->def;
sql_field->sql_type= dup_field->sql_type; sql_field->sql_type= dup_field->sql_type;
/*
If we are replacing a field with a BIT field, we need
to initialize pack_flag. Note that we do not need to
increment total_uneven_bit_length here as this dup_field
has already been processed.
*/
if (sql_field->sql_type == MYSQL_TYPE_BIT)
{
sql_field->pack_flag= FIELDFLAG_NUMBER;
if (!(file->ha_table_flags() & HA_CAN_BIT_FIELD))
sql_field->pack_flag|= FIELDFLAG_TREAT_BIT_AS_CHAR;
}
sql_field->charset= (dup_field->charset ? sql_field->charset= (dup_field->charset ?
dup_field->charset : dup_field->charset :
create_info->default_table_charset); create_info->default_table_charset);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment