summaryrefslogtreecommitdiff
path: root/sql/sql_acl.cc
diff options
context:
space:
mode:
authorunknown <mkindahl@dl145h.mysql.com>2008-01-30 11:25:54 +0100
committerunknown <mkindahl@dl145h.mysql.com>2008-01-30 11:25:54 +0100
commit206770562d2e3bd33599d5ea2aedfb31154c1487 (patch)
tree09a25ebdb100cc9b38eef8149c29eae0b6daa411 /sql/sql_acl.cc
parent4abbaf31df94131e9b44dbed535f745a45fa1eb4 (diff)
parent7faa7d60aa3d7df5b0617103559d1e3df41dba0b (diff)
downloadmariadb-git-206770562d2e3bd33599d5ea2aedfb31154c1487.tar.gz
Merge dl145h.mysql.com:/data0/mkindahl/mysql-5.0-rpl
into dl145h.mysql.com:/data0/mkindahl/mysql-5.0-rpl-merge include/my_sys.h: Auto merged mysql-test/r/blackhole.result: Auto merged mysql-test/r/case.result: Auto merged mysql-test/r/mysqlbinlog2.result: Auto merged mysql-test/t/blackhole.test: Auto merged mysql-test/t/case.test: Auto merged sql/set_var.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_parse.cc: Auto merged
Diffstat (limited to 'sql/sql_acl.cc')
-rw-r--r--sql/sql_acl.cc24
1 files changed, 17 insertions, 7 deletions
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 134541368e9..8fdd054eb39 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -5333,6 +5333,7 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list)
LEX_USER *user_name, *tmp_user_name;
List_iterator <LEX_USER> user_list(list);
TABLE_LIST tables[GRANT_TABLES];
+ bool some_users_created= FALSE;
DBUG_ENTER("mysql_create_user");
/* CREATE USER may be skipped on replication client. */
@@ -5361,6 +5362,7 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list)
continue;
}
+ some_users_created= TRUE;
sql_mode= thd->variables.sql_mode;
if (replace_user_table(thd, tables[0].table, *user_name, 0, 0, 1, 0))
{
@@ -5371,7 +5373,10 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list)
VOID(pthread_mutex_unlock(&acl_cache->lock));
- if (mysql_bin_log.is_open())
+ if (result)
+ my_error(ER_CANNOT_USER, MYF(0), "CREATE USER", wrong_users.c_ptr_safe());
+
+ if (some_users_created && mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE);
mysql_bin_log.write(&qinfo);
@@ -5379,8 +5384,6 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list)
rw_unlock(&LOCK_grant);
close_thread_tables(thd);
- if (result)
- my_error(ER_CANNOT_USER, MYF(0), "CREATE USER", wrong_users.c_ptr_safe());
DBUG_RETURN(result);
}
@@ -5405,6 +5408,7 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list)
LEX_USER *user_name, *tmp_user_name;
List_iterator <LEX_USER> user_list(list);
TABLE_LIST tables[GRANT_TABLES];
+ bool some_users_deleted= FALSE;
DBUG_ENTER("mysql_drop_user");
/* DROP USER may be skipped on replication client. */
@@ -5426,7 +5430,9 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list)
{
append_user(&wrong_users, user_name);
result= TRUE;
+ continue;
}
+ some_users_deleted= TRUE;
}
/* Rebuild 'acl_check_hosts' since 'acl_users' has been modified */
@@ -5440,7 +5446,7 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list)
DBUG_PRINT("info", ("thd->net.last_errno: %d", thd->net.last_errno));
DBUG_PRINT("info", ("thd->net.last_error: %s", thd->net.last_error));
- if (mysql_bin_log.is_open())
+ if (some_users_deleted && mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE);
mysql_bin_log.write(&qinfo);
@@ -5473,6 +5479,7 @@ bool mysql_rename_user(THD *thd, List <LEX_USER> &list)
LEX_USER *user_to, *tmp_user_to;
List_iterator <LEX_USER> user_list(list);
TABLE_LIST tables[GRANT_TABLES];
+ bool some_users_renamed= FALSE;
DBUG_ENTER("mysql_rename_user");
/* RENAME USER may be skipped on replication client. */
@@ -5506,7 +5513,9 @@ bool mysql_rename_user(THD *thd, List <LEX_USER> &list)
{
append_user(&wrong_users, user_from);
result= TRUE;
+ continue;
}
+ some_users_renamed= TRUE;
}
/* Rebuild 'acl_check_hosts' since 'acl_users' has been modified */
@@ -5514,7 +5523,10 @@ bool mysql_rename_user(THD *thd, List <LEX_USER> &list)
VOID(pthread_mutex_unlock(&acl_cache->lock));
- if (mysql_bin_log.is_open())
+ if (result)
+ my_error(ER_CANNOT_USER, MYF(0), "RENAME USER", wrong_users.c_ptr_safe());
+
+ if (some_users_renamed && mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE);
mysql_bin_log.write(&qinfo);
@@ -5522,8 +5534,6 @@ bool mysql_rename_user(THD *thd, List <LEX_USER> &list)
rw_unlock(&LOCK_grant);
close_thread_tables(thd);
- if (result)
- my_error(ER_CANNOT_USER, MYF(0), "RENAME USER", wrong_users.c_ptr_safe());
DBUG_RETURN(result);
}