2011-08-28 00:31:30 +00:00
|
|
|
|
#include <DB/Parsers/ASTSelectQuery.h>
|
2011-08-28 02:22:23 +00:00
|
|
|
|
#include <DB/Parsers/ASTIdentifier.h>
|
2011-08-28 00:31:30 +00:00
|
|
|
|
#include <DB/Parsers/IParserBase.h>
|
|
|
|
|
#include <DB/Parsers/CommonParsers.h>
|
|
|
|
|
#include <DB/Parsers/ExpressionElementParsers.h>
|
|
|
|
|
#include <DB/Parsers/ExpressionListParsers.h>
|
2014-06-12 00:48:56 +00:00
|
|
|
|
#include <DB/Parsers/ParserJoin.h>
|
2011-08-28 00:31:30 +00:00
|
|
|
|
#include <DB/Parsers/ParserSelectQuery.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
2015-04-11 03:10:23 +00:00
|
|
|
|
bool ParserSelectQuery::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_parsed_pos, Expected & expected)
|
2011-08-28 00:31:30 +00:00
|
|
|
|
{
|
|
|
|
|
Pos begin = pos;
|
|
|
|
|
|
2015-05-29 19:08:51 +00:00
|
|
|
|
ASTSelectQuery * select_query = new ASTSelectQuery;
|
2011-08-28 00:31:30 +00:00
|
|
|
|
node = select_query;
|
|
|
|
|
|
|
|
|
|
ParserWhiteSpaceOrComments ws;
|
|
|
|
|
ParserString s_select("SELECT", true, true);
|
2013-06-01 07:43:57 +00:00
|
|
|
|
ParserString s_distinct("DISTINCT", true, true);
|
2011-08-28 00:31:30 +00:00
|
|
|
|
ParserString s_from("FROM", true, true);
|
2013-07-22 16:49:19 +00:00
|
|
|
|
ParserString s_array("ARRAY", true, true);
|
|
|
|
|
ParserString s_join("JOIN", true, true);
|
2014-06-12 00:48:56 +00:00
|
|
|
|
ParserString s_using("USING", true, true);
|
2013-11-28 13:16:46 +00:00
|
|
|
|
ParserString s_prewhere("PREWHERE", true, true);
|
2011-08-28 00:31:30 +00:00
|
|
|
|
ParserString s_where("WHERE", true, true);
|
2013-04-23 11:08:41 +00:00
|
|
|
|
ParserString s_final("FINAL", true, true);
|
2012-12-12 14:25:55 +00:00
|
|
|
|
ParserString s_sample("SAMPLE", true, true);
|
2011-08-28 00:31:30 +00:00
|
|
|
|
ParserString s_group("GROUP", true, true);
|
|
|
|
|
ParserString s_by("BY", true, true);
|
2013-05-04 15:46:50 +00:00
|
|
|
|
ParserString s_with("WITH", true, true);
|
|
|
|
|
ParserString s_totals("TOTALS", true, true);
|
2011-08-28 00:31:30 +00:00
|
|
|
|
ParserString s_having("HAVING", true, true);
|
|
|
|
|
ParserString s_order("ORDER", true, true);
|
|
|
|
|
ParserString s_limit("LIMIT", true, true);
|
2011-10-30 05:19:41 +00:00
|
|
|
|
ParserString s_format("FORMAT", true, true);
|
2014-12-16 10:39:02 +00:00
|
|
|
|
ParserString s_union("UNION", true, true);
|
|
|
|
|
ParserString s_all("ALL", true, true);
|
2014-06-12 00:48:56 +00:00
|
|
|
|
|
2011-08-28 00:31:30 +00:00
|
|
|
|
ParserNotEmptyExpressionList exp_list;
|
2011-11-06 20:47:07 +00:00
|
|
|
|
ParserExpressionWithOptionalAlias exp_elem;
|
2014-06-12 00:48:56 +00:00
|
|
|
|
ParserJoin join;
|
2011-09-04 05:14:52 +00:00
|
|
|
|
ParserOrderByExpressionList order_list;
|
2011-08-28 00:31:30 +00:00
|
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
|
2013-06-01 07:43:57 +00:00
|
|
|
|
/// SELECT [DISTINCT] expr list
|
2011-08-28 00:31:30 +00:00
|
|
|
|
{
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (!s_select.ignore(pos, end, max_parsed_pos, expected))
|
2011-08-28 00:31:30 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (s_distinct.ignore(pos, end, max_parsed_pos, expected))
|
2013-06-01 07:43:57 +00:00
|
|
|
|
{
|
|
|
|
|
select_query->distinct = true;
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (!exp_list.parse(pos, end, select_query->select_expression_list, max_parsed_pos, expected))
|
2011-08-28 00:31:30 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-06 16:21:00 +00:00
|
|
|
|
/// FROM database.table или FROM table или FROM (subquery) или FROM tableFunction
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (s_from.ignore(pos, end, max_parsed_pos, expected))
|
2011-08-28 00:31:30 +00:00
|
|
|
|
{
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
|
2011-11-06 02:29:13 +00:00
|
|
|
|
ParserString s_lparen("(");
|
|
|
|
|
ParserString s_rparen(")");
|
2011-08-28 00:31:30 +00:00
|
|
|
|
ParserString s_dot(".");
|
|
|
|
|
ParserIdentifier ident;
|
2014-02-06 16:21:00 +00:00
|
|
|
|
ParserFunction table_function;
|
2014-01-28 16:45:10 +00:00
|
|
|
|
Pos before = pos;
|
2011-08-28 00:31:30 +00:00
|
|
|
|
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (s_lparen.ignore(pos, end, max_parsed_pos, expected))
|
2011-08-28 00:31:30 +00:00
|
|
|
|
{
|
2011-11-06 02:29:13 +00:00
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
|
|
|
|
|
ParserSelectQuery select_p;
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (!select_p.parse(pos, end, select_query->table, max_parsed_pos, expected))
|
2011-08-28 00:31:30 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
2011-08-28 02:22:23 +00:00
|
|
|
|
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (!s_rparen.ignore(pos, end, max_parsed_pos, expected))
|
2011-11-06 02:29:13 +00:00
|
|
|
|
return false;
|
2014-06-26 00:58:14 +00:00
|
|
|
|
|
2011-11-06 02:29:13 +00:00
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
}
|
2015-04-11 03:10:23 +00:00
|
|
|
|
else if (ident.parse(pos, end, select_query->table, max_parsed_pos, expected))
|
2011-11-06 02:29:13 +00:00
|
|
|
|
{
|
2014-01-28 16:45:10 +00:00
|
|
|
|
/// Если сразу после identifier идет скобка, значит это должна быть табличная функция
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (s_lparen.ignore(pos, end, max_parsed_pos, expected))
|
2011-11-06 02:29:13 +00:00
|
|
|
|
{
|
2014-01-28 16:45:10 +00:00
|
|
|
|
pos = before;
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (!table_function.parse(pos, end, select_query->table, max_parsed_pos, expected))
|
2011-11-06 02:29:13 +00:00
|
|
|
|
return false;
|
2014-02-28 13:09:43 +00:00
|
|
|
|
if (select_query->table)
|
2014-06-26 00:58:14 +00:00
|
|
|
|
typeid_cast<ASTFunction &>(*select_query->table).kind = ASTFunction::TABLE_FUNCTION;
|
2011-11-06 02:29:13 +00:00
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
}
|
2014-01-28 16:45:10 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ws.ignore(pos, end);
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (s_dot.ignore(pos, end, max_parsed_pos, expected))
|
2014-01-28 16:45:10 +00:00
|
|
|
|
{
|
|
|
|
|
select_query->database = select_query->table;
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (!ident.parse(pos, end, select_query->table, max_parsed_pos, expected))
|
2014-01-28 16:45:10 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (select_query->database)
|
2014-06-26 00:58:14 +00:00
|
|
|
|
typeid_cast<ASTIdentifier &>(*select_query->database).kind = ASTIdentifier::Database;
|
|
|
|
|
typeid_cast<ASTIdentifier &>(*select_query->table).kind = ASTIdentifier::Table;
|
2014-01-28 16:45:10 +00:00
|
|
|
|
}
|
2011-11-06 02:29:13 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return false;
|
2015-03-25 02:49:29 +00:00
|
|
|
|
|
|
|
|
|
/// Может быть указан алиас. На данный момент, он ничего не значит и не используется.
|
|
|
|
|
ParserAlias().ignore(pos, end);
|
|
|
|
|
ws.ignore(pos, end);
|
2011-08-28 00:31:30 +00:00
|
|
|
|
}
|
2014-06-26 00:58:14 +00:00
|
|
|
|
|
2014-10-09 22:46:28 +00:00
|
|
|
|
/** FINAL и SAMPLE может быть здесь или после всех JOIN-ов
|
|
|
|
|
* (второй вариант был изначально сделан по ошибке, и его приходится поддерживать).
|
|
|
|
|
*/
|
|
|
|
|
auto parse_final_and_sample = [&]() -> bool
|
|
|
|
|
{
|
|
|
|
|
/// FINAL
|
|
|
|
|
if (!select_query->final
|
2015-04-11 03:10:23 +00:00
|
|
|
|
&& s_final.ignore(pos, end, max_parsed_pos, expected))
|
2014-10-09 22:46:28 +00:00
|
|
|
|
{
|
|
|
|
|
select_query->final = true;
|
|
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// SAMPLE number
|
|
|
|
|
if (!select_query->sample_size
|
2015-04-11 03:10:23 +00:00
|
|
|
|
&& s_sample.ignore(pos, end, max_parsed_pos, expected))
|
2014-10-09 22:46:28 +00:00
|
|
|
|
{
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
|
|
|
|
|
ParserNumber num;
|
|
|
|
|
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (!num.parse(pos, end, select_query->sample_size, max_parsed_pos, expected))
|
2014-10-09 22:46:28 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!parse_final_and_sample())
|
|
|
|
|
return false;
|
|
|
|
|
|
2013-10-17 13:32:32 +00:00
|
|
|
|
/// ARRAY JOIN expr list
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (s_array.ignore(pos, end, max_parsed_pos, expected))
|
2013-07-22 16:49:19 +00:00
|
|
|
|
{
|
|
|
|
|
ws.ignore(pos, end);
|
2013-10-17 13:32:32 +00:00
|
|
|
|
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (!s_join.ignore(pos, end, max_parsed_pos, expected))
|
2013-07-22 16:49:19 +00:00
|
|
|
|
return false;
|
2013-10-17 13:32:32 +00:00
|
|
|
|
|
2013-07-22 16:49:19 +00:00
|
|
|
|
ws.ignore(pos, end);
|
2013-10-17 13:32:32 +00:00
|
|
|
|
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (!exp_list.parse(pos, end, select_query->array_join_expression_list, max_parsed_pos, expected))
|
2013-07-22 16:49:19 +00:00
|
|
|
|
return false;
|
2013-10-17 13:32:32 +00:00
|
|
|
|
|
2013-07-22 16:49:19 +00:00
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
}
|
2013-10-17 13:32:32 +00:00
|
|
|
|
|
2015-05-16 08:33:32 +00:00
|
|
|
|
/// [GLOBAL] ANY|ALL INNER|LEFT JOIN (subquery) USING tuple
|
2015-04-11 03:10:23 +00:00
|
|
|
|
join.parse(pos, end, select_query->join, max_parsed_pos, expected);
|
2014-06-12 00:48:56 +00:00
|
|
|
|
|
2014-10-09 22:46:28 +00:00
|
|
|
|
if (!parse_final_and_sample())
|
|
|
|
|
return false;
|
2014-06-26 00:58:14 +00:00
|
|
|
|
|
2013-11-28 13:16:46 +00:00
|
|
|
|
/// PREWHERE expr
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (s_prewhere.ignore(pos, end, max_parsed_pos, expected))
|
2013-11-28 13:16:46 +00:00
|
|
|
|
{
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (!exp_elem.parse(pos, end, select_query->prewhere_expression, max_parsed_pos, expected))
|
2013-11-28 13:16:46 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-28 00:31:30 +00:00
|
|
|
|
/// WHERE expr
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (s_where.ignore(pos, end, max_parsed_pos, expected))
|
2011-08-28 00:31:30 +00:00
|
|
|
|
{
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (!exp_elem.parse(pos, end, select_query->where_expression, max_parsed_pos, expected))
|
2011-08-28 00:31:30 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// GROUP BY expr list
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (s_group.ignore(pos, end, max_parsed_pos, expected))
|
2011-08-28 00:31:30 +00:00
|
|
|
|
{
|
|
|
|
|
ws.ignore(pos, end);
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (!s_by.ignore(pos, end, max_parsed_pos, expected))
|
2011-08-28 00:31:30 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (!exp_list.parse(pos, end, select_query->group_expression_list, max_parsed_pos, expected))
|
2011-08-28 00:31:30 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
2014-08-04 15:25:38 +00:00
|
|
|
|
}
|
2013-05-04 15:46:50 +00:00
|
|
|
|
|
2014-08-04 15:25:38 +00:00
|
|
|
|
/// WITH TOTALS
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (s_with.ignore(pos, end, max_parsed_pos, expected))
|
2014-08-04 15:25:38 +00:00
|
|
|
|
{
|
|
|
|
|
ws.ignore(pos, end);
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (!s_totals.ignore(pos, end, max_parsed_pos, expected))
|
2014-08-04 15:25:38 +00:00
|
|
|
|
return false;
|
2013-05-04 15:46:50 +00:00
|
|
|
|
|
2014-08-04 15:25:38 +00:00
|
|
|
|
select_query->group_by_with_totals = true;
|
2013-05-04 15:46:50 +00:00
|
|
|
|
|
2014-08-04 15:25:38 +00:00
|
|
|
|
ws.ignore(pos, end);
|
2011-08-28 00:31:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// HAVING expr
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (s_having.ignore(pos, end, max_parsed_pos, expected))
|
2011-08-28 00:31:30 +00:00
|
|
|
|
{
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (!exp_elem.parse(pos, end, select_query->having_expression, max_parsed_pos, expected))
|
2011-08-28 00:31:30 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-29 11:33:55 +00:00
|
|
|
|
/// ORDER BY expr ASC|DESC COLLATE 'locale' list
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (s_order.ignore(pos, end, max_parsed_pos, expected))
|
2011-08-28 00:31:30 +00:00
|
|
|
|
{
|
|
|
|
|
ws.ignore(pos, end);
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (!s_by.ignore(pos, end, max_parsed_pos, expected))
|
2011-08-28 00:31:30 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (!order_list.parse(pos, end, select_query->order_expression_list, max_parsed_pos, expected))
|
2011-08-28 00:31:30 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// LIMIT length или LIMIT offset, length
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (s_limit.ignore(pos, end, max_parsed_pos, expected))
|
2011-08-28 00:31:30 +00:00
|
|
|
|
{
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
|
|
|
|
|
ParserString s_comma(",");
|
|
|
|
|
ParserNumber num;
|
|
|
|
|
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (!num.parse(pos, end, select_query->limit_length, max_parsed_pos, expected))
|
2011-08-28 00:31:30 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (s_comma.ignore(pos, end, max_parsed_pos, expected))
|
2011-08-28 00:31:30 +00:00
|
|
|
|
{
|
|
|
|
|
select_query->limit_offset = select_query->limit_length;
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (!num.parse(pos, end, select_query->limit_length, max_parsed_pos, expected))
|
2011-08-28 00:31:30 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-30 05:19:41 +00:00
|
|
|
|
/// FORMAT format_name
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (s_format.ignore(pos, end, max_parsed_pos, expected))
|
2011-10-30 05:19:41 +00:00
|
|
|
|
{
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
|
|
|
|
|
ParserIdentifier format_p;
|
|
|
|
|
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (!format_p.parse(pos, end, select_query->format, max_parsed_pos, expected))
|
2011-10-30 05:19:41 +00:00
|
|
|
|
return false;
|
2014-06-26 00:58:14 +00:00
|
|
|
|
typeid_cast<ASTIdentifier &>(*select_query->format).kind = ASTIdentifier::Format;
|
2011-10-30 05:19:41 +00:00
|
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
}
|
2015-02-13 11:40:58 +00:00
|
|
|
|
|
2014-12-08 14:51:47 +00:00
|
|
|
|
// UNION ALL select query
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (s_union.ignore(pos, end, max_parsed_pos, expected))
|
2014-12-08 14:51:47 +00:00
|
|
|
|
{
|
|
|
|
|
ws.ignore(pos, end);
|
2015-02-13 11:40:58 +00:00
|
|
|
|
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (s_all.ignore(pos, end, max_parsed_pos, expected))
|
2014-12-16 10:39:02 +00:00
|
|
|
|
{
|
|
|
|
|
ParserSelectQuery select_p;
|
2015-04-11 03:10:23 +00:00
|
|
|
|
if (!select_p.parse(pos, end, select_query->next_union_all, max_parsed_pos, expected))
|
2014-12-16 10:39:02 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else
|
2014-12-08 14:51:47 +00:00
|
|
|
|
return false;
|
2015-02-13 11:40:58 +00:00
|
|
|
|
|
2014-12-08 14:51:47 +00:00
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
}
|
2015-02-13 11:40:58 +00:00
|
|
|
|
|
2015-05-29 19:08:51 +00:00
|
|
|
|
select_query->range = StringRange(begin, pos);
|
|
|
|
|
|
2011-08-28 00:31:30 +00:00
|
|
|
|
select_query->children.push_back(select_query->select_expression_list);
|
|
|
|
|
if (select_query->database)
|
|
|
|
|
select_query->children.push_back(select_query->database);
|
|
|
|
|
if (select_query->table)
|
|
|
|
|
select_query->children.push_back(select_query->table);
|
2013-10-17 13:32:32 +00:00
|
|
|
|
if (select_query->array_join_expression_list)
|
|
|
|
|
select_query->children.push_back(select_query->array_join_expression_list);
|
2014-06-12 05:13:50 +00:00
|
|
|
|
if (select_query->join)
|
|
|
|
|
select_query->children.push_back(select_query->join);
|
2012-12-12 14:25:55 +00:00
|
|
|
|
if (select_query->sample_size)
|
|
|
|
|
select_query->children.push_back(select_query->sample_size);
|
2014-02-01 01:27:00 +00:00
|
|
|
|
if (select_query->prewhere_expression)
|
|
|
|
|
select_query->children.push_back(select_query->prewhere_expression);
|
2015-02-03 16:38:30 +00:00
|
|
|
|
if (select_query->where_expression)
|
|
|
|
|
select_query->children.push_back(select_query->where_expression);
|
2011-08-28 00:31:30 +00:00
|
|
|
|
if (select_query->group_expression_list)
|
|
|
|
|
select_query->children.push_back(select_query->group_expression_list);
|
|
|
|
|
if (select_query->having_expression)
|
|
|
|
|
select_query->children.push_back(select_query->having_expression);
|
|
|
|
|
if (select_query->order_expression_list)
|
|
|
|
|
select_query->children.push_back(select_query->order_expression_list);
|
|
|
|
|
if (select_query->limit_offset)
|
|
|
|
|
select_query->children.push_back(select_query->limit_offset);
|
|
|
|
|
if (select_query->limit_length)
|
|
|
|
|
select_query->children.push_back(select_query->limit_length);
|
2011-10-30 05:19:41 +00:00
|
|
|
|
if (select_query->format)
|
|
|
|
|
select_query->children.push_back(select_query->format);
|
2014-12-08 14:51:47 +00:00
|
|
|
|
if (select_query->next_union_all)
|
|
|
|
|
select_query->children.push_back(select_query->next_union_all);
|
2011-08-28 00:31:30 +00:00
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|