* 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. */
| 1441 | * parameter is true only for a RETURNING targetlist. |
| 1442 | */ |
| 1443 | static void |
| 1444 | deparseExplicitTargetList(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. |
no test coverage detected