Обсуждение: ecpg problem
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.3.x thru 8.2.6. It uses embedded sql. I just yesterday upgraded our test system to 8.3.0 and this code will no longer compile. Below is a standalone code fragment in which I have removed everything but what is causing the problem. Any help or ideas would be appreciated. exec sql include sqlca; EXEC SQL WHENEVER NOT FOUND CONTINUE; // this array is grown as messages from new units are received // it is sorted by unit_serial_no ascending to support binary searches int getUnitData() { exec sql begin declare section; VARCHAR h_unit_serial_no [ 15+1]; // we do an array fetch on these 30 is the max number for these int h_remote_int_netmask [4096]; int h_local_int_netmask [4096]; VARCHAR h_tunnel_active [4096][ 1+1]; VARCHAR h_tunnel_config_type [4096][ 1+1]; VARCHAR h_local_vpn_int_ip [4096][ 20+1]; VARCHAR h_local_vpn_ext_ip [4096][ 20+1]; VARCHAR h_remote_vpn_int_ip [4096][ 20+1]; VARCHAR h_remote_vpn_ext_ip [4096][ 20+1]; exec sql end declare section; exec sql select tunnel_active, tunnel_config_type, host(local_int_gw_ip), host(local_ext_gw_ip), host(remote_int_gw_ip), host(remote_ext_gw_ip), masklen(remote_int_gw_ip), masklen(local_int_gw_ip) into :h_tunnel_active, :h_tunnel_config_type, :h_local_vpn_int_ip, :h_local_vpn_ext_ip, :h_remote_vpn_int_ip, :h_remote_vpn_ext_ip, :h_remote_int_netmask, :h_local_int_netmask from t_vpn_tunnel_status where unit_serial_no = :h_unit_serial_no order by oid; /*limit 30;*/ return TRUE; } gmake -k ecpg_test.o /usr/local/bin/ecpg -I/usr/local/include/pgsql -I/usr/local/include ecpg_test.pgc mkdep -O2 -Wall -DDEBUG -I../include -I/usr/local/include/pgsql -I/usr/local/include -I../common crypt_file.c mailuser.c srm2_monitor_server.c putfiles.c srm2_server_funcs.c escalate.c packet_loss.c srm2_cron.c srm2_db_funcs.c srm2_monitor_db.c ecpg_test.c g++ -O2 -Wall -DDEBUG -I../include -I/usr/local/include/pgsql -I/usr/local/include -I../common -c ecpg_test.c ecpg_test.pgc: In function `int getUnitData()': ecpg_test.pgc:36: error: invalid application of `sizeof' to incomplete type `varchar_h_tunnel_active' ecpg_test.pgc:38: error: invalid application of `sizeof' to incomplete type `varchar_h_tunnel_config_type' ecpg_test.pgc:40: error: invalid application of `sizeof' to incomplete type `varchar_h_local_vpn_int_ip' ecpg_test.pgc:42: error: invalid application of `sizeof' to incomplete type `varchar_h_local_vpn_ext_ip' ecpg_test.pgc:44: error: invalid application of `sizeof' to incomplete type `varchar_h_remote_vpn_int_ip' ecpg_test.pgc:46: error: invalid application of `sizeof' to incomplete type `varchar_h_remote_vpn_ext_ip' gmake: *** [ecpg_test.o] Error 1 Compilation exited abnormally with code 2 at Fri Feb 29 09:59:10
Steve Clark wrote: > 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.3.x thru 8.2.6. It uses embedded sql. I just > yesterday upgraded our test system to > 8.3.0 and this code will no longer compile. Below is a standalone code > fragment in which I have removed > everything but what is causing the problem. Any help or ideas would be > appreciated. > > exec sql include sqlca; > > EXEC SQL WHENEVER NOT FOUND CONTINUE; > > // this array is grown as messages from new units are received > // it is sorted by unit_serial_no ascending to support binary searches > > int getUnitData() > { > > exec sql begin declare section; > > VARCHAR h_unit_serial_no [ 15+1]; > // we do an array fetch on these 30 is the max number for these > int h_remote_int_netmask [4096]; > int h_local_int_netmask [4096]; > VARCHAR h_tunnel_active [4096][ 1+1]; > VARCHAR h_tunnel_config_type [4096][ 1+1]; > VARCHAR h_local_vpn_int_ip [4096][ 20+1]; > VARCHAR h_local_vpn_ext_ip [4096][ 20+1]; > VARCHAR h_remote_vpn_int_ip [4096][ 20+1]; > VARCHAR h_remote_vpn_ext_ip [4096][ 20+1]; > > exec sql end declare section; > > exec sql select tunnel_active, > tunnel_config_type, > host(local_int_gw_ip), > host(local_ext_gw_ip), > host(remote_int_gw_ip), > host(remote_ext_gw_ip), > masklen(remote_int_gw_ip), > masklen(local_int_gw_ip) > into :h_tunnel_active, > :h_tunnel_config_type, > :h_local_vpn_int_ip, > :h_local_vpn_ext_ip, > :h_remote_vpn_int_ip, > :h_remote_vpn_ext_ip, > :h_remote_int_netmask, > :h_local_int_netmask > from t_vpn_tunnel_status > where unit_serial_no = :h_unit_serial_no > order by oid; > /*limit 30;*/ > return TRUE; > } > gmake -k ecpg_test.o > /usr/local/bin/ecpg -I/usr/local/include/pgsql -I/usr/local/include > ecpg_test.pgc > mkdep -O2 -Wall -DDEBUG -I../include -I/usr/local/include/pgsql > -I/usr/local/include -I../common crypt_file.c mailuser.c > srm2_monitor_server.c putfiles.c srm2_server_funcs.c escalate.c > packet_loss.c srm2_cron.c srm2_db_funcs.c srm2_monitor_db.c ecpg_test.c > g++ -O2 -Wall -DDEBUG -I../include -I/usr/local/include/pgsql > -I/usr/local/include -I../common -c ecpg_test.c > ecpg_test.pgc: In function `int getUnitData()': > ecpg_test.pgc:36: error: invalid application of `sizeof' to incomplete > type `varchar_h_tunnel_active' > ecpg_test.pgc:38: error: invalid application of `sizeof' to incomplete > type `varchar_h_tunnel_config_type' > ecpg_test.pgc:40: error: invalid application of `sizeof' to incomplete > type `varchar_h_local_vpn_int_ip' > ecpg_test.pgc:42: error: invalid application of `sizeof' to incomplete > type `varchar_h_local_vpn_ext_ip' > ecpg_test.pgc:44: error: invalid application of `sizeof' to incomplete > type `varchar_h_remote_vpn_int_ip' > ecpg_test.pgc:46: error: invalid application of `sizeof' to incomplete > type `varchar_h_remote_vpn_ext_ip' > gmake: *** [ecpg_test.o] Error 1 > > Compilation exited abnormally with code 2 at Fri Feb 29 09:59:10 > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faq > > Actually it appears to work in 8.2.5 but be broken in 8.2.6 and 8.3.0. Steve
On Fri, Feb 29, 2008 at 11:27:25AM -0500, Steve Clark wrote: > Actually it appears to work in 8.2.5 but be broken in 8.2.6 and 8.3.0. Are you really sure? It appears to me that there was no change between 8.2.5 and 8.2.6 that could affect ecpg's handling of arrays of varchar. Michael -- Michael Meskes Email: Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org) ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes@jabber.org Go VfL Borussia! Go SF 49ers! Use Debian GNU/Linux! Use PostgreSQL!
I just committed the attached small fix to CVS HEAD and the 8.3 branch. This should fix your problem. Michael -- Michael Meskes Email: Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org) ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes@jabber.org Go VfL Borussia! Go SF 49ers! Use Debian GNU/Linux! Use PostgreSQL!
Michael Meskes wrote: > On Fri, Feb 29, 2008 at 11:27:25AM -0500, Steve Clark wrote: > >>Actually it appears to work in 8.2.5 but be broken in 8.2.6 and 8.3.0. > > > Are you really sure? It appears to me that there was no change between > 8.2.5 and 8.2.6 that could affect ecpg's handling of arrays of varchar. > > Michael I am pretty sure - but I upgraded my test system so I can't say for sure. Steve
Michael Meskes wrote: > I just committed the attached small fix to CVS HEAD and the 8.3 branch. > This should fix your problem. > > Michael > > > > ------------------------------------------------------------------------ > > diff --exclude CVS -ru /home/postgres/pgsql-ecpg/preproc/type.c preproc/type.c > --- /home/postgres/pgsql-ecpg/preproc/type.c 2007-12-21 15:33:20.000000000 +0100 > +++ preproc/type.c 2008-03-02 11:49:11.000000000 +0100 > @@ -259,7 +259,7 @@ > > ECPGdump_a_simple(o, name, > type->u.element->type, > - type->u.element->size, type->size, NULL, prefix, type->lineno); > + type->u.element->size, type->size, NULL, prefix, type->u.element->lineno); > > if (ind_type != NULL) > { Thank Michael, I'll give it a try. Steve