Обсуждение: BigDecimal instead of Integer in 7.1

Поиск
Список
Период
Сортировка

BigDecimal instead of Integer in 7.1

От
Joseph Shraibman
Дата:
I just upgraded from 7.0.3 to 7.1.

I have a query like this:
SELECT l, (SELECT COUNT(*) FROM ms WHERE ms.p = 4 AND ms.s = 2),
COUNT(DISTINCT m.uid), COUNT(m.oid), AVG(m.msgs::int), SUM(m.msgs::int)
FROM m, a WHERE key = 4 AND m.p = 4 GROUP BY l;

The problem is suddenly in 7.1 the result of the subselect used to
return an Integer now returns a BigInteger and is causing
classCastExceptions in my code.  What gives?



--
Joseph Shraibman
jks@selectacast.net
Increase signal to noise ratio.  http://www.targabot.com

Re: BigDecimal instead of Integer in 7.1

От
Tom Lane
Дата:
Joseph Shraibman <jks@selectacast.net> writes:
> The problem is suddenly in 7.1 the result of the subselect used to
> return an Integer now returns a BigInteger and is causing
> classCastExceptions in my code.  What gives?

sum() and avg() return NUMERIC now for integer input, to avoid
overflow and precision problems.

            regards, tom lane

Re: BigDecimal instead of Integer in 7.1

От
Joseph Shraibman
Дата:
Tom Lane wrote:
>
> Joseph Shraibman <jks@selectacast.net> writes:
> > The problem is suddenly in 7.1 the result of the subselect used to
> > return an Integer now returns a BigInteger and is causing
> > classCastExceptions in my code.  What gives?
>
> sum() and avg() return NUMERIC now for integer input, to avoid
> overflow and precision problems.
>
>                         regards, tom lane


My second count (not in the subquery) is returning an Integer.
--
Joseph Shraibman
jks@selectacast.net
Increase signal to noise ratio.  http://www.targabot.com