Open firebird-automations opened 12 years ago
Commented by: @hvlad
Currently, the ON TRANSACTION ROLLBACK and ON DISCONNECT triggers are silently ignores exceptions (except of bugcheks, but this is another story). This is done so because we don't want to abort ROLLBACK or DISCONNECT action, else application could be left in "no exit" state. But this is not good to hide errors, i think. We should make user somehow know about it. One possible way is to log such errors into firebird.log. Another is to catch error, store it somewhere and continue ROLLBACK\DISCONNECT. Then report catched error and, probably, add special message that ROLLBACK\DISCONNECT was completed despite of exception. Probably we can do something more clever, ideas are welcome...
Commented by: @dyemanov
Also, the error could be reported as a warning in this special case.
Submitted by: @pavel-zotov
Consider the following script that is stored in file 'TEST.SQL':
recreate table tmp(id int, s01 varchar(20)); commit;
set term ^; create or alter trigger t_rollback active on transaction rollback as declare v int; begin v = (select 1/0 from rdb$database); end^
create or alter trigger t_commit active on transaction commit as declare v int; begin if (exists(select * from tmp)) then v = (select 1/0 from rdb$database); end^ set term ;^ commit;
Then create a new database, make connect and run two cases.
CASE #1. ------------ C:\1INSTALL\FIREBIRD\Data>isql TR.FDB Database: TR.FDB SQL> in TEST.SQL; SQL> insert into tmp values(1,'aaa'); SQL> commit; Statement failed, SQLSTATE = 22012 arithmetic exception, numeric overflow, or string truncation -Integer divide by zero. The code attempted to divide an integer value by an integer divisor of zero. -At trigger 'T_COMMIT' line: 6, col: 34
CASE #2. ------------- C:\1INSTALL\FIREBIRD\Data>isql TR.FDB Database: TR.FDB SQL> in TEST.SQL; SQL> insert into tmp values(1,'aaa'); SQL> rollback; SQL> -- no messages about zero division --
-------------------------------------------------------------------------------------------------------------------------
PS. The trigger T_ROLLBACK was actually fired because in trace we can see for CASE #2:
2011-12-29T01:02:47.5460 (468:021EDEE0) EXECUTE_STATEMENT_FINISH
Statement 360:
-------------------------------------------------------------------------------
insert into tmp values(1,'aaa')
0 records fetched
Table Natural Index Update Insert Delete Backout Purge Expunge
***************************************************************************************************************
TMP 1
2011-12-29T01:02:50.8750 (468:021EDEE0) EXECUTE_TRIGGER_START
2011-12-29T01:02:50.8750 (468:021EDEE0) FAILED EXECUTE_TRIGGER_FINISH
2011-12-29T01:02:50.8900 (468:021EDEE0) ROLLBACK_TRANSACTION