* transformTargetEntry() * Transform any ordinary "expression-type" node into a targetlist entry. * This is exported so that parse_clause.c can generate targetlist entries * for ORDER/GROUP BY items that are not already in the targetlist. * * node the (untransformed) parse tree for the value expression. * expr the transformed expression, or NULL if caller didn't do it yet. * exprKind expr
| 74 | * wanted in the final projected tuple. |
| 75 | */ |
| 76 | TargetEntry * |
| 77 | transformTargetEntry(ParseState *pstate, |
| 78 | Node *node, |
| 79 | Node *expr, |
| 80 | ParseExprKind exprKind, |
| 81 | char *colname, |
| 82 | bool resjunk) |
| 83 | { |
| 84 | /* Transform the node if caller didn't do it already */ |
| 85 | if (expr == NULL) |
| 86 | { |
| 87 | /* |
| 88 | * If it's a SetToDefault node and we should allow that, pass it |
| 89 | * through unmodified. (transformExpr will throw the appropriate |
| 90 | * error if we're disallowing it.) |
| 91 | */ |
| 92 | if (exprKind == EXPR_KIND_UPDATE_SOURCE && IsA(node, SetToDefault)) |
| 93 | expr = node; |
| 94 | else |
| 95 | expr = transformExpr(pstate, node, exprKind); |
| 96 | } |
| 97 | |
| 98 | if (colname == NULL && !resjunk) |
| 99 | { |
| 100 | /* |
| 101 | * Generate a suitable column name for a column without any explicit |
| 102 | * 'AS ColumnName' clause. |
| 103 | */ |
| 104 | colname = FigureColname(node); |
| 105 | } |
| 106 | |
| 107 | return makeTargetEntry((Expr *) expr, |
| 108 | (AttrNumber) pstate->p_next_resno++, |
| 109 | colname, |
| 110 | resjunk); |
| 111 | } |
| 112 | |
| 113 | |
| 114 | /* |
no test coverage detected