@@ -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;
@@ -305,7 +311,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
305
311
case ECPGt_int :
306
312
case ECPGt_long :
307
313
res = strtol (pval , & scan_length , 10 );
308
- if (garbage_left (isarray , scan_length , compat ))
314
+ if (garbage_left (isarray , & scan_length , compat ))
309
315
{
310
316
ecpg_raise (lineno , ECPG_INT_FORMAT ,
311
317
ECPG_SQLSTATE_DATATYPE_MISMATCH , pval );
@@ -334,7 +340,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
334
340
case ECPGt_unsigned_int :
335
341
case ECPGt_unsigned_long :
336
342
ures = strtoul (pval , & scan_length , 10 );
337
- if (garbage_left (isarray , scan_length , compat ))
343
+ if (garbage_left (isarray , & scan_length , compat ))
338
344
{
339
345
ecpg_raise (lineno , ECPG_UINT_FORMAT ,
340
346
ECPG_SQLSTATE_DATATYPE_MISMATCH , pval );
@@ -363,7 +369,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
363
369
#ifdef HAVE_STRTOLL
364
370
case ECPGt_long_long :
365
371
* ((long long int * ) (var + offset * act_tuple )) = strtoll (pval , & scan_length , 10 );
366
- if (garbage_left (isarray , scan_length , compat ))
372
+ if (garbage_left (isarray , & scan_length , compat ))
367
373
{
368
374
ecpg_raise (lineno , ECPG_INT_FORMAT , ECPG_SQLSTATE_DATATYPE_MISMATCH , pval );
369
375
return (false);
@@ -375,7 +381,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
375
381
#ifdef HAVE_STRTOULL
376
382
case ECPGt_unsigned_long_long :
377
383
* ((unsigned long long int * ) (var + offset * act_tuple )) = strtoull (pval , & scan_length , 10 );
378
- if (garbage_left (isarray , scan_length , compat ))
384
+ if (garbage_left (isarray , & scan_length , compat ))
379
385
{
380
386
ecpg_raise (lineno , ECPG_UINT_FORMAT , ECPG_SQLSTATE_DATATYPE_MISMATCH , pval );
381
387
return (false);
@@ -397,7 +403,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
397
403
if (isarray && * scan_length == '"' )
398
404
scan_length ++ ;
399
405
400
- if (garbage_left (isarray , scan_length , compat ))
406
+ if (garbage_left (isarray , & scan_length , compat ))
401
407
{
402
408
ecpg_raise (lineno , ECPG_FLOAT_FORMAT ,
403
409
ECPG_SQLSTATE_DATATYPE_MISMATCH , pval );
@@ -595,7 +601,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
595
601
}
596
602
else
597
603
{
598
- if (!isarray && garbage_left (isarray , scan_length , compat ))
604
+ if (!isarray && garbage_left (isarray , & scan_length , compat ))
599
605
{
600
606
free (nres );
601
607
ecpg_raise (lineno , ECPG_NUMERIC_FORMAT ,
@@ -653,7 +659,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
653
659
if (* scan_length == '"' )
654
660
scan_length ++ ;
655
661
656
- if (!isarray && garbage_left (isarray , scan_length , compat ))
662
+ if (!isarray && garbage_left (isarray , & scan_length , compat ))
657
663
{
658
664
free (ires );
659
665
ecpg_raise (lineno , ECPG_INTERVAL_FORMAT ,
@@ -703,7 +709,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
703
709
if (* scan_length == '"' )
704
710
scan_length ++ ;
705
711
706
- if (!isarray && garbage_left (isarray , scan_length , compat ))
712
+ if (!isarray && garbage_left (isarray , & scan_length , compat ))
707
713
{
708
714
ecpg_raise (lineno , ECPG_DATE_FORMAT ,
709
715
ECPG_SQLSTATE_DATATYPE_MISMATCH , pval );
@@ -751,7 +757,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
751
757
if (* scan_length == '"' )
752
758
scan_length ++ ;
753
759
754
- if (!isarray && garbage_left (isarray , scan_length , compat ))
760
+ if (!isarray && garbage_left (isarray , & scan_length , compat ))
755
761
{
756
762
ecpg_raise (lineno , ECPG_TIMESTAMP_FORMAT ,
757
763
ECPG_SQLSTATE_DATATYPE_MISMATCH , pval );
0 commit comments