Issue Details (XML | Word | Printable)

Key: CORE-4232
Type: Improvement Improvement
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Pavel Zotov
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Firebird Core

ISQL: Add "Stop on Error" switch to immediatelly stop script error occurs during execution

Created: 20/Sep/13 04:42 PM   Updated: 20/Sep/13 07:52 PM
Component/s: ISQL
Affects Version/s: 3.0 Alpha 1
Fix Version/s: None


 Description  « Hide
I have a few huge scripts to be handled by ISQL. These scripts contains many EXECUTE BLOCKs delimited by COMMIT statement.
Each of EB, in turn, does a lot of DML.

For some test purpoces its needed to stop immediately all of ISQLs if server has been crashed or detected some serious error in database.
But ISQL will continue after error that enountered on N-th statement and will see that FB is (again) alive - due to fbguard that 'lifted up' FB process.

The "-b" switch (or the command issued inside ISQL prompt: set bail on) - doesn`t help in such situation:

sesson #1
########
-- run THREE 'heavy statement':
select count(*) from rdb$fields, rdb$fields, rdb$fields, rdb$fields; select count(*) from rdb$relations; select count(*) from rdb$relations;

session #2
#########
gfix -shut full -force 0

session #1
#########
       COUNT
============
Statement failed, SQLSTATE = HY000
database C:\MIX\FIREBIRD\TB.FDB shutdown ----- (1)
Statement failed, SQLSTATE = HY000
database C:\MIX\FIREBIRD\TB.FDB shutdown ----- (2)
Statement failed, SQLSTATE = HY000
database C:\MIX\FIREBIRD\TB.FDB shutdown ----- (3)

As we can see, ISQL attempted to run 2nd and 3rd statements after first error.

Is it possible to implement such func. that (2) and (3) will NOT appear and ISQL immediately will finish ?
(not only on case db shutdown - i'm speaking about ANY error)

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Sean Leyne added a comment - 20/Sep/13 05:14 PM - edited
The correct description of the switch would be "stop on error"

It also would seem reasonable that this would become the default mode, and that the switch would 'ignore' the errors.

Sean Leyne added a comment - 20/Sep/13 05:19 PM
@Pavel,

Does the script have the statements on separate lines or a single line?

If single line, what happens if on multiple lines?

Pavel Zotov added a comment - 20/Sep/13 05:45 PM
hm...

Now (FB 3.0.x) - yes, the problem exists only in case of few commands in SINGLE line.

I re-run simple test that did not stops in 2.5.x even when `-b` was specified:
-- file = 'tmp4test.sql'
     1 set list on;
     2 set term ^;
     3 execute block returns(msg varchar(80), dts timestamp) as
     4 declare v int;
     5 begin
     6 select 'start statement #1', current_timestamp from rdb$database into msg,dts;
     7 select count(*) from rdb$fields,rdb$fields,rdb$fields,rdb$relations into v;
     8 end^
     9 set term ;^
    10 commit;
    11
    12 set term ^;
    13 execute block returns(msg varchar(80), dts timestamp) as
    14 declare v int;
    15 begin
    16 select 'start statement #2', current_timestamp from rdb$database into msg,dts;
    17 select count(*) from rdb$fields,rdb$fields,rdb$fields,rdb$relations;
    18 end^
    19 set term ;^
    20 commit;
    21
    22 set term ^;
    23 execute block returns(msg varchar(80), dts timestamp) as
    24 declare v int;
    25 begin
    26 select 'start statement #3', current_timestamp from rdb$database into msg,dts;
    27 select count(*) from rdb$fields,rdb$fields,rdb$fields,rdb$relations;
    28 end^
    29 set term ;^
    30 select 'finish them all ok' msg, current_timestamp from rdb$database;
    31 commit;

And when I run in session #1:
isql localhost/3330:/var/db/fb30/tmp4test.fdb -b -i tmp4test.sql

- then issuing in session #2 gfix -shut full - force 0 causes session #1 to immediately to stop:
Statement failed, SQLSTATE = HY000
database /var/db/fb30/tmp4test.fdb shutdown
After line 2 in file tmp4test.sql

So, my apologies: this switch DOES work correctly, at leat on FB 3.0.x

Sean Leyne added a comment - 20/Sep/13 07:52 PM
I'm not sure where your results leave this case.

It seems that the requested functionality exists in v3.0 (although not for multiple statements on a single line -- but I would say that is a minor use-case)