Function C and INOUT parameters

Ben Ali Rachid <[email protected]> Wed, 18 Mar 2009 13:13:23 +0000 (GMT)
Newsgroups gmane.comp.db.postgresql.interfaces
Message-ID <[email protected]>
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