| 203 | } |
| 204 | |
| 205 | bool DisksApp::processQueryText(const String & text) |
| 206 | { |
| 207 | if (text.find_first_not_of(word_break_characters) == std::string::npos) |
| 208 | { |
| 209 | return true; |
| 210 | } |
| 211 | if (exit_strings.contains(text)) |
| 212 | return false; |
| 213 | CommandPtr command; |
| 214 | |
| 215 | auto subqueries = splitOnUnquotedSemicolons(text); |
| 216 | for (const auto & subquery : subqueries) |
| 217 | { |
| 218 | std::optional<String> error_string; |
| 219 | // std::cerr << "SUBQUERY: " << subquery << "\n"; |
| 220 | try |
| 221 | { |
| 222 | auto arguments = po::split_unix(subquery, word_break_characters); |
| 223 | if (arguments.empty()) |
| 224 | continue; |
| 225 | command = getCommandByName(arguments[0]); |
| 226 | arguments.erase(arguments.begin()); |
| 227 | command->execute(arguments, *client); |
| 228 | } |
| 229 | catch (DB::Exception & err) |
| 230 | { |
| 231 | int code = err.code(); |
| 232 | error_string = getExceptionMessageForLogging(err, true, false); |
| 233 | if (code == ErrorCodes::BAD_ARGUMENTS) |
| 234 | { |
| 235 | if (command.get()) |
| 236 | { |
| 237 | std::cerr << "COMMAND: " << command->command_name << "\n"; |
| 238 | std::cerr << command->options_description << "\n"; |
| 239 | } |
| 240 | else |
| 241 | { |
| 242 | printAvailableCommandsHelpMessage(); |
| 243 | } |
| 244 | } |
| 245 | } |
| 246 | catch (std::exception & err) |
| 247 | { |
| 248 | error_string = err.what(); |
| 249 | } |
| 250 | catch (...) // Ok: report unknown exception |
| 251 | { |
| 252 | error_string = "Unknown exception"; |
| 253 | } |
| 254 | if (error_string.has_value()) |
| 255 | { |
| 256 | std::cerr << "Error: " << error_string.value() << "\n"; |
| 257 | LOG_ERROR(&Poco::Logger::root(), "{}", error_string.value()); |
| 258 | } |
| 259 | command = nullptr; |
| 260 | } |
| 261 | |
| 262 | return true; |
nothing calls this directly
no test coverage detected