Commit 8ba06032 authored by Eugene Kosov's avatar Eugene Kosov Committed by GitHub

MDEV-14684 Assertion `table' failed in mysql_delete

SQL: disable TRUNCATE table_name TO statement for VIEWs
parent 04bed58a
......@@ -43,4 +43,16 @@ partition p0 history,
partition pn current);
truncate table t to system_time current_timestamp;
ERROR 42000: The used command is not allowed with this MariaDB version
create or replace table t (i int) with system versioning;
truncate t to system_time now();
create or replace view v as select * from t;
truncate v to system_time now();
ERROR HY000: TRUNCATE table_name TO doesn't work with VIEWs
create or replace table t (i int);
truncate t to system_time now();
ERROR HY000: System versioning required: t
create or replace view v as select * from t;
truncate v to system_time now();
ERROR HY000: TRUNCATE table_name TO doesn't work with VIEWs
drop table t;
drop view v;
......@@ -40,4 +40,18 @@ partition by system_time (
--error ER_NOT_ALLOWED_COMMAND
truncate table t to system_time current_timestamp;
create or replace table t (i int) with system versioning;
truncate t to system_time now();
create or replace view v as select * from t;
--error ER_VERS_TRUNCATE_TO_VIEW
truncate v to system_time now();
create or replace table t (i int);
--error ER_VERSIONING_REQUIRED
truncate t to system_time now();
create or replace view v as select * from t;
--error ER_VERS_TRUNCATE_TO_VIEW
truncate v to system_time now();
drop table t;
drop view v;
......@@ -7931,3 +7931,6 @@ ER_VERS_ALREADY_VERSIONED
WARN_VERS_TRT_EXPERIMENTAL
eng "Transaction-based system versioning is EXPERIMENTAL and is subject to change in future."
ER_VERS_TRUNCATE_TO_VIEW
eng "TRUNCATE table_name TO doesn't work with VIEWs"
......@@ -312,6 +312,12 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
bool truncate_history= table_list->vers_conditions;
if (truncate_history)
{
if (table_list->is_view_or_derived())
{
my_error(ER_VERS_TRUNCATE_TO_VIEW, MYF(0));
DBUG_RETURN(true);
}
TABLE *table= table_list->table;
DBUG_ASSERT(table);
......@@ -328,7 +334,8 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
DBUG_RETURN(TRUE);
// trx_sees() in InnoDB reads sys_trx_start
if (!table->versioned(VERS_TIMESTAMP)) {
if (!table->versioned(VERS_TIMESTAMP))
{
DBUG_ASSERT(table_list->vers_conditions.type == SYSTEM_TIME_BEFORE);
bitmap_set_bit(table->read_set, table->vers_end_field()->field_index);
}
......
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