Bug #49728 mysql client should not allow use of '--tee' or TEE when '-e' option is used
Submitted: 16 Dec 2009 3:26 Modified: 16 Dec 2009 3:33
Reporter: Roel Van de Paar (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:5.5.0m2, 5.1.41 OS:Any
Assigned to: CPU Architecture:Any
Triage: Triaged: D3 (Medium)

[16 Dec 2009 3:26] Roel Van de Paar
Description:
--tee=file.txt or TEE file.txt does not work when using -e (tee/TEE only works if the session is interactive.)

As such, an error should be given (and the mysql client should terminate without executing the command) when --tee or TEE is used together with -e.

There's also some incorrect messages being shown. Notice "Outfile disabled." and "Logging to file 'test.txt'" in the output below.

How to repeat:
roel@roel-ubuntu-vm:/mysql/mysql-5.5.0-m2-linux-i686-icc-glibc23$ ./bin/mysql -uroot -h127.0.0.1 -P5502 roelt -e "TEE test.txt;SELECT 1;SELECT 2;NOTEE;"
+---+
| 1 |
+---+
| 1 |
+---+
+---+
| 2 |
+---+
| 2 |
+---+
Outfile disabled.
roel@roel-ubuntu-vm:/mysql/mysql-5.5.0-m2-linux-i686-icc-glibc23$ cat test.txt
cat: test.txt: No such file or directory
roel@roel-ubuntu-vm:/mysql/mysql-5.5.0-m2-linux-i686-icc-glibc23$ ./bin/mysql -uroot -h127.0.0.1 -P5502 roelt -e "SELECT 1;SELECT 2;" --tee=test.txt
Logging to file 'test.txt'
+---+
| 1 |
+---+
| 1 |
+---+
+---+
| 2 |
+---+
| 2 |
+---+
roel@roel-ubuntu-vm:/mysql/mysql-5.5.0-m2-linux-i686-icc-glibc23$ cat test.txt
roel@roel-ubuntu-vm:/mysql/mysql-5.5.0-m2-linux-i686-icc-glibc23$ rm test.txt
roel@roel-ubuntu-vm:/mysql/mysql-5.5.0-m2-linux-i686-icc-glibc23$ ./bin/mysql -uroot -h127.0.0.1 -P5502 roelt -e "SELECT 1;SELECT 2;" > test.txt
roel@roel-ubuntu-vm:/mysql/mysql-5.5.0-m2-linux-i686-icc-glibc23$ cat test.txt
1
1
2
2

Suggested fix:
Produce an error and do not start mysql client if --tee or TEE is used.
[16 Dec 2009 3:33] Roel Van de Paar
Verifying as D3. Same happens on Windows.

An even better fix would be to fix tee/TEE so it works in non-interactive mode. Currently, there is no way to produce an output similar to tee/TEE in non-interactive mode. Especially having timing output (x.xx sec) would be great.