Re: About PostgreSQL's limit on arithmetic operations - Mailing list pgsql-general

From Stephan Szabo
Subject Re: About PostgreSQL's limit on arithmetic operations
Date
Msg-id 20040929080121.Q59588@megazone.bigpanda.com
Whole thread Raw
In response to About PostgreSQL's limit on arithmetic operations  (Devrim GUNDUZ <devrim@gunduz.org>)
List pgsql-general
On Wed, 29 Sep 2004, Devrim GUNDUZ wrote:

> We were performing some tests on PostgreSQL and found that it fails on the
> following query:
>
> SELECT 512*18014398509481984 AS result;
>
> and the result is:
>
>          result
> - ----------------------
>   -9223372036854775808

This query should either return the "correct" answer or error. The
constants are probably getting typed as int4 and int8 but the result
overflows int8. If we say that the result of an int8 and int4 must be
within the int8 precision (which appears to be allowed by the spec,
although may not be what was inteneded) then it should error.

We don't currently check the overflow cases for int<n> to generate the
error, and we don't upgrade smaller integer types into numerics if it
would have overflowed. At some point we probably need to do one of those,
but AFAIK noone's been particularly motivated to do it.

pgsql-general by date:

Previous
From: Richard Huxton
Date:
Subject: Re: Multiple Rules :: Postgres Is confused !!
Next
From: Stephan Szabo
Date:
Subject: Re: Setting search paths inside a function (plpgsql)