Hi,
String array type in ecpg is strange.
> pgbash
pgbash> create table test_array(code varchar(4), name text[3]);
pgbash> insert into test_array values('c01','{"n01","n02","n03"}');
pgbash> select * from test_array;
code|name
----+-------------------
c01 |{"n01","n02","n03"}
(1 row)
--------------------( ECPG program)------------------------
# include <stdio.h>
exec sql include sqlca;
main()
{ exec sql begin declare section; char code[5]; char name[256]; exec sql end declare section;
exec sql connect to admin user admin;
exec sql declare cur cursor for select * from test_array; exec sql open cur; while(1) { exec sql fetch cur
into:code, :name; if( sqlca.sqlcode == 100 ) break; printf("# code=(%s) name=(%s)\n", code, name ); } exec
sqlclose cur;
}
------------------------------------------------------------
Results are as follows.
# code=("n02","n03"}) name=({"n01","n02","n03"})
Segmentation fault (core dumped)
Here is the patch which corrects this bug.
*** postgresql-7.1.2/src/interfaces/ecpg/lib/data.c.orig Sat May 26 20:47:53 2001
--- postgresql-7.1.2/src/interfaces/ecpg/lib/data.c Sat May 26 21:33:10 2001
***************
*** 337,342 ****
--- 337,344 ---- return (false); break; }
+ if (type == ECPGt_char || type == ECPGt_unsigned_char || type == ECPGt_varchar)
+ break; if (isarray) { bool string = false;
--
SAKAIDA Masaaki