Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-36849

'Illegal mix of collations' is raised instead of 'Invalid utf8mb3 character string'

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.5(EOL), 12.0(EOL)
    • 10.6
    • Character Sets
    • None

    Description

      I run this query intentionally injecting a bad utf8 byte sequence into the query body:

      EXECUTE IMMEDIATE REPLACE("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES"
                                " WHERE TABLE_NAME LIKE 't20xBEBE'",
                                '0xBEBE', 0xBEBE);
      

      It returns a confusing error:

      ERROR 1267 (HY000): Illegal mix of collations (utf8mb3_general_ci,IMPLICIT) and (utf8mb4_uca1400_ai_ci,COERCIBLE) for operation 'like'
      

      It's true that the constant cannot be converted to utf8mb3, so utf8mb3_general_ci cannot be used for comparison in LIKE.

      However, the error should be raised earlier, even before mixing collations for comparison.

      ER_INVALID_CHARACTER_STRING would be fine, like the one raised in this query:

      SELECT _utf8mb3 0xBEBE;
      

      ERROR 1300 (HY000): Invalid utf8mb3 character string: 'BEBE'
      

      The misleading error message makes it hard to debug user programs when a user program erroneously added wrong bytes, e.g. using snprintf() or similar function.

      Attachments

        Activity

          People

            bar Alexander Barkov
            bar Alexander Barkov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.