1212 * by PostgreSQL
1313 *
1414 * IDENTIFICATION
15- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.423 2005/11/22 18:17:28 momjian Exp $
15+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.424 2005/12/03 21:06:18 tgl Exp $
1616 *
1717 *-------------------------------------------------------------------------
1818 */
@@ -3493,14 +3493,36 @@ getProcLangs(int *numProcLangs)
34933493 int i_lanname ;
34943494 int i_lanpltrusted ;
34953495 int i_lanplcallfoid ;
3496- int i_lanvalidator = -1 ;
3497- int i_lanacl = -1 ;
3496+ int i_lanvalidator ;
3497+ int i_lanacl ;
3498+ int i_lanowner ;
34983499
34993500 /* Make sure we are in proper schema */
35003501 selectSourceSchema ("pg_catalog" );
35013502
3502- if (g_fout -> remoteVersion >= 70100 )
3503+ if (g_fout -> remoteVersion >= 80100 )
35033504 {
3505+ /* Languages are owned by the bootstrap superuser, OID 10 */
3506+ appendPQExpBuffer (query , "SELECT tableoid, oid, *, "
3507+ "(%s '10') as lanowner "
3508+ "FROM pg_language "
3509+ "WHERE lanispl "
3510+ "ORDER BY oid" ,
3511+ username_subquery );
3512+ }
3513+ else if (g_fout -> remoteVersion >= 70400 )
3514+ {
3515+ /* Languages are owned by the bootstrap superuser, sysid 1 */
3516+ appendPQExpBuffer (query , "SELECT tableoid, oid, *, "
3517+ "(%s '1') as lanowner "
3518+ "FROM pg_language "
3519+ "WHERE lanispl "
3520+ "ORDER BY oid" ,
3521+ username_subquery );
3522+ }
3523+ else if (g_fout -> remoteVersion >= 70100 )
3524+ {
3525+ /* No clear notion of an owner at all before 7.4 ... */
35043526 appendPQExpBuffer (query , "SELECT tableoid, oid, * FROM pg_language "
35053527 "WHERE lanispl "
35063528 "ORDER BY oid" );
@@ -3528,11 +3550,10 @@ getProcLangs(int *numProcLangs)
35283550 i_lanname = PQfnumber (res , "lanname" );
35293551 i_lanpltrusted = PQfnumber (res , "lanpltrusted" );
35303552 i_lanplcallfoid = PQfnumber (res , "lanplcallfoid" );
3531- if (g_fout -> remoteVersion >= 70300 )
3532- {
3533- i_lanvalidator = PQfnumber (res , "lanvalidator" );
3534- i_lanacl = PQfnumber (res , "lanacl" );
3535- }
3553+ /* these may fail and return -1: */
3554+ i_lanvalidator = PQfnumber (res , "lanvalidator" );
3555+ i_lanacl = PQfnumber (res , "lanacl" );
3556+ i_lanowner = PQfnumber (res , "lanowner" );
35363557
35373558 for (i = 0 ; i < ntups ; i ++ )
35383559 {
@@ -3544,24 +3565,28 @@ getProcLangs(int *numProcLangs)
35443565 planginfo [i ].dobj .name = strdup (PQgetvalue (res , i , i_lanname ));
35453566 planginfo [i ].lanpltrusted = * (PQgetvalue (res , i , i_lanpltrusted )) == 't' ;
35463567 planginfo [i ].lanplcallfoid = atooid (PQgetvalue (res , i , i_lanplcallfoid ));
3547- if (g_fout -> remoteVersion >= 70300 )
3548- {
3568+ if (i_lanvalidator >= 0 )
35493569 planginfo [i ].lanvalidator = atooid (PQgetvalue (res , i , i_lanvalidator ));
3550- planginfo [i ].lanacl = strdup (PQgetvalue (res , i , i_lanacl ));
3551- }
35523570 else
3553- {
3554- FuncInfo * funcInfo ;
3555-
35563571 planginfo [i ].lanvalidator = InvalidOid ;
3572+ if (i_lanacl >= 0 )
3573+ planginfo [i ].lanacl = strdup (PQgetvalue (res , i , i_lanacl ));
3574+ else
35573575 planginfo [i ].lanacl = strdup ("{=U}" );
3576+ if (i_lanowner >= 0 )
3577+ planginfo [i ].lanowner = strdup (PQgetvalue (res , i , i_lanowner ));
3578+ else
3579+ planginfo [i ].lanowner = strdup ("" );
35583580
3581+ if (g_fout -> remoteVersion < 70300 )
3582+ {
35593583 /*
35603584 * We need to make a dependency to ensure the function will be
35613585 * dumped first. (In 7.3 and later the regular dependency
35623586 * mechanism will handle this for us.)
35633587 */
3564- funcInfo = findFuncByOid (planginfo [i ].lanplcallfoid );
3588+ FuncInfo * funcInfo = findFuncByOid (planginfo [i ].lanplcallfoid );
3589+
35653590 if (funcInfo )
35663591 addObjectDependency (& planginfo [i ].dobj ,
35673592 funcInfo -> dobj .dumpId );
@@ -5171,7 +5196,7 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
51715196
51725197 ArchiveEntry (fout , plang -> dobj .catId , plang -> dobj .dumpId ,
51735198 plang -> dobj .name ,
5174- lanschema , NULL , "" ,
5199+ lanschema , NULL , plang -> lanowner ,
51755200 false, "PROCEDURAL LANGUAGE" ,
51765201 defqry -> data , delqry -> data , NULL ,
51775202 plang -> dobj .dependencies , plang -> dobj .nDeps ,
@@ -5188,7 +5213,7 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
51885213 dumpACL (fout , plang -> dobj .catId , plang -> dobj .dumpId , "LANGUAGE" ,
51895214 qlanname , plang -> dobj .name ,
51905215 lanschema ,
5191- NULL , plang -> lanacl );
5216+ plang -> lanowner , plang -> lanacl );
51925217
51935218 free (qlanname );
51945219
@@ -6689,7 +6714,7 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
66896714 *
66906715 * 'objCatId' is the catalog ID of the underlying object.
66916716 * 'objDumpId' is the dump ID of the underlying object.
6692- * 'type' must be TABLE, FUNCTION, LANGUAGE, or SCHEMA .
6717+ * 'type' must be TABLE, FUNCTION, LANGUAGE, SCHEMA, DATABASE, or TABLESPACE .
66936718 * 'name' is the formatted name of the object. Must be quoted etc. already.
66946719 * 'tag' is the tag for the archive entry (typ. unquoted name of object).
66956720 * 'nspname' is the namespace the object is in (NULL if none).
0 commit comments