ERROR: bogus varattno for OUTER var: 4 (ruleutils.c:3636)
hsyuan opened this issue · 1 comments
hsyuan commented
On gpdb master with Orca on.
Repro:
create table foo(a int, b int);
create table bar(a int, b int);
create table pt(a int, b int) distributed by (a)
partition by range(b) (start(1) end(5) every(2));
explain select * from foo, pt where foo.a = pt.a and pt.b = (select max(b) from bar);
ERROR: bogus varattno for OUTER var: 4 (ruleutils.c:3636)
If I insert some data into foo, run the query, got a different error message:
insert into foo select i, i from generate_series(1,100) i;
explain select * from foo, pt where foo.a = pt.a and pt.b = (select max(b) from bar);
ERROR: bogus varno: 65000 (ruleutils.c:3720)
explain select * from foo, pt, bar where bar.a=pt.b and foo.a > pt.b;
ERROR: bogus varno: 65000 (ruleutils.c:3720)
vraghavan78 commented
All works on GPDB 5X.
vraghavan=# explain select * from foo, pt, bar where bar.a=pt.b and foo.a > pt.b;
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------
Gather Motion 3:1 (slice3; segments: 3) (cost=0.00..1324466.99 rows=1 width=24)
-> Hash Join (cost=0.00..1324466.99 rows=1 width=24)
Hash Cond: bar.a = pt.b
-> Table Scan on bar (cost=0.00..431.00 rows=1 width=8)
-> Hash (cost=1324035.99..1324035.99 rows=1 width=16)
-> Redistribute Motion 3:3 (slice2; segments: 3) (cost=0.00..1324035.99 rows=1 width=16)
Hash Key: pt.b
-> Nested Loop (cost=0.00..1324035.99 rows=1 width=16)
Join Filter: foo.a > pt.b
-> Broadcast Motion 3:3 (slice1; segments: 3) (cost=0.00..431.00 rows=1 width=8)
-> Sequence (cost=0.00..431.00 rows=1 width=8)
-> Partition Selector for pt (dynamic scan id: 1) (cost=10.00..100.00 rows=34 width=4)
Partitions selected: 2 (out of 2)
-> Dynamic Table Scan on pt (dynamic scan id: 1) (cost=0.00..431.00 rows=1 width=8)
-> Table Scan on foo (cost=0.00..431.00 rows=34 width=8)
Settings: optimizer=on
Optimizer status: PQO version 3.21.0
(17 rows)