diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-11-25 21:00:54 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-11-25 21:00:54 +0000 |
commit | a64846f3ada1a4ecc6ca8123777217b3c7781160 (patch) | |
tree | 703df98e0295f119b70fc8656d026fdec1592f3c /src/backend/executor/nodeHashjoin.c | |
parent | 38ba28e5c11aa53ccf5b2c4cdb8ab427b42ebca2 (diff) | |
download | postgresql-a64846f3ada1a4ecc6ca8123777217b3c7781160.tar.gz postgresql-a64846f3ada1a4ecc6ca8123777217b3c7781160.zip |
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.
Diffstat (limited to 'src/backend/executor/nodeHashjoin.c')
-rw-r--r-- | src/backend/executor/nodeHashjoin.c | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c index 112155bdd37..be0543ac613 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; |