Skip to content

Commit f2bdfeb

Browse files
committed
Un-break pg_dump for pre-8.3 source servers.
Commit 07b3908 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
1 parent fc8c6ae commit f2bdfeb

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17183,21 +17183,28 @@ getDependencies(Archive *fout)
1718317183
* entries will have dependencies on their parent opfamily, which we
1718417184
* should drop since they'd likewise become useless self-dependencies.
1718517185
* (But be sure to keep deps on *other* opfamilies; see amopsortfamily.)
17186+
*
17187+
* Skip this for pre-8.3 source servers: pg_opfamily doesn't exist there,
17188+
* and the (known) cases where it would matter to have these dependencies
17189+
* can't arise anyway.
1718617190
*/
17187-
appendPQExpBufferStr(query, "UNION ALL\n"
17188-
"SELECT 'pg_opfamily'::regclass AS classid, amopfamily AS objid, refclassid, refobjid, deptype "
17189-
"FROM pg_depend d, pg_amop o "
17190-
"WHERE deptype NOT IN ('p', 'e', 'i') AND "
17191-
"classid = 'pg_amop'::regclass AND objid = o.oid "
17192-
"AND NOT (refclassid = 'pg_opfamily'::regclass AND amopfamily = refobjid)\n");
17193-
17194-
/* Likewise for pg_amproc entries */
17195-
appendPQExpBufferStr(query, "UNION ALL\n"
17196-
"SELECT 'pg_opfamily'::regclass AS classid, amprocfamily AS objid, refclassid, refobjid, deptype "
17197-
"FROM pg_depend d, pg_amproc p "
17198-
"WHERE deptype NOT IN ('p', 'e', 'i') AND "
17199-
"classid = 'pg_amproc'::regclass AND objid = p.oid "
17200-
"AND NOT (refclassid = 'pg_opfamily'::regclass AND amprocfamily = refobjid)\n");
17191+
if (fout->remoteVersion >= 80300)
17192+
{
17193+
appendPQExpBufferStr(query, "UNION ALL\n"
17194+
"SELECT 'pg_opfamily'::regclass AS classid, amopfamily AS objid, refclassid, refobjid, deptype "
17195+
"FROM pg_depend d, pg_amop o "
17196+
"WHERE deptype NOT IN ('p', 'e', 'i') AND "
17197+
"classid = 'pg_amop'::regclass AND objid = o.oid "
17198+
"AND NOT (refclassid = 'pg_opfamily'::regclass AND amopfamily = refobjid)\n");
17199+
17200+
/* Likewise for pg_amproc entries */
17201+
appendPQExpBufferStr(query, "UNION ALL\n"
17202+
"SELECT 'pg_opfamily'::regclass AS classid, amprocfamily AS objid, refclassid, refobjid, deptype "
17203+
"FROM pg_depend d, pg_amproc p "
17204+
"WHERE deptype NOT IN ('p', 'e', 'i') AND "
17205+
"classid = 'pg_amproc'::regclass AND objid = p.oid "
17206+
"AND NOT (refclassid = 'pg_opfamily'::regclass AND amprocfamily = refobjid)\n");
17207+
}
1720117208

1720217209
/* Sort the output for efficiency below */
1720317210
appendPQExpBufferStr(query, "ORDER BY 1,2");

0 commit comments

Comments
 (0)