mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
Remove an unsafe Assert, and explain join_clause_is_movable_into() better.
join_clause_is_movable_into() is approximate, in the sense that it might sometimes return "false" when actually it would be valid to push the given join clause down to the specified level. This is okay ... but there was an Assert in get_joinrel_parampathinfo() that's only safe if the answers are always exact. Comment out the Assert, and add a bunch of commentary to clarify what's going on. Per fuzz testing by Andreas Seltenreich. The added regression test is a pretty silly query, but it's based on his crasher example. Back-patch to 9.2 where the faulty logic was introduced.
This commit is contained in:
@ -2218,6 +2218,54 @@ order by 1, 2;
|
||||
4567890123456789 | 4567890123456789 | 123 | 4567890123456789 | 123
|
||||
(5 rows)
|
||||
|
||||
--
|
||||
-- regression test: check a case where join_clause_is_movable_into() gives
|
||||
-- an imprecise result
|
||||
--
|
||||
analyze pg_enum;
|
||||
explain (costs off)
|
||||
select anname, outname, enumtypid
|
||||
from
|
||||
(select pa.proname as anname, coalesce(po.proname, typname) as outname
|
||||
from pg_type t
|
||||
left join pg_proc po on po.oid = t.typoutput
|
||||
join pg_proc pa on pa.oid = t.typanalyze) ss,
|
||||
pg_enum,
|
||||
pg_type t2
|
||||
where anname = enumlabel and outname = t2.typname and enumtypid = t2.oid;
|
||||
QUERY PLAN
|
||||
-----------------------------------------------------------------------
|
||||
Nested Loop
|
||||
Join Filter: (pg_enum.enumtypid = t2.oid)
|
||||
-> Nested Loop Left Join
|
||||
-> Hash Join
|
||||
Hash Cond: ((t.typanalyze)::oid = pa.oid)
|
||||
-> Seq Scan on pg_type t
|
||||
-> Hash
|
||||
-> Hash Join
|
||||
Hash Cond: (pa.proname = pg_enum.enumlabel)
|
||||
-> Seq Scan on pg_proc pa
|
||||
-> Hash
|
||||
-> Seq Scan on pg_enum
|
||||
-> Index Scan using pg_proc_oid_index on pg_proc po
|
||||
Index Cond: (oid = (t.typoutput)::oid)
|
||||
-> Index Scan using pg_type_typname_nsp_index on pg_type t2
|
||||
Index Cond: (typname = COALESCE(po.proname, t.typname))
|
||||
(16 rows)
|
||||
|
||||
select anname, outname, enumtypid
|
||||
from
|
||||
(select pa.proname as anname, coalesce(po.proname, typname) as outname
|
||||
from pg_type t
|
||||
left join pg_proc po on po.oid = t.typoutput
|
||||
join pg_proc pa on pa.oid = t.typanalyze) ss,
|
||||
pg_enum,
|
||||
pg_type t2
|
||||
where anname = enumlabel and outname = t2.typname and enumtypid = t2.oid;
|
||||
anname | outname | enumtypid
|
||||
--------+---------+-----------
|
||||
(0 rows)
|
||||
|
||||
--
|
||||
-- Clean up
|
||||
--
|
||||
|
@ -377,6 +377,32 @@ select * from int8_tbl i1 left join (int8_tbl i2 join
|
||||
(select 123 as x) ss on i2.q1 = x) on i1.q2 = i2.q2
|
||||
order by 1, 2;
|
||||
|
||||
--
|
||||
-- regression test: check a case where join_clause_is_movable_into() gives
|
||||
-- an imprecise result
|
||||
--
|
||||
analyze pg_enum;
|
||||
explain (costs off)
|
||||
select anname, outname, enumtypid
|
||||
from
|
||||
(select pa.proname as anname, coalesce(po.proname, typname) as outname
|
||||
from pg_type t
|
||||
left join pg_proc po on po.oid = t.typoutput
|
||||
join pg_proc pa on pa.oid = t.typanalyze) ss,
|
||||
pg_enum,
|
||||
pg_type t2
|
||||
where anname = enumlabel and outname = t2.typname and enumtypid = t2.oid;
|
||||
|
||||
select anname, outname, enumtypid
|
||||
from
|
||||
(select pa.proname as anname, coalesce(po.proname, typname) as outname
|
||||
from pg_type t
|
||||
left join pg_proc po on po.oid = t.typoutput
|
||||
join pg_proc pa on pa.oid = t.typanalyze) ss,
|
||||
pg_enum,
|
||||
pg_type t2
|
||||
where anname = enumlabel and outname = t2.typname and enumtypid = t2.oid;
|
||||
|
||||
|
||||
--
|
||||
-- Clean up
|
||||
|
Reference in New Issue
Block a user