2013-08-07 13:07:42 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#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]
|
2018-12-21 14:53:00 +00:00
|
|
|
* [ADD COLUMN [IF NOT EXISTS] col_name type [AFTER col_after],]
|
|
|
|
* [DROP COLUMN [IF EXISTS] col_to_drop, ...]
|
2020-11-10 10:23:46 +00:00
|
|
|
* [CLEAR COLUMN [IF EXISTS] col_to_clear[ IN PARTITION partition],]
|
2018-12-21 14:53:00 +00:00
|
|
|
* [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]
|
2017-04-01 07:20:54 +00:00
|
|
|
* [MODIFY PRIMARY KEY (a, b, c...)]
|
2019-07-24 15:22:16 +00:00
|
|
|
* [MODIFY SETTING setting_name=setting_value, ...]
|
2020-12-02 21:18:25 +00:00
|
|
|
* [RESET SETTING setting_name, ...]
|
2018-12-21 14:53:00 +00:00
|
|
|
* [COMMENT COLUMN [IF EXISTS] col_name string]
|
2021-09-20 11:06:19 +00:00
|
|
|
* [MODIFY COMMENT string]
|
2017-05-24 21:38:56 +00:00
|
|
|
* [DROP|DETACH|ATTACH PARTITION|PART partition, ...]
|
2017-04-01 07:20:54 +00:00
|
|
|
* [FETCH PARTITION partition FROM ...]
|
2018-11-01 11:16:04 +00:00
|
|
|
* [FREEZE [PARTITION] [WITH NAME name]]
|
2020-11-10 10:23:46 +00:00
|
|
|
* [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]]
|
2019-05-28 21:17:48 +00:00
|
|
|
* ALTER LIVE VIEW [db.name]
|
|
|
|
* [REFRESH]
|
2013-08-07 13:07:42 +00:00
|
|
|
*/
|
2018-06-09 15:53:14 +00:00
|
|
|
|
2018-08-07 13:58:11 +00:00
|
|
|
class ParserAlterQuery : public IParserBase
|
2018-06-09 15:53:14 +00:00
|
|
|
{
|
|
|
|
protected:
|
2020-01-21 08:54:26 +00:00
|
|
|
const char * getName() const override{ return "ALTER query"; }
|
|
|
|
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
|
2018-06-09 15:53:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ParserAlterCommandList : public IParserBase
|
|
|
|
{
|
|
|
|
protected:
|
2020-01-21 08:54:26 +00:00
|
|
|
const char * getName() const override{ return "a list of ALTER commands"; }
|
|
|
|
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
|
2019-05-28 21:17:48 +00:00
|
|
|
|
|
|
|
public:
|
2021-08-20 17:59:57 +00:00
|
|
|
ASTAlterQuery::AlterObjectType alter_object;
|
2019-05-28 21:17:48 +00:00
|
|
|
|
2021-08-20 17:59:57 +00:00
|
|
|
ParserAlterCommandList(ASTAlterQuery::AlterObjectType alter_object_ = ASTAlterQuery::AlterObjectType::TABLE)
|
|
|
|
: alter_object(alter_object_) {}
|
2018-06-09 15:53:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-08-07 13:58:11 +00:00
|
|
|
class ParserAlterCommand : public IParserBase
|
2013-08-07 13:07:42 +00:00
|
|
|
{
|
|
|
|
protected:
|
2020-01-21 08:54:26 +00:00
|
|
|
const char * getName() const override{ return "ALTER command"; }
|
|
|
|
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
|
2019-05-28 21:17:48 +00:00
|
|
|
|
|
|
|
public:
|
2021-08-20 17:59:57 +00:00
|
|
|
ASTAlterQuery::AlterObjectType alter_object;
|
2019-05-28 21:17:48 +00:00
|
|
|
|
2021-08-20 17:59:57 +00:00
|
|
|
ParserAlterCommand(ASTAlterQuery::AlterObjectType alter_object_ = ASTAlterQuery::AlterObjectType::TABLE)
|
|
|
|
: alter_object(alter_object_) {}
|
2018-08-07 13:58:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-08-07 13:07:42 +00:00
|
|
|
}
|