MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / processQueryText

Method processQueryText

programs/disks/DisksApp.cpp:205–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203}
204
205bool 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;

Callers

nothing calls this directly

Calls 11

containsMethod · 0.45
emptyMethod · 0.45
eraseMethod · 0.45
beginMethod · 0.45
executeMethod · 0.45
codeMethod · 0.45
getMethod · 0.45
whatMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected