Re: Function C and INOUT parameters - Mailing list pgsql-hackers

From Greg Stark
Subject Re: Function C and INOUT parameters
Date
Msg-id 4136ffa0903241111r4d552600h876839b9e3b65e3c@mail.gmail.com
Whole thread Raw
In response to Function C and INOUT parameters  (Ben Ali Rachid <souliman239@yahoo.fr>)
Responses Re: Function C and INOUT parameters  (Robert Haas <robertmhaas@gmail.com>)
Re: Function C and INOUT parameters  (Josh Berkus <josh@agliodbs.com>)
List pgsql-hackers
On Tue, Mar 24, 2009 at 4:54 PM, Ben Ali Rachid <souliman239@yahoo.fr> wrote:
> Hello,
>
> I posted my problem (on pgsql-interfaces list) about the INOUT parameters on
> PostgreSQL 8.3.6 (Win32), but without success. I re-post my question here,
> while hoping to have more success.

Personally I'm of the opinion we should eliminate most of these
duplicative mailing lists like -performance and -interfaces and just
use -general. I don't see that having multiple lists for user
questions helps either the users or the answerers due to just this
type of problem.


> When I use a function with one INOUT (or OUT) parameter like below,
> everyting is OK.
>
> CREATE OR REPLACE FUNCTION add_one(INOUT arg integer)
> RETURNS integer  AS '$libdir/myDLL.dll', 'add_one'
> LANGUAGE 'c' VOLATILE STRICT ;
>
> // In 'myDLL'
> void add_one(int arg)

a) you should probably be using V1 calling api rather than V0. see

http://www.postgresql.org/docs/8.3/interactive/xfunc-c.html#AEN40901

b) you need to arrange for the C function to return a record with all
the returned fields. You can't just set the parameters to new values
and return void.

The api to return a record is at:

http://www.postgresql.org/docs/8.3/interactive/xfunc-c.html#AEN41361

--
greg


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Function C and INOUT parameters
Next
From: Robert Haas
Date:
Subject: Re: Function C and INOUT parameters