Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISQL: Add "Stop on Error" switch to immediatelly stop script error occurs during execution [CORE4232] #4556

Open
firebird-issue-importer opened this issue Sep 20, 2013 · 5 comments

Comments

@firebird-issue-importer

Submitted by: @pavel-zotov

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)

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Sep 20, 2013

Commented by: Sean Leyne (seanleyne)

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.

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Sep 20, 2013

Modified by: Sean Leyne (seanleyne)

summary: ISQL: provide switch to immediatelly cancel script containing many 'heavy statements' if database in shutdown or any engine error occured => ISQL: Add "Stop on Error" switch to immediatelly stop script error occurs during execution

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Sep 20, 2013

Commented by: Sean Leyne (seanleyne)

@pavel,

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

If single line, what happens if on multiple lines?

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Sep 20, 2013

Commented by: @pavel-zotov

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

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Sep 20, 2013

Commented by: Sean Leyne (seanleyne)

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant