| 2520 | } |
| 2521 | |
| 2522 | static Node * |
| 2523 | transformXmlSerialize(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 | |
| 2565 | static Node * |
| 2566 | transformBooleanTest(ParseState *pstate, BooleanTest *b) |
no test coverage detected