aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeRecursiveunion.c
diff options
context:
space:
mode:
authorDavid Rowley <drowley@postgresql.org>2024-12-18 12:05:55 +1300
committerDavid Rowley <drowley@postgresql.org>2024-12-18 12:05:55 +1300
commitd96d1d5152f30d15678e08e75b42756101b7cab6 (patch)
treeaa68356a1d930a1a4ed2fdcdf052c4bdb29997b7 /src/backend/executor/nodeRecursiveunion.c
parent84f1b0b031e6914c41623102b93fed8ab0e51253 (diff)
downloadpostgresql-d96d1d5152f30d15678e08e75b42756101b7cab6.tar.gz
postgresql-d96d1d5152f30d15678e08e75b42756101b7cab6.zip
Fix incorrect slot type in BuildTupleHashTableExt
0f5738202 adjusted the execGrouping.c code so it made use of ExprStates to generate hash values. That commit made a wrong assumption that the slot type to pass to ExecBuildHash32FromAttrs() is always &TTSOpsMinimalTuple. That's not the case as the slot type depends on the slot type passed to LookupTupleHashEntry(), which for nodeRecursiveunion.c, could be any of the current slot types. Here we fix this by adding a new parameter to BuildTupleHashTableExt() to allow the slot type to be passed in. In the case of nodeSubplan.c and nodeAgg.c the slot type is always &TTSOpsVirtual, so for both of those cases, it's beneficial to pass the known slot type as that allows ExecBuildHash32FromAttrs() to skip adding the tuple deform step to the resulting ExprState. Another possible fix would have been to have ExecBuildHash32FromAttrs() set "fetch.kind" to NULL so that ExecComputeSlotInfo() always determines the EEOP_INNER_FETCHSOME is required, however, that option isn't favorable as slows down aggregation and hashed subplan evaluation due to the extra (needless) deform step. Thanks to Nathan Bossart for bisecting to find the offending commit based on Paul's report. Reported-by: Paul Ramsey <pramsey@cleverelephant.ca> Discussion: https://postgr.es/m/99F064C1-B3EB-4BE7-97D2-D2A0AA487A71@cleverelephant.ca
Diffstat (limited to 'src/backend/executor/nodeRecursiveunion.c')
-rw-r--r--src/backend/executor/nodeRecursiveunion.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/backend/executor/nodeRecursiveunion.c b/src/backend/executor/nodeRecursiveunion.c
index 22e7b83b2e6..39be4cdc3b1 100644
--- a/src/backend/executor/nodeRecursiveunion.c
+++ b/src/backend/executor/nodeRecursiveunion.c
@@ -37,8 +37,10 @@ build_hash_table(RecursiveUnionState *rustate)
Assert(node->numCols > 0);
Assert(node->numGroups > 0);
+ /* XXX is it worth working a bit harder to determine the inputOps here? */
rustate->hashtable = BuildTupleHashTableExt(&rustate->ps,
desc,
+ NULL,
node->numCols,
node->dupColIdx,
rustate->eqfuncoids,