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

Commit6a0779a

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 parent94d626f commit6a0779a

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
@@ -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

Lines changed: 9 additions & 21 deletions
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-
(selectpa.pronameas anname, coalesce(po.proname, typname)as outname
389-
from pg_type t
390-
left join pg_proc poonpo.oid=t.typoutput
391-
join pg_proc paonpa.oid=t.typanalyze) ss,
392-
pg_enum,
393-
pg_type t2
394-
where anname= enumlabeland outname=t2.typnameand enumtypid=t2.oid;
395-
396-
select anname, outname, enumtypid
384+
selectcount(*)
397385
from
398-
(selectpa.pronameasanname, coalesce(po.proname, typname)asoutname
399-
frompg_type t
400-
left joinpg_proc poonpo.oid=t.typoutput
401-
joinpg_proc paonpa.oid=t.typanalyze) ss,
402-
pg_enum,
403-
pg_type t2
404-
whereanname=enumlabelandoutname=t2.typnameandenumtypid=t2.oid;
386+
(selectt3.tenthousasx1, coalesce(t1.stringu1,t2.stringu1)asx2
387+
fromtenk1 t1
388+
left jointenk1 t2ont1.unique1=t2.unique1
389+
jointenk1 t3ont1.unique2=t3.unique2) ss,
390+
tenk1 t4,
391+
tenk1 t5
392+
wheret4.thousand=t5.unique1andss.x1=t4.tenthousandss.x2=t5.stringu1;
405393

406394

407395
--

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp