Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3bfd401

Browse files
committed
Improve regression test case to avoid depending on system catalog stats.
In commit95f4e59 I added a regression test case that examinedthe plan of a query on system catalogs. That isn't a terribly great ideabecause the catalogs tend to change from version to version, or evenwithin a version if someone makes an unrelated regression-test change thatpopulates the catalogs a bit differently. Usually I try to make plannertest cases rely on test tables that have not changed since Berkeley days,but I got sloppy in this case because the submitted crasher example queriedthe catalogs and I didn't spend enough time on rewriting it. But it was aproblem waiting to happen, as I was rudely reminded when I tried to portthat patch into Salesforce's Postgres variant :-(. So spend a little moreeffort and rewrite the query to not use any system catalogs. I verifiedthat this version still provokes the Assert if95f4e59's code fixis reverted.I also removed the EXPLAIN output from the test, as it turns out that theassertion occurs while considering a plan that isn't the one ultimatelyselected anyway; so there's no value in risking any cross-platformvariation in that printout.Back-patch to 9.2, like the previous patch.
1 parent83fd922 commit3bfd401

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-
(selectpa.pronameas anname, coalesce(po.proname, typname)as outname
377-
from pg_type t
378-
left join pg_proc poonpo.oid=t.typoutput
379-
join pg_proc paonpa.oid=t.typanalyze) ss,
380-
pg_enum,
381-
pg_type t2
382-
where anname= enumlabeland outname=t2.typnameand enumtypid=t2.oid;
383-
384-
select anname, outname, enumtypid
372+
selectcount(*)
385373
from
386-
(selectpa.pronameasanname, coalesce(po.proname, typname)asoutname
387-
frompg_type t
388-
left joinpg_proc poonpo.oid=t.typoutput
389-
joinpg_proc paonpa.oid=t.typanalyze) ss,
390-
pg_enum,
391-
pg_type t2
392-
whereanname=enumlabelandoutname=t2.typnameandenumtypid=t2.oid;
374+
(selectt3.tenthousasx1, coalesce(t1.stringu1,t2.stringu1)asx2
375+
fromtenk1 t1
376+
left jointenk1 t2ont1.unique1=t2.unique1
377+
jointenk1 t3ont1.unique2=t3.unique2) ss,
378+
tenk1 t4,
379+
tenk1 t5
380+
wheret4.thousand=t5.unique1andss.x1=t4.tenthousandss.x2=t5.stringu1;
393381

394382

395383
--

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp