mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Merge pull request #51287 from ClickHouse/remove-live-view-alter
Remove ALTER of LIVE VIEW
This commit is contained in:
commit
945a119fc6
@ -18,8 +18,6 @@
|
||||
#include <Parsers/queryToString.h>
|
||||
#include <Storages/AlterCommands.h>
|
||||
#include <Storages/IStorage.h>
|
||||
#include <Storages/LiveView/LiveViewCommands.h>
|
||||
#include <Storages/LiveView/StorageLiveView.h>
|
||||
#include <Storages/MutationCommands.h>
|
||||
#include <Storages/PartitionCommands.h>
|
||||
#include <Storages/StorageKeeperMap.h>
|
||||
@ -117,7 +115,6 @@ BlockIO InterpreterAlterQuery::executeToTable(const ASTAlterQuery & alter)
|
||||
AlterCommands alter_commands;
|
||||
PartitionCommands partition_commands;
|
||||
MutationCommands mutation_commands;
|
||||
LiveViewCommands live_view_commands;
|
||||
for (const auto & child : alter.command_list->children)
|
||||
{
|
||||
auto * command_ast = child->as<ASTAlterCommand>();
|
||||
@ -137,17 +134,13 @@ BlockIO InterpreterAlterQuery::executeToTable(const ASTAlterQuery & alter)
|
||||
|
||||
mutation_commands.emplace_back(std::move(*mut_command));
|
||||
}
|
||||
else if (auto live_view_command = LiveViewCommand::parse(command_ast))
|
||||
{
|
||||
live_view_commands.emplace_back(std::move(*live_view_command));
|
||||
}
|
||||
else
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR, "Wrong parameter type in ALTER query");
|
||||
}
|
||||
|
||||
if (typeid_cast<DatabaseReplicated *>(database.get()))
|
||||
{
|
||||
int command_types_count = !mutation_commands.empty() + !partition_commands.empty() + !live_view_commands.empty() + !alter_commands.empty();
|
||||
int command_types_count = !mutation_commands.empty() + !partition_commands.empty() + !alter_commands.empty();
|
||||
bool mixed_settings_amd_metadata_alter = alter_commands.hasSettingsAlterCommand() && !alter_commands.isSettingsAlter();
|
||||
if (1 < command_types_count || mixed_settings_amd_metadata_alter)
|
||||
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "For Replicated databases it's not allowed "
|
||||
@ -170,21 +163,6 @@ BlockIO InterpreterAlterQuery::executeToTable(const ASTAlterQuery & alter)
|
||||
res.pipeline = QueryPipeline(std::move(partition_commands_pipe));
|
||||
}
|
||||
|
||||
if (!live_view_commands.empty())
|
||||
{
|
||||
live_view_commands.validate(*table);
|
||||
for (const LiveViewCommand & command : live_view_commands)
|
||||
{
|
||||
auto live_view = std::dynamic_pointer_cast<StorageLiveView>(table);
|
||||
switch (command.type)
|
||||
{
|
||||
case LiveViewCommand::REFRESH:
|
||||
live_view->refresh();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!alter_commands.empty())
|
||||
{
|
||||
auto alter_lock = table->lockForAlter(getContext()->getSettingsRef().lock_acquire_timeout);
|
||||
|
@ -1,65 +0,0 @@
|
||||
#pragma once
|
||||
/* Copyright (c) 2018 BlackBerry Limited
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License. */
|
||||
|
||||
#include <optional>
|
||||
#include <Parsers/ASTAlterQuery.h>
|
||||
#include <Storages/LiveView/StorageLiveView.h>
|
||||
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int UNKNOWN_STORAGE;
|
||||
}
|
||||
|
||||
struct LiveViewCommand
|
||||
{
|
||||
enum Type
|
||||
{
|
||||
REFRESH
|
||||
};
|
||||
|
||||
Type type;
|
||||
|
||||
ASTPtr values;
|
||||
|
||||
static LiveViewCommand refresh(const ASTPtr & values)
|
||||
{
|
||||
LiveViewCommand res;
|
||||
res.type = REFRESH;
|
||||
res.values = values;
|
||||
return res;
|
||||
}
|
||||
|
||||
static std::optional<LiveViewCommand> parse(ASTAlterCommand * command)
|
||||
{
|
||||
if (command->type == ASTAlterCommand::LIVE_VIEW_REFRESH)
|
||||
return refresh(command->values);
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class LiveViewCommands : public std::vector<LiveViewCommand>
|
||||
{
|
||||
public:
|
||||
void validate(const IStorage & table)
|
||||
{
|
||||
if (!empty() && !dynamic_cast<const StorageLiveView *>(&table))
|
||||
throw Exception(DB::ErrorCodes::UNKNOWN_STORAGE, "Wrong storage type. Must be StorageLiveView");
|
||||
}
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user