Bug #55452 SET PASSWORD is replicated twice in RBR mode
Submitted: 21 Jul 2010 17:47 Modified: 15 Nov 2010 13:25
Reporter: Konstantin Osipov (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Row Based Replication ( RBR ) Severity:S3 (Non-critical)
Version:5.1, 5.6.99 bzr OS:Any
Assigned to: Konstantin Osipov
Triage: Triaged: D3 (Medium)

[21 Jul 2010 17:47] Konstantin Osipov
Description:
SET PASSWORD statement in RBR mode generates two sets of events -- for statement-based and row-based replication.

How to repeat:
Start the server with --binlog-format=row and --log-bin

CREATE USER rpl_do_grant@localhost;
SET PASSWORD FOR 
'rpl_do_grant'@'localhost'='*9313F3AC73D127EF8B2C6F70435C8C113F50C412';

-- then inspect the binary log.
SHOW BINLOG EVENTS;
[21 Jul 2010 17:53] Konstantin Osipov
The buggy behavior is even covered in the result file for  rpl.rpl_row_implicit_commit_binlog:
CURRENT_TEST: rpl.rpl_row_implicit_commit_binlog
--- /opt/local/work/trunk-runtime/mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result	2010-05-24 15:26:54.000000000 +0300
+++ /opt/local/work/trunk-runtime/mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.reject	2010-07-21 20:38:52.000000000 +0300
@@ -165,10 +165,6 @@
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Xid	#	#	COMMIT /* XID */
 master-bin.000001	#	Query	#	#	use `test`; SET PASSWORD FOR 'user'@'localhost'='*D8DECEC305209EEFEC43008E1D420E1AA06B19E0'
-master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Table_map	#	#	table_id: # (mysql.user)
-master-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	COMMIT
[21 Jul 2010 20:52] Sveta Smirnova
Thank you for the report.

Verified as described.
[22 Jul 2010 14: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/114145

3082 Konstantin Osipov	2010-07-22
      A pre-requisite patch for the fix for Bug#52044.
      This patch also fixes Bug#55452 "SET PASSWORD is
      replicated twice in RBR mode"
      
      Cleanup COM_FIELD_LIST.
      Don't call close_thread_tables() in COM_SHUTDOWN -- there
      are no open tables there that can be closed (we leave
      the locked tables mode in THD destructor, and this
      close_thread_tables() won't leave it anyway).
      
      Make open_and_lock_tables() and open_and_lock_tables_derived()
      call close_thread_tables() upon failure.
      Remove the calls to close_thread_tables that are now unnecessary.
      
      Remove the release of metadata locks
      from close_thread_tables().
      
      Simplify the back off condition in Open_table_context.
      
      Move statement commit outside 
      close_thread_tables().
      
      Streamline metadata lock handling in LOCK TABLES 
      implementation.
      
      Add asserts to ensure correct life cycle of 
      statement transaction in a session.
     @ mysql-test/r/view.result
        A harmless change in CHECK TABLE <view> status for a broken view.
        If previously a failure to prelock all functions used in a view 
        would leave the connection in LTM_PRELOCKED mode, now we call
        close_thread_tables() from open_and_lock_tables()
        and leave prelocked mode, thus some check in mysql_admin_table() that
        works only in prelocked/locked tables mode is no longer activated.
     @ mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result
        Fixed Bug#55452 "SET PASSWORD is replicated twice in
        RBR mode": extra binlog events are gone from the
        binary log.
     @ sql/event_data_objects.cc
        Simplify code in Event_job_data::execute().
        Move sp_head memory management to lex_end().
     @ sql/event_db_repository.cc
        Move the release of metadata locks outside
        close_thread_tables().
        Make sure we call close_thread_tables() when
        open_and_lock_tables() fails and remove extra
        code from the events data dictionary.
        Use close_mysql_tables(), a new internal
        function to properly close mysql.* tables
        in the data dictionary.
        Contract Event_db_repository::drop_events_by_field,
        drop_schema_events into one function.
        When dropping all events in a schema,
        make sure we don't mistakenly release all
        locks acquired by DROP DATABASE. These
        include locks in the database name
        and the global shared metadata lock.
     @ sql/event_db_repository.h
        Function open_event_table() does not require an instance 
        of Event_db_repository.
     @ sql/events.cc
        Use close_mysql_tables() instead of close_thread_tables()
        to bootstrap events, since the latter no longer
        releases metadata locks.
     @ sql/ha_ndbcluster.cc
        - mysql_rm_table_part2 no longer releases
        acquired metadata locks. Do it in the caller.
     @ sql/ha_ndbcluster_binlog.cc
        Deploy the new protocol for closing thread
        tables in run_query() and ndb_binlog_index
        code.
     @ sql/handler.cc
        Assert that we never call ha_commit_trans/
        ha_rollback_trans in sub-statement, which
        is now the case.
     @ sql/handler.h
        Add an accessor to check whether THD_TRANS object
        is empty (has no transaction started).
     @ sql/log.cc
        Update a comment.
     @ sql/log_event.cc
        Since now we commit/rollback statement transaction in 
        mysql_execute_command(), we need a mechanism to communicate
        from Query_log_event::do_apply_event() to mysql_execute_command()
        that the statement transaction should be rolled back, not committed.
        Ideally it would be a virtual method of THD. I hesitate
        to make THD a virtual base class in this already large patch.
        Use a thd->variables.option_bits for now.
        
        Remove a call to close_thread_tables() from the slave IO
        thread. It doesn't open any tables, and the protocol
        for closing thread tables is more complicated now.
        
        Make sure we properly close thread tables, however, 
        in Load_data_log_event, which doesn't
        follow the standard server execution procedure
        with mysql_execute_command().
        @todo: this piece should use Server_runnable
        framework instead.
        Remove an unnecessary call to mysql_unlock_tables().
     @ sql/rpl_rli.cc
        Update Relay_log_info::slave_close_thread_tables()
        to follow the new close protocol.
     @ sql/set_var.cc
        Remove an unused header.
     @ sql/slave.cc
        Remove an unnecessary call to
        close_thread_tables().
     @ sql/sp.cc
        Remove unnecessary calls to close_thread_tables()
        from SP DDL implementation. The tables will
        be closed by the caller, in mysql_execute_command().
        When dropping all routines in a database, make sure
        to not mistakenly all metadata locks acquired
        so far, they include the scoped lock on the schema.
     @ sql/sp_head.cc
        Correct the protocol that closes thread tables
        in an SP instruction.
        Clear lex->sphead before cleaning up lex
        with lex_end to make sure that we don't
        delete the sphead twice. It's considered
        to be "cleaner" and more in line with
        future changes than calling delete lex->sphead
        in other places that cleanup the lex.
     @ sql/sp_head.h
        When destroying m_lex_keeper of an instruction,
        don't delete the sphead that all lex objects
        share. 
        @todo: don't store a reference to routine's sp_head
        instance in instruction's lex.
     @ sql/sql_acl.cc
        Don't call close_thread_tables() where the caller will
        do that for us.
        Fix Bug#55452 "SET PASSWORD is replicated twice in RBR 
        mode" by disabling RBR replication in change_password()
        function.
        Use close_mysql_tables() in bootstrap and ACL reload
        code to make sure we release all metadata locks.
     @ sql/sql_base.cc
        This is the main part of the patch:
        - remove manipulation with thd->transaction
        and thd->mdl_context from close_thread_tables().
        Now this function is only responsible for closing
        tables, nothing else.
        This is necessary to be able to easily use
        close_thread_tables() in procedures, that
        involve multiple open/close tables, which all
        need to be protected continuously by metadata
        locks.
        Add asserts ensuring that TABLE object
        is only used when is protected by a metadata lock.
        Simplify the back off condition of Open_table_context,
        we no longer need to look at the autocommit mode.
        Make open_and_lock_tables() and open_normal_and_derived_tables()
        close thread tables and release metadata locks acquired so-far 
        upon failure. This simplifies their usage.
        Implement close_mysql_tables().
     @ sql/sql_base.h
        Add declaration for close_mysql_tables().
     @ sql/sql_do.cc
        Do nothing in DO if inside a substatement
        (the assert moved out of trans_rollback_stmt).
     @ sql/sql_handler.cc
        Add comments.
     @ sql/sql_insert.cc
        Remove dead code. 
        Release metadata locks explicitly at the
        end of the delayed insert thread.
     @ sql/sql_lex.cc
        Add destruction of lex->sphead to lex_end(),
        lex "reset" method called at the end of each statement.
     @ sql/sql_parse.cc
        Move close_thread_tables() and other related
        cleanups to mysql_execute_command()
        from dispatch_command(). This has become
        possible after the fix for Bug#37521.
        Mark federated SERVER statements as DDL.
        
        Next step: make sure that we don't store
        eof packet in the query cache, and move
        the query cache code outside mysql_parse.
        
        Brush up the code of COM_FIELD_LIST.
        Remove unnecessary calls to close_thread_tables().
        
        When killing a query, don't report "OK"
        if it was a suicide.
     @ sql/sql_parse.h
        Remove declaration of a function that is now static.
     @ sql/sql_partition.cc
        Remove anunnecessary call to close_thread_tables().
     @ sql/sql_plugin.cc
        open_and_lock_tables() will clean up
        after itself after a failure.
        Move close_thread_tables() above
        end: label, and replace with close_mysql_tables(),
        which will also release the metadata lock
        on mysql.plugin.
     @ sql/sql_prepare.cc
        Now that we no longer release locks in close_thread_tables()
        statement prepare code has become more straightforward.
        Remove the now redundant check for thd->killed() (used
        only by the backup project) from Execute_server_runnable.
        Reorder code to take into account that now mysql_execute_command()
        performs lex->unit.cleanup() and close_thread_tables().
     @ sql/sql_priv.h
        Add a new option to server options to interact
        between the slave SQL thread and execution
        framework (hack). @todo: use a virtual
        method of class THD instead.
     @ sql/sql_servers.cc
        Due to Bug 25705 replication of 
        DROP/CREATE/ALTER SERVER is broken.
        Make sure at least we do not attempt to 
        replicate these statements using RBR,
        as this violates the assert in close_mysql_tables().
     @ sql/sql_table.cc
        Do not release metadata locks in mysql_rm_table_part2,
        this is done by the caller.
        Do not call close_thread_tables() in mysql_create_table(),
        this is done by the caller. 
        Fix a bug in DROP TABLE under LOCK TABLES when,
        upon error in wait_while_table_is_used() we would mistakenly
        release the metadata lock on a non-dropped table.
        Explicitly release metadata locks when doing an implicit
        commit.
     @ sql/sql_trigger.cc
        Now that we delete lex->sphead in lex_end(),
        zero the trigger's sphead in lex after loading
        the trigger, to avoid double deletion.
     @ sql/sql_udf.cc
        Use close_mysql_tables() instead of close_thread_tables().
     @ sql/transaction.cc
        Add asserts.
     @ sql/tztime.cc
        Use close_mysql_tables() rather than close_thread_tables().
[22 Jul 2010 14:41] 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/114152

3082 Konstantin Osipov	2010-07-22
      A pre-requisite patch for the fix for Bug#52044.
      This patch also fixes Bug#55452 "SET PASSWORD is
      replicated twice in RBR mode".
      
      Cleanup COM_FIELD_LIST.
      Don't call close_thread_tables() in COM_SHUTDOWN -- there
      are no open tables there that can be closed (we leave
      the locked tables mode in THD destructor, and this
      close_thread_tables() won't leave it anyway).
      
      Make open_and_lock_tables() and open_and_lock_tables_derived()
      call close_thread_tables() upon failure.
      Remove the calls to close_thread_tables that are now unnecessary.
      
      Remove the release of metadata locks
      from close_thread_tables().
      
      Simplify the back off condition in Open_table_context.
      
      Move statement commit outside 
      close_thread_tables().
      
      Streamline metadata lock handling in LOCK TABLES 
      implementation.
      
      Add asserts to ensure correct life cycle of 
      statement transaction in a session.
     @ mysql-test/r/variables.result
        Update results: set @@autocommit and statement transaction/
        prelocked mode.
     @ mysql-test/r/view.result
        A harmless change in CHECK TABLE <view> status for a broken view.
        If previously a failure to prelock all functions used in a view 
        would leave the connection in LTM_PRELOCKED mode, now we call
        close_thread_tables() from open_and_lock_tables()
        and leave prelocked mode, thus some check in mysql_admin_table() that
        works only in prelocked/locked tables mode is no longer activated.
     @ mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result
        Fixed Bug#55452 "SET PASSWORD is replicated twice in
        RBR mode": extra binlog events are gone from the
        binary log.
     @ mysql-test/t/variables.test
        Add a test case: set autocommit and statement transaction/prelocked
        mode.
     @ sql/event_data_objects.cc
        Simplify code in Event_job_data::execute().
        Move sp_head memory management to lex_end().
     @ sql/event_db_repository.cc
        Move the release of metadata locks outside
        close_thread_tables().
        Make sure we call close_thread_tables() when
        open_and_lock_tables() fails and remove extra
        code from the events data dictionary.
        Use close_mysql_tables(), a new internal
        function to properly close mysql.* tables
        in the data dictionary.
        Contract Event_db_repository::drop_events_by_field,
        drop_schema_events into one function.
        When dropping all events in a schema,
        make sure we don't mistakenly release all
        locks acquired by DROP DATABASE. These
        include locks in the database name
        and the global shared metadata lock.
     @ sql/event_db_repository.h
        Function open_event_table() does not require an instance 
        of Event_db_repository.
     @ sql/events.cc
        Use close_mysql_tables() instead of close_thread_tables()
        to bootstrap events, since the latter no longer
        releases metadata locks.
     @ sql/ha_ndbcluster.cc
        - mysql_rm_table_part2 no longer releases
        acquired metadata locks. Do it in the caller.
     @ sql/ha_ndbcluster_binlog.cc
        Deploy the new protocol for closing thread
        tables in run_query() and ndb_binlog_index
        code.
     @ sql/handler.cc
        Assert that we never call ha_commit_trans/
        ha_rollback_trans in sub-statement, which
        is now the case.
     @ sql/handler.h
        Add an accessor to check whether THD_TRANS object
        is empty (has no transaction started).
     @ sql/log.cc
        Update a comment.
     @ sql/log_event.cc
        Since now we commit/rollback statement transaction in 
        mysql_execute_command(), we need a mechanism to communicate
        from Query_log_event::do_apply_event() to mysql_execute_command()
        that the statement transaction should be rolled back, not committed.
        Ideally it would be a virtual method of THD. I hesitate
        to make THD a virtual base class in this already large patch.
        Use a thd->variables.option_bits for now.
        
        Remove a call to close_thread_tables() from the slave IO
        thread. It doesn't open any tables, and the protocol
        for closing thread tables is more complicated now.
        
        Make sure we properly close thread tables, however, 
        in Load_data_log_event, which doesn't
        follow the standard server execution procedure
        with mysql_execute_command().
        @todo: this piece should use Server_runnable
        framework instead.
        Remove an unnecessary call to mysql_unlock_tables().
     @ sql/rpl_rli.cc
        Update Relay_log_info::slave_close_thread_tables()
        to follow the new close protocol.
     @ sql/set_var.cc
        Remove an unused header.
     @ sql/slave.cc
        Remove an unnecessary call to
        close_thread_tables().
     @ sql/sp.cc
        Remove unnecessary calls to close_thread_tables()
        from SP DDL implementation. The tables will
        be closed by the caller, in mysql_execute_command().
        When dropping all routines in a database, make sure
        to not mistakenly all metadata locks acquired
        so far, they include the scoped lock on the schema.
     @ sql/sp_head.cc
        Correct the protocol that closes thread tables
        in an SP instruction.
        Clear lex->sphead before cleaning up lex
        with lex_end to make sure that we don't
        delete the sphead twice. It's considered
        to be "cleaner" and more in line with
        future changes than calling delete lex->sphead
        in other places that cleanup the lex.
     @ sql/sp_head.h
        When destroying m_lex_keeper of an instruction,
        don't delete the sphead that all lex objects
        share. 
        @todo: don't store a reference to routine's sp_head
        instance in instruction's lex.
     @ sql/sql_acl.cc
        Don't call close_thread_tables() where the caller will
        do that for us.
        Fix Bug#55452 "SET PASSWORD is replicated twice in RBR 
        mode" by disabling RBR replication in change_password()
        function.
        Use close_mysql_tables() in bootstrap and ACL reload
        code to make sure we release all metadata locks.
     @ sql/sql_base.cc
        This is the main part of the patch:
        - remove manipulation with thd->transaction
        and thd->mdl_context from close_thread_tables().
        Now this function is only responsible for closing
        tables, nothing else.
        This is necessary to be able to easily use
        close_thread_tables() in procedures, that
        involve multiple open/close tables, which all
        need to be protected continuously by metadata
        locks.
        Add asserts ensuring that TABLE object
        is only used when is protected by a metadata lock.
        Simplify the back off condition of Open_table_context,
        we no longer need to look at the autocommit mode.
        Make open_and_lock_tables() and open_normal_and_derived_tables()
        close thread tables and release metadata locks acquired so-far 
        upon failure. This simplifies their usage.
        Implement close_mysql_tables().
     @ sql/sql_base.h
        Add declaration for close_mysql_tables().
     @ sql/sql_do.cc
        Do nothing in DO if inside a substatement
        (the assert moved out of trans_rollback_stmt).
     @ sql/sql_handler.cc
        Add comments.
     @ sql/sql_insert.cc
        Remove dead code. 
        Release metadata locks explicitly at the
        end of the delayed insert thread.
     @ sql/sql_lex.cc
        Add destruction of lex->sphead to lex_end(),
        lex "reset" method called at the end of each statement.
     @ sql/sql_parse.cc
        Move close_thread_tables() and other related
        cleanups to mysql_execute_command()
        from dispatch_command(). This has become
        possible after the fix for Bug#37521.
        Mark federated SERVER statements as DDL.
        
        Next step: make sure that we don't store
        eof packet in the query cache, and move
        the query cache code outside mysql_parse.
        
        Brush up the code of COM_FIELD_LIST.
        Remove unnecessary calls to close_thread_tables().
        
        When killing a query, don't report "OK"
        if it was a suicide.
     @ sql/sql_parse.h
        Remove declaration of a function that is now static.
     @ sql/sql_partition.cc
        Remove anunnecessary call to close_thread_tables().
     @ sql/sql_plugin.cc
        open_and_lock_tables() will clean up
        after itself after a failure.
        Move close_thread_tables() above
        end: label, and replace with close_mysql_tables(),
        which will also release the metadata lock
        on mysql.plugin.
     @ sql/sql_prepare.cc
        Now that we no longer release locks in close_thread_tables()
        statement prepare code has become more straightforward.
        Remove the now redundant check for thd->killed() (used
        only by the backup project) from Execute_server_runnable.
        Reorder code to take into account that now mysql_execute_command()
        performs lex->unit.cleanup() and close_thread_tables().
     @ sql/sql_priv.h
        Add a new option to server options to interact
        between the slave SQL thread and execution
        framework (hack). @todo: use a virtual
        method of class THD instead.
     @ sql/sql_servers.cc
        Due to Bug 25705 replication of 
        DROP/CREATE/ALTER SERVER is broken.
        Make sure at least we do not attempt to 
        replicate these statements using RBR,
        as this violates the assert in close_mysql_tables().
     @ sql/sql_table.cc
        Do not release metadata locks in mysql_rm_table_part2,
        this is done by the caller.
        Do not call close_thread_tables() in mysql_create_table(),
        this is done by the caller. 
        Fix a bug in DROP TABLE under LOCK TABLES when,
        upon error in wait_while_table_is_used() we would mistakenly
        release the metadata lock on a non-dropped table.
        Explicitly release metadata locks when doing an implicit
        commit.
     @ sql/sql_trigger.cc
        Now that we delete lex->sphead in lex_end(),
        zero the trigger's sphead in lex after loading
        the trigger, to avoid double deletion.
     @ sql/sql_udf.cc
        Use close_mysql_tables() instead of close_thread_tables().
     @ sql/sys_vars.cc
        Remove code added in scope of WL#4284 which would
        break when we perform set @@session.autocommit along
        with setting other variables and using tables or functions.
        A test case added to variables.test.
     @ sql/transaction.cc
        Add asserts.
     @ sql/tztime.cc
        Use close_mysql_tables() rather than close_thread_tables().
[22 Jul 2010 16:04] Luis Soares
5.1 patch based on Kostja's commit:
http://lists.mysql.com/commits/114164
[26 Jul 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/114363

3082 Konstantin Osipov	2010-07-26
      A pre-requisite patch for the fix for Bug#52044.
      This patch also fixes Bug#55452 "SET PASSWORD is
      replicated twice in RBR mode".
      
      Cleanup COM_FIELD_LIST.
      Don't call close_thread_tables() in COM_SHUTDOWN -- there
      are no open tables there that can be closed (we leave
      the locked tables mode in THD destructor, and this
      close_thread_tables() won't leave it anyway).
      
      Make open_and_lock_tables() and open_and_lock_tables_derived()
      call close_thread_tables() upon failure.
      Remove the calls to close_thread_tables that are now unnecessary.
      
      Remove the release of metadata locks
      from close_thread_tables().
      
      Simplify the back off condition in Open_table_context.
      
      Move statement commit outside 
      close_thread_tables().
      
      Streamline metadata lock handling in LOCK TABLES 
      implementation.
      
      Add asserts to ensure correct life cycle of 
      statement transaction in a session.
     @ mysql-test/r/variables.result
        Update results: set @@autocommit and statement transaction/
        prelocked mode.
     @ mysql-test/r/view.result
        A harmless change in CHECK TABLE <view> status for a broken view.
        If previously a failure to prelock all functions used in a view 
        would leave the connection in LTM_PRELOCKED mode, now we call
        close_thread_tables() from open_and_lock_tables()
        and leave prelocked mode, thus some check in mysql_admin_table() that
        works only in prelocked/locked tables mode is no longer activated.
     @ mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result
        Fixed Bug#55452 "SET PASSWORD is replicated twice in
        RBR mode": extra binlog events are gone from the
        binary log.
     @ mysql-test/t/variables.test
        Add a test case: set autocommit and statement transaction/prelocked
        mode.
     @ sql/event_data_objects.cc
        Simplify code in Event_job_data::execute().
        Move sp_head memory management to lex_end().
     @ sql/event_db_repository.cc
        Move the release of metadata locks outside
        close_thread_tables().
        Make sure we call close_thread_tables() when
        open_and_lock_tables() fails and remove extra
        code from the events data dictionary.
        Use close_mysql_tables(), a new internal
        function to properly close mysql.* tables
        in the data dictionary.
        Contract Event_db_repository::drop_events_by_field,
        drop_schema_events into one function.
        When dropping all events in a schema,
        make sure we don't mistakenly release all
        locks acquired by DROP DATABASE. These
        include locks in the database name
        and the global shared metadata lock.
     @ sql/event_db_repository.h
        Function open_event_table() does not require an instance 
        of Event_db_repository.
     @ sql/events.cc
        Use close_mysql_tables() instead of close_thread_tables()
        to bootstrap events, since the latter no longer
        releases metadata locks.
     @ sql/ha_ndbcluster.cc
        - mysql_rm_table_part2 no longer releases
        acquired metadata locks. Do it in the caller.
     @ sql/ha_ndbcluster_binlog.cc
        Deploy the new protocol for closing thread
        tables in run_query() and ndb_binlog_index
        code.
     @ sql/handler.cc
        Assert that we never call ha_commit_trans/
        ha_rollback_trans in sub-statement, which
        is now the case.
     @ sql/handler.h
        Add an accessor to check whether THD_TRANS object
        is empty (has no transaction started).
     @ sql/log.cc
        Update a comment.
     @ sql/log_event.cc
        Since now we commit/rollback statement transaction in 
        mysql_execute_command(), we need a mechanism to communicate
        from Query_log_event::do_apply_event() to mysql_execute_command()
        that the statement transaction should be rolled back, not committed.
        Ideally it would be a virtual method of THD. I hesitate
        to make THD a virtual base class in this already large patch.
        Use a thd->variables.option_bits for now.
        
        Remove a call to close_thread_tables() from the slave IO
        thread. It doesn't open any tables, and the protocol
        for closing thread tables is more complicated now.
        
        Make sure we properly close thread tables, however, 
        in Load_data_log_event, which doesn't
        follow the standard server execution procedure
        with mysql_execute_command().
        @todo: this piece should use Server_runnable
        framework instead.
        Remove an unnecessary call to mysql_unlock_tables().
     @ sql/rpl_rli.cc
        Update Relay_log_info::slave_close_thread_tables()
        to follow the new close protocol.
     @ sql/set_var.cc
        Remove an unused header.
     @ sql/slave.cc
        Remove an unnecessary call to
        close_thread_tables().
     @ sql/sp.cc
        Remove unnecessary calls to close_thread_tables()
        from SP DDL implementation. The tables will
        be closed by the caller, in mysql_execute_command().
        When dropping all routines in a database, make sure
        to not mistakenly all metadata locks acquired
        so far, they include the scoped lock on the schema.
     @ sql/sp_head.cc
        Correct the protocol that closes thread tables
        in an SP instruction.
        Clear lex->sphead before cleaning up lex
        with lex_end to make sure that we don't
        delete the sphead twice. It's considered
        to be "cleaner" and more in line with
        future changes than calling delete lex->sphead
        in other places that cleanup the lex.
     @ sql/sp_head.h
        When destroying m_lex_keeper of an instruction,
        don't delete the sphead that all lex objects
        share. 
        @todo: don't store a reference to routine's sp_head
        instance in instruction's lex.
     @ sql/sql_acl.cc
        Don't call close_thread_tables() where the caller will
        do that for us.
        Fix Bug#55452 "SET PASSWORD is replicated twice in RBR 
        mode" by disabling RBR replication in change_password()
        function.
        Use close_mysql_tables() in bootstrap and ACL reload
        code to make sure we release all metadata locks.
     @ sql/sql_base.cc
        This is the main part of the patch:
        - remove manipulation with thd->transaction
        and thd->mdl_context from close_thread_tables().
        Now this function is only responsible for closing
        tables, nothing else.
        This is necessary to be able to easily use
        close_thread_tables() in procedures, that
        involve multiple open/close tables, which all
        need to be protected continuously by metadata
        locks.
        Add asserts ensuring that TABLE object
        is only used when is protected by a metadata lock.
        Simplify the back off condition of Open_table_context,
        we no longer need to look at the autocommit mode.
        Make open_and_lock_tables() and open_normal_and_derived_tables()
        close thread tables and release metadata locks acquired so-far 
        upon failure. This simplifies their usage.
        Implement close_mysql_tables().
     @ sql/sql_base.h
        Add declaration for close_mysql_tables().
     @ sql/sql_do.cc
        Do nothing in DO if inside a substatement
        (the assert moved out of trans_rollback_stmt).
     @ sql/sql_handler.cc
        Add comments.
     @ sql/sql_insert.cc
        Remove dead code. 
        Release metadata locks explicitly at the
        end of the delayed insert thread.
     @ sql/sql_lex.cc
        Add destruction of lex->sphead to lex_end(),
        lex "reset" method called at the end of each statement.
     @ sql/sql_parse.cc
        Move close_thread_tables() and other related
        cleanups to mysql_execute_command()
        from dispatch_command(). This has become
        possible after the fix for Bug#37521.
        Mark federated SERVER statements as DDL.
        
        Next step: make sure that we don't store
        eof packet in the query cache, and move
        the query cache code outside mysql_parse.
        
        Brush up the code of COM_FIELD_LIST.
        Remove unnecessary calls to close_thread_tables().
        
        When killing a query, don't report "OK"
        if it was a suicide.
     @ sql/sql_parse.h
        Remove declaration of a function that is now static.
     @ sql/sql_partition.cc
        Remove an unnecessary call to close_thread_tables().
     @ sql/sql_plugin.cc
        open_and_lock_tables() will clean up
        after itself after a failure.
        Move close_thread_tables() above
        end: label, and replace with close_mysql_tables(),
        which will also release the metadata lock
        on mysql.plugin.
     @ sql/sql_prepare.cc
        Now that we no longer release locks in close_thread_tables()
        statement prepare code has become more straightforward.
        Remove the now redundant check for thd->killed() (used
        only by the backup project) from Execute_server_runnable.
        Reorder code to take into account that now mysql_execute_command()
        performs lex->unit.cleanup() and close_thread_tables().
     @ sql/sql_priv.h
        Add a new option to server options to interact
        between the slave SQL thread and execution
        framework (hack). @todo: use a virtual
        method of class THD instead.
     @ sql/sql_servers.cc
        Due to Bug 25705 replication of 
        DROP/CREATE/ALTER SERVER is broken.
        Make sure at least we do not attempt to 
        replicate these statements using RBR,
        as this violates the assert in close_mysql_tables().
     @ sql/sql_table.cc
        Do not release metadata locks in mysql_rm_table_part2,
        this is done by the caller.
        Do not call close_thread_tables() in mysql_create_table(),
        this is done by the caller. 
        Fix a bug in DROP TABLE under LOCK TABLES when,
        upon error in wait_while_table_is_used() we would mistakenly
        release the metadata lock on a non-dropped table.
        Explicitly release metadata locks when doing an implicit
        commit.
     @ sql/sql_trigger.cc
        Now that we delete lex->sphead in lex_end(),
        zero the trigger's sphead in lex after loading
        the trigger, to avoid double deletion.
     @ sql/sql_udf.cc
        Use close_mysql_tables() instead of close_thread_tables().
     @ sql/sys_vars.cc
        Remove code added in scope of WL#4284 which would
        break when we perform set @@session.autocommit along
        with setting other variables and using tables or functions.
        A test case added to variables.test.
     @ sql/transaction.cc
        Add asserts.
     @ sql/tztime.cc
        Use close_mysql_tables() rather than close_thread_tables().
[26 Jul 2010 18:35] 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/114378

3082 Konstantin Osipov	2010-07-26
      A pre-requisite patch for the fix for Bug#52044.
      This patch also fixes Bug#55452 "SET PASSWORD is
      replicated twice in RBR mode".
      
      Cleanup COM_FIELD_LIST.
      Don't call close_thread_tables() in COM_SHUTDOWN -- there
      are no open tables there that can be closed (we leave
      the locked tables mode in THD destructor, and this
      close_thread_tables() won't leave it anyway).
      
      Make open_and_lock_tables() and open_and_lock_tables_derived()
      call close_thread_tables() upon failure.
      Remove the calls to close_thread_tables that are now unnecessary.
      
      Remove the release of metadata locks
      from close_thread_tables().
      
      Simplify the back off condition in Open_table_context.
      
      Move statement commit outside 
      close_thread_tables().
      
      Streamline metadata lock handling in LOCK TABLES 
      implementation.
      
      Add asserts to ensure correct life cycle of 
      statement transaction in a session.
     @ mysql-test/r/variables.result
        Update results: set @@autocommit and statement transaction/
        prelocked mode.
     @ mysql-test/r/view.result
        A harmless change in CHECK TABLE <view> status for a broken view.
        If previously a failure to prelock all functions used in a view 
        would leave the connection in LTM_PRELOCKED mode, now we call
        close_thread_tables() from open_and_lock_tables()
        and leave prelocked mode, thus some check in mysql_admin_table() that
        works only in prelocked/locked tables mode is no longer activated.
     @ mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result
        Fixed Bug#55452 "SET PASSWORD is replicated twice in
        RBR mode": extra binlog events are gone from the
        binary log.
     @ mysql-test/t/variables.test
        Add a test case: set autocommit and statement transaction/prelocked
        mode.
     @ sql/event_data_objects.cc
        Simplify code in Event_job_data::execute().
        Move sp_head memory management to lex_end().
     @ sql/event_db_repository.cc
        Move the release of metadata locks outside
        close_thread_tables().
        Make sure we call close_thread_tables() when
        open_and_lock_tables() fails and remove extra
        code from the events data dictionary.
        Use close_mysql_tables(), a new internal
        function to properly close mysql.* tables
        in the data dictionary.
        Contract Event_db_repository::drop_events_by_field,
        drop_schema_events into one function.
        When dropping all events in a schema,
        make sure we don't mistakenly release all
        locks acquired by DROP DATABASE. These
        include locks in the database name
        and the global shared metadata lock.
     @ sql/event_db_repository.h
        Function open_event_table() does not require an instance 
        of Event_db_repository.
     @ sql/events.cc
        Use close_mysql_tables() instead of close_thread_tables()
        to bootstrap events, since the latter no longer
        releases metadata locks.
     @ sql/ha_ndbcluster.cc
        - mysql_rm_table_part2 no longer releases
        acquired metadata locks. Do it in the caller.
     @ sql/ha_ndbcluster_binlog.cc
        Deploy the new protocol for closing thread
        tables in run_query() and ndb_binlog_index
        code.
     @ sql/handler.cc
        Assert that we never call ha_commit_trans/
        ha_rollback_trans in sub-statement, which
        is now the case.
     @ sql/handler.h
        Add an accessor to check whether THD_TRANS object
        is empty (has no transaction started).
     @ sql/log.cc
        Update a comment.
     @ sql/log_event.cc
        Since now we commit/rollback statement transaction in 
        mysql_execute_command(), we need a mechanism to communicate
        from Query_log_event::do_apply_event() to mysql_execute_command()
        that the statement transaction should be rolled back, not committed.
        Ideally it would be a virtual method of THD. I hesitate
        to make THD a virtual base class in this already large patch.
        Use a thd->variables.option_bits for now.
        
        Remove a call to close_thread_tables() from the slave IO
        thread. It doesn't open any tables, and the protocol
        for closing thread tables is more complicated now.
        
        Make sure we properly close thread tables, however, 
        in Load_data_log_event, which doesn't
        follow the standard server execution procedure
        with mysql_execute_command().
        @todo: this piece should use Server_runnable
        framework instead.
        Remove an unnecessary call to mysql_unlock_tables().
     @ sql/rpl_rli.cc
        Update Relay_log_info::slave_close_thread_tables()
        to follow the new close protocol.
     @ sql/set_var.cc
        Remove an unused header.
     @ sql/slave.cc
        Remove an unnecessary call to
        close_thread_tables().
     @ sql/sp.cc
        Remove unnecessary calls to close_thread_tables()
        from SP DDL implementation. The tables will
        be closed by the caller, in mysql_execute_command().
        When dropping all routines in a database, make sure
        to not mistakenly all metadata locks acquired
        so far, they include the scoped lock on the schema.
     @ sql/sp_head.cc
        Correct the protocol that closes thread tables
        in an SP instruction.
        Clear lex->sphead before cleaning up lex
        with lex_end to make sure that we don't
        delete the sphead twice. It's considered
        to be "cleaner" and more in line with
        future changes than calling delete lex->sphead
        in other places that cleanup the lex.
     @ sql/sp_head.h
        When destroying m_lex_keeper of an instruction,
        don't delete the sphead that all lex objects
        share. 
        @todo: don't store a reference to routine's sp_head
        instance in instruction's lex.
     @ sql/sql_acl.cc
        Don't call close_thread_tables() where the caller will
        do that for us.
        Fix Bug#55452 "SET PASSWORD is replicated twice in RBR 
        mode" by disabling RBR replication in change_password()
        function.
        Use close_mysql_tables() in bootstrap and ACL reload
        code to make sure we release all metadata locks.
     @ sql/sql_base.cc
        This is the main part of the patch:
        - remove manipulation with thd->transaction
        and thd->mdl_context from close_thread_tables().
        Now this function is only responsible for closing
        tables, nothing else.
        This is necessary to be able to easily use
        close_thread_tables() in procedures, that
        involve multiple open/close tables, which all
        need to be protected continuously by metadata
        locks.
        Add asserts ensuring that TABLE object
        is only used when is protected by a metadata lock.
        Simplify the back off condition of Open_table_context,
        we no longer need to look at the autocommit mode.
        Make open_and_lock_tables() and open_normal_and_derived_tables()
        close thread tables and release metadata locks acquired so-far 
        upon failure. This simplifies their usage.
        Implement close_mysql_tables().
     @ sql/sql_base.h
        Add declaration for close_mysql_tables().
     @ sql/sql_do.cc
        Do nothing in DO if inside a substatement
        (the assert moved out of trans_rollback_stmt).
     @ sql/sql_handler.cc
        Add comments.
     @ sql/sql_insert.cc
        Remove dead code. 
        Release metadata locks explicitly at the
        end of the delayed insert thread.
     @ sql/sql_lex.cc
        Add destruction of lex->sphead to lex_end(),
        lex "reset" method called at the end of each statement.
     @ sql/sql_parse.cc
        Move close_thread_tables() and other related
        cleanups to mysql_execute_command()
        from dispatch_command(). This has become
        possible after the fix for Bug#37521.
        Mark federated SERVER statements as DDL.
        
        Next step: make sure that we don't store
        eof packet in the query cache, and move
        the query cache code outside mysql_parse.
        
        Brush up the code of COM_FIELD_LIST.
        Remove unnecessary calls to close_thread_tables().
        
        When killing a query, don't report "OK"
        if it was a suicide.
     @ sql/sql_parse.h
        Remove declaration of a function that is now static.
     @ sql/sql_partition.cc
        Remove an unnecessary call to close_thread_tables().
     @ sql/sql_plugin.cc
        open_and_lock_tables() will clean up
        after itself after a failure.
        Move close_thread_tables() above
        end: label, and replace with close_mysql_tables(),
        which will also release the metadata lock
        on mysql.plugin.
     @ sql/sql_prepare.cc
        Now that we no longer release locks in close_thread_tables()
        statement prepare code has become more straightforward.
        Remove the now redundant check for thd->killed() (used
        only by the backup project) from Execute_server_runnable.
        Reorder code to take into account that now mysql_execute_command()
        performs lex->unit.cleanup() and close_thread_tables().
     @ sql/sql_priv.h
        Add a new option to server options to interact
        between the slave SQL thread and execution
        framework (hack). @todo: use a virtual
        method of class THD instead.
     @ sql/sql_servers.cc
        Due to Bug 25705 replication of 
        DROP/CREATE/ALTER SERVER is broken.
        Make sure at least we do not attempt to 
        replicate these statements using RBR,
        as this violates the assert in close_mysql_tables().
     @ sql/sql_table.cc
        Do not release metadata locks in mysql_rm_table_part2,
        this is done by the caller.
        Do not call close_thread_tables() in mysql_create_table(),
        this is done by the caller. 
        Fix a bug in DROP TABLE under LOCK TABLES when,
        upon error in wait_while_table_is_used() we would mistakenly
        release the metadata lock on a non-dropped table.
        Explicitly release metadata locks when doing an implicit
        commit.
     @ sql/sql_trigger.cc
        Now that we delete lex->sphead in lex_end(),
        zero the trigger's sphead in lex after loading
        the trigger, to avoid double deletion.
     @ sql/sql_udf.cc
        Use close_mysql_tables() instead of close_thread_tables().
     @ sql/sys_vars.cc
        Remove code added in scope of WL#4284 which would
        break when we perform set @@session.autocommit along
        with setting other variables and using tables or functions.
        A test case added to variables.test.
     @ sql/transaction.cc
        Add asserts.
     @ sql/tztime.cc
        Use close_mysql_tables() rather than close_thread_tables().
[27 Jul 2010 10:27] 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/114426

3086 Konstantin Osipov	2010-07-27
      A pre-requisite patch for the fix for Bug#52044.
      This patch also fixes Bug#55452 "SET PASSWORD is
      replicated twice in RBR mode".
      
      The goal of this patch is to remove the release of 
      metadata locks from close_thread_tables().
      This is necessary to not mistakenly release
      the locks in the course of a multi-step
      operation that involves multiple close_thread_tables()
      or close_tables_for_reopen().
      
      On the same token, move statement commit outside 
      close_thread_tables().
      
      Other cleanups:
      Cleanup COM_FIELD_LIST.
      Don't call close_thread_tables() in COM_SHUTDOWN -- there
      are no open tables there that can be closed (we leave
      the locked tables mode in THD destructor, and this
      close_thread_tables() won't leave it anyway).
      
      Make open_and_lock_tables() and open_and_lock_tables_derived()
      call close_thread_tables() upon failure.
      Remove the calls to close_thread_tables() that are now
      unnecessary.
      
      Simplify the back off condition in Open_table_context.
      
      Streamline metadata lock handling in LOCK TABLES 
      implementation.
      
      Add asserts to ensure correct life cycle of 
      statement transaction in a session.
      
      Remove a piece of dead code that has also become redundant
      after the fix for Bug 37521.
     @ mysql-test/r/variables.result
        Update results: set @@autocommit and statement transaction/
        prelocked mode.
     @ mysql-test/r/view.result
        A harmless change in CHECK TABLE <view> status for a broken view.
        If previously a failure to prelock all functions used in a view 
        would leave the connection in LTM_PRELOCKED mode, now we call
        close_thread_tables() from open_and_lock_tables()
        and leave prelocked mode, thus some check in mysql_admin_table() that
        works only in prelocked/locked tables mode is no longer activated.
     @ mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result
        Fixed Bug#55452 "SET PASSWORD is replicated twice in
        RBR mode": extra binlog events are gone from the
        binary log.
     @ mysql-test/t/variables.test
        Add a test case: set autocommit and statement transaction/prelocked
        mode.
     @ sql/event_data_objects.cc
        Simplify code in Event_job_data::execute().
        Move sp_head memory management to lex_end().
     @ sql/event_db_repository.cc
        Move the release of metadata locks outside
        close_thread_tables().
        Make sure we call close_thread_tables() when
        open_and_lock_tables() fails and remove extra
        code from the events data dictionary.
        Use close_mysql_tables(), a new internal
        function to properly close mysql.* tables
        in the data dictionary.
        Contract Event_db_repository::drop_events_by_field,
        drop_schema_events into one function.
        When dropping all events in a schema,
        make sure we don't mistakenly release all
        locks acquired by DROP DATABASE. These
        include locks on the database name
        and the global intention exclusive
        metadata lock.
     @ sql/event_db_repository.h
        Function open_event_table() does not require an instance 
        of Event_db_repository.
     @ sql/events.cc
        Use close_mysql_tables() instead of close_thread_tables()
        to bootstrap events, since the latter no longer
        releases metadata locks.
     @ sql/ha_ndbcluster.cc
        - mysql_rm_table_part2 no longer releases
        acquired metadata locks. Do it in the caller.
     @ sql/ha_ndbcluster_binlog.cc
        Deploy the new protocol for closing thread
        tables in run_query() and ndb_binlog_index
        code.
     @ sql/handler.cc
        Assert that we never call ha_commit_trans/
        ha_rollback_trans in sub-statement, which
        is now the case.
     @ sql/handler.h
        Add an accessor to check whether THD_TRANS object
        is empty (has no transaction started).
     @ sql/log.cc
        Update a comment.
     @ sql/log_event.cc
        Since now we commit/rollback statement transaction in 
        mysql_execute_command(), we need a mechanism to communicate
        from Query_log_event::do_apply_event() to mysql_execute_command()
        that the statement transaction should be rolled back, not committed.
        Ideally it would be a virtual method of THD. I hesitate
        to make THD a virtual base class in this already large patch.
        Use a thd->variables.option_bits for now.
        
        Remove a call to close_thread_tables() from the slave IO
        thread. It doesn't open any tables, and the protocol
        for closing thread tables is more complicated now.
        
        Make sure we properly close thread tables, however, 
        in Load_data_log_event, which doesn't
        follow the standard server execution procedure
        with mysql_execute_command().
        @todo: this piece should use Server_runnable
        framework instead.
        Remove an unnecessary call to mysql_unlock_tables().
     @ sql/rpl_rli.cc
        Update Relay_log_info::slave_close_thread_tables()
        to follow the new close protocol.
     @ sql/set_var.cc
        Remove an unused header.
     @ sql/slave.cc
        Remove an unnecessary call to
        close_thread_tables().
     @ sql/sp.cc
        Remove unnecessary calls to close_thread_tables()
        from SP DDL implementation. The tables will
        be closed by the caller, in mysql_execute_command().
        When dropping all routines in a database, make sure
        to not mistakenly drop all metadata locks acquired
        so far, they include the scoped lock on the schema.
     @ sql/sp_head.cc
        Correct the protocol that closes thread tables
        in an SP instruction.
        Clear lex->sphead before cleaning up lex
        with lex_end to make sure that we don't
        delete the sphead twice. It's considered
        to be "cleaner" and more in line with
        future changes than calling delete lex->sphead
        in other places that cleanup the lex.
     @ sql/sp_head.h
        When destroying m_lex_keeper of an instruction,
        don't delete the sphead that all lex objects
        share. 
        @todo: don't store a reference to routine's sp_head
        instance in instruction's lex.
     @ sql/sql_acl.cc
        Don't call close_thread_tables() where the caller will
        do that for us.
        Fix Bug#55452 "SET PASSWORD is replicated twice in RBR 
        mode" by disabling RBR replication in change_password()
        function.
        Use close_mysql_tables() in bootstrap and ACL reload
        code to make sure we release all metadata locks.
     @ sql/sql_base.cc
        This is the main part of the patch:
        - remove manipulation with thd->transaction
        and thd->mdl_context from close_thread_tables().
        Now this function is only responsible for closing
        tables, nothing else.
        This is necessary to be able to easily use
        close_thread_tables() in procedures, that
        involve multiple open/close tables, which all
        need to be protected continuously by metadata
        locks.
        Add asserts ensuring that TABLE object
        is only used when is protected by a metadata lock.
        Simplify the back off condition of Open_table_context,
        we no longer need to look at the autocommit mode.
        Make open_and_lock_tables() and open_normal_and_derived_tables()
        close thread tables and release metadata locks acquired so-far 
        upon failure. This simplifies their usage.
        Implement close_mysql_tables().
     @ sql/sql_base.h
        Add declaration for close_mysql_tables().
     @ sql/sql_class.cc
        Remove a piece of dead code that has also become redundant
        after the fix for Bug 37521.
        The code became dead when my_eof() was made a non-protocol method,
        but a method that merely modifies the diagnostics area.
        The code became redundant with the fix for Bug#37521, when 
        we started to cal close_thread_tables() before
        Protocol::end_statement().
     @ sql/sql_do.cc
        Do nothing in DO if inside a substatement
        (the assert moved out of trans_rollback_stmt).
     @ sql/sql_handler.cc
        Add comments.
     @ sql/sql_insert.cc
        Remove dead code. 
        Release metadata locks explicitly at the
        end of the delayed insert thread.
     @ sql/sql_lex.cc
        Add destruction of lex->sphead to lex_end(),
        lex "reset" method called at the end of each statement.
     @ sql/sql_parse.cc
        Move close_thread_tables() and other related
        cleanups to mysql_execute_command()
        from dispatch_command(). This has become
        possible after the fix for Bug#37521.
        Mark federated SERVER statements as DDL.
        
        Next step: make sure that we don't store
        eof packet in the query cache, and move
        the query cache code outside mysql_parse.
        
        Brush up the code of COM_FIELD_LIST.
        Remove unnecessary calls to close_thread_tables().
        
        When killing a query, don't report "OK"
        if it was a suicide.
     @ sql/sql_parse.h
        Remove declaration of a function that is now static.
     @ sql/sql_partition.cc
        Remove an unnecessary call to close_thread_tables().
     @ sql/sql_plugin.cc
        open_and_lock_tables() will clean up
        after itself after a failure.
        Move close_thread_tables() above
        end: label, and replace with close_mysql_tables(),
        which will also release the metadata lock
        on mysql.plugin.
     @ sql/sql_prepare.cc
        Now that we no longer release locks in close_thread_tables()
        statement prepare code has become more straightforward.
        Remove the now redundant check for thd->killed() (used
        only by the backup project) from Execute_server_runnable.
        Reorder code to take into account that now mysql_execute_command()
        performs lex->unit.cleanup() and close_thread_tables().
     @ sql/sql_priv.h
        Add a new option to server options to interact
        between the slave SQL thread and execution
        framework (hack). @todo: use a virtual
        method of class THD instead.
     @ sql/sql_servers.cc
        Due to Bug 25705 replication of 
        DROP/CREATE/ALTER SERVER is broken.
        Make sure at least we do not attempt to 
        replicate these statements using RBR,
        as this violates the assert in close_mysql_tables().
     @ sql/sql_table.cc
        Do not release metadata locks in mysql_rm_table_part2,
        this is done by the caller.
        Do not call close_thread_tables() in mysql_create_table(),
        this is done by the caller. 
        Fix a bug in DROP TABLE under LOCK TABLES when,
        upon error in wait_while_table_is_used() we would mistakenly
        release the metadata lock on a non-dropped table.
        Explicitly release metadata locks when doing an implicit
        commit.
     @ sql/sql_trigger.cc
        Now that we delete lex->sphead in lex_end(),
        zero the trigger's sphead in lex after loading
        the trigger, to avoid double deletion.
     @ sql/sql_udf.cc
        Use close_mysql_tables() instead of close_thread_tables().
     @ sql/sys_vars.cc
        Remove code added in scope of WL#4284 which would
        break when we perform set @@session.autocommit along
        with setting other variables and using tables or functions.
        A test case added to variables.test.
     @ sql/transaction.cc
        Add asserts.
     @ sql/tztime.cc
        Use close_mysql_tables() rather than close_thread_tables().
[27 Jul 2010 11:04] Konstantin Osipov
5.5 version of the fix is queued into 5.5.6 (trunk-runtime).
[4 Aug 2010 7:53] Bugs System
Pushed into mysql-trunk 5.5.6-m3 (revid:alik@sun.com-20100731131027-1n61gseejyxsqk5d) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 8:04] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804080001-bny5271e65xo34ig) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 8:20] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804081533-c1d3rbipo9e8rt1s) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 9:01] Bugs System
Pushed into mysql-next-mr (revid:alik@ibmvm-20100804081630-ntapn8bf9pko9vj3) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (pib:20)
[4 Aug 2010 16:52] Jon Stephens
Documented bugfix in the 5.5.6 changelog as follows:

        When using the row-based logging format, a SET PASSWORD statement 
        was written to the binary log twice.

Set NM status, waiting for 5.1 merge.
[3 Sep 2010 17:31] Jon Stephens
Need Merge status set in error (mine). Closed.
[13 Oct 2010 7:38] Jon Stephens
Already documented in the 5.5.6 changelog, returning to Closed state.
[15 Oct 2010 9:13] Alfranio Correia
See also BUG#57357 and BUG#57098.
[29 Oct 2010 16:29] Jon Stephens
Also document4ed in the 5.1.53 and 5.6.1 changelogs. Closed.
[9 Nov 2010 19:43] Bugs System
Pushed into mysql-5.5 5.5.7-rc (revid:sunanda.menon@sun.com-20101109182959-otkxq8vo2dcd13la) (version source revid:sunanda.menon@sun.com-20101109182959-otkxq8vo2dcd13la) (merge vers: 5.5.7-rc) (pib:21)
[13 Nov 2010 16:24] Bugs System
Pushed into mysql-trunk 5.6.99-m5 (revid:alexander.nozdrin@oracle.com-20101113155825-czmva9kg4n31anmu) (version source revid:alexander.nozdrin@oracle.com-20101113152450-2zzcm50e7i4j35v7) (merge vers: 5.6.1-m4) (pib:21)
[13 Nov 2010 16:30] Bugs System
Pushed into mysql-next-mr (revid:alexander.nozdrin@oracle.com-20101113160336-atmtmfb3mzm4pz4i) (version source revid:vasil.dimov@oracle.com-20100629074804-359l9m9gniauxr94) (pib:21)
[15 Nov 2010 13:25] Jon Stephens
No additional changelog entries required.

Closed.
[18 Nov 2010 15:56] Bugs System
Pushed into mysql-5.1 5.1.54 (revid:build@mysql.com-20101118153531-693taxtxyxpt037i) (version source revid:build@mysql.com-20101118153531-693taxtxyxpt037i) (merge vers: 5.1.54) (pib:21)