These are two minor corrections to libpq's PQsetNoticeProcessor function.
authorBruce Momjian <bruce@momjian.us>
Tue, 26 Oct 1999 04:49:00 +0000 (04:49 +0000)
committerBruce Momjian <bruce@momjian.us>
Tue, 26 Oct 1999 04:49:00 +0000 (04:49 +0000)
One, it now returns the previous hook. That way people don't have to dig
around in libpq-int.h for that information anymore. It previously
returned void, so there should be no incompatibilities.

Second, you cannot set the callback to NULL anymore. (Of course you can
still call it with NULL just to get the current hook.) The way libpq uses
the callback pointer, having a NULL there wasn't very healthy.

Peter Eisentraut

src/interfaces/libpq/fe-connect.c
src/interfaces/libpq/libpq-fe.h

index bb61cdfd5bd27e6dcbcd47f502e9673634f3a2f4..a5c42ad8149823f95dd27b00f28c639934e8d685 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.103 1999/09/27 03:13:16 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.104 1999/10/26 04:49:00 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1575,13 +1575,19 @@ PQuntrace(PGconn *conn)
    }
 }
 
-void
+PQnoticeProcessor
 PQsetNoticeProcessor(PGconn *conn, PQnoticeProcessor proc, void *arg)
 {
+   PQnoticeProcessor old;
    if (conn == NULL)
-       return;
+       return NULL;
+
+   old = conn->noticeHook;
+   if (proc) {
    conn->noticeHook = proc;
    conn->noticeArg = arg;
+   }
+   return old;
 }
 
 /*
index acbf539cd784b9df57bcbc2d26a25c869a63d785..9b4cf2894b619eedb834c3b859d5bb17b7214ad7 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: libpq-fe.h,v 1.50 1999/05/25 16:15:13 momjian Exp $
+ * $Id: libpq-fe.h,v 1.51 1999/10/26 04:49:00 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -193,9 +193,7 @@ extern      "C"
    extern void PQuntrace(PGconn *conn);
 
    /* Override default notice processor */
-   extern void PQsetNoticeProcessor(PGconn *conn,
-                                                PQnoticeProcessor proc,
-                                                void *arg);
+   extern PQnoticeProcessor PQsetNoticeProcessor(PGconn *conn, PQnoticeProcessor proc, void *arg);
 
 /* === in fe-exec.c === */