diff options
author | Andres Freund <andres@anarazel.de> | 2018-11-07 09:25:54 -0800 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2018-11-07 09:25:54 -0800 |
commit | 5f32b29c18195299e90c1fb6c8945e9a46d772d2 (patch) | |
tree | 344f2e11da1804a2fdaac3fb019d590c1ecfad42 /src/backend/executor/nodeHashjoin.c | |
parent | da906766cd3bef8290db25bd5c8776c03689f3d5 (diff) | |
download | postgresql-5f32b29c18195299e90c1fb6c8945e9a46d772d2.tar.gz postgresql-5f32b29c18195299e90c1fb6c8945e9a46d772d2.zip |
Build HashState's hashkeys expression with the correct parent.
Previously the expressions were built with the HashJoinState as a
parent. That's incorrect.
Currently this does not appear to be harmful, but for the upcoming
'slot abstraction' work this proves to be problematic, as the
underlying slot types can differ between Hash and HashJoin. It's
possible that this already causes a problem, but I've not been able to
come up with a scenario. Therefore don't backpatch at this point.
Author: Andres Freund
Discussion: https://postgr.es/m/20180220224318.gw4oe5jadhpmcdnm@alap3.anarazel.de
Diffstat (limited to 'src/backend/executor/nodeHashjoin.c')
-rw-r--r-- | src/backend/executor/nodeHashjoin.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c index 5922e60eed6..d017bbfbd33 100644 --- a/src/backend/executor/nodeHashjoin.c +++ b/src/backend/executor/nodeHashjoin.c @@ -595,6 +595,7 @@ ExecInitHashJoin(HashJoin *node, EState *estate, int eflags) Hash *hashNode; List *lclauses; List *rclauses; + List *rhclauses; List *hoperators; TupleDesc outerDesc, innerDesc; @@ -726,6 +727,7 @@ ExecInitHashJoin(HashJoin *node, EState *estate, int eflags) */ lclauses = NIL; rclauses = NIL; + rhclauses = NIL; hoperators = NIL; foreach(l, node->hashclauses) { @@ -735,13 +737,15 @@ ExecInitHashJoin(HashJoin *node, EState *estate, int eflags) (PlanState *) hjstate)); rclauses = lappend(rclauses, ExecInitExpr(lsecond(hclause->args), (PlanState *) hjstate)); + rhclauses = lappend(rhclauses, ExecInitExpr(lsecond(hclause->args), + innerPlanState(hjstate))); hoperators = lappend_oid(hoperators, hclause->opno); } hjstate->hj_OuterHashKeys = lclauses; hjstate->hj_InnerHashKeys = rclauses; hjstate->hj_HashOperators = hoperators; /* child Hash node needs to evaluate inner hash keys, too */ - ((HashState *) innerPlanState(hjstate))->hashkeys = rclauses; + ((HashState *) innerPlanState(hjstate))->hashkeys = rhclauses; hjstate->hj_JoinState = HJ_BUILD_HASHTABLE; hjstate->hj_MatchedOuter = false; |