Re: ECPG failed
От | SAKAIDA Masaaki |
---|---|
Тема | Re: ECPG failed |
Дата | |
Msg-id | 3921F9C4398.4F67SAKAIDA@smtp.psn.ne.jp обсуждение исходный текст |
Список | pgsql-interfaces |
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 *** 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 */ {
В списке pgsql-interfaces по дате отправления: