mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Make sure ecpglib does accepts digits behind decimal point even for integers in
Informix mode. Spotted and fixed by 高增琦 <pgf00a@gmail.com>
This commit is contained in:
@ -46,7 +46,7 @@ array_boundary(enum ARRAY_TYPE isarray, char c)
|
||||
|
||||
/* returns true if some garbage is found at the end of the scanned string */
|
||||
static bool
|
||||
garbage_left(enum ARRAY_TYPE isarray, char *scan_length, enum COMPAT_MODE compat)
|
||||
garbage_left(enum ARRAY_TYPE isarray, char **scan_length, enum COMPAT_MODE compat)
|
||||
{
|
||||
/*
|
||||
* INFORMIX allows for selecting a numeric into an int, the result is
|
||||
@ -54,13 +54,19 @@ garbage_left(enum ARRAY_TYPE isarray, char *scan_length, enum COMPAT_MODE compat
|
||||
*/
|
||||
if (isarray == ECPG_ARRAY_NONE)
|
||||
{
|
||||
if (INFORMIX_MODE(compat) && *scan_length == '.')
|
||||
if (INFORMIX_MODE(compat) && **scan_length == '.')
|
||||
{
|
||||
/* skip invalid characters */
|
||||
do {
|
||||
(*scan_length)++;
|
||||
} while (**scan_length != ' ' && **scan_length != '\0' && isdigit(**scan_length));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (*scan_length != ' ' && *scan_length != '\0')
|
||||
if (**scan_length != ' ' && **scan_length != '\0')
|
||||
return true;
|
||||
}
|
||||
else if (ECPG_IS_ARRAY(isarray) && !array_delimiter(isarray, *scan_length) && !array_boundary(isarray, *scan_length))
|
||||
else if (ECPG_IS_ARRAY(isarray) && !array_delimiter(isarray, **scan_length) && !array_boundary(isarray, **scan_length))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@ -305,7 +311,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
||||
case ECPGt_int:
|
||||
case ECPGt_long:
|
||||
res = strtol(pval, &scan_length, 10);
|
||||
if (garbage_left(isarray, scan_length, compat))
|
||||
if (garbage_left(isarray, &scan_length, compat))
|
||||
{
|
||||
ecpg_raise(lineno, ECPG_INT_FORMAT,
|
||||
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
||||
@ -334,7 +340,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
||||
case ECPGt_unsigned_int:
|
||||
case ECPGt_unsigned_long:
|
||||
ures = strtoul(pval, &scan_length, 10);
|
||||
if (garbage_left(isarray, scan_length, compat))
|
||||
if (garbage_left(isarray, &scan_length, compat))
|
||||
{
|
||||
ecpg_raise(lineno, ECPG_UINT_FORMAT,
|
||||
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
||||
@ -363,7 +369,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
||||
#ifdef HAVE_STRTOLL
|
||||
case ECPGt_long_long:
|
||||
*((long long int *) (var + offset * act_tuple)) = strtoll(pval, &scan_length, 10);
|
||||
if (garbage_left(isarray, scan_length, compat))
|
||||
if (garbage_left(isarray, &scan_length, compat))
|
||||
{
|
||||
ecpg_raise(lineno, ECPG_INT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
||||
return (false);
|
||||
@ -375,7 +381,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
||||
#ifdef HAVE_STRTOULL
|
||||
case ECPGt_unsigned_long_long:
|
||||
*((unsigned long long int *) (var + offset * act_tuple)) = strtoull(pval, &scan_length, 10);
|
||||
if (garbage_left(isarray, scan_length, compat))
|
||||
if (garbage_left(isarray, &scan_length, compat))
|
||||
{
|
||||
ecpg_raise(lineno, ECPG_UINT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
||||
return (false);
|
||||
@ -397,7 +403,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
||||
if (isarray && *scan_length == '"')
|
||||
scan_length++;
|
||||
|
||||
if (garbage_left(isarray, scan_length, compat))
|
||||
if (garbage_left(isarray, &scan_length, compat))
|
||||
{
|
||||
ecpg_raise(lineno, ECPG_FLOAT_FORMAT,
|
||||
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
||||
@ -595,7 +601,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isarray && garbage_left(isarray, scan_length, compat))
|
||||
if (!isarray && garbage_left(isarray, &scan_length, compat))
|
||||
{
|
||||
free(nres);
|
||||
ecpg_raise(lineno, ECPG_NUMERIC_FORMAT,
|
||||
@ -653,7 +659,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
||||
if (*scan_length == '"')
|
||||
scan_length++;
|
||||
|
||||
if (!isarray && garbage_left(isarray, scan_length, compat))
|
||||
if (!isarray && garbage_left(isarray, &scan_length, compat))
|
||||
{
|
||||
free(ires);
|
||||
ecpg_raise(lineno, ECPG_INTERVAL_FORMAT,
|
||||
@ -703,7 +709,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
||||
if (*scan_length == '"')
|
||||
scan_length++;
|
||||
|
||||
if (!isarray && garbage_left(isarray, scan_length, compat))
|
||||
if (!isarray && garbage_left(isarray, &scan_length, compat))
|
||||
{
|
||||
ecpg_raise(lineno, ECPG_DATE_FORMAT,
|
||||
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
||||
@ -751,7 +757,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
||||
if (*scan_length == '"')
|
||||
scan_length++;
|
||||
|
||||
if (!isarray && garbage_left(isarray, scan_length, compat))
|
||||
if (!isarray && garbage_left(isarray, &scan_length, compat))
|
||||
{
|
||||
ecpg_raise(lineno, ECPG_TIMESTAMP_FORMAT,
|
||||
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
||||
|
Reference in New Issue
Block a user