|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.57 2003/09/25 06:57:59 petere Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.58 2003/11/25 21:00:52 tgl Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -308,7 +308,8 @@ ExecInitHashJoin(HashJoin *node, EState *estate)
|
308 | 308 | HashJoinState *hjstate;
|
309 | 309 | Plan *outerNode;
|
310 | 310 | Hash *hashNode;
|
311 |
| - List *hclauses; |
| 311 | + List *lclauses; |
| 312 | + List *rclauses; |
312 | 313 | List *hoperators;
|
313 | 314 | List *hcl;
|
314 | 315 |
|
@@ -410,31 +411,31 @@ ExecInitHashJoin(HashJoin *node, EState *estate)
|
410 | 411 | hjstate->hj_CurTuple = (HashJoinTuple) NULL;
|
411 | 412 |
|
412 | 413 | /*
|
413 |
| - * The planner already made a list of the inner hashkeys for us, but |
414 |
| - * we also need a list of the outer hashkeys, as well as a list of the |
415 |
| - * hash operator OIDs. Both lists of exprs must then be prepared for |
416 |
| - * execution. |
| 414 | + * Deconstruct the hash clauses into outer and inner argument values, |
| 415 | + * so that we can evaluate those subexpressions separately. Also make |
| 416 | + * a list of the hash operator OIDs, in preparation for looking up the |
| 417 | + * hash functions to use. |
417 | 418 | */
|
418 |
| - hjstate->hj_InnerHashKeys = (List *) |
419 |
| - ExecInitExpr((Expr *) hashNode->hashkeys, |
420 |
| - innerPlanState(hjstate)); |
421 |
| - ((HashState *) innerPlanState(hjstate))->hashkeys = |
422 |
| - hjstate->hj_InnerHashKeys; |
423 |
| - |
424 |
| - hclauses = NIL; |
| 419 | + lclauses = NIL; |
| 420 | + rclauses = NIL; |
425 | 421 | hoperators = NIL;
|
426 |
| - foreach(hcl, node->hashclauses) |
| 422 | + foreach(hcl, hjstate->hashclauses) |
427 | 423 | {
|
428 |
| - OpExpr *hclause = (OpExpr *) lfirst(hcl); |
| 424 | + FuncExprState *fstate = (FuncExprState *) lfirst(hcl); |
| 425 | + OpExpr *hclause; |
429 | 426 |
|
| 427 | + Assert(IsA(fstate, FuncExprState)); |
| 428 | + hclause = (OpExpr *) fstate->xprstate.expr; |
430 | 429 | Assert(IsA(hclause, OpExpr));
|
431 |
| - hclauses = lappend(hclauses, get_leftop((Expr *) hclause)); |
| 430 | + lclauses = lappend(lclauses, lfirst(fstate->args)); |
| 431 | + rclauses = lappend(rclauses, lsecond(fstate->args)); |
432 | 432 | hoperators = lappendo(hoperators, hclause->opno);
|
433 | 433 | }
|
434 |
| - hjstate->hj_OuterHashKeys = (List *) |
435 |
| - ExecInitExpr((Expr *) hclauses, |
436 |
| - (PlanState *) hjstate); |
| 434 | + hjstate->hj_OuterHashKeys = lclauses; |
| 435 | + hjstate->hj_InnerHashKeys = rclauses; |
437 | 436 | hjstate->hj_HashOperators = hoperators;
|
| 437 | + /* child Hash node needs to evaluate inner hash keys, too */ |
| 438 | + ((HashState *) innerPlanState(hjstate))->hashkeys = rclauses; |
438 | 439 |
|
439 | 440 | hjstate->js.ps.ps_OuterTupleSlot = NULL;
|
440 | 441 | hjstate->js.ps.ps_TupFromTlist = false;
|
|
0 commit comments