summaryrefslogtreecommitdiff
path: root/sql/sql_acl.cc
diff options
context:
space:
mode:
authorDavi Arnaut <Davi.Arnaut@Sun.COM>2009-06-12 18:11:19 -0300
committerDavi Arnaut <Davi.Arnaut@Sun.COM>2009-06-12 18:11:19 -0300
commit66398a877a19b56496f706fd131046a5ad257ce8 (patch)
tree5b37bac1df5706040b9ca456681ed78d39fa91c5 /sql/sql_acl.cc
parent35cf66325047934176fa5bd91c22d99f555cdea7 (diff)
downloadmariadb-git-66398a877a19b56496f706fd131046a5ad257ce8.tar.gz
Bug#45100: Incomplete DROP USER in case of SQL_MODE = 'PAD_CHAR_TO_FULL_LENGTH'
The SQL-mode PAD_CHAR_TO_FULL_LENGTH could prevent a DROP USER statement from privileges associated with the user being dropped. What ocurred was that reading from the User and Host fields of the tables tables_priv or columns_priv would yield values padded with spaces, causing a failure to match a specified user or host ('user' != 'user '); The solution is to disregard the PAD_CHAR_TO_FULL_LENGTH mode when iterating over and matching values in the privileges tables for a DROP USER statement. mysql-test/r/sql_mode.result: Add test case result for Bug#45100. mysql-test/t/sql_mode.test: Add test case for Bug#45100. sql/sql_acl.cc: Clear MODE_PAD_CHAR_TO_FULL_LENGTH before dropping privileges.
Diffstat (limited to 'sql/sql_acl.cc')
-rw-r--r--sql/sql_acl.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index be52fae2007..79fc5d816fd 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -5696,6 +5696,7 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list)
List_iterator <LEX_USER> user_list(list);
TABLE_LIST tables[GRANT_TABLES];
bool some_users_deleted= FALSE;
+ ulong old_sql_mode= thd->variables.sql_mode;
DBUG_ENTER("mysql_drop_user");
/*
@@ -5709,6 +5710,8 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list)
if ((result= open_grant_tables(thd, tables)))
DBUG_RETURN(result != 1);
+ thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH;
+
rw_wrlock(&LOCK_grant);
VOID(pthread_mutex_lock(&acl_cache->lock));
@@ -5741,6 +5744,7 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list)
rw_unlock(&LOCK_grant);
close_thread_tables(thd);
+ thd->variables.sql_mode= old_sql_mode;
DBUG_RETURN(result);
}