diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2003-08-24 18:36:38 +0000 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2003-08-24 18:36:38 +0000 |
commit | c3664c0c007931102727a016208ca604123622e0 (patch) | |
tree | bd43245bc6a2ddc39c1caf66e07af2b2efb8d5a2 /src/interfaces | |
parent | b4ab39ff05ae1489e97ec9e844ad63c20cc7e044 (diff) | |
download | postgresql-c3664c0c007931102727a016208ca604123622e0.tar.gz postgresql-c3664c0c007931102727a016208ca604123622e0.zip |
Add macros for error result fields to libpq.
Diffstat (limited to 'src/interfaces')
-rw-r--r-- | src/interfaces/ecpg/ecpglib/connect.c | 6 | ||||
-rw-r--r-- | src/interfaces/ecpg/ecpglib/error.c | 6 | ||||
-rw-r--r-- | src/interfaces/libpq/libpq-fe.h | 14 |
3 files changed, 19 insertions, 7 deletions
diff --git a/src/interfaces/ecpg/ecpglib/connect.c b/src/interfaces/ecpg/ecpglib/connect.c index 6574216a606..4b7683633bd 100644 --- a/src/interfaces/ecpg/ecpglib/connect.c +++ b/src/interfaces/ecpg/ecpglib/connect.c @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.16 2003/08/08 13:16:20 petere Exp $ */ +/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.17 2003/08/24 18:36:38 petere Exp $ */ #define POSTGRES_ECPG_INTERNAL #include "postgres_fe.h" @@ -158,8 +158,8 @@ ECPGsetconn(int lineno, const char *connection_name) static void ECPGnoticeReceiver(void *arg, const PGresult *result) { - char *sqlstate = PQresultErrorField(result, 'C'); - char *message = PQresultErrorField(result, 'M'); + char *sqlstate = PQresultErrorField(result, PG_DIAG_SQLSTATE); + char *message = PQresultErrorField(result, PG_DIAG_MESSAGE_PRIMARY); struct sqlca_t *sqlca = ECPGget_sqlca(); int sqlcode; diff --git a/src/interfaces/ecpg/ecpglib/error.c b/src/interfaces/ecpg/ecpglib/error.c index 82f2ccca366..48b879d5462 100644 --- a/src/interfaces/ecpg/ecpglib/error.c +++ b/src/interfaces/ecpg/ecpglib/error.c @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.7 2003/08/08 13:16:20 petere Exp $ */ +/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.8 2003/08/24 18:36:38 petere Exp $ */ #define POSTGRES_ECPG_INTERNAL #include "postgres_fe.h" @@ -164,10 +164,10 @@ ECPGraise_backend(int line, PGresult *result, PGconn *conn, int compat) if (result) { - sqlstate = PQresultErrorField(result, 'C'); + sqlstate = PQresultErrorField(result, PG_DIAG_SQLSTATE); if (sqlstate == NULL) sqlstate = ECPG_SQLSTATE_ECPG_INTERNAL_ERROR; - message = PQresultErrorField(result, 'M'); + message = PQresultErrorField(result, PG_DIAG_MESSAGE_PRIMARY); } else { diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h index 6843bb7e981..3e068cc6dc9 100644 --- a/src/interfaces/libpq/libpq-fe.h +++ b/src/interfaces/libpq/libpq-fe.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: libpq-fe.h,v 1.98 2003/08/13 16:29:03 tgl Exp $ + * $Id: libpq-fe.h,v 1.99 2003/08/24 18:36:38 petere Exp $ * *------------------------------------------------------------------------- */ @@ -104,6 +104,18 @@ typedef enum PQERRORS_VERBOSE /* all the facts, ma'am */ } PGVerbosity; +/* for PQresultErrorField() */ +#define PG_DIAG_SEVERITY 'S' +#define PG_DIAG_SQLSTATE 'C' +#define PG_DIAG_MESSAGE_PRIMARY 'M' +#define PG_DIAG_MESSAGE_DETAIL 'D' +#define PG_DIAG_MESSAGE_HINT 'H' +#define PG_DIAG_STATEMENT_POSITION 'P' +#define PG_DIAG_CONTEXT 'W' +#define PG_DIAG_SOURCE_FILE 'F' +#define PG_DIAG_SOURCE_LINE 'L' +#define PG_DIAG_SOURCE_FUNCTION 'R' + /* PGconn encapsulates a connection to the backend. * The contents of this struct are not supposed to be known to applications. */ |