diff options
-rw-r--r-- | mysql-test/suite/period/r/update.result | 12 | ||||
-rw-r--r-- | mysql-test/suite/period/t/update.test | 18 | ||||
-rw-r--r-- | sql/sql_parse.cc | 5 | ||||
-rw-r--r-- | sql/sql_update.cc | 8 |
4 files changed, 43 insertions, 0 deletions
diff --git a/mysql-test/suite/period/r/update.result b/mysql-test/suite/period/r/update.result index 05d1a2eb6d3..662db611106 100644 --- a/mysql-test/suite/period/r/update.result +++ b/mysql-test/suite/period/r/update.result @@ -281,3 +281,15 @@ create table t1 (s date, e date, period for app(s,e), f varchar(8)) engine=aria insert into t1 values ('2024-05-13','2026-03-25','foo'); update t1 for portion of app from '2024-04-02' to '2026-03-15' set f = 'bar'; drop table t1; +# +# MDEV-22805 SIGSEGV in check_fields on UPDATE (optimized builds) | Assertion `thd->lex->sql_command == SQLCOM_UPDATE' failed. +# +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' +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 +DROP VIEW v1; +DROP TABLE t1; diff --git a/mysql-test/suite/period/t/update.test b/mysql-test/suite/period/t/update.test index 0f54dd80eec..d4213752b14 100644 --- a/mysql-test/suite/period/t/update.test +++ b/mysql-test/suite/period/t/update.test @@ -173,3 +173,21 @@ update t1 for portion of app from '2024-04-02' to '2026-03-15' set f = 'bar'; # cleanup drop table t1; + +--echo # +--echo # MDEV-22805 SIGSEGV in check_fields on UPDATE (optimized builds) | Assertion `thd->lex->sql_command == SQLCOM_UPDATE' failed. +--echo # +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 +--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; + +CREATE VIEW v1 AS SELECT * FROM t1; +--error ER_IT_IS_A_VIEW +UPDATE v1 FOR PORTION OF APPTIME FROM (SELECT '1999-01-01' FROM t1 WHERE a=2) TO '2018-01-01' SET a = 100; + +DROP VIEW v1; +DROP TABLE t1;
\ No newline at end of file diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 909cb245b2e..400b6d70273 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4369,6 +4369,11 @@ mysql_execute_command(THD *thd) /* mysql_update return 2 if we need to switch to multi-update */ if (up_result != 2) break; + if (thd->lex->period_conditions.is_set()) + { + DBUG_ASSERT(0); // Should never happen + goto error; + } } /* fall through */ case SQLCOM_UPDATE_MULTI: diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 2095f99d1ac..4c90d5d4221 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -420,6 +420,14 @@ int mysql_update(THD *thd, DBUG_PRINT("info", ("Switch to multi-update")); /* pass counter value */ thd->lex->table_count= table_count; + if (thd->lex->period_conditions.is_set()) + { + my_error(ER_NOT_SUPPORTED_YET, MYF(0), + "updating and querying the same temporal periods table"); + + DBUG_RETURN(1); + } + /* convert to multiupdate */ DBUG_RETURN(2); } |