Percona's mysql client horizontally wraps long queries, how to disable

Howdy folks.

With Percona 8.0.34-26’s mysql client, queries that are longer than the terminal width get horizontally wrapped rather than vertically wrapped when pulling them from history with the up arrow. I cannot find a way to turn this off, and it’s really frustrating. The normal mysql client that ships with ubuntu/debian does not appear to do this.

It’s maybe related to Percona’s mysql linking to its own libreadline / libncurses, but I’m not sure.

Does anyone know how to turn off this behaviour?

Thanks.

Hi @alh,

This is indeed due to your readline configuration. You can test the following:

echo "set horizontal-scroll-mode off" >> ~/.inputrc

And then connect using the mysql client again. This should solve your issues.

Check if there is anything in an alreadly-existing .inputrc file, maybe, that’s overriding the default behavior in the environment where you set up your Percona Server.

I wish that were so. But this does not happen with the debian mysql client, only with the percona mysql client, and changing this setting has no affect on it.

FWIW it’s repeatable (for me) by downloading https://downloads.percona.com/downloads/Percona-Server-LATEST/Percona-Server-8.0.34-26/binary/tarball/Percona-Server-8.0.34-26-Linux.x86_64.glibc2.17-minimal.tar.gz, unpacking it, and running ./bin/mysql

Strange. I tried with that binary also, and still can’t reproduce. I’m testing on Rocky linux 8.9.

I suggest you to try with strace, and compare a run using Percona Server one and another using the upstream one.

For example, use the binary you downloaded from Percona:

strace -f -s8192 -yy -ttt -o/tmp/run1_percona_server.out ./bin/mysql

CTRL-D or exit the client, and then try another run with upstream:

strace -f -s8192 -yy -ttt -o/tmp/run2_upstream.out mysql

I would grep by the configuration name I sent above. If you get nothing from it, then I would inspect which files are being read to see if any of them have leads on this.

Quick test from my side:

[root@node0 /]# echo "set horizontal-scroll-mode off" > ~/.inputrc
[root@node0 /]# strace -f -s8192 -yy -ttt -o/tmp/run1_percona_server.out mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 22
Server version: 8.0.34-26 Percona Server (GPL), Release 26, Revision 0fe62c85
...output trimmed...
mysql> exit
[root@node0 /]# cat /tmp/run1_percona_server.out | grep horizontal
5870  1732243884.467454 read(4</root/.inputrc>, "set horizontal-scroll-mode off\n", 31) = 31
[root@node0 /]# echo "set horizontal-scroll-mode on" > ~/.inputrc
[root@node0 /]# strace -f -s8192 -yy -ttt -o/tmp/run2_percona_server.out mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 23
Server version: 8.0.34-26 Percona Server (GPL), Release 26, Revision 0fe62c85

Copyright (c) 2009-2023 Percona LLC and/or its affiliates
Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

<1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);^C
^C
mysql> exit
Bye
[root@node0 /]# cat /tmp/run2_percona_server.out | grep horizontal
5877  1732243972.545869 read(4</root/.inputrc>, "set horizontal-scroll-mode on\n", 30) = 30

Hope this helps.

Thanks, I’d tried strace before and found that inputrc is not being loaded. After some more playing I think I tracked down what’s going on - it’s related to which TERM my terminal is presenting as.

If I use rxvt-unicode (with TERM=rxvt-unicode-256color), inputrc isn’t even read. How bizarre.

So no inputrc is being applied (and so I would expect default non-horizontal-scrolling behaviour). It’s a bummer that the stock mysql client works, but the percona provided one doesn’t. The big differences here seem to be percona mysql’s use of libedit/libncurses perhaps.

With that in mind, by default on my Ubuntu system, both xterm and gnome-terminal behave incorrectly with percona, unless I set TERM=vte or TERM=xterm-color, etc…

This feels like a difference in behaviour to me that could be fixed in the percona mysql, since it’s not behaviour that’s there in mysql, but once we start talking termcaps/terminfo I’ll admit I really have no idea what’s going on.

Anyway thanks for the tip, it helped.

Cheers.

Ahah! Okay I’ve cracked it. The installed libcurses on my system searches all of:

  • /etc/terminfo/
  • /lib/terminfo/
  • /usr/share/terminfo/

On Debian/Ubuntu, most of the terminfo files appear to be in /lib/terminfo

The percona mysql only searches:

  • /etc/terminfo/
  • /usr/share/terminfo/

So it’s not finding any of the terminfo data, and so horizontal scroll is being used instead of the expected vertical scroll!

This fixes it for me:

TERMINFO_DIRS=/etc/terminfo:/lib/terminfo:/usr/share/terminfo ./bin/mysql ...

Awesome detective work! :slight_smile:

You can submit a bug for it, referencing this thread.

Thanks, I’ve filed Jira

Hi @alh,

Could you clarify which operating system is used for your environment?
The mentioned tarball is build on RedHat but you referred Debian/Ubuntu in the last reply.

It’s on Debian Bookworm

Annoyingly, my fix works for TERM=“rxvt-unicode-256color” but not TERM=“xterm-256color” even though there is a terminfo file for xterm-256color…