summaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Interpreters/InterpreterCreateQuery.cpp
diff options
context:
space:
mode:
authorrobot-piglet <[email protected]>2023-11-25 09:58:34 +0300
committerrobot-piglet <[email protected]>2023-11-25 10:21:16 +0300
commit87b47db8278b512a71c50ed56d2ed8ee68ac7e4d (patch)
tree7bd7c6e592dd051becd4e873d49e08300fd09fe8 /contrib/clickhouse/src/Interpreters/InterpreterCreateQuery.cpp
parent6b2a05ea439e6a1248e679d60d44519c21f11396 (diff)
Intermediate changes
Diffstat (limited to 'contrib/clickhouse/src/Interpreters/InterpreterCreateQuery.cpp')
-rw-r--r--contrib/clickhouse/src/Interpreters/InterpreterCreateQuery.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/contrib/clickhouse/src/Interpreters/InterpreterCreateQuery.cpp b/contrib/clickhouse/src/Interpreters/InterpreterCreateQuery.cpp
index 92d74f4f18a..06cee002bae 100644
--- a/contrib/clickhouse/src/Interpreters/InterpreterCreateQuery.cpp
+++ b/contrib/clickhouse/src/Interpreters/InterpreterCreateQuery.cpp
@@ -1215,9 +1215,9 @@ BlockIO InterpreterCreateQuery::createTable(ASTCreateQuery & create)
DatabasePtr database;
bool need_add_to_database = !create.temporary;
if (need_add_to_database)
- database = DatabaseCatalog::instance().getDatabase(database_name);
+ database = DatabaseCatalog::instance().tryGetDatabase(database_name);
- if (need_add_to_database && database->shouldReplicateQuery(getContext(), query_ptr))
+ if (need_add_to_database && database && database->shouldReplicateQuery(getContext(), query_ptr))
{
chassert(!ddl_guard);
auto guard = DatabaseCatalog::instance().getDDLGuard(create.getDatabase(), create.getTable());
@@ -1232,6 +1232,9 @@ BlockIO InterpreterCreateQuery::createTable(ASTCreateQuery & create)
return executeQueryOnCluster(create);
}
+ if (need_add_to_database && !database)
+ throw Exception(ErrorCodes::UNKNOWN_DATABASE, "Database {} does not exist", backQuoteIfNeed(database_name));
+
if (create.replace_table)
{
chassert(!ddl_guard);