|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.52 2000/07/12 02:37:03 tgl Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.53 2000/08/13 02:50:03 tgl Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -281,6 +281,16 @@ IndexNext(IndexScan *node)
|
281 | 281 | TupleTableSlot *
|
282 | 282 | ExecIndexScan(IndexScan *node)
|
283 | 283 | {
|
| 284 | + IndexScanState *indexstate = node->indxstate; |
| 285 | + |
| 286 | + /* ---------------- |
| 287 | + * If we have runtime keys and they've not already been set up, |
| 288 | + * do it now. |
| 289 | + * ---------------- |
| 290 | + */ |
| 291 | + if (indexstate->iss_RuntimeKeyInfo && !indexstate->iss_RuntimeKeysReady) |
| 292 | + ExecReScan((Plan *) node, NULL, NULL); |
| 293 | + |
284 | 294 | /* ----------------
|
285 | 295 | * use IndexNext as access method
|
286 | 296 | * ----------------
|
@@ -335,9 +345,10 @@ ExecIndexReScan(IndexScan *node, ExprContext *exprCtxt, Plan *parent)
|
335 | 345 | scanKeys = indexstate->iss_ScanKeys;
|
336 | 346 | runtimeKeyInfo = indexstate->iss_RuntimeKeyInfo;
|
337 | 347 | numScanKeys = indexstate->iss_NumScanKeys;
|
338 |
| - indexstate->iss_IndexPtr = -1; |
339 | 348 | if (ScanDirectionIsBackward(node->indxorderdir))
|
340 | 349 | indexstate->iss_IndexPtr = numIndices;
|
| 350 | + else |
| 351 | + indexstate->iss_IndexPtr = -1; |
341 | 352 |
|
342 | 353 | if (econtext)
|
343 | 354 | {
|
@@ -420,6 +431,9 @@ ExecIndexReScan(IndexScan *node, ExprContext *exprCtxt, Plan *parent)
|
420 | 431 | skey = scanKeys[i];
|
421 | 432 | index_rescan(scan, direction, skey);
|
422 | 433 | }
|
| 434 | + |
| 435 | + if (runtimeKeyInfo) |
| 436 | + indexstate->iss_RuntimeKeysReady = true; |
423 | 437 | }
|
424 | 438 |
|
425 | 439 | /* ----------------------------------------------------------------
|
@@ -603,7 +617,6 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent)
|
603 | 617 | Relation currentRelation;
|
604 | 618 | HeapScanDesc currentScanDesc;
|
605 | 619 | ScanDirection direction;
|
606 |
| - List *execParam = NIL; |
607 | 620 |
|
608 | 621 | /* ----------------
|
609 | 622 | * assign execution state to node
|
@@ -656,6 +669,7 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent)
|
656 | 669 | indexstate->iss_NumScanKeys = NULL;
|
657 | 670 | indexstate->iss_RuntimeKeyInfo = NULL;
|
658 | 671 | indexstate->iss_RuntimeContext = NULL;
|
| 672 | + indexstate->iss_RuntimeKeysReady = false; |
659 | 673 | indexstate->iss_RelationDescs = NULL;
|
660 | 674 | indexstate->iss_ScanDescs = NULL;
|
661 | 675 |
|
@@ -787,6 +801,9 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent)
|
787 | 801 | */
|
788 | 802 | leftop = (Node *) get_leftop(clause);
|
789 | 803 |
|
| 804 | + if (leftop && IsA(leftop, RelabelType)) |
| 805 | + leftop = ((RelabelType *) leftop)->arg; |
| 806 | + |
790 | 807 | Assert(leftop != NULL);
|
791 | 808 |
|
792 | 809 | if (IsA(leftop, Var) && var_is_rel((Var *) leftop))
|
@@ -827,7 +844,6 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent)
|
827 | 844 | /* treat Param as runtime key */
|
828 | 845 | have_runtime_keys = true;
|
829 | 846 | run_keys[j] = LEFT_OP;
|
830 |
| - execParam = lappendi(execParam, ((Param *) leftop)->paramid); |
831 | 847 | }
|
832 | 848 | else
|
833 | 849 | {
|
@@ -857,6 +873,9 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent)
|
857 | 873 | */
|
858 | 874 | rightop = (Node *) get_rightop(clause);
|
859 | 875 |
|
| 876 | + if (rightop && IsA(rightop, RelabelType)) |
| 877 | + rightop = ((RelabelType *) rightop)->arg; |
| 878 | + |
860 | 879 | Assert(rightop != NULL);
|
861 | 880 |
|
862 | 881 | if (IsA(rightop, Var) && var_is_rel((Var *) rightop))
|
@@ -906,7 +925,6 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent)
|
906 | 925 | /* treat Param as runtime key */
|
907 | 926 | have_runtime_keys = true;
|
908 | 927 | run_keys[j] = RIGHT_OP;
|
909 |
| - execParam = lappendi(execParam, ((Param *) rightop)->paramid); |
910 | 928 | }
|
911 | 929 | else
|
912 | 930 | {
|
@@ -1068,12 +1086,6 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent)
|
1068 | 1086 | indexstate->iss_RelationDescs = relationDescs;
|
1069 | 1087 | indexstate->iss_ScanDescs = scanDescs;
|
1070 | 1088 |
|
1071 |
| - /* |
1072 |
| - * if there are some PARAM_EXEC in scankeys then force index rescan on |
1073 |
| - * first scan. |
1074 |
| - */ |
1075 |
| - ((Plan *) node)->chgParam = execParam; |
1076 |
| - |
1077 | 1089 | /* ----------------
|
1078 | 1090 | * all done.
|
1079 | 1091 | * ----------------
|
|
0 commit comments