Bug #44127 mysql client: Unclear description of batch mode
Submitted: 7 Apr 2009 8:13 Modified: 7 Apr 2009 8:28
Reporter: Jørgen Austvik Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:4.1, 5.0, 5,1, 6.0 bzr OS:Any
Assigned to: CPU Architecture:Any

[7 Apr 2009 8:13] Jørgen Austvik
Description:
----8<--------8<--------8<--------8<----
4.5.1.1. mysql Options:

--batch 	batch 	Don't use history file

--execute=statement, -e statement

Execute the statement and quit. The default output format is like that produced with --batch.

--tee=file_name

Append a copy of output to the given file. This option does not work in batch mode
----8<--------8<--------8<--------8<----

If you look in mysql.cc source code, you will see that:

----8<--------8<--------8<--------8<----
case 'e':
    status.batch= 1;
----8<--------8<--------8<--------8<----

...and...

----8<--------8<--------8<--------8<----
if (status.batch) /* disable pager and outfile in this case */
----8<--------8<--------8<--------8<----

...so the text about "The default output format is like that produced with --batch." is too mild. It turns on --batch mode.

How to repeat:
See bug#44126

Suggested fix:
Change doc to say that --execute implies --batch.

(Or much better: separate output format from whether or not it is possible to write to file in mysql client, and separate output format from how you get the SLQ (cat/-e/interactive) see bug#44126)
[7 Apr 2009 8:28] Sveta Smirnova
Thank you for the report.

Verified as described.

Also I think "--batch 	batch 	Don't use history file" is confusing.

Additionally default output is not as with --batch used:

$mysql -e "select 1, 2" --batch
1       2
1       2

$mysql -e "select 1, 2" 
+---+---+
| 1 | 2 |
+---+---+
| 1 | 2 | 
+---+---+

$mysql --version
/Users/apple/Applications/mysql-5.1/bin/mysql  Ver 14.14 Distrib 5.1.35, for apple-darwin8.11.1 (i386) using readline 5.1

While we have in client/mysql.cc:

1667   case 'e':
1668     status.batch= 1;
1669     status.add_to_history= 0;
[15 Apr 2009 8:01] Sveta Smirnova
Category changed, because user manual relies here on output of mysql --help which needs to be fixed. Change to Docs bug again after fix of mysql --help output.