• unknown's avatar
    The following statements support the CURRENT_USER() where a user is needed. · 1a17d7e8
    unknown authored
    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.
    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->invoker is written into Query_log_event,
      if it exists.
    sql/sql_acl.cc:
      On slave SQL thread, grantor should copy from thd->invoker, if it exists
    sql/sql_class.h:
      On slave SQL thread, thd->invoker is used to store the applying event's
      invoker.
    1a17d7e8
sql_acl.cc 197 KB