Commit 695c5aab authored by Aleksey Midenkov's avatar Aleksey Midenkov

SQL: error on FOR SYSTEM_TIME without any versioned tables

[fixes #88]
parent 1bedafb7
......@@ -398,6 +398,10 @@ insert into t1 values(1);
select * from t1;
A
1
create or replace table t1 (x int);
insert into t1 values (1);
select * from t1 for system_time all;
ERROR HY000: System Versioning required: `FOR SYSTEM_TIME` query
drop table t1;
call verify_vtq;
No A B C D
......
......@@ -108,7 +108,7 @@ call test_01('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_start)');
call test_02('timestamp(6)', 'myisam', 'sys_start');
call test_02('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_start)');
# Test wildcard expansion on hidden fields.
# wildcard expansion on hidden fields.
create table t1(
A int
) with system versioning engine=myisam;
......@@ -121,8 +121,12 @@ create or replace table t1(
insert into t1 values(1);
select * from t1;
create or replace table t1 (x int);
insert into t1 values (1);
--error ER_VERSIONING_REQUIRED
select * from t1 for system_time all;
drop table t1;
# End test wildcard expansion.
call verify_vtq;
......
......@@ -7487,8 +7487,8 @@ ER_UNKNOWN_VIEW 42S02
# MariaDB error numbers related to System Versioning
ER_TABLE_DOESNT_SUPPORT_SYSTEM_VERSIONING
eng "Table %`s doesn't support system versioning"
ER_VERSIONING_REQUIRED
eng "System Versioning required: %s"
ER_VERS_READONLY_FIELD
eng "System field %`s is read-only"
......
......@@ -668,9 +668,9 @@ setup_without_group(THD *thd, Ref_ptr_array ref_pointer_array,
}
static int
setup_for_system_time(THD *thd, TABLE_LIST *tables, COND **where_expr, SELECT_LEX *slex)
vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr, SELECT_LEX *slex)
{
DBUG_ENTER("setup_for_system_time");
DBUG_ENTER("vers_setup_select");
#define newx new (thd->mem_root)
TABLE_LIST *table;
......@@ -693,7 +693,14 @@ setup_for_system_time(THD *thd, TABLE_LIST *tables, COND **where_expr, SELECT_LE
}
if (versioned_tables == 0)
{
if (slex->vers_conditions.type != FOR_SYSTEM_TIME_UNSPECIFIED)
{
my_error(ER_VERSIONING_REQUIRED, MYF(0), "`FOR SYSTEM_TIME` query");
DBUG_RETURN(-1);
}
DBUG_RETURN(0);
}
/* For prepared statements we create items on statement arena,
because they must outlive execution phase for multiple executions. */
......@@ -980,7 +987,7 @@ JOIN::prepare(TABLE_LIST *tables_init,
}
/* Handle FOR SYSTEM_TIME clause. */
if (setup_for_system_time(thd, tables_list, &conds, select_lex) < 0)
if (vers_setup_select(thd, tables_list, &conds, select_lex) < 0)
DBUG_RETURN(-1);
/*
......
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