Merge pull request #56026 from ClickHouse/make_code_worse

Fix some bad code by making it worse
This commit is contained in:
Alexander Tokmakov 2023-10-26 20:18:04 +02:00 committed by GitHub
commit eacf1ee79b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -621,7 +621,8 @@ void DatabaseReplicated::checkQueryValid(const ASTPtr & query, ContextPtr query_
if (auto * create = query->as<ASTCreateQuery>())
{
bool replicated_table = create->storage && create->storage->engine && startsWith(create->storage->engine->name, "Replicated");
bool replicated_table = create->storage && create->storage->engine &&
(startsWith(create->storage->engine->name, "Replicated") || startsWith(create->storage->engine->name, "Shared"));
if (!replicated_table || !create->storage->engine->arguments)
return;
@ -761,8 +762,9 @@ BlockIO DatabaseReplicated::tryEnqueueReplicatedDDL(const ASTPtr & query, Contex
static UUID getTableUUIDIfReplicated(const String & metadata, ContextPtr context)
{
bool looks_like_replicated = metadata.find("Replicated") != std::string::npos;
bool looks_like_shared = metadata.find("Shared") != std::string::npos;
bool looks_like_merge_tree = metadata.find("MergeTree") != std::string::npos;
if (!looks_like_replicated || !looks_like_merge_tree)
if (!(looks_like_replicated || looks_like_shared) || !looks_like_merge_tree)
return UUIDHelpers::Nil;
ParserCreateQuery parser;
@ -772,7 +774,8 @@ static UUID getTableUUIDIfReplicated(const String & metadata, ContextPtr context
const ASTCreateQuery & create = query->as<const ASTCreateQuery &>();
if (!create.storage || !create.storage->engine)
return UUIDHelpers::Nil;
if (!startsWith(create.storage->engine->name, "Replicated") || !endsWith(create.storage->engine->name, "MergeTree"))
if (!(startsWith(create.storage->engine->name, "Replicated") || startsWith(create.storage->engine->name, "Shared"))
|| !endsWith(create.storage->engine->name, "MergeTree"))
return UUIDHelpers::Nil;
chassert(create.uuid != UUIDHelpers::Nil);
return create.uuid;

View File

@ -902,8 +902,8 @@ namespace
{
void checkTemporaryTableEngineName(const String& name)
{
if (name.starts_with("Replicated") || name == "KeeperMap")
throw Exception(ErrorCodes::INCORRECT_QUERY, "Temporary tables cannot be created with Replicated or KeeperMap table engines");
if (name.starts_with("Replicated") || name.starts_with("Shared") || name == "KeeperMap")
throw Exception(ErrorCodes::INCORRECT_QUERY, "Temporary tables cannot be created with Replicated, Shared or KeeperMap table engines");
}
void setDefaultTableEngine(ASTStorage &storage, DefaultTableEngine engine)