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

Wrong result from index lookup on CHAR(n) when a longer constant is equal under a collation with expansions

    XMLWordPrintable

Details

    • Unexpected results

    Description

      In utf8mb4_german2_ci, 'ß' is equal to 'ss', so a CHAR ( 1 ) column holding 'ß' should match the constant 'ss'. However, an index lookup with that constant misses the row:

        SET NAMES utf8mb4;
        CREATE TABLE t1 (v CHAR(1) COLLATE utf8mb4_german2_ci, KEY(v));
        INSERT INTO t1 VALUES ('ß'),('s'),('x');
        SELECT v FROM t1 WHERE v = 'ss';
        DROP TABLE t1;
        

      The query returns an empty set. It should return ß.

      PostgreSQL 18.1 returns ß for the equivalent case. It uses a nondeterministic ICU collation at primary strength, under which 'ß' equals 'ss'. Turning
      off enable_seqscan makes the planner use the index on a table this small.

        CREATE COLLATION de_ss (provider = icu, locale = 'de-u-ks-level1',
                                deterministic = false);
        CREATE TABLE t1 (v char(1) COLLATE de_ss);
        CREATE INDEX ON t1 (v);
        INSERT INTO t1 VALUES ('ß'), ('s'), ('x');
        SET enable_seqscan = off;
        SELECT v FROM t1 WHERE v = 'ss';
        DROP TABLE t1;
        DROP COLLATION de_ss;
        

      Attachments

        Activity

          People

            Unassigned Unassigned
            Gosselin Dave Gosselin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0d
                0d
                Logged:
                Time Spent - 1h
                1h

                Git Integration

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