Tom Lane wrote:
The patch I submitted to implement this, hits bogus varno:65001 in get_variable when I explain the following query from the aggregates.sql regression test.In principle it could look something like select ten, sum(distinct four) from onek a group by ten having exists (select 1 from onek b where sum(distinct a.four) = b.four); The explain without the subplan argument-patch shows regression=# explain verbose select ten, sum(distinct four) from onek a group by ten having exists (select 1 from onek b where sum(distinct a.four) = b.four); QUERY PLAN ------------------------------------------------------------------------------ GroupAggregate (cost=197.83..216.52 rows=10 width=8) Output: a.ten, sum(DISTINCT a.four) Filter: (alternatives: SubPlan 1 or hashed SubPlan 2) -> Sort (cost=197.83..200.33 rows=1000 width=8) Output: a.ten, a.four Sort Key: a.ten -> Seq Scan on public.onek a (cost=0.00..148.00 rows=1000 width=8) Output: a.ten, a.four SubPlan 1 -> Seq Scan on public.onek b (cost=0.00..150.50 rows=250 width=0) Filter: ($0 = b.four) SubPlan 2 -> Seq Scan on public.onek b (cost=0.00..148.00 rows=1000 width=4) Output: b.four (14 rows) The subplan argument list contains a aggref node, with a var argument that has the 65001 varno. Apparently the OUTER varno is set by search_indexed_tlist_for_var and it seems like correct behaviour, see stack trace below. I'm unsure what is a good approach to solve this problem: let get_variable not give an error in this case? regards, Yeb Havinga #0 search_indexed_tlist_for_var (var=0xe32dc0, itlist=0xe67290, newvarno=65001, rtoffset=0) at setrefs.c:1568 #1 0x0000000000697581 in fix_upper_expr_mutator (node=0xe32dc0, context=0x7fffabcde850) at setrefs.c:1853 #2 0x0000000000697529 in fix_upper_expr (glob=0xe77178, node=0xe32dc0, subplan_itlist=0xe67290, rtoffset=0) at setrefs.c:1839 #3 0x0000000000696b6e in set_upper_references (glob=0xe77178, plan=0xe66f80, rtoffset=0) postgres=# explain select oid::int + 1,(select oid from pg_class a where a.oid = b.relfilenode and a.relnamespace = b.relnamespace) from pg_class b; |
- Re: [HACKERS] parallelizing subplan... Mark Kirkwood
- Re: [HACKERS] parallelizing subplan... Dimitri Fontaine
- Re: [HACKERS] parallelizing subplan... Greg Stark
- Re: [HACKERS] explain and PARAM_EXEC Tom Lane
- Re: [HACKERS] explain and PARAM_EXE... Dimitri Fontaine
- Re: [HACKERS] explain and PARAM_EXEC Greg Stark
- Re: [HACKERS] explain and PARAM_EXEC Robert Haas
- Re: [HACKERS] explain and PARAM_EXEC Tom Lane
- Re: [HACKERS] explain and PARAM_EXEC Jaime Casanova
- Re: [HACKERS] explain and PARAM_EXEC Yeb Havinga
- Re: [HACKERS] explain and PARAM_EXEC Yeb Havinga
- Re: [HACKERS] explain and PARAM_EXEC Tom Lane
- Re: [HACKERS] explain and PARAM_EXEC Yeb Havinga
- Re: [HACKERS] explain and PARAM_EXEC Yeb Havinga