BUG #4549: ecpg produces code that don't compile - Mailing list pgsql-bugs
From | Clemens Fischer |
---|---|
Subject | BUG #4549: ecpg produces code that don't compile |
Date | |
Msg-id | 200811251044.mAPAiWi0090108@wwwmaster.postgresql.org Whole thread Raw |
Responses |
Re: BUG #4549: ecpg produces code that don't compile
|
List | pgsql-bugs |
The following bug has been logged online: Bug reference: 4549 Logged by: Clemens Fischer Email address: cfi@mbs-software.de PostgreSQL version: 8.3.5 Operating system: QNX 6.3 Description: ecpg produces code that don't compile Details: Hello List, Don't know whether anyone here can help but... We have some code that has compiled and ran just fine from postgresql 7.4.x thru 8.2.9. It uses embedded sql. With the new port - 8.3.5 - this code will no longer compile. Below is a standalone code, which shows you the details. Any help or ideas would be appreciated. -- snip ecpgtest-multidim.pgc begin -- #include <stdio.h> #include <stdlib.h> EXEC SQL include sqlca; EXEC SQL WHENEVER SQLERROR sqlprint; EXEC SQL WHENEVER SQLWARNING sqlprint; EXEC SQL WHENEVER NOT FOUND continue; int main( void ) { EXEC SQL begin declare section; char multidim_char[4][50]; // works VARCHAR multidim_varchar[4][50]; // failed EXEC SQL end declare section; ECPGdebug(1, stderr); EXEC SQL connect to postgres user postgres using postgres; EXEC SQL DROP TABLE IF EXISTS ecpgtest; EXEC SQL CREATE TABLE ecpgtest (no INTEGER PRIMARY KEY, name VARCHAR(30) NOT NULL); EXEC SQL INSERT INTO ecpgtest VALUES (1, 'first'); EXEC SQL INSERT INTO ecpgtest VALUES (2, 'second'); EXEC SQL INSERT INTO ecpgtest VALUES (3, 'third'); // test 1 EXEC SQL SELECT name INTO :multidim_char[0] FROM ecpgtest WHERE no = 1; // test 2 EXEC SQL SELECT name INTO :multidim_varchar[0] FROM ecpgtest WHERE no = 1; EXEC SQL DISCONNECT ALL; ECPGdebug(0, stderr); return( EXIT_SUCCESS ); } -- snip ecpgtest-multidim.pgc end -- Using ecpg and gcc generates the following output: ecpg -t -o ecpgtest-multidim.c ecpgtest-multidim.pgc cc -c -I/usr/local/pgsql/include ecpgtest-multidim.c ecpgtest-multidim.pgc: In function `main': ecpgtest-multidim.pgc:30: parse error before `_13' cc: /usr/qnx630/host/qnx6/x86/usr/lib/gcc-lib/ntox86/2.95.3/cc1 error 33 make: *** [ecpgtest-multidim.o] Error 1 -- snip ecpgtest-multidim.c code fragment 1 begin -- int main( void ) { /* exec sql begin declare section */ // works // failed #line 12 "ecpgtest-multidim.pgc" char multidim_char [ 4 ] [ 50 ] ; #line 13 "ecpgtest-multidim.pgc" struct varchar_multidim_varchar_13 { int len; char arr[ 50 ]; } multidim_va rchar [4] ; /* exec sql end declare section */ #line 14 "ecpgtest-multidim.pgc" ECPGdebug(1, stderr); -- snip ecpgtest-multidim.c code fragment 1 end -- You see in "#line 13" the definition of the varchar. -- snip ecpgtest-multidim.c code fragment 2 begin -- // test 1 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select name from ecpgtest where no = 1 ", ECPGt_EOIT, ECPGt_char,(multidim_char[0]),(long)50,(long)1,(50)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 27 "ecpgtest-multidim.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 27 "ecpgtest-multidim.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 27 "ecpgtest-multidim.pgc" // test 2 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select name from ecpgtest where no = 1 ", ECPGt_EOIT, ECPGt_varchar,&(multidim_varchar[0]),(long)50,(long)1,sizeof(struct varchar_multidim_varchar[0]_13), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 29 "ecpgtest-multidim.pgc" -- snip ecpgtest-multidim.c fragment 2 end -- In the second fragment you see the wrong sizeof-call: varchar_multidim_varchar[0]_13 one solution is: varchar_multidim_varchar_13[0] Can you fix this, please? Thank you Clemens Fischer
pgsql-bugs by date: