ClickHouse/src/Parsers/ParserAlterQuery.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

72 lines
2.3 KiB
C++
Raw Normal View History

2013-08-07 13:07:42 +00:00
#pragma once
#include <Parsers/IParserBase.h>
#include <Parsers/ExpressionElementParsers.h>
2021-08-20 17:59:57 +00:00
#include <Parsers/ASTAlterQuery.h>
2013-08-07 13:07:42 +00:00
namespace DB
{
2016-03-25 11:48:45 +00:00
2017-05-27 17:29:55 +00:00
/** Query like this:
2017-04-21 12:39:28 +00:00
* ALTER TABLE [db.]name [ON CLUSTER cluster]
* [ADD COLUMN [IF NOT EXISTS] col_name type [AFTER col_after],]
* [DROP COLUMN [IF EXISTS] col_to_drop, ...]
* [CLEAR COLUMN [IF EXISTS] col_to_clear[ IN PARTITION partition],]
* [MODIFY COLUMN [IF EXISTS] col_to_modify type, ...]
2020-03-25 18:44:08 +00:00
* [RENAME COLUMN [IF EXISTS] col_name TO col_name]
* [MODIFY PRIMARY KEY (a, b, c...)]
2019-07-24 15:22:16 +00:00
* [MODIFY SETTING setting_name=setting_value, ...]
* [RESET SETTING setting_name, ...]
* [COMMENT COLUMN [IF EXISTS] col_name string]
* [MODIFY COMMENT string]
* [DROP|DETACH|ATTACH PARTITION|PART partition, ...]
* [FETCH PARTITION partition FROM ...]
* [FREEZE [PARTITION] [WITH NAME name]]
* [DELETE[ IN PARTITION partition] WHERE ...]
* [UPDATE col_name = expr, ...[ IN PARTITION partition] WHERE ...]
* [ADD INDEX [IF NOT EXISTS] index_name [AFTER index_name]]
* [DROP INDEX [IF EXISTS] index_name]
* [CLEAR INDEX [IF EXISTS] index_name IN PARTITION partition]
* [MATERIALIZE INDEX [IF EXISTS] index_name [IN PARTITION partition]]
* ALTER LIVE VIEW [db.name]
* [REFRESH]
2013-08-07 13:07:42 +00:00
*/
class ParserAlterQuery : public IParserBase
{
protected:
const char * getName() const override{ return "ALTER query"; }
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
};
class ParserAlterCommandList : public IParserBase
{
protected:
const char * getName() const override{ return "a list of ALTER commands"; }
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
public:
2021-08-20 17:59:57 +00:00
ASTAlterQuery::AlterObjectType alter_object;
2021-08-20 17:59:57 +00:00
ParserAlterCommandList(ASTAlterQuery::AlterObjectType alter_object_ = ASTAlterQuery::AlterObjectType::TABLE)
: alter_object(alter_object_) {}
};
class ParserAlterCommand : public IParserBase
2013-08-07 13:07:42 +00:00
{
protected:
const char * getName() const override{ return "ALTER command"; }
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
public:
2021-08-20 17:59:57 +00:00
ASTAlterQuery::AlterObjectType alter_object;
2021-08-20 17:59:57 +00:00
ParserAlterCommand(ASTAlterQuery::AlterObjectType alter_object_ = ASTAlterQuery::AlterObjectType::TABLE)
: alter_object(alter_object_) {}
};
2013-08-07 13:07:42 +00:00
}