302323 {
302325
302326 auto &config = ClientConfig::GetConfig(context);
302327 config.enable_profiler = true;
302328 config.emit_profiler_output = true;
302329
302330 if (parameter != "no_output" && !config.profiler_save_location.empty()) {
302331 auto &file_system = FileSystem::GetFileSystem(context);
302332 const auto file_type = file_system.ExtractExtension(config.profiler_save_location);
302333 if (file_type != parameter && file_type != "txt") {
302334 throw ParserException(
302335 "Profiler file type (%s) must either have the same file extension as the profiling output type (%s), "
302336 "or be a '.txt' file. Set 'profiling_output' to a '%s' file or run \"RESET profiling_output\" first.",
302337 config.profiler_save_location, parameter, parameter);
302338 }
302339 }
302340
302341 if (parameter == "json") {
302342 config.profiler_print_format = ProfilerPrintFormat::JSON;
302343 } else if (parameter == "query_tree") {
302344 config.profiler_print_format = ProfilerPrintFormat::QUERY_TREE;
302345 } else if (parameter == "query_tree_optimizer") {
302346 config.profiler_print_format = ProfilerPrintFormat::QUERY_TREE_OPTIMIZER;
302347
302348
302349 auto optimizer_settings = MetricsUtils::GetOptimizerMetrics();
302350 for (auto &setting : optimizer_settings) {
302351 config.profiler_settings.insert(setting);
302352 }
302353
302354
302355 auto phase_timing_settings = MetricsUtils::GetPhaseTimingMetrics();
302356 for (auto &setting : phase_timing_settings) {
302357 config.profiler_settings.insert(setting);
302358 }
302359 } else if (parameter == "no_output") {
302360 config.profiler_print_format = ProfilerPrintFormat::NO_OUTPUT;
302361 config.emit_profiler_output = false;
302362 } else if (parameter == "html") {
302363 config.profiler_print_format = ProfilerPrintFormat::HTML;
302364 } else if (parameter == "graphviz") {
302365 config.profiler_print_format = ProfilerPrintFormat::GRAPHVIZ;
302366 } else {
302367 throw ParserException("Unrecognized print format %s, supported formats: [json, query_tree, "
302368 "query_tree_optimizer, no_output, html, graphviz]",
302369 parameter);
302370 }
302371}
static DUCKDB_API string Lower(const string &str)
Convert a string to lowercase.
Definition duckdb.cpp:109630