2011-08-18 18:48:00 +00:00
|
|
|
|
#include <DB/Parsers/ASTFunction.h>
|
|
|
|
|
#include <DB/Parsers/ASTIdentifier.h>
|
|
|
|
|
#include <DB/Parsers/ASTExpressionList.h>
|
|
|
|
|
#include <DB/Parsers/ASTCreateQuery.h>
|
|
|
|
|
#include <DB/Parsers/ExpressionListParsers.h>
|
|
|
|
|
#include <DB/Parsers/ParserCreateQuery.h>
|
2011-11-01 15:16:04 +00:00
|
|
|
|
#include <DB/Parsers/ParserSelectQuery.h>
|
2011-08-18 18:48:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
|
{
|
2014-06-26 00:58:14 +00:00
|
|
|
|
|
2014-06-12 00:48:56 +00:00
|
|
|
|
bool ParserNestedTable::parseImpl(Pos & pos, Pos end, ASTPtr & node, Expected & expected)
|
2013-07-11 17:35:56 +00:00
|
|
|
|
{
|
|
|
|
|
ParserWhiteSpaceOrComments ws;
|
|
|
|
|
ParserString open("(");
|
|
|
|
|
ParserString close(")");
|
|
|
|
|
ParserIdentifier name_p;
|
|
|
|
|
ParserNameTypePairList columns_p;
|
2014-06-26 00:58:14 +00:00
|
|
|
|
|
2013-07-11 17:35:56 +00:00
|
|
|
|
ASTPtr name;
|
|
|
|
|
ASTPtr columns;
|
2014-06-26 00:58:14 +00:00
|
|
|
|
|
2013-07-11 17:35:56 +00:00
|
|
|
|
Pos begin = pos;
|
2014-06-26 00:58:14 +00:00
|
|
|
|
|
2013-07-11 17:35:56 +00:00
|
|
|
|
/// Пока name == 'Nested', возможно потом появятся альтернативные вложенные структуры данных
|
|
|
|
|
if (!name_p.parse(pos, end, name, expected))
|
|
|
|
|
return false;
|
2014-06-26 00:58:14 +00:00
|
|
|
|
|
2013-07-11 17:35:56 +00:00
|
|
|
|
ws.ignore(pos, end);
|
2014-06-26 00:58:14 +00:00
|
|
|
|
|
2013-07-11 17:35:56 +00:00
|
|
|
|
if (!open.ignore(pos, end))
|
|
|
|
|
return false;
|
2014-06-26 00:58:14 +00:00
|
|
|
|
|
2013-07-11 17:35:56 +00:00
|
|
|
|
ws.ignore(pos, end);
|
2014-06-26 00:58:14 +00:00
|
|
|
|
|
2013-07-11 17:35:56 +00:00
|
|
|
|
if (!columns_p.parse(pos, end, columns, expected))
|
|
|
|
|
return false;
|
2014-06-26 00:58:14 +00:00
|
|
|
|
|
2013-07-11 17:35:56 +00:00
|
|
|
|
ws.ignore(pos, end);
|
2014-06-26 00:58:14 +00:00
|
|
|
|
|
2013-07-11 17:35:56 +00:00
|
|
|
|
if (!close.ignore(pos, end))
|
|
|
|
|
return false;
|
2014-06-26 00:58:14 +00:00
|
|
|
|
|
2013-07-11 17:35:56 +00:00
|
|
|
|
ASTFunction * func = new ASTFunction(StringRange(begin, pos));
|
|
|
|
|
node = func;
|
2014-06-26 00:58:14 +00:00
|
|
|
|
func->name = typeid_cast<ASTIdentifier &>(*name).name;
|
2013-07-12 16:46:58 +00:00
|
|
|
|
func->arguments = columns;
|
|
|
|
|
func->children.push_back(columns);
|
2014-06-26 00:58:14 +00:00
|
|
|
|
|
2013-07-11 17:35:56 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2014-06-26 00:58:14 +00:00
|
|
|
|
|
|
|
|
|
|
2014-06-12 00:48:56 +00:00
|
|
|
|
bool ParserIdentifierWithParameters::parseImpl(Pos & pos, Pos end, ASTPtr & node, Expected & expected)
|
2013-07-11 17:35:56 +00:00
|
|
|
|
{
|
|
|
|
|
Pos begin = pos;
|
2014-06-26 00:58:14 +00:00
|
|
|
|
|
2013-07-11 17:35:56 +00:00
|
|
|
|
ParserFunction function_or_array;
|
|
|
|
|
if (function_or_array.parse(pos, end, node, expected))
|
|
|
|
|
return true;
|
2014-06-26 00:58:14 +00:00
|
|
|
|
|
2013-07-11 17:35:56 +00:00
|
|
|
|
pos = begin;
|
2014-06-26 00:58:14 +00:00
|
|
|
|
|
|
|
|
|
ParserNestedTable nested;
|
2013-07-11 17:35:56 +00:00
|
|
|
|
if (nested.parse(pos, end, node, expected))
|
|
|
|
|
return true;
|
2014-06-26 00:58:14 +00:00
|
|
|
|
|
2013-07-11 17:35:56 +00:00
|
|
|
|
pos = begin;
|
2014-06-26 00:58:14 +00:00
|
|
|
|
|
2013-07-11 17:35:56 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2011-08-18 18:48:00 +00:00
|
|
|
|
|
|
|
|
|
|
2014-06-12 00:48:56 +00:00
|
|
|
|
bool ParserIdentifierWithOptionalParameters::parseImpl(Pos & pos, Pos end, ASTPtr & node, Expected & expected)
|
2011-08-18 18:48:00 +00:00
|
|
|
|
{
|
|
|
|
|
ParserIdentifier non_parametric;
|
2013-07-11 17:35:56 +00:00
|
|
|
|
ParserIdentifierWithParameters parametric;
|
2014-06-26 00:58:14 +00:00
|
|
|
|
|
2011-08-18 18:48:00 +00:00
|
|
|
|
Pos begin = pos;
|
|
|
|
|
|
|
|
|
|
if (parametric.parse(pos, end, node, expected))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
pos = begin;
|
|
|
|
|
|
|
|
|
|
ASTPtr ident;
|
|
|
|
|
if (non_parametric.parse(pos, end, ident, expected))
|
|
|
|
|
{
|
|
|
|
|
ASTFunction * func = new ASTFunction(StringRange(begin, pos));
|
|
|
|
|
node = func;
|
2014-06-26 00:58:14 +00:00
|
|
|
|
func->name = typeid_cast<ASTIdentifier &>(*ident).name;
|
2011-08-18 18:48:00 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
pos = begin;
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-12 00:48:56 +00:00
|
|
|
|
bool ParserNameTypePairList::parseImpl(Pos & pos, Pos end, ASTPtr & node, Expected & expected)
|
2013-07-11 17:35:56 +00:00
|
|
|
|
{
|
2014-03-10 14:47:04 +00:00
|
|
|
|
return ParserList(ParserPtr(new ParserNameTypePair), ParserPtr(new ParserString(",")), false).parse(pos, end, node, expected);
|
2013-07-11 17:35:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-06-12 00:48:56 +00:00
|
|
|
|
bool ParserEngine::parseImpl(Pos & pos, Pos end, ASTPtr & storage, Expected & expected)
|
2011-11-01 15:16:04 +00:00
|
|
|
|
{
|
|
|
|
|
ParserWhiteSpaceOrComments ws;
|
2011-11-05 23:31:19 +00:00
|
|
|
|
ParserString s_engine("ENGINE", true, true);
|
2011-11-01 15:16:04 +00:00
|
|
|
|
ParserString s_eq("=");
|
|
|
|
|
ParserIdentifierWithOptionalParameters storage_p;
|
|
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
2014-06-26 00:58:14 +00:00
|
|
|
|
|
2011-11-01 15:16:04 +00:00
|
|
|
|
if (s_engine.ignore(pos, end, expected))
|
|
|
|
|
{
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
|
|
|
|
|
if (!s_eq.ignore(pos, end, expected))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
|
|
|
|
|
if (!storage_p.parse(pos, end, storage, expected))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-06-12 00:48:56 +00:00
|
|
|
|
bool ParserCreateQuery::parseImpl(Pos & pos, Pos end, ASTPtr & node, Expected & expected)
|
2011-08-18 18:48:00 +00:00
|
|
|
|
{
|
|
|
|
|
Pos begin = pos;
|
|
|
|
|
|
|
|
|
|
ParserWhiteSpaceOrComments ws;
|
|
|
|
|
ParserString s_create("CREATE", true, true);
|
2014-03-12 13:14:16 +00:00
|
|
|
|
ParserString s_temporary("TEMPORARY", true, true);
|
2011-08-18 18:48:00 +00:00
|
|
|
|
ParserString s_attach("ATTACH", true, true);
|
|
|
|
|
ParserString s_table("TABLE", true, true);
|
2011-11-05 23:31:19 +00:00
|
|
|
|
ParserString s_database("DATABASE", true, true);
|
2011-10-30 05:19:41 +00:00
|
|
|
|
ParserString s_dot(".");
|
2011-08-18 18:48:00 +00:00
|
|
|
|
ParserString s_lparen("(");
|
|
|
|
|
ParserString s_rparen(")");
|
2011-11-05 23:31:19 +00:00
|
|
|
|
ParserString s_if("IF", true, true);
|
|
|
|
|
ParserString s_not("NOT", true, true);
|
|
|
|
|
ParserString s_exists("EXISTS", true, true);
|
|
|
|
|
ParserString s_as("AS", true, true);
|
|
|
|
|
ParserString s_select("SELECT", true, true);
|
2013-10-30 13:52:02 +00:00
|
|
|
|
ParserString s_view("VIEW", true, true);
|
|
|
|
|
ParserString s_materialized("MATERIALIZED", true, true);
|
2013-12-10 12:23:43 +00:00
|
|
|
|
ParserString s_populate("POPULATE", true, true);
|
2011-11-01 15:16:04 +00:00
|
|
|
|
ParserEngine engine_p;
|
2011-08-18 18:48:00 +00:00
|
|
|
|
ParserIdentifier name_p;
|
2013-07-11 17:35:56 +00:00
|
|
|
|
ParserNameTypePairList columns_p;
|
2011-08-18 18:48:00 +00:00
|
|
|
|
|
2011-10-30 05:19:41 +00:00
|
|
|
|
ASTPtr database;
|
|
|
|
|
ASTPtr table;
|
2011-08-18 18:48:00 +00:00
|
|
|
|
ASTPtr columns;
|
|
|
|
|
ASTPtr storage;
|
2013-10-30 13:52:02 +00:00
|
|
|
|
ASTPtr inner_storage;
|
2011-10-31 17:30:44 +00:00
|
|
|
|
ASTPtr as_database;
|
|
|
|
|
ASTPtr as_table;
|
2011-11-01 15:16:04 +00:00
|
|
|
|
ASTPtr select;
|
2011-08-18 18:48:00 +00:00
|
|
|
|
bool attach = false;
|
2011-08-19 18:31:14 +00:00
|
|
|
|
bool if_not_exists = false;
|
2013-11-08 17:43:03 +00:00
|
|
|
|
bool is_view = false;
|
|
|
|
|
bool is_materialized_view = false;
|
2013-12-10 12:23:43 +00:00
|
|
|
|
bool is_populate = false;
|
2014-03-12 13:14:16 +00:00
|
|
|
|
bool is_temporary = false;
|
2011-08-18 18:48:00 +00:00
|
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
|
|
|
|
|
if (!s_create.ignore(pos, end, expected))
|
|
|
|
|
{
|
|
|
|
|
if (s_attach.ignore(pos, end, expected))
|
|
|
|
|
attach = true;
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
|
2014-03-12 13:14:16 +00:00
|
|
|
|
if (s_temporary.ignore(pos, end, expected))
|
|
|
|
|
{
|
|
|
|
|
is_temporary = true;
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-05 23:31:19 +00:00
|
|
|
|
if (s_database.ignore(pos, end, expected))
|
2011-10-30 05:19:41 +00:00
|
|
|
|
{
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
|
2011-11-05 23:31:19 +00:00
|
|
|
|
if (s_if.ignore(pos, end, expected)
|
|
|
|
|
&& ws.ignore(pos, end)
|
|
|
|
|
&& s_not.ignore(pos, end, expected)
|
|
|
|
|
&& ws.ignore(pos, end)
|
|
|
|
|
&& s_exists.ignore(pos, end, expected)
|
|
|
|
|
&& ws.ignore(pos, end))
|
|
|
|
|
if_not_exists = true;
|
2011-08-18 18:48:00 +00:00
|
|
|
|
|
2011-11-05 23:31:19 +00:00
|
|
|
|
if (!name_p.parse(pos, end, database, expected))
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2013-10-30 13:52:02 +00:00
|
|
|
|
else if (s_table.ignore(pos, end, expected))
|
2011-11-05 23:31:19 +00:00
|
|
|
|
{
|
2011-10-31 17:30:44 +00:00
|
|
|
|
ws.ignore(pos, end);
|
2011-08-18 18:48:00 +00:00
|
|
|
|
|
2011-11-05 23:31:19 +00:00
|
|
|
|
if (s_if.ignore(pos, end, expected)
|
|
|
|
|
&& ws.ignore(pos, end)
|
|
|
|
|
&& s_not.ignore(pos, end, expected)
|
|
|
|
|
&& ws.ignore(pos, end)
|
|
|
|
|
&& s_exists.ignore(pos, end, expected)
|
|
|
|
|
&& ws.ignore(pos, end))
|
|
|
|
|
if_not_exists = true;
|
|
|
|
|
|
|
|
|
|
if (!name_p.parse(pos, end, table, expected))
|
2011-10-31 17:30:44 +00:00
|
|
|
|
return false;
|
2011-08-18 18:48:00 +00:00
|
|
|
|
|
2011-10-31 17:30:44 +00:00
|
|
|
|
ws.ignore(pos, end);
|
2011-11-01 15:16:04 +00:00
|
|
|
|
|
2011-11-05 23:31:19 +00:00
|
|
|
|
if (s_dot.ignore(pos, end, expected))
|
|
|
|
|
{
|
|
|
|
|
database = table;
|
|
|
|
|
if (!name_p.parse(pos, end, table, expected))
|
|
|
|
|
return false;
|
2011-11-01 15:38:01 +00:00
|
|
|
|
|
2011-11-05 23:31:19 +00:00
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
}
|
2011-08-18 18:48:00 +00:00
|
|
|
|
|
2011-11-05 23:31:19 +00:00
|
|
|
|
/// Список столбцов
|
|
|
|
|
if (s_lparen.ignore(pos, end, expected))
|
2011-10-31 17:30:44 +00:00
|
|
|
|
{
|
2011-11-05 23:31:19 +00:00
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
|
|
|
|
|
if (!columns_p.parse(pos, end, columns, expected))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
|
|
|
|
|
if (!s_rparen.ignore(pos, end, expected))
|
|
|
|
|
return false;
|
|
|
|
|
|
2013-12-17 14:07:59 +00:00
|
|
|
|
|
2011-11-05 23:31:19 +00:00
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
|
|
|
|
|
if (!engine_p.parse(pos, end, storage, expected))
|
|
|
|
|
return false;
|
2013-10-30 13:52:02 +00:00
|
|
|
|
|
|
|
|
|
/// Для engine VIEW необходимо так же считать запрос AS SELECT
|
2014-06-26 00:58:14 +00:00
|
|
|
|
if (storage && (typeid_cast<ASTFunction &>(*storage).name == "View"
|
|
|
|
|
|| typeid_cast<ASTFunction &>(*storage).name == "MaterializedView"))
|
2013-10-30 13:52:02 +00:00
|
|
|
|
{
|
|
|
|
|
if (!s_as.ignore(pos, end, expected))
|
|
|
|
|
return false;
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
Pos before_select = pos;
|
|
|
|
|
if (!s_select.ignore(pos, end, expected))
|
|
|
|
|
return false;
|
|
|
|
|
pos = before_select;
|
|
|
|
|
ParserSelectQuery select_p;
|
|
|
|
|
select_p.parse(pos, end, select, expected);
|
|
|
|
|
}
|
2011-11-01 15:16:04 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-11-05 23:31:19 +00:00
|
|
|
|
engine_p.parse(pos, end, storage, expected);
|
|
|
|
|
|
|
|
|
|
if (!s_as.ignore(pos, end, expected))
|
2011-10-31 17:30:44 +00:00
|
|
|
|
return false;
|
2011-08-18 18:48:00 +00:00
|
|
|
|
|
2011-10-31 17:30:44 +00:00
|
|
|
|
ws.ignore(pos, end);
|
2011-11-01 15:16:04 +00:00
|
|
|
|
|
2011-11-05 23:31:19 +00:00
|
|
|
|
/// AS SELECT ...
|
|
|
|
|
Pos before_select = pos;
|
|
|
|
|
if (s_select.ignore(pos, end, expected))
|
|
|
|
|
{
|
|
|
|
|
pos = before_select;
|
|
|
|
|
ParserSelectQuery select_p;
|
|
|
|
|
select_p.parse(pos, end, select, expected);
|
|
|
|
|
}
|
|
|
|
|
else
|
2011-11-01 15:16:04 +00:00
|
|
|
|
{
|
2011-11-05 23:31:19 +00:00
|
|
|
|
/// AS [db.]table
|
2011-11-01 15:16:04 +00:00
|
|
|
|
if (!name_p.parse(pos, end, as_table, expected))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
2011-11-05 23:31:19 +00:00
|
|
|
|
|
|
|
|
|
if (s_dot.ignore(pos, end, expected))
|
|
|
|
|
{
|
|
|
|
|
as_database = as_table;
|
|
|
|
|
if (!name_p.parse(pos, end, as_table, expected))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
}
|
2012-07-12 20:06:45 +00:00
|
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
|
|
|
|
|
/// Опционально - может быть указана ENGINE.
|
|
|
|
|
engine_p.parse(pos, end, storage, expected);
|
2011-11-01 15:16:04 +00:00
|
|
|
|
}
|
2011-10-31 17:30:44 +00:00
|
|
|
|
}
|
2014-04-24 18:49:07 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-10-30 13:52:02 +00:00
|
|
|
|
/// VIEW or MATERIALIZED VIEW
|
2014-02-11 18:54:31 +00:00
|
|
|
|
if (s_materialized.ignore(pos, end, expected) && ws.ignore(pos, end, expected))
|
2013-11-08 17:43:03 +00:00
|
|
|
|
is_materialized_view = true;
|
|
|
|
|
else
|
|
|
|
|
is_view = true;
|
2013-10-30 13:52:02 +00:00
|
|
|
|
|
2014-02-11 18:54:31 +00:00
|
|
|
|
if (!s_view.ignore(pos, end, expected) || !ws.ignore(pos, end, expected))
|
2013-11-08 17:43:03 +00:00
|
|
|
|
return false;
|
2014-02-11 18:54:31 +00:00
|
|
|
|
|
|
|
|
|
if (s_if.ignore(pos, end, expected)
|
|
|
|
|
&& ws.ignore(pos, end)
|
|
|
|
|
&& s_not.ignore(pos, end, expected)
|
|
|
|
|
&& ws.ignore(pos, end)
|
|
|
|
|
&& s_exists.ignore(pos, end, expected)
|
|
|
|
|
&& ws.ignore(pos, end))
|
|
|
|
|
if_not_exists = true;
|
|
|
|
|
|
2013-10-30 13:52:02 +00:00
|
|
|
|
if (!name_p.parse(pos, end, table, expected))
|
|
|
|
|
return false;
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
|
|
|
|
|
if (s_dot.ignore(pos, end, expected))
|
|
|
|
|
{
|
|
|
|
|
database = table;
|
|
|
|
|
if (!name_p.parse(pos, end, table, expected))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-12 17:27:48 +00:00
|
|
|
|
/// Опционально - может быть указан список столбцов. Он должен полностью соответствовать SELECT-у.
|
|
|
|
|
if (s_lparen.ignore(pos, end, expected))
|
|
|
|
|
{
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
|
|
|
|
|
if (!columns_p.parse(pos, end, columns, expected))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
|
|
|
|
|
if (!s_rparen.ignore(pos, end, expected))
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-30 13:52:02 +00:00
|
|
|
|
/// Опционально - может быть указана внутренняя ENGINE для MATERIALIZED VIEW
|
|
|
|
|
engine_p.parse(pos, end, inner_storage, expected);
|
|
|
|
|
|
2013-12-10 12:23:43 +00:00
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
|
|
|
|
|
if (s_populate.ignore(pos, end, expected))
|
|
|
|
|
is_populate = true;
|
|
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
|
2013-10-30 13:52:02 +00:00
|
|
|
|
/// AS SELECT ...
|
|
|
|
|
if (!s_as.ignore(pos, end, expected))
|
|
|
|
|
return false;
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
Pos before_select = pos;
|
|
|
|
|
if (!s_select.ignore(pos, end, expected))
|
|
|
|
|
return false;
|
|
|
|
|
pos = before_select;
|
|
|
|
|
ParserSelectQuery select_p;
|
|
|
|
|
select_p.parse(pos, end, select, expected);
|
2011-10-31 17:30:44 +00:00
|
|
|
|
}
|
2011-08-18 18:48:00 +00:00
|
|
|
|
|
2011-11-05 23:31:19 +00:00
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
|
2011-08-18 18:48:00 +00:00
|
|
|
|
ASTCreateQuery * query = new ASTCreateQuery(StringRange(begin, pos));
|
|
|
|
|
node = query;
|
|
|
|
|
|
|
|
|
|
query->attach = attach;
|
2011-08-19 18:31:14 +00:00
|
|
|
|
query->if_not_exists = if_not_exists;
|
2013-11-08 17:43:03 +00:00
|
|
|
|
query->is_view = is_view;
|
|
|
|
|
query->is_materialized_view = is_materialized_view;
|
2013-12-10 12:23:43 +00:00
|
|
|
|
query->is_populate = is_populate;
|
2014-03-12 13:14:16 +00:00
|
|
|
|
query->is_temporary = is_temporary;
|
2014-06-26 00:58:14 +00:00
|
|
|
|
|
2011-10-31 06:37:12 +00:00
|
|
|
|
if (database)
|
2014-06-26 00:58:14 +00:00
|
|
|
|
query->database = typeid_cast<ASTIdentifier &>(*database).name;
|
2011-11-05 23:31:19 +00:00
|
|
|
|
if (table)
|
2014-06-26 00:58:14 +00:00
|
|
|
|
query->table = typeid_cast<ASTIdentifier &>(*table).name;
|
2013-10-30 13:52:02 +00:00
|
|
|
|
if (inner_storage)
|
|
|
|
|
query->inner_storage = inner_storage;
|
|
|
|
|
|
2011-08-18 18:48:00 +00:00
|
|
|
|
query->columns = columns;
|
|
|
|
|
query->storage = storage;
|
2011-10-31 17:30:44 +00:00
|
|
|
|
if (as_database)
|
2014-06-26 00:58:14 +00:00
|
|
|
|
query->as_database = typeid_cast<ASTIdentifier &>(*as_database).name;
|
2011-10-31 17:30:44 +00:00
|
|
|
|
if (as_table)
|
2014-06-26 00:58:14 +00:00
|
|
|
|
query->as_table = typeid_cast<ASTIdentifier &>(*as_table).name;
|
2011-11-01 15:16:04 +00:00
|
|
|
|
query->select = select;
|
2011-08-18 18:48:00 +00:00
|
|
|
|
|
2012-12-27 17:40:54 +00:00
|
|
|
|
if (columns)
|
|
|
|
|
query->children.push_back(columns);
|
2011-11-01 15:16:04 +00:00
|
|
|
|
if (storage)
|
|
|
|
|
query->children.push_back(storage);
|
|
|
|
|
if (select)
|
|
|
|
|
query->children.push_back(select);
|
2013-11-13 14:39:48 +00:00
|
|
|
|
if (inner_storage)
|
|
|
|
|
query->children.push_back(inner_storage);
|
2011-08-18 18:48:00 +00:00
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|