summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/sql_alter.cc13
-rw-r--r--sql/sql_parse.cc51
-rw-r--r--sql/sql_parse.h3
3 files changed, 17 insertions, 50 deletions
diff --git a/sql/sql_alter.cc b/sql/sql_alter.cc
index 046e09b20a3..5af01523aa7 100644
--- a/sql/sql_alter.cc
+++ b/sql/sql_alter.cc
@@ -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 */
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index a0b9959e626..aa9d29f3d07 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -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;
diff --git a/sql/sql_parse.h b/sql/sql_parse.h
index ad620544d29..c9b0f981d19 100644
--- a/sql/sql_parse.h
+++ b/sql/sql_parse.h
@@ -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; }