On Mon, Feb 24, 2003 at 12:36:56PM -0500, Tom Lane wrote:
> Not without help from the backend --- you have no idea whether a LISTEN
> command might have been executed via some user-defined function.
True. Hadn't thought of that. The backend does identify a direct
LISTEN to the frontend through PQcmdStatus(), but it doesn't say
anything about what happens in functions and such. And similar for
transactions, I guess.
> Again, it's not all that easy to be sure if you're inside a transaction
> or not. We looked at this and decided it was impractical to do without
> a protocol addition.
I don't think I followed that discussion to its conclusion at the time,
but it left me with the impression that such an addition was being
considered.
However I just took a look at the docs for readline and apparently it
was designed with select() in mind. So it should be possible to
implement this without any cost to scalability: the server doesn't
care if the frontend is listening when it sends out the notification,
and the frontend can sleep until either a notification or a keypress
arrives.
Or am I missing something basic here?
Jeroen