| 2545 | } |
| 2546 | |
| 2547 | BlockIO 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 | |
| 2578 | AccessRightsElements InterpreterCreateQuery::getRequiredAccess() const |
no test coverage detected