Fix special case of trivial regexp

Previously, we would alsays set 1 in case of a trivial regex (which is
correct). If someone in future builds a negated operator, then this
will produce wrong results. Right now, negation of regexp (SQL: NOT
MATCH) is implemented at a higher level, so we are safe and this is more
a preventive fix.
This commit is contained in:
Robert Schulze 2022-05-24 22:59:48 +02:00
parent 01ab7b9bad
commit 05e4fa7df1
No known key found for this signature in database
GPG Key ID: 26703B55FB13728A

View File

@ -179,7 +179,7 @@ struct MatchImpl
if (!regexp->getRE2()) /// An empty regexp. Always matches.
{
if (haystack_size)
memset(res.data(), 1, haystack_size * sizeof(res[0]));
memset(res.data(), !negate, haystack_size * sizeof(res[0]));
}
else
{
@ -338,7 +338,7 @@ struct MatchImpl
if (!regexp->getRE2()) /// An empty regexp. Always matches.
{
if (haystack_size)
memset(res.data(), 1, haystack_size * sizeof(res[0]));
memset(res.data(), !negate, haystack_size * sizeof(res[0]));
}
else
{
@ -490,7 +490,7 @@ struct MatchImpl
{
if (!regexp.getRE2()) /// An empty regexp. Always matches.
{
res[i] = 1;
res[i] = !negate;
}
else
{
@ -604,7 +604,7 @@ struct MatchImpl
{
if (!regexp.getRE2()) /// An empty regexp. Always matches.
{
res[i] = 1;
res[i] = !negate;
}
else
{