Commit 53e566a4 authored by Alexander Nozdrin's avatar Alexander Nozdrin

Remove check_merge_table_access().

check_merge_table_access() used to do two things:
  - set proper database for every merge table child;
  - check SELECT | UPDATE | DELETE for merge table children.

Setting database is not needed anymore, since it's done
on the parsing stage.

Thus, check_merge_table_access() can be removed;
needed privileges can be checked using check_table_access().
parent 6b9371bd
......@@ -13,8 +13,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
#include "sql_parse.h" // check_access,
// check_merge_table_access
#include "sql_parse.h" // check_access
#include "sql_table.h" // mysql_alter_table,
// mysql_exchange_partition
#include "sql_alter.h"
......@@ -60,11 +59,15 @@ bool Alter_table_statement::execute(THD *thd)
check_access(thd, INSERT_ACL | CREATE_ACL, select_lex->db,
&priv,
NULL, /* Don't use first_tab->grant with sel_lex->db */
0, 0) ||
check_merge_table_access(thd, first_table->db,
create_info.merge_list.first))
0, 0))
DBUG_RETURN(TRUE); /* purecov: inspected */
/* If it is a merge table, check privileges for merge children. */
if (create_info.merge_list.first &&
check_table_access(thd, SELECT_ACL | UPDATE_ACL | DELETE_ACL,
create_info.merge_list.first, FALSE, UINT_MAX, FALSE))
DBUG_RETURN(TRUE);
if (check_grant(thd, priv_needed, first_table, FALSE, UINT_MAX, FALSE))
DBUG_RETURN(TRUE); /* purecov: inspected */
......
......@@ -642,45 +642,6 @@ end:
}
/**
@brief Check access privs for a MERGE table and fix children lock types.
@param[in] thd thread handle
@param[in] db database name
@param[in,out] table_list list of child tables (merge_list)
lock_type and optionally db set per table
@return status
@retval 0 OK
@retval != 0 Error
@detail
This function is used for write access to MERGE tables only
(CREATE TABLE, ALTER TABLE ... UNION=(...)). Set TL_WRITE for
every child. Set 'db' for every child if not present.
*/
#ifndef NO_EMBEDDED_ACCESS_CHECKS
bool check_merge_table_access(THD *thd, char *db, TABLE_LIST *table_list)
{
int error= 0;
if (table_list)
{
/* Check that all tables use the current database */
TABLE_LIST *tlist;
for (tlist= table_list; tlist; tlist= tlist->next_local)
{
if (!tlist->db || !tlist->db[0])
tlist->db= db; /* purecov: inspected */
}
error= check_table_access(thd, SELECT_ACL | UPDATE_ACL | DELETE_ACL,
table_list, FALSE, UINT_MAX, FALSE);
}
return error;
}
#endif
/* This works because items are allocated with sql_alloc() */
void free_items(Item *item)
......@@ -6963,10 +6924,16 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables,
if (check_access(thd, want_priv, create_table->db,
&create_table->grant.privilege,
&create_table->grant.m_internal,
0, 0) ||
check_merge_table_access(thd, create_table->db,
lex->create_info.merge_list.first))
0, 0))
goto err;
/* If it is a merge table, check privileges for merge children. */
if (lex->create_info.merge_list.first &&
check_table_access(thd, SELECT_ACL | UPDATE_ACL | DELETE_ACL,
lex->create_info.merge_list.first,
FALSE, UINT_MAX, FALSE))
goto err;
if (want_priv != CREATE_TMP_ACL &&
check_grant(thd, want_priv, create_table, FALSE, 1, FALSE))
goto err;
......
......@@ -153,7 +153,6 @@ bool check_single_table_access(THD *thd, ulong privilege,
bool check_routine_access(THD *thd,ulong want_access,char *db,char *name,
bool is_proc, bool no_errors);
bool check_some_access(THD *thd, ulong want_access, TABLE_LIST *table);
bool check_merge_table_access(THD *thd, char *db, TABLE_LIST *table_list);
bool check_some_routine_access(THD *thd, const char *db, const char *name, bool is_proc);
bool check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
GRANT_INTERNAL_INFO *grant_internal_info,
......@@ -176,8 +175,6 @@ inline bool check_some_access(THD *thd, ulong want_access, TABLE_LIST *table)
table->grant.privilege= want_access;
return false;
}
inline bool check_merge_table_access(THD *thd, char *db, TABLE_LIST *table_list)
{ return false; }
inline bool check_some_routine_access(THD *thd, const char *db,
const char *name, bool is_proc)
{ return false; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment