Function C and INOUT parameters - Mailing list pgsql-hackers

From Ben Ali Rachid
Subject Function C and INOUT parameters
Date
Msg-id 665164.63021.qm@web28512.mail.ukl.yahoo.com
Whole thread Raw
Responses Re: Function C and INOUT parameters
Re: Function C and INOUT parameters
List pgsql-hackers
<table border="0" cellpadding="0" cellspacing="0"><tr><td style="font: inherit;" valign="top">Hello, <br /><br />I
postedmy 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.<br /><br />When I use a function with one INOUT
(orOUT) parameter like below, everyting is OK.<br /><span id="intelliTxt" name="intelliTxt"><span style="font-style:
italic;"><br/></span></span><span id="intelliTxt" name="intelliTxt" style="font-style: italic;">CREATE OR REPLACE
FUNCTIONadd_one(INOUT arg integer)<br /> RETURNS integer  AS '$libdir/myDLL.dll', 'add_one'<br /> LANGUAGE 'c' VOLATILE
STRICT;</span><br /><br /><span id="intelliTxt" name="intelliTxt" style="font-style: italic;">// In 'myDLL'<br />void
add_one(intarg)<br /> {<br /> arg = arg + 1 ;<br /> }</span><br /><br /><span id="intelliTxt" name="intelliTxt"
style="font-style:italic;">select * from add_one(10)</span><span style="font-style: italic;"> ;  // OK</span><br /><br
/>Butwhen I use 2 or more INOUT (or OUT) parameters like below, the server crashes with exception 0xC0000005 (access
violation).<br /><br /><span id="intelliTxt" name="intelliTxt"><span style="font-style: italic;">CREATE OR REPLACE
FUNCTIONadd_one(INOUT arg1 integer, INOUT arg2 integer)</span><br style="font-style: italic;" /><span
style="font-style:italic;"> RETURNS record  </span><span style="font-style: italic;">AS '$libdir/myDLL.dll',
'add_one'</span><brstyle="font-style: italic;" /><span style="font-style: italic;"> LANGUAGE 'c' VOLATILE STRICT ;<br
/><br/></span></span><span id="intelliTxt" name="intelliTxt"><span style="font-style: italic;">void add_one(int arg1,
intarg2)</span><br style="font-style: italic;" /><span style="font-style: italic;"> {</span><br style="font-style:
italic;"/><span style="font-style: italic;"> arg1 = arg1 + 1 ;</span><br style="font-style: italic;" /><span
style="font-style:italic;"> arg2 = arg2 + 1 ;</span><br style="font-style: italic;" /><span style="font-style:
italic;">}</span></span><br /><br /><span id="intelliTxt" name="intelliTxt" style="font-style: italic;">select * from
add_one(10,20);  // CRASH</span><br /><br />I probably understood something wrong with the INOUT parameter. Is there
someoneto help me ? Thanks.<br /><br /></td></tr></table><br /> 

pgsql-hackers by date:

Previous
From: Teodor Sigaev
Date:
Subject: Re: GIN fast insert
Next
From: Tom Lane
Date:
Subject: Re: Function C and INOUT parameters