summaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorTom Lane2018-10-20 02:22:57 +0000
committerTom Lane2018-10-20 02:22:57 +0000
commit34aad21cbf03fd0d49e7322efdd18c9bf692f53d (patch)
tree9d4fc326168444e193d048bf186c671871b078fc /doc/src
parentcbab94077e126bf32d5fb47695d7a43fe7cb60ac (diff)
Client-side fixes for delayed NOTIFY receipt.
PQnotifies() is defined to just process already-read data, not try to read any more from the socket. (This is a debatable decision, perhaps, but I'm hesitant to change longstanding library behavior.) The documentation has long recommended calling PQconsumeInput() before PQnotifies() to ensure that any already-arrived message would get absorbed and processed. However, psql did not get that memo, which explains why it's not very reliable about reporting notifications promptly. Also, most (not quite all) callers called PQconsumeInput() just once before a PQnotifies() loop. Taking this recommendation seriously implies that we should do PQconsumeInput() before each call. This is more important now that we have "payload" strings in notification messages than it was before; that increases the probability of having more than one packet's worth of notify messages. Hence, adjust code as well as documentation examples to do it like that. Back-patch to 9.5 to match related server fixes. In principle we could probably go back further with these changes, but given lack of field complaints I doubt it's worthwhile. Discussion: https://postgr.es/m/CAOYf6ec-TmRYjKBXLLaGaB-jrd=mjG1Hzn1a1wufUAR39PQYhw@mail.gmail.com
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/libpq.sgml3
1 files changed, 2 insertions, 1 deletions
diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml
index aecd903dbe9..69ae6226998 100644
--- a/doc/src/sgml/libpq.sgml
+++ b/doc/src/sgml/libpq.sgml
@@ -5000,7 +5000,7 @@ typedef struct pgNotify
<para>
<function>PQnotifies</function> does not actually read data from the
server; it just returns messages previously absorbed by another
- <application>libpq</application> function. In prior releases of
+ <application>libpq</application> function. In ancient releases of
<application>libpq</application>, the only way to ensure timely receipt
of <command>NOTIFY</> messages was to constantly submit commands, even
empty ones, and then check <function>PQnotifies</function> after each
@@ -8313,6 +8313,7 @@ main(int argc, char **argv)
notify->relname, notify->be_pid);
PQfreemem(notify);
nnotifies++;
+ PQconsumeInput(conn);
}
}