mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Bug #30377: EXPLAIN loses last_query_cost when used with UNION
Currently the Last_query_cost session status variable shows only the cost of a single flat subselect. For complex queries (with subselects or unions etc) Last_query_cost is not valid as it was showing the cost for the last optimized subselect. Fixed by reseting to zero Last_query_cost when the complete cost of the query cannot be determined. Last_query_cost will be non-zero only for single flat queries.
This commit is contained in:
@ -1257,6 +1257,28 @@ typedef struct st_lex : public Query_tables_list
|
||||
|
||||
void reset_n_backup_query_tables_list(Query_tables_list *backup);
|
||||
void restore_backup_query_tables_list(Query_tables_list *backup);
|
||||
|
||||
/**
|
||||
@brief check if the statement is a single-level join
|
||||
@return result of the check
|
||||
@retval TRUE The statement doesn't contain subqueries, unions and
|
||||
stored procedure calls.
|
||||
@retval FALSE There are subqueries, UNIONs or stored procedure calls.
|
||||
*/
|
||||
bool is_single_level_stmt()
|
||||
{
|
||||
/*
|
||||
This check exploits the fact that the last added to all_select_list is
|
||||
on its top. So select_lex (as the first added) will be at the tail
|
||||
of the list.
|
||||
*/
|
||||
if (&select_lex == all_selects_list && !sroutines.records)
|
||||
{
|
||||
DBUG_ASSERT(!all_selects_list->next_select_in_list());
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
} LEX;
|
||||
|
||||
struct st_lex_local: public st_lex
|
||||
|
Reference in New Issue
Block a user