postgres-nio icon indicating copy to clipboard operation
postgres-nio copied to clipboard

Connection metadata

Open tanner0101 opened this issue 7 years ago • 4 comments

Currently, the FluentPostgreSQL integration needs to check PSQL version during boot time. This happens here.

This check requires a known, static database identifier to create a new connection. This makes supporting multiple Postgres databases with possibly different versions difficult / impossible.

Ideally this package would provide a better way to check active Postgres version. I believe this is sent during startup, so it could be stored and accessed on individual connections without the need for any extra queries.

tanner0101 avatar Oct 29 '18 18:10 tanner0101

in the fluent-postgresql PR that line is updated to use the custom identifier

gperdomor avatar Oct 29 '18 18:10 gperdomor

@gperdomor the problem with that is it's still limited to at max one Postgres database. This package ostensibly supports working with multiple DBs with potentially different versions of Postgres running. We need a solution that solves both of these problems.

tanner0101 avatar Oct 31 '18 20:10 tanner0101

I use two database with this solution soñé time ago, but in that case was the same postgres version (postgres:10-alpine)

gperdomor avatar Oct 31 '18 22:10 gperdomor

Upon further investigation, it appears that the connection status returned by Postgres does indeed contain the server version:

["IntervalStyle": "postgres", "application_name": "", "DateStyle": "ISO, MDY", "is_superuser": "on", "standard_conforming_strings": "on", "server_encoding": "UTF8", "integer_datetimes": "on", "session_authorization": "vapor_username", "client_encoding": "UTF8", "server_version": "10.5 (Debian 10.5-2.pgdg90+1)", "TimeZone": "UTC"]

Grabbing this value from the connection directly instead of using a global seems like the right approach going forward.

tanner0101 avatar Oct 31 '18 22:10 tanner0101