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.
This commit is contained in:
parent
5bd50b80a7
commit
fc42cbaca3
@ -164,5 +164,16 @@ a b
|
||||
2 NULL
|
||||
DROP TABLE t1, t2, t3, t4, t5;
|
||||
#
|
||||
# Bug#58207: invalid memory reads when using default column value and
|
||||
# tmptable needed
|
||||
#
|
||||
CREATE TABLE t(a VARCHAR(245) DEFAULT
|
||||
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
|
||||
INSERT INTO t VALUES (''),(''),(''),(''),(''),(''),(''),(''),(''),(''),('');
|
||||
SELECT * FROM (SELECT default(a) FROM t GROUP BY a) d;
|
||||
default(a)
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
DROP TABLE t;
|
||||
#
|
||||
# End of 5.1 tests.
|
||||
#
|
||||
|
@ -136,6 +136,16 @@ SELECT * FROM t1 WHERE NULL NOT IN ( SELECT c FROM t2 WHERE c = 1 AND c <> 1 );
|
||||
|
||||
DROP TABLE t1, t2, t3, t4, t5;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#58207: invalid memory reads when using default column value and
|
||||
--echo # tmptable needed
|
||||
--echo #
|
||||
CREATE TABLE t(a VARCHAR(245) DEFAULT
|
||||
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
|
||||
INSERT INTO t VALUES (''),(''),(''),(''),(''),(''),(''),(''),(''),(''),('');
|
||||
SELECT * FROM (SELECT default(a) FROM t GROUP BY a) d;
|
||||
DROP TABLE t;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # End of 5.1 tests.
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user