mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +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 */
 | 
					/* returns true if some garbage is found at the end of the scanned string */
 | 
				
			||||||
static bool
 | 
					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
 | 
						 * 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 (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;
 | 
								return false;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (*scan_length != ' ' && *scan_length != '\0')
 | 
							if (**scan_length != ' ' && **scan_length != '\0')
 | 
				
			||||||
			return true;
 | 
								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 true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return false;
 | 
						return false;
 | 
				
			||||||
@@ -304,7 +310,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
 | 
				
			|||||||
				case ECPGt_int:
 | 
									case ECPGt_int:
 | 
				
			||||||
				case ECPGt_long:
 | 
									case ECPGt_long:
 | 
				
			||||||
					res = strtol(pval, &scan_length, 10);
 | 
										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_raise(lineno, ECPG_INT_FORMAT,
 | 
				
			||||||
								   ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
 | 
													   ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
 | 
				
			||||||
@@ -333,7 +339,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
 | 
				
			|||||||
				case ECPGt_unsigned_int:
 | 
									case ECPGt_unsigned_int:
 | 
				
			||||||
				case ECPGt_unsigned_long:
 | 
									case ECPGt_unsigned_long:
 | 
				
			||||||
					ures = strtoul(pval, &scan_length, 10);
 | 
										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_raise(lineno, ECPG_UINT_FORMAT,
 | 
				
			||||||
								   ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
 | 
													   ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
 | 
				
			||||||
@@ -362,7 +368,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
 | 
				
			|||||||
#ifdef HAVE_STRTOLL
 | 
					#ifdef HAVE_STRTOLL
 | 
				
			||||||
				case ECPGt_long_long:
 | 
									case ECPGt_long_long:
 | 
				
			||||||
					*((long long int *) (var + offset * act_tuple)) = strtoll(pval, &scan_length, 10);
 | 
										*((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);
 | 
											ecpg_raise(lineno, ECPG_INT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
 | 
				
			||||||
						return (false);
 | 
											return (false);
 | 
				
			||||||
@@ -374,7 +380,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
 | 
				
			|||||||
#ifdef HAVE_STRTOULL
 | 
					#ifdef HAVE_STRTOULL
 | 
				
			||||||
				case ECPGt_unsigned_long_long:
 | 
									case ECPGt_unsigned_long_long:
 | 
				
			||||||
					*((unsigned long long int *) (var + offset * act_tuple)) = strtoull(pval, &scan_length, 10);
 | 
										*((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);
 | 
											ecpg_raise(lineno, ECPG_UINT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
 | 
				
			||||||
						return (false);
 | 
											return (false);
 | 
				
			||||||
@@ -396,7 +402,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
 | 
				
			|||||||
					if (isarray && *scan_length == '"')
 | 
										if (isarray && *scan_length == '"')
 | 
				
			||||||
						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_raise(lineno, ECPG_FLOAT_FORMAT,
 | 
				
			||||||
								   ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
 | 
													   ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
 | 
				
			||||||
@@ -594,7 +600,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
 | 
				
			|||||||
					}
 | 
										}
 | 
				
			||||||
					else
 | 
										else
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
						if (!isarray && garbage_left(isarray, scan_length, compat))
 | 
											if (!isarray && garbage_left(isarray, &scan_length, compat))
 | 
				
			||||||
						{
 | 
											{
 | 
				
			||||||
							free(nres);
 | 
												free(nres);
 | 
				
			||||||
							ecpg_raise(lineno, ECPG_NUMERIC_FORMAT,
 | 
												ecpg_raise(lineno, ECPG_NUMERIC_FORMAT,
 | 
				
			||||||
@@ -652,7 +658,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
 | 
				
			|||||||
						if (*scan_length == '"')
 | 
											if (*scan_length == '"')
 | 
				
			||||||
							scan_length++;
 | 
												scan_length++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
						if (!isarray && garbage_left(isarray, scan_length, compat))
 | 
											if (!isarray && garbage_left(isarray, &scan_length, compat))
 | 
				
			||||||
						{
 | 
											{
 | 
				
			||||||
							free(ires);
 | 
												free(ires);
 | 
				
			||||||
							ecpg_raise(lineno, ECPG_INTERVAL_FORMAT,
 | 
												ecpg_raise(lineno, ECPG_INTERVAL_FORMAT,
 | 
				
			||||||
@@ -702,7 +708,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
 | 
				
			|||||||
						if (*scan_length == '"')
 | 
											if (*scan_length == '"')
 | 
				
			||||||
							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_raise(lineno, ECPG_DATE_FORMAT,
 | 
				
			||||||
									   ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
 | 
														   ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
 | 
				
			||||||
@@ -750,7 +756,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
 | 
				
			|||||||
						if (*scan_length == '"')
 | 
											if (*scan_length == '"')
 | 
				
			||||||
							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_raise(lineno, ECPG_TIMESTAMP_FORMAT,
 | 
				
			||||||
									   ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
 | 
														   ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user