From a64846f3ada1a4ecc6ca8123777217b3c7781160 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 25 Nov 2003 21:00:54 +0000 Subject: Get rid of hashkeys field of Hash plan node, since it's redundant with the hashclauses field of the parent HashJoin. This avoids problems with duplicated links to SubPlans in hash clauses, as per report from Andrew Holm-Hansen. --- src/backend/executor/nodeHashjoin.c | 39 +++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'src/backend/executor/nodeHashjoin.c') diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c index 112155bdd3..be0543ac61 100644 --- a/src/backend/executor/nodeHashjoin.c +++ b/src/backend/executor/nodeHashjoin.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.57 2003/09/25 06:57:59 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.58 2003/11/25 21:00:52 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -308,7 +308,8 @@ ExecInitHashJoin(HashJoin *node, EState *estate) HashJoinState *hjstate; Plan *outerNode; Hash *hashNode; - List *hclauses; + List *lclauses; + List *rclauses; List *hoperators; List *hcl; @@ -410,31 +411,31 @@ ExecInitHashJoin(HashJoin *node, EState *estate) hjstate->hj_CurTuple = (HashJoinTuple) NULL; /* - * The planner already made a list of the inner hashkeys for us, but - * we also need a list of the outer hashkeys, as well as a list of the - * hash operator OIDs. Both lists of exprs must then be prepared for - * execution. + * Deconstruct the hash clauses into outer and inner argument values, + * so that we can evaluate those subexpressions separately. Also make + * a list of the hash operator OIDs, in preparation for looking up the + * hash functions to use. */ - hjstate->hj_InnerHashKeys = (List *) - ExecInitExpr((Expr *) hashNode->hashkeys, - innerPlanState(hjstate)); - ((HashState *) innerPlanState(hjstate))->hashkeys = - hjstate->hj_InnerHashKeys; - - hclauses = NIL; + lclauses = NIL; + rclauses = NIL; hoperators = NIL; - foreach(hcl, node->hashclauses) + foreach(hcl, hjstate->hashclauses) { - OpExpr *hclause = (OpExpr *) lfirst(hcl); + FuncExprState *fstate = (FuncExprState *) lfirst(hcl); + OpExpr *hclause; + Assert(IsA(fstate, FuncExprState)); + hclause = (OpExpr *) fstate->xprstate.expr; Assert(IsA(hclause, OpExpr)); - hclauses = lappend(hclauses, get_leftop((Expr *) hclause)); + lclauses = lappend(lclauses, lfirst(fstate->args)); + rclauses = lappend(rclauses, lsecond(fstate->args)); hoperators = lappendo(hoperators, hclause->opno); } - hjstate->hj_OuterHashKeys = (List *) - ExecInitExpr((Expr *) hclauses, - (PlanState *) hjstate); + 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; hjstate->js.ps.ps_OuterTupleSlot = NULL; hjstate->js.ps.ps_TupFromTlist = false; -- cgit v1.2.1