Version mismatch

12 views
Skip to first unread message

Perry Smith

unread,
Mar 20, 2020, 10:58:09 AM3/20/20
to ruby-pg
I am developing an RoR app using containers. I had version 12 PostgreSQL in the server container and the version 11 client library in the Rails container. Nothing complained until I happened to do some commands via psql from the Rails container.

Would it be possible that when the Rails app tries to connect to the server, it does some type of version check and either reject the connection or at least spew out an error message.

Jeremy Evans

unread,
Mar 20, 2020, 12:36:51 PM3/20/20
to ruby-pg
On Friday, March 20, 2020 at 7:58:09 AM UTC-7, Perry Smith wrote:
I am developing an RoR app using containers.  I had version 12 PostgreSQL in the server container and the version 11 client library in the Rails container.  Nothing complained until I happened to do some commands via psql from the Rails container.

Would it be possible that when the Rails app tries to connect to the server, it does some type of version check and either reject the connection or at least spew out an error message.

 In general psql is designed to work with both newer and older versions, though not everything may work perfectly if there is a version mismatch are used.

However, this is unrelated to ruby-pg (psql doesn't use ruby-pg).  You may want to request Rails add this feature, however it would have to be opt-in as it would likely break many environments if it was made the default.

Thanks,
Jeremy

Perry Smith

unread,
Mar 20, 2020, 1:18:37 PM3/20/20
to ruby-pg
Doesn’t psql use the same library, libpq, that ruby-pg uses?  Isn’t that where the real problem is going to be?


Jeremy Evans

unread,
Mar 20, 2020, 2:41:40 PM3/20/20
to ruby-pg
As I mentioned, psql is designed to work with both newer and older versions, though not everything may work perfectly if there is a version mismatch. If you think that is a bug and not a feature, you'll want to file an issue with PostgreSQL (libpq is part of PostgreSQL).

Thanks,
Jeremy

Perry Smith

unread,
Mar 20, 2020, 2:45:50 PM3/20/20
to rub...@googlegroups.com
Lets ignore psql completely.  That’s not my concern at all.

ruby-pg uses libpq — does it not?  What happens if the libpq version that ruby-pg is using mismatches the version of the server it is talking to?

Jeremy Evans

unread,
Mar 20, 2020, 3:34:13 PM3/20/20
to ruby-pg
On Friday, March 20, 2020 at 11:45:50 AM UTC-7, Perry Smith wrote:
ruby-pg uses libpq — does it not?  What happens if the libpq version that ruby-pg is using mismatches the version of the server it is talking to?

The reason psql in general works with both older and newer PostgreSQL versions is because libpq does (psql is implemented using libpq).  In general the PostgreSQL client-server wire protocol that libpq talks does not change between PostgreSQL versions, it's remained compatible since PostgreSQL 7.4. It's fairly routine that you would have a client version different from the server version in more complex environments, and not a problem.

Now, it's possible you are sending a query for one PostgreSQL version (the client version) that doesn't work on an older or newer version of PostgreSQL (the server version) using libpq.  The server may return an error for such queries, just as it would return an error for any query it determines is invalid.  It's the client's responsibility to send the appropriate queries for the server version in use.

Thanks,
Jeremy

Reply all
Reply to author
Forward
0 new messages