Subject Re: [firebird-support] sum of integers results in an overflow
Author Steve Wiser
> > > Anyways my question is: Is this a bug in Firebird with Dialect 1?
> >
> > One possibility is that it is a bug in FB (although I am not aware of
> it).
> > Can you send reproducible test case ?
> >
> > The other possibility is that it is a bug in IB - perhaps the
> overflow exception
> > is correct (for given data and datatype), but IB will send you wrong
> result instead.
> > Are you sure the results in IB5.6 are always correct ?
> >
> > Ivan
> > http://www.volny.cz/iprenosil/interbase/
>
> We are creating a test script to see if it is reproducible or maybe just
> a bad db on our part? I will post it once we have verified it again.
>
>

Here is our test case:

***

create table TEST_TABLE (
integerValue INTEGER
);

insert into TEST_TABLE ( integerValue ) values ( 1000000000 );
insert into TEST_TABLE ( integerValue ) values ( 2000000000 );

select sum( cast( integerValue as DOUBLE PRECISION ) )
from test_table;

select sum( integerValue )
from test_table;

***

The first select sum works in Interbase 5.6, Firebird 1.5.3 Dialect 1,
and Firebird 1.5.3 Dialect 3. The second select sum works in Firebird
1.5.3 Dialect 3 and throws an overflow exception in Firebird 1.5.3
Dialect 1 *and* Interbase 5.6...

So I guess it functions exactly how it did in Interbase which is what it
is supposed to do.

Thank you for taking the time to answer my question and we will just
cast it to a double until we can move off of Dialect 1.

-steve