Function C and INOUT parameters

From: Ben Ali Rachid <souliman239(at)yahoo(dot)fr>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Function C and INOUT parameters
Date: 2009-03-24 16:54:30
Message-ID: 665164.63021.qm@web28512.mail.ukl.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-www

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.

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)

{

arg = arg + 1 ;

}

select * from add_one(10) ;  // OK

But when I use 2 or more INOUT (or OUT) parameters like below, the server crashes with exception 0xC0000005 (access violation).

CREATE OR REPLACE FUNCTION add_one(INOUT arg1 integer, INOUT arg2 integer)

RETURNS record  AS '$libdir/myDLL.dll', 'add_one'

LANGUAGE 'c' VOLATILE STRICT ;

void add_one(int arg1, int arg2)

{

arg1 = arg1 + 1 ;

arg2 = arg2 + 1 ;

}

select * from add_one(10, 20);  // CRASH

I probably understood something wrong with the INOUT parameter. Is there someone to help me ? Thanks.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-03-24 18:11:07 Re: Function C and INOUT parameters
Previous Message Teodor Sigaev 2009-03-24 15:39:21 Re: GIN fast insert

Browse pgsql-www by date

  From Date Subject
Next Message Tom Lane 2009-03-24 18:11:07 Re: Function C and INOUT parameters
Previous Message Marc G. Fournier 2009-03-23 03:44:09 WWW Cert ...