diff options
| author | Michael Meskes <meskes@postgresql.org> | 2003-09-18 13:12:23 +0000 |
|---|---|---|
| committer | Michael Meskes <meskes@postgresql.org> | 2003-09-18 13:12:23 +0000 |
| commit | 723a9bde3335daa32e90bf804241eec8d1dda597 (patch) | |
| tree | 4b5154eabe3be606b693932073c13ff35911f774 /src/interfaces/ecpg/ecpglib | |
| parent | 215d965f0e9b36ed06fe019bd4795782274787c4 (diff) | |
| download | postgresql-723a9bde3335daa32e90bf804241eec8d1dda597.tar.gz | |
- Accept output variables for FETCH in DECLARE statement.
- Synced parser.
- Allowed C variables to carry the name of prepared statements.
- Added Informix handling of datatype converion errors.
Diffstat (limited to 'src/interfaces/ecpg/ecpglib')
| -rw-r--r-- | src/interfaces/ecpg/ecpglib/data.c | 63 | ||||
| -rw-r--r-- | src/interfaces/ecpg/ecpglib/execute.c | 6 |
2 files changed, 65 insertions, 4 deletions
diff --git a/src/interfaces/ecpg/ecpglib/data.c b/src/interfaces/ecpg/ecpglib/data.c index 4bfcb128ba..dfe6e6e6e5 100644 --- a/src/interfaces/ecpg/ecpglib/data.c +++ b/src/interfaces/ecpg/ecpglib/data.c @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.17 2003/09/09 10:46:37 meskes Exp $ */ +/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.18 2003/09/18 13:12:23 meskes Exp $ */ #define POSTGRES_ECPG_INTERNAL #include "postgres_fe.h" @@ -390,6 +390,21 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno, else nres = PGTYPESnumeric_from_asc(pval, &scan_length); + /* did we get an error? */ + if (errno != 0) + { + if (INFORMIX_MODE(compat)) + { + /* Informix wants its own NULL value here instead of an error */ + ECPGset_informix_null(ECPGt_numeric, &nres); + return (true); + } + else + { + ECPGraise(lineno, ECPG_NUMERIC_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval); + return (false); + } + } if (isarray && *scan_length == '"') scan_length++; @@ -417,6 +432,21 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno, else ires = PGTYPESinterval_from_asc(pval, &scan_length); + /* did we get an error? */ + if (errno != 0) + { + if (INFORMIX_MODE(compat)) + { + /* Informix wants its own NULL value here instead of an error */ + ECPGset_informix_null(ECPGt_interval, &ires); + return (true); + } + else + { + ECPGraise(lineno, ECPG_INTERVAL_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval); + return (false); + } + } if (isarray && *scan_length == '"') scan_length++; @@ -440,6 +470,22 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno, else ddres = PGTYPESdate_from_asc(pval, &scan_length); + /* did we get an error? */ + if (errno != 0) + { + if (INFORMIX_MODE(compat)) + { + /* Informix wants its own NULL value here instead of an error */ + ECPGset_informix_null(ECPGt_date, &ddres); + return (true); + } + else + { + ECPGraise(lineno, ECPG_DATE_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval); + return (false); + } + } + if (isarray && *scan_length == '"') scan_length++; @@ -462,6 +508,21 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno, else tres = PGTYPEStimestamp_from_asc(pval, &scan_length); + /* did we get an error? */ + if (errno != 0) + { + if (INFORMIX_MODE(compat)) + { + /* Informix wants its own NULL value here instead of an error */ + ECPGset_informix_null(ECPGt_timestamp, &tres); + return (true); + } + else + { + ECPGraise(lineno, ECPG_TIMESTAMP_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval); + return (false); + } + } if (isarray && *scan_length == '"') scan_length++; diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c index 6a6b4d8e46..9f813f6be8 100644 --- a/src/interfaces/ecpg/ecpglib/execute.c +++ b/src/interfaces/ecpg/ecpglib/execute.c @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.24 2003/09/09 10:46:37 meskes Exp $ */ +/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.25 2003/09/18 13:12:23 meskes Exp $ */ /* * The aim is to get a simpler inteface to the database routines. @@ -857,7 +857,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var, else PGTYPESnumeric_from_decimal((decimal *) ((var + var->offset * element)->value), nval); - str = PGTYPESnumeric_to_asc(nval, 0); + str = PGTYPESnumeric_to_asc(nval, nval->dscale); PGTYPESnumeric_free(nval); slen = strlen(str); @@ -879,7 +879,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var, else PGTYPESnumeric_from_decimal((decimal *) (var->value), nval); - str = PGTYPESnumeric_to_asc(nval, 0); + str = PGTYPESnumeric_to_asc(nval, nval->dscale); PGTYPESnumeric_free(nval); slen = strlen(str); |
