MDEV-31319 Assertion const_item_cache == true failed in Item_func::fix_fields
On create table tmp as select ... we exited Item_func::fix_fields() with error. fix_fields_if_needed('foo' or 'bar') failed and we returned true, but already changed const_item_cache. So the item is in inconsistent state: fixed == false and const_item_cache == false. Now we cleanup the item before the return if Item_func::fix_fields() fails to process.
This commit is contained in:
parent
c5a8341115
commit
21a8d2c313
@ -197,3 +197,22 @@ Warnings:
|
||||
Warning 1292 Truncated incorrect DECIMAL value: 'x'
|
||||
Warning 1292 Truncated incorrect DECIMAL value: 'test'
|
||||
drop table t1;
|
||||
#
|
||||
# MDEV-31319 Assertion const_item_cache == true failed in Item_func::fix_fields
|
||||
#
|
||||
create table t (f1 int, f2 int, fv int generated always as (case user() when 'foo' or 'bar' then f1 else f2 end) virtual);
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'foo'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'bar'
|
||||
select * from t;
|
||||
f1 f2 fv
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'foo'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'bar'
|
||||
create table tmp as select * from information_schema.tables where table_name = 't';
|
||||
select * from t;
|
||||
f1 f2 fv
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'foo'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'bar'
|
||||
drop table t, tmp;
|
||||
|
@ -162,3 +162,14 @@ create table t1 (a int , b date as (1 in ('x' ,(database ()) ))) ;
|
||||
select b from t1;
|
||||
select a from t1 order by 'x' = b;
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-31319 Assertion const_item_cache == true failed in Item_func::fix_fields
|
||||
--echo #
|
||||
create table t (f1 int, f2 int, fv int generated always as (case user() when 'foo' or 'bar' then f1 else f2 end) virtual);
|
||||
select * from t;
|
||||
create table tmp as select * from information_schema.tables where table_name = 't';
|
||||
select * from t;
|
||||
|
||||
# cleanup
|
||||
drop table t, tmp;
|
||||
|
@ -353,7 +353,10 @@ Item_func::fix_fields(THD *thd, Item **ref)
|
||||
We shouldn't call fix_fields() twice, so check 'fixed' field first
|
||||
*/
|
||||
if ((*arg)->fix_fields_if_needed(thd, arg))
|
||||
{
|
||||
cleanup();
|
||||
return TRUE; /* purecov: inspected */
|
||||
}
|
||||
item= *arg;
|
||||
|
||||
if (item->maybe_null)
|
||||
@ -369,9 +372,15 @@ Item_func::fix_fields(THD *thd, Item **ref)
|
||||
}
|
||||
}
|
||||
if (check_arguments())
|
||||
{
|
||||
cleanup();
|
||||
return true;
|
||||
}
|
||||
if (fix_length_and_dec())
|
||||
{
|
||||
cleanup();
|
||||
return TRUE;
|
||||
}
|
||||
fixed= 1;
|
||||
return FALSE;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user