Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 9caafda

Browse files
committed
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.
1 parent d307c42 commit 9caafda

40 files changed

+1873
-309
lines changed

src/backend/catalog/heap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.311 2006/07/31 20:09:00 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.312 2006/08/02 01:59:44 joe Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -1841,7 +1841,7 @@ cookDefault(ParseState *pstate,
18411841
/*
18421842
* Coerce the expression to the correct type and typmod, if given. This
18431843
* should match the parser's processing of non-defaulted expressions ---
1844-
* see updateTargetListEntry().
1844+
* see transformAssignedExpr().
18451845
*/
18461846
if (OidIsValid(atttypid))
18471847
{

src/backend/commands/explain.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994-5, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.149 2006/07/14 14:52:18 momjian Exp $
10+
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.150 2006/08/02 01:59:45 joe Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -527,6 +527,9 @@ explain_outNode(StringInfo str,
527527
case T_FunctionScan:
528528
pname = "Function Scan";
529529
break;
530+
case T_ValuesScan:
531+
pname = "Values Scan";
532+
break;
530533
case T_Material:
531534
pname = "Materialize";
532535
break;
@@ -666,6 +669,22 @@ explain_outNode(StringInfo str,
666669
quote_identifier(rte->eref->aliasname));
667670
}
668671
break;
672+
case T_ValuesScan:
673+
if (((Scan *) plan)->scanrelid > 0)
674+
{
675+
RangeTblEntry *rte = rt_fetch(((Scan *) plan)->scanrelid,
676+
es->rtable);
677+
char *valsname;
678+
679+
/* Assert it's on a values rte */
680+
Assert(rte->rtekind == RTE_VALUES);
681+
682+
valsname = rte->eref->aliasname;
683+
684+
appendStringInfo(str, " on %s",
685+
quote_identifier(valsname));
686+
}
687+
break;
669688
default:
670689
break;
671690
}
@@ -728,6 +747,7 @@ explain_outNode(StringInfo str,
728747
case T_SeqScan:
729748
case T_SubqueryScan:
730749
case T_FunctionScan:
750+
case T_ValuesScan:
731751
show_scan_qual(plan->qual,
732752
"Filter",
733753
((Scan *) plan)->scanrelid,

src/backend/executor/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Makefile for executor
55
#
66
# IDENTIFICATION
7-
# $PostgreSQL: pgsql/src/backend/executor/Makefile,v 1.23 2005/04/19 22:35:11 tgl Exp $
7+
# $PostgreSQL: pgsql/src/backend/executor/Makefile,v 1.24 2006/08/02 01:59:45 joe Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -19,7 +19,8 @@ OBJS = execAmi.o execGrouping.o execJunk.o execMain.o \
1919
nodeBitmapHeapscan.o nodeBitmapIndexscan.o nodeHash.o \
2020
nodeHashjoin.o nodeIndexscan.o nodeMaterial.o nodeMergejoin.o \
2121
nodeNestloop.o nodeFunctionscan.o nodeResult.o nodeSeqscan.o \
22-
nodeSetOp.o nodeSort.o nodeUnique.o nodeLimit.o nodeGroup.o \
22+
nodeSetOp.o nodeSort.o nodeUnique.o \
23+
nodeValuesscan.o nodeLimit.o nodeGroup.o \
2324
nodeSubplan.o nodeSubqueryscan.o nodeTidscan.o tstoreReceiver.o spi.o
2425

2526
all: SUBSYS.o

src/backend/executor/execAmi.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/backend/executor/execAmi.c,v 1.88 2006/07/14 14:52:18 momjian Exp $
9+
* $PostgreSQL: pgsql/src/backend/executor/execAmi.c,v 1.89 2006/08/02 01:59:45 joe Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -38,6 +38,7 @@
3838
#include "executor/nodeSubqueryscan.h"
3939
#include "executor/nodeTidscan.h"
4040
#include "executor/nodeUnique.h"
41+
#include "executor/nodeValuesscan.h"
4142

4243

4344
/*
@@ -144,6 +145,10 @@ ExecReScan(PlanState *node, ExprContext *exprCtxt)
144145
ExecFunctionReScan((FunctionScanState *) node, exprCtxt);
145146
break;
146147

148+
case T_ValuesScanState:
149+
ExecValuesReScan((ValuesScanState *) node, exprCtxt);
150+
break;
151+
147152
case T_NestLoopState:
148153
ExecReScanNestLoop((NestLoopState *) node, exprCtxt);
149154
break;
@@ -226,6 +231,10 @@ ExecMarkPos(PlanState *node)
226231
ExecFunctionMarkPos((FunctionScanState *) node);
227232
break;
228233

234+
case T_ValuesScanState:
235+
ExecValuesMarkPos((ValuesScanState *) node);
236+
break;
237+
229238
case T_MaterialState:
230239
ExecMaterialMarkPos((MaterialState *) node);
231240
break;
@@ -275,6 +284,10 @@ ExecRestrPos(PlanState *node)
275284
ExecFunctionRestrPos((FunctionScanState *) node);
276285
break;
277286

287+
case T_ValuesScanState:
288+
ExecValuesRestrPos((ValuesScanState *) node);
289+
break;
290+
278291
case T_MaterialState:
279292
ExecMaterialRestrPos((MaterialState *) node);
280293
break;
@@ -298,8 +311,8 @@ ExecRestrPos(PlanState *node)
298311
*
299312
* (However, since the only present use of mark/restore is in mergejoin,
300313
* there is no need to support mark/restore in any plan type that is not
301-
* capable of generating ordered output. So the seqscan, tidscan, and
302-
* functionscan support is actually useless code at present.)
314+
* capable of generating ordered output. So the seqscan, tidscan,
315+
* functionscan, and valuesscan support is actually useless code at present.)
303316
*/
304317
bool
305318
ExecSupportsMarkRestore(NodeTag plantype)
@@ -310,6 +323,7 @@ ExecSupportsMarkRestore(NodeTag plantype)
310323
case T_IndexScan:
311324
case T_TidScan:
312325
case T_FunctionScan:
326+
case T_ValuesScan:
313327
case T_Material:
314328
case T_Sort:
315329
return true;
@@ -359,6 +373,7 @@ ExecSupportsBackwardScan(Plan *node)
359373
case T_IndexScan:
360374
case T_TidScan:
361375
case T_FunctionScan:
376+
case T_ValuesScan:
362377
return true;
363378

364379
case T_SubqueryScan:
@@ -413,6 +428,7 @@ ExecMayReturnRawTuples(PlanState *node)
413428
case T_TidScanState:
414429
case T_SubqueryScanState:
415430
case T_FunctionScanState:
431+
case T_ValuesScanState:
416432
if (node->ps_ProjInfo == NULL)
417433
return true;
418434
break;

src/backend/executor/execProcnode.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/backend/executor/execProcnode.c,v 1.57 2006/07/14 14:52:18 momjian Exp $
15+
* $PostgreSQL: pgsql/src/backend/executor/execProcnode.c,v 1.58 2006/08/02 01:59:45 joe Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -102,6 +102,7 @@
102102
#include "executor/nodeSubqueryscan.h"
103103
#include "executor/nodeTidscan.h"
104104
#include "executor/nodeUnique.h"
105+
#include "executor/nodeValuesscan.h"
105106
#include "miscadmin.h"
106107

107108
/* ------------------------------------------------------------------------
@@ -194,6 +195,11 @@ ExecInitNode(Plan *node, EState *estate, int eflags)
194195
estate, eflags);
195196
break;
196197

198+
case T_ValuesScan:
199+
result = (PlanState *) ExecInitValuesScan((ValuesScan *) node,
200+
estate, eflags);
201+
break;
202+
197203
/*
198204
* join nodes
199205
*/
@@ -365,6 +371,10 @@ ExecProcNode(PlanState *node)
365371
result = ExecFunctionScan((FunctionScanState *) node);
366372
break;
367373

374+
case T_ValuesScanState:
375+
result = ExecValuesScan((ValuesScanState *) node);
376+
break;
377+
368378
/*
369379
* join nodes
370380
*/
@@ -536,6 +546,9 @@ ExecCountSlotsNode(Plan *node)
536546
case T_FunctionScan:
537547
return ExecCountSlotsFunctionScan((FunctionScan *) node);
538548

549+
case T_ValuesScan:
550+
return ExecCountSlotsValuesScan((ValuesScan *) node);
551+
539552
/*
540553
* join nodes
541554
*/
@@ -669,6 +682,10 @@ ExecEndNode(PlanState *node)
669682
ExecEndFunctionScan((FunctionScanState *) node);
670683
break;
671684

685+
case T_ValuesScanState:
686+
ExecEndValuesScan((ValuesScanState *) node);
687+
break;
688+
672689
/*
673690
* join nodes
674691
*/

0 commit comments

Comments
 (0)