22
22
*
23
23
*
24
24
* IDENTIFICATION
25
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.172 2000/10/22 05:27:18 momjian Exp $
25
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.173 2000/10/22 18:13:09 pjw Exp $
26
26
*
27
27
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
28
28
*
@@ -140,7 +140,7 @@ static char *checkForQuote(const char *s);
140
140
static void clearTableInfo (TableInfo * , int );
141
141
static void dumpOneFunc (Archive * fout , FuncInfo * finfo , int i ,
142
142
TypeInfo * tinfo , int numTypes );
143
- static int findLastBuiltinOid (void );
143
+ static int findLastBuiltinOid (const char * );
144
144
static void setMaxOid (Archive * fout );
145
145
146
146
static void AddAcl (char * aclbuf , const char * keyword );
@@ -954,7 +954,7 @@ main(int argc, char **argv)
954
954
PQclear (res );
955
955
}
956
956
957
- g_last_builtin_oid = findLastBuiltinOid ();
957
+ g_last_builtin_oid = findLastBuiltinOid (dbname );
958
958
959
959
/* Dump the database definition */
960
960
if (!dataOnly )
@@ -3888,14 +3888,17 @@ setMaxOid(Archive *fout)
3888
3888
*/
3889
3889
3890
3890
static int
3891
- findLastBuiltinOid (void )
3891
+ findLastBuiltinOid (const char * dbname )
3892
3892
{
3893
3893
PGresult * res ;
3894
3894
int ntups ;
3895
3895
int last_oid ;
3896
+ PQExpBuffer query = createPQExpBuffer ();
3897
+
3898
+ resetPQExpBuffer (query );
3899
+ appendPQExpBuffer (query , "SELECT datlastsysoid from pg_database where datname = '%s'" , dbname );
3896
3900
3897
- res = PQexec (g_conn ,
3898
- "SELECT oid from pg_database where datname = 'template1'" );
3901
+ res = PQexec (g_conn , query -> data );
3899
3902
if (res == NULL ||
3900
3903
PQresultStatus (res ) != PGRES_TUPLES_OK )
3901
3904
{
@@ -3916,7 +3919,7 @@ findLastBuiltinOid(void)
3916
3919
fprintf (stderr , "There is more than one 'template1' entry in the 'pg_database' table\n" );
3917
3920
exit_nicely (g_conn );
3918
3921
}
3919
- last_oid = atoi (PQgetvalue (res , 0 , PQfnumber (res , "oid " )));
3922
+ last_oid = atoi (PQgetvalue (res , 0 , PQfnumber (res , "datlastsysoid " )));
3920
3923
PQclear (res );
3921
3924
return last_oid ;
3922
3925
}
0 commit comments