diff options
author | Joe Conway <mail@joeconway.com> | 2006-08-02 01:59:48 +0000 |
---|---|---|
committer | Joe Conway <mail@joeconway.com> | 2006-08-02 01:59:48 +0000 |
commit | 9caafda579f699b43fa4c89bf13a2331ef00611e (patch) | |
tree | 330423c4be56ffaacb2d028153706f0c213c0aec /src/backend/parser/parse_expr.c | |
parent | d307c428cbb7c426e40163d234d993e644bbcc6b (diff) | |
download | postgresql-9caafda579f699b43fa4c89bf13a2331ef00611e.tar.gz postgresql-9caafda579f699b43fa4c89bf13a2331ef00611e.zip |
Add support for multi-row VALUES clauses as part of INSERT statements
(e.g. "INSERT ... VALUES (...), (...), ...") and elsewhere as allowed
by the spec. (e.g. similar to a FROM clause subselect). initdb required.
Joe Conway and Tom Lane.
Diffstat (limited to 'src/backend/parser/parse_expr.c')
-rw-r--r-- | src/backend/parser/parse_expr.c | 60 |
1 files changed, 11 insertions, 49 deletions
diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c index 11ef7e4f1e9..6a7117e98bf 100644 --- a/src/backend/parser/parse_expr.c +++ b/src/backend/parser/parse_expr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.195 2006/07/14 14:52:22 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.196 2006/08/02 01:59:46 joe Exp $ * *------------------------------------------------------------------------- */ @@ -1281,56 +1281,9 @@ static Node * transformRowExpr(ParseState *pstate, RowExpr *r) { RowExpr *newr = makeNode(RowExpr); - List *newargs = NIL; - ListCell *arg; /* Transform the field expressions */ - foreach(arg, r->args) - { - Node *e = (Node *) lfirst(arg); - Node *newe; - - /* - * Check for "something.*". Depending on the complexity of the - * "something", the star could appear as the last name in ColumnRef, - * or as the last indirection item in A_Indirection. - */ - if (IsA(e, ColumnRef)) - { - ColumnRef *cref = (ColumnRef *) e; - - if (strcmp(strVal(llast(cref->fields)), "*") == 0) - { - /* It is something.*, expand into multiple items */ - newargs = list_concat(newargs, - ExpandColumnRefStar(pstate, cref, - false)); - continue; - } - } - else if (IsA(e, A_Indirection)) - { - A_Indirection *ind = (A_Indirection *) e; - Node *lastitem = llast(ind->indirection); - - if (IsA(lastitem, String) && - strcmp(strVal(lastitem), "*") == 0) - { - /* It is something.*, expand into multiple items */ - newargs = list_concat(newargs, - ExpandIndirectionStar(pstate, ind, - false)); - continue; - } - } - - /* - * Not "something.*", so transform as a single expression - */ - newe = transformExpr(pstate, e); - newargs = lappend(newargs, newe); - } - newr->args = newargs; + newr->args = transformExpressionList(pstate, r->args); /* Barring later casting, we consider the type RECORD */ newr->row_typeid = RECORDOID; @@ -1526,6 +1479,15 @@ transformWholeRowRef(ParseState *pstate, char *schemaname, char *relname, sublevels_up); } break; + case RTE_VALUES: + toid = RECORDOID; + /* returns composite; same as relation case */ + result = (Node *) makeVar(vnum, + InvalidAttrNumber, + toid, + -1, + sublevels_up); + break; default: /* |