mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 10:14:19 +01:00
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.
This commit is contained in:
parent
9c5fd0f624
commit
5ba77222e9
3 changed files with 71 additions and 1 deletions
|
@ -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
|
||||
#
|
||||
|
|
|
@ -139,6 +139,32 @@ FROM t1;
|
|||
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 #
|
||||
|
|
|
@ -16333,7 +16333,8 @@ Field *create_tmp_field_from_field(THD *thd, Field *org_field,
|
|||
table->s->db_create_options|= HA_OPTION_PACK_RECORD;
|
||||
else if (org_field->type() == FIELD_TYPE_DOUBLE)
|
||||
((Field_double *) new_field)->not_fixed= TRUE;
|
||||
new_field->vcol_info= 0;
|
||||
new_field->vcol_info= new_field->default_value=
|
||||
new_field->check_constraint= 0;
|
||||
new_field->cond_selectivity= 1.0;
|
||||
new_field->next_equal_field= NULL;
|
||||
new_field->option_list= NULL;
|
||||
|
|
Loading…
Add table
Reference in a new issue