aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/trigger.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-08-12 01:36:05 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-08-12 01:36:05 +0000
commit721e53785d837d48dc33dd68aa77c42ece7c9afb (patch)
tree59c7bf34cada497f50c61072826d6fa0de080b57 /src/backend/commands/trigger.c
parent9e4a2de8448997924e74ace8dfd9ccd05acb2d08 (diff)
downloadpostgresql-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/trigger.c')
-rw-r--r--src/backend/commands/trigger.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index 9df00d8cbea..4ea973ae7fa 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.190 2005/08/01 20:31:07 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.191 2005/08/12 01:35:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -184,7 +184,9 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint)
* Generate the trigger's OID now, so that we can use it in the name
* if needed.
*/
- trigoid = newoid();
+ tgrel = heap_open(TriggerRelationId, RowExclusiveLock);
+
+ trigoid = GetNewOid(tgrel);
/*
* If trigger is an RI constraint, use specified trigger name as
@@ -252,7 +254,6 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint)
* NOTE that this is cool only because we have AccessExclusiveLock on the
* relation, so the trigger set won't be changing underneath us.
*/
- tgrel = heap_open(TriggerRelationId, RowExclusiveLock);
ScanKeyInit(&key,
Anum_pg_trigger_tgrelid,
BTEqualStrategyNumber, F_OIDEQ,