Received: from mail.psn.ne.jp (mail.psn.ne.jp [210.167.249.5]) by hub.org (8.9.3/8.9.3) with ESMTP id VAA72727 for ; Tue, 16 May 2000 21:39:49 -0400 (EDT) (envelope-from sakaida@psn.co.jp) Received: from ppp119 (ppp119.psn.ne.jp [210.167.249.119]) by mail.psn.ne.jp (8.9.1/3.7W) with SMTP id KAA00370 for ; Wed, 17 May 2000 10:39:47 +0900 (JST) Date: Wed, 17 May 2000 10:45:40 +0900 From: SAKAIDA Masaaki To: pgsql-interfaces@postgreSQL.org Subject: Re: ECPG failed In-Reply-To: <20000515112018.B14019@fam-meskes.de> References: <391D401878.E288SAKAIDA@smtp.psn.ne.jp> <20000515112018.B14019@fam-meskes.de> Message-Id: <3921F9C4398.4F67SAKAIDA@smtp.psn.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Mailer: Becky! ver 1.26 X-Archive-Number: 200005/12 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 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 *** 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 + #include #include #include *************** *** 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 */ {