Ticket #16255: 16255.1.diff

File 16255.1.diff, 5.9 KB (added by Ramiro Morales, 13 years ago)

Patch for this issue, included docs changes

  • django/db/backends/postgresql_psycopg2/base.py

    diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py
    a b  
    145145                # No savepoint support for earlier version of PostgreSQL.
    146146                self.features.uses_savepoints = False
    147147            if self.features.uses_autocommit:
    148                 if self._version[0:2] < (8, 2):
    149                     # FIXME: Needs extra code to do reliable model insert
    150                     # handling, so we forbid it for now.
    151                     from django.core.exceptions import ImproperlyConfigured
    152                     raise ImproperlyConfigured("You cannot use autocommit=True with PostgreSQL prior to 8.2 at the moment.")
    153                 else:
    154                     # FIXME: Eventually we're enable this by default for
    155                     # versions that support it, but, right now, that's hard to
    156                     # do without breaking other things (#10509).
    157                     self.features.can_return_id_from_insert = True
     148                # FIXME: Eventually we'll enable this by default for
     149                # versions that support it, but, right now, that's hard to
     150                # do without breaking other things (#10509).
     151                self.features.can_return_id_from_insert = True
    158152        return CursorWrapper(cursor)
    159153
    160154    def _enter_transaction_management(self, managed):
  • django/db/backends/postgresql_psycopg2/operations.py

    diff --git a/django/db/backends/postgresql_psycopg2/operations.py b/django/db/backends/postgresql_psycopg2/operations.py
    a b  
    8484
    8585    def sql_flush(self, style, tables, sequences):
    8686        if tables:
    87             if self.postgres_version[0:2] >= (8,1):
    88                 # Postgres 8.1+ can do 'TRUNCATE x, y, z...;'. In fact, it *has to*
    89                 # in order to be able to truncate tables referenced by a foreign
    90                 # key in any other table. The result is a single SQL TRUNCATE
    91                 # statement.
    92                 sql = ['%s %s;' % \
    93                     (style.SQL_KEYWORD('TRUNCATE'),
    94                      style.SQL_FIELD(', '.join([self.quote_name(table) for table in tables]))
    95                 )]
    96             else:
    97                 # Older versions of Postgres can't do TRUNCATE in a single call, so
    98                 # they must use a simple delete.
    99                 sql = ['%s %s %s;' % \
    100                         (style.SQL_KEYWORD('DELETE'),
    101                          style.SQL_KEYWORD('FROM'),
    102                          style.SQL_FIELD(self.quote_name(table))
    103                          ) for table in tables]
     87            # Perform a single SQL 'TRUNCATE x, y, z...;' statement.  It allows
     88            # us to truncate tables referenced by a foreign key in any other
     89            # table.
     90            sql = ['%s %s;' % \
     91                (style.SQL_KEYWORD('TRUNCATE'),
     92                    style.SQL_FIELD(', '.join([self.quote_name(table) for table in tables]))
     93            )]
    10494
    10595            # 'ALTER SEQUENCE sequence_name RESTART WITH 1;'... style SQL statements
    10696            # to reset sequence indices
     
    171161    def check_aggregate_support(self, aggregate):
    172162        """Check that the backend fully supports the provided aggregate.
    173163
    174         The population and sample statistics (STDDEV_POP, STDDEV_SAMP,
    175         VAR_POP, VAR_SAMP) were first implemented in Postgres 8.2.
    176 
    177164        The implementation of population statistics (STDDEV_POP and VAR_POP)
    178165        under Postgres 8.2 - 8.2.4 is known to be faulty. Raise
    179166        NotImplementedError if this is the database in use.
    180167        """
    181         if aggregate.sql_function in ('STDDEV_POP', 'STDDEV_SAMP', 'VAR_POP', 'VAR_SAMP'):
    182             if self.postgres_version[0:2] < (8,2):
    183                 raise NotImplementedError('PostgreSQL does not support %s prior to version 8.2. Please upgrade your version of PostgreSQL.' % aggregate.sql_function)
    184 
    185168        if aggregate.sql_function in ('STDDEV_POP', 'VAR_POP'):
    186169            if self.postgres_version[0:2] == (8,2):
    187170                if self.postgres_version[2] is None or self.postgres_version[2] <= 4:
  • docs/ref/databases.txt

    diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt
    a b  
    1616PostgreSQL notes
    1717================
    1818
    19 .. versionchanged:: 1.3
     19.. versionchanged:: 1.4
    2020
    21 Django supports PostgreSQL 8.0 and higher. If you want to use
    22 :ref:`database-level autocommit <postgresql-autocommit-mode>`, a
    23 minimum version of PostgreSQL 8.2 is required.
    24 
    25 .. admonition:: Improvements in recent PostgreSQL versions
    26 
    27     PostgreSQL 8.0 and 8.1 `will soon reach end-of-life`_; there have
    28     also been a number of significant performance improvements added
    29     in recent PostgreSQL versions. Although PostgreSQL 8.0 is the minimum
    30     supported version, you would be well advised to use a more recent
    31     version if at all possible.
    32 
    33 .. _will soon reach end-of-life: http://wiki.postgresql.org/wiki/PostgreSQL_Release_Support_Policy
     21Django supports PostgreSQL 8.2 and higher.
    3422
    3523PostgreSQL 8.2 to 8.2.4
    3624-----------------------
  • docs/releases/1.4.txt

    diff --git a/docs/releases/1.4.txt b/docs/releases/1.4.txt
    a b  
    363363Some legacy ways of calling :func:`~django.views.decorators.cache.cache_page`
    364364have been deprecated, please see the docs for the correct way to use this
    365365decorator.
     366
     367Support for PostgreSQL version older than 8.2
     368~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     369
     370Django 1.3 dropped support for PostgreSQL versions older than 8.0 and the
     371relevant documents suggested to use 8.2 because of performance reasons but more
     372importantly because of the end of the support periods for releases 8.0
     373and 8.1 (November 2010.)
     374
     375Django 1.4 takes that policy further and sets 8.2 as the minimum PostgreSQL
     376version it officially supports.
Back to Top