'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.'

def check_aggregate_support(self, aggregate):

    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)):
                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))
