mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-11 17:02:25 +00:00
Merge pull request #35711 from kssenii/fix-local-drop-db
Fix dropping non-empty database in clickhouse local
This commit is contained in:
commit
f3e580e876
@ -184,6 +184,11 @@ void LocalServer::tryInitPath()
|
|||||||
if (path.back() != '/')
|
if (path.back() != '/')
|
||||||
path += '/';
|
path += '/';
|
||||||
|
|
||||||
|
fs::create_directories(fs::path(path) / "user_defined/");
|
||||||
|
fs::create_directories(fs::path(path) / "data/");
|
||||||
|
fs::create_directories(fs::path(path) / "metadata/");
|
||||||
|
fs::create_directories(fs::path(path) / "metadata_dropped/");
|
||||||
|
|
||||||
global_context->setPath(path);
|
global_context->setPath(path);
|
||||||
|
|
||||||
global_context->setTemporaryStorage(path + "tmp");
|
global_context->setTemporaryStorage(path + "tmp");
|
||||||
@ -565,7 +570,6 @@ void LocalServer::processConfig()
|
|||||||
/// Lock path directory before read
|
/// Lock path directory before read
|
||||||
status.emplace(fs::path(path) / "status", StatusFile::write_full_info);
|
status.emplace(fs::path(path) / "status", StatusFile::write_full_info);
|
||||||
|
|
||||||
fs::create_directories(fs::path(path) / "user_defined/");
|
|
||||||
LOG_DEBUG(log, "Loading user defined objects from {}", path);
|
LOG_DEBUG(log, "Loading user defined objects from {}", path);
|
||||||
Poco::File(path + "user_defined/").createDirectories();
|
Poco::File(path + "user_defined/").createDirectories();
|
||||||
UserDefinedSQLObjectsLoader::instance().loadObjects(global_context);
|
UserDefinedSQLObjectsLoader::instance().loadObjects(global_context);
|
||||||
@ -573,9 +577,6 @@ void LocalServer::processConfig()
|
|||||||
LOG_DEBUG(log, "Loaded user defined objects.");
|
LOG_DEBUG(log, "Loaded user defined objects.");
|
||||||
|
|
||||||
LOG_DEBUG(log, "Loading metadata from {}", path);
|
LOG_DEBUG(log, "Loading metadata from {}", path);
|
||||||
fs::create_directories(fs::path(path) / "data/");
|
|
||||||
fs::create_directories(fs::path(path) / "metadata/");
|
|
||||||
|
|
||||||
loadMetadataSystem(global_context);
|
loadMetadataSystem(global_context);
|
||||||
attachSystemTablesLocal(global_context, *createMemoryDatabaseIfNotExists(global_context, DatabaseCatalog::SYSTEM_DATABASE));
|
attachSystemTablesLocal(global_context, *createMemoryDatabaseIfNotExists(global_context, DatabaseCatalog::SYSTEM_DATABASE));
|
||||||
attachInformationSchema(global_context, *createMemoryDatabaseIfNotExists(global_context, DatabaseCatalog::INFORMATION_SCHEMA));
|
attachInformationSchema(global_context, *createMemoryDatabaseIfNotExists(global_context, DatabaseCatalog::INFORMATION_SCHEMA));
|
||||||
|
24
tests/queries/0_stateless/02246_clickhouse_local_drop_database.sh
Executable file
24
tests/queries/0_stateless/02246_clickhouse_local_drop_database.sh
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||||
|
# shellcheck source=../shell_config.sh
|
||||||
|
. "$CURDIR"/../shell_config.sh
|
||||||
|
|
||||||
|
dir=${CLICKHOUSE_TEST_UNIQUE_NAME}
|
||||||
|
[[ -d $dir ]] && rm -r $dir
|
||||||
|
mkdir $dir
|
||||||
|
$CLICKHOUSE_LOCAL --multiline --multiquery --path $dir -q """
|
||||||
|
DROP DATABASE IF EXISTS test;
|
||||||
|
CREATE DATABASE IF NOT EXISTS test;
|
||||||
|
USE test;
|
||||||
|
CREATE TABLE test (id Int32) ENGINE=MergeTree() ORDER BY id;
|
||||||
|
DROP DATABASE test;
|
||||||
|
"""
|
||||||
|
|
||||||
|
$CLICKHOUSE_LOCAL --multiline --multiquery -q """
|
||||||
|
DROP DATABASE IF EXISTS test;
|
||||||
|
CREATE DATABASE IF NOT EXISTS test;
|
||||||
|
USE test;
|
||||||
|
CREATE TABLE test (id Int32) ENGINE=MergeTree() ORDER BY id;
|
||||||
|
DROP DATABASE test;
|
||||||
|
"""
|
Loading…
Reference in New Issue
Block a user