mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +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:
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: libpq-fe.h,v 1.36 1998/07/18 18:34:34 momjian Exp $
|
||||
* $Id: libpq-fe.h,v 1.37 1998/08/09 02:59:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -121,6 +121,9 @@ extern "C"
|
||||
int be_pid; /* process id of backend */
|
||||
} PGnotify;
|
||||
|
||||
/* PQnoticeProcessor is a typedef for a callback function type */
|
||||
typedef void (*PQnoticeProcessor) (void * arg, const char * message);
|
||||
|
||||
/* PGAsyncStatusType is private to libpq, really shouldn't be seen by users */
|
||||
typedef enum
|
||||
{
|
||||
@@ -165,6 +168,10 @@ extern "C"
|
||||
/* Optional file to write trace info to */
|
||||
FILE *Pfdebug;
|
||||
|
||||
/* Callback procedure for notice/error message processing */
|
||||
PQnoticeProcessor noticeHook;
|
||||
void *noticeArg;
|
||||
|
||||
/* Status indicators */
|
||||
ConnStatusType status;
|
||||
PGAsyncStatusType asyncStatus;
|
||||
@@ -300,6 +307,11 @@ extern "C"
|
||||
extern void PQtrace(PGconn *conn, FILE *debug_port);
|
||||
extern void PQuntrace(PGconn *conn);
|
||||
|
||||
/* Override default notice processor */
|
||||
extern void PQsetNoticeProcessor (PGconn *conn,
|
||||
PQnoticeProcessor proc,
|
||||
void *arg);
|
||||
|
||||
/* === in fe-exec.c === */
|
||||
/* Simple synchronous query */
|
||||
extern PGresult *PQexec(PGconn *conn, const char *query);
|
||||
@@ -390,6 +402,7 @@ extern "C"
|
||||
extern int pqGetInt(int *result, int bytes, PGconn *conn);
|
||||
extern int pqPutInt(int value, int bytes, PGconn *conn);
|
||||
extern int pqReadData(PGconn *conn);
|
||||
extern int pqReadReady(PGconn *conn);
|
||||
extern int pqFlush(PGconn *conn);
|
||||
extern int pqWait(int forRead, int forWrite, PGconn *conn);
|
||||
|
||||
|
Reference in New Issue
Block a user