Re: Weird problem with aggregate functions - Mailing list pgsql-odbc

From Tom Lane
Subject Re: Weird problem with aggregate functions
Date
Msg-id 17221.1005073355@sss.pgh.pa.us
Whole thread Raw
In response to Re: Weird problem with aggregate functions  ("Andrea Aime" <aaime@comune.modena.it>)
List pgsql-odbc
"Andrea Aime" <aaime@comune.modena.it> writes:
> Thanks, it works!!! But why doesn't it work without the
> cast? This is a good workaround, but the standard behaviour
> is a bug, isn't it?

No, it isn't.  We *used* to return int4 as the result of sum(int4),
etc, but that tends to suffer from overflow.  And the deficiency of
using int4 as the result of avg() should be pretty obvious ;-)

The SQL spec says that we can use any exact numeric datatype we please
for these functions:

            b) If SUM is specified and DT is exact numeric with scale
              S, then the data type of the result is exact numeric with
              implementation-defined precision and scale S.

            c) If AVG is specified and DT is exact numeric, then the data
              type of the result is exact numeric with implementation-
              defined precision not less than the precision of DT and
              implementation-defined scale not less than the scale of DT.

From what I've heard, VB simply does not recognize Postgres' NUMERIC
datatype at all.  I don't know if that's VB's fault or a problem in
our ODBC driver.

            regards, tom lane

pgsql-odbc by date:

Previous
From: "Alan R. Johns"
Date:
Subject: Access 2000 & Views
Next
From: Hiroshi Inoue
Date:
Subject: Re: Access 2000 & Views