Re: ECPG Segfault and variable usage question. - Mailing list pgsql-interfaces

From Edmund Bacon
Subject Re: ECPG Segfault and variable usage question.
Date
Msg-id 1076688454.19238.12.camel@elb_lx.onesystem.ca
Whole thread Raw
In response to ECPG Segfault and variable usage question.  (Jürgen Cappel <email@juergen-cappel.de>)
Responses Re: ECPG Segfault and variable usage question.  (Michael Meskes <meskes@postgresql.org>)
List pgsql-interfaces
An added data point for this bug<br /><br /> I have seen a similar problem, although it seems to only manifest itself
inlong (1000+ line) source files.   It seems to have something to do with using macros rather than explicit constants
todefine array dimensions.  I'd be willing to bet that the below code example would compile by adding<br /><br />
#defineCL_2   (2*CHAR_LENGTH)<br /> ...<br />    char var[CL_2];<br /> ...<br /><br /> There seem to be 2 work arounds:
eitheruse a shorter macro name, or break long files into smaller pieces.<br /><br /> On Thu, 2004-02-12 at 12:00,
JürgenCappel wrote: <blockquote type="CITE"><pre><font color="#737373"><i>Hello,
 

this is a code snippet that causes ECPG to segfault. It's quite tricky
to produce, as changing the variable name from 'var' to 'myvar' already
causes things to compile fine ...


#define CHAR_LENGTH 25
myfunction ()
{   EXEC SQL BEGIN DECLARE SECTION;   char   var[2*CHAR_LENGTH];   EXEC SQL END DECLARE SECTION;
   EXEC SQL DECLARE mycursor CURSOR FOR SELECT att1, att2 FROM mytable WHERE att1 LIKE :var ESCAPE '\\';   EXEC SQL
OPENmycursor;
 
}

Stack trace was obtained using a snapshot from about 2 weeks ago, ECPG from
the 7.4.1 release segfaults also.

#0  0x4015fdcb in chunk_free () from /lib/libc.so.6
#1  0x4015fc53 in free () from /lib/libc.so.6
#2  0x080685b7 in dump_variables (list=0x80c1408, mode=1) at variable.c:405
#3  0x08066d56 in output_statement (   stmt=0x80c14f8 "declare mycursor  cursor  for select  att1  , att2
from mytable where att1  like  ? escape '\\\\'  ", mode=0, con=0x0) at
output.c:126
#4  0x0804af02 in yyparse () at preproc.y:780
#5  0x0806671d in main (argc=8, argv=0xbffff264) at ecpg.c:409
#6  0x401089ed in __libc_start_main () from /lib/libc.so.6


Another problem that's giving me headaches trying to find a workaround for
is the following use of variables as data sources in INSERT/UPDATE
statements:
:myarray[index[10]]

Any comments, suggestions, hints ?   Thanks a lot,

Jürgen


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend</i></font></pre></blockquote><pre><table cellpadding="0" cellspacing="0"
width="100%">
<tr>
<td>
-- <br />
Edmund Bacon <<a href="mailto:ebacon@onesystem.com"><u>ebacon@onesystem.com</u></a>>
</td>
</tr>
</table>
</pre>

pgsql-interfaces by date:

Previous
From: L J Bayuk
Date:
Subject: Re: libpgtcl.dll for tcl 8.4?
Next
From: Michael Meskes
Date:
Subject: Re: ECPG Segfault and variable usage question.