diff options
| author | Tom Lane | 2006-08-12 20:05:56 +0000 |
|---|---|---|
| committer | Tom Lane | 2006-08-12 20:05:56 +0000 |
| commit | 3f8db37c2f1eeeffd9dae3189b783a463f56fe77 (patch) | |
| tree | f6520123161af6191b5f53262d67eab69b24eccf /src/backend/tcop | |
| parent | 883f4b42d7292f1a7142e55046cee86f92049b5a (diff) | |
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.
Diffstat (limited to 'src/backend/tcop')
| -rw-r--r-- | src/backend/tcop/utility.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index 807b64360c8..7d6941ddcef 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -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 $ * *------------------------------------------------------------------------- */ @@ -1225,6 +1225,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 * command operation, given a raw (un-analyzed) parsetree. |
