Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-2481

NameSet assumes lowercase characters have greater codes, which does not hold for certain characters

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.17.0
    • Fix Version/s: 1.18.0
    • Component/s: core
    • Labels:
      None

      Description

        @Test public void lowerCaseWithLowerCode() {
          for (int i = 0; i < 0xffff; i++) {
            char c = (char) i;
            if (!Character.isLetter(c)) {
              continue;
            }
      
            char lc = Character.toLowerCase(c);
            char uc = Character.toUpperCase(c);
            if (lc < uc) {
              System.out.println(c + ": (" + ((int) lc) + ") " + lc + " < " + uc + " (" + ((int) uc) + ")");
            }
          }
        }
      
      µ: (181) µ < Μ (924)
      ÿ: (255) ÿ < Ÿ (376)
      İ: (105) i < İ (304)
      Ÿ: (255) ÿ < Ÿ (376)
      ƀ: (384) ƀ < Ƀ (579)
      ƕ: (405) ƕ < Ƕ (502)
      ƚ: (410) ƚ < Ƚ (573)
      ƞ: (414) ƞ < Ƞ (544)
      ƿ: (447) ƿ < Ƿ (503)
      Ƕ: (405) ƕ < Ƕ (502)
      Ƿ: (447) ƿ < Ƿ (503)
      Ƞ: (414) ƞ < Ƞ (544)
      Ƚ: (410) ƚ < Ƚ (573)
      ȿ: (575) ȿ < Ȿ (11390)
      ɀ: (576) ɀ < Ɀ (11391)
      Ƀ: (384) ƀ < Ƀ (579)
      ɐ: (592) ɐ < Ɐ (11375)
      ɑ: (593) ɑ < Ɑ (11373)
      ɒ: (594) ɒ < Ɒ (11376)
      ɜ: (604) ɜ < Ɜ (42923)
      ɡ: (609) ɡ < Ɡ (42924)
      ɥ: (613) ɥ < Ɥ (42893)
      ɦ: (614) ɦ < Ɦ (42922)
      ɪ: (618) ɪ < Ɪ (42926)
      ɫ: (619) ɫ < Ɫ (11362)
      ɬ: (620) ɬ < Ɬ (42925)
      ɱ: (625) ɱ < Ɱ (11374)
      ɽ: (637) ɽ < Ɽ (11364)
      ʇ: (647) ʇ < Ʇ (42929)
      ʝ: (669) ʝ < Ʝ (42930)
      ʞ: (670) ʞ < Ʞ (42928)
      ͻ: (891) ͻ < Ͻ (1021)
      ͼ: (892) ͼ < Ͼ (1022)
      ͽ: (893) ͽ < Ͽ (1023)
      ϲ: (1010) ϲ < Ϲ (1017)
      ϴ: (952) θ < ϴ (1012)
      Ϲ: (1010) ϲ < Ϲ (1017)
      Ͻ: (891) ͻ < Ͻ (1021)
      Ͼ: (892) ͼ < Ͼ (1022)
      Ͽ: (893) ͽ < Ͽ (1023)
      ᲈ: (7304) ᲈ < Ꙋ (42570)
      ᵹ: (7545) ᵹ < Ᵹ (42877)
      ᵽ: (7549) ᵽ < Ᵽ (11363)
      ẞ: (223) ß < ẞ (7838)
      ἀ: (7936) ἀ < Ἀ (7944)
      ἁ: (7937) ἁ < Ἁ (7945)
      ἂ: (7938) ἂ < Ἂ (7946)
      ἃ: (7939) ἃ < Ἃ (7947)
      ἄ: (7940) ἄ < Ἄ (7948)
      ἅ: (7941) ἅ < Ἅ (7949)
      ἆ: (7942) ἆ < Ἆ (7950)
      ἇ: (7943) ἇ < Ἇ (7951)
      Ἀ: (7936) ἀ < Ἀ (7944)
      Ἁ: (7937) ἁ < Ἁ (7945)
      Ἂ: (7938) ἂ < Ἂ (7946)
      Ἃ: (7939) ἃ < Ἃ (7947)
      Ἄ: (7940) ἄ < Ἄ (7948)
      Ἅ: (7941) ἅ < Ἅ (7949)
      Ἆ: (7942) ἆ < Ἆ (7950)
      Ἇ: (7943) ἇ < Ἇ (7951)
      ἐ: (7952) ἐ < Ἐ (7960)
      ἑ: (7953) ἑ < Ἑ (7961)
      ἒ: (7954) ἒ < Ἒ (7962)
      ἓ: (7955) ἓ < Ἓ (7963)
      ἔ: (7956) ἔ < Ἔ (7964)
      ἕ: (7957) ἕ < Ἕ (7965)
      Ἐ: (7952) ἐ < Ἐ (7960)
      Ἑ: (7953) ἑ < Ἑ (7961)
      Ἒ: (7954) ἒ < Ἒ (7962)
      Ἓ: (7955) ἓ < Ἓ (7963)
      Ἔ: (7956) ἔ < Ἔ (7964)
      Ἕ: (7957) ἕ < Ἕ (7965)
      ἠ: (7968) ἠ < Ἠ (7976)
      ἡ: (7969) ἡ < Ἡ (7977)
      ἢ: (7970) ἢ < Ἢ (7978)
      ἣ: (7971) ἣ < Ἣ (7979)
      ἤ: (7972) ἤ < Ἤ (7980)
      ἥ: (7973) ἥ < Ἥ (7981)
      ἦ: (7974) ἦ < Ἦ (7982)
      ἧ: (7975) ἧ < Ἧ (7983)
      Ἠ: (7968) ἠ < Ἠ (7976)
      Ἡ: (7969) ἡ < Ἡ (7977)
      Ἢ: (7970) ἢ < Ἢ (7978)
      Ἣ: (7971) ἣ < Ἣ (7979)
      Ἤ: (7972) ἤ < Ἤ (7980)
      Ἥ: (7973) ἥ < Ἥ (7981)
      Ἦ: (7974) ἦ < Ἦ (7982)
      Ἧ: (7975) ἧ < Ἧ (7983)
      ἰ: (7984) ἰ < Ἰ (7992)
      ἱ: (7985) ἱ < Ἱ (7993)
      ἲ: (7986) ἲ < Ἲ (7994)
      ἳ: (7987) ἳ < Ἳ (7995)
      ἴ: (7988) ἴ < Ἴ (7996)
      ἵ: (7989) ἵ < Ἵ (7997)
      ἶ: (7990) ἶ < Ἶ (7998)
      ἷ: (7991) ἷ < Ἷ (7999)
      Ἰ: (7984) ἰ < Ἰ (7992)
      Ἱ: (7985) ἱ < Ἱ (7993)
      Ἲ: (7986) ἲ < Ἲ (7994)
      Ἳ: (7987) ἳ < Ἳ (7995)
      Ἴ: (7988) ἴ < Ἴ (7996)
      Ἵ: (7989) ἵ < Ἵ (7997)
      Ἶ: (7990) ἶ < Ἶ (7998)
      Ἷ: (7991) ἷ < Ἷ (7999)
      ὀ: (8000) ὀ < Ὀ (8008)
      ὁ: (8001) ὁ < Ὁ (8009)
      ὂ: (8002) ὂ < Ὂ (8010)
      ὃ: (8003) ὃ < Ὃ (8011)
      ὄ: (8004) ὄ < Ὄ (8012)
      ὅ: (8005) ὅ < Ὅ (8013)
      Ὀ: (8000) ὀ < Ὀ (8008)
      Ὁ: (8001) ὁ < Ὁ (8009)
      Ὂ: (8002) ὂ < Ὂ (8010)
      Ὃ: (8003) ὃ < Ὃ (8011)
      Ὄ: (8004) ὄ < Ὄ (8012)
      Ὅ: (8005) ὅ < Ὅ (8013)
      ὑ: (8017) ὑ < Ὑ (8025)
      ὓ: (8019) ὓ < Ὓ (8027)
      ὕ: (8021) ὕ < Ὕ (8029)
      ὗ: (8023) ὗ < Ὗ (8031)
      Ὑ: (8017) ὑ < Ὑ (8025)
      Ὓ: (8019) ὓ < Ὓ (8027)
      Ὕ: (8021) ὕ < Ὕ (8029)
      Ὗ: (8023) ὗ < Ὗ (8031)
      ὠ: (8032) ὠ < Ὠ (8040)
      ὡ: (8033) ὡ < Ὡ (8041)
      ὢ: (8034) ὢ < Ὢ (8042)
      ὣ: (8035) ὣ < Ὣ (8043)
      ὤ: (8036) ὤ < Ὤ (8044)
      ὥ: (8037) ὥ < Ὥ (8045)
      ὦ: (8038) ὦ < Ὦ (8046)
      ὧ: (8039) ὧ < Ὧ (8047)
      Ὠ: (8032) ὠ < Ὠ (8040)
      Ὡ: (8033) ὡ < Ὡ (8041)
      Ὢ: (8034) ὢ < Ὢ (8042)
      Ὣ: (8035) ὣ < Ὣ (8043)
      Ὤ: (8036) ὤ < Ὤ (8044)
      Ὥ: (8037) ὥ < Ὥ (8045)
      Ὦ: (8038) ὦ < Ὦ (8046)
      Ὧ: (8039) ὧ < Ὧ (8047)
      ὰ: (8048) ὰ < Ὰ (8122)
      ά: (8049) ά < Ά (8123)
      ὲ: (8050) ὲ < Ὲ (8136)
      έ: (8051) έ < Έ (8137)
      ὴ: (8052) ὴ < Ὴ (8138)
      ή: (8053) ή < Ή (8139)
      ὶ: (8054) ὶ < Ὶ (8154)
      ί: (8055) ί < Ί (8155)
      ὸ: (8056) ὸ < Ὸ (8184)
      ό: (8057) ό < Ό (8185)
      ὺ: (8058) ὺ < Ὺ (8170)
      ύ: (8059) ύ < Ύ (8171)
      ὼ: (8060) ὼ < Ὼ (8186)
      ώ: (8061) ώ < Ώ (8187)
      ᾀ: (8064) ᾀ < ᾈ (8072)
      ᾁ: (8065) ᾁ < ᾉ (8073)
      ᾂ: (8066) ᾂ < ᾊ (8074)
      ᾃ: (8067) ᾃ < ᾋ (8075)
      ᾄ: (8068) ᾄ < ᾌ (8076)
      ᾅ: (8069) ᾅ < ᾍ (8077)
      ᾆ: (8070) ᾆ < ᾎ (8078)
      ᾇ: (8071) ᾇ < ᾏ (8079)
      ᾈ: (8064) ᾀ < ᾈ (8072)
      ᾉ: (8065) ᾁ < ᾉ (8073)
      ᾊ: (8066) ᾂ < ᾊ (8074)
      ᾋ: (8067) ᾃ < ᾋ (8075)
      ᾌ: (8068) ᾄ < ᾌ (8076)
      ᾍ: (8069) ᾅ < ᾍ (8077)
      ᾎ: (8070) ᾆ < ᾎ (8078)
      ᾏ: (8071) ᾇ < ᾏ (8079)
      ᾐ: (8080) ᾐ < ᾘ (8088)
      ᾑ: (8081) ᾑ < ᾙ (8089)
      ᾒ: (8082) ᾒ < ᾚ (8090)
      ᾓ: (8083) ᾓ < ᾛ (8091)
      ᾔ: (8084) ᾔ < ᾜ (8092)
      ᾕ: (8085) ᾕ < ᾝ (8093)
      ᾖ: (8086) ᾖ < ᾞ (8094)
      ᾗ: (8087) ᾗ < ᾟ (8095)
      ᾘ: (8080) ᾐ < ᾘ (8088)
      ᾙ: (8081) ᾑ < ᾙ (8089)
      ᾚ: (8082) ᾒ < ᾚ (8090)
      ᾛ: (8083) ᾓ < ᾛ (8091)
      ᾜ: (8084) ᾔ < ᾜ (8092)
      ᾝ: (8085) ᾕ < ᾝ (8093)
      ᾞ: (8086) ᾖ < ᾞ (8094)
      ᾟ: (8087) ᾗ < ᾟ (8095)
      ᾠ: (8096) ᾠ < ᾨ (8104)
      ᾡ: (8097) ᾡ < ᾩ (8105)
      ᾢ: (8098) ᾢ < ᾪ (8106)
      ᾣ: (8099) ᾣ < ᾫ (8107)
      ᾤ: (8100) ᾤ < ᾬ (8108)
      ᾥ: (8101) ᾥ < ᾭ (8109)
      ᾦ: (8102) ᾦ < ᾮ (8110)
      ᾧ: (8103) ᾧ < ᾯ (8111)
      ᾨ: (8096) ᾠ < ᾨ (8104)
      ᾩ: (8097) ᾡ < ᾩ (8105)
      ᾪ: (8098) ᾢ < ᾪ (8106)
      ᾫ: (8099) ᾣ < ᾫ (8107)
      ᾬ: (8100) ᾤ < ᾬ (8108)
      ᾭ: (8101) ᾥ < ᾭ (8109)
      ᾮ: (8102) ᾦ < ᾮ (8110)
      ᾯ: (8103) ᾧ < ᾯ (8111)
      ᾰ: (8112) ᾰ < Ᾰ (8120)
      ᾱ: (8113) ᾱ < Ᾱ (8121)
      ᾳ: (8115) ᾳ < ᾼ (8124)
      Ᾰ: (8112) ᾰ < Ᾰ (8120)
      Ᾱ: (8113) ᾱ < Ᾱ (8121)
      Ὰ: (8048) ὰ < Ὰ (8122)
      Ά: (8049) ά < Ά (8123)
      ᾼ: (8115) ᾳ < ᾼ (8124)
      ῃ: (8131) ῃ < ῌ (8140)
      Ὲ: (8050) ὲ < Ὲ (8136)
      Έ: (8051) έ < Έ (8137)
      Ὴ: (8052) ὴ < Ὴ (8138)
      Ή: (8053) ή < Ή (8139)
      ῌ: (8131) ῃ < ῌ (8140)
      ῐ: (8144) ῐ < Ῐ (8152)
      ῑ: (8145) ῑ < Ῑ (8153)
      Ῐ: (8144) ῐ < Ῐ (8152)
      Ῑ: (8145) ῑ < Ῑ (8153)
      Ὶ: (8054) ὶ < Ὶ (8154)
      Ί: (8055) ί < Ί (8155)
      ῠ: (8160) ῠ < Ῠ (8168)
      ῡ: (8161) ῡ < Ῡ (8169)
      ῥ: (8165) ῥ < Ῥ (8172)
      Ῠ: (8160) ῠ < Ῠ (8168)
      Ῡ: (8161) ῡ < Ῡ (8169)
      Ὺ: (8058) ὺ < Ὺ (8170)
      Ύ: (8059) ύ < Ύ (8171)
      Ῥ: (8165) ῥ < Ῥ (8172)
      ῳ: (8179) ῳ < ῼ (8188)
      Ὸ: (8056) ὸ < Ὸ (8184)
      Ό: (8057) ό < Ό (8185)
      Ὼ: (8060) ὼ < Ὼ (8186)
      Ώ: (8061) ώ < Ώ (8187)
      ῼ: (8179) ῳ < ῼ (8188)
      Ω: (969) ω < Ω (8486)
      K: (107) k < K (8490)
      Å: (229) å < Å (8491)
      Ɫ: (619) ɫ < Ɫ (11362)
      Ᵽ: (7549) ᵽ < Ᵽ (11363)
      Ɽ: (637) ɽ < Ɽ (11364)
      Ɑ: (593) ɑ < Ɑ (11373)
      Ɱ: (625) ɱ < Ɱ (11374)
      Ɐ: (592) ɐ < Ɐ (11375)
      Ɒ: (594) ɒ < Ɒ (11376)
      Ȿ: (575) ȿ < Ȿ (11390)
      Ɀ: (576) ɀ < Ɀ (11391)
      Ᵹ: (7545) ᵹ < Ᵹ (42877)
      Ɥ: (613) ɥ < Ɥ (42893)
      Ɦ: (614) ɦ < Ɦ (42922)
      Ɜ: (604) ɜ < Ɜ (42923)
      Ɡ: (609) ɡ < Ɡ (42924)
      Ɬ: (620) ɬ < Ɬ (42925)
      Ɪ: (618) ɪ < Ɪ (42926)
      Ʞ: (670) ʞ < Ʞ (42928)
      Ʇ: (647) ʇ < Ʇ (42929)
      Ʝ: (669) ʝ < Ʝ (42930)
      

      Sample usage:

        @Test public void nameSetRange() {
          final NameSet names = new NameSet();
          names.range("ͼ", false);
        }
      java.lang.IllegalArgumentException: fromKey > toKey
      
      	at java.base/java.util.TreeMap$NavigableSubMap.<init>(TreeMap.java:1365)
      	at java.base/java.util.TreeMap$AscendingSubMap.<init>(TreeMap.java:1852)
      	at java.base/java.util.TreeMap.subMap(TreeMap.java:910)
      	at java.base/java.util.TreeSet.subSet(TreeSet.java:325)
      	at org.apache.calcite.util.NameSet.range(NameSet.java:92)
      	at org.apache.calcite.util.UtilTest.nameSetRange(UtilTest.java:2111)
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                julianhyde Julian Hyde
                Reporter:
                vladimirsitnikov Vladimir Sitnikov
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: