summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2019-08-13 16:57:58 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2019-08-13 16:57:58 -0400
commit6844adba54f7d96f30f834efc6d9aa1e52e5672d (patch)
treecbad432e2566cb391b5796ff6bcd89e2691dc966
parent4c0b9cf9e073ca2dc95a75fe983d90fd518864fb (diff)
Un-break pg_dump for pre-8.3 source servers.
Commit 07b39083c inserted an unconditional reference to pg_opfamily, which of course fails on servers predating that catalog. Fortunately, the case it's trying to solve can't occur on such old servers (AFAIK). Hence, just skip the additional code when the source predates 8.3. Per bug #15955 from sly. Back-patch to all supported branches, like the previous patch. Discussion: https://postgr.es/m/15955-1daa2e676e903d87@postgresql.org
-rw-r--r--src/bin/pg_dump/pg_dump.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index b092b14bedc..7d27c1b9027 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -17926,21 +17926,28 @@ getDependencies(Archive *fout)
* entries will have dependencies on their parent opfamily, which we
* should drop since they'd likewise become useless self-dependencies.
* (But be sure to keep deps on *other* opfamilies; see amopsortfamily.)
+ *
+ * Skip this for pre-8.3 source servers: pg_opfamily doesn't exist there,
+ * and the (known) cases where it would matter to have these dependencies
+ * can't arise anyway.
*/
- appendPQExpBufferStr(query, "UNION ALL\n"
- "SELECT 'pg_opfamily'::regclass AS classid, amopfamily AS objid, refclassid, refobjid, deptype "
- "FROM pg_depend d, pg_amop o "
- "WHERE deptype NOT IN ('p', 'e', 'i') AND "
- "classid = 'pg_amop'::regclass AND objid = o.oid "
- "AND NOT (refclassid = 'pg_opfamily'::regclass AND amopfamily = refobjid)\n");
-
- /* Likewise for pg_amproc entries */
- appendPQExpBufferStr(query, "UNION ALL\n"
- "SELECT 'pg_opfamily'::regclass AS classid, amprocfamily AS objid, refclassid, refobjid, deptype "
- "FROM pg_depend d, pg_amproc p "
- "WHERE deptype NOT IN ('p', 'e', 'i') AND "
- "classid = 'pg_amproc'::regclass AND objid = p.oid "
- "AND NOT (refclassid = 'pg_opfamily'::regclass AND amprocfamily = refobjid)\n");
+ if (fout->remoteVersion >= 80300)
+ {
+ appendPQExpBufferStr(query, "UNION ALL\n"
+ "SELECT 'pg_opfamily'::regclass AS classid, amopfamily AS objid, refclassid, refobjid, deptype "
+ "FROM pg_depend d, pg_amop o "
+ "WHERE deptype NOT IN ('p', 'e', 'i') AND "
+ "classid = 'pg_amop'::regclass AND objid = o.oid "
+ "AND NOT (refclassid = 'pg_opfamily'::regclass AND amopfamily = refobjid)\n");
+
+ /* Likewise for pg_amproc entries */
+ appendPQExpBufferStr(query, "UNION ALL\n"
+ "SELECT 'pg_opfamily'::regclass AS classid, amprocfamily AS objid, refclassid, refobjid, deptype "
+ "FROM pg_depend d, pg_amproc p "
+ "WHERE deptype NOT IN ('p', 'e', 'i') AND "
+ "classid = 'pg_amproc'::regclass AND objid = p.oid "
+ "AND NOT (refclassid = 'pg_opfamily'::regclass AND amprocfamily = refobjid)\n");
+ }
/* Sort the output for efficiency below */
appendPQExpBufferStr(query, "ORDER BY 1,2");