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

Method execute

src/Interpreters/InterpreterCreateQuery.cpp:2547–2575  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2545}
2546
2547BlockIO InterpreterCreateQuery::execute()
2548{
2549 FunctionNameNormalizer::visit(query_ptr.get());
2550 auto & create = query_ptr->as<ASTCreateQuery &>();
2551
2552 create.if_not_exists |= getContext()->getSettingsRef()[Setting::create_if_not_exists];
2553
2554 bool is_create_database = create.database && !create.table;
2555 if (!create.cluster.empty() && !maybeRemoveOnCluster(query_ptr, getContext()))
2556 {
2557 if (create.attach_as_replicated.has_value())
2558 throw Exception(
2559 ErrorCodes::SUPPORT_IS_DISABLED,
2560 "ATTACH AS [NOT] REPLICATED is not supported for ON CLUSTER queries");
2561
2562 auto on_cluster_version = getContext()->getSettingsRef()[Setting::distributed_ddl_entry_format_version];
2563 if (is_create_database || on_cluster_version < DDLLogEntry::NORMALIZE_CREATE_ON_INITIATOR_VERSION)
2564 return executeQueryOnCluster(create);
2565 }
2566
2567 getContext()->checkAccess(getRequiredAccess());
2568
2569 ASTQueryWithOutput::resetOutputASTIfExist(create);
2570
2571 /// CREATE|ATTACH DATABASE
2572 if (is_create_database)
2573 return createDatabase(create);
2574 return createTable(create);
2575}
2576
2577
2578AccessRightsElements InterpreterCreateQuery::getRequiredAccess() const

Callers 3

doCreateTableMethod · 0.45
fillTableIfNeededMethod · 0.45

Calls 7

maybeRemoveOnClusterFunction · 0.85
createTableFunction · 0.85
ExceptionClass · 0.70
getContextFunction · 0.50
getMethod · 0.45
emptyMethod · 0.45
checkAccessMethod · 0.45

Tested by

no test coverage detected