dbms: fixed error [#METR-15387].

This commit is contained in:
Alexey Milovidov 2015-04-03 19:16:02 +03:00
parent e267ba87f0
commit f1dc2f4775
5 changed files with 51 additions and 6 deletions

View File

@ -395,14 +395,21 @@ struct MatchImpl
if (required_substring.empty())
{
size_t prev_offset = 0;
for (size_t i = 0; i < size; ++i)
if (!regexp->getRE2()) /// Пустой регексп. Всегда матчит.
{
res[i] = revert ^ regexp->getRE2()->Match(
re2_st::StringPiece(reinterpret_cast<const char *>(&data[prev_offset]), offsets[i] - prev_offset - 1),
0, offsets[i] - prev_offset - 1, re2_st::RE2::UNANCHORED, nullptr, 0);
memset(&res[0], 1, size * sizeof(res[0]));
}
else
{
size_t prev_offset = 0;
for (size_t i = 0; i < size; ++i)
{
res[i] = revert ^ regexp->getRE2()->Match(
re2_st::StringPiece(reinterpret_cast<const char *>(&data[prev_offset]), offsets[i] - prev_offset - 1),
0, offsets[i] - prev_offset - 1, re2_st::RE2::UNANCHORED, nullptr, 0);
prev_offset = offsets[i];
prev_offset = offsets[i];
}
}
}
else

View File

@ -0,0 +1,2 @@
1
1

View File

@ -0,0 +1,2 @@
SELECT match(materialize('Hello'), '');
SELECT match('Hello', '');

View File

@ -0,0 +1,16 @@
0
1
1
1
1
0
1
1
0
1
1
1
1
0
1
1

View File

@ -0,0 +1,18 @@
SELECT materialize('Hello') LIKE '';
SELECT materialize('Hello') LIKE '%';
SELECT materialize('Hello') LIKE '%%';
SELECT materialize('Hello') LIKE '%%%';
SELECT materialize('Hello') LIKE '%_%';
SELECT materialize('Hello') LIKE '_';
SELECT materialize('Hello') LIKE '_%';
SELECT materialize('Hello') LIKE '%_';
SELECT 'Hello' LIKE '';
SELECT 'Hello' LIKE '%';
SELECT 'Hello' LIKE '%%';
SELECT 'Hello' LIKE '%%%';
SELECT 'Hello' LIKE '%_%';
SELECT 'Hello' LIKE '_';
SELECT 'Hello' LIKE '_%';
SELECT 'Hello' LIKE '%_';