aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2012-07-04 17:36:50 -0400
committerBruce Momjian <bruce@momjian.us>2012-07-04 17:37:01 -0400
commit3e00d332615be32d64bbb1f604a783fade3146c0 (patch)
tree1343585dfdbb7f31c63de3978617145d7dead45a /src
parent0fc32c00d74404a9a535e0e1b8d9437dfd8075db (diff)
downloadpostgresql-3e00d332615be32d64bbb1f604a783fade3146c0.tar.gz
postgresql-3e00d332615be32d64bbb1f604a783fade3146c0.zip
Have pg_dump in binary-upgrade mode properly drop user-created
extensions that might exist in the new empty cluster databases, like plpgsql. Backpatch to 9.2.
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_dump/pg_dump.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index afb28a870e6..7d672878ed3 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -7331,6 +7331,16 @@ dumpExtension(Archive *fout, ExtensionInfo *extinfo)
int n;
appendPQExpBuffer(q, "-- For binary upgrade, create an empty extension and insert objects into it\n");
+
+ /*
+ * We unconditionally create the extension, so we must drop it if it
+ * exists. This could happen if the user deleted 'plpgsql' and then
+ * readded it, causing its oid to be greater than FirstNormalObjectId.
+ * The FirstNormalObjectId test was kept to avoid repeatedly dropping
+ * and recreating extensions like 'plpgsql'.
+ */
+ appendPQExpBuffer(q, "DROP EXTENSION IF EXISTS %s;\n", qextname);
+
appendPQExpBuffer(q,
"SELECT binary_upgrade.create_empty_extension(");
appendStringLiteralAH(q, extinfo->dobj.name, fout);