* Append the steps necessary for the evaluation of node to ExprState->steps, * possibly recursing into sub-expressions of node. * * node - expression to evaluate * state - ExprState to whose ->steps to append the necessary operations * resv / resnull - where to store the result of the node into */
| 909 | * resv / resnull - where to store the result of the node into |
| 910 | */ |
| 911 | static void |
| 912 | ExecInitExprRec(Expr *node, ExprState *state, |
| 913 | Datum *resv, bool *resnull) |
| 914 | { |
| 915 | ExprEvalStep scratch = {0}; |
| 916 | |
| 917 | /* Guard against stack overflow due to overly complex expressions */ |
| 918 | check_stack_depth(); |
| 919 | |
| 920 | /* Step's output location is always what the caller gave us */ |
| 921 | Assert(resv != NULL && resnull != NULL); |
| 922 | scratch.resvalue = resv; |
| 923 | scratch.resnull = resnull; |
| 924 | |
| 925 | /* cases should be ordered as they are in enum NodeTag */ |
| 926 | switch (nodeTag(node)) |
| 927 | { |
| 928 | case T_Var: |
| 929 | { |
| 930 | Var *variable = (Var *) node; |
| 931 | |
| 932 | if (variable->varattno == InvalidAttrNumber) |
| 933 | { |
| 934 | /* whole-row Var */ |
| 935 | ExecInitWholeRowVar(&scratch, variable, state); |
| 936 | } |
| 937 | else if (variable->varattno <= 0) |
| 938 | { |
| 939 | /* system column */ |
| 940 | scratch.d.var.attnum = variable->varattno; |
| 941 | scratch.d.var.vartype = variable->vartype; |
| 942 | switch (variable->varno) |
| 943 | { |
| 944 | case INNER_VAR: |
| 945 | scratch.opcode = EEOP_INNER_SYSVAR; |
| 946 | break; |
| 947 | case OUTER_VAR: |
| 948 | scratch.opcode = EEOP_OUTER_SYSVAR; |
| 949 | break; |
| 950 | |
| 951 | /* INDEX_VAR is handled by default case */ |
| 952 | |
| 953 | default: |
| 954 | scratch.opcode = EEOP_SCAN_SYSVAR; |
| 955 | break; |
| 956 | } |
| 957 | } |
| 958 | else |
| 959 | { |
| 960 | /* regular user column */ |
| 961 | scratch.d.var.attnum = variable->varattno - 1; |
| 962 | scratch.d.var.vartype = variable->vartype; |
| 963 | switch (variable->varno) |
| 964 | { |
| 965 | case INNER_VAR: |
| 966 | scratch.opcode = EEOP_INNER_VAR; |
| 967 | break; |
| 968 | case OUTER_VAR: |
no test coverage detected