1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-24 11:21:21 +03:00

MDEV-324: SHOW EXPLAIN: Plan produced by SHOW EXPLAIN for a query with TEMPTABLE view loses 'DERIVED' line

- Make SHOW EXPLAIN code take into account that st_select_lex object without joins can be
  a full-featured SELECTs which were already executed and cleaned up.
This commit is contained in:
Sergey Petrunya
2012-06-07 19:55:22 +04:00
parent 2c1e737c6c
commit 5eecea8caf
8 changed files with 121 additions and 37 deletions

View File

@@ -2356,13 +2356,14 @@ int select_result_explain_buffer::send_data(List<Item> &items)
}
/* Write all strings out to the output, and free them. */
void select_result_explain_buffer::flush_data()
{
List_iterator<String> it(data_rows);
String *str;
while ((str= it++))
{
/* TODO: write out the lines. */
protocol->set_packet(str->ptr(), str->length());
protocol->write();
delete str;
@@ -2370,6 +2371,20 @@ void select_result_explain_buffer::flush_data()
data_rows.empty();
}
/* Just free all of the accumulated strings */
void select_result_explain_buffer::discard_data()
{
List_iterator<String> it(data_rows);
String *str;
while ((str= it++))
{
delete str;
}
data_rows.empty();
}
//////////////////////////////////////////////////////////////////////////////
@@ -3288,6 +3303,7 @@ void Show_explain_request::get_explain_data(void *arg)
// Actually, change the ARENA, because we're going to allocate items!
Query_arena backup_arena;
THD *target_thd= req->target_thd;
bool printed_anything= FALSE;
target_thd->set_n_backup_active_arena((Query_arena*)req->request_thd,
&backup_arena);
@@ -3296,7 +3312,11 @@ void Show_explain_request::get_explain_data(void *arg)
target_thd->query_length(),
&my_charset_bin);
if (target_thd->lex->unit.print_explain(req->explain_buf, 0 /* explain flags */))
if (target_thd->lex->unit.print_explain(req->explain_buf, 0 /* explain flags*/,
&printed_anything))
req->failed_to_produce= TRUE;
if (!printed_anything)
req->failed_to_produce= TRUE;
target_thd->restore_active_arena((Query_arena*)req->request_thd,