Skip to content

Weirdness around COLLATION between MariaDB 10.11 vs 11.6 #12

@restena-sw

Description

@restena-sw

Hello!

We have recently upgraded our MariaDB backend, which the sqlattribs module uses for getting user attributes.

It turned out that this major version upgrade introduced breakage inside the module, at an entirely unexpected place:

Not being in-depth into MariaDB, my understanding is that there used to be a default encoding for UTF-8 which used three bytes (utf8mb3) but that default changed in 11 towards a (more proper) four-byte representation, utf8mb4. As it is an upgrade, the existing DB remained on utf8mb3.

The concrete error we got was not on the referenced statement, which seemed to go okay, but on a subsequent query:

Caused by: SimpleSAML\Error\Exception: AttributeFromSQL: execute(value1, value2) failed: SQLSTATE[HY000]: General error: 1267 Illegal mix of collations (utf8mb3_general_ci,COERCIBLE) and (utf8mb3_uca1400_ai_ci,COERCIBLE) for operation '='

uca1400_ai_ci ? Nothing I've ever heard of.

What I can say is that the fix was a patch to the referenced line:

$db->exec("SET NAMES 'utf8'");
+$db->exec("SET NAMES 'utf8' COLLATE 'utf8mb3_general_ci'");

Not sure what the way forward here is. Adding a conditional check in the module to catch such utter weirdness? Or rather change our collations to utfmb4 so that it matches the default? Maybe the module documentation should have some advice in that regards.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions