88bool
99get_data (PGresult * results ,int act_tuple ,int act_field ,int lineno ,
1010enum ECPGttype type ,enum ECPGttype ind_type ,
11- void * var ,void * ind ,long varcharsize ,long offset )
11+ void * var ,void * ind ,long varcharsize ,long offset ,
12+ bool isarray )
1213{
1314char * pval = (char * )PQgetvalue (results ,act_tuple ,act_field );
1415
1516ECPGlog ("get_data line %d: RESULT: %s\n" ,lineno ,pval ?pval :"" );
1617
1718/* Now the pval is a pointer to the value. */
19+ /* let's check is it really is an array if it should be */
20+ if (isarray )
21+ {
22+ if (* pval != '{' )
23+ {
24+ ECPGlog ("get_data data entry does not look like an array in line %d\n" ,lineno );
25+ ECPGraise (lineno ,ECPG_DATA_NOT_ARRAY ,NULL );
26+ return (false);
27+ }
28+ else ++ pval ;
29+ }
30+
1831/* We will have to decode the value */
1932
2033/*
@@ -48,8 +61,10 @@ get_data(PGresult *results, int act_tuple, int act_field, int lineno,
4861break ;
4962}
5063
51- switch (type )
52- {
64+ do
65+ {
66+ switch (type )
67+ {
5368long res ;
5469unsigned long ures ;
5570double dres ;
@@ -61,7 +76,8 @@ get_data(PGresult *results, int act_tuple, int act_field, int lineno,
6176if (pval )
6277{
6378res = strtol (pval ,& scan_length ,10 );
64- if (* scan_length != '\0' )/* Garbage left */
79+ if ((isarray && * scan_length != ',' && * scan_length != '}' )
80+ || (!isarray && * scan_length != '\0' ))/* Garbage left */
6581{
6682ECPGraise (lineno ,ECPG_INT_FORMAT ,pval );
6783return (false);
@@ -94,7 +110,8 @@ get_data(PGresult *results, int act_tuple, int act_field, int lineno,
94110if (pval )
95111{
96112ures = strtoul (pval ,& scan_length ,10 );
97- if (* scan_length != '\0' )/* Garbage left */
113+ if ((isarray && * scan_length != ',' && * scan_length != '}' )
114+ || (!isarray && * scan_length != '\0' ))/* Garbage left */
98115{
99116ECPGraise (lineno ,ECPG_UINT_FORMAT ,pval );
100117return (false);
@@ -127,7 +144,8 @@ get_data(PGresult *results, int act_tuple, int act_field, int lineno,
127144if (pval )
128145{
129146dres = strtod (pval ,& scan_length );
130- if (* scan_length != '\0' )/* Garbage left */
147+ if ((isarray && * scan_length != ',' && * scan_length != '}' )
148+ || (!isarray && * scan_length != '\0' ))/* Garbage left */
131149{
132150ECPGraise (lineno ,ECPG_FLOAT_FORMAT ,pval );
133151return (false);
@@ -246,7 +264,23 @@ get_data(PGresult *results, int act_tuple, int act_field, int lineno,
246264ECPGraise (lineno ,ECPG_UNSUPPORTED ,ECPGtype_name (type ));
247265return (false);
248266break ;
249- }
250-
267+ }
268+ if (isarray )
269+ {
270+ bool string = false;
271+
272+ /* set array to next entry */
273+ ++ act_tuple ;
274+
275+ /* set pval to the next entry */
276+ for (;string || (* pval != ',' && * pval != '}' );++ pval )
277+ if (* pval == '"' )
278+ string = string ? false : true;
279+
280+ if (* pval == ',' )
281+ ++ pval ;
282+ }
283+ }while (isarray && * pval != '}' );
284+
251285return (true);
252286}