0

I have a table that stores Windows system paths. I am scratching my head about how to store them and in particular which collation to use.

The paths are unicode strings. They are case insensitive, therefore 'utf8_binis probably not the best thing to do. However all theutf8_*_ci` collations allows equality between strings corresponding to different paths.

I am aware that path comparison is generally much more involved that string comparison, due to the potential presence of parent (..) directories, symbolic links, 8.3 alternative naming, aso. I am assuming that the folders are input in a systematically consistent fashion.

What do people do when storing paths? Do they assume that folders are indeed always stored in a consistent fashion and say always store Windows paths in lower or upper case and use utf8_general? Or another collation? Or simply forget about the idea of using server-side path comparison?

7
  • Look for character_set_filesystem variable value. However all the utf8_*_ci collations allows equality between strings corresponding to different paths. This depends of OS file requestor settings. And it may use collation unknows to MySQL.
    – Akina
    Commented Jan 29, 2020 at 20:25
  • Please give an example of where "theutf8_*_ci` collations allows equality between strings corresponding to different paths"
    – Rick James
    Commented Jan 31, 2020 at 2:48
  • Be aware that backslash is, in some contexts, an escape character, not a path delimiter.
    – Rick James
    Commented Jan 31, 2020 at 2:49
  • Are you storing full paths? Or storing directory names, plus "parent", etc to build a hierarchical tree?
    – Rick James
    Commented Jan 31, 2020 at 2:51
  • @RickJames I am stocking full paths. "utf8_*_ci" would not work because "a" and "à" would be considered a match although there can be two distinct directories with those names.
    – user209974
    Commented Jan 31, 2020 at 8:57

1 Answer 1

1

Not until MySQL 8.0 is there a "case-insensitive, accent-sensitive" collation:

mysql> set names utf8mb4 collate utf8mb4_0900_as_ci;
Query OK, 0 rows affected (0.00 sec)

mysql> select 'a'='A', "a" = "à" ;
+---------+------------+
| 'a'='A' | "a" = "à"  |
+---------+------------+
|       1 |          0 |
+---------+------------+
1 row in set (0.00 sec)
2
  • Thanks. Unfortunately, there is no equivalent in MariaDB, although I found this blog post about adding a custom collation -- I am not sure I want to go through all this trouble though.
    – user209974
    Commented Feb 6, 2020 at 12:50
  • @user209974 - You could also file a bug with jira.mariadb.com
    – Rick James
    Commented Feb 6, 2020 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.