|
From: Damyan I. <di...@cr...> - 2004-11-16 11:20:55
|
Hi, I've finally found some spare time to try implementing bailing out from isql when an error occurs in non-interactive mode. Since I don't have suitable build/test environment, may I ask some of the developers to give it a try? The patch (attached) is against HEAD. If there's interest, I can prepare one against whatever you need. Description of the idea and the patch follows. Why: On error further execution may be unneeded, since the rest of the script may require some prerequisites, that are not fulfilled due to the error. For example, consider the following script (run as "isql -i script.sql") -------------------------------- create table inventory( item_id int65, name varchar(200), constraint pk_inventory primary key(id) ); -- fill in initial items insert into inventory(item_id, name) values(1001, 'Some nice stuff'); -------------------------------- The create statement is obviously mistaken (there is no datatype int 65) and will fail, causing failure in subsequent attempts to use the table. Turning echo on can help finding such errors, but unfortunatelly an error may get lost in large scripts. With the proposed capability, isql will stop after the error, leaving the err statement last in the logs. How is it acomplished: + new global variable introduced, keeping the "bail on error" preference, BailOnError. Defaults to false. + -b command line switch activates BailOnError + SET BAIL command is supported + around line 2765: if process_statement returns ERR and BailOnError is set and Interactive is not set, then set Abort_flag, causing a rollback, followed by exit from the main loop in do_isql() + additionally, in ISQL_main() do not reset Exit_value to FINI_OK after calling do_isql(). This way isql will return an error status, helping automation. I consider this usefull even if BailOnError is not set. (!) There is one thing left to do - help message about SET BAIL. I've included the necessary change, but commented it, since it requires an update of the message file, which update I am not capable of doing. Many thanks for considering this patch. dam -- Damyan Ivanov Creditreform Bulgaria di...@cr... http://www.creditreform.bg/ phone: +359(2)928-2611, 929-3993 fax: +359(2)920-0994 mobile: +359-88-856-6067 ICQ: 3028500 Y!M: dam3028500 |