Skip to content

Commit 27b762e

Browse files
committed
MDEV-22805 SIGSEGV in check_fields on UPDATE
Additional case for PS protocol: UPDATE is converted to multi-update in mysql_multi_update_prepare().
1 parent e451145 commit 27b762e

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

mysql-test/suite/period/r/update.result

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,9 @@ CREATE TABLE t1 (a INT, b DATE, c DATE, PERIOD FOR APPTIME(b, c));
299299
INSERT INTO t1 VALUES(1, '1999-01-01', '2018-12-12');
300300
UPDATE t1 FOR PORTION OF APPTIME FROM (SELECT '1999-01-01' FROM t1 WHERE a=2) TO '2018-01-01' SET a = 100;
301301
ERROR 42000: This version of MariaDB doesn't yet support 'updating and querying the same temporal periods table'
302+
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";
303+
execute immediate @tmp;
304+
ERROR 42000: This version of MariaDB doesn't yet support 'updating and querying the same temporal periods table'
302305
CREATE VIEW v1 AS SELECT * FROM t1;
303306
UPDATE v1 FOR PORTION OF APPTIME FROM (SELECT '1999-01-01' FROM t1 WHERE a=2) TO '2018-01-01' SET a = 100;
304307
ERROR 42S02: 'v1' is a view

mysql-test/suite/period/t/update.test

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,12 @@ CREATE TABLE t1 (a INT, b DATE, c DATE, PERIOD FOR APPTIME(b, c));
192192
INSERT INTO t1 VALUES(1, '1999-01-01', '2018-12-12');
193193

194194
# Without a patch the following statement crashs a server built in debug mode
195+
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;
195196
--error ER_NOT_SUPPORTED_YET
196-
UPDATE t1 FOR PORTION OF APPTIME FROM (SELECT '1999-01-01' FROM t1 WHERE a=2) TO '2018-01-01' SET a = 100;
197+
eval $stmt;
198+
eval set @tmp= "$stmt";
199+
--error ER_NOT_SUPPORTED_YET
200+
execute immediate @tmp;
197201

198202
CREATE VIEW v1 AS SELECT * FROM t1;
199203
--error ER_IT_IS_A_VIEW

sql/sql_update.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,13 @@ static bool check_fields(THD *thd, TABLE_LIST *table, List<Item> &items,
190190
my_error(ER_IT_IS_A_VIEW, MYF(0), table->table_name.str);
191191
return TRUE;
192192
}
193+
if (thd->lex->sql_command == SQLCOM_UPDATE_MULTI)
194+
{
195+
my_error(ER_NOT_SUPPORTED_YET, MYF(0),
196+
"updating and querying the same temporal periods table");
197+
198+
return true;
199+
}
193200
DBUG_ASSERT(thd->lex->sql_command == SQLCOM_UPDATE);
194201
for (List_iterator_fast<Item> it(items); (item=it++);)
195202
{

0 commit comments

Comments
 (0)