From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Michael Andreen" <harv(at)ruin(dot)nu> |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #2817: Mixing spi_prepare and spi_exec_query causes postgresql to terminate itself on bad argument types |
Date: | 2006-12-08 00:42:12 |
Message-ID: | 23182.1165538532@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
"Michael Andreen" <harv(at)ruin(dot)nu> writes:
> CREATE OR REPLACE FUNCTION crash()
> RETURNS int4 AS
> $BODY$$rv = spi_exec_query("SELECT 1");
> $query = spi_prepare('SELECT 1 WHERE 1 = $1','integer');
> return 1;$BODY$
> LANGUAGE 'plperl' VOLATILE;
Thanks for the test case. This is not plperl's fault, it's the
consequence of some anti-memory-leak code added very recently.
Here's the fix if you need it right away...
regards, tom lane
*** src/backend/executor/spi.c.orig Tue Nov 21 17:35:29 2006
--- src/backend/executor/spi.c Thu Dec 7 19:33:33 2006
***************
*** 1543,1548 ****
--- 1543,1551 ----
SPI_lastoid = my_lastoid;
SPI_tuptable = my_tuptable;
+ /* tuptable now is caller's responsibility, not SPI's */
+ _SPI_current->tuptable = NULL;
+
return my_res;
}
***************
*** 1694,1699 ****
--- 1697,1705 ----
/* Put the result into place for access by caller */
SPI_processed = _SPI_current->processed;
SPI_tuptable = _SPI_current->tuptable;
+
+ /* tuptable now is caller's responsibility, not SPI's */
+ _SPI_current->tuptable = NULL;
/* Pop the SPI stack */
_SPI_end_call(true);
From | Date | Subject | |
---|---|---|---|
Next Message | Juan Pablo Yañez | 2006-12-08 16:00:39 | unsubscribe |
Previous Message | Tom Lane | 2006-12-07 23:26:59 | Re: BUG #2811: Error determining param type in prepared statement of unused variable |