summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorTom Lane2005-08-12 01:36:05 +0000
committerTom Lane2005-08-12 01:36:05 +0000
commit721e53785d837d48dc33dd68aa77c42ece7c9afb (patch)
tree59c7bf34cada497f50c61072826d6fa0de080b57 /src/bin
parent9e4a2de8448997924e74ace8dfd9ccd05acb2d08 (diff)
Solve the problem of OID collisions by probing for duplicate OIDs
whenever we generate a new OID. This prevents occasional duplicate-OID errors that can otherwise occur once the OID counter has wrapped around. Duplicate relfilenode values are also checked for when creating new physical files. Per my recent proposal.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c8
-rw-r--r--src/bin/pg_dump/pg_dump.c52
2 files changed, 5 insertions, 55 deletions
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 224dbcec6fb..9bfed97424f 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.111 2005/06/21 20:45:44 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.112 2005/08/12 01:35:59 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1962,11 +1962,11 @@ _tocEntryRequired(TocEntry *te, RestoreOptions *ropt, bool include_acls)
}
/*
- * Special case: <Init> type with <Max OID> tag; this is part of a
- * DATA restore even though it has SQL.
+ * Special case: <Init> type with <Max OID> tag; this is obsolete
+ * and we always ignore it.
*/
if ((strcmp(te->desc, "<Init>") == 0) && (strcmp(te->tag, "Max OID") == 0))
- res = REQ_DATA;
+ return 0;
/* Mask it if we only want schema */
if (ropt->schemaOnly)
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 54ca6252a45..70255a91d6d 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -12,7 +12,7 @@
* by PostgreSQL
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.415 2005/07/10 15:08:52 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.416 2005/08/12 01:36:00 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -158,7 +158,6 @@ static const char *convertRegProcReference(const char *proc);
static const char *convertOperatorReference(const char *opr);
static Oid findLastBuiltinOid_V71(const char *);
static Oid findLastBuiltinOid_V70(void);
-static void setMaxOid(Archive *fout);
static void selectSourceSchema(const char *schemaName);
static char *getFormattedTypeName(Oid oid, OidOptions opts);
static char *myFormatType(const char *typname, int32 typmod);
@@ -611,10 +610,6 @@ main(int argc, char **argv)
if (!dataOnly)
dumpDatabase(g_fout);
- /* Max OID is next. */
- if (oids == true)
- setMaxOid(g_fout);
-
/* Now the rearrangeable objects. */
for (i = 0; i < numObjs; i++)
dumpDumpableObject(g_fout, dobjs[i]);
@@ -7409,51 +7404,6 @@ dumpTableConstraintComment(Archive *fout, ConstraintInfo *coninfo)
}
/*
- * setMaxOid -
- * find the maximum oid and generate a COPY statement to set it
- */
-static void
-setMaxOid(Archive *fout)
-{
- PGresult *res;
- Oid max_oid;
- char sql[1024];
-
- if (fout->remoteVersion >= 70200)
- do_sql_command(g_conn,
- "CREATE TEMPORARY TABLE pgdump_oid (dummy integer) WITH OIDS");
- else
- do_sql_command(g_conn,
- "CREATE TEMPORARY TABLE pgdump_oid (dummy integer)");
- res = PQexec(g_conn, "INSERT INTO pgdump_oid VALUES (0)");
- check_sql_result(res, g_conn, "INSERT INTO pgdump_oid VALUES (0)",
- PGRES_COMMAND_OK);
- max_oid = PQoidValue(res);
- if (max_oid == 0)
- {
- write_msg(NULL, "inserted invalid OID\n");
- exit_nicely();
- }
- PQclear(res);
- do_sql_command(g_conn, "DROP TABLE pgdump_oid;");
- if (g_verbose)
- write_msg(NULL, "maximum system OID is %u\n", max_oid);
- snprintf(sql, sizeof(sql),
- "CREATE TEMPORARY TABLE pgdump_oid (dummy integer) WITH OIDS;\n"
- "COPY pgdump_oid WITH OIDS FROM stdin;\n"
- "%u\t0\n"
- "\\.\n"
- "DROP TABLE pgdump_oid;\n",
- max_oid);
-
- ArchiveEntry(fout, nilCatalogId, createDumpId(),
- "Max OID", NULL, NULL, "",
- false, "<Init>", sql, "", NULL,
- NULL, 0,
- NULL, NULL);
-}
-
-/*
* findLastBuiltInOid -
* find the last built in oid
*