ISQL on Windows must behave like on Linux when several commands are passed via PIPE, and 'SET BAIL' present among them
Run two similar commands on Windows and Linux:
- on Windows:
echo set bail on; select 1/0 as result_1 from rdb$database; select log10(0) as result_2 from rdb$database; select q'{Hi there! I'm still running }' as msg from rdb$database; | %FB_HOME%\isql localhost:employee -user sysdba -pas masterkey
(also one may to add "-bail" to isql command switches, but result will be the same)
- on Linux:
echo "set bail on; select 1/0 as result_1 from rdb\$database; select log10(0) as result_2 from rdb\$database; select q'{Hi there! I'm still running }' as msg from rdb\$database;" | $PWD/bin/isql localhost:employee -user sysdba -pas masterkey
Output on Windows will be:
SQL>
RESULT_1
=====================
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.
RESULT_2
=======================
Statement failed, SQLSTATE = 42000
expression evaluation not supported
-Argument for LOG10 must be positive
MSG
============================
Hi there! I'm still running
Output on Linux:
RESULT_1
=====================
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.
Documentation ( doc\README.isql_enhancements.txt ) states that:
- Even if BAIL is activated, it doesn't mean it will change isql behavior. An
additional requirement should be met: the session should be non-interactive ...
giving it a script as input.
As we can see, this rule is respected on Windows only. But on Linux behaviour seems more logic: 1st error break execution, regardless whether we call ISQL using '-i <script.sql>' or give all commands vis PIPE (say, using command 'cat <script.sql> | isql localhost:employee ....').
It would be great if ISQL on Windows will 'switch' its own mode to NON-interactive if several (>=2) commands come from PIPE. May be some new command switch can be implemented for that (in order to preserve backward compatibility).
The problem is that on Windows all pipes are the same so envelopes like MSYS would cause ISQL to be in "non-interactive" mode. IIRC it was the primary reason (and corresponding ticket) to make it this way.