Commit 74883f5e authored by Aleksey Midenkov's avatar Aleksey Midenkov

MDEV-32082 Server crash in find_field_in_table

Attempt to resolve FOR SYSTEM_TIME expression as field for derived
table is done before derived table is fully prepared, so we fail on
assertion that table_list->table is missing.

Actually Vers_history_point::resolve_unit() is done under the call of
mysql_derived_prepare() itself (sql_derived.cc:824) and the table is
assigned later at 867.

The fix disables unit resolution for field type in FOR SYSTEM_TIME
expression as it does a little sense in any case: making historical
queries based on variable field values produces the result of multiple
time points.

fix_fields_if_needed() in resolve_units() was introduced by 46be3198
parent e53e7cd1
......@@ -444,7 +444,7 @@ create or replace table t1 (x int) with system versioning;
select * from t1 for system_time as of current_timestamp;
x
select * from t1 for system_time as of now;
ERROR 42S22: Unknown column 'now' in 'FOR SYSTEM_TIME'
ERROR HY000: Illegal parameter data type now for operation 'FOR SYSTEM_TIME'
### Issue #405, NATURAL JOIN failure
create or replace table t1 (a int) with system versioning;
create or replace table t2 (b int);
......@@ -708,3 +708,12 @@ No A B C D
32 1 1 1 1
33 1 1 1 1
34 1 1 1 1
#
# MDEV-32082 Server crash in find_field_in_table
#
create table t0 (c0 int) with system versioning;
select x0 from (
select c0 x0 from t0
) for system_time as of nowasdf deriv;
ERROR HY000: Illegal parameter data type nowasdf for operation 'FOR SYSTEM_TIME'
drop table t0;
......@@ -307,7 +307,7 @@ select * from t1 where (a, 2) in ((1, 1), (2, 2)) and b = 1;
--echo ### Issue #398, NOW is now non-magic
create or replace table t1 (x int) with system versioning;
select * from t1 for system_time as of current_timestamp;
--error ER_BAD_FIELD_ERROR
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
select * from t1 for system_time as of now;
--echo ### Issue #405, NATURAL JOIN failure
......@@ -471,4 +471,14 @@ drop tables x, x_p;
call verify_trt_dummy(34);
--echo #
--echo # MDEV-32082 Server crash in find_field_in_table
--echo #
create table t0 (c0 int) with system versioning;
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
select x0 from (
select c0 x0 from t0
) for system_time as of nowasdf deriv;
drop table t0;
-- source suite/versioning/common_finish.inc
......@@ -9965,6 +9965,11 @@ bool Vers_history_point::resolve_unit(THD *thd)
{
if (!item)
return false;
if (item->real_type() == Item::FIELD_ITEM)
{
bad_expression_data_type_error(item->full_name());
return true;
}
if (item->fix_fields_if_needed(thd, &item))
return true;
return item->this_item()->real_type_handler()->
......
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