Cleanup SubPlanstate
Hello hackers,
While reviewing a related patch, it came to the notice that tab_eq_funcs in
the SubPlanState is not used. Hence the patch.
--
Regards,
Rafia Sabih
CYBERTEC PostgreSQL International GmbH
Attachments:
0001-Remove-the-unused-field-from-the-struct-SubPlanState.patchapplication/x-patch; name=0001-Remove-the-unused-field-from-the-struct-SubPlanState.patchDownload
From 9415a530ff6557f424d9c04d7aace697d0fe2883 Mon Sep 17 00:00:00 2001
From: rafia sabih <rafia.sabih@cybertec.at>
Date: Tue, 29 Oct 2024 14:48:01 +0100
Subject: [PATCH] Remove the unused field from the struct SubPlanState.
---
src/backend/executor/nodeSubplan.c | 4 ----
src/include/nodes/execnodes.h | 4 +---
2 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/src/backend/executor/nodeSubplan.c b/src/backend/executor/nodeSubplan.c
index a96cdd01e1..236222d72a 100644
--- a/src/backend/executor/nodeSubplan.c
+++ b/src/backend/executor/nodeSubplan.c
@@ -856,7 +856,6 @@ ExecInitSubPlan(SubPlan *subplan, PlanState *parent)
sstate->keyColIdx = NULL;
sstate->tab_eq_funcoids = NULL;
sstate->tab_hash_funcs = NULL;
- sstate->tab_eq_funcs = NULL;
sstate->tab_collations = NULL;
sstate->lhs_hash_funcs = NULL;
sstate->cur_eq_funcs = NULL;
@@ -954,7 +953,6 @@ ExecInitSubPlan(SubPlan *subplan, PlanState *parent)
sstate->tab_eq_funcoids = (Oid *) palloc(ncols * sizeof(Oid));
sstate->tab_collations = (Oid *) palloc(ncols * sizeof(Oid));
sstate->tab_hash_funcs = (FmgrInfo *) palloc(ncols * sizeof(FmgrInfo));
- sstate->tab_eq_funcs = (FmgrInfo *) palloc(ncols * sizeof(FmgrInfo));
sstate->lhs_hash_funcs = (FmgrInfo *) palloc(ncols * sizeof(FmgrInfo));
sstate->cur_eq_funcs = (FmgrInfo *) palloc(ncols * sizeof(FmgrInfo));
/* we'll need the cross-type equality fns below, but not in sstate */
@@ -999,8 +997,6 @@ ExecInitSubPlan(SubPlan *subplan, PlanState *parent)
elog(ERROR, "could not find compatible hash operator for operator %u",
opexpr->opno);
sstate->tab_eq_funcoids[i - 1] = get_opcode(rhs_eq_oper);
- fmgr_info(sstate->tab_eq_funcoids[i - 1],
- &sstate->tab_eq_funcs[i - 1]);
/* Lookup the associated hash functions */
if (!get_op_hash_functions(opexpr->opno,
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index b67d5186a2..cee0a7b1c4 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -795,8 +795,7 @@ typedef struct ExecAuxRowMark
*
* All-in-memory tuple hash tables are used for a number of purposes.
*
- * Note: tab_hash_funcs are for the key datatype(s) stored in the table,
- * and tab_eq_funcs are non-cross-type equality operators for those types.
+ * Note: tab_hash_funcs are for the key datatype(s) stored in the table.
* Normally these are the only functions used, but FindTupleHashEntry()
* supports searching a hashtable using cross-data-type hashing. For that,
* the caller must supply hash functions for the LHS datatype as well as
@@ -994,7 +993,6 @@ typedef struct SubPlanState
* datatype(s) */
Oid *tab_collations; /* collations for hash and comparison */
FmgrInfo *tab_hash_funcs; /* hash functions for table datatype(s) */
- FmgrInfo *tab_eq_funcs; /* equality functions for table datatype(s) */
FmgrInfo *lhs_hash_funcs; /* hash functions for lefthand datatype(s) */
FmgrInfo *cur_eq_funcs; /* equality functions for LHS vs. table */
ExprState *cur_eq_comp; /* equality comparator for LHS vs. table */
--
2.39.3 (Apple Git-146)
On 10/29/24 21:34, Rafia Sabih wrote:
Hello hackers,
While reviewing a related patch, it came to the notice that tab_eq_funcs
in the SubPlanState is not used. Hence the patch.
Ok.
My initial doubt in such cases is - may it be the case where we mask a
mistake? But that case looks good. Introduced in ab05eed, the approach
with an equality function for each grouping column was replaced by
bf6c614, which moved the grouping operation execution via the expression
evaluation machinery. That made the tab_eq_funcs useless.
So, I think it may be removed.
--
regards, Andrei Lepikhov
On Wed, 30 Oct 2024 at 03:34, Rafia Sabih <rafia.pghackers@gmail.com> wrote:
While reviewing a related patch, it came to the notice that tab_eq_funcs in the SubPlanState is not used. Hence the patch.
Thanks for picking that up. I didn't quite understand why you adjusted
the header comment for the TupleHashEntryData struct when the field
you removed was in the SubPlanState struct, so I left that part out.
However, I did fix the existing typo in that comment.
I've pushed the resulting patch.
David