Re: BUG #10014: Does not work PQfn in libpq with array

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: BUG #10014: Does not work PQfn in libpq with array
Дата
Msg-id 534C3868.3010207@vmware.com
обсуждение исходный текст
Ответ на BUG #10014: Does not work PQfn in libpq with array  (aleksey.vitaliev@transas.com)
Список pgsql-bugs
On 04/14/2014 11:42 AM, aleksey.vitaliev@transas.com wrote:
> The following bug has been logged on the website:
>
> Bug reference:      10014
> Logged by:          Vitalyev Aleksey
> Email address:      aleksey.vitaliev@transas.com
> PostgreSQL version: 9.2.4
> Operating system:   Windows 7
> Description:
>
> I have a store procedure __a(INT[] args). I try execute this procedure with
> libpq and call PQfn function. How should I transmit array of int from c++
> code?

You probably shouldn't be using the PQfn function. Per the manual:

> Tip: This interface is somewhat obsolete, as one can achieve similar
> performance and greater functionality by setting up a prepared
> statement to define the function call. Then, executing the statement
> with binary transmission of parameters and results substitutes for a
> fast-path function call.

Constructing the binary format for arrays is quite complicated. You can
look at the array_send/array_recv functions in the PostgreSQL source
tree to see what's involved. There's also a library called libpqtypes
out there that can do it for you. But it's a lot simpler to just use the
text format.

Yet another approach is to pass the elements to the server separately,
and construct the array in the server. Something like "SELECT
myprocedure(ARRAY[?, ?, ?])".

- Heikki

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

Предыдущее
От: David G Johnston
Дата:
Сообщение: Re: Fwd: cant insert into a post gre sql table...Can u please help in fixing this
Следующее
От: digoal@126.com
Дата:
Сообщение: BUG #10035: PostgreSQL nodes's estimate rows bug? when alter column set statistics 0