summaryrefslogtreecommitdiff
path: root/src/interfaces
diff options
context:
space:
mode:
authorPeter Eisentraut2003-08-27 00:33:34 +0000
committerPeter Eisentraut2003-08-27 00:33:34 +0000
commitf2c2943aae143cd6cfa6e3195658e7e15de16000 (patch)
treed49186f1c40aaae6f22890099532a0e9f49587cc /src/interfaces
parent73e3edf2e64925a5a012c4155ab453a7a864895a (diff)
Share PG_DIAG_* macros between client and server and use them internally.
Diffstat (limited to 'src/interfaces')
-rw-r--r--src/interfaces/libpq/fe-exec.c6
-rw-r--r--src/interfaces/libpq/fe-protocol2.c10
-rw-r--r--src/interfaces/libpq/fe-protocol3.c22
-rw-r--r--src/interfaces/libpq/libpq-fe.h14
4 files changed, 20 insertions, 32 deletions
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c
index 3e652766813..f9ce9564a7c 100644
--- a/src/interfaces/libpq/fe-exec.c
+++ b/src/interfaces/libpq/fe-exec.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.145 2003/08/13 18:56:21 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.146 2003/08/27 00:33:34 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -480,8 +480,8 @@ pqInternalNotice(const PGNoticeHooks * hooks, const char *fmt,...)
/*
* Set up fields of notice.
*/
- pqSaveMessageField(res, 'M', msgBuf);
- pqSaveMessageField(res, 'S', libpq_gettext("NOTICE"));
+ pqSaveMessageField(res, PG_DIAG_MESSAGE_PRIMARY, msgBuf);
+ pqSaveMessageField(res, PG_DIAG_SEVERITY, libpq_gettext("NOTICE"));
/* XXX should provide a SQLSTATE too? */
/*
diff --git a/src/interfaces/libpq/fe-protocol2.c b/src/interfaces/libpq/fe-protocol2.c
index 834aa69bbf4..1b766996910 100644
--- a/src/interfaces/libpq/fe-protocol2.c
+++ b/src/interfaces/libpq/fe-protocol2.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-protocol2.c,v 1.6 2003/08/04 02:40:20 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-protocol2.c,v 1.7 2003/08/27 00:33:34 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -828,7 +828,7 @@ pqGetErrorNotice2(PGconn *conn, bool isError)
{
/* what comes before the colon is severity */
*splitp = '\0';
- pqSaveMessageField(res, 'S', workBuf.data);
+ pqSaveMessageField(res, PG_DIAG_SEVERITY, workBuf.data);
startp = splitp + 3;
}
else
@@ -841,16 +841,16 @@ pqGetErrorNotice2(PGconn *conn, bool isError)
{
/* what comes before the newline is primary message */
*splitp++ = '\0';
- pqSaveMessageField(res, 'M', startp);
+ pqSaveMessageField(res, PG_DIAG_MESSAGE_PRIMARY, startp);
/* the rest is detail; strip any leading whitespace */
while (*splitp && isspace((unsigned char) *splitp))
splitp++;
- pqSaveMessageField(res, 'D', splitp);
+ pqSaveMessageField(res, PG_DIAG_MESSAGE_DETAIL, splitp);
}
else
{
/* single-line message, so all primary */
- pqSaveMessageField(res, 'M', startp);
+ pqSaveMessageField(res, PG_DIAG_MESSAGE_PRIMARY, startp);
}
/*
diff --git a/src/interfaces/libpq/fe-protocol3.c b/src/interfaces/libpq/fe-protocol3.c
index 0591d63da98..ba06a37848f 100644
--- a/src/interfaces/libpq/fe-protocol3.c
+++ b/src/interfaces/libpq/fe-protocol3.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-protocol3.c,v 1.8 2003/08/13 18:56:21 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-protocol3.c,v 1.9 2003/08/27 00:33:34 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -614,19 +614,19 @@ pqGetErrorNotice3(PGconn *conn, bool isError)
* Now build the "overall" error message for PQresultErrorMessage.
*/
resetPQExpBuffer(&workBuf);
- val = PQresultErrorField(res, 'S'); /* Severity */
+ val = PQresultErrorField(res, PG_DIAG_SEVERITY);
if (val)
appendPQExpBuffer(&workBuf, "%s: ", val);
if (conn->verbosity == PQERRORS_VERBOSE)
{
- val = PQresultErrorField(res, 'C'); /* SQLSTATE Code */
+ val = PQresultErrorField(res, PG_DIAG_SQLSTATE);
if (val)
appendPQExpBuffer(&workBuf, "%s: ", val);
}
- val = PQresultErrorField(res, 'M'); /* Primary message */
+ val = PQresultErrorField(res, PG_DIAG_MESSAGE_PRIMARY);
if (val)
appendPQExpBufferStr(&workBuf, val);
- val = PQresultErrorField(res, 'P'); /* Position */
+ val = PQresultErrorField(res, PG_DIAG_STATEMENT_POSITION);
if (val)
{
/* translator: %s represents a digit string */
@@ -635,13 +635,13 @@ pqGetErrorNotice3(PGconn *conn, bool isError)
appendPQExpBufferChar(&workBuf, '\n');
if (conn->verbosity != PQERRORS_TERSE)
{
- val = PQresultErrorField(res, 'D'); /* Detail */
+ val = PQresultErrorField(res, PG_DIAG_MESSAGE_DETAIL);
if (val)
appendPQExpBuffer(&workBuf, libpq_gettext("DETAIL: %s\n"), val);
- val = PQresultErrorField(res, 'H'); /* Hint */
+ val = PQresultErrorField(res, PG_DIAG_MESSAGE_HINT);
if (val)
appendPQExpBuffer(&workBuf, libpq_gettext("HINT: %s\n"), val);
- val = PQresultErrorField(res, 'W'); /* Where */
+ val = PQresultErrorField(res, PG_DIAG_CONTEXT);
if (val)
appendPQExpBuffer(&workBuf, libpq_gettext("CONTEXT: %s\n"), val);
}
@@ -650,9 +650,9 @@ pqGetErrorNotice3(PGconn *conn, bool isError)
const char *valf;
const char *vall;
- valf = PQresultErrorField(res, 'F'); /* File */
- vall = PQresultErrorField(res, 'L'); /* Line */
- val = PQresultErrorField(res, 'R'); /* Routine */
+ valf = PQresultErrorField(res, PG_DIAG_SOURCE_FILE);
+ vall = PQresultErrorField(res, PG_DIAG_SOURCE_LINE);
+ val = PQresultErrorField(res, PG_DIAG_SOURCE_FUNCTION);
if (val || valf || vall)
{
appendPQExpBufferStr(&workBuf, libpq_gettext("LOCATION: "));
diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h
index 3e068cc6dc9..bafe0ddd6c9 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.99 2003/08/24 18:36:38 petere Exp $
+ * $Id: libpq-fe.h,v 1.100 2003/08/27 00:33:34 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -104,18 +104,6 @@ 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.
*/