1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Fix old oversight in join removal logic.

Commit 9e7e29c75a introduced an Assert that
join removal didn't reduce the eval_at set of any PlaceHolderVar to empty.
At first glance it looks like join_is_removable ensures that's true --- but
actually, the loop in join_is_removable skips PlaceHolderVars that are not
referenced above the join due to be removed.  So, if we don't want any
empty eval_at sets, the right thing to do is to delete any now-unreferenced
PlaceHolderVars from the data structure entirely.

Per fuzz testing by Andreas Seltenreich.  Back-patch to 9.3 where the
aforesaid Assert was added.
This commit is contained in:
Tom Lane
2015-08-06 22:14:07 -04:00
parent 58e09b9024
commit bab163e121
3 changed files with 45 additions and 6 deletions

View File

@ -3862,6 +3862,22 @@ SELECT * FROM
1 | 4567890123456789 | -4567890123456789 | 4567890123456789
(5 rows)
rollback;
-- another join removal bug: we must clean up correctly when removing a PHV
begin;
create temp table uniquetbl (f1 text unique);
explain (costs off)
select t1.* from
uniquetbl as t1
left join (select *, '***'::text as d1 from uniquetbl) t2
on t1.f1 = t2.f1
left join uniquetbl t3
on t2.d1 = t3.f1;
QUERY PLAN
--------------------------
Seq Scan on uniquetbl t1
(1 row)
rollback;
-- bug #8444: we've historically allowed duplicate aliases within aliased JOINs
select * from

View File

@ -1247,6 +1247,21 @@ SELECT * FROM
rollback;
-- another join removal bug: we must clean up correctly when removing a PHV
begin;
create temp table uniquetbl (f1 text unique);
explain (costs off)
select t1.* from
uniquetbl as t1
left join (select *, '***'::text as d1 from uniquetbl) t2
on t1.f1 = t2.f1
left join uniquetbl t3
on t2.d1 = t3.f1;
rollback;
-- bug #8444: we've historically allowed duplicate aliases within aliased JOINs
select * from