Opened 15 years ago

Closed 13 years ago

#11285 closed Bug (fixed)

postgresql server version as a static variable

Reported by: findepi Owned by: nobody
Component: Database layer (models, ORM) Version: 1.0
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In django.db.backends.postgresql.base and django.db.backends.postgresql_psycopg2.base modules there is a code:

cursor = self.connection.cursor()
if set_tz:
    cursor.execute("SET TIME ZONE %s", [settings_dict['TIME_ZONE']])
    if not hasattr(self, '_version'):
        self.__class__._version = get_version(cursor)
    if self._version[0:2] < (8, 0):

It means that the server version is checked only at the first connection. I understand that django does not support and maybe will never support multiple different db connections from one process, but this may brake things even in case of database failover
E.g. at one network address there may be postgresql servers of different version available.

Change History (5)

comment:1 by Alex Gaynor, 15 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Julien Phalip, 13 years ago

Severity: Normal
Type: New feature

comment:3 by Thejaswi Puthraya, 13 years ago

Component: UncategorizedDatabase layer (models, ORM)
Easy pickings: unset
UI/UX: unset

comment:4 by Ramiro Morales, 13 years ago

Type: New featureBug

comment:5 by Ramiro Morales, 13 years ago

Resolution: fixed
Status: newclosed

In [16439]:

Fixed #11065, #11285 -- Streamlined PostgreSQL version detection, fixing incompatibility with multi-db. Thanks findepi for the report.

Changed our internal representation of the PostgreSQL version from tuples to
integers as used by libpq and psycopg2. This simplifies version comparison
operations.

Also, using the associated libpq/psycopg2 API allows to remove the need for
manually issuing in-band SELECT version() SQL queries to obtain the server
version (or at least reduce its number if version of psycopg2 in use is older
than 2.0.12). Refs #10509.

Note: See TracTickets for help on using tickets.
Back to Top