Skip to content

Commit 23c6700

Browse files
committed
fix: WASM filterStringLike case sensitivity — use sqlLikeMatch instead of sqlLikeMatchCI
SQL LIKE is case-sensitive per standard. The JS evaluator (compileLikeRegex) was fixed in aec0ced but the WASM export still called sqlLikeMatchCI (case-insensitive), creating an inconsistency between JS and WASM paths. Changed filterStringLike to call sqlLikeMatch (case-sensitive) and removed the now-dead sqlLikeMatchCI and toLowerASCII functions.
1 parent 1e3db7c commit 23c6700

File tree

1 file changed

+1
-39
lines changed

1 file changed

+1
-39
lines changed

wasm/src/wasm/aggregates.zig

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -952,45 +952,7 @@ fn sqlLikeMatch(str: []const u8, pattern: []const u8) bool {
952952
return true;
953953
}
954954

955-
/// Case-insensitive SQL LIKE match
956-
fn sqlLikeMatchCI(str: []const u8, pattern: []const u8) bool {
957-
var si: usize = 0;
958-
var pi: usize = 0;
959-
var star_pi: usize = pattern.len;
960-
var star_si: usize = 0;
961-
962-
while (si < str.len or pi < pattern.len) {
963-
if (pi < pattern.len) {
964-
if (pattern[pi] == '%') {
965-
star_pi = pi;
966-
star_si = si;
967-
pi += 1;
968-
continue;
969-
}
970-
if (si < str.len) {
971-
const sc = toLowerASCII(str[si]);
972-
const pc = toLowerASCII(pattern[pi]);
973-
if (pc == '_' or sc == pc) {
974-
si += 1;
975-
pi += 1;
976-
continue;
977-
}
978-
}
979-
}
980-
if (star_pi < pattern.len) {
981-
pi = star_pi + 1;
982-
star_si += 1;
983-
si = star_si;
984-
continue;
985-
}
986-
return false;
987-
}
988-
return true;
989-
}
990955

991-
inline fn toLowerASCII(c: u8) u8 {
992-
return if (c >= 'A' and c <= 'Z') c + 32 else c;
993-
}
994956

995957
/// Filter string column with SQL LIKE pattern, returns matching indices.
996958
/// offsets_ptr[i] = byte offset of string i in data, offsets_ptr[count] = total data length.
@@ -1014,7 +976,7 @@ export fn filterStringLike(
1014976
const start = offsets_ptr[i];
1015977
const end = offsets_ptr[i + 1];
1016978
const str = data_ptr[start..end];
1017-
const matches = sqlLikeMatchCI(str, pattern);
979+
const matches = sqlLikeMatch(str, pattern);
1018980
if (matches != negate) {
1019981
out_indices[out_count] = @intCast(i);
1020982
out_count += 1;

0 commit comments

Comments
 (0)