Please consider script:
===========
set bail on;
set list on;
set autoterm on;
shell if exist r:\temp\tmp4test.fdb del r:\temp\tmp4test.fdb;
create database 'localhost:r:\temp\tmp4test.fdb' user 'sysdba' password 'masterkey';
commit;
create global temporary table t_accumulator(id smallint, f int128) on commit delete rows;
create or alter procedure sp_recur(i smallint) returns(o int128, u int128) as
-- declare temporary table t_accumulator(id smallint, f int128); ------------ [ 1 ]
begin
if ( i > 1 ) then
begin
o = i * (select o from sp_recur( :i - 1 ));
end
else
begin
o = i;
end
insert into t_accumulator(id, f) values(:i, :o);
u = (select sum(f) from t_accumulator);
suspend;
end
;
select p.* from sp_recur(34) p;
===========
It will raise error:
===========
Statement failed, SQLSTATE = 22003
arithmetic exception, numeric overflow, or string truncation
-Integer overflow. The result of an integer operation caused the most significant bit of the result to carry.
-At procedure "PUBLIC"."SP_RECUR" line: 6, col: 13
===========
(and this is expected because 34! =~ 2.95E38 -- greater than max(int128) = 2^127 =~ 1.70E38)
Now UNcomment line markled as "[ 1 ] " and repeat.
Bugcheck will raise with following message in the firebird.log:
==========
arithmetic exception, numeric overflow, or string truncation
Integer overflow. The result of an integer operation caused the most significant bit of the result to carry.
At procedure "PUBLIC"."SP_RECUR" line: 6, col: 13
internal Firebird consistency check (record disappeared (186), file: Savepoint.cpp line: 281)
==========
This is
URL to dump, stacktracem firebird.conf, firebird.log and snapshot ( checked on 6.0.0.2097-0592438 ).