mirror of
https://github.com/postgres/postgres.git
synced 2025-08-27 07:42:10 +03:00
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.
This commit is contained in:
@@ -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 $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -366,6 +366,22 @@ _copyFunctionScan(FunctionScan *from)
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/*
|
||||
* _copyValuesScan
|
||||
*/
|
||||
static ValuesScan *
|
||||
_copyValuesScan(ValuesScan *from)
|
||||
{
|
||||
ValuesScan *newnode = makeNode(ValuesScan);
|
||||
|
||||
/*
|
||||
* copy node superclass fields
|
||||
*/
|
||||
CopyScanFields((Scan *) from, (Scan *) newnode);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/*
|
||||
* CopyJoinFields
|
||||
*
|
||||
@@ -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;
|
||||
|
@@ -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);
|
||||
|
@@ -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*
|
||||
@@ -410,6 +410,14 @@ _outFunctionScan(StringInfo str, FunctionScan *node)
|
||||
_outScanInfo(str, (Scan *) node);
|
||||
}
|
||||
|
||||
static void
|
||||
_outValuesScan(StringInfo str, ValuesScan *node)
|
||||
{
|
||||
WRITE_NODE_TYPE("VALUESSCAN");
|
||||
|
||||
_outScanInfo(str, (Scan *) node);
|
||||
}
|
||||
|
||||
static void
|
||||
_outJoin(StringInfo str, Join *node)
|
||||
{
|
||||
@@ -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;
|
||||
|
@@ -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')
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user