Bug #48321 CURRENT_USER() incorrectly replicated for DROP/RENAME USER;REVOKE;GRANT;ALTER EV
Submitted: 26 Oct 2009 16:44 Modified: 14 Oct 2010 12:24
Reporter: Sven Sandberg Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:5.1+ OS:Any
Assigned to: Libing Song CPU Architecture:Any
Tags: current_user

[26 Oct 2009 16:44] Sven Sandberg
Description:
The following commands support the CURRENT_USER() function where a user is needed:

DROP USER CURRENT_USER()
RENAME USER CURRENT_USER() ...
GRANT ... TO CURRENT_USER()
REVOKE ... FROM CURRENT_USER()
CREATE DEFINER = CURRENT_USER [FUNCTION | PROCEDURE | TRIGGER | EVENT | VIEW]
ALTER DEFINER = CURRENT_USER [EVENT | VIEW]

For ALTER VIEW and for all CREATE statements, the query is rewritten before it is binlogged, so that CURRENT_USER is expanded to the name of the current user. For DROP USER, RENAME USER, GRANT, REVOKE, and ALTER EVENT, the query is not rewritten and hence CURRENT_USER is not expanded. This breaks replication because CURRENT_USER expands to the user of the slave sql thread on the slave.

How to repeat:
For GRANT and REVOKE, this cannot currently be reproduced due to BUG#41319.

==== test for drop user ====
--source include/master-slave.inc
CREATE USER user@localhost;
GRANT ALL ON *.* TO user@localhost;
GRANT GRANT OPTION ON *.* TO user@localhost;
--connect (user,127.0.0.1,user,,test,$MASTER_MYPORT,)
--connection user
SELECT CURRENT_USER();
DROP USER CURRENT_USER();
sync_slave_with_master;

==== test for rename user ====
--source include/master-slave.inc
CREATE USER user@localhost;
GRANT ALL ON *.* TO user@localhost;
GRANT GRANT OPTION ON *.* TO user@localhost;
--connect (user,127.0.0.1,user,,test,$MASTER_MYPORT,)
--connection user
SELECT CURRENT_USER();
RENAME USER CURRENT_USER() TO other_user@localhost;
sync_slave_with_master;

==== test for alter event ====
--source include/master-slave.inc

CREATE DEFINER=CURRENT_USER() EVENT e1 ON SCHEDULE EVERY 10 YEAR DO INSERT INTO t1 VALUES (1);
ALTER DEFINER=CURRENT_USER() EVENT e1 ON SCHEDULE EVERY 10 YEAR DO INSERT INTO t1 VALUES (1);

SHOW EVENTS;
--sync_slave_with_master
SHOW EVENTS;
[26 Oct 2009 16:52] Sven Sandberg
Just a note: "SET PASSWORD FOR CURRENT_USER = something" also supports CURRENT_USER and is correctly logged.
[26 Oct 2009 17:25] Valeriy Kravchuk
Verified just as described with recent 5.1.41 from bzr on Mac OS X.
[23 Nov 2009 7:25] Libing Song
Hi Sven,
For GRANT and REVOKE, this cannot currently be reproduced due to BUG#48319.
[27 Nov 2009 10:03] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/91881

3202 Li-Bing.Song@sun.com	2009-11-27
      Bug #48321  CURRENT_USER() incorrectly replicated for DROP/RENAME USER;
                  REVOKE/GRANT; ALTER EVENT.
      
      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() EVENT
      but, 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, All above statements are rewritten when they are binlogged.
      The CURRENT_USER() is expanded to the real user's name and host.
[21 Dec 2009 6:22] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/95167

3279 Li-Bing.Song@sun.com	2009-12-21
      Bug #48321  CURRENT_USER() incorrectly replicated for DROP/RENAME USER;
                  REVOKE/GRANT; ALTER EVENT.
      
      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() EVENT
      but, 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, All above statements are rewritten when they are binlogged.
      The CURRENT_USER() is expanded to the real user's name and host.
[22 Dec 2009 9:58] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/95344

3279 Li-Bing.Song@sun.com	2009-12-22
      Bug #48321  CURRENT_USER() incorrectly replicated for DROP/RENAME USER;
                  REVOKE/GRANT; ALTER EVENT.
      
      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() EVENT
      but, 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, All above statements are rewritten when they are binlogged.
      The CURRENT_USER() is expanded to the real user's name and host.
[24 Dec 2009 4:12] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/95614

3279 Li-Bing.Song@sun.com	2009-12-24
      Bug #48321  CURRENT_USER() incorrectly replicated for DROP/RENAME USER;
                  REVOKE/GRANT; ALTER EVENT.
      
      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() EVENT
      but, 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, All above statements are rewritten when they are binlogged.
      The CURRENT_USER() is expanded to the real user's name and host.
[29 Dec 2009 7:43] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/95769

3279 Li-Bing.Song@sun.com	2009-12-29
      Bug #48321  CURRENT_USER() incorrectly replicated for DROP/RENAME USER;
                  REVOKE/GRANT; ALTER EVENT.
      
      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() EVENT
      but, 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, All above statements are rewritten when they are binlogged.
      The CURRENT_USER() is expanded to the real user's name and host.
[17 Jan 2010 15:13] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/97194

3318 Li-Bing.Song@sun.com	2010-01-17
      Bug #48321  CURRENT_USER() incorrectly replicated for DROP/RENAME USER;
                  REVOKE/GRANT; ALTER EVENT.
      
      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() EVENT
      but, 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, All above statements are rewritten when they are binlogged.
      The CURRENT_USER() is expanded to the real user's name and host.
[17 Jan 2010 16:14] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/97195

3318 Li-Bing.Song@sun.com	2010-01-18
      Bug #48321  CURRENT_USER() incorrectly replicated for DROP/RENAME USER;
                  REVOKE/GRANT; ALTER EVENT.
      
      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() EVENT
      but, 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, All above statements are rewritten when they are binlogged.
      The CURRENT_USER() is expanded to the real user's name and host.
[23 Jan 2010 13:26] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/97977

3333 Li-Bing.Song@sun.com	2010-01-23
      Bug #48321  CURRENT_USER() incorrectly replicated for DROP/RENAME USER;
                  REVOKE/GRANT; ALTER EVENT.
      
      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() EVENT
      but, 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, All above statements are rewritten when they are binlogged.
      The CURRENT_USER() is expanded to the real user's name and host.
[28 Jan 2010 7:50] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/98426

3339 Li-Bing.Song@sun.com	2010-01-28
      Bug #48321  CURRENT_USER() incorrectly replicated for DROP/RENAME USER;
                  REVOKE/GRANT; ALTER EVENT.
      
      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() EVENT
      but, 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, All above statements are rewritten when they are binlogged.
      The CURRENT_USER() is expanded to the real user's name and host.
[30 Jan 2010 4:17] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/98701

3343 Li-Bing.Song@sun.com	2010-01-30
      Bug #48321  CURRENT_USER() incorrectly replicated for DROP/RENAME USER;
                  REVOKE/GRANT; ALTER EVENT.
      
      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() EVENT
      but, 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, All above statements are rewritten when they are binlogged.
      The CURRENT_USER() is expanded to the real user's name and host.
[30 Jan 2010 9:16] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/98702

3343 Li-Bing.Song@sun.com	2010-01-30
      Bug #48321  CURRENT_USER() incorrectly replicated for DROP/RENAME USER;
                  REVOKE/GRANT; ALTER EVENT.
      
      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() EVENT
      but, 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, All above statements are rewritten when they are binlogged.
      The CURRENT_USER() is expanded to the real user's name and host.
[30 Jan 2010 12:51] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/98706

3343 Li-Bing.Song@sun.com	2010-01-30
      Bug #48321  CURRENT_USER() incorrectly replicated for DROP/RENAME USER;
                  REVOKE/GRANT; ALTER EVENT.
      
      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() EVENT
      but, 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, All above statements are rewritten when they are binlogged.
      The CURRENT_USER() is expanded to the real user's name and host.
[31 Jan 2010 8:29] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/98759

3862 Li-Bing.Song@sun.com	2010-01-31
      Postfix for BUG#48321
[31 Jan 2010 8:57] Libing Song
Pushed into mysql-5.1-bugteam and merged into mysql-pe
[2 Feb 2010 13:39] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/98950

3348 Alexander Nozdrin	2010-02-02
      Revert a patch for Bug#48231, which introduced valgrind warnings.
      Original revision:
      ------------------------------------------------------------
      revision-id: li-bing.song@sun.com-20100130124925-o6sfex42b6noyc6x
      parent: joro@sun.com-20100129145427-0n79l9hnk0q43ajk
      committer: <Li-Bing.Song@sun.com>
      branch nick: mysql-5.1-bugteam
      timestamp: Sat 2010-01-30 20:49:25 +0800
      message:
        Bug #48321  CURRENT_USER() incorrectly replicated for DROP/RENAME USER;
                    REVOKE/GRANT; ALTER EVENT.
        
        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() EVENT
        but, 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, All above statements are rewritten when they are binlogged.
        The CURRENT_USER() is expanded to the real user's name and host.
      ------------------------------------------------------------
[4 Feb 2010 10:20] Bugs System
Pushed into 5.1.44 (revid:joro@sun.com-20100204101444-2j32mhqroo0iiio6) (version source revid:li-bing.song@sun.com-20100130124925-o6sfex42b6noyc6x) (merge vers: 5.1.43) (pib:16)
[5 Feb 2010 11:49] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100204063540-9czpdmpixi3iw2yb) (version source revid:alik@sun.com-20100203162117-gjiiuzj6sq2ohlss) (pib:16)
[5 Feb 2010 11:54] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100205113942-oqovjy0eoqbarn7i) (version source revid:alik@sun.com-20100204064210-ljwanqvrjs83s1gq) (merge vers: 6.0.14-alpha) (pib:16)
[5 Feb 2010 12:01] Bugs System
Pushed into 5.5.2-m2 (revid:alik@sun.com-20100203172258-1n5dsotny40yufxw) (version source revid:alik@sun.com-20100203140148-nmlve92a9cq69vp9) (merge vers: 5.5.2-m2) (pib:16)
[3 Mar 2010 18:04] Andrei Elkin
LiBing, I wonder what's the approach you're holding now, but
an approach of the latest fixes for bug#49124 introducing Q_MASTER_VERSION a new Query_log_event status variable is something to consider for this task.

cheers,

Andrei
[12 Mar 2010 14:07] Bugs System
Pushed into 5.1.44-ndb-7.0.14 (revid:jonas@mysql.com-20100312135944-t0z8s1da2orvl66x) (version source revid:jonas@mysql.com-20100312115609-woou0te4a6s4ae9y) (merge vers: 5.1.44-ndb-7.0.14) (pib:16)
[12 Mar 2010 14:23] Bugs System
Pushed into 5.1.44-ndb-6.2.19 (revid:jonas@mysql.com-20100312134846-tuqhd9w3tv4xgl3d) (version source revid:jonas@mysql.com-20100312060623-mx6407w2vx76h3by) (merge vers: 5.1.44-ndb-6.2.19) (pib:16)
[12 Mar 2010 14:37] Bugs System
Pushed into 5.1.44-ndb-6.3.33 (revid:jonas@mysql.com-20100312135724-xcw8vw2lu3mijrhn) (version source revid:jonas@mysql.com-20100312103652-snkltsd197l7q2yg) (merge vers: 5.1.44-ndb-6.3.33) (pib:16)
[23 Mar 2010 13:29] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/104085

3368 Li-Bing.Song@sun.com	2010-03-23
      Bug #48321  CURRENT_USER() incorrectly replicated for DROP/RENAME USER;
                  REVOKE/GRANT; ALTER EVENT.
      
      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() EVENT
      but, 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/extra/rpl_tests/rpl_diff_tables.test
        Diff the same table between master and slaves.
     @ 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->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.
[13 May 2010 4:59] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/108214

3378 Li-Bing.Song@sun.com	2010-05-13
      Bug #48321  CURRENT_USER() incorrectly replicated for DROP/RENAME USER;
                  REVOKE/GRANT; ALTER EVENT.
      
      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() EVENT
      but, 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/extra/rpl_tests/rpl_diff_tables.test
        Diff the same table between master and slaves.
     @ 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->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.
[21 May 2010 15:54] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/108908

3378 Li-Bing.Song@sun.com	2010-05-21
      Bug #48321  CURRENT_USER() incorrectly replicated for DROP/RENAME USER;
                        REVOKE/GRANT; ALTER EVENT.
            
      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.
[23 Jun 2010 7:26] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/111860

3438 Li-Bing.Song@sun.com	2010-06-23
      Bug #48321  CURRENT_USER() incorrectly replicated for DROP/RENAME USER;
                  REVOKE/GRANT; ALTER EVENT.
                  
      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() EVENT
      but, 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.
[27 Jun 2010 8:39] Libing Song
Pushed to mysql-5.1-bugteam and merged to mysql-trunk-merge
[28 Jun 2010 21:00] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/112385

3450 Davi Arnaut	2010-06-28
      Revert Bug#48321 due to build breakage and failing tests.
[4 Jul 2010 8:22] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/112825

3462 Li-Bing.Song@sun.com	2010-07-04
      Postfix for bug#48321
      Some test cases set ANSI_QUOTES in sql_mode.
      So we have to use single quotes to quote literal strings.
[8 Jul 2010 1:22] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/113079

3468 Li-Bing.Song@sun.com	2010-07-08
      Postfix bug #48321 
      sovle memory leak
[8 Jul 2010 2:32] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/113082

3469 Li-Bing.Song@sun.com	2010-07-08
      Postfix bug#48321
      Fix the memory leak
[19 Jul 2010 14:35] Bugs System
Pushed into 5.1.49 (revid:build@mysql.com-20100719143034-omcma40sblwmay3x) (version source revid:davi.arnaut@sun.com-20100628205941-3udl3q45glumvuz0) (merge vers: 5.1.48) (pib:16)
[22 Jul 2010 10:00] Jon Stephens
Documented bugfix in the 5.1.49 changelog as follows:

        When CURRRENT_USER() or CURRENT_USER was used to supply the name
        and host of the affected user or of the definer in any of the
        statements DROP USER, RENAME USER, GRANT, REVOKE, and ALTER
        EVENT, the reference to CURRENT_USER() or CURRENT_USER was not 
        expanded when written to the binary log. This resulted in 
        CURRENT_USER() or CURRENT_USER being expanded to the user and 
        host of the slave SQL thread on the slave, thus breaking 
        replication. Now CURRENT_USER() and CURRENT_USER are expanded 
        prior to being written to the binary log in such cases, so that 
        the correct user and host are referenced on both the master and 
        the slave.

Also updated CURRENT_USER() description in the Manual, and added a new section "Replication of CURRENT_USER()" to http://dev.mysql.com/doc/refman/5.1/en/replication-features.html -- see http://lists.mysql.com/commits/114123 for all related docs changes. 

Set to NM status, waiting for merge to 5.5 tree.
[23 Jul 2010 12:22] Bugs System
Pushed into mysql-trunk 5.5.6-m3 (revid:alik@sun.com-20100723121820-jryu2fuw3pc53q9w) (version source revid:vasil.dimov@oracle.com-20100531152341-x2d4hma644icamh1) (merge vers: 5.5.5-m3) (pib:18)
[23 Jul 2010 12:29] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100723121929-90e9zemk3jkr2ocy) (version source revid:vasil.dimov@oracle.com-20100531152341-x2d4hma644icamh1) (pib:18)
[3 Aug 2010 13:17] Jon Stephens
Also documented in the 5.5.6 changelog. Closed.
[19 Aug 2010 15:41] Bugs System
Pushed into mysql-5.1 5.1.51 (revid:build@mysql.com-20100819151858-muaaor6jojb5ouzj) (version source revid:build@mysql.com-20100819151858-muaaor6jojb5ouzj) (merge vers: 5.1.51) (pib:20)
[24 Sep 2010 19:00] Sveta Smirnova
Bug #56421 was marked as duplicate of this one.
[14 Oct 2010 8:27] Bugs System
Pushed into mysql-5.1-telco-7.0 5.1.51-ndb-7.0.20 (revid:martin.skold@mysql.com-20101014082627-jrmy9xbfbtrebw3c) (version source revid:martin.skold@mysql.com-20101014082627-jrmy9xbfbtrebw3c) (merge vers: 5.1.51-ndb-7.0.20) (pib:21)
[14 Oct 2010 8:42] Bugs System
Pushed into mysql-5.1-telco-6.3 5.1.51-ndb-6.3.39 (revid:martin.skold@mysql.com-20101014083757-5qo48b86d69zjvzj) (version source revid:martin.skold@mysql.com-20101014083757-5qo48b86d69zjvzj) (merge vers: 5.1.51-ndb-6.3.39) (pib:21)
[14 Oct 2010 8:56] Bugs System
Pushed into mysql-5.1-telco-6.2 5.1.51-ndb-6.2.19 (revid:martin.skold@mysql.com-20101014084420-y54ecj85j5we27oa) (version source revid:martin.skold@mysql.com-20101014084420-y54ecj85j5we27oa) (merge vers: 5.1.51-ndb-6.2.19) (pib:21)
[14 Oct 2010 12:24] Jon Stephens
No new changelog entry required. Setting back to Closed state.