From 687bcf557ddce09959a241ecd408a5f66aa6e5a4 Mon Sep 17 00:00:00 2001 From: Tejasmadhukar Date: Sun, 2 Nov 2025 21:14:44 +0530 Subject: [PATCH 1/5] Implemented case-insensitivity for ASCII characters only --- core/vdbe/execute.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/vdbe/execute.rs b/core/vdbe/execute.rs index 00410e9e38..391d89ac28 100644 --- a/core/vdbe/execute.rs +++ b/core/vdbe/execute.rs @@ -9832,10 +9832,17 @@ fn construct_like_regex(pattern: &str) -> Regex { '%' => regex_pattern.push_str(".*"), '_' => regex_pattern.push('.'), ch => { - if regex_syntax::is_meta_character(c) { - regex_pattern.push('\\'); + if ch.is_ascii_alphabetic() { + regex_pattern.push('['); + regex_pattern.push(ch.to_ascii_lowercase()); + regex_pattern.push(ch.to_ascii_uppercase()); + regex_pattern.push(']'); + } else { + if regex_syntax::is_meta_character(c) { + regex_pattern.push('\\'); + } + regex_pattern.push(ch); } - regex_pattern.push(ch); } } } @@ -9843,7 +9850,6 @@ fn construct_like_regex(pattern: &str) -> Regex { regex_pattern.push('$'); RegexBuilder::new(®ex_pattern) - .case_insensitive(true) .dot_matches_new_line(true) .build() .unwrap() From f2f05b96a728ed0306d53df0005b5043daf768f6 Mon Sep 17 00:00:00 2001 From: Tejasmadhukar Date: Sun, 2 Nov 2025 21:25:39 +0530 Subject: [PATCH 2/5] Added test --- testing/like.test | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/testing/like.test b/testing/like.test index e813d6251e..63b94c79c2 100755 --- a/testing/like.test +++ b/testing/like.test @@ -138,3 +138,10 @@ do_execsql_test like-fn-esc-13 { do_execsql_test like-fn-esc-14 { SELECT like('abcXX', 'abcXX', 'X') } 0 + +do_execsql_test unicode-like-case-sensitivity-1 { + SELECT like('ä', 'Ä'); +} {0} +do_execsql_test unicode-like-case-sensitivity-2 { + SELECT like('a', 'A'); +} {1} From 4c32745bab9fbb8b2fe2506b508d091734d27bbb Mon Sep 17 00:00:00 2001 From: Tejasmadhukar Date: Tue, 18 Nov 2025 19:34:06 +0530 Subject: [PATCH 3/5] Limit Like(X,Y) case folding to ASCII Disable case folding for non-ASCII characters so they remain case-sensitive. --- core/vdbe/value.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/vdbe/value.rs b/core/vdbe/value.rs index 62dfccd27f..9e911bd7f3 100644 --- a/core/vdbe/value.rs +++ b/core/vdbe/value.rs @@ -1026,10 +1026,17 @@ pub fn construct_like_regex(pattern: &str) -> Regex { '%' => regex_pattern.push_str(".*"), '_' => regex_pattern.push('.'), ch => { - if regex_syntax::is_meta_character(c) { - regex_pattern.push('\\'); + if ch.is_ascii_alphabetic() { + regex_pattern.push('['); + regex_pattern.push(ch.to_ascii_lowercase()); + regex_pattern.push(ch.to_ascii_uppercase()); + regex_pattern.push(']'); + } else { + if regex_syntax::is_meta_character(c) { + regex_pattern.push('\\'); + } + regex_pattern.push(ch); } - regex_pattern.push(ch); } } } @@ -1037,7 +1044,6 @@ pub fn construct_like_regex(pattern: &str) -> Regex { regex_pattern.push('$'); RegexBuilder::new(®ex_pattern) - .case_insensitive(true) .dot_matches_new_line(true) .build() .unwrap() From 49101277964796ef486cc386b159a32a26d16bd1 Mon Sep 17 00:00:00 2001 From: Tejasmadhukar Date: Tue, 18 Nov 2025 22:09:31 +0530 Subject: [PATCH 4/5] patched LIKE(X,Y,Z) case-folding --- core/vdbe/likeop.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/vdbe/likeop.rs b/core/vdbe/likeop.rs index 894dfdf844..98e8d8598b 100644 --- a/core/vdbe/likeop.rs +++ b/core/vdbe/likeop.rs @@ -46,10 +46,17 @@ fn construct_like_regex_with_escape(pattern: &str, escape: char) -> Regex { '%' => regex_pattern.push_str(".*"), '_' => regex_pattern.push('.'), c => { - if regex_syntax::is_meta_character(c) { - regex_pattern.push('\\'); + if c.is_ascii_alphabetic() { + regex_pattern.push('['); + regex_pattern.push(c.to_ascii_lowercase()); + regex_pattern.push(c.to_ascii_uppercase()); + regex_pattern.push(']'); + } else { + if regex_syntax::is_meta_character(c) { + regex_pattern.push('\\'); + } + regex_pattern.push(c); } - regex_pattern.push(c); } } } @@ -57,7 +64,6 @@ fn construct_like_regex_with_escape(pattern: &str, escape: char) -> Regex { regex_pattern.push('$'); RegexBuilder::new(®ex_pattern) - .case_insensitive(true) .dot_matches_new_line(true) .build() .unwrap() From ebbe7bab9eae5249bc2e37720b0254a7b9c79971 Mon Sep 17 00:00:00 2001 From: Tejasmadhukar Date: Tue, 18 Nov 2025 22:14:09 +0530 Subject: [PATCH 5/5] Added tests --- testing/like.test | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/testing/like.test b/testing/like.test index 63b94c79c2..b051fed127 100755 --- a/testing/like.test +++ b/testing/like.test @@ -145,3 +145,9 @@ do_execsql_test unicode-like-case-sensitivity-1 { do_execsql_test unicode-like-case-sensitivity-2 { SELECT like('a', 'A'); } {1} +do_execsql_test unicode-like-with-escape-1 { + SELECT like('ÄX%', 'ä%', 'X'); +} {0} +do_execsql_test unicode-like-with-escape-2 { + SELECT like('ÄX%', 'Ä%', 'X'); +} {1}