Thread: ecpg question
I wanted to ask this on here before going any further. I've got functions that return rowsets, which from the psql shell require me to write selects with AS TBL( ... ) to define the return types. When I try to put a query together in ECPG to get values from these functions, I discovered some nasty ecpg behavior. EXEC SQL SELECT * FROM foo() AS TBL( c int ); compiles properly (?) to { ECPGdo(__LINE__, 0, 1, NULL, "select * from foo () as TBL ( c int ) ", ECPGt_EOIT, ECPGt_EORT);} however EXEC SQL SELECT * FROM foo() AS TBL( c int, i int ); or any other query with multiple columns to a TBL description causes a segfault in ecpg. It also concerns me that all other symbols are dropped to lowercase, while TBL is still uppercase. Leads me to believe that TBL isn't getting parsed. This was tested against cvs pgsql, and the backtrace from the segfaults are consistent and appear below. Program received signal SIGSEGV, Segmentation fault. in strlen () from /usr/lib/libc.so.1 (gdb) bt #0 in strlen () from /usr/lib/libc.so.1 #1 in cat2_str (str1=0xa5750 "c int ", str2=0x2c <Address 0x2c out of bounds>) at preproc.y:80 #2 in cat_str (count=3) at preproc.y:103 #3 in _end () #4 in main (argc=2, argv=0xxxxxxxxx) at ecpg.c:395 I tried picking the rules apart that call cat_str in this case, but I can't really figure out where in preproc.y it gets called and screws that second var argument to cat_str up. Hopefully someone has dealt with this before and can tell me why what I'm doing is wrong, or that I should send this on to -hackers. Thanks, -George werkt@csh.rit.edu
On Tue, Dec 23, 2003 at 02:06:14AM -0500, George Gensure wrote: > dropped to lowercase, while TBL is still uppercase. Leads me to > believe that TBL isn't getting parsed. This was tested against cvs pgsql, > and the backtrace from the segfaults are consistent and appear below. Yes, it surely looks that way. > second var argument to cat_str up. Hopefully someone has dealt with this > before and can tell me why what I'm doing is wrong, or that I should send > this on to -hackers. Not yet, but I will when I find the time. Michael -- Michael Meskes Email: Michael at Fam-Meskes dot De ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes@jabber.org Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!
On Tue, Dec 23, 2003 at 02:06:14AM -0500, George Gensure wrote: > EXEC SQL SELECT * FROM foo() AS TBL( c int, i int ); > > or any other query with multiple columns to a TBL description causes a > segfault in ecpg. It also concerns me that all other symbols are I just fixed this. The reason was a usage of ',' instead of make_str(",") in the cat_str call. Since the argument is free'd afterwards it couldn't work. Ecpg does not lowercase all symbols per default but only those that need some special treatment like keywords. There's no logic to just lowercase everything as this is not requiered IIRC. Michael -- Michael Meskes Email: Michael at Fam-Meskes dot De ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes@jabber.org Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!
Cool. I only thought that tbl would need special treatment. Is that fix in cvs? Thanks, -George