Re: Trouble with bytea in SPI...

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Trouble with bytea in SPI...
Дата
Msg-id 20050902030535.GA58575@winnie.fuhr.org
обсуждение исходный текст
Ответ на Trouble with bytea in SPI...  ("Cristian Prieto" <cristian@clickdiario.com>)
Ответы Re: Trouble with bytea in SPI...  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
On Thu, Sep 01, 2005 at 08:23:31PM -0600, Cristian Prieto wrote:
> Hello, I've been working just a little with SPI in a few stored
> functions, this is a model of my SP:

Please post a real example instead of a "model."  The code you
posted fails to compile, with errors and warnings like the following:

spitest.c: In function `myspi':
spitest.c:18: `ret' undeclared (first use in this function)
spitest.c:18: (Each undeclared identifier is reported only once
spitest.c:18: for each function it appears in.)
spitest.c:39: warning: passing arg 2 of `SPI_execp' from incompatible pointer type
spitest.c:41: warning: implicit declaration of function `SPI_finnish'
spitest.c:16: warning: unused variable `res'

Since what you posted doesn't compile, it can't be what you're
really doing; that means we have to guess at what the real code
looks like.  It would be easier to help if we could see the real
thing so we don't have to guess.

>     // This is where the SP and the connection dies!
>     ret = SPI_execp(plan, val, NULL, 1);

val is a bytea * but the second argument to SPI_execp() is a Datum *
(the compiler warning hints that something's wrong here).  Try
something like this:

    Datum  values[1];

    values[0] = PointerGetDatum(val);
    ret = SPI_execp(plan, values, NULL, 1);

That works for me in simple tests.  If anybody sees a problem with
it then please make corrections.

--
Michael Fuhr

В списке pgsql-general по дате отправления:

Предыдущее
От: "Cristian Prieto"
Дата:
Сообщение: Trouble with bytea in SPI...
Следующее
От: Matthew Peter
Дата:
Сообщение: same size VARCHAR or INT IX faster?