3753 magnus.blaudd@stripped 2012-05-11
WL#6004 Server extension for allowing user tables to be put into transactional
SE
- patch 2, adds calls into handler so that updates to ACL tables can be
propagated to other mysql servers in a cluster
modified:
sql/handler.h
sql/sql_acl.cc
3752 magnus.blaudd@stripped 2012-05-11
WL#6004 Server extension for allowing user tables to be put into transactional
SE
- patch 1 which adds commit/rollback into ACL code
modified:
sql/event_db_repository.cc
sql/sql_acl.cc
=== modified file 'sql/handler.h'
--- a/sql/handler.h 2012-04-24 15:44:07 +0000
+++ b/sql/handler.h 2012-05-11 17:04:49 +0000
@@ -374,7 +374,12 @@ enum enum_binlog_command {
LOGCOM_DROP_TABLE,
LOGCOM_CREATE_DB,
LOGCOM_ALTER_DB,
- LOGCOM_DROP_DB
+ LOGCOM_DROP_DB,
+ LOGCOM_CREATE_USER,
+ LOGCOM_DROP_USER,
+ LOGCOM_RENAME_USER,
+ LOGCOM_GRANT,
+ LOGCOM_REVOKE
};
/* struct to hold information about the table that should be created */
=== modified file 'sql/sql_acl.cc'
--- a/sql/sql_acl.cc 2012-05-11 14:20:23 +0000
+++ b/sql/sql_acl.cc 2012-05-11 17:04:49 +0000
@@ -49,6 +49,7 @@
#include "sql_connect.h"
#include "hostname.h"
#include "sql_db.h"
+#include "handler.h"
using std::min;
using std::max;
@@ -1907,6 +1908,7 @@ bool change_password(THD *thd, const cha
bool save_binlog_row_based;
uint new_password_len= (uint) strlen(new_password);
bool result= 1;
+ bool do_distribute= 0;
DBUG_ENTER("change_password");
DBUG_PRINT("enter",("host: '%s' user: '%s' new_password: '%s'",
host,user,new_password));
@@ -1991,6 +1993,7 @@ bool change_password(THD *thd, const cha
else
{
result= 1;
+ do_distribute= 0;
DBUG_PRINT("info", ("%u: Commit DDL transaction failed: %d",
__LINE__, err));
}
@@ -1998,11 +2001,21 @@ bool change_password(THD *thd, const cha
else
{
DBUG_PRINT("info", ("%u: Aborting DDL transaction", __LINE__));
+ do_distribute= 0;
trans_rollback_stmt(thd);
}
assert(thd->transaction.stmt.is_empty());
}
+ if (result)
+ {
+ do_distribute= 0;
+ }
+ else
+ {
+ do_distribute= 1;
+ }
+
if (!result && mysql_bin_log.is_open())
{
query_length= sprintf(buff, "SET PASSWORD FOR '%-.120s'@'%-.120s'='%-.120s'",
@@ -2026,6 +2039,17 @@ end:
assert(thd->transaction.stmt.is_empty());
}
+ if (do_distribute)
+ {
+ query_length= sprintf(buff, "SET PASSWORD FOR '%-.120s'@'%-.120s'='%-.120s'",
+ acl_user->user ? acl_user->user : "",
+ acl_user->host.get_host() ? acl_user->host.get_host() : "",
+ new_password);
+ ha_binlog_log_query(thd, 0, LOGCOM_GRANT,
+ buff, query_length,
+ "mysql", "");
+ }
+
close_thread_tables(thd);
/* Restore the state of binlog format */
@@ -3849,11 +3873,23 @@ int mysql_table_grant(THD *thd, TABLE_LI
assert(thd->transaction.stmt.is_empty());
}
+ bool do_distribute= !result;
+
if (should_write_to_binlog)
result= result |
write_bin_log(thd, FALSE, thd->query(), thd->query_length());
mysql_rwlock_unlock(&LOCK_grant);
+ if (do_distribute)
+ {
+ ha_binlog_log_query(thd, 0, LOGCOM_GRANT,
+ thd->query(), thd->query_length(),
+ (table_list->get_db_name())?table_list->get_db_name():
+ ((thd->lex->select_lex.db)?thd->lex->select_lex.db:
+ "mysql"),
+ "");
+ }
+
if (!result) /* success */
my_ok(thd);
@@ -4235,6 +4271,8 @@ bool mysql_grant(THD *thd, const char *d
assert(thd->transaction.stmt.is_empty());
}
+ bool do_distribute= !result;
+
if (should_write_to_binlog)
{
if (thd->rewritten_query.length())
@@ -4249,6 +4287,15 @@ bool mysql_grant(THD *thd, const char *d
mysql_rwlock_unlock(&LOCK_grant);
+ if (do_distribute)
+ {
+ ha_binlog_log_query(thd, 0, LOGCOM_GRANT,
+ thd->query(), thd->query_length(),
+ (db)?db:
+ ((thd->lex->select_lex.db)?thd->lex->select_lex.db:
+ "mysql"), "");
+ }
+
if (!result)
my_ok(thd);
/* Restore the state of binlog format */
@@ -6725,6 +6772,14 @@ bool mysql_create_user(THD *thd, List <L
}
mysql_rwlock_unlock(&LOCK_grant);
+
+ if (some_users_created)
+ {
+ ha_binlog_log_query(thd, 0, LOGCOM_CREATE_USER,
+ thd->query(), thd->query_length(),
+ "mysql", "");
+ }
+
/* Restore the state of binlog format */
DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row());
if (save_binlog_row_based)
@@ -6835,6 +6890,14 @@ bool mysql_drop_user(THD *thd, List <LEX
result |= write_bin_log(thd, FALSE, thd->query(), thd->query_length());
mysql_rwlock_unlock(&LOCK_grant);
+
+ if (some_users_deleted)
+ {
+ ha_binlog_log_query(thd, 0, LOGCOM_DROP_USER,
+ thd->query(), thd->query_length(),
+ "mysql", "");
+ }
+
thd->variables.sql_mode= old_sql_mode;
/* Restore the state of binlog format */
DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row());
@@ -6958,6 +7021,14 @@ bool mysql_rename_user(THD *thd, List <L
result |= write_bin_log(thd, FALSE, thd->query(), thd->query_length());
mysql_rwlock_unlock(&LOCK_grant);
+
+ if (some_users_renamed)
+ {
+ ha_binlog_log_query(thd, 0, LOGCOM_RENAME_USER,
+ thd->query(), thd->query_length(),
+ "mysql", "");
+ }
+
/* Restore the state of binlog format */
DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row());
if (save_binlog_row_based)
@@ -6985,6 +7056,7 @@ bool mysql_revoke_all(THD *thd, List <L
uint counter, revoked, is_proc;
int result;
ACL_DB *acl_db;
+ char *db= NULL;
TABLE_LIST tables[GRANT_TABLES];
bool save_binlog_row_based, should_write_to_binlog= FALSE;
DBUG_ENTER("mysql_revoke_all");
@@ -7065,6 +7137,7 @@ bool mysql_revoke_all(THD *thd, List <L
current element in acl_dbs.
*/
revoked= 1;
+ db= acl_db->db;
continue;
}
result= -1; // Something went wrong
@@ -7186,6 +7259,14 @@ bool mysql_revoke_all(THD *thd, List <L
write_bin_log(thd, FALSE, thd->query(), thd->query_length());
}
+ if (true) // statment is always written to binlog??
+ {
+ ha_binlog_log_query(thd, 0, LOGCOM_REVOKE,
+ thd->query(), thd->query_length(),
+ (db)?db:((thd->lex->select_lex.db)?
+ thd->lex->select_lex.db:"mysql"), "");
+ }
+
mysql_rwlock_unlock(&LOCK_grant);
/* Restore the state of binlog format */
DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row());
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk branch (magnus.blaudd:3752 to 3753) WL#6004 | magnus.blaudd | 21 May |