Backport #67129 to 24.6: Fix truncate database

This commit is contained in:
robot-clickhouse 2024-07-26 12:09:35 +00:00
parent 6938ce9a9f
commit b474ce4ab8
3 changed files with 7 additions and 2 deletions

View File

@ -398,10 +398,9 @@ BlockIO InterpreterDropQuery::executeToDatabaseImpl(const ASTDropQuery & query,
if (query.if_empty)
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "DROP IF EMPTY is not implemented for databases");
if (database->hasReplicationThread())
if (!truncate && database->hasReplicationThread())
database->stopReplication();
if (database->shouldBeEmptyOnDetach())
{
/// Cancel restarting replicas in that database, wait for remaining RESTART queries to finish.

View File

@ -20,3 +20,5 @@ source_table_stripe_log
source_table_tiny_log
=== DICTIONARIES IN test_truncate_database ===
dest_dictionary
new tables
new_table

View File

@ -73,4 +73,8 @@ SELECT * FROM dest_dictionary; -- {serverError UNKNOWN_TABLE}
SHOW TABLES FROM test_truncate_database;
SHOW DICTIONARIES FROM test_truncate_database;
CREATE TABLE new_table (x UInt16) ENGINE = MergeTree ORDER BY x;
select 'new tables';
SHOW TABLES FROM test_truncate_database;
DROP DATABASE test_truncate_database;