mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
MDEV-3988 fix.
Subquery turned into constant too late to be excluded from grouping list so test for constant added to the create_temp_table().
This commit is contained in:
parent
12bf6fe858
commit
a716b06167
3 changed files with 42 additions and 0 deletions
|
@ -380,4 +380,22 @@ select 1 from t1 where 1 like (select 1 from t1 where 1 <=> (select 1 from t1 gr
|
|||
1
|
||||
1
|
||||
drop table t1;
|
||||
#
|
||||
# MDEV-3988 crash in create_tmp_table
|
||||
#
|
||||
drop table if exists `t1`,`t2`;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 't1'
|
||||
Note 1051 Unknown table 't2'
|
||||
create table `t1`(`a` char(1) character set utf8)engine=innodb;
|
||||
create table `t2`(`b` char(1) character set utf8)engine=memory;
|
||||
select distinct (select 1 from `t2` where `a`) `d2` from `t1`;
|
||||
d2
|
||||
select distinct (select 1 from `t2` where `a`) `d2`, a from `t1`;
|
||||
d2 a
|
||||
select distinct a, (select 1 from `t2` where `a`) `d2` from `t1`;
|
||||
a d2
|
||||
select distinct (1 + (select 1 from `t2` where `a`)) `d2` from `t1`;
|
||||
d2
|
||||
drop table t1,t2;
|
||||
set optimizer_switch=@subselect_innodb_tmp;
|
||||
|
|
|
@ -368,4 +368,18 @@ select 1 from t1 where 1 like (select 1 from t1 where 1 <=> (select 1 from t1 gr
|
|||
drop table t1;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-3988 crash in create_tmp_table
|
||||
--echo #
|
||||
|
||||
drop table if exists `t1`,`t2`;
|
||||
create table `t1`(`a` char(1) character set utf8)engine=innodb;
|
||||
create table `t2`(`b` char(1) character set utf8)engine=memory;
|
||||
select distinct (select 1 from `t2` where `a`) `d2` from `t1`;
|
||||
select distinct (select 1 from `t2` where `a`) `d2`, a from `t1`;
|
||||
select distinct a, (select 1 from `t2` where `a`) `d2` from `t1`;
|
||||
select distinct (1 + (select 1 from `t2` where `a`)) `d2` from `t1`;
|
||||
|
||||
drop table t1,t2;
|
||||
|
||||
set optimizer_switch=@subselect_innodb_tmp;
|
||||
|
|
|
@ -13797,10 +13797,20 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
|
|||
|
||||
if (group)
|
||||
{
|
||||
ORDER **prev= &group;
|
||||
if (!param->quick_group)
|
||||
group=0; // Can't use group key
|
||||
else for (ORDER *tmp=group ; tmp ; tmp=tmp->next)
|
||||
{
|
||||
/* Exclude found constant from the list */
|
||||
if ((*tmp->item)->const_item())
|
||||
{
|
||||
*prev= tmp->next;
|
||||
param->group_parts--;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
prev= &(tmp->next);
|
||||
/*
|
||||
marker == 4 means two things:
|
||||
- store NULLs in the key, and
|
||||
|
|
Loading…
Reference in a new issue