1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

MWL#182: Explain running statements: address review feedback

- switch SHOW EXPLAIN to using an INFORMATION_SCHEMA table.
This commit is contained in:
Sergey Petrunya
2012-07-10 21:23:00 +04:00
parent a931467e17
commit 725d76e1e8
11 changed files with 118 additions and 175 deletions

View File

@ -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;