Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 0a271df

Browse files
committed
Clean up some variable names in ri_triggers.c
There was a mix of old_slot/oldslot, new_slot/newslot. Since we've changed everything from row to slot, we might as well take this opportunity to clean this up. Also update some more comments for the slot change.
1 parent 554ebf6 commit 0a271df

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

src/backend/utils/adt/ri_triggers.c

+35-35
Original file line numberDiff line numberDiff line change
@@ -454,10 +454,10 @@ RI_FKey_check_upd(PG_FUNCTION_ARGS)
454454
* ri_Check_Pk_Match
455455
*
456456
* Check to see if another PK row has been created that provides the same
457-
* key values as the "old_row" that's been modified or deleted in our trigger
457+
* key values as the "oldslot" that's been modified or deleted in our trigger
458458
* event. Returns true if a match is found in the PK table.
459459
*
460-
* We assume the caller checked that the old_row contains no NULL key values,
460+
* We assume the caller checked that the oldslot contains no NULL key values,
461461
* since otherwise a match is impossible.
462462
*/
463463
static bool
@@ -625,7 +625,7 @@ ri_restrict(TriggerData *trigdata, bool is_no_action)
625625
const RI_ConstraintInfo *riinfo;
626626
Relation fk_rel;
627627
Relation pk_rel;
628-
TupleTableSlot *old_slot;
628+
TupleTableSlot *oldslot;
629629
RI_QueryKey qkey;
630630
SPIPlanPtr qplan;
631631

@@ -640,7 +640,7 @@ ri_restrict(TriggerData *trigdata, bool is_no_action)
640640
*/
641641
fk_rel = table_open(riinfo->fk_relid, RowShareLock);
642642
pk_rel = trigdata->tg_relation;
643-
old_slot = trigdata->tg_trigslot;
643+
oldslot = trigdata->tg_trigslot;
644644

645645
/*
646646
* If another PK row now exists providing the old key values, we
@@ -649,7 +649,7 @@ ri_restrict(TriggerData *trigdata, bool is_no_action)
649649
* allow another row to be substituted.
650650
*/
651651
if (is_no_action &&
652-
ri_Check_Pk_Match(pk_rel, fk_rel, old_slot, riinfo))
652+
ri_Check_Pk_Match(pk_rel, fk_rel, oldslot, riinfo))
653653
{
654654
table_close(fk_rel, RowShareLock);
655655
return PointerGetDatum(NULL);
@@ -716,7 +716,7 @@ ri_restrict(TriggerData *trigdata, bool is_no_action)
716716
*/
717717
ri_PerformCheck(riinfo, &qkey, qplan,
718718
fk_rel, pk_rel,
719-
old_slot, NULL,
719+
oldslot, NULL,
720720
true, /* must detect new rows */
721721
SPI_OK_SELECT);
722722

@@ -741,7 +741,7 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS)
741741
const RI_ConstraintInfo *riinfo;
742742
Relation fk_rel;
743743
Relation pk_rel;
744-
TupleTableSlot *old_slot;
744+
TupleTableSlot *oldslot;
745745
RI_QueryKey qkey;
746746
SPIPlanPtr qplan;
747747

@@ -759,7 +759,7 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS)
759759
*/
760760
fk_rel = table_open(riinfo->fk_relid, RowExclusiveLock);
761761
pk_rel = trigdata->tg_relation;
762-
old_slot = trigdata->tg_trigslot;
762+
oldslot = trigdata->tg_trigslot;
763763

764764
if (SPI_connect() != SPI_OK_CONNECT)
765765
elog(ERROR, "SPI_connect failed");
@@ -818,7 +818,7 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS)
818818
*/
819819
ri_PerformCheck(riinfo, &qkey, qplan,
820820
fk_rel, pk_rel,
821-
old_slot, NULL,
821+
oldslot, NULL,
822822
true, /* must detect new rows */
823823
SPI_OK_DELETE);
824824

@@ -843,8 +843,8 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS)
843843
const RI_ConstraintInfo *riinfo;
844844
Relation fk_rel;
845845
Relation pk_rel;
846-
TupleTableSlot *new_slot;
847-
TupleTableSlot *old_slot;
846+
TupleTableSlot *newslot;
847+
TupleTableSlot *oldslot;
848848
RI_QueryKey qkey;
849849
SPIPlanPtr qplan;
850850

@@ -863,8 +863,8 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS)
863863
*/
864864
fk_rel = table_open(riinfo->fk_relid, RowExclusiveLock);
865865
pk_rel = trigdata->tg_relation;
866-
new_slot = trigdata->tg_newslot;
867-
old_slot = trigdata->tg_trigslot;
866+
newslot = trigdata->tg_newslot;
867+
oldslot = trigdata->tg_trigslot;
868868

869869
if (SPI_connect() != SPI_OK_CONNECT)
870870
elog(ERROR, "SPI_connect failed");
@@ -935,7 +935,7 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS)
935935
*/
936936
ri_PerformCheck(riinfo, &qkey, qplan,
937937
fk_rel, pk_rel,
938-
old_slot, new_slot,
938+
oldslot, newslot,
939939
true, /* must detect new rows */
940940
SPI_OK_UPDATE);
941941

@@ -989,7 +989,7 @@ ri_setnull(TriggerData *trigdata)
989989
const RI_ConstraintInfo *riinfo;
990990
Relation fk_rel;
991991
Relation pk_rel;
992-
TupleTableSlot *old_slot;
992+
TupleTableSlot *oldslot;
993993
RI_QueryKey qkey;
994994
SPIPlanPtr qplan;
995995

@@ -1004,7 +1004,7 @@ ri_setnull(TriggerData *trigdata)
10041004
*/
10051005
fk_rel = table_open(riinfo->fk_relid, RowExclusiveLock);
10061006
pk_rel = trigdata->tg_relation;
1007-
old_slot = trigdata->tg_trigslot;
1007+
oldslot = trigdata->tg_trigslot;
10081008

10091009
if (SPI_connect() != SPI_OK_CONNECT)
10101010
elog(ERROR, "SPI_connect failed");
@@ -1075,7 +1075,7 @@ ri_setnull(TriggerData *trigdata)
10751075
*/
10761076
ri_PerformCheck(riinfo, &qkey, qplan,
10771077
fk_rel, pk_rel,
1078-
old_slot, NULL,
1078+
oldslot, NULL,
10791079
true, /* must detect new rows */
10801080
SPI_OK_UPDATE);
10811081

@@ -1129,7 +1129,7 @@ ri_setdefault(TriggerData *trigdata)
11291129
const RI_ConstraintInfo *riinfo;
11301130
Relation fk_rel;
11311131
Relation pk_rel;
1132-
TupleTableSlot *old_slot;
1132+
TupleTableSlot *oldslot;
11331133
RI_QueryKey qkey;
11341134
SPIPlanPtr qplan;
11351135

@@ -1144,7 +1144,7 @@ ri_setdefault(TriggerData *trigdata)
11441144
*/
11451145
fk_rel = table_open(riinfo->fk_relid, RowExclusiveLock);
11461146
pk_rel = trigdata->tg_relation;
1147-
old_slot = trigdata->tg_trigslot;
1147+
oldslot = trigdata->tg_trigslot;
11481148

11491149
if (SPI_connect() != SPI_OK_CONNECT)
11501150
elog(ERROR, "SPI_connect failed");
@@ -1215,7 +1215,7 @@ ri_setdefault(TriggerData *trigdata)
12151215
*/
12161216
ri_PerformCheck(riinfo, &qkey, qplan,
12171217
fk_rel, pk_rel,
1218-
old_slot, NULL,
1218+
oldslot, NULL,
12191219
true, /* must detect new rows */
12201220
SPI_OK_UPDATE);
12211221

@@ -1251,11 +1251,11 @@ ri_setdefault(TriggerData *trigdata)
12511251
* trigger must be fired, false if we can prove the constraint will still
12521252
* be satisfied.
12531253
*
1254-
* new_slot will be NULL if this is called for a delete.
1254+
* newslot will be NULL if this is called for a delete.
12551255
*/
12561256
bool
12571257
RI_FKey_pk_upd_check_required(Trigger *trigger, Relation pk_rel,
1258-
TupleTableSlot *old_slot, TupleTableSlot *new_slot)
1258+
TupleTableSlot *oldslot, TupleTableSlot *newslot)
12591259
{
12601260
const RI_ConstraintInfo *riinfo;
12611261

@@ -1265,11 +1265,11 @@ RI_FKey_pk_upd_check_required(Trigger *trigger, Relation pk_rel,
12651265
* If any old key value is NULL, the row could not have been
12661266
* referenced by an FK row, so no check is needed.
12671267
*/
1268-
if (ri_NullCheck(RelationGetDescr(pk_rel), old_slot, riinfo, true) != RI_KEYS_NONE_NULL)
1268+
if (ri_NullCheck(RelationGetDescr(pk_rel), oldslot, riinfo, true) != RI_KEYS_NONE_NULL)
12691269
return false;
12701270

12711271
/* If all old and new key values are equal, no check is needed */
1272-
if (new_slot && ri_KeysEqual(pk_rel, old_slot, new_slot, riinfo, true))
1272+
if (newslot && ri_KeysEqual(pk_rel, oldslot, newslot, riinfo, true))
12731273
return false;
12741274

12751275
/* Else we need to fire the trigger. */
@@ -1287,7 +1287,7 @@ RI_FKey_pk_upd_check_required(Trigger *trigger, Relation pk_rel,
12871287
*/
12881288
bool
12891289
RI_FKey_fk_upd_check_required(Trigger *trigger, Relation fk_rel,
1290-
TupleTableSlot *old_slot, TupleTableSlot *new_slot)
1290+
TupleTableSlot *oldslot, TupleTableSlot *newslot)
12911291
{
12921292
const RI_ConstraintInfo *riinfo;
12931293
int ri_nullcheck;
@@ -1297,7 +1297,7 @@ RI_FKey_fk_upd_check_required(Trigger *trigger, Relation fk_rel,
12971297

12981298
riinfo = ri_FetchConstraintInfo(trigger, fk_rel, false);
12991299

1300-
ri_nullcheck = ri_NullCheck(RelationGetDescr(fk_rel), new_slot, riinfo, false);
1300+
ri_nullcheck = ri_NullCheck(RelationGetDescr(fk_rel), newslot, riinfo, false);
13011301

13021302
/*
13031303
* If all new key values are NULL, the row satisfies the constraint, so no
@@ -1350,14 +1350,14 @@ RI_FKey_fk_upd_check_required(Trigger *trigger, Relation fk_rel,
13501350
* UPDATE check. (We could skip this if we knew the INSERT
13511351
* trigger already fired, but there is no easy way to know that.)
13521352
*/
1353-
xminDatum = slot_getsysattr(old_slot, MinTransactionIdAttributeNumber, &isnull);
1353+
xminDatum = slot_getsysattr(oldslot, MinTransactionIdAttributeNumber, &isnull);
13541354
Assert(!isnull);
13551355
xmin = DatumGetTransactionId(xminDatum);
13561356
if (TransactionIdIsCurrentTransactionId(xmin))
13571357
return true;
13581358

13591359
/* If all old and new key values are equal, no check is needed */
1360-
if (ri_KeysEqual(fk_rel, old_slot, new_slot, riinfo, false))
1360+
if (ri_KeysEqual(fk_rel, oldslot, newslot, riinfo, false))
13611361
return false;
13621362

13631363
/* Else we need to fire the trigger. */
@@ -2047,7 +2047,7 @@ static bool
20472047
ri_PerformCheck(const RI_ConstraintInfo *riinfo,
20482048
RI_QueryKey *qkey, SPIPlanPtr qplan,
20492049
Relation fk_rel, Relation pk_rel,
2050-
TupleTableSlot *old_slot, TupleTableSlot *new_slot,
2050+
TupleTableSlot *oldslot, TupleTableSlot *newslot,
20512051
bool detectNewRows, int expect_OK)
20522052
{
20532053
Relation query_rel,
@@ -2090,17 +2090,17 @@ ri_PerformCheck(const RI_ConstraintInfo *riinfo,
20902090
}
20912091

20922092
/* Extract the parameters to be passed into the query */
2093-
if (new_slot)
2093+
if (newslot)
20942094
{
2095-
ri_ExtractValues(source_rel, new_slot, riinfo, source_is_pk,
2095+
ri_ExtractValues(source_rel, newslot, riinfo, source_is_pk,
20962096
vals, nulls);
2097-
if (old_slot)
2098-
ri_ExtractValues(source_rel, old_slot, riinfo, source_is_pk,
2097+
if (oldslot)
2098+
ri_ExtractValues(source_rel, oldslot, riinfo, source_is_pk,
20992099
vals + riinfo->nkeys, nulls + riinfo->nkeys);
21002100
}
21012101
else
21022102
{
2103-
ri_ExtractValues(source_rel, old_slot, riinfo, source_is_pk,
2103+
ri_ExtractValues(source_rel, oldslot, riinfo, source_is_pk,
21042104
vals, nulls);
21052105
}
21062106

@@ -2170,7 +2170,7 @@ ri_PerformCheck(const RI_ConstraintInfo *riinfo,
21702170
(SPI_processed == 0) == (qkey->constr_queryno == RI_PLAN_CHECK_LOOKUPPK))
21712171
ri_ReportViolation(riinfo,
21722172
pk_rel, fk_rel,
2173-
new_slot ? new_slot : old_slot,
2173+
newslot ? newslot : oldslot,
21742174
NULL,
21752175
qkey->constr_queryno);
21762176

0 commit comments

Comments
 (0)