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

Method processOptions

programs/client/Client.cpp:862–1050  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

860
861
862void Client::processOptions(
863 const OptionsDescription & options_description,
864 const CommandLineOptions & options,
865 const std::vector<Arguments> & external_tables_arguments,
866 const std::vector<Arguments> & hosts_and_ports_arguments)
867{
868 namespace po = boost::program_options;
869
870 size_t number_of_external_tables_with_stdin_source = 0;
871 for (size_t i = 0; i < external_tables_arguments.size(); ++i)
872 {
873 /// Parse commandline options related to external tables.
874 po::parsed_options parsed_tables
875 = po::command_line_parser(external_tables_arguments[i]).options(options_description.external_description.value()).run();
876 po::variables_map external_options;
877 po::store(parsed_tables, external_options);
878
879 try
880 {
881 external_tables.emplace_back(external_options);
882 if (external_tables.back().file == "-")
883 ++number_of_external_tables_with_stdin_source;
884 if (number_of_external_tables_with_stdin_source > 1)
885 throw Exception(ErrorCodes::BAD_ARGUMENTS, "Two or more external tables has stdin (-) set as --file field");
886 }
887 catch (Exception & e)
888 {
889 std::cerr << getExceptionMessageForLogging(e, false) << std::endl;
890 std::cerr << "Table №" << i << std::endl << std::endl;
891 /// Avoid the case when error exit code can possibly overflow to normal (zero).
892 auto exit_code = e.code() % 256;
893 if (exit_code == 0)
894 exit_code = 255;
895 _exit(exit_code);
896 }
897 }
898
899 for (const auto & hosts_and_ports_argument : hosts_and_ports_arguments)
900 {
901 /// Parse commandline options related to external tables.
902 po::parsed_options parsed_hosts_and_ports
903 = po::command_line_parser(hosts_and_ports_argument).options(options_description.hosts_and_ports_description.value()).run();
904 po::variables_map host_and_port_options;
905 po::store(parsed_hosts_and_ports, host_and_port_options);
906 std::string host = host_and_port_options["host"].as<std::string>();
907 std::optional<UInt16> port
908 = !host_and_port_options["port"].empty() ? std::make_optional(host_and_port_options["port"].as<UInt16>()) : std::nullopt;
909 hosts_and_ports.emplace_back(HostAndPort{host, port});
910 }
911
912 send_external_tables = true;
913
914 shared_context = Context::createShared();
915 global_context = Context::createGlobal(shared_context.get());
916 global_context->makeGlobalContext();
917 global_context->setApplicationType(Context::ApplicationType::CLIENT);
918 global_context->setSettings(*cmd_settings);
919

Callers

nothing calls this directly

Calls 15

storeFunction · 0.85
makeGlobalContextMethod · 0.80
setApplicationTypeMethod · 0.80
allowAllSettingsMethod · 0.80
ExceptionClass · 0.50
printFunction · 0.50
createFunction · 0.50
sizeMethod · 0.45
runMethod · 0.45
optionsMethod · 0.45

Tested by

no test coverage detected