Fixed #16255 -- Raised minimum PostgreSQL version supported to 8.2.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16423 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Ramiro Morales 2011-06-16 20:05:25 +00:00
parent b2f5efc6ac
commit b870bf6b9a
4 changed files with 24 additions and 51 deletions

View File

@ -141,20 +141,11 @@ class DatabaseWrapper(BaseDatabaseWrapper):
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):
# No savepoint support for earlier version of PostgreSQL.
self.features.uses_savepoints = False
if self.features.uses_autocommit:
if self._version[0:2] < (8, 2):
# FIXME: Needs extra code to do reliable model insert
# handling, so we forbid it for now.
from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured("You cannot use autocommit=True with PostgreSQL prior to 8.2 at the moment.")
else:
# FIXME: Eventually we're enable this by default for
# versions that support it, but, right now, that's hard to
# do without breaking other things (#10509).
self.features.can_return_id_from_insert = True
# FIXME: Eventually we'll enable this by default for
# versions that support it, but, right now, that's hard to
# do without breaking other things (#10509).
self.features.can_return_id_from_insert = True
return CursorWrapper(cursor)
def _enter_transaction_management(self, managed):

View File

@ -84,23 +84,13 @@ class DatabaseOperations(BaseDatabaseOperations):
def sql_flush(self, style, tables, sequences):
if tables:
if self.postgres_version[0:2] >= (8,1):
# Postgres 8.1+ can do 'TRUNCATE x, y, z...;'. In fact, it *has to*
# in order to be able to truncate tables referenced by a foreign
# key in any other table. The result is a single SQL TRUNCATE
# statement.
sql = ['%s %s;' % \
(style.SQL_KEYWORD('TRUNCATE'),
style.SQL_FIELD(', '.join([self.quote_name(table) for table in tables]))
)]
else:
# Older versions of Postgres can't do TRUNCATE in a single call, so
# they must use a simple delete.
sql = ['%s %s %s;' % \
(style.SQL_KEYWORD('DELETE'),
style.SQL_KEYWORD('FROM'),
style.SQL_FIELD(self.quote_name(table))
) for table in tables]
# Perform a single SQL 'TRUNCATE x, y, z...;' statement. It allows
# us to truncate tables referenced by a foreign key in any other
# table.
sql = ['%s %s;' % \
(style.SQL_KEYWORD('TRUNCATE'),
style.SQL_FIELD(', '.join([self.quote_name(table) for table in tables]))
)]
# 'ALTER SEQUENCE sequence_name RESTART WITH 1;'... style SQL statements
# to reset sequence indices
@ -171,17 +161,10 @@ class DatabaseOperations(BaseDatabaseOperations):
def check_aggregate_support(self, aggregate):
"""Check that the backend fully supports the provided aggregate.
The population and sample statistics (STDDEV_POP, STDDEV_SAMP,
VAR_POP, VAR_SAMP) were first implemented in Postgres 8.2.
The implementation of population statistics (STDDEV_POP and VAR_POP)
under Postgres 8.2 - 8.2.4 is known to be faulty. Raise
NotImplementedError if this is the database in use.
"""
if aggregate.sql_function in ('STDDEV_POP', 'STDDEV_SAMP', 'VAR_POP', 'VAR_SAMP'):
if self.postgres_version[0:2] < (8,2):
raise NotImplementedError('PostgreSQL does not support %s prior to version 8.2. Please upgrade your version of PostgreSQL.' % aggregate.sql_function)
if aggregate.sql_function in ('STDDEV_POP', 'VAR_POP'):
if self.postgres_version[0:2] == (8,2):
if self.postgres_version[2] is None or self.postgres_version[2] <= 4:

View File

@ -16,21 +16,9 @@ documentation or reference manuals.
PostgreSQL notes
================
.. versionchanged:: 1.3
.. versionchanged:: 1.4
Django supports PostgreSQL 8.0 and higher. If you want to use
:ref:`database-level autocommit <postgresql-autocommit-mode>`, a
minimum version of PostgreSQL 8.2 is required.
.. admonition:: Improvements in recent PostgreSQL versions
PostgreSQL 8.0 and 8.1 `will soon reach end-of-life`_; there have
also been a number of significant performance improvements added
in recent PostgreSQL versions. Although PostgreSQL 8.0 is the minimum
supported version, you would be well advised to use a more recent
version if at all possible.
.. _will soon reach end-of-life: http://wiki.postgresql.org/wiki/PostgreSQL_Release_Support_Policy
Django supports PostgreSQL 8.2 and higher.
PostgreSQL 8.2 to 8.2.4
-----------------------

View File

@ -376,3 +376,14 @@ Old styles of calling ``cache_page`` decorator
Some legacy ways of calling :func:`~django.views.decorators.cache.cache_page`
have been deprecated, please see the docs for the correct way to use this
decorator.
Support for PostgreSQL versions older than 8.2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Django 1.3 dropped support for PostgreSQL versions older than 8.0 and the
relevant documents suggested to use a recent version because of performance
reasons but more importantly because end of the upstream support periods for
releases 8.0 and 8.1 was near (November 2010.)
Django 1.4 takes that policy further and sets 8.2 as the minimum PostgreSQL
version it officially supports.