* For the given 'expr', build and return an appropriate TidOpExpr taking into * account the expr's operator and operand order. */
| 50 | * account the expr's operator and operand order. |
| 51 | */ |
| 52 | static TidOpExpr * |
| 53 | MakeTidOpExpr(OpExpr *expr, TidRangeScanState *tidstate) |
| 54 | { |
| 55 | Node *arg1 = get_leftop((Expr *) expr); |
| 56 | Node *arg2 = get_rightop((Expr *) expr); |
| 57 | ExprState *exprstate = NULL; |
| 58 | bool invert = false; |
| 59 | TidOpExpr *tidopexpr; |
| 60 | |
| 61 | if (IsCTIDVar(arg1)) |
| 62 | exprstate = ExecInitExpr((Expr *) arg2, &tidstate->ss.ps); |
| 63 | else if (IsCTIDVar(arg2)) |
| 64 | { |
| 65 | exprstate = ExecInitExpr((Expr *) arg1, &tidstate->ss.ps); |
| 66 | invert = true; |
| 67 | } |
| 68 | else |
| 69 | elog(ERROR, "could not identify CTID variable"); |
| 70 | |
| 71 | tidopexpr = (TidOpExpr *) palloc(sizeof(TidOpExpr)); |
| 72 | tidopexpr->inclusive = false; /* for now */ |
| 73 | |
| 74 | switch (expr->opno) |
| 75 | { |
| 76 | case TIDLessEqOperator: |
| 77 | tidopexpr->inclusive = true; |
| 78 | /* fall through */ |
| 79 | case TIDLessOperator: |
| 80 | tidopexpr->exprtype = invert ? TIDEXPR_LOWER_BOUND : TIDEXPR_UPPER_BOUND; |
| 81 | break; |
| 82 | case TIDGreaterEqOperator: |
| 83 | tidopexpr->inclusive = true; |
| 84 | /* fall through */ |
| 85 | case TIDGreaterOperator: |
| 86 | tidopexpr->exprtype = invert ? TIDEXPR_UPPER_BOUND : TIDEXPR_LOWER_BOUND; |
| 87 | break; |
| 88 | default: |
| 89 | elog(ERROR, "could not identify CTID operator"); |
| 90 | } |
| 91 | |
| 92 | tidopexpr->exprstate = exprstate; |
| 93 | |
| 94 | return tidopexpr; |
| 95 | } |
| 96 | |
| 97 | /* |
| 98 | * Extract the qual subexpressions that yield TIDs to search for, |
no test coverage detected