summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorMartin Hansson <martin.hansson@oracle.com>2011-01-12 09:55:31 +0100
committerMartin Hansson <martin.hansson@oracle.com>2011-01-12 09:55:31 +0100
commit3c5662c1951f59295a41b05274ed0be793b01843 (patch)
tree06930793ac389b84570ac6701c4ee37b3c58c77d /sql/sql_select.cc
parent0fd846bad057cc205a5b5742c0d8c61c7c73c7f6 (diff)
downloadmariadb-git-3c5662c1951f59295a41b05274ed0be793b01843.tar.gz
Bug#58207: invalid memory reads when using default column value and
tmptable needed The function DEFAULT() works by modifying the the data buffer pointers (often referred to as 'record' or 'table record') of its argument. This modification is done during name resolution (fix_fields().) Unfortunately, the same modification is done when creating a temporary table, because default values need to propagate to the new table. Fixed by skipping the pointer modification for fields that are arguments to the DEFAULT function.
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 067f3cfc95d..8cc2ec6a0f8 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -9816,7 +9816,12 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
convert_blob_length);
if (orig_type == Item::REF_ITEM && orig_modify)
((Item_ref*)orig_item)->set_result_field(result);
- if (field->field->eq_def(result))
+ /*
+ Fields that are used as arguments to the DEFAULT() function already have
+ their data pointers set to the default value during name resulotion. See
+ Item_default_value::fix_fields.
+ */
+ if (orig_type != Item::DEFAULT_VALUE_ITEM && field->field->eq_def(result))
*default_field= field->field;
return result;
}