Skip to content

Commit 50ce8ab

Browse files
author
Neil Conway
committed
Revert changes to CREATE TRIGGER and ALTER TABLE ADD FOREIGN KEY locking,
per request from Tom.
1 parent 8abba63 commit 50ce8ab

File tree

3 files changed

+13
-21
lines changed

3 files changed

+13
-21
lines changed

doc/src/sgml/mvcc.sgml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/mvcc.sgml,v 2.48 2005/03/23 07:44:56 neilc Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/mvcc.sgml,v 2.49 2005/03/24 00:03:18 neilc Exp $
33
-->
44

55
<chapter id="mvcc">
@@ -677,10 +677,9 @@ SELECT SUM(value) FROM mytab WHERE class = 2;
677677
</para>
678678

679679
<para>
680-
Acquired by <command>CREATE TRIGGER</command> and
681-
<command>ALTER TABLE ADD FOREIGN KEY</command>. This lock
682-
mode can also be acquired on certain system catalogs in some
683-
operations.
680+
This lock mode is not automatically acquired on user tables by any
681+
<productname>PostgreSQL</productname> command. However it is
682+
acquired on certain system catalogs in some operations.
684683
</para>
685684
</listitem>
686685
</varlistentry>

src/backend/commands/tablecmds.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.149 2005/03/23 07:44:57 neilc Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.150 2005/03/24 00:03:22 neilc Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -3829,13 +3829,13 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel,
38293829
Oid constrOid;
38303830

38313831
/*
3832-
* Grab a lock on the pk table, so that someone doesn't delete
3833-
* rows out from under us. We will eventually need to add triggers
3834-
* to the table, at which point we'll need to an ExclusiveLock --
3835-
* therefore we grab an ExclusiveLock now to prevent possible
3836-
* deadlock.
3832+
* Grab an exclusive lock on the pk table, so that someone doesn't
3833+
* delete rows out from under us. (Although a lesser lock would do for
3834+
* that purpose, we'll need exclusive lock anyway to add triggers to
3835+
* the pk table; trying to start with a lesser lock will just create a
3836+
* risk of deadlock.)
38373837
*/
3838-
pkrel = heap_openrv(fkconstraint->pktable, ExclusiveLock);
3838+
pkrel = heap_openrv(fkconstraint->pktable, AccessExclusiveLock);
38393839

38403840
/*
38413841
* Validity and permissions checks

src/backend/commands/trigger.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.179 2005/03/23 07:44:57 neilc Exp $
10+
* $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.180 2005/03/24 00:03:26 neilc Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -87,14 +87,7 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint)
8787
ObjectAddress myself,
8888
referenced;
8989

90-
/*
91-
* We need to prevent concurrent CREATE TRIGGER commands, as well
92-
* as concurrent table modifications (INSERT, DELETE, UPDATE), so
93-
* acquire an ExclusiveLock -- it should be fine to allow SELECTs
94-
* to proceed. We could perhaps acquire ShareRowExclusiveLock, but
95-
* there seems little gain in allowing SELECT FOR UPDATE.
96-
*/
97-
rel = heap_openrv(stmt->relation, ExclusiveLock);
90+
rel = heap_openrv(stmt->relation, AccessExclusiveLock);
9891

9992
if (stmt->constrrel != NULL)
10093
constrrelid = RangeVarGetRelid(stmt->constrrel, false);

0 commit comments

Comments
 (0)