pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <hlinnakangas@vmware.com>
To: aleksey.vitaliev@transas.com
To: pgsql-bugs@postgresql.org
Subject: Re: BUG #10014: Does not work PQfn in libpq with array
Date: Mon, 14 Apr 2014 22:35:04 +0300
Message-ID: <534C3868.3010207@vmware.com> (raw)
In-Reply-To: <20140414084248.15390.12810@wrigleys.postgresql.org>
References: <20140414084248.15390.12810@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (2+ messages)

Message-ID: <534C3868.3010207@vmware.com>
Permalink:  ../534C3868.3010207@vmware.com/
Also on:    postgresql.org/message-id/534C3868.3010207@vmware.com

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: hlinnakangas@vmware.com, aleksey.vitaliev@transas.com
  Subject: Re: BUG #10014: Does not work PQfn in libpq with array
  In-Reply-To: <534C3868.3010207@vmware.com>
  References: <20140414084248.15390.12810@wrigleys.postgresql.org> <534C3868.3010207@vmware.com>

* 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