Function C and INOUT parameters
От | Ben Ali Rachid |
---|---|
Тема | Function C and INOUT parameters |
Дата | |
Msg-id | 238982.46441.qm@web28504.mail.ukl.yahoo.com обсуждение исходный текст |
Список | pgsql-interfaces |
<table border="0" cellpadding="0" cellspacing="0"><tr><td style="font: inherit;" valign="top"><span id="intelliTxt" name="intelliTxt">Hello,<br /><br /> I have created a function (on Windows XP) in PostgreSQL 8.3.6 with 2 inout parameters.His code is :<br /><br /><span style="font-style: italic;">CREATE OR REPLACE FUNCTION add_one(INOUT arg1 integer,INOUT arg2 integer)</span><br style="font-style: italic;" /><span style="font-style: italic;"> RETURNS <span style="font-weight:bold;">record</span> </span><br style="font-style: italic;" /><span style="font-style: italic;"> AS '$libdir/myDLL.dll','add_one'</span><br style="font-style: italic;" /><span style="font-style: italic;"> LANGUAGE 'c' VOLATILESTRICT ;</span><br /><br /> In my DLL (created with Visual Studio Pro 2008), I have a function C (it's just a testfunction) :<br /><br /><span style="font-style: italic;"> void add_one(int arg1, int arg2)</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><br /><br />When I try to execute my function (select * from add_one(10, 20)), the server crashes <img alt="" border="0" class="inlineimg"src="http://images.devshed.com/fds/smilies/confused.gif" title="Confused" /> . The problem is that if Iuse a function with one INOUT parameter like this :<br /><br /></span><span id="intelliTxt" name="intelliTxt" style="font-style:italic;">CREATE OR REPLACE FUNCTION add_one(INOUT arg integer)<br /> RETURNS integer <br /> AS '$libdir/myDLL.dll','add_one'<br /> LANGUAGE 'c' VOLATILE STRICT ;</span><br /><span id="intelliTxt" name="intelliTxt"><br/></span><span id="intelliTxt" name="intelliTxt" style="font-style: italic;">void add_one(int arg)<br/> {<br /> arg = arg + 1 ;<br /> }</span><br /><span id="intelliTxt" name="intelliTxt">, everything is OK. </span>Ithink the problem is related to "RETURNS record", but I have no idea to solve it<br /><span id="intelliTxt" name="intelliTxt"><br/> Any idea ?<br /> Thanks<br /></span><br /></td></tr></table><br />
В списке pgsql-interfaces по дате отправления: