diff options
Diffstat (limited to 'src/backend/parser')
-rw-r--r-- | src/backend/parser/gram.y | 1 | ||||
-rw-r--r-- | src/backend/parser/parse_expr.c | 14 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index d79576bcaa3..db63ff23711 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -10555,6 +10555,7 @@ c_expr: columnref { $$ = $1; } RowExpr *r = makeNode(RowExpr); r->args = $1; r->row_typeid = InvalidOid; /* not analyzed yet */ + r->colnames = NIL; /* to be filled in during analysis */ r->location = @1; $$ = (Node *)r; } diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c index 698f206f169..d22d8a12bac 100644 --- a/src/backend/parser/parse_expr.c +++ b/src/backend/parser/parse_expr.c @@ -1692,6 +1692,9 @@ static Node * transformRowExpr(ParseState *pstate, RowExpr *r) { RowExpr *newr = makeNode(RowExpr); + char fname[16]; + int fnum; + ListCell *lc; /* Transform the field expressions */ newr->args = transformExpressionList(pstate, r->args); @@ -1699,7 +1702,16 @@ transformRowExpr(ParseState *pstate, RowExpr *r) /* Barring later casting, we consider the type RECORD */ newr->row_typeid = RECORDOID; newr->row_format = COERCE_IMPLICIT_CAST; - newr->colnames = NIL; /* ROW() has anonymous columns */ + + /* ROW() has anonymous columns, so invent some field names */ + newr->colnames = NIL; + fnum = 1; + foreach(lc, newr->args) + { + snprintf(fname, sizeof(fname), "f%d", fnum++); + newr->colnames = lappend(newr->colnames, makeString(pstrdup(fname))); + } + newr->location = r->location; return (Node *) newr; |