2013-02-21 10:02:33 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Parsers/ASTQueryWithTableAndOutput.h>
|
2019-10-08 18:42:22 +00:00
|
|
|
#include <Common/quoteString.h>
|
2013-02-21 10:02:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2015-08-06 03:26:27 +00:00
|
|
|
|
2019-10-08 12:34:04 +00:00
|
|
|
struct ASTExistsTableQueryIDAndQueryNames
|
2017-11-01 14:34:05 +00:00
|
|
|
{
|
2019-10-08 12:34:04 +00:00
|
|
|
static constexpr auto ID = "ExistsTableQuery";
|
2017-11-01 14:34:05 +00:00
|
|
|
static constexpr auto Query = "EXISTS TABLE";
|
2019-06-29 16:58:32 +00:00
|
|
|
static constexpr auto QueryTemporary = "EXISTS TEMPORARY TABLE";
|
2017-11-01 14:34:05 +00:00
|
|
|
};
|
|
|
|
|
2019-10-08 12:34:04 +00:00
|
|
|
struct ASTExistsDictionaryQueryIDAndQueryNames
|
|
|
|
{
|
|
|
|
static constexpr auto ID = "ExistsDictionaryQuery";
|
|
|
|
static constexpr auto Query = "EXISTS DICTIONARY";
|
2019-10-08 13:26:15 +00:00
|
|
|
/// No temporary dictionaries are supported, just for parsing
|
2019-10-08 12:34:04 +00:00
|
|
|
static constexpr auto QueryTemporary = "EXISTS TEMPORARY DICTIONARY";
|
|
|
|
};
|
|
|
|
|
2018-03-12 14:14:56 +00:00
|
|
|
struct ASTShowCreateTableQueryIDAndQueryNames
|
2017-11-01 14:34:05 +00:00
|
|
|
{
|
2018-03-12 14:14:56 +00:00
|
|
|
static constexpr auto ID = "ShowCreateTableQuery";
|
2017-11-01 14:34:05 +00:00
|
|
|
static constexpr auto Query = "SHOW CREATE TABLE";
|
2019-06-29 16:58:32 +00:00
|
|
|
static constexpr auto QueryTemporary = "SHOW CREATE TEMPORARY TABLE";
|
2017-11-01 14:34:05 +00:00
|
|
|
};
|
|
|
|
|
2018-03-12 14:14:56 +00:00
|
|
|
struct ASTShowCreateDatabaseQueryIDAndQueryNames
|
|
|
|
{
|
|
|
|
static constexpr auto ID = "ShowCreateDatabaseQuery";
|
|
|
|
static constexpr auto Query = "SHOW CREATE DATABASE";
|
2019-06-29 16:58:32 +00:00
|
|
|
static constexpr auto QueryTemporary = "SHOW CREATE TEMPORARY DATABASE";
|
2018-03-12 14:14:56 +00:00
|
|
|
};
|
|
|
|
|
2019-10-08 12:34:04 +00:00
|
|
|
struct ASTShowCreateDictionaryQueryIDAndQueryNames
|
|
|
|
{
|
|
|
|
static constexpr auto ID = "ShowCreateDictionaryQuery";
|
|
|
|
static constexpr auto Query = "SHOW CREATE DICTIONARY";
|
2019-10-08 13:26:15 +00:00
|
|
|
/// No temporary dictionaries are supported, just for parsing
|
2019-10-08 12:34:04 +00:00
|
|
|
static constexpr auto QueryTemporary = "SHOW CREATE TEMPORARY DICTIONARY";
|
|
|
|
};
|
|
|
|
|
2017-11-01 14:34:05 +00:00
|
|
|
struct ASTDescribeQueryExistsQueryIDAndQueryNames
|
|
|
|
{
|
|
|
|
static constexpr auto ID = "DescribeQuery";
|
|
|
|
static constexpr auto Query = "DESCRIBE TABLE";
|
2019-06-29 16:58:32 +00:00
|
|
|
static constexpr auto QueryTemporary = "DESCRIBE TEMPORARY TABLE";
|
2017-11-01 14:34:05 +00:00
|
|
|
};
|
|
|
|
|
2019-10-08 12:34:04 +00:00
|
|
|
using ASTExistsTableQuery = ASTQueryWithTableAndOutputImpl<ASTExistsTableQueryIDAndQueryNames>;
|
|
|
|
using ASTExistsDictionaryQuery = ASTQueryWithTableAndOutputImpl<ASTExistsDictionaryQueryIDAndQueryNames>;
|
2018-03-12 14:14:56 +00:00
|
|
|
using ASTShowCreateTableQuery = ASTQueryWithTableAndOutputImpl<ASTShowCreateTableQueryIDAndQueryNames>;
|
2019-10-08 12:34:04 +00:00
|
|
|
using ASTShowCreateDictionaryQuery = ASTQueryWithTableAndOutputImpl<ASTShowCreateDictionaryQueryIDAndQueryNames>;
|
2018-03-12 14:14:56 +00:00
|
|
|
|
|
|
|
class ASTShowCreateDatabaseQuery : public ASTQueryWithTableAndOutputImpl<ASTShowCreateDatabaseQueryIDAndQueryNames>
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
void formatQueryImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override
|
|
|
|
{
|
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << ASTShowCreateDatabaseQueryIDAndQueryNames::Query
|
|
|
|
<< " " << (settings.hilite ? hilite_none : "") << backQuoteIfNeed(database);
|
|
|
|
}
|
|
|
|
};
|
2017-11-01 14:34:05 +00:00
|
|
|
|
|
|
|
class ASTDescribeQuery : public ASTQueryWithOutput
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ASTPtr table_expression;
|
|
|
|
|
2018-12-07 12:34:40 +00:00
|
|
|
String getID(char) const override { return "DescribeQuery"; }
|
2017-11-01 14:34:05 +00:00
|
|
|
|
|
|
|
ASTPtr clone() const override
|
|
|
|
{
|
|
|
|
auto res = std::make_shared<ASTDescribeQuery>(*this);
|
|
|
|
res->children.clear();
|
|
|
|
if (table_expression)
|
|
|
|
{
|
|
|
|
res->table_expression = table_expression->clone();
|
|
|
|
res->children.push_back(res->table_expression);
|
|
|
|
}
|
|
|
|
cloneOutputOptions(*res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override
|
|
|
|
{
|
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "")
|
|
|
|
<< "DESCRIBE TABLE " << (settings.hilite ? hilite_none : "");
|
|
|
|
table_expression->formatImpl(settings, state, frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
2015-08-06 03:26:27 +00:00
|
|
|
|
2013-02-21 10:02:33 +00:00
|
|
|
}
|