Commit 27b762e2 authored by Aleksey Midenkov's avatar Aleksey Midenkov

MDEV-22805 SIGSEGV in check_fields on UPDATE

Additional case for PS protocol: UPDATE is converted to multi-update
in mysql_multi_update_prepare().
parent e451145a
......@@ -299,6 +299,9 @@ CREATE TABLE t1 (a INT, b DATE, c DATE, PERIOD FOR APPTIME(b, c));
INSERT INTO t1 VALUES(1, '1999-01-01', '2018-12-12');
UPDATE t1 FOR PORTION OF APPTIME FROM (SELECT '1999-01-01' FROM t1 WHERE a=2) TO '2018-01-01' SET a = 100;
ERROR 42000: This version of MariaDB doesn't yet support 'updating and querying the same temporal periods table'
set @tmp= "UPDATE t1 FOR PORTION OF APPTIME FROM (SELECT '1999-01-01' FROM t1 WHERE a=2) TO '2018-01-01' SET a = 100";
execute immediate @tmp;
ERROR 42000: This version of MariaDB doesn't yet support 'updating and querying the same temporal periods table'
CREATE VIEW v1 AS SELECT * FROM t1;
UPDATE v1 FOR PORTION OF APPTIME FROM (SELECT '1999-01-01' FROM t1 WHERE a=2) TO '2018-01-01' SET a = 100;
ERROR 42S02: 'v1' is a view
......
......@@ -192,8 +192,12 @@ CREATE TABLE t1 (a INT, b DATE, c DATE, PERIOD FOR APPTIME(b, c));
INSERT INTO t1 VALUES(1, '1999-01-01', '2018-12-12');
# Without a patch the following statement crashs a server built in debug mode
let $stmt= UPDATE t1 FOR PORTION OF APPTIME FROM (SELECT '1999-01-01' FROM t1 WHERE a=2) TO '2018-01-01' SET a = 100;
--error ER_NOT_SUPPORTED_YET
UPDATE t1 FOR PORTION OF APPTIME FROM (SELECT '1999-01-01' FROM t1 WHERE a=2) TO '2018-01-01' SET a = 100;
eval $stmt;
eval set @tmp= "$stmt";
--error ER_NOT_SUPPORTED_YET
execute immediate @tmp;
CREATE VIEW v1 AS SELECT * FROM t1;
--error ER_IT_IS_A_VIEW
......
......@@ -190,6 +190,13 @@ static bool check_fields(THD *thd, TABLE_LIST *table, List<Item> &items,
my_error(ER_IT_IS_A_VIEW, MYF(0), table->table_name.str);
return TRUE;
}
if (thd->lex->sql_command == SQLCOM_UPDATE_MULTI)
{
my_error(ER_NOT_SUPPORTED_YET, MYF(0),
"updating and querying the same temporal periods table");
return true;
}
DBUG_ASSERT(thd->lex->sql_command == SQLCOM_UPDATE);
for (List_iterator_fast<Item> it(items); (item=it++);)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment