diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-08-12 01:36:05 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-08-12 01:36:05 +0000 |
commit | 721e53785d837d48dc33dd68aa77c42ece7c9afb (patch) | |
tree | 59c7bf34cada497f50c61072826d6fa0de080b57 /src/backend/commands/dbcommands.c | |
parent | 9e4a2de8448997924e74ace8dfd9ccd05acb2d08 (diff) | |
download | postgresql-721e53785d837d48dc33dd68aa77c42ece7c9afb.tar.gz postgresql-721e53785d837d48dc33dd68aa77c42ece7c9afb.zip |
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/backend/commands/dbcommands.c')
-rw-r--r-- | src/backend/commands/dbcommands.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index 01b53e06933..40e28a0821c 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.169 2005/08/02 19:02:31 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.170 2005/08/12 01:35:57 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -80,7 +80,7 @@ createdb(const CreatedbStmt *stmt) TransactionId src_frozenxid; Oid src_deftablespace; volatile Oid dst_deftablespace; - volatile Relation pg_database_rel = NULL; + volatile Relation pg_database_rel; HeapTuple tuple; TupleDesc pg_database_dsc; Datum new_record[Natts_pg_database]; @@ -347,9 +347,13 @@ createdb(const CreatedbStmt *stmt) /* * Preassign OID for pg_database tuple, so that we can compute db - * path. + * path. We have to open pg_database to do this, but we don't want + * to take ExclusiveLock yet, so just do it and close again. */ - dboid = newoid(); + pg_database_rel = heap_open(DatabaseRelationId, AccessShareLock); + dboid = GetNewOid(pg_database_rel); + heap_close(pg_database_rel, AccessShareLock); + pg_database_rel = NULL; /* * Force dirty buffers out to disk, to ensure source database is |