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

Function transformXmlSerialize

src/backend/parser/parse_expr.c:2522–2563  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2520}
2521
2522static Node *
2523transformXmlSerialize(ParseState *pstate, XmlSerialize *xs)
2524{
2525 Node *result;
2526 XmlExpr *xexpr;
2527 Oid targetType;
2528 int32 targetTypmod;
2529
2530 xexpr = makeNode(XmlExpr);
2531 xexpr->op = IS_XMLSERIALIZE;
2532 xexpr->args = list_make1(coerce_to_specific_type(pstate,
2533 transformExprRecurse(pstate, xs->expr),
2534 XMLOID,
2535 "XMLSERIALIZE"));
2536
2537 typenameTypeIdAndMod(pstate, xs->typeName, &targetType, &targetTypmod);
2538
2539 xexpr->xmloption = xs->xmloption;
2540 xexpr->location = xs->location;
2541 /* We actually only need these to be able to parse back the expression. */
2542 xexpr->type = targetType;
2543 xexpr->typmod = targetTypmod;
2544
2545 /*
2546 * The actual target type is determined this way. SQL allows char and
2547 * varchar as target types. We allow anything that can be cast implicitly
2548 * from text. This way, user-defined text-like data types automatically
2549 * fit in.
2550 */
2551 result = coerce_to_target_type(pstate, (Node *) xexpr,
2552 TEXTOID, targetType, targetTypmod,
2553 COERCION_IMPLICIT,
2554 COERCE_IMPLICIT_CAST,
2555 -1);
2556 if (result == NULL)
2557 ereport(ERROR,
2558 (errcode(ERRCODE_CANNOT_COERCE),
2559 errmsg("cannot cast XMLSERIALIZE result to %s",
2560 format_type_be(targetType)),
2561 parser_errposition(pstate, xexpr->location)));
2562 return result;
2563}
2564
2565static Node *
2566transformBooleanTest(ParseState *pstate, BooleanTest *b)

Callers 1

transformExprRecurseFunction · 0.85

Calls 8

coerce_to_specific_typeFunction · 0.85
transformExprRecurseFunction · 0.85
typenameTypeIdAndModFunction · 0.85
coerce_to_target_typeFunction · 0.85
format_type_beFunction · 0.85
parser_errpositionFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected