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.