public inbox for [email protected]  
help / color / mirror / Atom feed
From: Greg Stark <[email protected]>
To: Ben Ali Rachid <[email protected]>
Cc: [email protected]
Subject: Re: Function C and INOUT parameters
Date: Tue, 24 Mar 2009 18:11:17 +0000
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>

On Tue, Mar 24, 2009 at 4:54 PM, Ben Ali Rachid <[email protected]> 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



view thread (16+ messages)  latest in thread

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Function C and INOUT parameters
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox