Function C and INOUT parameters

View: New views
1 Messages — Rating Filter:   Alert me  

Function C and INOUT parameters

by Ben Ali Rachid :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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