summaryrefslogtreecommitdiff
path: root/sql/sql_table.cc
diff options
context:
space:
mode:
authorKarthik Kamath <karthik.kamath@oracle.com>2015-12-29 15:58:44 +0530
committerKarthik Kamath <karthik.kamath@oracle.com>2015-12-29 15:58:44 +0530
commit1ec594dd60aa3b58e7d1c686016695b5b0bc1aa1 (patch)
tree512bb849b1e359b031a759cf4b2ffa99b5da851c /sql/sql_table.cc
parent3c9ba967af3e8d2c47e7849760f018dcfc9d4d16 (diff)
downloadmariadb-git-1ec594dd60aa3b58e7d1c686016695b5b0bc1aa1.tar.gz
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.
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r--sql/sql_table.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 3f64de7eac2..7b4d08613cf 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -3081,8 +3081,31 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
else
{
/* 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->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 ?
dup_field->charset :
create_info->default_table_charset);