pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: SAKAIDA <sakaida@psn.co.jp>
To: pgsql-interfaces@postgresql.org
Subject: String array type in ecpg.
Date: Sat, 26 May 2001 22:08:23 +0900
Message-ID: <20010526210752.5CBA.SAKAIDA@psn.co.jp> (raw)

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 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.

inline patch 1: postgresql-7.1.2/src/interfaces/ecpg/lib/data.c (+2/-0 lines) download inline-1.patch*** 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

Message-ID: <20010526210752.5CBA.SAKAIDA@psn.co.jp>
Permalink:  ../20010526210752.5CBA.SAKAIDA@psn.co.jp/
Also on:    postgresql.org/message-id/20010526210752.5CBA.SAKAIDA@psn.co.jp

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: sakaida@psn.co.jp
  Subject: Re: String array type in ecpg.
  In-Reply-To: <20010526210752.5CBA.SAKAIDA@psn.co.jp>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox