mirror of
https://github.com/MariaDB/server.git
synced 2025-09-03 20:43:11 +03:00
fixed staistic of subquery if outer field resolved in merged view (BUG#5247)
This commit is contained in:
@@ -1230,3 +1230,11 @@ c
|
||||
<EFBFBD>
|
||||
drop view v<>;
|
||||
drop table t<>;
|
||||
create table t1 (a int, b int);
|
||||
insert into t1 values (1,2), (1,3), (2,4), (2,5), (3,10);
|
||||
create view v1(c) as select a+1 from t1 where b >= 4;
|
||||
select c from v1 where exists (select * from t1 where a=2 and b=c);
|
||||
c
|
||||
4
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
|
@@ -1178,3 +1178,13 @@ insert into v
|
||||
select * from v<>;
|
||||
drop view v<>;
|
||||
drop table t<>;
|
||||
|
||||
#
|
||||
# problem with used_tables() of outer reference resolved in VIEW
|
||||
#
|
||||
create table t1 (a int, b int);
|
||||
insert into t1 values (1,2), (1,3), (2,4), (2,5), (3,10);
|
||||
create view v1(c) as select a+1 from t1 where b >= 4;
|
||||
select c from v1 where exists (select * from t1 where a=2 and b=c);
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
|
24
sql/item.cc
24
sql/item.cc
@@ -1302,11 +1302,21 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
|
||||
table_list, ref,
|
||||
0, 1)) != not_found_field)
|
||||
{
|
||||
if (tmp && tmp != view_ref_found)
|
||||
if (tmp)
|
||||
{
|
||||
if (tmp != view_ref_found)
|
||||
{
|
||||
prev_subselect_item->used_tables_cache|= tmp->table->map;
|
||||
prev_subselect_item->const_item_cache= 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
prev_subselect_item->used_tables_cache|=
|
||||
(*ref)->used_tables();
|
||||
prev_subselect_item->const_item_cache&=
|
||||
(*ref)->const_item();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (sl->resolve_mode == SELECT_LEX::SELECT_MODE &&
|
||||
@@ -2029,11 +2039,21 @@ bool Item_ref::fix_fields(THD *thd, TABLE_LIST *tables, Item **reference)
|
||||
table_list, reference,
|
||||
0, 1)) != not_found_field)
|
||||
{
|
||||
if (tmp && tmp != view_ref_found)
|
||||
if (tmp)
|
||||
{
|
||||
if (tmp != view_ref_found)
|
||||
{
|
||||
prev_subselect_item->used_tables_cache|= tmp->table->map;
|
||||
prev_subselect_item->const_item_cache= 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
prev_subselect_item->used_tables_cache|=
|
||||
(*reference)->used_tables();
|
||||
prev_subselect_item->const_item_cache&=
|
||||
(*reference)->const_item();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user