Edgewall Software

Opened 6 years ago

Last modified 6 years ago

#13032 closed defect

Postgres server version reported incorrectly for psql >= 10 — at Version 1

Reported by: Ryan J Ollos Owned by: Ryan J Ollos
Priority: normal Milestone: 1.3.3
Component: general Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description (last modified by Ryan J Ollos)

The About Trac page on my dev machine is showing server: 10.0.4. It should display 10.4:

$ psql -c "SELECT version();" trac tracuser
                                                    version
---------------------------------------------------------------------------------------------------------------
 PostgreSQL 10.4 on x86_64-apple-darwin17.5.0, compiled by Apple LLVM version 9.1.0 (clang-902.0.39.1), 64-bit
(1 row)

I've done only a cursory investigation, but it looks like the versioning policy has changed. So for version ≥ 10 we should parse 100004 to tuple (10, 4): tags/trac-1.3.2/trac/db/postgres_backend.py@:454:#L452.

  • trac/db/postgres_backend.py

    diff --git a/trac/db/postgres_backend.py b/trac/db/postgres_backend.py
    index c2e94becc..2647f9b9d 100644
    a b def _quote(identifier):  
    9999def _version_tuple(ver):
    100100
    101101    if ver:
    102         # Extract 9.1.23 from 90123.
    103102        def get_digit(version, n):
    104103            return version / 10 ** (2 * n) % 100
    105         return get_digit(ver, 2), get_digit(ver, 1), get_digit(ver, 0)
     104        first_digit = get_digit(ver, 2)
     105        if first_digit >= 10:
     106            # Extract (10, 4) from 100004.
     107            return first_digit, get_digit(ver, 0)
     108        else:
     109            # Extract (9, 1, 23) from 90123.
     110            return first_digit, get_digit(ver, 1), get_digit(ver, 0)
    106111
    107112
    108113def _version_string(ver):

A few other minor changes may also be needed.

Change History (1)

comment:1 by Ryan J Ollos, 6 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.