Bug #16707 --force doesn't work with --execute

Submitted: 22 Jan 2006 5:03
Reporter: Kolbe Kegel Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S4 (Feature request)
Version:5.0.19 OS:Linux (Linux)
Assigned to: CPU Architecture:Any

[22 Jan 2006 5:03] Kolbe Kegel
Description:
The --force [-f] option to the mysql command line client doesn't have any effect when statements are passed to the client using --execute [-e] as opposed to STDIN.

How to repeat:
All statements are executed when this technique is used:

kolbe@beluga:~/MySQL/inst/5.0-bk> echo 'select 1; select 2; select nonsense; select 3; select 4;' | ./bin/mysql -ft
+---+
| 1 |
+---+
| 1 |
+---+
+---+
| 2 |
+---+
| 2 |
+---+
ERROR 1054 (42S22) at line 1: Unknown column 'nonsense' in 'field list'
+---+
| 3 |
+---+
| 3 |
+---+
+---+
| 4 |
+---+
| 4 |
+---+

Even though -f is specified, execution stops after the first error is encountered:

kolbe@beluga:~/MySQL/inst/5.0-bk> ./bin/mysql -fe 'select 1; select 2; select nonsense; select 3; select 4;'
+---+
| 1 |
+---+
| 1 |
+---+
+---+
| 2 |
+---+
| 2 |
+---+
ERROR 1054 (42S22) at line 1: Unknown column 'nonsense' in 'field list'

One possible solution might be to require that statements be specified using separate -e arguments if the user wants them to be processed even if one a previous statement has resulted in an error. For example:

kolbe@beluga:~/MySQL/inst/5.0-bk> ./bin/mysql -fe 'select 1;' -e 'select 2;' -e 'select nonsense;' -e 'select 3;' -e 'select 4;'
+---+
| 1 |
+---+
| 1 |
+---+
+---+
| 2 |
+---+
| 2 |
+---+
ERROR 1054 (42S22) at line 1: Unknown column 'nonsense' in 'field list'

Suggested fix:
It seems as though the description of the --force option (Continue even if an SQL error occurs.) indicates that it should apply to statements provided in a -e clause. Changing the client to exhibit this behavior would be the best resolution.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.048 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.