mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-17 21:24:28 +00:00
skip spaces before and after \<letter> alias
... for proper single letter like `\l`, `\d` handling. Using `std::search()` for alias substring search instead of `.starts_with()` to get the alias start position, to check the leading range contains only space characters, and to get the rest of input after the space. See issue #9339
This commit is contained in:
parent
f4e3d053c2
commit
7b50ab7136
@ -1366,12 +1366,19 @@ void ClientBase::runInteractive()
|
||||
|
||||
for (const auto& [alias, command] : backslash_aliases)
|
||||
{
|
||||
if (input.starts_with(alias))
|
||||
auto it = std::search(input.begin(), input.end(), alias.begin(), alias.end());
|
||||
if (it != input.end() && std::all_of(input.begin(), it, isWhitespaceASCII))
|
||||
{
|
||||
// append the rest of input to the command
|
||||
// for parameters support, e.g. \c db_name -> USE db_name
|
||||
input = command + input.substr(alias.size());
|
||||
break;
|
||||
it += alias.size();
|
||||
if (it == input.end() || isWhitespaceASCII(*it))
|
||||
{
|
||||
String new_input = command;
|
||||
// append the rest of input to the command
|
||||
// for parameters support, e.g. \c db_name -> USE db_name
|
||||
new_input.append(it, input.end());
|
||||
input = std::move(new_input);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user