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

Function transformXmlExpr

src/backend/parser/parse_expr.c:2393–2520  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2391}
2392
2393static Node *
2394transformXmlExpr(ParseState *pstate, XmlExpr *x)
2395{
2396 XmlExpr *newx;
2397 ListCell *lc;
2398 int i;
2399
2400 newx = makeNode(XmlExpr);
2401 newx->op = x->op;
2402 if (x->name)
2403 newx->name = map_sql_identifier_to_xml_name(x->name, false, false);
2404 else
2405 newx->name = NULL;
2406 newx->xmloption = x->xmloption;
2407 newx->type = XMLOID; /* this just marks the node as transformed */
2408 newx->typmod = -1;
2409 newx->location = x->location;
2410
2411 /*
2412 * gram.y built the named args as a list of ResTarget. Transform each,
2413 * and break the names out as a separate list.
2414 */
2415 newx->named_args = NIL;
2416 newx->arg_names = NIL;
2417
2418 foreach(lc, x->named_args)
2419 {
2420 ResTarget *r = lfirst_node(ResTarget, lc);
2421 Node *expr;
2422 char *argname;
2423
2424 expr = transformExprRecurse(pstate, r->val);
2425
2426 if (r->name)
2427 argname = map_sql_identifier_to_xml_name(r->name, false, false);
2428 else if (IsA(r->val, ColumnRef))
2429 argname = map_sql_identifier_to_xml_name(FigureColname(r->val),
2430 true, false);
2431 else
2432 {
2433 ereport(ERROR,
2434 (errcode(ERRCODE_SYNTAX_ERROR),
2435 x->op == IS_XMLELEMENT
2436 ? errmsg("unnamed XML attribute value must be a column reference")
2437 : errmsg("unnamed XML element value must be a column reference"),
2438 parser_errposition(pstate, r->location)));
2439 argname = NULL; /* keep compiler quiet */
2440 }
2441
2442 /* reject duplicate argnames in XMLELEMENT only */
2443 if (x->op == IS_XMLELEMENT)
2444 {
2445 ListCell *lc2;
2446
2447 foreach(lc2, newx->arg_names)
2448 {
2449 if (strcmp(argname, strVal(lfirst(lc2))) == 0)
2450 ereport(ERROR,

Callers 1

transformExprRecurseFunction · 0.85

Calls 11

transformExprRecurseFunction · 0.85
FigureColnameFunction · 0.85
parser_errpositionFunction · 0.85
lappendFunction · 0.85
makeStringFunction · 0.85
coerce_to_specific_typeFunction · 0.85
coerce_to_booleanFunction · 0.85
foreachFunction · 0.50
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected