diff options
author | unknown <Li-Bing.Song@sun.com> | 2010-06-27 12:42:06 +0800 |
---|---|---|
committer | unknown <Li-Bing.Song@sun.com> | 2010-06-27 12:42:06 +0800 |
commit | 451cea3f62a1b53c441995c8e1f052875c4fb3bd (patch) | |
tree | 81bce2c4d3e4822ad29ea031ab6cf72a5ecc3413 /sql/sql_class.h | |
parent | b4593605e0604f22bec09981709a202c809516fc (diff) | |
download | mariadb-git-451cea3f62a1b53c441995c8e1f052875c4fb3bd.tar.gz |
The following statements support the CURRENT_USER() where a user is needed.
DROP USER
RENAME USER CURRENT_USER() ...
GRANT ... TO CURRENT_USER()
REVOKE ... FROM CURRENT_USER()
ALTER DEFINER = CURRENT_USER() EVENTbut, When these statements are binlogged, CURRENT_USER() just is binlogged
as 'CURRENT_USER()', it is not expanded to the real user name. When slave
executes the log event, 'CURRENT_USER()' is expand to the user of slave
SQL thread, but SQL thread's user name always NULL. This breaks the replication.
After this patch, session's user will be written into query log events
if these statements call CURREN_USER() or 'ALTER EVENT' does not assign a definer.
mysql-test/include/diff_tables.inc:
Expend its abilities.
Now it can diff not only in sessions of 'master' and 'slave', but
other sessions as well.
mysql-test/include/rpl_diff_tables.inc:
Diff the same table between master and slaves.
sql/log_event.cc:
session's user will be written into Query_log_event, if is_current_user_used() is TRUE.
On slave SQL thread, Only thd->variables.current_user is written into Query_log_event,
if it exists.
sql/sql_acl.cc:
On slave SQL thread, grantor should copy from thd->variables.current_user, if it exists
sql/sql_class.h:
On slave SQL thread, thd->variables.current_user is used to store the applying event's
invoker.
Diffstat (limited to 'sql/sql_class.h')
-rw-r--r-- | sql/sql_class.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h index 4c1d4a98db0..72ffa2e6ba4 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -401,6 +401,7 @@ struct system_variables DATE_TIME_FORMAT *datetime_format; DATE_TIME_FORMAT *time_format; my_bool sysdate_is_now; + LEX_USER current_user; }; @@ -2340,6 +2341,19 @@ public: Protected with LOCK_thd_data mutex. */ void set_query(char *query_arg, uint32 query_length_arg); + void set_current_user_used() { current_user_used= TRUE; } + bool is_current_user_used() { return current_user_used; } + void clean_current_user_used() { current_user_used= FALSE; } + void get_definer(LEX_USER *definer) + { + set_current_user_used(); +#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) + if (slave_thread && variables.current_user.user.length) + *definer= variables.current_user; + else +#endif + get_default_definer(this, definer); + } private: /** The current internal error handler for this thread, or NULL. */ Internal_error_handler *m_internal_handler; @@ -2359,6 +2373,8 @@ private: tree itself is reused between executions and thus is stored elsewhere. */ MEM_ROOT main_mem_root; + + bool current_user_used; }; |