* Extract the qual subexpressions that yield TIDs to search for, * and compile them into ExprStates if they're ordinary expressions. * * CURRENT OF is a special case that we can't compile usefully; * just drop it into the TidExpr list as-is. */
| 64 | * just drop it into the TidExpr list as-is. |
| 65 | */ |
| 66 | static void |
| 67 | TidExprListCreate(TidScanState *tidstate) |
| 68 | { |
| 69 | TidScan *node = (TidScan *) tidstate->ss.ps.plan; |
| 70 | ListCell *l; |
| 71 | |
| 72 | tidstate->tss_tidexprs = NIL; |
| 73 | tidstate->tss_isCurrentOf = false; |
| 74 | |
| 75 | foreach(l, node->tidquals) |
| 76 | { |
| 77 | Expr *expr = (Expr *) lfirst(l); |
| 78 | TidExpr *tidexpr = (TidExpr *) palloc0(sizeof(TidExpr)); |
| 79 | |
| 80 | if (is_opclause(expr)) |
| 81 | { |
| 82 | Node *arg1; |
| 83 | Node *arg2; |
| 84 | |
| 85 | arg1 = get_leftop(expr); |
| 86 | arg2 = get_rightop(expr); |
| 87 | if (IsCTIDVar(arg1)) |
| 88 | tidexpr->exprstate = ExecInitExpr((Expr *) arg2, |
| 89 | &tidstate->ss.ps); |
| 90 | else if (IsCTIDVar(arg2)) |
| 91 | tidexpr->exprstate = ExecInitExpr((Expr *) arg1, |
| 92 | &tidstate->ss.ps); |
| 93 | else |
| 94 | elog(ERROR, "could not identify CTID variable"); |
| 95 | tidexpr->isarray = false; |
| 96 | } |
| 97 | else if (expr && IsA(expr, ScalarArrayOpExpr)) |
| 98 | { |
| 99 | ScalarArrayOpExpr *saex = (ScalarArrayOpExpr *) expr; |
| 100 | |
| 101 | Assert(IsCTIDVar(linitial(saex->args))); |
| 102 | tidexpr->exprstate = ExecInitExpr(lsecond(saex->args), |
| 103 | &tidstate->ss.ps); |
| 104 | tidexpr->isarray = true; |
| 105 | } |
| 106 | else if (expr && IsA(expr, CurrentOfExpr)) |
| 107 | { |
| 108 | CurrentOfExpr *cexpr = (CurrentOfExpr *) expr; |
| 109 | |
| 110 | tidexpr->cexpr = cexpr; |
| 111 | tidstate->tss_isCurrentOf = true; |
| 112 | } |
| 113 | else |
| 114 | elog(ERROR, "could not identify CTID expression"); |
| 115 | |
| 116 | tidstate->tss_tidexprs = lappend(tidstate->tss_tidexprs, tidexpr); |
| 117 | } |
| 118 | |
| 119 | /* CurrentOfExpr could never appear OR'd with something else */ |
| 120 | Assert(list_length(tidstate->tss_tidexprs) == 1 || |
| 121 | !tidstate->tss_isCurrentOf); |
| 122 | } |
| 123 |
no test coverage detected