Fix findLastBuiltinOid_V70() to deliver correct result when running
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 21 Oct 2003 04:46:28 +0000 (04:46 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 21 Oct 2003 04:46:28 +0000 (04:46 +0000)
against a 7.0 server.

Christopher Kings-Lynne

src/bin/pg_dump/pg_dump.c

index ea68a486bbc9290cd663f8ad215ea7437e193914..428673fd742e3d09e7646f3bd3010b63511a0fbe 100644 (file)
@@ -5822,9 +5822,10 @@ setMaxOid(Archive *fout)
 /*
  * findLastBuiltInOid -
  * find the last built in oid
- * we do this by retrieving datlastsysoid from the pg_database entry for this database,
+ *
+ * For 7.1 and 7.2, we do this by retrieving datlastsysoid from the
+ * pg_database entry for the current database
  */
-
 static Oid
 findLastBuiltinOid_V71(const char *dbname)
 {
@@ -5864,10 +5865,11 @@ findLastBuiltinOid_V71(const char *dbname)
 /*
  * findLastBuiltInOid -
  * find the last built in oid
- * we do this by looking up the oid of 'template1' in pg_database,
- * this is probably not foolproof but comes close
-*/
-
+ *
+ * For 7.0, we do this by assuming that the last thing that initdb does is to
+ * create the pg_indexes view.  This sucks in general, but seeing that 7.0.x
+ * initdb won't be changing anymore, it'll do.
+ */
 static Oid
 findLastBuiltinOid_V70(void)
 {
@@ -5876,7 +5878,7 @@ findLastBuiltinOid_V70(void)
        int                     last_oid;
 
        res = PQexec(g_conn,
-                         "SELECT oid from pg_database where datname = 'template1'");
+                                "SELECT oid FROM pg_class WHERE relname = 'pg_indexes'");
        if (res == NULL ||
                PQresultStatus(res) != PGRES_TUPLES_OK)
        {