mirror of
https://github.com/postgres/postgres.git
synced 2025-08-27 07:42:10 +03:00
Add INSERT/UPDATE/DELETE RETURNING, with basic docs and regression tests.
plpgsql support to come later. Along the way, convert execMain's SELECT INTO support into a DestReceiver, in order to eliminate some ugly special cases. Jonah Harris 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.346 2006/08/10 02:36:28 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.347 2006/08/12 02:52:04 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -1704,6 +1704,7 @@ _copyQuery(Query *from)
|
||||
COPY_NODE_FIELD(rtable);
|
||||
COPY_NODE_FIELD(jointree);
|
||||
COPY_NODE_FIELD(targetList);
|
||||
COPY_NODE_FIELD(returningList);
|
||||
COPY_NODE_FIELD(groupClause);
|
||||
COPY_NODE_FIELD(havingQual);
|
||||
COPY_NODE_FIELD(distinctClause);
|
||||
@@ -1713,6 +1714,7 @@ _copyQuery(Query *from)
|
||||
COPY_NODE_FIELD(rowMarks);
|
||||
COPY_NODE_FIELD(setOperations);
|
||||
COPY_NODE_FIELD(resultRelations);
|
||||
COPY_NODE_FIELD(returningLists);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
@@ -1725,6 +1727,7 @@ _copyInsertStmt(InsertStmt *from)
|
||||
COPY_NODE_FIELD(relation);
|
||||
COPY_NODE_FIELD(cols);
|
||||
COPY_NODE_FIELD(selectStmt);
|
||||
COPY_NODE_FIELD(returningList);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
@@ -1735,8 +1738,9 @@ _copyDeleteStmt(DeleteStmt *from)
|
||||
DeleteStmt *newnode = makeNode(DeleteStmt);
|
||||
|
||||
COPY_NODE_FIELD(relation);
|
||||
COPY_NODE_FIELD(whereClause);
|
||||
COPY_NODE_FIELD(usingClause);
|
||||
COPY_NODE_FIELD(whereClause);
|
||||
COPY_NODE_FIELD(returningList);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
@@ -1750,6 +1754,7 @@ _copyUpdateStmt(UpdateStmt *from)
|
||||
COPY_NODE_FIELD(targetList);
|
||||
COPY_NODE_FIELD(whereClause);
|
||||
COPY_NODE_FIELD(fromClause);
|
||||
COPY_NODE_FIELD(returningList);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.280 2006/08/10 02:36:28 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.281 2006/08/12 02:52:04 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -664,6 +664,7 @@ _equalQuery(Query *a, Query *b)
|
||||
COMPARE_NODE_FIELD(rtable);
|
||||
COMPARE_NODE_FIELD(jointree);
|
||||
COMPARE_NODE_FIELD(targetList);
|
||||
COMPARE_NODE_FIELD(returningList);
|
||||
COMPARE_NODE_FIELD(groupClause);
|
||||
COMPARE_NODE_FIELD(havingQual);
|
||||
COMPARE_NODE_FIELD(distinctClause);
|
||||
@@ -673,6 +674,7 @@ _equalQuery(Query *a, Query *b)
|
||||
COMPARE_NODE_FIELD(rowMarks);
|
||||
COMPARE_NODE_FIELD(setOperations);
|
||||
COMPARE_NODE_FIELD(resultRelations);
|
||||
COMPARE_NODE_FIELD(returningLists);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -683,6 +685,7 @@ _equalInsertStmt(InsertStmt *a, InsertStmt *b)
|
||||
COMPARE_NODE_FIELD(relation);
|
||||
COMPARE_NODE_FIELD(cols);
|
||||
COMPARE_NODE_FIELD(selectStmt);
|
||||
COMPARE_NODE_FIELD(returningList);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -691,8 +694,9 @@ static bool
|
||||
_equalDeleteStmt(DeleteStmt *a, DeleteStmt *b)
|
||||
{
|
||||
COMPARE_NODE_FIELD(relation);
|
||||
COMPARE_NODE_FIELD(whereClause);
|
||||
COMPARE_NODE_FIELD(usingClause);
|
||||
COMPARE_NODE_FIELD(whereClause);
|
||||
COMPARE_NODE_FIELD(returningList);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -704,6 +708,7 @@ _equalUpdateStmt(UpdateStmt *a, UpdateStmt *b)
|
||||
COMPARE_NODE_FIELD(targetList);
|
||||
COMPARE_NODE_FIELD(whereClause);
|
||||
COMPARE_NODE_FIELD(fromClause);
|
||||
COMPARE_NODE_FIELD(returningList);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.281 2006/08/10 02:36:28 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.282 2006/08/12 02:52:04 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Every node type that can appear in stored rules' parsetrees *must*
|
||||
@@ -1525,6 +1525,7 @@ _outQuery(StringInfo str, Query *node)
|
||||
WRITE_NODE_FIELD(rtable);
|
||||
WRITE_NODE_FIELD(jointree);
|
||||
WRITE_NODE_FIELD(targetList);
|
||||
WRITE_NODE_FIELD(returningList);
|
||||
WRITE_NODE_FIELD(groupClause);
|
||||
WRITE_NODE_FIELD(havingQual);
|
||||
WRITE_NODE_FIELD(distinctClause);
|
||||
@@ -1534,6 +1535,7 @@ _outQuery(StringInfo str, Query *node)
|
||||
WRITE_NODE_FIELD(rowMarks);
|
||||
WRITE_NODE_FIELD(setOperations);
|
||||
WRITE_NODE_FIELD(resultRelations);
|
||||
WRITE_NODE_FIELD(returningLists);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/readfuncs.c,v 1.194 2006/08/10 02:36:28 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/readfuncs.c,v 1.195 2006/08/12 02:52:04 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Path and Plan nodes do not have any readfuncs support, because we
|
||||
@@ -148,6 +148,7 @@ _readQuery(void)
|
||||
READ_NODE_FIELD(rtable);
|
||||
READ_NODE_FIELD(jointree);
|
||||
READ_NODE_FIELD(targetList);
|
||||
READ_NODE_FIELD(returningList);
|
||||
READ_NODE_FIELD(groupClause);
|
||||
READ_NODE_FIELD(havingQual);
|
||||
READ_NODE_FIELD(distinctClause);
|
||||
@@ -157,6 +158,7 @@ _readQuery(void)
|
||||
READ_NODE_FIELD(rowMarks);
|
||||
READ_NODE_FIELD(setOperations);
|
||||
READ_NODE_FIELD(resultRelations);
|
||||
READ_NODE_FIELD(returningLists);
|
||||
|
||||
READ_DONE();
|
||||
}
|
||||
|
Reference in New Issue
Block a user