1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-07 00:36:50 +03:00

Revise backend libpq interfaces so that messages to the frontend

can be generated in a buffer and then sent to the frontend in a single
libpq call.  This solves problems with NOTICE and ERROR messages generated
in the middle of a data message or COPY OUT operation.
This commit is contained in:
Tom Lane
1999-04-25 03:19:27 +00:00
parent fc08814e00
commit 95cc41b81d
18 changed files with 1071 additions and 1028 deletions

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.41 1999/04/20 02:19:54 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.42 1999/04/25 03:19:11 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -188,12 +188,21 @@ elog(int lev, const char *fmt,...)
/* Send IPC message to the front-end program */
if (IsUnderPostmaster && lev > DEBUG)
{
/* notices are not exactly errors, handle it differently */
/* notices are not errors, handle 'em differently */
char msgtype;
if (lev == NOTICE)
pq_putnchar("N", 1);
msgtype = 'N';
else
pq_putnchar("E", 1);
pq_putstr(line + TIMESTAMP_SIZE); /* don't show timestamps */
{
/* Abort any COPY OUT in progress when an error is detected.
* This hack is necessary because of poor design of copy protocol.
*/
pq_endcopyout(true);
msgtype = 'E';
}
/* exclude the timestamp from msg sent to frontend */
pq_putmessage(msgtype, line + TIMESTAMP_SIZE,
strlen(line + TIMESTAMP_SIZE) + 1);
/*
* This flush is normally not necessary, since postgres.c will
* flush out waiting data when control returns to the main loop.