From 09d3670df3e4593be1d2299a62d982829016b847 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 31 Jul 2006 20:09:10 +0000 Subject: Change the relation_open protocol so that we obtain lock on a relation (table or index) before trying to open its relcache entry. This fixes race conditions in which someone else commits a change to the relation's catalog entries while we are in process of doing relcache load. Problems of that ilk have been reported sporadically for years, but it was not really practical to fix until recently --- for instance, the recent addition of WAL-log support for in-place updates helped. Along the way, remove pg_am.amconcurrent: all AMs are now expected to support concurrent update. --- src/backend/commands/trigger.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src/backend/commands/trigger.c') diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index 158e783c575..13e7cab721b 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.204 2006/07/14 14:52:18 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.205 2006/07/31 20:09:00 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -36,7 +36,6 @@ #include "utils/inval.h" #include "utils/lsyscache.h" #include "utils/memutils.h" -#include "utils/relcache.h" #include "utils/syscache.h" @@ -2986,7 +2985,6 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt) while (HeapTupleIsValid(htup = systable_getnext(tgscan))) { Form_pg_trigger pg_trigger = (Form_pg_trigger) GETSTRUCT(htup); - Relation constraintRel; Oid constraintNamespaceId; /* @@ -3010,13 +3008,9 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt) pg_trigger->tgfoid == F_RI_FKEY_SETNULL_DEL || pg_trigger->tgfoid == F_RI_FKEY_SETDEFAULT_UPD || pg_trigger->tgfoid == F_RI_FKEY_SETDEFAULT_DEL) - { - constraintRel = RelationIdGetRelation(pg_trigger->tgconstrrelid); - } else { - constraintRel = RelationIdGetRelation(pg_trigger->tgrelid); - } - constraintNamespaceId = RelationGetNamespace(constraintRel); - RelationClose(constraintRel); + constraintNamespaceId = get_rel_namespace(pg_trigger->tgconstrrelid); + else + constraintNamespaceId = get_rel_namespace(pg_trigger->tgrelid); /* * If this constraint is not in the schema we're -- cgit v1.2.3