summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPhilip Hazel <ph10@hermes.cam.ac.uk>2006-07-14 14:42:57 +0000
committerPhilip Hazel <ph10@hermes.cam.ac.uk>2006-07-14 14:42:57 +0000
commit034d99ab7d8d4bf671671e583c32cf7dd322c1c2 (patch)
tree2f0aab031eeedf88793fd0adfe36e8d666a34c86 /src
parent35d40a980556bac0460dc027a44fb5285cda3364 (diff)
Add a call to PQsetNoticeProcessor() to catch PostgreSQL "notices" and
thereby stop them being written to stderr (the default).
Diffstat (limited to 'src')
-rw-r--r--src/src/lookups/pgsql.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/src/lookups/pgsql.c b/src/src/lookups/pgsql.c
index 8b777f40b..9c0c647c0 100644
--- a/src/src/lookups/pgsql.c
+++ b/src/src/lookups/pgsql.c
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/lookups/pgsql.c,v 1.6 2006/07/14 14:21:27 ph10 Exp $ */
+/* $Cambridge: exim/src/src/lookups/pgsql.c,v 1.7 2006/07/14 14:42:57 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -76,6 +76,28 @@ while ((cn = pgsql_connections) != NULL)
}
+/*************************************************
+* Notice processor function for pgsql *
+*************************************************/
+
+/* This function is passed to pgsql below, and called for any PostgreSQL
+"notices". By default they are written to stderr, which is undesirable.
+
+Arguments:
+ arg an opaque user cookie (not used)
+ message the notice
+
+Returns: nothing
+*/
+
+static void
+notice_processor(void *arg, const char *message)
+{
+arg = arg; /* Keep compiler happy */
+DEBUG(D_lookup) debug_printf("PGSQL: %s\n", message);
+}
+
+
/*************************************************
* Internal search function *
@@ -253,6 +275,12 @@ if (cn == NULL)
PQsetClientEncoding(pg_conn, "SQL_ASCII");
+ /* Set the notice processor to prevent notices from being written to stderr
+ (which is what the default does). Our function (above) just produces debug
+ output. */
+
+ PQsetNoticeProcessor(pg_conn, notice_processor, NULL);
+
/* Add the connection to the cache */
cn = store_get(sizeof(pgsql_connection));