Skip to content

Commit 56b01dc

Browse files
committed
Make SPI set SPI_processed for CREATE TABLE AS / SELECT INTO commands;
this in turn causes CREATE TABLE AS in plpgsql to set ROW_COUNT. This is how it behaved before 7.4; I had unintentionally changed the behavior in a bit of sloppy micro-optimization.
1 parent dce83e7 commit 56b01dc

File tree

1 file changed

+6
-4
lines changed
  • src/backend/executor

1 file changed

+6
-4
lines changed

src/backend/executor/spi.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.140 2005/05/06 17:24:54 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.141 2005/06/09 21:25:22 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1497,17 +1497,18 @@ static int
14971497
_SPI_pquery(QueryDesc *queryDesc, long tcount)
14981498
{
14991499
int operation = queryDesc->operation;
1500+
CommandDest origDest = queryDesc->dest->mydest;
15001501
int res;
15011502
Oid save_lastoid;
15021503

15031504
switch (operation)
15041505
{
15051506
case CMD_SELECT:
15061507
res = SPI_OK_SELECT;
1507-
if (queryDesc->parsetree->into != NULL) /* select into table */
1508+
if (queryDesc->parsetree->into) /* select into table? */
15081509
{
15091510
res = SPI_OK_SELINTO;
1510-
queryDesc->dest = None_Receiver; /* don't output results */
1511+
queryDesc->dest = None_Receiver; /* don't output results */
15111512
}
15121513
break;
15131514
case CMD_INSERT:
@@ -1548,7 +1549,8 @@ _SPI_pquery(QueryDesc *queryDesc, long tcount)
15481549

15491550
ExecutorEnd(queryDesc);
15501551

1551-
if (queryDesc->dest->mydest == SPI)
1552+
/* Test origDest here so that SPI_processed gets set in SELINTO case */
1553+
if (origDest == SPI)
15521554
{
15531555
SPI_processed = _SPI_current->processed;
15541556
SPI_lastoid = save_lastoid;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy