Bug #44126 mysql client: Respect --tee and --pager when combined with -e
Submitted: 7 Apr 2009 8:00 Modified: 7 Apr 2009 8:29
Reporter: Jørgen Austvik Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S4 (Feature request)
Version:6.0-perf OS:Any
Assigned to: CPU Architecture:Any

[7 Apr 2009 8:00] Jørgen Austvik
Description:
The -e option to mysql turns on batch-mode, which make --tee and --pager stop working. E.g. --tee work when run interactively.

Having --tee and --pager work also when run not-interactively is good for scripting purposes.

How to repeat:
$ ../client/mysql -S var/tmp/mysqld.1.sock -u root --tee=./file.txt performance_schema
Logging to file './file.txt'
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 6.0.11-alpha-debug-log-perfschema Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> \q
Bye
$ ../client/mysql -S var/tmp/mysqld.1.sock -u root --tee=./file.txt performance_schema
$ cat file.txt 
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 6.0.11-alpha-debug-log-perfschema Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> \q
$ rm file.txt
$ ../client/mysql -S var/tmp/mysqld.1.sock -u root -e "SHOW TABLES" --tee=./file.txt performance_schema
Logging to file './file.txt'
+----------------------------------------------+
| Tables_in_performance_schema                 |
+----------------------------------------------+
| COND_INSTANCES                               | 
| EVENTS_WAITS_CURRENT                         | 
| EVENTS_WAITS_HISTORY                         | 
| EVENTS_WAITS_HISTORY_LONG                    | 
| EVENTS_WAITS_SUMMARY_BY_EVENT_NAME           | 
| EVENTS_WAITS_SUMMARY_BY_INSTANCE             | 
| EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME | 
| FILE_INSTANCES                               | 
| FILE_SUMMARY_BY_EVENT_NAME                   | 
| FILE_SUMMARY_BY_INSTANCE                     | 
| MUTEX_INSTANCES                              | 
| PERFORMANCE_TIMERS                           | 
| PROCESSLIST                                  | 
| RWLOCK_INSTANCES                             | 
| SETUP_CONSUMERS                              | 
| SETUP_INSTRUMENTS                            | 
| SETUP_OBJECTS                                | 
| SETUP_TIMERS                                 | 
+----------------------------------------------+
$ cat file.txt 
$

Also: cat'ing something to mysql client make --tee not work.

$ cat /tmp/agent.sql | ./mysql -h machine -P 56500 -u admin --password=... --tee=/tmp/test.log

Logging to file '/tmp/test.log'

Site    Port    Local   Hosts

mysite  56500   Local   nanna11

[ /opt/csw/mysql5/bin ]

$ cat /tmp/test.log

$

Suggested fix:
Stop disabling of pager and outfile in batch mode.
[7 Apr 2009 8:29] Valeriy Kravchuk
Thank you for the feature request.
[13 Aug 2009 9:23] Gabriel Hautclocq
I also think you should not disable outfile in batch mode ! I don't see the point to do such a thing. Currently it seems there is no means to use --execute="command" option together with --tee="logfile". That would be useful !