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/nodes | |
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/nodes')
-rw-r--r-- | src/backend/nodes/copyfuncs.c | 24 | ||||
-rw-r--r-- | src/backend/nodes/equalfuncs.c | 5 | ||||
-rw-r--r-- | src/backend/nodes/outfuncs.c | 17 | ||||
-rw-r--r-- | src/backend/nodes/print.c | 15 | ||||
-rw-r--r-- | src/backend/nodes/readfuncs.c | 5 |
5 files changed, 59 insertions, 7 deletions
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c index f2b2afd81af..8903d6b42dd 100644 --- a/src/backend/nodes/copyfuncs.c +++ b/src/backend/nodes/copyfuncs.c @@ -15,7 +15,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.344 2006/07/27 19:52:05 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.345 2006/08/02 01:59:45 joe Exp $ * *------------------------------------------------------------------------- */ @@ -367,6 +367,22 @@ _copyFunctionScan(FunctionScan *from) } /* + * _copyValuesScan + */ +static ValuesScan * +_copyValuesScan(ValuesScan *from) +{ + ValuesScan *newnode = makeNode(ValuesScan); + + /* + * copy node superclass fields + */ + CopyScanFields((Scan *) from, (Scan *) newnode); + + return newnode; +} + +/* * CopyJoinFields * * This function copies the fields of the Join node. It is used by @@ -1356,6 +1372,7 @@ _copyRangeTblEntry(RangeTblEntry *from) COPY_NODE_FIELD(funcexpr); COPY_NODE_FIELD(funccoltypes); COPY_NODE_FIELD(funccoltypmods); + COPY_NODE_FIELD(values_lists); COPY_SCALAR_FIELD(jointype); COPY_NODE_FIELD(joinaliasvars); COPY_NODE_FIELD(alias); @@ -1707,7 +1724,6 @@ _copyInsertStmt(InsertStmt *from) COPY_NODE_FIELD(relation); COPY_NODE_FIELD(cols); - COPY_NODE_FIELD(targetList); COPY_NODE_FIELD(selectStmt); return newnode; @@ -1754,6 +1770,7 @@ _copySelectStmt(SelectStmt *from) COPY_NODE_FIELD(whereClause); COPY_NODE_FIELD(groupClause); COPY_NODE_FIELD(havingClause); + COPY_NODE_FIELD(valuesLists); COPY_NODE_FIELD(sortClause); COPY_NODE_FIELD(limitOffset); COPY_NODE_FIELD(limitCount); @@ -2812,6 +2829,9 @@ copyObject(void *from) case T_FunctionScan: retval = _copyFunctionScan(from); break; + case T_ValuesScan: + retval = _copyValuesScan(from); + break; case T_Join: retval = _copyJoin(from); break; diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c index 0122ebd629c..d49e02b3d8a 100644 --- a/src/backend/nodes/equalfuncs.c +++ b/src/backend/nodes/equalfuncs.c @@ -18,7 +18,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.278 2006/07/27 19:52:05 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.279 2006/08/02 01:59:45 joe Exp $ * *------------------------------------------------------------------------- */ @@ -682,7 +682,6 @@ _equalInsertStmt(InsertStmt *a, InsertStmt *b) { COMPARE_NODE_FIELD(relation); COMPARE_NODE_FIELD(cols); - COMPARE_NODE_FIELD(targetList); COMPARE_NODE_FIELD(selectStmt); return true; @@ -723,6 +722,7 @@ _equalSelectStmt(SelectStmt *a, SelectStmt *b) COMPARE_NODE_FIELD(whereClause); COMPARE_NODE_FIELD(groupClause); COMPARE_NODE_FIELD(havingClause); + COMPARE_NODE_FIELD(valuesLists); COMPARE_NODE_FIELD(sortClause); COMPARE_NODE_FIELD(limitOffset); COMPARE_NODE_FIELD(limitCount); @@ -1706,6 +1706,7 @@ _equalRangeTblEntry(RangeTblEntry *a, RangeTblEntry *b) COMPARE_NODE_FIELD(funcexpr); COMPARE_NODE_FIELD(funccoltypes); COMPARE_NODE_FIELD(funccoltypmods); + COMPARE_NODE_FIELD(values_lists); COMPARE_SCALAR_FIELD(jointype); COMPARE_NODE_FIELD(joinaliasvars); COMPARE_NODE_FIELD(alias); diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c index 61d49572ca8..34555e1c567 100644 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.279 2006/07/27 19:52:05 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.280 2006/08/02 01:59:45 joe Exp $ * * NOTES * Every node type that can appear in stored rules' parsetrees *must* @@ -411,6 +411,14 @@ _outFunctionScan(StringInfo str, FunctionScan *node) } static void +_outValuesScan(StringInfo str, ValuesScan *node) +{ + WRITE_NODE_TYPE("VALUESSCAN"); + + _outScanInfo(str, (Scan *) node); +} + +static void _outJoin(StringInfo str, Join *node) { WRITE_NODE_TYPE("JOIN"); @@ -1381,6 +1389,7 @@ _outSelectStmt(StringInfo str, SelectStmt *node) WRITE_NODE_FIELD(whereClause); WRITE_NODE_FIELD(groupClause); WRITE_NODE_FIELD(havingClause); + WRITE_NODE_FIELD(valuesLists); WRITE_NODE_FIELD(sortClause); WRITE_NODE_FIELD(limitOffset); WRITE_NODE_FIELD(limitCount); @@ -1591,6 +1600,9 @@ _outRangeTblEntry(StringInfo str, RangeTblEntry *node) WRITE_NODE_FIELD(funccoltypes); WRITE_NODE_FIELD(funccoltypmods); break; + case RTE_VALUES: + WRITE_NODE_FIELD(values_lists); + break; case RTE_JOIN: WRITE_ENUM_FIELD(jointype, JoinType); WRITE_NODE_FIELD(joinaliasvars); @@ -1876,6 +1888,9 @@ _outNode(StringInfo str, void *obj) case T_FunctionScan: _outFunctionScan(str, obj); break; + case T_ValuesScan: + _outValuesScan(str, obj); + break; case T_Join: _outJoin(str, obj); break; diff --git a/src/backend/nodes/print.c b/src/backend/nodes/print.c index 1a83be65747..7fff94a8a39 100644 --- a/src/backend/nodes/print.c +++ b/src/backend/nodes/print.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/print.c,v 1.80 2006/07/14 14:52:20 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/print.c,v 1.81 2006/08/02 01:59:45 joe Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -275,6 +275,10 @@ print_rt(List *rtable) printf("%d\t%s\t[rangefunction]", i, rte->eref->aliasname); break; + case RTE_VALUES: + printf("%d\t%s\t[values list]", + i, rte->eref->aliasname); + break; case RTE_JOIN: printf("%d\t%s\t[join]", i, rte->eref->aliasname); @@ -507,6 +511,8 @@ plannode_type(Plan *p) return "SUBQUERYSCAN"; case T_FunctionScan: return "FUNCTIONSCAN"; + case T_ValuesScan: + return "VALUESSCAN"; case T_Join: return "JOIN"; case T_NestLoop: @@ -575,6 +581,13 @@ print_plan_recursive(Plan *p, Query *parsetree, int indentLevel, char *label) rte = rt_fetch(((FunctionScan *) p)->scan.scanrelid, parsetree->rtable); StrNCpy(extraInfo, rte->eref->aliasname, NAMEDATALEN); } + else if (IsA(p, ValuesScan)) + { + RangeTblEntry *rte; + + rte = rt_fetch(((ValuesScan *) p)->scan.scanrelid, parsetree->rtable); + StrNCpy(extraInfo, rte->eref->aliasname, NAMEDATALEN); + } else extraInfo[0] = '\0'; if (extraInfo[0] != '\0') diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c index 265a5b369ee..7459acb30c0 100644 --- a/src/backend/nodes/readfuncs.c +++ b/src/backend/nodes/readfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/readfuncs.c,v 1.192 2006/07/27 19:52:05 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/readfuncs.c,v 1.193 2006/08/02 01:59:45 joe Exp $ * * NOTES * Path and Plan nodes do not have any readfuncs support, because we @@ -902,6 +902,9 @@ _readRangeTblEntry(void) READ_NODE_FIELD(funccoltypes); READ_NODE_FIELD(funccoltypmods); break; + case RTE_VALUES: + READ_NODE_FIELD(values_lists); + break; case RTE_JOIN: READ_ENUM_FIELD(jointype, JoinType); READ_NODE_FIELD(joinaliasvars); |