aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/trigger.c
diff options
context:
space:
mode:
authorNeil Conway <neilc@samurai.com>2005-03-23 07:44:57 +0000
committerNeil Conway <neilc@samurai.com>2005-03-23 07:44:57 +0000
commitf30c76ce8de6a3d9e79367112a9287b576c9e9cd (patch)
tree9017f983db33211276afd59bb3bd3fe89e340532 /src/backend/commands/trigger.c
parentac323044cf6afd43f17adb11d3241737a5e40d7b (diff)
downloadpostgresql-f30c76ce8de6a3d9e79367112a9287b576c9e9cd.tar.gz
postgresql-f30c76ce8de6a3d9e79367112a9287b576c9e9cd.zip
Adjust CREATE TRIGGER and ALTER TABLE ... ADD FOREIGN KEY to acquire
ExclusiveLock rather than AccessExclusiveLock. This will allow concurrent SELECT queries to proceed on the table. Per discussion with Andrew at SuperNews.
Diffstat (limited to 'src/backend/commands/trigger.c')
-rw-r--r--src/backend/commands/trigger.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index fd7d9afb836..55333e1f4f1 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.178 2005/03/20 23:40:24 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.179 2005/03/23 07:44:57 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -87,7 +87,14 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint)
ObjectAddress myself,
referenced;
- rel = heap_openrv(stmt->relation, AccessExclusiveLock);
+ /*
+ * We need to prevent concurrent CREATE TRIGGER commands, as well
+ * as concurrent table modifications (INSERT, DELETE, UPDATE), so
+ * acquire an ExclusiveLock -- it should be fine to allow SELECTs
+ * to proceed. We could perhaps acquire ShareRowExclusiveLock, but
+ * there seems little gain in allowing SELECT FOR UPDATE.
+ */
+ rel = heap_openrv(stmt->relation, ExclusiveLock);
if (stmt->constrrel != NULL)
constrrelid = RangeVarGetRelid(stmt->constrrel, false);