0

I have this rather inconvenient problem with mysql console client, the column widths in display are broken for non-latin characters, i.e. mysql makes the column 1.5 times wider than it needs to be for Chinese characters, Cyrillic is even worse, the column is twice as wide as it needs to be, i.e. for a string 100 characters wide, the column width will be 200 characters which makes the output absolute mess really. Is there a way to fix this? I tried to use -r -s and \P but I could not get anything suitable.

See the example below, note how abc column is exactly as wide as the string RRRRRRR plus two margin characters, and how zh and cyr are incorrectly padded as if the input contained invisible spaces.

 select '你好你好' as zh, 'RRRRRRR' as abc, 'ЯЯЯЯЯЯЯ' as cyr;
+--------------+---------+----------------+
| zh           | abc     | cyr            |
+--------------+---------+----------------+
| 你好你好     | RRRRRRR | ЯЯЯЯЯЯЯ        |
+--------------+---------+----------------+
Shadow
  • 33,525
  • 10
  • 51
  • 64
exebook
  • 32,014
  • 33
  • 141
  • 226
  • 1
    So what? The interactive CLI client is not intended to be used for applications, formatting is not a priority. – Barmar Dec 09 '22 at 22:10
  • @Barmar do you mean mysql console client is deprecated? What should I use for development and debugging then? – exebook Dec 09 '22 at 22:22
  • 1
    No, just that its formatting is very simple. It doesn't know anything about the appearance of the data. – Barmar Dec 09 '22 at 22:23
  • 1
    I tested your example query in the MySQL 8.0.31 client on MacOS, and the alignment of columns is not broken as you show it. But I have seen what you are describing in the past when using zero-width special characters. I agree with Barmar, ignore the weirdness of the mysql client. It's just for prototyping. Worry about formatting and alignment in your application presentation layer. – Bill Karwin Dec 09 '22 at 23:17

0 Answers0