summaryrefslogtreecommitdiff
path: root/sql/sql_insert.cc
diff options
context:
space:
mode:
authorNikita Malyavin <nikitamalyavin@gmail.com>2020-03-17 02:59:11 +1000
committerSergei Golubchik <serg@mariadb.org>2020-03-31 17:42:34 +0200
commit244ff3e5a09eb1b4b3d4bc75371260550a47f576 (patch)
tree985147d3183c5d9d399e56cc452055eb23fc0fe2 /sql/sql_insert.cc
parent62e7ad2bbcf89f4a254be0bfbfcbb437f14e6e78 (diff)
downloadmariadb-git-244ff3e5a09eb1b4b3d4bc75371260550a47f576.tar.gz
forbid REPLACE/ODKU on tables containing WITHOUT OVERLAPS
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r--sql/sql_insert.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 5de2cc6d539..c1e7d3bde79 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -1410,6 +1410,33 @@ static bool check_view_insertability(THD * thd, TABLE_LIST *view)
}
+/**
+ TODO remove when MDEV-17395 will be closed
+
+ Checks if REPLACE or ON DUPLICATE UPDATE was executed on table containing
+ WITHOUT OVERLAPS key.
+
+ @return
+ 0 if no error
+ ER_NOT_SUPPORTED_YET if the above condidion was met
+ */
+int check_duplic_insert_without_overlaps(THD *thd, TABLE *table,
+ enum_duplicates duplic)
+{
+ if (duplic == DUP_REPLACE || duplic == DUP_UPDATE)
+ {
+ for (uint k = 0; k < table->s->keys; k++)
+ {
+ if (table->key_info[k].without_overlaps)
+ {
+ my_error(ER_NOT_SUPPORTED_YET, MYF(0), "WITHOUT OVERLAPS");
+ return ER_NOT_SUPPORTED_YET;
+ }
+ }
+ }
+ return 0;
+}
+
/*
Check if table can be updated
@@ -1607,6 +1634,9 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
if (!table)
table= table_list->table;
+ if (check_duplic_insert_without_overlaps(thd, table, duplic) != 0)
+ DBUG_RETURN(true);
+
if (table->versioned(VERS_TIMESTAMP) && duplic == DUP_REPLACE)
{
// Additional memory may be required to create historical items.