• unknown's avatar
    The following statements support the CURRENT_USER() where a user is needed. · 451cea3f
    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.
    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.
    451cea3f
rpl_current_user.result 6.43 KB