From: SAKAIDA Masaaki <sakaida@psn.co.jp>
To: pgsql-interfaces@postgreSQL.org
Subject: Re: ECPG failed
Date: Wed, 17 May 2000 10:45:40 +0900
Message-ID: <3921F9C4398.4F67SAKAIDA@smtp.psn.ne.jp> (raw)
In-Reply-To: <20000515112018.B14019@fam-meskes.de>
References: <391D401878.E288SAKAIDA@smtp.psn.ne.jp>
<20000515112018.B14019@fam-meskes.de>
Yesterday I have sent this mail to pgsql-interfaces, but I could
not receive this mail. So, let me send this mail again.
Michael Meskes <meskes@postgresql.org> wrote:
> On Sat, May 13, 2000 at 08:44:24PM +0900, SAKAIDA Masaaki wrote:
> > In postgresql-7.0, it seems to work normally with the next
> > patch.
>
> Unfortunately this does break the usage I had in mind with arrays. If you
> have an int[3] stored in the database the easiest way IMO to work with it is
> ro read it into a int[3] in C. And that operation needs the ++pval.
I could understand what you meant. I think you already made the
patch for this error. But, your patch will be applied in 7.0.1.
So, I have made the next patch for 7.0. This patch would solve
the next cases.
(1) if a host variable is char type, then
c1 = "{1,2,3}"
d1 = "{\"1.1\",\"2.2\",\"3.3\"}"
(2) if a host variable is int array type, then
c1[0] = 1, c1[1] = 2, c1[2] = 3
(3) if a host variable is float array type, then
d1[0] = 1.1, d1[1] = 2.2, d1[2] = 3.3
--
Regards,
SAKAIDA Masaaki -- Osaka, Japan
inline patch 1: src/interfaces/ecpg/lib/data.c (+23/-2 lines) download inline-1.patch*** src/interfaces/ecpg/lib/data.c.orig Sat May 13 14:38:43 2000
--- src/interfaces/ecpg/lib/data.c Tue May 16 15:40:57 2000
***************
*** 1,4 ****
--- 1,5 ----
#include <stdlib.h>
+ #include <string.h>
#include <ecpgtype.h>
#include <ecpglib.h>
***************
*** 26,33 ****
ECPGraise(lineno, ECPG_DATA_NOT_ARRAY, NULL);
return (false);
}
! else
! ++pval;
}
/* We will have to decode the value */
--- 27,44 ----
ECPGraise(lineno, ECPG_DATA_NOT_ARRAY, NULL);
return (false);
}
!
! switch (type)
! {
! case ECPGt_char:
! case ECPGt_unsigned_char:
! case ECPGt_varchar:
! break;
!
! default:
! pval++;
! break;
! }
}
/* We will have to decode the value */
***************
*** 144,150 ****
--- 155,171 ----
case ECPGt_double:
if (pval)
{
+ if (isarray && *pval == '"')+ pval++;+
dres = strtod(pval, &scan_length);
+ + if (isarray && *scan_length == '"')+ {+ scan_length++;+ pval = scan_length;+ }+
if ((isarray && *scan_length != ',' && *scan_length != '}')
|| (!isarray && *scan_length != '\0')) /* Garbage left */
{
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: ECPG failed
In-Reply-To: <3921F9C4398.4F67SAKAIDA@smtp.psn.ne.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