diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2011-07-07 13:14:46 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2011-07-07 13:15:15 -0400 |
commit | a195e3c34f1eeb6a607c342121edf48e49067ea9 (patch) | |
tree | 75dbe45ab465bbe8bc519db9856ac761a2a2a6b7 /src/backend/commands/tablecmds.c | |
parent | 928408d9e5b4b389897b799b3b6af505d719a3f6 (diff) | |
download | postgresql-a195e3c34f1eeb6a607c342121edf48e49067ea9.tar.gz postgresql-a195e3c34f1eeb6a607c342121edf48e49067ea9.zip |
Finish disabling reduced-lock-levels-for-DDL feature.
Previous patch only covered the ALTER TABLE changes, not changes in other
commands; and it neglected to revert the documentation changes.
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r-- | src/backend/commands/tablecmds.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 3bc350a1134..c1af12a5a30 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -3425,14 +3425,12 @@ ATRewriteTables(List **wqueue, LOCKMODE lockmode) Relation refrel; if (rel == NULL) + { /* Long since locked, no need for another */ rel = heap_open(tab->relid, NoLock); + } - /* - * We're adding a trigger to both tables, so the lock level - * here should sensibly reflect that. - */ - refrel = heap_open(con->refrelid, ShareRowExclusiveLock); + refrel = heap_open(con->refrelid, RowShareLock); validateForeignKeyConstraint(fkconstraint->conname, rel, refrel, con->refindid, @@ -5529,7 +5527,14 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel, Oid indexOid; Oid constrOid; - pkrel = heap_openrv(fkconstraint->pktable, lockmode); + /* + * Grab an exclusive lock on the pk table, so that someone doesn't delete + * rows out from under us. (Although a lesser lock would do for that + * purpose, we'll need exclusive lock anyway to add triggers to the pk + * table; trying to start with a lesser lock will just create a risk of + * deadlock.) + */ + pkrel = heap_openrv(fkconstraint->pktable, AccessExclusiveLock); /* * Validity checks (permission checks wait till we have the column |