summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergey Petrunya <psergey@askmonty.org>2012-04-26 08:48:31 +0530
committerSergey Petrunya <psergey@askmonty.org>2012-04-26 08:48:31 +0530
commitff40705f89b977d966427710e1b32a0774a2f0b3 (patch)
treea9e2c51dd41a128cc22dfdf3ccbe3140e38b4386 /sql
parent9b269ea11b49c186a12f1a877c1d7cfa26b8b5c1 (diff)
downloadmariadb-git-ff40705f89b977d966427710e1b32a0774a2f0b3.tar.gz
Make SHOW EXPLAIN FOR produce a warning with the original text of query
that the EXPLAIN is for.
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_class.cc16
-rw-r--r--sql/sql_class.h2
-rw-r--r--sql/sql_show.cc5
3 files changed, 18 insertions, 5 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 545c9aff5e9..4e9a0507bba 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -3030,14 +3030,20 @@ void Show_explain_request::get_explain_data(void *arg)
//TODO: change mem_root to point to request_thd->mem_root.
// Actually, change the ARENA, because we're going to allocate items!
Query_arena backup_arena;
- req->target_thd->set_n_backup_active_arena((Query_arena*)req->request_thd,
- &backup_arena);
+ THD *target_thd= req->target_thd;
- if (req->target_thd->lex->unit.print_explain(req->explain_buf))
+ target_thd->set_n_backup_active_arena((Query_arena*)req->request_thd,
+ &backup_arena);
+
+ req->query_str.copy(target_thd->query(),
+ target_thd->query_length(),
+ &my_charset_bin);
+
+ if (target_thd->lex->unit.print_explain(req->explain_buf))
req->failed_to_produce= TRUE;
- req->target_thd->restore_active_arena((Query_arena*)req->request_thd,
- &backup_arena);
+ target_thd->restore_active_arena((Query_arena*)req->request_thd,
+ &backup_arena);
}
diff --git a/sql/sql_class.h b/sql/sql_class.h
index de7c8de6c26..223a42b1d02 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1471,6 +1471,8 @@ public:
select_result_explain_buffer *explain_buf;
+ String query_str;
+
static void get_explain_data(void *arg);
};
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index dd1b749e8bd..a0c39ff6c8c 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -2126,6 +2126,11 @@ void mysqld_show_explain(THD *thd, ulong thread_id)
"Target is not running EXPLAINable command");
bres= TRUE;
}
+ else
+ {
+ push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
+ ER_YES, explain_req.query_str.c_ptr_safe());
+ }
pthread_mutex_unlock(&tmp->LOCK_thd_data);
if (!bres)
{