summaryrefslogtreecommitdiff
path: root/django/db/backends/postgresql/operations.py
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2009-02-02 12:03:31 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2009-02-02 12:03:31 +0000
commit65ad2132abd4c56f38c43b0ba9a23ed716733728 (patch)
tree2518f3fc6be3ac8d9256d7e5609bbddc905ffd15 /django/db/backends/postgresql/operations.py
parent2b8e768b2205793db0f0db4709b9b4674f14ada6 (diff)
downloaddjango-65ad2132abd4c56f38c43b0ba9a23ed716733728.tar.gz
Fixed #10142 -- Added docs and an exploding error message to highlight an error present in the implementation of STDDEV_POP and VAR_POP in PostgreSQL 8.2-8.2.4 that will give incorrect answers (the database function mistakenly returns sample, rather than population deviation/variance). Thanks to Vinay Sajip <vinay_sajip@yahoo.co.uk> for the report, and Ian Kelly for pointing out the cause of the problem.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9804 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/backends/postgresql/operations.py')
-rw-r--r--django/db/backends/postgresql/operations.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/django/db/backends/postgresql/operations.py b/django/db/backends/postgresql/operations.py
index 235210939f..9f221b3822 100644
--- a/django/db/backends/postgresql/operations.py
+++ b/django/db/backends/postgresql/operations.py
@@ -144,3 +144,14 @@ class DatabaseOperations(BaseDatabaseOperations):
def prep_for_iexact_query(self, x):
return x
+
+ def check_aggregate_support(self, aggregate):
+ """Check that the backend fully supports the provided aggregate.
+
+ 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 == 'STDDEV_POP' or aggregate.sql_function == 'VAR_POP':
+ if self.postgres_version[0] == 8 and self.postgres_version[1] == 2 and self.postgres_version[1] <= 4:
+ raise NotImplementedError('PostgreSQL 8.2 to 8.2.4 is known to have a faulty implementation of %s. Please upgrade your version of PostgreSQL.' % aggregate.sql_function)