summaryrefslogtreecommitdiff
path: root/sql/sql_parse.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r--sql/sql_parse.cc55
1 files changed, 26 insertions, 29 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 9ebb1b3f36e..3a6bb4909f2 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2144,6 +2144,32 @@ mysql_execute_command(THD *thd)
execute_show_status(thd, all_tables);
break;
}
+ case SQLCOM_SHOW_EXPLAIN:
+ {
+ if (!thd->security_ctx->priv_user[0] &&
+ check_global_access(thd,PROCESS_ACL))
+ break;
+
+ /*
+ The select should use only one table, it's the SHOW EXPLAIN pseudo-table
+ */
+ if (lex->sroutines.records || lex->query_tables->next_global)
+ {
+ my_error(ER_NOT_SUPPORTED_YET, MYF(0), "Usage of subqueries or stored "
+ "function calls as part of this statement");
+ break;
+ }
+
+ Item **it= &(lex->show_explain_for_thread);
+ if ((!(*it)->fixed && (*it)->fix_fields(lex->thd, it)) ||
+ (*it)->check_cols(1))
+ {
+ my_message(ER_SET_CONSTANTS_ONLY, ER(ER_SET_CONSTANTS_ONLY),
+ MYF(0));
+ goto error;
+ }
+ /* no break; fall through */
+ }
case SQLCOM_SHOW_DATABASES:
case SQLCOM_SHOW_TABLES:
case SQLCOM_SHOW_TRIGGERS:
@@ -3128,35 +3154,6 @@ end_with_restore_list:
thd->security_ctx->priv_user),
lex->verbose);
break;
- case SQLCOM_SHOW_EXPLAIN:
- {
- const char *effective_user;
- /* Same security as SHOW PROCESSLIST (TODO check this) */
- if (!thd->security_ctx->priv_user[0] &&
- check_global_access(thd,PROCESS_ACL))
- break;
-
- Item *it= (Item *)lex->value_list.head();
-
- if (lex->table_or_sp_used())
- {
- my_error(ER_NOT_SUPPORTED_YET, MYF(0), "Usage of subqueries or stored "
- "function calls as part of this statement");
- break;
- }
-
- if ((!it->fixed && it->fix_fields(lex->thd, &it)) || it->check_cols(1))
- {
- my_message(ER_SET_CONSTANTS_ONLY, ER(ER_SET_CONSTANTS_ONLY),
- MYF(0));
- goto error;
- }
- effective_user=(thd->security_ctx->master_access & PROCESS_ACL ? NullS :
- thd->security_ctx->priv_user);
-
- mysqld_show_explain(thd, effective_user, (ulong)it->val_int());
- break;
- }
case SQLCOM_SHOW_AUTHORS:
res= mysqld_show_authors(thd);
break;