Re: Function C and INOUT parameters

From: Greg Stark <stark(at)enterprisedb(dot)com>
To: Ben Ali Rachid <souliman239(at)yahoo(dot)fr>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Function C and INOUT parameters
Date: 2009-03-24 18:11:17
Message-ID: 4136ffa0903241111r4d552600h876839b9e3b65e3c@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-www

On Tue, Mar 24, 2009 at 4:54 PM, Ben Ali Rachid <souliman239(at)yahoo(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2009-03-24 18:21:22 Re: Function C and INOUT parameters
Previous Message Tom Lane 2009-03-24 18:11:07 Re: Function C and INOUT parameters

Browse pgsql-www by date

  From Date Subject
Next Message Robert Haas 2009-03-24 18:21:22 Re: Function C and INOUT parameters
Previous Message Tom Lane 2009-03-24 18:11:07 Re: Function C and INOUT parameters