2222 *
2323 *
2424 * 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 $
2626 *
2727 * Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
2828 *
@@ -140,7 +140,7 @@ static char *checkForQuote(const char *s);
140140static void clearTableInfo (TableInfo * , int );
141141static void dumpOneFunc (Archive * fout , FuncInfo * finfo , int i ,
142142 TypeInfo * tinfo , int numTypes );
143- static int findLastBuiltinOid (void );
143+ static int findLastBuiltinOid (const char * );
144144static void setMaxOid (Archive * fout );
145145
146146static void AddAcl (char * aclbuf , const char * keyword );
@@ -954,7 +954,7 @@ main(int argc, char **argv)
954954 PQclear (res );
955955 }
956956
957- g_last_builtin_oid = findLastBuiltinOid ();
957+ g_last_builtin_oid = findLastBuiltinOid (dbname );
958958
959959 /* Dump the database definition */
960960 if (!dataOnly )
@@ -3888,14 +3888,17 @@ setMaxOid(Archive *fout)
38883888*/
38893889
38903890static int
3891- findLastBuiltinOid (void )
3891+ findLastBuiltinOid (const char * dbname )
38923892{
38933893 PGresult * res ;
38943894 int ntups ;
38953895 int last_oid ;
3896+ PQExpBuffer query = createPQExpBuffer ();
3897+
3898+ resetPQExpBuffer (query );
3899+ appendPQExpBuffer (query , "SELECT datlastsysoid from pg_database where datname = '%s'" , dbname );
38963900
3897- res = PQexec (g_conn ,
3898- "SELECT oid from pg_database where datname = 'template1'" );
3901+ res = PQexec (g_conn , query -> data );
38993902 if (res == NULL ||
39003903 PQresultStatus (res ) != PGRES_TUPLES_OK )
39013904 {
@@ -3916,7 +3919,7 @@ findLastBuiltinOid(void)
39163919 fprintf (stderr , "There is more than one 'template1' entry in the 'pg_database' table\n" );
39173920 exit_nicely (g_conn );
39183921 }
3919- last_oid = atoi (PQgetvalue (res , 0 , PQfnumber (res , "oid " )));
3922+ last_oid = atoi (PQgetvalue (res , 0 , PQfnumber (res , "datlastsysoid " )));
39203923 PQclear (res );
39213924 return last_oid ;
39223925}
0 commit comments