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