From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tomasz Myrta <jasiek@klaster.net>
Cc: Lista dyskusyjna pgsql-sql <pgsql-sql@postgresql.org>
Subject: Re: pl/pgsql, cursors and C function
Date: Tue, 23 Sep 2003 11:15:09 -0400
Message-ID: <16949.1064330109@sss.pgh.pa.us> (raw)
In-Reply-To: <3F70314C.30507@klaster.net>
References: <3F70314C.30507@klaster.net>
Tomasz Myrta <jasiek@klaster.net> writes:
> I don't understand ERROR message at all:
> ERROR: SPI_prepare() failed on "SELECT $1 "
This is a bug. Or two bugs, actually: one of yours and one of PG's.
I have repaired the PG bug with the attached patch. The bug in your
code is that your C function needs to call SPI_connect and SPI_finish
if it's going to use any SPI operations.
regards, tom lane
inline patch 1: spi.c (+2/-1 lines) download inline-1.patchIndex: spi.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/executor/spi.c,v
retrieving revision 1.75.2.3
diff -c -r1.75.2.3 spi.c
*** spi.c 14 Feb 2003 21:12:54 -0000 1.75.2.3
--- spi.c 23 Sep 2003 15:09:39 -0000
***************
*** 1387,1393 ****
elog(ERROR, "invalid portal in SPI cursor operation");
/* Push the SPI stack */
! _SPI_begin_call(true);
/* Reset the SPI result */
SPI_processed = 0;
--- 1387,1394 ----
elog(ERROR, "invalid portal in SPI cursor operation");
/* Push the SPI stack */
! if (_SPI_begin_call(true) < 0)
! elog(ERROR, "SPI cursor operation called while not connected");
/* Reset the SPI result */
SPI_processed = 0;
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, jasiek@klaster.net
Subject: Re: pl/pgsql, cursors and C function
In-Reply-To: <16949.1064330109@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox