Changeset 704 for trunk/module/pg.py


Ignore:
Timestamp:
Jan 9, 2016, 9:48:47 AM (4 years ago)
Author:
cito
Message:

Simplify code by removing case distinctions for PG < 8.2

In PyGres? 5 (the trunk) we support only PG 9.0 and above, so we shouldn't
worry about PG 8.1 and below any more (PG 8.2 was released 10 years ago).
People who need to request old databases can still use PyGres? 4.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/module/pg.py

    r664 r704  
    584584            # if not found, check again in case it was added after we started
    585585            self._pkeys = {}
    586             if self.server_version >= 80200:
    587                 # the ANY syntax works correctly only with PostgreSQL >= 8.2
    588                 any_indkey = "= ANY (pg_index.indkey)"
    589             else:
    590                 any_indkey = "IN (%s)" % ', '.join(
    591                     ['pg_index.indkey[%d]' % i for i in range(16)])
    592586            for r in self.db.query(
    593587                "SELECT pg_namespace.nspname, pg_class.relname,"
     
    600594                " JOIN pg_index ON pg_index.indrelid = pg_class.oid"
    601595                    " AND pg_index.indisprimary = 't'"
    602                     " AND pg_attribute.attnum " + any_indkey).getresult():
     596                    " AND pg_attribute.attnum"
     597                        " = ANY (pg_index.indkey)").getresult():
    603598                cl, pkey = _join_parts(r[:2]), r[2]
    604599                self._pkeys.setdefault(cl, []).append(pkey)
     
    819814        names, values = ', '.join(names), ', '.join(values)
    820815        selectable = self.has_table_privilege(qcl)
    821         if selectable and self.server_version >= 80200:
     816        if selectable:
    822817            ret = ' RETURNING %s*' % ('oid, ' if 'oid' in attnames else '')
    823818        else:
     
    893888        values = ', '.join(values)
    894889        selectable = self.has_table_privilege(qcl)
    895         if selectable and self.server_version >= 80200:
     890        if selectable:
    896891            ret = ' RETURNING %s*' % ('oid, ' if 'oid' in attnames else '')
    897892        else:
Note: See TracChangeset for help on using the changeset viewer.