Consider script (based on
#8255):
select first (1+1+ ... +1+1) rdb$relation_name from rdb$relations;
// "1+1+ ... +1+1" contains 100'000 terms; full example see in attached .7z
If we run it on *Windows* then after ~20 seconds message about stack overflow appears
("SQLSTATE = HY001 / Stack overflow. The resource requirements ... exceeded the memory available to it." -- and it occurs on any Windows host with RAM = 16 ... 96 Gb).
But Firebird process alive, no crash occurs.
Now lets 'enclose' this query in CTAS:
recreate table ctas_test as (
select first (1+1+ ... +1+1) rdb$relation_name from rdb$relations
);
This causes FB crash (checked on 6.0.0.2067-bf10ae1).
Full script is in attachment.
Run it:
isql -q -e -i CTAS-crash-on-too-long-arith-expr.sql
Tail of output will be:
===============
select 'point-0' from rdb$database;
CONSTANT point-0
out nul;
Statement failed, SQLSTATE = HY001
Stack overflow. The resource requirements of the runtime stack have exceeded the memory available to it.
After line 11 in file CTAS-crash-on-too-long-arith-expr.sql
select 'point-1' from rdb$database;
CONSTANT point-1
out nul;
Statement failed, SQLSTATE = 08006
Error reading data from the connection.
After line 16 in file CTAS-crash-on-too-long-arith-expr.sql
select 'point-2' from rdb$database;
Statement failed, SQLSTATE = 08006
Error writing data to the connection.
After line 20 in file CTAS-crash-on-too-long-arith-expr.sql
quit;
===============
Dump, stack-trace, firebird.conf and snapshot 6.0.0.2067-bf10ae1 are
here.