diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2015-08-13 13:25:01 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2015-08-13 13:25:23 -0400 |
commit | 657cdb3a21b09a7f02497b8c2e9f46b7bfc59993 (patch) | |
tree | cc8d94357a8af68885557d64921f00ba4f6f7042 /src | |
parent | 1136971daef209a40eb495b4bd74ce50fbd0fe63 (diff) | |
download | postgresql-657cdb3a21b09a7f02497b8c2e9f46b7bfc59993.tar.gz postgresql-657cdb3a21b09a7f02497b8c2e9f46b7bfc59993.zip |
Improve regression test case to avoid depending on system catalog stats.
In commit 95f4e59c32866716 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 95f4e59c32866716'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.
Diffstat (limited to 'src')
-rw-r--r-- | src/test/regress/expected/join.out | 56 | ||||
-rw-r--r-- | src/test/regress/sql/join.sql | 30 |
2 files changed, 22 insertions, 64 deletions
diff --git a/src/test/regress/expected/join.out b/src/test/regress/expected/join.out index c1f022c5460..087cddf03a2 100644 --- a/src/test/regress/expected/join.out +++ b/src/test/regress/expected/join.out @@ -2220,51 +2220,21 @@ order by 1, 2; -- -- regression test: check a case where join_clause_is_movable_into() gives --- an imprecise result +-- an imprecise result, causing an assertion failure -- -analyze pg_enum; -explain (costs off) -select anname, outname, enumtypid +select count(*) 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) + (select t3.tenthous as x1, coalesce(t1.stringu1, t2.stringu1) as x2 + from tenk1 t1 + left join tenk1 t2 on t1.unique1 = t2.unique1 + join tenk1 t3 on t1.unique2 = t3.unique2) ss, + tenk1 t4, + tenk1 t5 +where t4.thousand = t5.unique1 and ss.x1 = t4.tenthous and ss.x2 = t5.stringu1; + count +------- + 1000 +(1 row) -- -- Clean up diff --git a/src/test/regress/sql/join.sql b/src/test/regress/sql/join.sql index 0a63741d663..df59703bb56 100644 --- a/src/test/regress/sql/join.sql +++ b/src/test/regress/sql/join.sql @@ -379,29 +379,17 @@ order by 1, 2; -- -- regression test: check a case where join_clause_is_movable_into() gives --- an imprecise result +-- an imprecise result, causing an assertion failure -- -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 +select count(*) 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 t3.tenthous as x1, coalesce(t1.stringu1, t2.stringu1) as x2 + from tenk1 t1 + left join tenk1 t2 on t1.unique1 = t2.unique1 + join tenk1 t3 on t1.unique2 = t3.unique2) ss, + tenk1 t4, + tenk1 t5 +where t4.thousand = t5.unique1 and ss.x1 = t4.tenthous and ss.x2 = t5.stringu1; -- |