aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-02-24 01:57:16 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2010-02-24 01:57:16 +0000
commit24ac52c3f1f7f408820dc9eff001e2c6bc0941a1 (patch)
tree6f4360e2ec56d2bd7d8077d94494e51c1c873b0e /src
parentb951c03f88129d2814dca5239f57653c8d6284d1 (diff)
downloadpostgresql-24ac52c3f1f7f408820dc9eff001e2c6bc0941a1.tar.gz
postgresql-24ac52c3f1f7f408820dc9eff001e2c6bc0941a1.zip
Use CREATE OR REPLACE LANGUAGE in pg_dump to avoid the need for a couple of
significantly uglier kluges that were working around the change in plpgsql's preinstalled status.
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_dump/pg_dump.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 84d12b118f4..cf38f167fbe 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -12,7 +12,7 @@
* by PostgreSQL
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.572 2010/02/18 01:29:10 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.573 2010/02/24 01:57:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -32,7 +32,6 @@
#include "access/attnum.h"
#include "access/sysattr.h"
-#include "access/transam.h"
#include "catalog/pg_cast.h"
#include "catalog/pg_class.h"
#include "catalog/pg_default_acl.h"
@@ -4795,10 +4794,8 @@ getProcLangs(int *numProcLangs)
"(%s lanowner) AS lanowner "
"FROM pg_language "
"WHERE lanispl "
- /* do not dump initdb-installed languages */
- "AND oid >= %u "
"ORDER BY oid",
- username_subquery, FirstNormalObjectId);
+ username_subquery);
}
else if (g_fout->remoteVersion >= 80300)
{
@@ -4808,10 +4805,9 @@ getProcLangs(int *numProcLangs)
"lanvalidator, lanacl, "
"(%s lanowner) AS lanowner "
"FROM pg_language "
- "WHERE lanispl%s "
+ "WHERE lanispl "
"ORDER BY oid",
- username_subquery,
- binary_upgrade ? "\nAND lanname != 'plpgsql'" : "");
+ username_subquery);
}
else if (g_fout->remoteVersion >= 80100)
{
@@ -7552,11 +7548,11 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
appendPQExpBuffer(delqry, "DROP PROCEDURAL LANGUAGE %s;\n",
qlanname);
- appendPQExpBuffer(defqry, "CREATE %sPROCEDURAL LANGUAGE %s",
- (useParams && plang->lanpltrusted) ? "TRUSTED " : "",
- qlanname);
if (useParams)
{
+ appendPQExpBuffer(defqry, "CREATE %sPROCEDURAL LANGUAGE %s",
+ plang->lanpltrusted ? "TRUSTED " : "",
+ qlanname);
appendPQExpBuffer(defqry, " HANDLER %s",
fmtId(funcInfo->dobj.name));
if (OidIsValid(plang->laninline))
@@ -7580,6 +7576,20 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
fmtId(validatorInfo->dobj.name));
}
}
+ else
+ {
+ /*
+ * If not dumping parameters, then use CREATE OR REPLACE so that
+ * the command will not fail if the language is preinstalled in the
+ * target database. We restrict the use of REPLACE to this case so
+ * as to eliminate the risk of replacing a language with incompatible
+ * parameter settings: this command will only succeed at all if there
+ * is a pg_pltemplate entry, and if there is one, the existing entry
+ * must match it too.
+ */
+ appendPQExpBuffer(defqry, "CREATE OR REPLACE PROCEDURAL LANGUAGE %s",
+ qlanname);
+ }
appendPQExpBuffer(defqry, ";\n");
ArchiveEntry(fout, plang->dobj.catId, plang->dobj.dumpId,