aboutsummaryrefslogtreecommitdiff
path: root/src/bin/psql/common.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-02-16 22:34:57 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2010-02-16 22:34:57 +0000
commitd1e027221d0243b7b57eabb0e482923dd7d1c8eb (patch)
tree034988b788248c88fad3b73fb4d8d1afff2dd509 /src/bin/psql/common.c
parentfc5173ad514a216dc93bc190dbba3751024a257d (diff)
downloadpostgresql-d1e027221d0243b7b57eabb0e482923dd7d1c8eb.tar.gz
postgresql-d1e027221d0243b7b57eabb0e482923dd7d1c8eb.zip
Replace the pg_listener-based LISTEN/NOTIFY mechanism with an in-memory queue.
In addition, add support for a "payload" string to be passed along with each notify event. This implementation should be significantly more efficient than the old one, and is also more compatible with Hot Standby usage. There is not yet any facility for HS slaves to receive notifications generated on the master, although such a thing is possible in future. Joachim Wieland, reviewed by Jeff Davis; also hacked on by me.
Diffstat (limited to 'src/bin/psql/common.c')
-rw-r--r--src/bin/psql/common.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c
index 8422bb76ab5..9661f0cd803 100644
--- a/src/bin/psql/common.c
+++ b/src/bin/psql/common.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2010, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.143 2010/01/02 16:57:59 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.144 2010/02/16 22:34:50 tgl Exp $
*/
#include "postgres_fe.h"
#include "common.h"
@@ -555,8 +555,13 @@ PrintNotifications(void)
while ((notify = PQnotifies(pset.db)))
{
- fprintf(pset.queryFout, _("Asynchronous notification \"%s\" received from server process with PID %d.\n"),
- notify->relname, notify->be_pid);
+ /* for backward compatibility, only show payload if nonempty */
+ if (notify->extra[0])
+ fprintf(pset.queryFout, _("Asynchronous notification \"%s\" with payload \"%s\" received from server process with PID %d.\n"),
+ notify->relname, notify->extra, notify->be_pid);
+ else
+ fprintf(pset.queryFout, _("Asynchronous notification \"%s\" received from server process with PID %d.\n"),
+ notify->relname, notify->be_pid);
fflush(pset.queryFout);
PQfreemem(notify);
}