diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2019-05-22 12:55:34 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2019-05-22 12:55:34 -0400 |
commit | be76af171cdb3e7465c4ef234af403f97ad79b7b (patch) | |
tree | 1fa62d2b7a6680a4237a1548f7002fa0b234b143 /src/backend/utils/adt/ri_triggers.c | |
parent | 66a4bad83aaa6613a45a00a488c04427f9969fb4 (diff) | |
download | postgresql-be76af171cdb3e7465c4ef234af403f97ad79b7b.tar.gz postgresql-be76af171cdb3e7465c4ef234af403f97ad79b7b.zip |
Initial pgindent run for v12.
This is still using the 2.0 version of pg_bsd_indent.
I thought it would be good to commit this separately,
so as to document the differences between 2.0 and 2.1 behavior.
Discussion: https://postgr.es/m/16296.1558103386@sss.pgh.pa.us
Diffstat (limited to 'src/backend/utils/adt/ri_triggers.c')
-rw-r--r-- | src/backend/utils/adt/ri_triggers.c | 70 |
1 files changed, 37 insertions, 33 deletions
diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c index 095334b3363..b9e0f5c048d 100644 --- a/src/backend/utils/adt/ri_triggers.c +++ b/src/backend/utils/adt/ri_triggers.c @@ -635,10 +635,10 @@ ri_restrict(TriggerData *trigdata, bool is_no_action) oldslot = trigdata->tg_trigslot; /* - * If another PK row now exists providing the old key values, we - * should not do anything. However, this check should only be - * made in the NO ACTION case; in RESTRICT cases we don't wish to - * allow another row to be substituted. + * If another PK row now exists providing the old key values, we should + * not do anything. However, this check should only be made in the NO + * ACTION case; in RESTRICT cases we don't wish to allow another row to be + * substituted. */ if (is_no_action && ri_Check_Pk_Match(pk_rel, fk_rel, oldslot, riinfo)) @@ -651,8 +651,8 @@ ri_restrict(TriggerData *trigdata, bool is_no_action) elog(ERROR, "SPI_connect failed"); /* - * Fetch or prepare a saved plan for the restrict lookup (it's the - * same query for delete and update cases) + * Fetch or prepare a saved plan for the restrict lookup (it's the same + * query for delete and update cases) */ ri_BuildQueryKey(&qkey, riinfo, RI_PLAN_RESTRICT_CHECKREF); @@ -713,7 +713,7 @@ ri_restrict(TriggerData *trigdata, bool is_no_action) ri_PerformCheck(riinfo, &qkey, qplan, fk_rel, pk_rel, oldslot, NULL, - true, /* must detect new rows */ + true, /* must detect new rows */ SPI_OK_SELECT); if (SPI_finish() != SPI_OK_FINISH) @@ -813,13 +813,13 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS) } /* - * We have a plan now. Build up the arguments from the key values - * in the deleted PK tuple and delete the referencing rows + * We have a plan now. Build up the arguments from the key values in the + * deleted PK tuple and delete the referencing rows */ ri_PerformCheck(riinfo, &qkey, qplan, fk_rel, pk_rel, oldslot, NULL, - true, /* must detect new rows */ + true, /* must detect new rows */ SPI_OK_DELETE); if (SPI_finish() != SPI_OK_FINISH) @@ -940,7 +940,7 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS) ri_PerformCheck(riinfo, &qkey, qplan, fk_rel, pk_rel, oldslot, newslot, - true, /* must detect new rows */ + true, /* must detect new rows */ SPI_OK_UPDATE); if (SPI_finish() != SPI_OK_FINISH) @@ -1119,7 +1119,7 @@ ri_set(TriggerData *trigdata, bool is_set_null) ri_PerformCheck(riinfo, &qkey, qplan, fk_rel, pk_rel, oldslot, NULL, - true, /* must detect new rows */ + true, /* must detect new rows */ SPI_OK_UPDATE); if (SPI_finish() != SPI_OK_FINISH) @@ -1132,18 +1132,17 @@ ri_set(TriggerData *trigdata, bool is_set_null) else { /* - * If we just deleted or updated the PK row whose key was equal to - * the FK columns' default values, and a referencing row exists in - * the FK table, we would have updated that row to the same values - * it already had --- and RI_FKey_fk_upd_check_required would - * hence believe no check is necessary. So we need to do another - * lookup now and in case a reference still exists, abort the - * operation. That is already implemented in the NO ACTION - * trigger, so just run it. (This recheck is only needed in the - * SET DEFAULT case, since CASCADE would remove such rows in case - * of a DELETE operation or would change the FK key values in case - * of an UPDATE, while SET NULL is certain to result in rows that - * satisfy the FK constraint.) + * If we just deleted or updated the PK row whose key was equal to the + * FK columns' default values, and a referencing row exists in the FK + * table, we would have updated that row to the same values it already + * had --- and RI_FKey_fk_upd_check_required would hence believe no + * check is necessary. So we need to do another lookup now and in + * case a reference still exists, abort the operation. That is + * already implemented in the NO ACTION trigger, so just run it. (This + * recheck is only needed in the SET DEFAULT case, since CASCADE would + * remove such rows in case of a DELETE operation or would change the + * FK key values in case of an UPDATE, while SET NULL is certain to + * result in rows that satisfy the FK constraint.) */ return ri_restrict(trigdata, true); } @@ -1170,8 +1169,8 @@ RI_FKey_pk_upd_check_required(Trigger *trigger, Relation pk_rel, riinfo = ri_FetchConstraintInfo(trigger, pk_rel, true); /* - * If any old key value is NULL, the row could not have been - * referenced by an FK row, so no check is needed. + * If any old key value is NULL, the row could not have been referenced by + * an FK row, so no check is needed. */ if (ri_NullCheck(RelationGetDescr(pk_rel), oldslot, riinfo, true) != RI_KEYS_NONE_NULL) return false; @@ -1213,14 +1212,17 @@ RI_FKey_fk_upd_check_required(Trigger *trigger, Relation fk_rel, */ if (ri_nullcheck == RI_KEYS_ALL_NULL) return false; + /* - * If some new key values are NULL, the behavior depends on the match type. + * If some new key values are NULL, the behavior depends on the match + * type. */ else if (ri_nullcheck == RI_KEYS_SOME_NULL) { switch (riinfo->confmatchtype) { case FKCONSTR_MATCH_SIMPLE: + /* * If any new key value is NULL, the row must satisfy the * constraint, so no check is needed. @@ -1228,12 +1230,14 @@ RI_FKey_fk_upd_check_required(Trigger *trigger, Relation fk_rel, return false; case FKCONSTR_MATCH_PARTIAL: + /* * Don't know, must run full check. */ break; case FKCONSTR_MATCH_FULL: + /* * If some new key values are NULL, the row fails the * constraint. We must not throw error here, because the row @@ -1251,12 +1255,12 @@ RI_FKey_fk_upd_check_required(Trigger *trigger, Relation fk_rel, */ /* - * If the original row was inserted by our own transaction, we - * must fire the trigger whether or not the keys are equal. This - * is because our UPDATE will invalidate the INSERT so that the - * INSERT RI trigger will not do anything; so we had better do the - * UPDATE check. (We could skip this if we knew the INSERT - * trigger already fired, but there is no easy way to know that.) + * If the original row was inserted by our own transaction, we must fire + * the trigger whether or not the keys are equal. This is because our + * UPDATE will invalidate the INSERT so that the INSERT RI trigger will + * not do anything; so we had better do the UPDATE check. (We could skip + * this if we knew the INSERT trigger already fired, but there is no easy + * way to know that.) */ xminDatum = slot_getsysattr(oldslot, MinTransactionIdAttributeNumber, &isnull); Assert(!isnull); |