aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/ri_triggers.c
diff options
context:
space:
mode:
authorSimon Riggs <simon@2ndQuadrant.com>2011-02-08 12:23:20 +0000
committerSimon Riggs <simon@2ndQuadrant.com>2011-02-08 12:23:20 +0000
commit722bf7017bbe796decc79c1fde03e7a83dae9ada (patch)
tree94145fc7a78c140f753d856bae8edf54bcce93b3 /src/backend/utils/adt/ri_triggers.c
parent7202ad7b8dd07864092be70287fe971ec72a3fbc (diff)
downloadpostgresql-722bf7017bbe796decc79c1fde03e7a83dae9ada.tar.gz
postgresql-722bf7017bbe796decc79c1fde03e7a83dae9ada.zip
Extend ALTER TABLE to allow Foreign Keys to be added without initial validation.
FK constraints that are marked NOT VALID may later be VALIDATED, which uses an ShareUpdateExclusiveLock on constraint table and RowShareLock on referenced table. Significantly reduces lock strength and duration when adding FKs. New state visible from psql. Simon Riggs, with reviews from Marko Tiikkaja and Robert Haas
Diffstat (limited to 'src/backend/utils/adt/ri_triggers.c')
-rw-r--r--src/backend/utils/adt/ri_triggers.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c
index 7bc1ab1e812..5ef1563d1c9 100644
--- a/src/backend/utils/adt/ri_triggers.c
+++ b/src/backend/utils/adt/ri_triggers.c
@@ -2608,8 +2608,11 @@ RI_FKey_keyequal_upd_fk(Trigger *trigger, Relation fk_rel,
* This is not a trigger procedure, but is called during ALTER TABLE
* ADD FOREIGN KEY to validate the initial table contents.
*
- * We expect that a ShareRowExclusiveLock or higher has been taken on rel and pkrel;
- * hence, we do not need to lock individual rows for the check.
+ * We expect that the caller has made provision to prevent any problems
+ * caused by concurrent actions. This could be either by locking rel and
+ * pkrel at ShareRowExclusiveLock or higher, or by otherwise ensuring
+ * that triggers implementing the checks are already active.
+ * Hence, we do not need to lock individual rows for the check.
*
* If the check fails because the current user doesn't have permissions
* to read both tables, return false to let our caller know that they will