@@ -44,21 +44,27 @@ array_boundary(enum ARRAY_TYPE isarray, char c)
44
44
45
45
/* returns true if some garbage is found at the end of the scanned string */
46
46
static bool
47
- garbage_left (enum ARRAY_TYPE isarray , char * scan_length , enum COMPAT_MODE compat )
47
+ garbage_left (enum ARRAY_TYPE isarray , char * * scan_length , enum COMPAT_MODE compat )
48
48
{
49
49
/*
50
50
* INFORMIX allows for selecting a numeric into an int, the result is
51
51
* truncated
52
52
*/
53
53
if (isarray == ECPG_ARRAY_NONE )
54
54
{
55
- if (INFORMIX_MODE (compat ) && * scan_length == '.' )
55
+ if (INFORMIX_MODE (compat ) && * * scan_length == '.' )
56
+ {
57
+ /* skip invalid characters */
58
+ do {
59
+ (* scan_length )++ ;
60
+ } while (* * scan_length != ' ' && * * scan_length != '\0' && isdigit (* * scan_length ));
56
61
return false;
62
+ }
57
63
58
- if (* scan_length != ' ' && * scan_length != '\0' )
64
+ if (* * scan_length != ' ' && * * scan_length != '\0' )
59
65
return true;
60
66
}
61
- else if (ECPG_IS_ARRAY (isarray ) && !array_delimiter (isarray , * scan_length ) && !array_boundary (isarray , * scan_length ))
67
+ else if (ECPG_IS_ARRAY (isarray ) && !array_delimiter (isarray , * * scan_length ) && !array_boundary (isarray , * * scan_length ))
62
68
return true;
63
69
64
70
return false;
@@ -303,7 +309,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
303
309
case ECPGt_int :
304
310
case ECPGt_long :
305
311
res = strtol (pval , & scan_length , 10 );
306
- if (garbage_left (isarray , scan_length , compat ))
312
+ if (garbage_left (isarray , & scan_length , compat ))
307
313
{
308
314
ecpg_raise (lineno , ECPG_INT_FORMAT ,
309
315
ECPG_SQLSTATE_DATATYPE_MISMATCH , pval );
@@ -332,7 +338,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
332
338
case ECPGt_unsigned_int :
333
339
case ECPGt_unsigned_long :
334
340
ures = strtoul (pval , & scan_length , 10 );
335
- if (garbage_left (isarray , scan_length , compat ))
341
+ if (garbage_left (isarray , & scan_length , compat ))
336
342
{
337
343
ecpg_raise (lineno , ECPG_UINT_FORMAT ,
338
344
ECPG_SQLSTATE_DATATYPE_MISMATCH , pval );
@@ -361,7 +367,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
361
367
#ifdef HAVE_STRTOLL
362
368
case ECPGt_long_long :
363
369
* ((long long int * ) (var + offset * act_tuple )) = strtoll (pval , & scan_length , 10 );
364
- if (garbage_left (isarray , scan_length , compat ))
370
+ if (garbage_left (isarray , & scan_length , compat ))
365
371
{
366
372
ecpg_raise (lineno , ECPG_INT_FORMAT , ECPG_SQLSTATE_DATATYPE_MISMATCH , pval );
367
373
return (false);
@@ -373,7 +379,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
373
379
#ifdef HAVE_STRTOULL
374
380
case ECPGt_unsigned_long_long :
375
381
* ((unsigned long long int * ) (var + offset * act_tuple )) = strtoull (pval , & scan_length , 10 );
376
- if (garbage_left (isarray , scan_length , compat ))
382
+ if (garbage_left (isarray , & scan_length , compat ))
377
383
{
378
384
ecpg_raise (lineno , ECPG_UINT_FORMAT , ECPG_SQLSTATE_DATATYPE_MISMATCH , pval );
379
385
return (false);
@@ -395,7 +401,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
395
401
if (isarray && * scan_length == '"' )
396
402
scan_length ++ ;
397
403
398
- if (garbage_left (isarray , scan_length , compat ))
404
+ if (garbage_left (isarray , & scan_length , compat ))
399
405
{
400
406
ecpg_raise (lineno , ECPG_FLOAT_FORMAT ,
401
407
ECPG_SQLSTATE_DATATYPE_MISMATCH , pval );
@@ -593,7 +599,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
593
599
}
594
600
else
595
601
{
596
- if (!isarray && garbage_left (isarray , scan_length , compat ))
602
+ if (!isarray && garbage_left (isarray , & scan_length , compat ))
597
603
{
598
604
free (nres );
599
605
ecpg_raise (lineno , ECPG_NUMERIC_FORMAT ,
@@ -651,7 +657,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
651
657
if (* scan_length == '"' )
652
658
scan_length ++ ;
653
659
654
- if (!isarray && garbage_left (isarray , scan_length , compat ))
660
+ if (!isarray && garbage_left (isarray , & scan_length , compat ))
655
661
{
656
662
free (ires );
657
663
ecpg_raise (lineno , ECPG_INTERVAL_FORMAT ,
@@ -701,7 +707,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
701
707
if (* scan_length == '"' )
702
708
scan_length ++ ;
703
709
704
- if (!isarray && garbage_left (isarray , scan_length , compat ))
710
+ if (!isarray && garbage_left (isarray , & scan_length , compat ))
705
711
{
706
712
ecpg_raise (lineno , ECPG_DATE_FORMAT ,
707
713
ECPG_SQLSTATE_DATATYPE_MISMATCH , pval );
@@ -749,7 +755,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
749
755
if (* scan_length == '"' )
750
756
scan_length ++ ;
751
757
752
- if (!isarray && garbage_left (isarray , scan_length , compat ))
758
+ if (!isarray && garbage_left (isarray , & scan_length , compat ))
753
759
{
754
760
ecpg_raise (lineno , ECPG_TIMESTAMP_FORMAT ,
755
761
ECPG_SQLSTATE_DATATYPE_MISMATCH , pval );
0 commit comments