1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

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.
This commit is contained in:
2010-06-27 12:42:06 +08:00
parent 9fa66b6440
commit 899a1d694f
12 changed files with 602 additions and 21 deletions

View File

@ -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;
};