Skip to content

Commit 7c7c4a3

Browse files
committed
Fix non-ASCII column name case insensitivity
1 parent a55d3b9 commit 7c7c4a3

3 files changed

Lines changed: 21 additions & 5 deletions

File tree

core/src/main/java/io/questdb/client/std/AbstractLowerCaseAsciiCharSequenceHashSet.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ public void clear() {
5454
}
5555

5656
public int keyIndex(CharSequence key) {
57-
int index = Chars.lowerCaseAsciiHashCode(key) & mask;
57+
int index = Chars.lowerCaseHashCode(key) & mask;
5858

5959
if (keys[index] == noEntryKey) {
6060
return index;
6161
}
6262

63-
if (Chars.equalsLowerCaseAscii(key, keys[index])) {
63+
if (Chars.equalsIgnoreCase(key, keys[index])) {
6464
return -index - 1;
6565
}
6666

@@ -77,7 +77,7 @@ private int probe(CharSequence key, int index) {
7777
if (keys[index] == noEntryKey) {
7878
return index;
7979
}
80-
if (Chars.equalsLowerCaseAscii(key, keys[index])) {
80+
if (Chars.equalsIgnoreCase(key, keys[index])) {
8181
return -index - 1;
8282
}
8383
} while (true);

core/src/main/java/io/questdb/client/std/Chars.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,22 @@ public static boolean startsWith(CharSequence _this, char c) {
364364
return _this.length() > 0 && _this.charAt(0) == c;
365365
}
366366

367+
public static String toLowerCase(@Nullable CharSequence value) {
368+
if (value == null) {
369+
return null;
370+
}
371+
final int len = value.length();
372+
if (len == 0) {
373+
return "";
374+
}
375+
376+
final Utf16Sink b = Misc.getThreadLocalSink();
377+
for (int i = 0; i < len; i++) {
378+
b.put(Character.toLowerCase(value.charAt(i)));
379+
}
380+
return b.toString();
381+
}
382+
367383
public static String toLowerCaseAscii(@Nullable CharSequence value) {
368384
if (value == null) {
369385
return null;

core/src/main/java/io/questdb/client/std/LowerCaseAsciiCharSequenceIntHashMap.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ public boolean putAt(int index, CharSequence key, int value) {
6565
values[-index - 1] = value;
6666
return false;
6767
}
68-
putAt0(index, Chars.toLowerCaseAscii(key), value);
68+
putAt0(index, Chars.toLowerCase(key), value);
6969
return true;
7070
}
7171

7272
public void putIfAbsent(CharSequence key, int value) {
7373
int index = keyIndex(key);
7474
if (index > -1) {
75-
putAt0(index, Chars.toLowerCaseAscii(key), value);
75+
putAt0(index, Chars.toLowerCase(key), value);
7676
}
7777
}
7878

0 commit comments

Comments
 (0)