Skip to content

Commit 3bfd401

Browse files
committed
Improve regression test case to avoid depending on system catalog stats.
In commit 95f4e59 I added a regression test case that examined the plan of a query on system catalogs. That isn't a terribly great idea because the catalogs tend to change from version to version, or even within a version if someone makes an unrelated regression-test change that populates the catalogs a bit differently. Usually I try to make planner test cases rely on test tables that have not changed since Berkeley days, but I got sloppy in this case because the submitted crasher example queried the catalogs and I didn't spend enough time on rewriting it. But it was a problem waiting to happen, as I was rudely reminded when I tried to port that patch into Salesforce's Postgres variant :-(. So spend a little more effort and rewrite the query to not use any system catalogs. I verified that this version still provokes the Assert if 95f4e59's code fix is reverted. I also removed the EXPLAIN output from the test, as it turns out that the assertion occurs while considering a plan that isn't the one ultimately selected anyway; so there's no value in risking any cross-platform variation in that printout. Back-patch to 9.2, like the previous patch.
1 parent 83fd922 commit 3bfd401

File tree

2 files changed

+22
-64
lines changed

2 files changed

+22
-64
lines changed

src/test/regress/expected/join.out

Lines changed: 13 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,51 +2186,21 @@ select aa, bb, unique1, unique1
21862186

21872187
--
21882188
-- regression test: check a case where join_clause_is_movable_into() gives
2189-
-- an imprecise result
2189+
-- an imprecise result, causing an assertion failure
21902190
--
2191-
analyze pg_enum;
2192-
explain (costs off)
2193-
select anname, outname, enumtypid
2194-
from
2195-
(select pa.proname as anname, coalesce(po.proname, typname) as outname
2196-
from pg_type t
2197-
left join pg_proc po on po.oid = t.typoutput
2198-
join pg_proc pa on pa.oid = t.typanalyze) ss,
2199-
pg_enum,
2200-
pg_type t2
2201-
where anname = enumlabel and outname = t2.typname and enumtypid = t2.oid;
2202-
QUERY PLAN
2203-
-----------------------------------------------------------------------
2204-
Nested Loop
2205-
Join Filter: (pg_enum.enumtypid = t2.oid)
2206-
-> Nested Loop Left Join
2207-
-> Hash Join
2208-
Hash Cond: ((t.typanalyze)::oid = pa.oid)
2209-
-> Seq Scan on pg_type t
2210-
-> Hash
2211-
-> Hash Join
2212-
Hash Cond: (pa.proname = pg_enum.enumlabel)
2213-
-> Seq Scan on pg_proc pa
2214-
-> Hash
2215-
-> Seq Scan on pg_enum
2216-
-> Index Scan using pg_proc_oid_index on pg_proc po
2217-
Index Cond: (oid = (t.typoutput)::oid)
2218-
-> Index Scan using pg_type_typname_nsp_index on pg_type t2
2219-
Index Cond: (typname = COALESCE(po.proname, t.typname))
2220-
(16 rows)
2221-
2222-
select anname, outname, enumtypid
2191+
select count(*)
22232192
from
2224-
(select pa.proname as anname, coalesce(po.proname, typname) as outname
2225-
from pg_type t
2226-
left join pg_proc po on po.oid = t.typoutput
2227-
join pg_proc pa on pa.oid = t.typanalyze) ss,
2228-
pg_enum,
2229-
pg_type t2
2230-
where anname = enumlabel and outname = t2.typname and enumtypid = t2.oid;
2231-
anname | outname | enumtypid
2232-
--------+---------+-----------
2233-
(0 rows)
2193+
(select t3.tenthous as x1, coalesce(t1.stringu1, t2.stringu1) as x2
2194+
from tenk1 t1
2195+
left join tenk1 t2 on t1.unique1 = t2.unique1
2196+
join tenk1 t3 on t1.unique2 = t3.unique2) ss,
2197+
tenk1 t4,
2198+
tenk1 t5
2199+
where t4.thousand = t5.unique1 and ss.x1 = t4.tenthous and ss.x2 = t5.stringu1;
2200+
count
2201+
-------
2202+
1000
2203+
(1 row)
22342204

22352205
--
22362206
-- Clean up

src/test/regress/sql/join.sql

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -367,29 +367,17 @@ select aa, bb, unique1, unique1
367367

368368
--
369369
-- regression test: check a case where join_clause_is_movable_into() gives
370-
-- an imprecise result
370+
-- an imprecise result, causing an assertion failure
371371
--
372-
analyze pg_enum;
373-
explain (costs off)
374-
select anname, outname, enumtypid
375-
from
376-
(select pa.proname as anname, coalesce(po.proname, typname) as outname
377-
from pg_type t
378-
left join pg_proc po on po.oid = t.typoutput
379-
join pg_proc pa on pa.oid = t.typanalyze) ss,
380-
pg_enum,
381-
pg_type t2
382-
where anname = enumlabel and outname = t2.typname and enumtypid = t2.oid;
383-
384-
select anname, outname, enumtypid
372+
select count(*)
385373
from
386-
(select pa.proname as anname, coalesce(po.proname, typname) as outname
387-
from pg_type t
388-
left join pg_proc po on po.oid = t.typoutput
389-
join pg_proc pa on pa.oid = t.typanalyze) ss,
390-
pg_enum,
391-
pg_type t2
392-
where anname = enumlabel and outname = t2.typname and enumtypid = t2.oid;
374+
(select t3.tenthous as x1, coalesce(t1.stringu1, t2.stringu1) as x2
375+
from tenk1 t1
376+
left join tenk1 t2 on t1.unique1 = t2.unique1
377+
join tenk1 t3 on t1.unique2 = t3.unique2) ss,
378+
tenk1 t4,
379+
tenk1 t5
380+
where t4.thousand = t5.unique1 and ss.x1 = t4.tenthous and ss.x2 = t5.stringu1;
393381

394382

395383
--

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy