MCPcopy Create free account
hub / github.com/apache/cloudberry / transformCollateClause

Function transformCollateClause

src/backend/parser/parse_expr.c:2828–2854  ·  view source on GitHub ↗

* Handle an explicit COLLATE clause. * * Transform the argument, and look up the collation name. */

Source from the content-addressed store, hash-verified

2826 * Transform the argument, and look up the collation name.
2827 */
2828static Node *
2829transformCollateClause(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

Callers 1

transformExprRecurseFunction · 0.85

Calls 8

transformExprRecurseFunction · 0.85
exprTypeFunction · 0.85
type_is_collatableFunction · 0.85
format_type_beFunction · 0.85
parser_errpositionFunction · 0.85
LookupCollationFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected