mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
subqueries made printable
new EXPLAIN parameter to show real query as it was interpreted (SCRUM) (WL#1274)
This commit is contained in:
@ -1421,7 +1421,73 @@ bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num)
|
||||
order_group_num)* 5)) == 0;
|
||||
}
|
||||
|
||||
void st_select_lex_unit::print(String *str)
|
||||
{
|
||||
for (SELECT_LEX *sl= first_select(); sl; sl= sl->next_select())
|
||||
{
|
||||
if (sl != first_select())
|
||||
{
|
||||
str->append(" union ");
|
||||
if (union_option & UNION_ALL)
|
||||
str->append("all ");
|
||||
}
|
||||
if (sl->braces)
|
||||
str->append('(');
|
||||
sl->print(thd, str);
|
||||
if (sl->braces)
|
||||
str->append(')');
|
||||
}
|
||||
if (fake_select_lex == global_parameters)
|
||||
{
|
||||
if (fake_select_lex->order_list.elements)
|
||||
{
|
||||
str->append(" order by ");
|
||||
fake_select_lex->print_order(str,
|
||||
(ORDER *) fake_select_lex->
|
||||
order_list.first);
|
||||
}
|
||||
fake_select_lex->print_limit(thd, str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void st_select_lex::print_order(String *str, ORDER *order)
|
||||
{
|
||||
for (; order; order= order->next)
|
||||
{
|
||||
(*order->item)->print(str);
|
||||
if (!order->asc)
|
||||
str->append(" desc");
|
||||
if (order->next)
|
||||
str->append(',');
|
||||
}
|
||||
}
|
||||
|
||||
void st_select_lex::print_limit(THD *thd, String *str)
|
||||
{
|
||||
if (!thd)
|
||||
thd= current_thd;
|
||||
|
||||
if (select_limit != thd->variables.select_limit ||
|
||||
select_limit != HA_POS_ERROR ||
|
||||
offset_limit != 0L)
|
||||
{
|
||||
str->append(" limit ");
|
||||
char buff[21];
|
||||
snprintf(buff, 21, "%ld", select_limit);
|
||||
str->append(buff);
|
||||
if (offset_limit)
|
||||
{
|
||||
str->append(',');
|
||||
snprintf(buff, 21, "%ld", offset_limit);
|
||||
str->append(buff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
There are st_select_lex::add_table_to_list &
|
||||
st_select_lex::set_lock_for_tables in sql_parse.cc
|
||||
|
||||
st_select_lex::print is in sql_select.h
|
||||
*/
|
||||
|
Reference in New Issue
Block a user