summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/suite/period/r/delete.result2
-rw-r--r--mysql-test/suite/period/t/delete.test3
-rw-r--r--sql/sql_delete.cc10
3 files changed, 15 insertions, 0 deletions
diff --git a/mysql-test/suite/period/r/delete.result b/mysql-test/suite/period/r/delete.result
index 451017e5340..9391014a00f 100644
--- a/mysql-test/suite/period/r/delete.result
+++ b/mysql-test/suite/period/r/delete.result
@@ -176,6 +176,8 @@ delete from t for portion of othertime from '2000-01-01' to '2018-01-01';
ERROR HY000: Period `othertime` is not found in table
delete from t for portion of system_time from '2000-01-01' to '2018-01-01';
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'of system_time from '2000-01-01' to '2018-01-01'' at line 1
+delete from t for portion of apptime from s to e;
+ERROR HY000: Expression in FOR PORTION OF must be constant
create or replace table t (id int, str text, s date, e date,
period for apptime(s,e));
insert into t values(1, 'data', '1999-01-01', '2018-12-12');
diff --git a/mysql-test/suite/period/t/delete.test b/mysql-test/suite/period/t/delete.test
index 738d77d2c19..105b974de3b 100644
--- a/mysql-test/suite/period/t/delete.test
+++ b/mysql-test/suite/period/t/delete.test
@@ -67,6 +67,9 @@ delete from t for portion of othertime from '2000-01-01' to '2018-01-01';
--error ER_PARSE_ERROR
delete from t for portion of system_time from '2000-01-01' to '2018-01-01';
+--error ER_NOT_CONSTANT_EXPRESSION
+delete from t for portion of apptime from s to e;
+
create or replace table t (id int, str text, s date, e date,
period for apptime(s,e));
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index f4cad88124f..202478eb586 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -372,6 +372,16 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
&delete_while_scanning))
DBUG_RETURN(TRUE);
+ if (table_list->has_period())
+ {
+ if (!table_list->period_conditions.start.item->const_item()
+ || !table_list->period_conditions.end.item->const_item())
+ {
+ my_error(ER_NOT_CONSTANT_EXPRESSION, MYF(0), "FOR PORTION OF");
+ DBUG_RETURN(true);
+ }
+ }
+
if (delete_history)
table->vers_write= false;