Skip to content

Fix the version parsing to support Debian #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

suhaibmujahid
Copy link

The bug already reported and the fix proposed by Marten KARL on Debian bug tracking system (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=890646)

The fix aims to support the customized version string for some Debian postgresql packages. So, the version string 10.3 (Debian 10.3-1.pgdg90+1) will be split by the space to consider only the first part.

The following error raised when I used Debian's postgresql package. This because the customized version string in Debian makes the patch value having an invalid string rather than an integer.

  File "/lib/python3.6/site-packages/postgresql/driver/dbapi20.py", line 409, in connect
    return driver.connect(**params)
  File "/lib/python3.6/site-packages/postgresql/driver/pq3.py", line 3037, in connect
    c.connect()
  File "/lib/python3.6/site-packages/postgresql/driver/dbapi20.py", line 354, in connect
    super().connect(*args, **kw)
  File "/lib/python3.6/site-packages/postgresql/driver/pq3.py", line 2427, in connect
    self._establish()
  File "/lib/python3.6/site-packages/postgresql/driver/pq3.py", line 2559, in _establish
    self.version_info = pg_version.normalize(pg_version.split(sv))
  File "/lib/python3.6/site-packages/postgresql/versionstring.py", line 28, in split
    vlist = [int(x or '0') for x in v[:-1]]
  File "/lib/python3.6/site-packages/postgresql/versionstring.py", line 28, in <listcomp>
    vlist = [int(x or '0') for x in v[:-1]]
ValueError: invalid literal for int() with base 10: '3 (Debian 10'

By excluding the extra part form the version string, the package works fine.

The fix aimed to support the customized version string for some Debian postgresql packages. So, the version string `10.3 (Debian 10.3-1.pgdg90+1)` will be split by the space to consider only the first part.
@ThomasChr
Copy link

Note: This happens also on Ubuntu.

@jwp
Copy link
Contributor

jwp commented Jun 7, 2018

I'd recommend keeping this at the debian/ubuntu packaging level. The patch itself is a reasonable solution, but I'm disinclined to commit in fear of running into other packaging systems that wish to make the field inconsistent with what postgresql.org defines.

The versionstring module is unlikely to change unless postgresql.org changes their versioning strategy, so there should be little concern about having to update the patch in the future.

@jwp jwp closed this Jun 7, 2018
@greatvovan
Copy link

greatvovan commented Oct 16, 2018

@jwp

The patch itself is a reasonable solution, but I'm disinclined to commit in fear of running into other packaging systems.

This is like waiting until the world adjusts for you rather than doing vice versa.

  1. Any Postgres on Debian (and ancestors) now returns additional data in parenthesis.
  2. Official Docker images of Postgres return additional data in parenthesis.

Your library basically cannot be used with recent versions of Postgres.

wish to make the field inconsistent with what postgresql.org defines.

Could you provide a link where the strict version format (as returned by pg_settings) is described?

@suhaibmujahid suhaibmujahid changed the title Fx the version parsing to support Debian Fix the version parsing to support Debian Oct 16, 2018
@jwp
Copy link
Contributor

jwp commented Nov 17, 2018

Debian is not the world. This software is tested against releases made by postgresql.org.

@suhaibmujahid
Copy link
Author

@jwp
I understand your point. I think it makes sense.

However, the patch will make the library compatible with packages that return additional data in parenthesis without breaking the backward compatibility with the packages that do not. So, it will stay consistent with what postgresql.org defines.

Merging the patch will save a lot of debugging time for many people.

aneslozo added a commit to aneslozo/fe that referenced this pull request Jun 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants