Example for notification usage
Is there any example code for pg notification?
See usage in prompt.ml: dump_notification
Thanks, @dboris, yes, prompt.ml and prompt_gtk.ml contain some example code.
I'm sorry to come back this later, I'm afraid the mechanism in the "dump_notifcation" is not the same as the async listen and notify on channel. As stated in https://www.postgresql.org/docs/16/libpq-notify.html , which is basically clients run PQexec(conn, "LISTEN testChannel"), and on the server or other end point you execute the select pg_notify('testChannel', 'Hi there').
PostgreSQL offers asynchronous notification via the LISTEN and NOTIFY commands. A client session registers its interest in a particular notification channel with the LISTEN command (and can stop listening with the UNLISTEN command). All sessions listening on a particular channel will be notified asynchronously when a NOTIFY command with that channel name is executed by any session. A “payload” string can be passed to communicate additional data to the listeners.
Sorry for the late reply. I don't have time to investigate this right now, but please feel free to propose any changes that will make the code consistent with the expected functionality.