On Tue, Jan 5, 2016 at 7:45 PM, Álvaro Hernández Tortosa <aht@8kdata.com> wrote:
There are other parts of the protocol that require a separate connection. Those I don't like either, but it's not unheard of. Maybe the solution is different: that LD may be consumed within the same connection (if that would be possible).
Why not use the existing LISTEN/NOTIFY infrastructure for this? If there were a reserved namespace (ex: pg_% or pg_schema_%) then the existing protocol could be used to listen for schema changes.
There would still need to be backend support for publishing those changes but it'd be backwards compatible in both directions; it wouldn't break existing clients and a modern client that issued a LISTEN for those changes could work with an older backend that doesn't support it (it just won't receive any notifications).
Full support for something like this would require well defined message types to indicate what changed. For an initial version it might be easier to just have a "something changed" message without the specifics of which relations where impacted. A client could invalidate all prepared statements associated with the connection.