1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-02 17:22:27 +03:00

bug(funcexp): Fixes MCOL-5599 where LIKE operator never finishes (#3116)

This is a fix of logging subsystem, nothing else.

The old code expanded an argument into string and advanced too little
and, if expansion contained argument's index, it expanded it again. And
again.

Co-authored-by: Serguey Zefirov <serguey.zefirov@mariadb.com>
This commit is contained in:
Leonid Fedorov
2024-02-05 18:31:57 +03:00
committed by GitHub
parent 4a2c73780a
commit c46a0ab5f0
3 changed files with 31 additions and 2 deletions

View File

@ -40,16 +40,27 @@ void formatOne(std::string& errMsg, Iter iter, uint32_t position)
if (index == std::string::npos)
break;
size_t advance_length;
// below we can replace token with longer or shorter string.
// we should compute exact replacement length to prevent
// 1) recognizing token inside a replacement
// 2) not skipping token recognition if replacement is shorter.i
// regarding 1: the string is "%1%" and replacement is "aaaaa %1%".
// regarding 2: the string is "%1% %1%" and replacement is empty string.
if constexpr (std::is_same_v<T, std::string>)
{
advance_length = arg.length();
errMsg.replace(index, token.length(), arg);
}
else
{
advance_length = std::to_string(arg).length();
errMsg.replace(index, token.length(), std::to_string(arg));
}
index += token.length();
index += advance_length;
}
}
@ -89,4 +100,4 @@ void formatMany(std::string& errMsg, const T& args)
errMsg = std::regex_replace(errMsg, restToken, "");
}
} // namespace logging
} // namespace logging