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 46be31982a
This commit is contained in:
Aleksey Midenkov 2023-11-09 16:26:11 +03:00
commit 74883f5e2f
3 changed files with 26 additions and 2 deletions

View file

@ -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;

View file

@ -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