12
12
* by PostgreSQL
13
13
*
14
14
* 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 $
16
16
*
17
17
*-------------------------------------------------------------------------
18
18
*/
@@ -3493,14 +3493,36 @@ getProcLangs(int *numProcLangs)
3493
3493
int i_lanname ;
3494
3494
int i_lanpltrusted ;
3495
3495
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 ;
3498
3499
3499
3500
/* Make sure we are in proper schema */
3500
3501
selectSourceSchema ("pg_catalog" );
3501
3502
3502
- if (g_fout -> remoteVersion >= 70100 )
3503
+ if (g_fout -> remoteVersion >= 80100 )
3503
3504
{
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 ... */
3504
3526
appendPQExpBuffer (query , "SELECT tableoid, oid, * FROM pg_language "
3505
3527
"WHERE lanispl "
3506
3528
"ORDER BY oid" );
@@ -3528,11 +3550,10 @@ getProcLangs(int *numProcLangs)
3528
3550
i_lanname = PQfnumber (res , "lanname" );
3529
3551
i_lanpltrusted = PQfnumber (res , "lanpltrusted" );
3530
3552
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" );
3536
3557
3537
3558
for (i = 0 ; i < ntups ; i ++ )
3538
3559
{
@@ -3544,24 +3565,28 @@ getProcLangs(int *numProcLangs)
3544
3565
planginfo [i ].dobj .name = strdup (PQgetvalue (res , i , i_lanname ));
3545
3566
planginfo [i ].lanpltrusted = * (PQgetvalue (res , i , i_lanpltrusted )) == 't' ;
3546
3567
planginfo [i ].lanplcallfoid = atooid (PQgetvalue (res , i , i_lanplcallfoid ));
3547
- if (g_fout -> remoteVersion >= 70300 )
3548
- {
3568
+ if (i_lanvalidator >= 0 )
3549
3569
planginfo [i ].lanvalidator = atooid (PQgetvalue (res , i , i_lanvalidator ));
3550
- planginfo [i ].lanacl = strdup (PQgetvalue (res , i , i_lanacl ));
3551
- }
3552
3570
else
3553
- {
3554
- FuncInfo * funcInfo ;
3555
-
3556
3571
planginfo [i ].lanvalidator = InvalidOid ;
3572
+ if (i_lanacl >= 0 )
3573
+ planginfo [i ].lanacl = strdup (PQgetvalue (res , i , i_lanacl ));
3574
+ else
3557
3575
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 ("" );
3558
3580
3581
+ if (g_fout -> remoteVersion < 70300 )
3582
+ {
3559
3583
/*
3560
3584
* We need to make a dependency to ensure the function will be
3561
3585
* dumped first. (In 7.3 and later the regular dependency
3562
3586
* mechanism will handle this for us.)
3563
3587
*/
3564
- funcInfo = findFuncByOid (planginfo [i ].lanplcallfoid );
3588
+ FuncInfo * funcInfo = findFuncByOid (planginfo [i ].lanplcallfoid );
3589
+
3565
3590
if (funcInfo )
3566
3591
addObjectDependency (& planginfo [i ].dobj ,
3567
3592
funcInfo -> dobj .dumpId );
@@ -5171,7 +5196,7 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
5171
5196
5172
5197
ArchiveEntry (fout , plang -> dobj .catId , plang -> dobj .dumpId ,
5173
5198
plang -> dobj .name ,
5174
- lanschema , NULL , "" ,
5199
+ lanschema , NULL , plang -> lanowner ,
5175
5200
false, "PROCEDURAL LANGUAGE" ,
5176
5201
defqry -> data , delqry -> data , NULL ,
5177
5202
plang -> dobj .dependencies , plang -> dobj .nDeps ,
@@ -5188,7 +5213,7 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
5188
5213
dumpACL (fout , plang -> dobj .catId , plang -> dobj .dumpId , "LANGUAGE" ,
5189
5214
qlanname , plang -> dobj .name ,
5190
5215
lanschema ,
5191
- NULL , plang -> lanacl );
5216
+ plang -> lanowner , plang -> lanacl );
5192
5217
5193
5218
free (qlanname );
5194
5219
@@ -6689,7 +6714,7 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
6689
6714
*
6690
6715
* 'objCatId' is the catalog ID of the underlying object.
6691
6716
* '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 .
6693
6718
* 'name' is the formatted name of the object. Must be quoted etc. already.
6694
6719
* 'tag' is the tag for the archive entry (typ. unquoted name of object).
6695
6720
* 'nspname' is the namespace the object is in (NULL if none).
0 commit comments