*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.120 2003/08/26 21:15:27 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.121 2003/08/27 00:33:34 petere Exp $
*
*-------------------------------------------------------------------------
*/
int ssval;
int i;
- pq_sendbyte(&msgbuf, 'S');
+ pq_sendbyte(&msgbuf, PG_DIAG_SEVERITY);
pq_sendstring(&msgbuf, error_severity(edata->elevel));
/* unpack MAKE_SQLSTATE code */
}
tbuf[i] = '\0';
- pq_sendbyte(&msgbuf, 'C');
+ pq_sendbyte(&msgbuf, PG_DIAG_SQLSTATE);
pq_sendstring(&msgbuf, tbuf);
/* M field is required per protocol, so always send something */
- pq_sendbyte(&msgbuf, 'M');
+ pq_sendbyte(&msgbuf, PG_DIAG_MESSAGE_PRIMARY);
if (edata->message)
pq_sendstring(&msgbuf, edata->message);
else
if (edata->detail)
{
- pq_sendbyte(&msgbuf, 'D');
+ pq_sendbyte(&msgbuf, PG_DIAG_MESSAGE_DETAIL);
pq_sendstring(&msgbuf, edata->detail);
}
if (edata->hint)
{
- pq_sendbyte(&msgbuf, 'H');
+ pq_sendbyte(&msgbuf, PG_DIAG_MESSAGE_HINT);
pq_sendstring(&msgbuf, edata->hint);
}
if (edata->context)
{
- pq_sendbyte(&msgbuf, 'W');
+ pq_sendbyte(&msgbuf, PG_DIAG_CONTEXT);
pq_sendstring(&msgbuf, edata->context);
}
if (edata->cursorpos > 0)
{
snprintf(tbuf, sizeof(tbuf), "%d", edata->cursorpos);
- pq_sendbyte(&msgbuf, 'P');
+ pq_sendbyte(&msgbuf, PG_DIAG_STATEMENT_POSITION);
pq_sendstring(&msgbuf, tbuf);
}
if (edata->filename)
{
- pq_sendbyte(&msgbuf, 'F');
+ pq_sendbyte(&msgbuf, PG_DIAG_SOURCE_FILE);
pq_sendstring(&msgbuf, edata->filename);
}
if (edata->lineno > 0)
{
snprintf(tbuf, sizeof(tbuf), "%d", edata->lineno);
- pq_sendbyte(&msgbuf, 'L');
+ pq_sendbyte(&msgbuf, PG_DIAG_SOURCE_LINE);
pq_sendstring(&msgbuf, tbuf);
}
if (edata->funcname)
{
- pq_sendbyte(&msgbuf, 'R');
+ pq_sendbyte(&msgbuf, PG_DIAG_SOURCE_FUNCTION);
pq_sendstring(&msgbuf, edata->funcname);
}
* use header files that are otherwise internal to Postgres to interface
* with the backend.
*
- * $Id: postgres_ext.h,v 1.12 2003/03/18 17:21:07 momjian Exp $
+ * $Id: postgres_ext.h,v 1.13 2003/08/27 00:33:34 petere Exp $
*
*-------------------------------------------------------------------------
*/
*/
#define NAMEDATALEN 64
+
+/*
+ * Identifiers of error message fields. Kept here to keep common
+ * between frontend and backend, and also to export them to libpq
+ * applications.
+ */
+#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'
+
#endif
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
/*
* 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? */
/*
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
{
/* 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
{
/* 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);
}
/*
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
* 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 */
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);
}
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: "));
* 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 $
*
*-------------------------------------------------------------------------
*/
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.
*/