summaryrefslogtreecommitdiff
path: root/sql/sql_delete.cc
diff options
context:
space:
mode:
authorNayuta Yanagisawa <nayuta.yanagisawa@gmail.com>2020-10-11 12:26:38 +0000
committerNikita Malyavin <nikitamalyavin@gmail.com>2020-10-13 00:40:32 +1000
commitae825436c7052b9cf791017ff8963c662d1f625e (patch)
treef9c06ffc75d09766b9b5aaf86785cbb56e4eff61 /sql/sql_delete.cc
parentc2ac0ce1f02e3ae2b1de5c07ba40bed25c30dc40 (diff)
downloadmariadb-git-bb-10.4-MDEV-22596.tar.gz
MDEV-22596: Check if deletion period is specified by constantbb-10.4-MDEV-22596
DELETE...FOR PORTION OF... statement accepted non-constant FROM...TO clause. This contradicts the documentation and is inconsistent with the behavior of UPDATE statement. Thus, we add a validation that checks if a given deletion period is specified by constant.
Diffstat (limited to 'sql/sql_delete.cc')
-rw-r--r--sql/sql_delete.cc10
1 files changed, 10 insertions, 0 deletions
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;