mirror of
https://github.com/postgres/postgres.git
synced 2025-07-18 17:42:25 +03:00
Fixed array handling in ecpg.
When ecpg was rewritten to the new protocol version not all variable types were corrected. This patch rewrites the code for these types to fix that. It also fixes the documentation to correctly tell the status of array handling. Conflicts: doc/src/sgml/ecpg.sgml
This commit is contained in:
@ -291,6 +291,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
||||
date ddres;
|
||||
timestamp tres;
|
||||
interval *ires;
|
||||
char *endptr, endchar;
|
||||
|
||||
case ECPGt_short:
|
||||
case ECPGt_int:
|
||||
@ -564,10 +565,11 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
||||
|
||||
case ECPGt_decimal:
|
||||
case ECPGt_numeric:
|
||||
if (isarray && *pval == '"')
|
||||
nres = PGTYPESnumeric_from_asc(pval + 1, &scan_length);
|
||||
else
|
||||
nres = PGTYPESnumeric_from_asc(pval, &scan_length);
|
||||
for (endptr = pval; *endptr && *endptr != ',' && *endptr != '}'; endptr++);
|
||||
endchar = *endptr;
|
||||
*endptr = '\0';
|
||||
nres = PGTYPESnumeric_from_asc(pval, &scan_length);
|
||||
*endptr = endchar;
|
||||
|
||||
/* did we get an error? */
|
||||
if (nres == NULL)
|
||||
@ -600,10 +602,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isarray && *scan_length == '"')
|
||||
scan_length++;
|
||||
|
||||
if (garbage_left(isarray, scan_length, compat))
|
||||
if (!isarray && garbage_left(isarray, scan_length, compat))
|
||||
{
|
||||
free(nres);
|
||||
ecpg_raise(lineno, ECPG_NUMERIC_FORMAT,
|
||||
@ -622,10 +621,14 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
||||
break;
|
||||
|
||||
case ECPGt_interval:
|
||||
if (isarray && *pval == '"')
|
||||
ires = PGTYPESinterval_from_asc(pval + 1, &scan_length);
|
||||
else
|
||||
ires = PGTYPESinterval_from_asc(pval, &scan_length);
|
||||
if (*pval == '"')
|
||||
pval++;
|
||||
|
||||
for (endptr = pval; *endptr && *endptr != ',' && *endptr != '"' && *endptr != '}'; endptr++);
|
||||
endchar = *endptr;
|
||||
*endptr = '\0';
|
||||
ires = PGTYPESinterval_from_asc(pval, &scan_length);
|
||||
*endptr = endchar;
|
||||
|
||||
/* did we get an error? */
|
||||
if (ires == NULL)
|
||||
@ -654,10 +657,10 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isarray && *scan_length == '"')
|
||||
if (*scan_length == '"')
|
||||
scan_length++;
|
||||
|
||||
if (garbage_left(isarray, scan_length, compat))
|
||||
if (!isarray && garbage_left(isarray, scan_length, compat))
|
||||
{
|
||||
free(ires);
|
||||
ecpg_raise(lineno, ECPG_INTERVAL_FORMAT,
|
||||
@ -672,10 +675,14 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
||||
break;
|
||||
|
||||
case ECPGt_date:
|
||||
if (isarray && *pval == '"')
|
||||
ddres = PGTYPESdate_from_asc(pval + 1, &scan_length);
|
||||
else
|
||||
ddres = PGTYPESdate_from_asc(pval, &scan_length);
|
||||
if (*pval == '"')
|
||||
pval++;
|
||||
|
||||
for (endptr = pval; *endptr && *endptr != ',' && *endptr != '"' && *endptr != '}'; endptr++);
|
||||
endchar = *endptr;
|
||||
*endptr = '\0';
|
||||
ddres = PGTYPESdate_from_asc(pval, &scan_length);
|
||||
*endptr = endchar;
|
||||
|
||||
/* did we get an error? */
|
||||
if (errno != 0)
|
||||
@ -700,10 +707,10 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isarray && *scan_length == '"')
|
||||
if (*scan_length == '"')
|
||||
scan_length++;
|
||||
|
||||
if (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);
|
||||
@ -716,10 +723,14 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
||||
break;
|
||||
|
||||
case ECPGt_timestamp:
|
||||
if (isarray && *pval == '"')
|
||||
tres = PGTYPEStimestamp_from_asc(pval + 1, &scan_length);
|
||||
else
|
||||
tres = PGTYPEStimestamp_from_asc(pval, &scan_length);
|
||||
if (*pval == '"')
|
||||
pval++;
|
||||
|
||||
for (endptr = pval; *endptr && *endptr != ',' && *endptr != '"' && *endptr != '}'; endptr++);
|
||||
endchar = *endptr;
|
||||
*endptr = '\0';
|
||||
tres = PGTYPEStimestamp_from_asc(pval, &scan_length);
|
||||
*endptr = endchar;
|
||||
|
||||
/* did we get an error? */
|
||||
if (errno != 0)
|
||||
@ -744,10 +755,10 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isarray && *scan_length == '"')
|
||||
if (*scan_length == '"')
|
||||
scan_length++;
|
||||
|
||||
if (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