Received: from trust.ocn.ne.jp (trust.ocn.ne.jp [210.190.142.54]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f4QD7VA30993 for ; Sat, 26 May 2001 09:07:31 -0400 (EDT) (envelope-from sakaida@psn.co.jp) Received: from u5q6l1 (p0801-ip01kobeminato.hyogo.ocn.ne.jp [211.130.253.39]) by trust.ocn.ne.jp (8.9.1a/OCN/) with ESMTP id WAA05022 for ; Sat, 26 May 2001 22:07:25 +0900 (JST) Date: Sat, 26 May 2001 22:08:23 +0900 From: SAKAIDA To: pgsql-interfaces@postgresql.org Subject: String array type in ecpg. Message-Id: <20010526210752.5CBA.SAKAIDA@psn.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Becky! ver. 2.00.01 X-Archive-Number: 200105/106 X-Sequence-Number: 1636 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 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 sql close 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