Skip to content

Commit 566480a

Browse files
committed
Avoid double free of _SPI_current->tuptable. AtEOSubXact_SPI() now tries to
release it in a subtransaction abort, but this neglects possibility that someone outside SPI already did. Fix is for spi.c to forget about a tuptable as soon as it's handed it back to the caller. Per bug #2817 from Michael Andreen.
1 parent 8124215 commit 566480a

File tree

1 file changed

+7
-1
lines changed
  • src/backend/executor

1 file changed

+7
-1
lines changed

src/backend/executor/spi.c

Lines changed: 7 additions & 1 deletion
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.165 2006/11/21 22:35:29 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.166 2006/12/08 00:40:27 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1543,6 +1543,9 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, const char *Nulls,
15431543
SPI_lastoid = my_lastoid;
15441544
SPI_tuptable = my_tuptable;
15451545

1546+
/* tuptable now is caller's responsibility, not SPI's */
1547+
_SPI_current->tuptable = NULL;
1548+
15461549
return my_res;
15471550
}
15481551

@@ -1695,6 +1698,9 @@ _SPI_cursor_operation(Portal portal, bool forward, long count,
16951698
SPI_processed = _SPI_current->processed;
16961699
SPI_tuptable = _SPI_current->tuptable;
16971700

1701+
/* tuptable now is caller's responsibility, not SPI's */
1702+
_SPI_current->tuptable = NULL;
1703+
16981704
/* Pop the SPI stack */
16991705
_SPI_end_call(true);
17001706
}

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