mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 00:52:02 +00:00
8c3417fbf7
* Integrated CachingAllocator into MarkCache * fixed build errors * reset func hotfix * upd: Fixing build * updated submodules links * fix 2 * updating grabber allocator proto * updating lost work * updating CMake to use concepts * some other changes to get it building (integration into MarkCache) * further integration into caches * updated Async metrics, fixed some build errors * and some other errors revealing * added perfect forwarding to some functions * fix: forward template * fix: constexpr modifier * fix: FakePODAllocator missing member func * updated PODArray constructor taking alloc params * fix: PODArray overload with n restored * fix: FakePODAlloc duplicating alloc() func * added constexpr variable for alloc_tag_t * split cache values by allocators, provided updates * fix: memcpy * fix: constexpr modifier * fix: noexcept modifier * fix: alloc_tag_t for PODArray constructor * fix: PODArray copy ctor with different alloc * fix: resize() signature * updating to lastest working master * syncing with 273267 * first draft version * fix: update Searcher to case-insensitive * added ILIKE test * fixed style errors, updated test, split like and ilike, added notILike * replaced inconsistent comments * fixed show tables ilike * updated missing test cases * regenerated ya.make * Update 01355_ilike.sql Co-authored-by: myrrc <me-clickhouse@myrrec.space> Co-authored-by: alexey-milovidov <milovidov@yandex-team.ru>
65 lines
1.5 KiB
C++
65 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <Core/Types.h>
|
|
|
|
namespace DB
|
|
{
|
|
|
|
/// Transforms the [I]LIKE expression into regexp re2. For example, abc%def -> ^abc.*def$
|
|
inline String likePatternToRegexp(const String & pattern)
|
|
{
|
|
String res;
|
|
res.reserve(pattern.size() * 2);
|
|
const char * pos = pattern.data();
|
|
const char * end = pos + pattern.size();
|
|
|
|
if (pos < end && *pos == '%')
|
|
++pos;
|
|
else
|
|
res = "^";
|
|
|
|
while (pos < end)
|
|
{
|
|
switch (*pos)
|
|
{
|
|
case '^': case '$': case '.': case '[': case '|': case '(': case ')': case '?': case '*': case '+': case '{':
|
|
res += '\\';
|
|
res += *pos;
|
|
break;
|
|
case '%':
|
|
if (pos + 1 != end)
|
|
res += ".*";
|
|
else
|
|
return res;
|
|
break;
|
|
case '_':
|
|
res += ".";
|
|
break;
|
|
case '\\':
|
|
++pos;
|
|
if (pos == end)
|
|
res += "\\\\";
|
|
else
|
|
{
|
|
if (*pos == '%' || *pos == '_')
|
|
res += *pos;
|
|
else
|
|
{
|
|
res += '\\';
|
|
res += *pos;
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
res += *pos;
|
|
break;
|
|
}
|
|
++pos;
|
|
}
|
|
|
|
res += '$';
|
|
return res;
|
|
}
|
|
|
|
}
|