From 2a0ddd8a34b96df8dabe18a9fa2481768bbbcbf8 Mon Sep 17 00:00:00 2001
From: Amul Sul <amul.sul@enterprisedb.com>
Date: Mon, 20 Jan 2025 18:49:41 +0530
Subject: [PATCH v13 4/9] refactor: Pass Relid instead of Relation to
 createForeignKeyCheckTriggers().

Currently, createForeignKeyCheckTriggers() takes a Relation type as
its first argument, but it doesn't use that argument directly.
Instead, it fetches the Relid by calling RelationGetRelid().
Therefore, it would be more consistent with other functions (e.g.,
createForeignKeyCheckTriggers()) to pass the Relid directly instead of
the whole Relation.
---
 src/backend/commands/tablecmds.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index dc0bf8c629f..5a7f4808821 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -569,7 +569,7 @@ static void createForeignKeyCheckTriggers(Oid myRelOid, Oid refRelOid,
 										  Oid indexOid,
 										  Oid parentInsTrigger, Oid parentUpdTrigger,
 										  Oid *insertTrigOid, Oid *updateTrigOid);
-static void createForeignKeyActionTriggers(Relation rel, Oid refRelOid,
+static void createForeignKeyActionTriggers(Oid myRelOid, Oid refRelOid,
 										   Constraint *fkconstraint, Oid constraintOid,
 										   Oid indexOid,
 										   Oid parentDelTrigger, Oid parentUpdTrigger,
@@ -10659,7 +10659,8 @@ addFkRecurseReferenced(Constraint *fkconstraint, Relation rel,
 	/*
 	 * Create the action triggers that enforce the constraint.
 	 */
-	createForeignKeyActionTriggers(rel, RelationGetRelid(pkrel),
+	createForeignKeyActionTriggers(RelationGetRelid(rel),
+								   RelationGetRelid(pkrel),
 								   fkconstraint,
 								   parentConstr, indexOid,
 								   parentDelTrigger, parentUpdTrigger,
@@ -13034,10 +13035,11 @@ CreateFKCheckTrigger(Oid myRelOid, Oid refRelOid, Constraint *fkconstraint,
  * *updateTrigOid.
  */
 static void
-createForeignKeyActionTriggers(Relation rel, Oid refRelOid, Constraint *fkconstraint,
-							   Oid constraintOid, Oid indexOid,
-							   Oid parentDelTrigger, Oid parentUpdTrigger,
-							   Oid *deleteTrigOid, Oid *updateTrigOid)
+createForeignKeyActionTriggers(Oid myRelOid, Oid refRelOid,
+							   Constraint *fkconstraint, Oid constraintOid,
+							   Oid indexOid, Oid parentDelTrigger,
+							   Oid parentUpdTrigger, Oid *deleteTrigOid,
+							   Oid *updateTrigOid)
 {
 	CreateTrigStmt *fk_trigger;
 	ObjectAddress trigAddress;
@@ -13093,8 +13095,7 @@ createForeignKeyActionTriggers(Relation rel, Oid refRelOid, Constraint *fkconstr
 			break;
 	}
 
-	trigAddress = CreateTrigger(fk_trigger, NULL, refRelOid,
-								RelationGetRelid(rel),
+	trigAddress = CreateTrigger(fk_trigger, NULL, refRelOid, myRelOid,
 								constraintOid, indexOid, InvalidOid,
 								parentDelTrigger, NULL, true, false);
 	if (deleteTrigOid)
@@ -13154,8 +13155,7 @@ createForeignKeyActionTriggers(Relation rel, Oid refRelOid, Constraint *fkconstr
 			break;
 	}
 
-	trigAddress = CreateTrigger(fk_trigger, NULL, refRelOid,
-								RelationGetRelid(rel),
+	trigAddress = CreateTrigger(fk_trigger, NULL, refRelOid, myRelOid,
 								constraintOid, indexOid, InvalidOid,
 								parentUpdTrigger, NULL, true, false);
 	if (updateTrigOid)
-- 
2.43.5

