@@ -296,7 +296,7 @@ BlockIO InterpreterCreateQuery::createDatabase(ASTCreateQuery & create)
296296 }
297297 else
298298 {
299- bool is_on_cluster = getContext ()->getClientInfo (). query_kind == ClientInfo::QueryKind:: SECONDARY_QUERY ;
299+ bool is_on_cluster = getContext ()->isDDLOrOnClusterInternal () ;
300300 if (create.uuid != UUIDHelpers::Nil && !is_on_cluster && !internal)
301301 throw Exception (ErrorCodes::INCORRECT_QUERY , " Ordinary database engine does not support UUID" );
302302
@@ -1393,7 +1393,7 @@ void InterpreterCreateQuery::assertOrSetUUID(ASTCreateQuery & create, const Data
13931393 const auto * kind_upper = create.is_dictionary ? " DICTIONARY" : " TABLE" ;
13941394 bool is_replicated_database_internal = database->getEngineName () == " Replicated" && getContext ()->getClientInfo ().is_replicated_database_internal ;
13951395 bool from_path = create.attach_from_path .has_value ();
1396- bool is_on_cluster = getContext ()->getClientInfo (). query_kind == ClientInfo::QueryKind:: SECONDARY_QUERY ;
1396+ bool is_on_cluster = getContext ()->isDDLOrOnClusterInternal () ;
13971397
13981398 if (database->getEngineName () == " Replicated" && create.uuid != UUIDHelpers::Nil && !is_replicated_database_internal && !internal && !is_on_cluster && !create.attach )
13991399 {
@@ -1598,7 +1598,7 @@ BlockIO InterpreterCreateQuery::createTable(ASTCreateQuery & create)
15981598 fs::path user_files = fs::path (getContext ()->getUserFilesPath ()).lexically_normal ();
15991599 fs::path root_path = fs::path (getContext ()->getPath ()).lexically_normal ();
16001600
1601- if (getContext ()->getClientInfo (). query_kind == ClientInfo::QueryKind:: INITIAL_QUERY )
1601+ if (! getContext ()->isDDLOrOnClusterInternal () )
16021602 {
16031603 fs::path data_path = fs::path (*create.attach_from_path ).lexically_normal ();
16041604 if (data_path.is_relative ())
@@ -1618,7 +1618,7 @@ BlockIO InterpreterCreateQuery::createTable(ASTCreateQuery & create)
16181618 " Data directory {} must be inside {} to attach it" , String (data_path), String (user_files));
16191619 }
16201620 }
1621- else if (create.attach && !create.attach_short_syntax && getContext ()->getClientInfo (). query_kind != ClientInfo::QueryKind:: SECONDARY_QUERY )
1621+ else if (create.attach && !create.attach_short_syntax && ! getContext ()->isDDLOrOnClusterInternal () )
16221622 {
16231623 auto log = getLogger (" InterpreterCreateQuery" );
16241624 LOG_WARNING (log, " ATTACH TABLE query with full table definition is not recommended: "
@@ -1922,9 +1922,9 @@ bool InterpreterCreateQuery::doCreateTable(ASTCreateQuery & create,
19221922 // / Before actually creating the table, check if it will lead to cyclic dependencies.
19231923 checkTableCanBeAddedWithNoCyclicDependencies (create, query_ptr, getContext ());
19241924
1925- // / Initial queries in Replicated database at this point have query_kind = ClientInfo::QueryKind::SECONNDARY_QUERY ,
1925+ // / Initial queries in Replicated database at this point have is_ddl_or_on_cluster_internal = true ,
19261926 // / so we need to check whether the query is initial through getZooKeeperMetadataTransaction()->isInitialQuery()
1927- bool is_initial_query = getContext ()->getClientInfo (). query_kind == ClientInfo::QueryKind:: INITIAL_QUERY ||
1927+ bool is_initial_query = ! getContext ()->isDDLOrOnClusterInternal () ||
19281928 (getContext ()->getZooKeeperMetadataTransaction () && getContext ()->getZooKeeperMetadataTransaction ()->isInitialQuery ());
19291929 bool is_predefined_database = DatabaseCatalog::isPredefinedDatabase (create.getDatabase ());
19301930 if (!internal && is_initial_query && !is_predefined_database)
0 commit comments