From ab5ec0f346a8244e99067fab0fbd6b48f23cee9c Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Thu, 14 Dec 2017 19:11:02 +0300 Subject: [PATCH] SQL: disable truncate history on partitioned [fixes #399] --- mysql-test/suite/versioning/r/truncate.result | 9 +++++++++ mysql-test/suite/versioning/t/truncate.opt | 1 + mysql-test/suite/versioning/t/truncate.test | 12 ++++++++++++ sql/sql_delete.cc | 8 ++++++++ 4 files changed, 30 insertions(+) diff --git a/mysql-test/suite/versioning/r/truncate.result b/mysql-test/suite/versioning/r/truncate.result index 47647ade900..0390ba8b796 100644 --- a/mysql-test/suite/versioning/r/truncate.result +++ b/mysql-test/suite/versioning/r/truncate.result @@ -34,4 +34,13 @@ select * from t for system_time all; a 11 22 +### Issue #399, truncate partitioned table is now unimplemented +create or replace table t (a int) +with system versioning +engine myisam +partition by system_time ( +partition p0 versioning, +partition pn as of current_timestamp); +truncate table t to system_time current_timestamp; +ERROR 42000: The used command is not allowed with this MariaDB version drop table t; diff --git a/mysql-test/suite/versioning/t/truncate.opt b/mysql-test/suite/versioning/t/truncate.opt index c1a585b67eb..7e681a629a8 100644 --- a/mysql-test/suite/versioning/t/truncate.opt +++ b/mysql-test/suite/versioning/t/truncate.opt @@ -1 +1,2 @@ --versioning-hide=implicit +--partition diff --git a/mysql-test/suite/versioning/t/truncate.test b/mysql-test/suite/versioning/t/truncate.test index f4a20ed7af2..86880c52fd9 100644 --- a/mysql-test/suite/versioning/t/truncate.test +++ b/mysql-test/suite/versioning/t/truncate.test @@ -28,4 +28,16 @@ select * from t for system_time all; truncate table t to system_time timestamp now(6); select * from t for system_time all; +--echo ### Issue #399, truncate partitioned table is now unimplemented + +create or replace table t (a int) +with system versioning +engine myisam +partition by system_time ( + partition p0 versioning, + partition pn as of current_timestamp); + +--error ER_NOT_ALLOWED_COMMAND +truncate table t to system_time current_timestamp; + drop table t; diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 2ea2af73743..118066e7d93 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -315,6 +315,14 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, TABLE *table= table_list->table; DBUG_ASSERT(table); +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (table->part_info) + { + my_error(ER_NOT_ALLOWED_COMMAND, MYF(0)); + DBUG_RETURN(true); + } +#endif + DBUG_ASSERT(!conds); if (select_lex->vers_setup_conds(thd, table_list, &conds)) DBUG_RETURN(TRUE);