Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.6.11
-
None
-
Linux 6.1.19 on amd64
Description
A very welcome feature of the mysql CLI client, auto-vertical-output, has an unfortunate interaction with --batch mode of the client.
I am quite happy to have this as my ~/.my.cnf
[mysql]
|
auto-vertical-output
|
The unfortunate thing is that this setting interferes with the --batch mode of the client. The --batch mode is documented as writing result sets as a series of lines of tab-separated column values, one line per row--all prefixed by a line that contains tab-separated column names for the result set. I have a Bash script which happily ingests such result sets.
The trouble is that when auto-vertical-output is enabled in .my.cnf and the client judges the output table is going to be too wide for the tty (based on column widths that would be in force for normal horizontal mode), the not-for-human-consumption batch output is switched to vertical mode.
This query illustrates the problem:
SELECT RPAD("abc", 45) name; |
(This assumes the CLI window is at least 45 columns wide, a generally safe assumption.)
The MySQL client should write this result for the query regardless of the setting of auto-vertical-output:
name
|
ABC
|
Now if auto-vertical-output is enabled, changing the 45 in the above query to 500 will almost certainly give this result:
*************************** 1. row ***************************
|
name: ABC
|
This is a bug. Here are three ways to fix it--listed in descending order of preference:
- Make the client ignore the auto-vertical-output setting when --batch mode is in effect. (I haven't taken a look at the code but it looks like it would be an easy patch--and easy for me to try out since I use Gentoo Linux. I'd send you the patch if you want it.)
- Implement a --no-auto-vertical-output switch to override the setting of .my.cnf
- Implement a switch to allow the selection of a different .my.cnf or to disable the reading of .my.cnf