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:48 -0400 |
commit | ec1339ea5cb591da53ad7584ffc29e120f6bf74f (patch) | |
tree | b3945717c68886e71cd9fdb719c1bd9783a04959 /src/backend/commands/tablecmds.c | |
parent | 046d52f7d319419d338fa605f9d6e00b21c5c5ff (diff) | |
download | postgresql-ec1339ea5cb591da53ad7584ffc29e120f6bf74f.tar.gz postgresql-ec1339ea5cb591da53ad7584ffc29e120f6bf74f.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 142419f2cca..4d4d4069ee8 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -3409,14 +3409,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, @@ -5508,7 +5506,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 |