/* * 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. * colname the column name to be assigned, or NULL if none yet set. * resjunk true if the target should be marked resjunk, ie, it is not * wanted in the final projected tuple. */ TargetEntry * transformTargetEntry(ParseState *pstate, Node *node, Node *expr, char *colname, bool resjunk) { /* Transform the node if caller didn't do it already */ if (expr == NULL) expr = transformExpr(pstate, node); if (colname == NULL && !resjunk) { /* * Generate a suitable column name for a column without any explicit * 'AS ColumnName' clause. */ colname = FigureColname(node); } return makeTargetEntry((Expr *) expr, (AttrNumber) pstate->p_next_resno++, colname, resjunk); }
/* * add_coltypes * * Given a target list, add the types the entries to a list of types seen * for the same column across all streams */ static void add_coltypes(StreamTargetsEntry *stream, List *targetlist) { ListCell *lc; foreach(lc, targetlist) { bool found; TypeCast *tc = (TypeCast *) lfirst(lc); StreamColumnsEntry *entry; char *name = FigureColname((Node *) tc); entry = (StreamColumnsEntry *) hash_search(stream->colstotypes, name, HASH_ENTER, &found); if (!found) entry->types = NIL; entry->types = lappend(entry->types, tc); }
/* * xfrm_tgt_entry() * 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. * colname the column name to be assigned, or NULL if none yet set. * resjunk true if the target should be marked resjunk, ie, it is not * wanted in the final projected tuple. */ tgt_entry_xp* xfrm_tgt_entry( parse_state_s* pstate, node_n* node, node_n* expr, char* colname, bool resjunk) { /* Transform the node if caller didn't do it already */ if (expr == NULL) expr = xfrm_expr(pstate, node); if (colname == NULL && !resjunk) { /* * Generate a suitable column name for a column without any explicit * 'AS ColumnName' clause. */ colname = FigureColname(node); } return makeTargetEntry((expr_n*) expr, (attr_nr_t) pstate->p_next_resno++, colname, resjunk); }