[MDEV-33271] mysql client: auto-vertical-output interferes with --batch mode Created: 2024-01-18  Updated: 2024-01-18

Status: Open
Project: MariaDB Server
Component/s: Documentation, Scripts & Clients
Affects Version/s: 10.6.11
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Mike Thompson Assignee: Ian Gilfillan
Resolution: Unresolved Votes: 0
Labels: None
Environment:

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


 Comments   
Comment by Sergei Golubchik [ 2024-01-18 ]

you can turn off any boolean option with skip- or disable- prefix. That is --disable-auto-vertical-output will do the trick. Or --skip-auto-vertical-output. Or --auto-vertical-output=0.

you can specify what config file to read with --defaults-file=/path/to/file, you can specify that no config file should be read with --no-defaults.

See https://mariadb.com/kb/en/mariadbd-options/#option-prefixes and https://mariadb.com/kb/en/mariadbd-options/#option-file-options

Comment by Sergei Golubchik [ 2024-01-18 ]

greenman, isn't it confusing that options common to all tools are listed under "mariadbd-options"? Perhaps there should be, like, "common options and option prefixes" page and all pages for tools and mariadbd should refer to it?

Generated at Thu Feb 08 10:37:40 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.