Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-3975

SELECT DISTINCT may return duplicates with territory-based collation

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 10.3.1.4, 10.4.2.0
    • 10.3.3.1, 10.4.2.1, 10.5.1.1
    • SQL
    • None
    • Wrong query result

    Description

      I defined my own locale (en_US_aisb) where the collation rules said that a=b. When I tried queries with SELECT DISTINCT, they didn't always eliminate all duplicates. Here's an example:

      ij> connect 'jdbc:derby:db;create=true;territory=en_US_aisb;collation=TERRITORY_BASED';
      ij> create table t (x varchar(10));
      0 rows inserted/updated/deleted
      ij> insert into t values 'a','b','abba','baab','ABBA';
      5 rows inserted/updated/deleted
      ij> select distinct * from t;
      X
      ----------
      ABBA
      b
      a
      abba

      4 rows selected
      ij> select distinct * from t order by x;
      X
      ----------
      a
      abba
      ABBA

      3 rows selected

      The first query did eliminate the duplicate "abba"/"baab", but it did not eliminate the duplicate "a"/"b". When an ORDER BY clause was added (the second query), all the duplicates were eliminated.

      Attachments

        1. AisBCollatorProvider.java
          0.5 kB
          Knut Anders Hatlen
        2. derby-3975-1a.diff
          8 kB
          Knut Anders Hatlen
        3. derby-3975-1a.stat
          0.4 kB
          Knut Anders Hatlen

        Activity

          People

            knutanders Knut Anders Hatlen
            knutanders Knut Anders Hatlen
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: