2018-02-02 16:02:43 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-06-13 13:49:27 +00:00
|
|
|
#include <Parsers/ASTAlterQuery.h>
|
2019-05-17 14:34:25 +00:00
|
|
|
#include <Storages/IStorage_fwd.h>
|
|
|
|
|
2018-06-13 13:49:27 +00:00
|
|
|
#include <optional>
|
2018-08-07 13:58:11 +00:00
|
|
|
#include <unordered_map>
|
2018-02-02 16:02:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2018-05-15 12:56:14 +00:00
|
|
|
class Context;
|
2018-07-11 12:43:55 +00:00
|
|
|
class WriteBuffer;
|
|
|
|
class ReadBuffer;
|
2018-05-15 12:56:14 +00:00
|
|
|
|
2018-02-02 16:02:43 +00:00
|
|
|
struct MutationCommand
|
|
|
|
{
|
2018-06-13 13:49:27 +00:00
|
|
|
ASTPtr ast; /// The AST of the whole command
|
|
|
|
|
2018-02-02 16:02:43 +00:00
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
EMPTY, /// Not used.
|
|
|
|
DELETE,
|
2018-08-07 13:58:11 +00:00
|
|
|
UPDATE,
|
2018-02-02 16:02:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Type type = EMPTY;
|
|
|
|
|
|
|
|
ASTPtr predicate;
|
|
|
|
|
2018-08-07 13:58:11 +00:00
|
|
|
std::unordered_map<String, ASTPtr> column_to_update_expression;
|
|
|
|
|
2018-06-13 13:49:27 +00:00
|
|
|
static std::optional<MutationCommand> parse(ASTAlterCommand * command);
|
2018-02-02 16:02:43 +00:00
|
|
|
};
|
|
|
|
|
2018-06-13 13:49:27 +00:00
|
|
|
class MutationCommands : public std::vector<MutationCommand>
|
2018-02-02 16:02:43 +00:00
|
|
|
{
|
2018-06-13 13:49:27 +00:00
|
|
|
public:
|
|
|
|
std::shared_ptr<ASTAlterCommandList> ast() const;
|
2018-04-19 10:33:16 +00:00
|
|
|
|
2018-07-11 12:43:55 +00:00
|
|
|
void writeText(WriteBuffer & out) const;
|
|
|
|
void readText(ReadBuffer & in);
|
2018-02-02 16:02:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|