diff options
| author | Sergei Golubchik <serg@mariadb.org> | 2022-04-19 17:09:19 +0200 |
|---|---|---|
| committer | Sergei Golubchik <serg@mariadb.org> | 2022-04-20 22:07:48 +0200 |
| commit | 5ba77222e9fe7af8ff403816b5338b18b342053c (patch) | |
| tree | 0935771c60b5092579745e50a8e47776a3e35084 /mysql-test | |
| parent | 9c5fd0f624df846686742182825d964c546fac58 (diff) | |
| download | mariadb-git-5ba77222e9fe7af8ff403816b5338b18b342053c.tar.gz | |
MDEV-21028 Server crashes in Query_arena::set_query_arena upon SELECT from view
if the view has algorithm=temptable it is not updatable,
so DEFAULT() for its fields is meaningless,
and thus it's NULL or 0/'' for NOT NULL columns.
Diffstat (limited to 'mysql-test')
| -rw-r--r-- | mysql-test/r/func_default.result | 43 | ||||
| -rw-r--r-- | mysql-test/t/func_default.test | 26 |
2 files changed, 69 insertions, 0 deletions
diff --git a/mysql-test/r/func_default.result b/mysql-test/r/func_default.result index 8721270ca1c..2b5c869ee66 100644 --- a/mysql-test/r/func_default.result +++ b/mysql-test/r/func_default.result @@ -159,5 +159,48 @@ a 10 DROP TABLE t1; # +# MDEV-21028 Server crashes in Query_arena::set_query_arena upon SELECT from view +# +create table t1 (a datetime default current_timestamp); +insert into t1 () values (),(); +create algorithm=temptable view v1 as select * from t1; +create algorithm=merge view v2 as select * from t1; +select default(a) = now() from v1; +default(a) = now() +NULL +NULL +select default(a) = now() from v2; +default(a) = now() +1 +1 +select table_name,is_updatable from information_schema.views; +table_name is_updatable +v1 NO +v2 YES +drop view v1, v2; +drop table t1; +create table t1 (v1 timestamp) select 'x'; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v1` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `x` varchar(1) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select default(v1) from (select v1 from t1) dt; +default(v1) +2001-01-01 10:20:30 +select default(v1) from (select v1 from t1 group by v1) dt; +default(v1) +0000-00-00 00:00:00 +drop table t1; +create table t1 (a text default ''); +create algorithm=temptable view v1 as select * from t1; +insert into t1 values ('a'); +select default(a) from v1; +default(a) +NULL +drop view v1; +drop table t1; +# # End of 10.2 tests # diff --git a/mysql-test/t/func_default.test b/mysql-test/t/func_default.test index cba7842c68f..f542a279478 100644 --- a/mysql-test/t/func_default.test +++ b/mysql-test/t/func_default.test @@ -140,5 +140,31 @@ SELECT a FROM t1 WHERE CASE WHEN a THEN DEFAULT(a) END IS FALSE; DROP TABLE t1; --echo # +--echo # MDEV-21028 Server crashes in Query_arena::set_query_arena upon SELECT from view +--echo # +create table t1 (a datetime default current_timestamp); +insert into t1 () values (),(); +create algorithm=temptable view v1 as select * from t1; +create algorithm=merge view v2 as select * from t1; +select default(a) = now() from v1; +select default(a) = now() from v2; +select table_name,is_updatable from information_schema.views; +drop view v1, v2; +drop table t1; + +create table t1 (v1 timestamp) select 'x'; +show create table t1; +select default(v1) from (select v1 from t1) dt; +select default(v1) from (select v1 from t1 group by v1) dt; +drop table t1; + +create table t1 (a text default ''); +create algorithm=temptable view v1 as select * from t1; +insert into t1 values ('a'); +select default(a) from v1; +drop view v1; +drop table t1; + +--echo # --echo # End of 10.2 tests --echo # |
