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

Function deparseSubscriptingRef

contrib/postgres_fdw/deparse.c:2743–2784  ·  view source on GitHub ↗

* Deparse a container subscript expression. */

Source from the content-addressed store, hash-verified

2741 * Deparse a container subscript expression.
2742 */
2743static void
2744deparseSubscriptingRef(SubscriptingRef *node, deparse_expr_cxt *context)
2745{
2746 StringInfo buf = context->buf;
2747 ListCell *lowlist_item;
2748 ListCell *uplist_item;
2749
2750 /* Always parenthesize the expression. */
2751 appendStringInfoChar(buf, '(');
2752
2753 /*
2754 * Deparse referenced array expression first. If that expression includes
2755 * a cast, we have to parenthesize to prevent the array subscript from
2756 * being taken as typename decoration. We can avoid that in the typical
2757 * case of subscripting a Var, but otherwise do it.
2758 */
2759 if (IsA(node->refexpr, Var))
2760 deparseExpr(node->refexpr, context);
2761 else
2762 {
2763 appendStringInfoChar(buf, '(');
2764 deparseExpr(node->refexpr, context);
2765 appendStringInfoChar(buf, ')');
2766 }
2767
2768 /* Deparse subscript expressions. */
2769 lowlist_item = list_head(node->reflowerindexpr); /* could be NULL */
2770 foreach(uplist_item, node->refupperindexpr)
2771 {
2772 appendStringInfoChar(buf, '[');
2773 if (lowlist_item)
2774 {
2775 deparseExpr(lfirst(lowlist_item), context);
2776 appendStringInfoChar(buf, ':');
2777 lowlist_item = lnext(node->reflowerindexpr, lowlist_item);
2778 }
2779 deparseExpr(lfirst(uplist_item), context);
2780 appendStringInfoChar(buf, ']');
2781 }
2782
2783 appendStringInfoChar(buf, ')');
2784}
2785
2786/*
2787 * Deparse a function call.

Callers 1

deparseExprFunction · 0.85

Calls 5

appendStringInfoCharFunction · 0.85
deparseExprFunction · 0.85
list_headFunction · 0.85
lnextFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected