mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Tweak SPI_cursor_open to allow INSERT/UPDATE/DELETE RETURNING; this was
merely a matter of fixing the error check, since the underlying Portal infrastructure already handles it. This in turn allows these statements to be used in some existing plpgsql and plperl contexts, such as a plpgsql FOR loop. Also, do some marginal code cleanup in places that were being sloppy about distinguishing SELECT from SELECT INTO.
This commit is contained in:
@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.264 2006/08/12 02:52:05 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.265 2006/08/12 20:05:56 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1224,6 +1224,38 @@ UtilityTupleDescriptor(Node *parsetree)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* QueryReturnsTuples
|
||||
* Return "true" if this Query will send output to the destination.
|
||||
*/
|
||||
bool
|
||||
QueryReturnsTuples(Query *parsetree)
|
||||
{
|
||||
switch (parsetree->commandType)
|
||||
{
|
||||
case CMD_SELECT:
|
||||
/* returns tuples ... unless it's SELECT INTO */
|
||||
if (parsetree->into == NULL)
|
||||
return true;
|
||||
break;
|
||||
case CMD_INSERT:
|
||||
case CMD_UPDATE:
|
||||
case CMD_DELETE:
|
||||
/* the forms with RETURNING return tuples */
|
||||
if (parsetree->returningList)
|
||||
return true;
|
||||
break;
|
||||
case CMD_UTILITY:
|
||||
return UtilityReturnsTuples(parsetree->utilityStmt);
|
||||
case CMD_UNKNOWN:
|
||||
case CMD_NOTHING:
|
||||
/* probably shouldn't get here */
|
||||
break;
|
||||
}
|
||||
return false; /* default */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* CreateCommandTag
|
||||
* utility to get a string representation of the
|
||||
|
Reference in New Issue
Block a user