1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-29 10:41:53 +03:00

The attached patch implements some changes that were discussed a

couple weeks ago on the hackers and interfaces lists:

1. When the backend sends a NOTICE message and closes the connection
   (typically, because it was told to by the postmaster after
   another backend coredumped), libpq will now print the notice
   and close the connection cleanly.  Formerly, the frontend app
   would usually terminate ungracefully due to a SIGPIPE.  (I am
   not sure if 6.3.2 behaved that way, but the current cvs sources
   do...)

2. libpq's various printouts to stderr are now fed through a single
   "notice processor" routine, which can be overridden by the
   application to direct notices someplace else.  This should ease
   porting libpq to Windows.

I also noticed and fixed a problem in PQprint: when sending output
to a pager subprocess, it would disable SIGPIPE in case the pager
terminates early (this is good) --- but afterwards it reset SIGPIPE
to SIG_DFL, rather than restoring the application's prior setting
(bad).

			regards, tom lane
This commit is contained in:
Bruce Momjian
1998-08-09 02:59:33 +00:00
parent e46df2ff6e
commit e6311b4ad0
7 changed files with 223 additions and 262 deletions

View File

@ -24,7 +24,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.16 1998/07/03 04:24:14 momjian Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.17 1998/08/09 02:59:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -50,6 +50,10 @@
#include "postgres.h"
#include "libpq-fe.h"
#define DONOTICE(conn,message) \
((*(conn)->noticeHook) ((conn)->noticeArg, (message)))
/* --------------------------------------------------------------------- */
/* pqGetc:
get a character from the connection
@ -218,7 +222,9 @@ pqGetInt(int *result, int bytes, PGconn *conn)
*result = (int) ntohl(tmp4);
break;
default:
fprintf(stderr, "** int size %d not supported\n", bytes);
sprintf(conn->errorMessage,
"pqGetInt: int size %d not supported\n", bytes);
DONOTICE(conn, conn->errorMessage);
return EOF;
}
@ -252,7 +258,9 @@ pqPutInt(int value, int bytes, PGconn *conn)
return EOF;
break;
default:
fprintf(stderr, "** int size %d not supported\n", bytes);
sprintf(conn->errorMessage,
"pqPutInt: int size %d not supported\n", bytes);
DONOTICE(conn, conn->errorMessage);
return EOF;
}
@ -265,7 +273,7 @@ pqPutInt(int value, int bytes, PGconn *conn)
/* --------------------------------------------------------------------- */
/* pqReadReady: is select() saying the file is ready to read?
*/
static int
int
pqReadReady(PGconn *conn)
{
fd_set input_mask;