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

REPLACE() a string with NULL leads to unexpected result for non UTF-8 char sets

    XMLWordPrintable

    Details

      Description

      I expect both fields of the following query to be NULL, however only the utf8mb4_expected field actually is. Instead, the latin1_unexpected field returns the original string of foo, which is unexpected.

      SELECT
          REPLACE(convert('foo' using utf8mb4), convert('bar' using utf8mb4), null) as `utf8mb4_expected`,
          REPLACE(convert('foo' using latin1), convert('bar' using latin1), null) as `latin1_unexpected`;
      

      +------------------+------------------+
      | utf8mb4_expected | latin_unexpected |
      +------------------+------------------+
      | NULL             | foo              |
      +------------------+------------------+
      1 row in set (0.01 sec)
      

      This seems to be in issue in all versions of MariaDB and all versions of MySQL below 8.0.x (works on MySQL 8.0.21).

        Attachments

          Activity

            People

            Assignee:
            sanja Oleksandr Byelkin
            Reporter:
            lauxjpn Lau
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: