Re: pl/pgsql, cursors and C function
От | Tom Lane |
---|---|
Тема | Re: pl/pgsql, cursors and C function |
Дата | |
Msg-id | 16949.1064330109@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | pl/pgsql, cursors and C function (Tomasz Myrta <jasiek@klaster.net>) |
Ответы |
Re: pl/pgsql, cursors and C function
|
Список | pgsql-sql |
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 Index: 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;
В списке pgsql-sql по дате отправления: