1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-14684 Assertion `table' failed in mysql_delete

SQL: disable TRUNCATE table_name TO statement for VIEWs
This commit is contained in:
Eugene Kosov
2017-12-19 15:12:11 +03:00
committed by GitHub
parent 04bed58acf
commit 8ba06032ae
4 changed files with 37 additions and 1 deletions

View File

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

View File

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

View File

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

View File

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