* ExecInitExprWithParams: prepare a standalone expression tree for execution * * This is the same as ExecInitExpr, except that there is no parent PlanState, * and instead we may have a ParamListInfo describing PARAM_EXTERN Params. */
| 169 | * and instead we may have a ParamListInfo describing PARAM_EXTERN Params. |
| 170 | */ |
| 171 | ExprState * |
| 172 | ExecInitExprWithParams(Expr *node, ParamListInfo ext_params) |
| 173 | { |
| 174 | ExprState *state; |
| 175 | ExprEvalStep scratch = {0}; |
| 176 | |
| 177 | /* Special case: NULL expression produces a NULL ExprState pointer */ |
| 178 | if (node == NULL) |
| 179 | return NULL; |
| 180 | |
| 181 | /* Initialize ExprState with empty step list */ |
| 182 | state = makeNode(ExprState); |
| 183 | state->expr = node; |
| 184 | state->parent = NULL; |
| 185 | state->ext_params = ext_params; |
| 186 | |
| 187 | /* Insert EEOP_*_FETCHSOME steps as needed */ |
| 188 | ExecInitExprSlots(state, (Node *) node); |
| 189 | |
| 190 | /* Compile the expression proper */ |
| 191 | ExecInitExprRec(node, state, &state->resvalue, &state->resnull); |
| 192 | |
| 193 | /* Finally, append a DONE step */ |
| 194 | scratch.opcode = EEOP_DONE; |
| 195 | ExprEvalPushStep(state, &scratch); |
| 196 | |
| 197 | ExecReadyExpr(state); |
| 198 | |
| 199 | return state; |
| 200 | } |
| 201 | |
| 202 | /* |
| 203 | * ExecInitQual: prepare a qual for execution by ExecQual |
no test coverage detected