Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 6a0779a

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 94d626f commit 6a0779a

File tree

2 files changed

+22
-64
lines changed

2 files changed

+22
-64
lines changed

src/test/regress/expected/join.out

+13-43
Original file line numberDiff line numberDiff line change
@@ -2220,51 +2220,21 @@ order by 1, 2;
22202220

22212221
--
22222222
-- regression test: check a case where join_clause_is_movable_into() gives
2223-
-- an imprecise result
2223+
-- an imprecise result, causing an assertion failure
22242224
--
2225-
analyze pg_enum;
2226-
explain (costs off)
2227-
select anname, outname, enumtypid
2225+
select count(*)
22282226
from
2229-
(select pa.proname as anname, coalesce(po.proname, typname) as outname
2230-
from pg_type t
2231-
left join pg_proc po on po.oid = t.typoutput
2232-
join pg_proc pa on pa.oid = t.typanalyze) ss,
2233-
pg_enum,
2234-
pg_type t2
2235-
where anname = enumlabel and outname = t2.typname and enumtypid = t2.oid;
2236-
QUERY PLAN
2237-
-----------------------------------------------------------------------
2238-
Nested Loop
2239-
Join Filter: (pg_enum.enumtypid = t2.oid)
2240-
-> Nested Loop Left Join
2241-
-> Hash Join
2242-
Hash Cond: ((t.typanalyze)::oid = pa.oid)
2243-
-> Seq Scan on pg_type t
2244-
-> Hash
2245-
-> Hash Join
2246-
Hash Cond: (pa.proname = pg_enum.enumlabel)
2247-
-> Seq Scan on pg_proc pa
2248-
-> Hash
2249-
-> Seq Scan on pg_enum
2250-
-> Index Scan using pg_proc_oid_index on pg_proc po
2251-
Index Cond: (oid = (t.typoutput)::oid)
2252-
-> Index Scan using pg_type_typname_nsp_index on pg_type t2
2253-
Index Cond: (typname = COALESCE(po.proname, t.typname))
2254-
(16 rows)
2255-
2256-
select anname, outname, enumtypid
2257-
from
2258-
(select pa.proname as anname, coalesce(po.proname, typname) as outname
2259-
from pg_type t
2260-
left join pg_proc po on po.oid = t.typoutput
2261-
join pg_proc pa on pa.oid = t.typanalyze) ss,
2262-
pg_enum,
2263-
pg_type t2
2264-
where anname = enumlabel and outname = t2.typname and enumtypid = t2.oid;
2265-
anname | outname | enumtypid
2266-
--------+---------+-----------
2267-
(0 rows)
2227+
(select t3.tenthous as x1, coalesce(t1.stringu1, t2.stringu1) as x2
2228+
from tenk1 t1
2229+
left join tenk1 t2 on t1.unique1 = t2.unique1
2230+
join tenk1 t3 on t1.unique2 = t3.unique2) ss,
2231+
tenk1 t4,
2232+
tenk1 t5
2233+
where t4.thousand = t5.unique1 and ss.x1 = t4.tenthous and ss.x2 = t5.stringu1;
2234+
count
2235+
-------
2236+
1000
2237+
(1 row)
22682238

22692239
--
22702240
-- Clean up

src/test/regress/sql/join.sql

+9-21
Original file line numberDiff line numberDiff line change
@@ -379,29 +379,17 @@ order by 1, 2;
379379

380380
--
381381
-- regression test: check a case where join_clause_is_movable_into() gives
382-
-- an imprecise result
382+
-- an imprecise result, causing an assertion failure
383383
--
384-
analyze pg_enum;
385-
explain (costs off)
386-
select anname, outname, enumtypid
387-
from
388-
(select pa.proname as anname, coalesce(po.proname, typname) as outname
389-
from pg_type t
390-
left join pg_proc po on po.oid = t.typoutput
391-
join pg_proc pa on pa.oid = t.typanalyze) ss,
392-
pg_enum,
393-
pg_type t2
394-
where anname = enumlabel and outname = t2.typname and enumtypid = t2.oid;
395-
396-
select anname, outname, enumtypid
384+
select count(*)
397385
from
398-
(select pa.proname as anname, coalesce(po.proname, typname) as outname
399-
from pg_type t
400-
left join pg_proc po on po.oid = t.typoutput
401-
join pg_proc pa on pa.oid = t.typanalyze) ss,
402-
pg_enum,
403-
pg_type t2
404-
where anname = enumlabel and outname = t2.typname and enumtypid = t2.oid;
386+
(select t3.tenthous as x1, coalesce(t1.stringu1, t2.stringu1) as x2
387+
from tenk1 t1
388+
left join tenk1 t2 on t1.unique1 = t2.unique1
389+
join tenk1 t3 on t1.unique2 = t3.unique2) ss,
390+
tenk1 t4,
391+
tenk1 t5
392+
where t4.thousand = t5.unique1 and ss.x1 = t4.tenthous and ss.x2 = t5.stringu1;
405393

406394

407395
--

0 commit comments

Comments
 (0)