Skip to content
Permalink
Browse files
MDEV-22805 SIGSEGV in check_fields on UPDATE
Additional case for PS protocol: UPDATE is converted to multi-update
in mysql_multi_update_prepare().
  • Loading branch information
midenok committed Oct 29, 2020
1 parent e451145 commit 27b762e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
@@ -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++);)
{

0 comments on commit 27b762e

Please sign in to comment.