mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
Share PG_DIAG_* macros between client and server and use them internally.
This commit is contained in:
@ -37,7 +37,7 @@
|
||||
*
|
||||
*
|
||||
* 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 $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1165,7 +1165,7 @@ send_message_to_frontend(ErrorData *edata)
|
||||
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 */
|
||||
@ -1177,11 +1177,11 @@ send_message_to_frontend(ErrorData *edata)
|
||||
}
|
||||
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
|
||||
@ -1189,45 +1189,45 @@ send_message_to_frontend(ErrorData *edata)
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user