Remove unused function argument

Started by Peter Eisentrautabout 6 years ago3 messages
#1Peter Eisentraut
peter.eisentraut@2ndquadrant.com
1 attachment(s)

The cache_plan argument to ri_PlanCheck has not been used since
e8c9fd5fdf768323911f7088e8287f63b513c3c6. I propose to remove it.

That commit said "I left it alone in case there is any future need for
it" but there hasn't been a need in 7 years, and I find it confusing to
have an unused function argument without a clear purpose. It would
trivial to put it back if needed.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachments:

0001-Remove-unused-function-argument.patchtext/plain; charset=UTF-8; name=0001-Remove-unused-function-argument.patch; x-mac-creator=0; x-mac-type=0Download
From 942a2a9fd19fdeb79e82b9849a55daf7fa5b9bff Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Tue, 29 Oct 2019 10:13:14 +0100
Subject: [PATCH] Remove unused function argument

The cache_plan argument to ri_PlanCheck has not been used since
e8c9fd5fdf768323911f7088e8287f63b513c3c6.
---
 src/backend/utils/adt/ri_triggers.c | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c
index de0f810062..ef946d5ef5 100644
--- a/src/backend/utils/adt/ri_triggers.c
+++ b/src/backend/utils/adt/ri_triggers.c
@@ -210,8 +210,7 @@ static const RI_ConstraintInfo *ri_FetchConstraintInfo(Trigger *trigger,
 													   Relation trig_rel, bool rel_is_pk);
 static const RI_ConstraintInfo *ri_LoadConstraintInfo(Oid constraintOid);
 static SPIPlanPtr ri_PlanCheck(const char *querystr, int nargs, Oid *argtypes,
-							   RI_QueryKey *qkey, Relation fk_rel, Relation pk_rel,
-							   bool cache_plan);
+							   RI_QueryKey *qkey, Relation fk_rel, Relation pk_rel);
 static bool ri_PerformCheck(const RI_ConstraintInfo *riinfo,
 							RI_QueryKey *qkey, SPIPlanPtr qplan,
 							Relation fk_rel, Relation pk_rel,
@@ -422,7 +421,7 @@ RI_FKey_check(TriggerData *trigdata)
 
 		/* Prepare and save the plan */
 		qplan = ri_PlanCheck(querybuf.data, riinfo->nkeys, queryoids,
-							 &qkey, fk_rel, pk_rel, true);
+							 &qkey, fk_rel, pk_rel);
 	}
 
 	/*
@@ -549,7 +548,7 @@ ri_Check_Pk_Match(Relation pk_rel, Relation fk_rel,
 
 		/* Prepare and save the plan */
 		qplan = ri_PlanCheck(querybuf.data, riinfo->nkeys, queryoids,
-							 &qkey, fk_rel, pk_rel, true);
+							 &qkey, fk_rel, pk_rel);
 	}
 
 	/*
@@ -741,7 +740,7 @@ ri_restrict(TriggerData *trigdata, bool is_no_action)
 
 		/* Prepare and save the plan */
 		qplan = ri_PlanCheck(querybuf.data, riinfo->nkeys, queryoids,
-							 &qkey, fk_rel, pk_rel, true);
+							 &qkey, fk_rel, pk_rel);
 	}
 
 	/*
@@ -846,7 +845,7 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS)
 
 		/* Prepare and save the plan */
 		qplan = ri_PlanCheck(querybuf.data, riinfo->nkeys, queryoids,
-							 &qkey, fk_rel, pk_rel, true);
+							 &qkey, fk_rel, pk_rel);
 	}
 
 	/*
@@ -968,7 +967,7 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS)
 
 		/* Prepare and save the plan */
 		qplan = ri_PlanCheck(querybuf.data, riinfo->nkeys * 2, queryoids,
-							 &qkey, fk_rel, pk_rel, true);
+							 &qkey, fk_rel, pk_rel);
 	}
 
 	/*
@@ -1147,7 +1146,7 @@ ri_set(TriggerData *trigdata, bool is_set_null)
 
 		/* Prepare and save the plan */
 		qplan = ri_PlanCheck(querybuf.data, riinfo->nkeys, queryoids,
-							 &qkey, fk_rel, pk_rel, true);
+							 &qkey, fk_rel, pk_rel);
 	}
 
 	/*
@@ -2165,8 +2164,7 @@ InvalidateConstraintCacheCallBack(Datum arg, int cacheid, uint32 hashvalue)
  */
 static SPIPlanPtr
 ri_PlanCheck(const char *querystr, int nargs, Oid *argtypes,
-			 RI_QueryKey *qkey, Relation fk_rel, Relation pk_rel,
-			 bool cache_plan)
+			 RI_QueryKey *qkey, Relation fk_rel, Relation pk_rel)
 {
 	SPIPlanPtr	qplan;
 	Relation	query_rel;
@@ -2197,12 +2195,9 @@ ri_PlanCheck(const char *querystr, int nargs, Oid *argtypes,
 	/* Restore UID and security context */
 	SetUserIdAndSecContext(save_userid, save_sec_context);
 
-	/* Save the plan if requested */
-	if (cache_plan)
-	{
-		SPI_keepplan(qplan);
-		ri_HashPreparedPlan(qkey, qplan);
-	}
+	/* Save the plan */
+	SPI_keepplan(qplan);
+	ri_HashPreparedPlan(qkey, qplan);
 
 	return qplan;
 }
-- 
2.23.0

#2vignesh C
vignesh21@gmail.com
In reply to: Peter Eisentraut (#1)
Re: Remove unused function argument

On Tue, Oct 29, 2019 at 2:51 PM Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:

The cache_plan argument to ri_PlanCheck has not been used since
e8c9fd5fdf768323911f7088e8287f63b513c3c6. I propose to remove it.

That commit said "I left it alone in case there is any future need for
it" but there hasn't been a need in 7 years, and I find it confusing to
have an unused function argument without a clear purpose. It would
trivial to put it back if needed.

Code changes looks fine to me.

Regards,
Vignesh
EnterpriseDB: http://www.enterprisedb.com

#3Peter Eisentraut
peter.eisentraut@2ndquadrant.com
In reply to: vignesh C (#2)
Re: Remove unused function argument

On 2019-10-30 06:51, vignesh C wrote:

On Tue, Oct 29, 2019 at 2:51 PM Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:

The cache_plan argument to ri_PlanCheck has not been used since
e8c9fd5fdf768323911f7088e8287f63b513c3c6. I propose to remove it.

That commit said "I left it alone in case there is any future need for
it" but there hasn't been a need in 7 years, and I find it confusing to
have an unused function argument without a clear purpose. It would
trivial to put it back if needed.

Code changes looks fine to me.

pushed, thanks

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services