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

Function deparseExplicitTargetList

contrib/postgres_fdw/deparse.c:1443–1472  ·  view source on GitHub ↗

* Deparse given targetlist and append it to context->buf. * * tlist is list of TargetEntry's which in turn contain Var nodes. * * retrieved_attrs is the list of continuously increasing integers starting * from 1. It has same number of entries as tlist. * * This is used for both SELECT and RETURNING targetlists; the is_returning * parameter is true only for a RETURNING targetlist. */

Source from the content-addressed store, hash-verified

1441 * parameter is true only for a RETURNING targetlist.
1442 */
1443static void
1444deparseExplicitTargetList(List *tlist,
1445 bool is_returning,
1446 List **retrieved_attrs,
1447 deparse_expr_cxt *context)
1448{
1449 ListCell *lc;
1450 StringInfo buf = context->buf;
1451 int i = 0;
1452
1453 *retrieved_attrs = NIL;
1454
1455 foreach(lc, tlist)
1456 {
1457 TargetEntry *tle = lfirst_node(TargetEntry, lc);
1458
1459 if (i > 0)
1460 appendStringInfoString(buf, ", ");
1461 else if (is_returning)
1462 appendStringInfoString(buf, " RETURNING ");
1463
1464 deparseExpr((Expr *) tle->expr, context);
1465
1466 *retrieved_attrs = lappend_int(*retrieved_attrs, i + 1);
1467 i++;
1468 }
1469
1470 if (i == 0 && !is_returning)
1471 appendStringInfoString(buf, "NULL");
1472}
1473
1474/*
1475 * Emit expressions specified in the given relation's reltarget.

Callers 3

deparseSelectSqlFunction · 0.85
deparseDirectUpdateSqlFunction · 0.85
deparseDirectDeleteSqlFunction · 0.85

Calls 4

appendStringInfoStringFunction · 0.85
deparseExprFunction · 0.85
lappend_intFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected