[MDEV-17088] Provide tools to encode/decode mysql-encoded file system names Created: 2018-08-29  Updated: 2020-02-27  Resolved: 2019-12-05

Status: Closed
Project: MariaDB Server
Component/s: Character Sets
Fix Version/s: 10.5.1

Type: Task Priority: Minor
Reporter: Hartmut Holzgraefe Assignee: Unassigned
Resolution: Fixed Votes: 1
Labels: beginner-friendly

Issue Links:
Relates
relates to MDEV-21825 Document mariadb-conv Closed
relates to MDEV-21228 Document mariadb-conv Closed

 Description   

As non-ASCII letters are encoded in database directory names and table file nasenames there should be tools that can be used to perform conversion to human-readable unicode output (and back from unicode to encoded form?), either as SQL function, command line tool, or both.

e.g. @6e2c@8a66@8cc7@6599@5eab' <-> 測試資料

See also:

and especially the comment from HeidiSQL on the later one.



 Comments   
Comment by Marko Mäkelä [ 2018-08-29 ]

I believe that this is a documentation issue, not a code bug.

The CONVERT function with the filename character set should already do the trick:

SET NAMES utf8;
SELECT CONVERT(CONVERT('測試資料' USING filename) USING binary),
CONVERT(_filename '@6e2c@8a66@8cc7@6599@5eab' USING utf8);

It will return the conversion:

@6e2c@8a66@8cc7@6599	測試資料庫

Note: these strings are from the description. The hexadecimal string had 5 encoded 5-byte characters, while the UTF-8 string only has 4 characters corresponding to the 4 first 5-byte characters.

Comment by Hartmut Holzgraefe [ 2018-08-29 ]

Ok, that covers the SQL level part, but I still think we should have some binary tool, maybe a "myls", to be able to do the conversion on the command line without having to fall back to mysql -e 'SELECT CONVERT ...'

Shouldn't be too hard to create a simple wrapper binary around the strconvert() function?

Comment by Sergei Golubchik [ 2018-08-29 ]

I've documented the filename charset in https://mariadb.com/kb/en/library/identifier-to-file-name-mapping/

Let's keep this issue open until a tool is created. But it should be a Task, not a Bug.

Comment by Takashi Sasaki [ 2018-10-14 ]

Is it a simple wrapper command that calls an existing function?
So I'll work on this for my first contribution.

example:
terminal$ myls "測試資料"
@6e2c@8a66@8cc7@6599
terminal$ myls -r "@6e2c@8a66@8cc7@6599@5eab"
測試資料庫

Generated at Thu Feb 08 08:33:49 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.