Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-33271

mysql client: auto-vertical-output interferes with --batch mode

    XMLWordPrintable

Details

    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

      Attachments

        Activity

          People

            greenman Ian Gilfillan
            miketh Mike Thompson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.