mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Allow LIKE over binary data
This commit is contained in:
parent
ba6f0431a5
commit
1326bffe60
@ -496,6 +496,14 @@ OptimizedRegularExpression::OptimizedRegularExpression(const std::string & regex
|
||||
regexp_options.set_dot_nl(true);
|
||||
|
||||
re2 = std::make_unique<re2::RE2>(regexp_, regexp_options);
|
||||
|
||||
/// Fallback to latin1 to allow matching binary data.
|
||||
if (!re2->ok() && re2->error_code() == re2::RE2::ErrorCode::ErrorBadUTF8)
|
||||
{
|
||||
regexp_options.set_encoding(re2::RE2::Options::EncodingLatin1);
|
||||
re2 = std::make_unique<re2::RE2>(regexp_, regexp_options);
|
||||
}
|
||||
|
||||
if (!re2->ok())
|
||||
{
|
||||
throw DB::Exception(DB::ErrorCodes::CANNOT_COMPILE_REGEXP,
|
||||
|
24
tests/queries/0_stateless/02886_binary_like.reference
Normal file
24
tests/queries/0_stateless/02886_binary_like.reference
Normal file
@ -0,0 +1,24 @@
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
0
|
||||
0
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
0
|
||||
0
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
0
|
||||
0
|
||||
1
|
26
tests/queries/0_stateless/02886_binary_like.sql
Normal file
26
tests/queries/0_stateless/02886_binary_like.sql
Normal file
@ -0,0 +1,26 @@
|
||||
SELECT 'aяb' LIKE 'a_b';
|
||||
SELECT 'a\0b' LIKE 'a_b';
|
||||
SELECT 'a\0b' LIKE 'a\0b';
|
||||
SELECT 'a\0b' LIKE 'a%\0b';
|
||||
SELECT 'a\xFFb' LIKE 'a%\xFFb';
|
||||
SELECT 'a\xFFb' LIKE 'a%\xFF\xFEb';
|
||||
SELECT 'a\xFFb' LIKE '%a\xFF\xFEb';
|
||||
SELECT 'a\xFF\xFEb' LIKE '%a\xFF\xFEb';
|
||||
|
||||
SELECT materialize('aяb') LIKE 'a_b';
|
||||
SELECT materialize('a\0b') LIKE 'a_b';
|
||||
SELECT materialize('a\0b') LIKE 'a\0b';
|
||||
SELECT materialize('a\0b') LIKE 'a%\0b';
|
||||
SELECT materialize('a\xFFb') LIKE 'a%\xFFb';
|
||||
SELECT materialize('a\xFFb') LIKE 'a%\xFF\xFEb';
|
||||
SELECT materialize('a\xFFb') LIKE '%a\xFF\xFEb';
|
||||
SELECT materialize('a\xFF\xFEb') LIKE '%a\xFF\xFEb';
|
||||
|
||||
SELECT materialize('aяb') LIKE materialize('a_b');
|
||||
SELECT materialize('a\0b') LIKE materialize('a_b');
|
||||
SELECT materialize('a\0b') LIKE materialize('a\0b');
|
||||
SELECT materialize('a\0b') LIKE materialize('a%\0b');
|
||||
SELECT materialize('a\xFFb') LIKE materialize('a%\xFFb');
|
||||
SELECT materialize('a\xFFb') LIKE materialize('a%\xFF\xFEb');
|
||||
SELECT materialize('a\xFFb') LIKE materialize('%a\xFF\xFEb');
|
||||
SELECT materialize('a\xFF\xFEb') LIKE materialize('%a\xFF\xFEb');
|
Loading…
Reference in New Issue
Block a user