mirror of
https://github.com/postgres/postgres.git
synced 2025-04-27 22:56:53 +03:00
Started to create different error codes for different backend messages.
This commit is contained in:
parent
9117e55493
commit
42df5e311f
@ -1569,6 +1569,16 @@ Wed Jul 9 11:45:02 CEST 2003
|
|||||||
- Made all Informix functions honor Informix NULLs.
|
- Made all Informix functions honor Informix NULLs.
|
||||||
- Extended compatibility functions for INFORMIX handling of DECLARE
|
- Extended compatibility functions for INFORMIX handling of DECLARE
|
||||||
statement to work with indicators.
|
statement to work with indicators.
|
||||||
|
|
||||||
|
Mon Jul 14 09:34:04 CEST 2003
|
||||||
|
|
||||||
|
- Synced preproc.y with gram.y
|
||||||
|
- Init sqlca in ECPGprepare().
|
||||||
|
- Added CLOSE DATABASE for Informix compatibility.
|
||||||
|
|
||||||
|
Tue Jul 15 14:28:53 CEST 2003
|
||||||
|
|
||||||
|
_ Started to add error codes for backend error messages.
|
||||||
- Set ecpg version to 3.0.0
|
- Set ecpg version to 3.0.0
|
||||||
- Set ecpg library to 4.0.0
|
- Set ecpg library to 4.0.0
|
||||||
- Set pgtypes library to 1.0.0
|
- Set pgtypes library to 1.0.0
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.11 2003/07/08 07:13:48 meskes Exp $ */
|
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.12 2003/07/15 12:38:38 meskes Exp $ */
|
||||||
|
|
||||||
#define POSTGRES_ECPG_INTERNAL
|
#define POSTGRES_ECPG_INTERNAL
|
||||||
#include "postgres_fe.h"
|
#include "postgres_fe.h"
|
||||||
@ -68,7 +68,6 @@ ecpg_finish(struct connection * act)
|
|||||||
struct ECPGtype_information_cache *cache,
|
struct ECPGtype_information_cache *cache,
|
||||||
*ptr;
|
*ptr;
|
||||||
|
|
||||||
ECPGlog("ecpg_finish: finishing %s.\n", act->name);
|
|
||||||
PQfinish(act->connection);
|
PQfinish(act->connection);
|
||||||
|
|
||||||
/* no need to lock connections_mutex - we're always called
|
/* no need to lock connections_mutex - we're always called
|
||||||
@ -90,6 +89,8 @@ ecpg_finish(struct connection * act)
|
|||||||
if (actual_connection == act)
|
if (actual_connection == act)
|
||||||
actual_connection = all_connections;
|
actual_connection = all_connections;
|
||||||
|
|
||||||
|
ECPGlog("ecpg_finish: Connection %s closed.\n", act->name);
|
||||||
|
|
||||||
for (cache = act->cache_head; cache; ptr = cache, cache = cache->next, ECPGfree(ptr));
|
for (cache = act->cache_head; cache; ptr = cache, cache = cache->next, ECPGfree(ptr));
|
||||||
ECPGfree(act->name);
|
ECPGfree(act->name);
|
||||||
ECPGfree(act);
|
ECPGfree(act);
|
||||||
@ -481,10 +482,9 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
|
|||||||
|
|
||||||
if (PQstatus(this->connection) == CONNECTION_BAD)
|
if (PQstatus(this->connection) == CONNECTION_BAD)
|
||||||
{
|
{
|
||||||
const char *errmsg = PQerrorMessage(this->connection);
|
const char *errmsg = PQerrorMessage(this->connection);
|
||||||
char *db = realname ? realname : "<DEFAULT>";
|
char *db = realname ? realname : "<DEFAULT>";
|
||||||
|
|
||||||
set_backend_err(errmsg, lineno);
|
|
||||||
ecpg_finish(this);
|
ecpg_finish(this);
|
||||||
#ifdef USE_THREADS
|
#ifdef USE_THREADS
|
||||||
pthread_mutex_unlock(&connections_mutex);
|
pthread_mutex_unlock(&connections_mutex);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.2 2003/06/15 04:07:58 momjian Exp $ */
|
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.3 2003/07/15 12:38:38 meskes Exp $ */
|
||||||
|
|
||||||
#define POSTGRES_ECPG_INTERNAL
|
#define POSTGRES_ECPG_INTERNAL
|
||||||
#include "postgres_fe.h"
|
#include "postgres_fe.h"
|
||||||
@ -11,10 +11,6 @@
|
|||||||
#include "extern.h"
|
#include "extern.h"
|
||||||
#include "sqlca.h"
|
#include "sqlca.h"
|
||||||
|
|
||||||
/* This should hold the back-end error message from
|
|
||||||
* the last back-end operation. */
|
|
||||||
static char *ECPGerr;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ECPGraise(int line, int code, const char *str)
|
ECPGraise(int line, int code, const char *str)
|
||||||
{
|
{
|
||||||
@ -142,6 +138,11 @@ ECPGraise(int line, int code, const char *str)
|
|||||||
slen--;
|
slen--;
|
||||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
|
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
|
||||||
"'%.*s' in line %d.", slen, str, line);
|
"'%.*s' in line %d.", slen, str, line);
|
||||||
|
if (strncmp(str, "ERROR: Cannot insert a duplicate key", strlen("ERROR: Cannot insert a duplicate key")) == 0)
|
||||||
|
sqlca->sqlcode = ECPG_DUPLICATE_KEY;
|
||||||
|
else if (strncmp(str, "ERROR: More than one tuple returned by a subselect", strlen("ERROR: More than one tuple returned by a subselect")) == 0)
|
||||||
|
sqlca->sqlcode = ECPG_SUBSELECT_NOT_ONE;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,29 +169,6 @@ ECPGraise(int line, int code, const char *str)
|
|||||||
ECPGfree_auto_mem();
|
ECPGfree_auto_mem();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the error message string from the backend */
|
|
||||||
void
|
|
||||||
set_backend_err(const char *err, int lineno)
|
|
||||||
{
|
|
||||||
if (ECPGerr)
|
|
||||||
ECPGfree(ECPGerr);
|
|
||||||
|
|
||||||
if (!err)
|
|
||||||
{
|
|
||||||
ECPGerr = NULL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ECPGerr = ECPGstrdup(err, lineno);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Retrieve the error message from the backend. */
|
|
||||||
char *
|
|
||||||
ECPGerrmsg(void)
|
|
||||||
{
|
|
||||||
return ECPGerr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* print out an error message */
|
/* print out an error message */
|
||||||
void
|
void
|
||||||
sqlprint(void)
|
sqlprint(void)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.18 2003/07/08 12:11:29 meskes Exp $ */
|
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.19 2003/07/15 12:38:38 meskes Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The aim is to get a simpler inteface to the database routines.
|
* The aim is to get a simpler inteface to the database routines.
|
||||||
@ -1131,7 +1131,6 @@ ECPGexecute(struct statement * stmt)
|
|||||||
errmsg = PQerrorMessage(stmt->connection->connection);
|
errmsg = PQerrorMessage(stmt->connection->connection);
|
||||||
ECPGlog("ECPGexecute line %d: error: %s", stmt->lineno, errmsg);
|
ECPGlog("ECPGexecute line %d: error: %s", stmt->lineno, errmsg);
|
||||||
ECPGraise(stmt->lineno, ECPG_PGSQL, errmsg);
|
ECPGraise(stmt->lineno, ECPG_PGSQL, errmsg);
|
||||||
set_backend_err(errmsg, stmt->lineno);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
||||||
@ -1144,7 +1143,6 @@ ECPGexecute(struct statement * stmt)
|
|||||||
struct sqlca_t *sqlca = ECPGget_sqlca();
|
struct sqlca_t *sqlca = ECPGget_sqlca();
|
||||||
|
|
||||||
errmsg = PQresultErrorMessage(results);
|
errmsg = PQresultErrorMessage(results);
|
||||||
set_backend_err(errmsg, stmt->lineno);
|
|
||||||
|
|
||||||
var = stmt->outlist;
|
var = stmt->outlist;
|
||||||
switch (PQresultStatus(results))
|
switch (PQresultStatus(results))
|
||||||
|
@ -10,13 +10,6 @@ enum COMPAT_MODE { ECPG_COMPAT_PGSQL = 0, ECPG_COMPAT_INFORMIX, ECPG_COMPAT_INFO
|
|||||||
|
|
||||||
/* Here are some methods used by the lib. */
|
/* Here are some methods used by the lib. */
|
||||||
|
|
||||||
/* Stores the backend error message for client access */
|
|
||||||
void set_backend_err(const char *err, int lineon);
|
|
||||||
|
|
||||||
/* Store and retrieve the backend error message for client access */
|
|
||||||
void set_backend_err(const char *err, int lineon);
|
|
||||||
char *ECPGerrmsg(void);
|
|
||||||
|
|
||||||
/* Returns a pointer to a string containing a simple type name. */
|
/* Returns a pointer to a string containing a simple type name. */
|
||||||
void ECPGadd_mem(void *ptr, int lineno);
|
void ECPGadd_mem(void *ptr, int lineno);
|
||||||
|
|
||||||
|
@ -47,6 +47,8 @@
|
|||||||
#define ECPG_PGSQL -400
|
#define ECPG_PGSQL -400
|
||||||
#define ECPG_TRANS -401
|
#define ECPG_TRANS -401
|
||||||
#define ECPG_CONNECT -402
|
#define ECPG_CONNECT -402
|
||||||
|
#define ECPG_DUPLICATE_KEY -403
|
||||||
|
#define ECPG_SUBSELECT_NOT_ONE -404
|
||||||
|
|
||||||
/* backend WARNINGs, starting at 600 */
|
/* backend WARNINGs, starting at 600 */
|
||||||
#define ECPG_WARNING_UNRECOGNIZED -600
|
#define ECPG_WARNING_UNRECOGNIZED -600
|
||||||
|
@ -17,8 +17,18 @@ int main()
|
|||||||
|
|
||||||
rsetnull(CDECIMALTYPE, (char *)&j);
|
rsetnull(CDECIMALTYPE, (char *)&j);
|
||||||
$insert into test (i, j) values (7, :j);
|
$insert into test (i, j) values (7, :j);
|
||||||
|
$commit;
|
||||||
|
|
||||||
|
$insert into test (i, j) values (7, 2);
|
||||||
|
printf("%ld: %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
|
||||||
|
if (sqlca.sqlcode != 0) $rollback;
|
||||||
|
|
||||||
$insert into test (i, j) values (:i, 1);
|
$insert into test (i, j) values (:i, 1);
|
||||||
|
|
||||||
|
$select i from test where j=(select j from test);
|
||||||
|
printf("%ld: %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
|
||||||
|
if (sqlca.sqlcode != 0) $rollback;
|
||||||
|
|
||||||
$declare c cursor for select * from test where i <= :i;
|
$declare c cursor for select * from test where i <= :i;
|
||||||
openit();
|
openit();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user