mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +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:
@ -1,7 +1,7 @@
|
||||
.\" This is -*-nroff-*-
|
||||
.\" XXX standard disclaimer belongs here....
|
||||
.\" $Header: /cvsroot/pgsql/src/man/Attic/libpq.3,v 1.22 1998/07/15 17:34:06 momjian Exp $
|
||||
.TH LIBPQ INTRO 07/08/98 PostgreSQL PostgreSQL
|
||||
.\" $Header: /cvsroot/pgsql/src/man/Attic/libpq.3,v 1.23 1998/08/09 02:59:33 momjian Exp $
|
||||
.TH LIBPQ INTRO 08/08/98 PostgreSQL PostgreSQL
|
||||
.SH DESCRIPTION
|
||||
Libpq is the programmer's interface to Postgres. Libpq is a set of
|
||||
library routines which allows
|
||||
@ -823,6 +823,36 @@ Disable tracing started by
|
||||
.nf
|
||||
void PQuntrace(PGconn *conn)
|
||||
.fi
|
||||
|
||||
.PP
|
||||
.SH "LIBPQ Control Functions"
|
||||
.PP
|
||||
.B PQsetNoticeProcessor
|
||||
.IP
|
||||
Control reporting of notice and warning messages generated by libpq.
|
||||
.nf
|
||||
void PQsetNoticeProcessor (PGconn * conn,
|
||||
void (*noticeProcessor) (void * arg, const char * message),
|
||||
void * arg)
|
||||
.fi
|
||||
By default, libpq prints "notice" messages from the backend on stderr,
|
||||
as well as a few error messages that it generates by itself.
|
||||
This behavior can be overridden by supplying a callback function that
|
||||
does something else with the messages. The callback function is passed
|
||||
the text of the error message (which includes a trailing newline), plus
|
||||
a void pointer that is the same one passed to PQsetNoticeProcessor.
|
||||
(This pointer can be used to access application-specific state if needed.)
|
||||
The default notice processor is simply
|
||||
.nf
|
||||
static void
|
||||
defaultNoticeProcessor(void * arg, const char * message)
|
||||
{
|
||||
fprintf(stderr, "%s", message);
|
||||
}
|
||||
.fi
|
||||
To use a special notice processor, call PQsetNoticeProcessor just after
|
||||
any creation of a new PGconn object.
|
||||
|
||||
.PP
|
||||
.SH "User Authentication Functions"
|
||||
.PP
|
||||
|
Reference in New Issue
Block a user