Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WZmew-00073d-2m for pgsql-bugs@arkaria.postgresql.org; Mon, 14 Apr 2014 19:35:14 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WZmev-0007Lm-IF for pgsql-bugs@arkaria.postgresql.org; Mon, 14 Apr 2014 19:35:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WZmeu-0007La-UX for pgsql-bugs@postgresql.org; Mon, 14 Apr 2014 19:35:12 +0000 Received: from smtp-outbound-1.vmware.com ([208.91.2.12]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WZmer-0007qm-IZ for pgsql-bugs@postgresql.org; Mon, 14 Apr 2014 19:35:12 +0000 Received: from sc9-mailhost3.vmware.com (sc9-mailhost3.vmware.com [10.113.161.73]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id A0A88285D4; Mon, 14 Apr 2014 12:35:06 -0700 (PDT) Received: from zcs-prod-ext-mta-2.vmware.com (zcs-prod-ext-mta-2.vmware.com [10.113.62.224]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id 9B9FC4639B; Mon, 14 Apr 2014 12:35:06 -0700 (PDT) Received: from zcs-prod-ext-mta-2.vmware.com (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-2.vmware.com (Postfix) with ESMTP id 42EB6C0036; Mon, 14 Apr 2014 12:34:59 -0700 (PDT) Received: from [192.168.1.90] (zimbra-prod-ext-proxy-vip.vmware.com [10.113.63.87]) by zcs-prod-ext-mta-2.vmware.com (Postfix) with ESMTPSA; Mon, 14 Apr 2014 12:34:58 -0700 (PDT) Message-ID: <534C3868.3010207@vmware.com> Date: Mon, 14 Apr 2014 22:35:04 +0300 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.4.0 MIME-Version: 1.0 To: aleksey.vitaliev@transas.com, pgsql-bugs@postgresql.org Subject: Re: BUG #10014: Does not work PQfn in libpq with array References: <20140414084248.15390.12810@wrigleys.postgresql.org> In-Reply-To: <20140414084248.15390.12810@wrigleys.postgresql.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -7.9 (-------) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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