Re: libpq and Datums management with embedded C function

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: libpq and Datums management with embedded C function
Дата
Msg-id AANLkTi=A057jDrpsGRuf0u-eFn4hwbRekABGEOrakGSs@mail.gmail.com
обсуждение исходный текст
Ответ на libpq and Datums management with embedded C function  (Alessandro Candini <candini@meeo.it>)
Ответы Re: libpq and Datums management with embedded C function  (Alessandro Candini <candini@meeo.it>)
Список pgsql-general
On Thu, Feb 17, 2011 at 4:16 AM, Alessandro Candini <candini@meeo.it> wrote:
> I'm dealing witch a C function embedded into postgresql-9.0.2.
>
> I'm returning a set of rows and following the example here
> http://www.postgresql.org/docs/9.0/static/xfunc-c.html everything works
> fine, but only if I use the C string approach.
>
> I'm using libpq to retrieve data and something like this works fine:
> snprintf(values[0], 16, "%s", PQgetvalue(funcctx->user_fctx, call_cntr, 0));
> because PQgetvalue returns an array of char.
>
> But if I want to get the original data as output, I have to deal with Datums
> and I don't know how to do this with lippq.
> Something like the following it doesn't work:
>
> Datum values[1];
> values[0] = (Datum) PQgetvalue(funcctx->user_fctx, call_cntr, 1);
> snprintf(values[0], 16, "%s", PQgetvalue(funcctx->user_fctx, call_cntr, 0));
>
> Have you got any idea of how to solve this...do you know another way to
> perform a query indide the db without involve libpq?
> I would prefer to use them because I can connect to several postgresql
> instances.

Have you ruled out dblink?  Also for connecting to self it would be
preferable to use SPI
(http://www.postgresql.org/docs/9.0/static/spi.html) vs libpq.

merlin

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

Предыдущее
От: Ahmed
Дата:
Сообщение: Re: "could not accept SSPI security context"
Следующее
От: Dmitriy Igrishin
Дата:
Сообщение: Re: SELECT INTO array[i] with PL/pgSQL