Following script has three EXECUTE BLOCKs:
=============
SET BAIL OFF;
shell if exist r:\temp\tmp4test.fdb del r:\temp\tmp4test.fdb;
create database 'localhost:r:\temp\tmp4test.fdb' user 'sysdba' password 'masterkey';
commit;
set list on;
set autoterm on;
create domain dm_rdb_key char(8) character set octets;
create table test(fn boolean);
commit;
set echo on;
-- /*
--------------------------- [ 1 ] -------------------------
execute block returns(
local_proc_result_1 boolean
) as
begin
-- output:
-- SQLSTATE = 22018 / conversion error from string "DBKEY"
-- (expected)
insert into test values (false) returning rdb$db_key into local_proc_result_1;
suspend;
end;
-- */
-- /*
--------------------------- [ 2 ] -------------------------
execute block returns(
local_proc_result_2 boolean
) as
declare local temporary table dtt_outer (
fn boolean
);
declare procedure local_sp returns(local_proc_result_2 dm_rdb_key) as
begin
insert into dtt_outer values (false) returning not fn into local_proc_result_2;
suspend;
end
begin
-- output:
-- SQLSTATE = 22018 / conversion error from string "TRUE#x00#x00#x00#x00"
-- (expected)
execute procedure local_sp returning_values local_proc_result_2;
suspend;
end;
--*/
--/*
--------------------------- [ 3 ] -------------------------
execute block returns (
local_proc_result boolean
) as
declare procedure local_sp returns(local_proc_result dm_rdb_key) as
declare local temporary table dtt_inner (
fn boolean
);
begin
insert into dtt_inner values (false) returning not fn into local_proc_result;
suspend;
end
begin
-- bugcheck with following in firebird.log:
-- conversion error from string "TRUE#x00#x00#x00#x00"
-- At block line: 48, col: 5
-- internal Firebird consistency check (record disappeared (186), file: Savepoint.cpp line: 281)
execute procedure local_sp returning_values local_proc_result;
suspend;
end;
-- */
=============
All of them can compile but will fail at runtime because of types incomatibility.
But only 1st and 2nd will issue expected output ("conversion error").
EB marked as "[ 3 ]" causes bugcheck and firebird.log will contain:
==========
conversion error from string "TRUE#x00#x00#x00#x00"
At block line: 21, col: 5
internal Firebird consistency check (record disappeared (186), file: Savepoint.cpp line: 281)
...
Error writing data to the connection.
==========
This is
URL to dump, stack-trace, firebird.log and FB snapshot (checked on 6.0.0.2092-0-3fa7269).