Re: Cheapest way to poll for notifications? & Driver improvement question re SSL and notify - Mailing list pgsql-jdbc

From Craig Ringer
Subject Re: Cheapest way to poll for notifications? & Driver improvement question re SSL and notify
Date
Msg-id 4B2ED137.50501@postnewspapers.com.au
Whole thread Raw
In response to Cheapest way to poll for notifications? & Driver improvement question re SSL and notify  (Craig Ringer <craig@postnewspapers.com.au>)
List pgsql-jdbc
Maciek Sakrejda wrote:

> Does the jdbc driver work with EmptyQueryResponse? At the protocol
> level, if you send a Query message with an all-whitespace sql string,
> the backend is supposed to reply with a single EmptyQueryResponse
> message and then issue ReadyForQuery again. I have a feeling that jdbc
> is probably "too smart" for this to work, but it could be worth a
> shot.

Even if the JDBC driver avoids sending such a query, it'd be a handy
behavior to use if explicit polling was implemented in the driver
interface. Send an empty Query message, read() from the buffer now that
you know there's something in it (the server's empty query response) and
see if there are any async notifications in the buffer before the empty
query response.

Thanks for the tip. If the JDBC folks ever stick their heads up here to
comment on any of this or to respond to the docs patches I've sent them
I'll see if they'd accept a patch for this and put one together if so.
It wouldn't be as efficient as purely client-side polling as it'd
require a network round trip, but it'd be a whole lot simpler and would
avoid spamming the db logs.

--
Craig Ringer

pgsql-jdbc by date:

Previous
From: Alexander Pyhalov
Date:
Subject: Re: Get bytes sent to client
Next
From: Maciek Sakrejda
Date:
Subject: Re: Cheapest way to poll for notifications? & Driver improvement question re SSL and notify