summaryrefslogtreecommitdiff
path: root/src/backend/executor
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/executor')
-rw-r--r--src/backend/executor/execExpr.c20
-rw-r--r--src/backend/executor/nodeIndexscan.c28
2 files changed, 16 insertions, 32 deletions
diff --git a/src/backend/executor/execExpr.c b/src/backend/executor/execExpr.c
index db3777d15ef..7cbf9d3bc1c 100644
--- a/src/backend/executor/execExpr.c
+++ b/src/backend/executor/execExpr.c
@@ -1683,7 +1683,6 @@ ExecInitExprRec(Expr *node, ExprState *state,
*l_opfamily,
*l_inputcollid;
ListCell *lc;
- int off;
/*
* Iterate over each field, prepare comparisons. To handle
@@ -1695,20 +1694,11 @@ ExecInitExprRec(Expr *node, ExprState *state,
Assert(list_length(rcexpr->opfamilies) == nopers);
Assert(list_length(rcexpr->inputcollids) == nopers);
- off = 0;
- for (off = 0,
- l_left_expr = list_head(rcexpr->largs),
- l_right_expr = list_head(rcexpr->rargs),
- l_opno = list_head(rcexpr->opnos),
- l_opfamily = list_head(rcexpr->opfamilies),
- l_inputcollid = list_head(rcexpr->inputcollids);
- off < nopers;
- off++,
- l_left_expr = lnext(l_left_expr),
- l_right_expr = lnext(l_right_expr),
- l_opno = lnext(l_opno),
- l_opfamily = lnext(l_opfamily),
- l_inputcollid = lnext(l_inputcollid))
+ forfive(l_left_expr, rcexpr->largs,
+ l_right_expr, rcexpr->rargs,
+ l_opno, rcexpr->opnos,
+ l_opfamily, rcexpr->opfamilies,
+ l_inputcollid, rcexpr->inputcollids)
{
Expr *left_expr = (Expr *) lfirst(l_left_expr);
Expr *right_expr = (Expr *) lfirst(l_right_expr);
diff --git a/src/backend/executor/nodeIndexscan.c b/src/backend/executor/nodeIndexscan.c
index 324356ec757..8b294378936 100644
--- a/src/backend/executor/nodeIndexscan.c
+++ b/src/backend/executor/nodeIndexscan.c
@@ -1332,12 +1332,12 @@ ExecIndexBuildScanKeys(PlanState *planstate, Relation index,
{
/* (indexkey, indexkey, ...) op (expression, expression, ...) */
RowCompareExpr *rc = (RowCompareExpr *) clause;
- ListCell *largs_cell = list_head(rc->largs);
- ListCell *rargs_cell = list_head(rc->rargs);
- ListCell *opnos_cell = list_head(rc->opnos);
- ListCell *collids_cell = list_head(rc->inputcollids);
ScanKey first_sub_key;
int n_sub_key;
+ ListCell *largs_cell;
+ ListCell *rargs_cell;
+ ListCell *opnos_cell;
+ ListCell *collids_cell;
Assert(!isorderby);
@@ -1346,19 +1346,22 @@ ExecIndexBuildScanKeys(PlanState *planstate, Relation index,
n_sub_key = 0;
/* Scan RowCompare columns and generate subsidiary ScanKey items */
- while (opnos_cell != NULL)
+ forfour(largs_cell, rc->largs, rargs_cell, rc->rargs,
+ opnos_cell, rc->opnos, collids_cell, rc->inputcollids)
{
ScanKey this_sub_key = &first_sub_key[n_sub_key];
int flags = SK_ROW_MEMBER;
Datum scanvalue;
Oid inputcollation;
+ leftop = (Expr *) lfirst(largs_cell);
+ rightop = (Expr *) lfirst(rargs_cell);
+ opno = lfirst_oid(opnos_cell);
+ inputcollation = lfirst_oid(collids_cell);
+
/*
* leftop should be the index key Var, possibly relabeled
*/
- leftop = (Expr *) lfirst(largs_cell);
- largs_cell = lnext(largs_cell);
-
if (leftop && IsA(leftop, RelabelType))
leftop = ((RelabelType *) leftop)->arg;
@@ -1374,9 +1377,6 @@ ExecIndexBuildScanKeys(PlanState *planstate, Relation index,
* We have to look up the operator's associated btree support
* function
*/
- opno = lfirst_oid(opnos_cell);
- opnos_cell = lnext(opnos_cell);
-
if (index->rd_rel->relam != BTREE_AM_OID ||
varattno < 1 || varattno > indnkeyatts)
elog(ERROR, "bogus RowCompare index qualification");
@@ -1398,15 +1398,9 @@ ExecIndexBuildScanKeys(PlanState *planstate, Relation index,
elog(ERROR, "missing support function %d(%u,%u) in opfamily %u",
BTORDER_PROC, op_lefttype, op_righttype, opfamily);
- inputcollation = lfirst_oid(collids_cell);
- collids_cell = lnext(collids_cell);
-
/*
* rightop is the constant or variable comparison value
*/
- rightop = (Expr *) lfirst(rargs_cell);
- rargs_cell = lnext(rargs_cell);
-
if (rightop && IsA(rightop, RelabelType))
rightop = ((RelabelType *) rightop)->arg;