Function C and INOUT parameters

From: Ben Ali Rachid <souliman239(at)yahoo(dot)fr>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Function C and INOUT parameters
Date: 2009-03-18 13:13:23
Message-ID: 238982.46441.qm@web28504.mail.ukl.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Hello,

I have created a function (on Windows XP) in PostgreSQL 8.3.6 with 2 inout parameters. His code is :

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

RETURNS record

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

LANGUAGE 'c' VOLATILE STRICT ;

In my DLL (created with Visual Studio Pro 2008), I have a function C (it's just a test function) :

void add_one(int arg1, int arg2)

{

arg1 = arg1 + 1 ;

arg2 = arg2 + 1 ;

}

When I try to execute my function (select * from add_one(10, 20)), the server crashes . The problem is that if I use a function with one INOUT parameter like this :

CREATE OR REPLACE FUNCTION add_one(INOUT arg integer)

RETURNS integer

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

LANGUAGE 'c' VOLATILE STRICT ;

void add_one(int arg)

{

arg = arg + 1 ;

}
, everything is OK. I think the problem is related to "RETURNS record", but I have no idea to solve it

Any idea ?

Thanks

Browse pgsql-interfaces by date

  From Date Subject
Next Message Alvaro Herrera 2009-03-25 21:50:34 Re: this mailing list is proposed to be retired
Previous Message David Saracini 2009-03-08 22:32:10 Function to return a tabledef?