* Handle an explicit COLLATE clause. * * Transform the argument, and look up the collation name. */
| 2826 | * Transform the argument, and look up the collation name. |
| 2827 | */ |
| 2828 | static Node * |
| 2829 | transformCollateClause(ParseState *pstate, CollateClause *c) |
| 2830 | { |
| 2831 | CollateExpr *newc; |
| 2832 | Oid argtype; |
| 2833 | |
| 2834 | newc = makeNode(CollateExpr); |
| 2835 | newc->arg = (Expr *) transformExprRecurse(pstate, c->arg); |
| 2836 | |
| 2837 | argtype = exprType((Node *) newc->arg); |
| 2838 | |
| 2839 | /* |
| 2840 | * The unknown type is not collatable, but coerce_type() takes care of it |
| 2841 | * separately, so we'll let it go here. |
| 2842 | */ |
| 2843 | if (!type_is_collatable(argtype) && argtype != UNKNOWNOID) |
| 2844 | ereport(ERROR, |
| 2845 | (errcode(ERRCODE_DATATYPE_MISMATCH), |
| 2846 | errmsg("collations are not supported by type %s", |
| 2847 | format_type_be(argtype)), |
| 2848 | parser_errposition(pstate, c->location))); |
| 2849 | |
| 2850 | newc->collOid = LookupCollation(pstate, c->collname, c->location); |
| 2851 | newc->location = c->location; |
| 2852 | |
| 2853 | return (Node *) newc; |
| 2854 | } |
| 2855 | |
| 2856 | /* |
| 2857 | * Transform a "row compare-op row" construct |
no test coverage detected