12
12
* by PostgreSQL
13
13
*
14
14
* IDENTIFICATION
15
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.572 2010/02/18 01:29:10 tgl Exp $
15
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.573 2010/02/24 01:57:16 tgl Exp $
16
16
*
17
17
*-------------------------------------------------------------------------
18
18
*/
32
32
33
33
#include "access/attnum.h"
34
34
#include "access/sysattr.h"
35
- #include "access/transam.h"
36
35
#include "catalog/pg_cast.h"
37
36
#include "catalog/pg_class.h"
38
37
#include "catalog/pg_default_acl.h"
@@ -4795,10 +4794,8 @@ getProcLangs(int *numProcLangs)
4795
4794
"(%s lanowner) AS lanowner "
4796
4795
"FROM pg_language "
4797
4796
"WHERE lanispl "
4798
- /* do not dump initdb-installed languages */
4799
- "AND oid >= %u "
4800
4797
"ORDER BY oid" ,
4801
- username_subquery , FirstNormalObjectId );
4798
+ username_subquery );
4802
4799
}
4803
4800
else if (g_fout -> remoteVersion >= 80300 )
4804
4801
{
@@ -4808,10 +4805,9 @@ getProcLangs(int *numProcLangs)
4808
4805
"lanvalidator, lanacl, "
4809
4806
"(%s lanowner) AS lanowner "
4810
4807
"FROM pg_language "
4811
- "WHERE lanispl%s "
4808
+ "WHERE lanispl "
4812
4809
"ORDER BY oid" ,
4813
- username_subquery ,
4814
- binary_upgrade ? "\nAND lanname != 'plpgsql'" : "" );
4810
+ username_subquery );
4815
4811
}
4816
4812
else if (g_fout -> remoteVersion >= 80100 )
4817
4813
{
@@ -7552,11 +7548,11 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
7552
7548
appendPQExpBuffer (delqry , "DROP PROCEDURAL LANGUAGE %s;\n" ,
7553
7549
qlanname );
7554
7550
7555
- appendPQExpBuffer (defqry , "CREATE %sPROCEDURAL LANGUAGE %s" ,
7556
- (useParams && plang -> lanpltrusted ) ? "TRUSTED " : "" ,
7557
- qlanname );
7558
7551
if (useParams )
7559
7552
{
7553
+ appendPQExpBuffer (defqry , "CREATE %sPROCEDURAL LANGUAGE %s" ,
7554
+ plang -> lanpltrusted ? "TRUSTED " : "" ,
7555
+ qlanname );
7560
7556
appendPQExpBuffer (defqry , " HANDLER %s" ,
7561
7557
fmtId (funcInfo -> dobj .name ));
7562
7558
if (OidIsValid (plang -> laninline ))
@@ -7580,6 +7576,20 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
7580
7576
fmtId (validatorInfo -> dobj .name ));
7581
7577
}
7582
7578
}
7579
+ else
7580
+ {
7581
+ /*
7582
+ * If not dumping parameters, then use CREATE OR REPLACE so that
7583
+ * the command will not fail if the language is preinstalled in the
7584
+ * target database. We restrict the use of REPLACE to this case so
7585
+ * as to eliminate the risk of replacing a language with incompatible
7586
+ * parameter settings: this command will only succeed at all if there
7587
+ * is a pg_pltemplate entry, and if there is one, the existing entry
7588
+ * must match it too.
7589
+ */
7590
+ appendPQExpBuffer (defqry , "CREATE OR REPLACE PROCEDURAL LANGUAGE %s" ,
7591
+ qlanname );
7592
+ }
7583
7593
appendPQExpBuffer (defqry , ";\n" );
7584
7594
7585
7595
ArchiveEntry (fout , plang -> dobj .catId , plang -> dobj .dumpId ,
0 commit comments