Fix whitespace in canonicalized queries
Trailing whitespace was not removed and whitespace wasn't normalized to spaces.
This commit is contained in:
@ -1459,9 +1459,16 @@ std::string get_canonical(GWBUF* querybuf)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (is_space(*it) && (i == 0 || is_space(rval[i - 1])))
|
else if (is_space(*it))
|
||||||
{
|
{
|
||||||
// Repeating space, skip it
|
if (i == 0 || is_space(rval[i - 1]))
|
||||||
|
{
|
||||||
|
// Leading or repeating whitespace, skip it
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rval[i++] = ' ';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (*it == '/' && is_next(it, buf.end(), "/*"))
|
else if (*it == '/' && is_next(it, buf.end(), "/*"))
|
||||||
{
|
{
|
||||||
@ -1565,6 +1572,12 @@ std::string get_canonical(GWBUF* querybuf)
|
|||||||
mxb_assert(it != buf.end());
|
mxb_assert(it != buf.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove trailing whitespace
|
||||||
|
while (i > 0 && is_space(rval[i - 1]))
|
||||||
|
{
|
||||||
|
--i;
|
||||||
|
}
|
||||||
|
|
||||||
// Shrink the buffer so that the internal bookkeeping of std::string remains up to date
|
// Shrink the buffer so that the internal bookkeeping of std::string remains up to date
|
||||||
rval.resize(i);
|
rval.resize(i);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user