mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
SQL: unit resolution Item_field not yet accessible [fixes #398]
This commit is contained in:
@ -356,6 +356,12 @@ create or replace table t1 (a int, b int, key idx(a)) with system versioning;
|
|||||||
insert into t1 values (1, 1), (2, 2);
|
insert into t1 values (1, 1), (2, 2);
|
||||||
select * from t1 where (a, 2) in ((1, 1), (2, 2)) and b = 1;
|
select * from t1 where (a, 2) in ((1, 1), (2, 2)) and b = 1;
|
||||||
a b
|
a b
|
||||||
|
### 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;
|
||||||
|
x
|
||||||
|
select * from t1 for system_time as of now;
|
||||||
|
ERROR 42S22: Unknown column 'now' in 'where clause'
|
||||||
drop view v1;
|
drop view v1;
|
||||||
drop table t1, t2;
|
drop table t1, t2;
|
||||||
call innodb_verify_vtq(32);
|
call innodb_verify_vtq(32);
|
||||||
|
@ -242,6 +242,12 @@ create or replace table t1 (a int, b int, key idx(a)) with system versioning;
|
|||||||
insert into t1 values (1, 1), (2, 2);
|
insert into t1 values (1, 1), (2, 2);
|
||||||
select * from t1 where (a, 2) in ((1, 1), (2, 2)) and b = 1;
|
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
|
||||||
|
select * from t1 for system_time as of now;
|
||||||
|
|
||||||
drop view v1;
|
drop view v1;
|
||||||
drop table t1, t2;
|
drop table t1, t2;
|
||||||
|
|
||||||
|
@ -895,6 +895,10 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables, COND **where_expr
|
|||||||
|
|
||||||
if (vers_conditions)
|
if (vers_conditions)
|
||||||
{
|
{
|
||||||
|
/* TODO: do resolve fix_length_and_dec(), fix_fields(). This requires
|
||||||
|
storing vers_conditions as Item and make some magic related to
|
||||||
|
UNIT_TIMESTAMP/UNIT_TRX_ID at stage of fix_fields()
|
||||||
|
(this is large refactoring). */
|
||||||
vers_conditions.resolve_units(timestamps_only);
|
vers_conditions.resolve_units(timestamps_only);
|
||||||
if (timestamps_only && (vers_conditions.unit_start == UNIT_TRX_ID ||
|
if (timestamps_only && (vers_conditions.unit_start == UNIT_TRX_ID ||
|
||||||
vers_conditions.unit_end == UNIT_TRX_ID))
|
vers_conditions.unit_end == UNIT_TRX_ID))
|
||||||
|
18
sql/table.cc
18
sql/table.cc
@ -8879,15 +8879,21 @@ void vers_select_conds_t::resolve_units(bool timestamps_only)
|
|||||||
DBUG_ASSERT(start);
|
DBUG_ASSERT(start);
|
||||||
if (unit_start == UNIT_AUTO)
|
if (unit_start == UNIT_AUTO)
|
||||||
{
|
{
|
||||||
unit_start= (!timestamps_only && (start->result_type() == INT_RESULT ||
|
if (start->type() == Item::FIELD_ITEM)
|
||||||
start->result_type() == REAL_RESULT)) ?
|
unit_start= UNIT_TIMESTAMP;
|
||||||
UNIT_TRX_ID : UNIT_TIMESTAMP;
|
else
|
||||||
|
unit_start= (!timestamps_only && (start->result_type() == INT_RESULT ||
|
||||||
|
start->result_type() == REAL_RESULT)) ?
|
||||||
|
UNIT_TRX_ID : UNIT_TIMESTAMP;
|
||||||
}
|
}
|
||||||
if (end && unit_end == UNIT_AUTO)
|
if (end && unit_end == UNIT_AUTO)
|
||||||
{
|
{
|
||||||
unit_end= (!timestamps_only && (end->result_type() == INT_RESULT ||
|
if (start->type() == Item::FIELD_ITEM)
|
||||||
end->result_type() == REAL_RESULT)) ?
|
unit_start= UNIT_TIMESTAMP;
|
||||||
UNIT_TRX_ID : UNIT_TIMESTAMP;
|
else
|
||||||
|
unit_end= (!timestamps_only && (end->result_type() == INT_RESULT ||
|
||||||
|
end->result_type() == REAL_RESULT)) ?
|
||||||
|
UNIT_TRX_ID : UNIT_TIMESTAMP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user