mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
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.
This commit is contained in:
@@ -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]);
|
||||
@@ -7408,51 +7403,6 @@ dumpTableConstraintComment(Archive *fout, ConstraintInfo *coninfo)
|
||||
destroyPQExpBuffer(q);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
|
Reference in New Issue
Block a user