mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 10:02:01 +00:00
Don't replicate KeeperMap DELETE and TRUNCATE
This commit is contained in:
parent
e428ed5543
commit
7975df538e
@ -30,6 +30,7 @@
|
|||||||
#include <Parsers/ASTAlterQuery.h>
|
#include <Parsers/ASTAlterQuery.h>
|
||||||
#include <Parsers/ASTDropQuery.h>
|
#include <Parsers/ASTDropQuery.h>
|
||||||
#include <Parsers/ASTFunction.h>
|
#include <Parsers/ASTFunction.h>
|
||||||
|
#include <Parsers/ASTDeleteQuery.h>
|
||||||
#include <Parsers/formatAST.h>
|
#include <Parsers/formatAST.h>
|
||||||
#include <Parsers/parseQuery.h>
|
#include <Parsers/parseQuery.h>
|
||||||
#include <Parsers/ParserCreateQuery.h>
|
#include <Parsers/ParserCreateQuery.h>
|
||||||
@ -1388,25 +1389,31 @@ bool DatabaseReplicated::shouldReplicateQuery(const ContextPtr & query_context,
|
|||||||
if (query_context->getClientInfo().is_replicated_database_internal)
|
if (query_context->getClientInfo().is_replicated_database_internal)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/// Some ALTERs are not replicated on database level
|
/// we never replicate KeeperMap operations for some types of queries because it doesn't make sense
|
||||||
if (const auto * alter = query_ptr->as<const ASTAlterQuery>())
|
const auto is_keeper_map_table = [&](const ASTPtr & ast)
|
||||||
{
|
{
|
||||||
auto table_id = query_context->resolveStorageID(*alter, Context::ResolveOrdinary);
|
auto table_id = query_context->resolveStorageID(ast, Context::ResolveOrdinary);
|
||||||
StoragePtr table = DatabaseCatalog::instance().getTable(table_id, query_context);
|
StoragePtr table = DatabaseCatalog::instance().getTable(table_id, query_context);
|
||||||
|
|
||||||
/// we never replicate KeeperMap operations because it doesn't make sense
|
return table->as<StorageKeeperMap>() != nullptr;
|
||||||
if (auto * keeper_map = table->as<StorageKeeperMap>())
|
};
|
||||||
return false;
|
|
||||||
|
|
||||||
return !alter->isAttachAlter() && !alter->isFetchAlter() && !alter->isDropPartitionAlter();
|
/// Some ALTERs are not replicated on database level
|
||||||
}
|
if (const auto * alter = query_ptr->as<const ASTAlterQuery>())
|
||||||
|
return !alter->isAttachAlter() && !alter->isFetchAlter() && !alter->isDropPartitionAlter() && !is_keeper_map_table(query_ptr);
|
||||||
|
|
||||||
/// DROP DATABASE is not replicated
|
/// DROP DATABASE is not replicated
|
||||||
if (const auto * drop = query_ptr->as<const ASTDropQuery>())
|
if (const auto * drop = query_ptr->as<const ASTDropQuery>())
|
||||||
{
|
{
|
||||||
return drop->table.get();
|
if (drop->table.get())
|
||||||
|
return drop->kind != ASTDropQuery::Truncate || !is_keeper_map_table(query_ptr);
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (query_ptr->as<const ASTDeleteQuery>() != nullptr)
|
||||||
|
return !is_keeper_map_table(query_ptr);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user