1. 23 Oct, 2010 1 commit
    • unknown's avatar
      Bug#27606 GRANT statement should be replicated with DEFINER information · 650f0081
      unknown authored
      "Grantor" columns' data is lost when replicating mysql.tables_priv.
      Slave SQL thread used its default user ''@'' as the grantor of GRANT|REVOKE
      statements executing on it.
      
      In this patch, current user is put in query log event for all GRANT and REVOKE
      statement, SQL thread uses the user in query log event as grantor.
      
      
      mysql-test/suite/rpl/r/rpl_do_grant.result:
        Add test for this bug.
      mysql-test/suite/rpl/t/rpl_do_grant.test:
        Add test for this bug.
      sql/log_event.cc:
        Refactoring THD::current_user_used and related functions.
        current_user_used is used to judge if current user should be
        binlogged in query log event. So it is better to call it m_binlog_invoker.
        The related functions are renamed too.
      sql/sql_class.cc:
        Refactoring THD::current_user_used and related functions.
        current_user_used is used to judge if current user should be
        binlogged in query log event. So it is better to call it m_binlog_invoker.
        The related functions are renamed too.
      sql/sql_class.h:
        Refactoring THD::current_user_used and related functions.
        current_user_used is used to judge if current user should be
        binlogged in query log event. So it is better to call it m_binlog_invoker.
        The related functions are renamed too.
      sql/sql_parse.cc:
        Call binlog_invoker() for GRANT and REVOKE statements.
      650f0081
  2. 18 Aug, 2010 1 commit
    • unknown's avatar
      WL#5370 Keep forward-compatibility when changing · 26391375
      unknown authored
              'CREATE TABLE IF NOT EXISTS ... SELECT' behaviour
      BUG#55474, BUG#55499, BUG#55598, BUG#55616 and BUG#55777 are fixed
      in this patch too.
      
      This is the 5.1 part.
      It implements:
      - if the table exists, binlog two events: CREATE TABLE IF NOT EXISTS
        and INSERT ... SELECT
      
      - Insert nothing and binlog nothing on master if the existing object
        is a view. It only generates a warning that table already exists.
      
      
      mysql-test/r/trigger.result:
        Ather this patch, 'CREATE TABLE IF NOT EXISTS ... SELECT' will not
        insert anything if the creating table already exists and is a view.
      sql/sql_class.h:
        Declare virtual function write_to_binlog() for select_insert.
        It's used to binlog 'create select'
      sql/sql_insert.cc:
        Implement write_to_binlog();
        Use write_to_binlog() instead of binlog_query() to binlog the statement.
        if the table exists, binlog two events: CREATE TABLE IF NOT EXISTS
        and INSERT ... SELECT
      sql/sql_lex.h:
        Declare create_select_start_with_brace and create_select_pos.
        They are helpful for binlogging 'create select'
      sql/sql_parse.cc:
        Do nothing on master if the existing object is a view.
      sql/sql_yacc.yy:
        Record the relative postion of 'SELECT' in the 'CREATE ...SELECT' statement.
        Record whether there is a '(' before the 'SELECT' clause.
      26391375
  3. 17 Aug, 2010 1 commit
  4. 10 Aug, 2010 1 commit
    • Alfranio Correia's avatar
      BUG#50312 Warnings for unsafe sub-statement not returned to client · 98626f1e
      Alfranio Correia authored
                              
      After BUG#36649, warnings for sub-statements are cleared when a 
      new sub-statement is started. This is problematic since it suppresses
      warnings for unsafe statements in some cases. It is important that we
      always give a warning to the client, because the user needs to know
      when there is a risk that the slave goes out of sync.
                              
      We fixed the problem by generating warning messages for unsafe statements
      while returning from a stored procedure, function, trigger or while
      executing a top level statement.
                              
      We also started checking unsafeness when both performance and log tables are
      used. This is necessary after the performance schema which does a distinction
      between performance and log tables.
      
      mysql-test/extra/rpl_tests/create_recursive_construct.inc:
        Changed the order of the calls in the procedure because the code
        that checks if a warning message is printed out expects that the
        first statement gives an warning what is not the case for INSERT
        INTO ta$CRC_ARG_level VALUES (47);
      mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result:
        Updated the result file.
      mysql-test/suite/binlog/r/binlog_unsafe.result:
        There are several changes here:
                
        (1) - Changed the CREATE PROCEDURE $CRC.
                                        
        (2) - The procedure $CRC was failing and the content of the binlog
              was being printed out, after fix (1) the failure disappeared.
                                        
        (3) - The warning message for unsafeness due to auto-increment collumns was
              changed.
                                        
        (4) - The warning message for unsafeness due to VERSION(), RAND() was changed.
      mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test:
        Tested filters.
      mysql-test/suite/binlog/t/binlog_unsafe.test:
        Reenabled the test case binlog_unsafe.
      mysql-test/suite/binlog/t/disabled.def:
        Reenabled the test case binlog_unsafe.
      mysql-test/suite/rpl/r/rpl_begin_commit_rollback.result:
        Updated the result file.
      mysql-test/suite/rpl/r/rpl_non_direct_stm_mixing_engines.result:
        Updated the result file.
      mysql-test/suite/rpl/r/rpl_stm_auto_increment_bug33029.result:
        Updated the result file.
      sql/sql_class.cc:
        Moved the stmt_accessed_table_flag variable and related information to the
        LEX as we need the variable reset after each statement even inside a stored
        procedure, what did not happen if the information was in the THD.
                
        Changed the routine in the THD::binlog_query that prints the warning
        messages to avoid trying to print them when inside a stored procedure,
        function or trigger.
                                
        Checked for unsafeness when both performance and log tables where used.
        After the introduction of the performance schema, we need to check both.
      98626f1e
  5. 09 Aug, 2010 1 commit
  6. 30 Jul, 2010 1 commit
    • Alexander Nozdrin's avatar
      Auto-merge from mysql-trunk-bugfixing. · f203f617
      Alexander Nozdrin authored
      ******
      This patch fixes the following bugs:
        - Bug#5889: Exit handler for a warning doesn't hide the warning in
          trigger
        - Bug#9857: Stored procedures: handler for sqlwarning ignored
        - Bug#23032: Handlers declared in a SP do not handle warnings generated
          in sub-SP
        - Bug#36185: Incorrect precedence for warning and exception handlers
      
      The problem was in the way warnings/errors during stored routine execution
      were handled. Prior to this patch the logic was as follows:
      
        - when a warning/an error happens: if we're executing a stored routine,
          and there is a handler for that warning/error, remember the handler,
          ignore the warning/error and continue execution.
      
        - after a stored routine instruction is executed: check for a remembered
          handler and activate one (if any).
      
      This logic caused several problems:
      
        - if one instruction generates several warnings (errors) it's impossible
          to choose the right handler -- a handler for the first generated
          condition was chosen and remembered for activation.
      
        - mess with handling conditions in scopes different from the current one.
      
        - not putting generated warnings/errors into Warning Info (Diagnostic
          Area) is against The Standard.
      
      The patch changes the logic as follows:
      
        - Diagnostic Area is cleared on the beginning of each statement that
          either is able to generate warnings, or is able to work with tables.
      
        - at the end of a stored routine instruction, Diagnostic Area is left
          intact.
      
        - Diagnostic Area is checked after each stored routine instruction. If
          an instruction generates several condition, it's now possible to take a
          look at all of them and determine an appropriate handler.
      
      mysql-test/r/signal.result:
        Update result file:
          1. handled conditions are not cleared any more;
          2. reflect changes in signal.test
      mysql-test/r/signal_demo3.result:
        Update result file: handled conditions are not cleared any more.
        Due to playing with max_error_count, resulting warning lists
        have changed.
      mysql-test/r/sp-big.result:
        Update result file: handled conditions are not cleared any more.
      mysql-test/r/sp-bugs.result:
        Update result file: handled conditions are not cleared any more.
      mysql-test/r/sp-code.result:
        Update result file:
          1. handled conditions are not cleared any more.
          2. add result for a new test case in sp-code.test.
      mysql-test/r/sp-error.result:
        Update result file:
          1. handled conditions are not cleared any more.
          2. add result for a new test case in sp-error.test.
      mysql-test/r/sp.result:
        Update result file: handled conditions are not cleared any more.
      mysql-test/r/sp_trans.result:
        Update result file: handled conditions are not cleared any more.
      mysql-test/r/strict.result:
        Update result file: handled conditions are not cleared any more.
      mysql-test/r/view.result:
        Update result file: handled conditions are not cleared any more.
      mysql-test/suite/funcs_1/r/innodb_storedproc_02.result:
        Update result file: handled conditions are not cleared any more.
      mysql-test/suite/funcs_1/r/memory_storedproc_02.result:
        Update result file: handled conditions are not cleared any more.
      mysql-test/suite/funcs_1/r/myisam_storedproc_02.result:
        Update result file: handled conditions are not cleared any more.
      mysql-test/suite/funcs_1/r/storedproc.result:
        Update result file: handled conditions are not cleared any more.
      mysql-test/suite/rpl/r/rpl_row_sp005.result:
        Update result file: handled conditions are not cleared any more.
      mysql-test/suite/rpl/r/rpl_row_sp006_InnoDB.result:
        Update result file: handled conditions are not cleared any more.
      mysql-test/suite/rpl/r/rpl_row_trig003.result:
        Update result file: handled conditions are not cleared any more.
      mysql-test/t/signal.test:
        Make a test case more readable in the result file.
      mysql-test/t/sp-code.test:
        Add a test case for Bug#23032 checking that
        No Data takes precedence on Warning.
      mysql-test/t/sp-error.test:
        Adding test cases for:
          - Bug#23032
          - Bug#36185
          - Bug#5889
          - Bug#9857
      mysql-test/t/sp.test:
        Fixing test case to reflect behavioral changes made by the patch.
      sql/sp_head.cc:
        Reset the per-statement warning count before executing
        a stored procedure instruction.
        
        Move to a separate function code which checks the
        completion status of the executed statement and searches
        for a handler.
        
        Remove redundant code now that search for a handler is
        done after execution, errors are always pushed.
      sql/sp_pcontext.h:
        Remove unused code.
      sql/sp_rcontext.cc:
        - Polish sp_rcontext::find_handler(): use sp_rcontext::m_hfound instead
          of an extra local variable;
        
        - Remove sp_rcontext::handle_condition();
        
        - Introduce sp_rcontext::activate_handler(), which prepares
          previously found handler for execution.
        
        - Move sp_rcontext::enter_handler() code into activate_handler(),
          because enter_handler() is used only from there;
        
        - Cleanups;
        
        - Introduce DBUG_EXECUTE_IF() for a test case in sp-code.test
      sql/sp_rcontext.h:
        - Remove unused code
        - Cleanups
      sql/sql_class.cc:
        Merge THD::raise_condition_no_handler() into THD::raise_condition().
        After the patch raise_condition_no_handler() was called
        in raise_condition() only.
      sql/sql_class.h:
        Remove raise_condition_no_handler().
      sql/sql_error.cc:
        Remove Warning_info::reserve_space() -- handled conditions are not
        cleared any more, so there is no need for RESIGNAL to re-push them.
      sql/sql_error.h:
        Remove Warning_info::reserve_space().
      sql/sql_signal.cc:
        Handled conditions are not cleared any more,
        so there is no need for RESIGNAL to re-push them.
      f203f617
  7. 28 Jul, 2010 1 commit
  8. 27 Jul, 2010 2 commits
    • Dmitry Lenev's avatar
      Fix for bug #52044 "FLUSH TABLES WITH READ LOCK and FLUSH · 5bb44ae0
      Dmitry Lenev authored
      TABLES <list> WITH READ LOCK are incompatible".
      
      The problem was that FLUSH TABLES <list> WITH READ LOCK
      which was issued when other connection has acquired global
      read lock using FLUSH TABLES WITH READ LOCK was blocked
      and has to wait until global read lock is released.
      
      This issue stemmed from the fact that FLUSH TABLES <list>
      WITH READ LOCK implementation has acquired X metadata locks
      on tables to be flushed. Since these locks required acquiring
      of global IX lock this statement was incompatible with global
      read lock.
      
      This patch addresses problem by using SNW metadata type of
      lock for tables to be flushed by FLUSH TABLES <list> WITH
      READ LOCK. It is OK to acquire them without global IX lock
      as long as we won't try to upgrade those locks. Since SNW
      locks allow concurrent statements using same table FLUSH
      TABLE <list> WITH READ LOCK now has to wait until old
      versions of tables to be flushed go away after acquiring
      metadata locks. Since such waiting can lead to deadlock
      MDL deadlock detector was extended to take into account
      waits for flush and resolve such deadlocks.
      
      As a bonus code in open_tables() which was responsible for
      waiting old versions of tables to go away was refactored.
      Now when we encounter old version of table in open_table()
      we don't back-off and wait for all old version to go away,
      but instead wait for this particular table to be flushed.
      Such approach supported by deadlock detection should reduce
      number of scenarios in which FLUSH TABLES aborts concurrent
      multi-statement transactions.
      
      Note that active FLUSH TABLES <list> WITH READ LOCK still
      blocks concurrent FLUSH TABLES WITH READ LOCK statement
      as the former keeps tables open and thus prevents the
      latter statement from doing flush.
      
      mysql-test/include/handler.inc:
        Adjusted test case after changing status which is set
        when FLUSH TABLES waits for tables to be flushed from
        "Flushing tables" to "Waiting for table".
      mysql-test/r/flush.result:
        Added test which checks that "flush tables <list> with
        read lock" is compatible with active "flush tables with
        read lock" but not vice-versa. This test also covers
        bug #52044 "FLUSH TABLES WITH READ LOCK and FLUSH TABLES
        <list> WITH READ LOCK are incompatible".
      mysql-test/r/mdl_sync.result:
        Added scenarios in which wait for table to be flushed
        causes deadlocks to the coverage of MDL deadlock detector.
      mysql-test/suite/perfschema/r/dml_setup_instruments.result:
        Adjusted test results after removal of COND_refresh
        condition variable.
      mysql-test/suite/perfschema/r/server_init.result:
        Adjusted test and its results after removal of COND_refresh
        condition variable.
      mysql-test/suite/perfschema/t/server_init.test:
        Adjusted test and its results after removal of COND_refresh
        condition variable.
      mysql-test/t/flush.test:
        Added test which checks that "flush tables <list> with
        read lock" is compatible with active "flush tables with
        read lock" but not vice-versa. This test also covers
        bug #52044 "FLUSH TABLES WITH READ LOCK and FLUSH TABLES
        <list> WITH READ LOCK are incompatible".
      mysql-test/t/kill.test:
        Adjusted test case after changing status which is set
        when FLUSH TABLES waits for tables to be flushed from
        "Flushing tables" to "Waiting for table".
      mysql-test/t/lock_multi.test:
        Adjusted test case after changing status which is set
        when FLUSH TABLES waits for tables to be flushed from
        "Flushing tables" to "Waiting for table".
      mysql-test/t/mdl_sync.test:
        Added scenarios in which wait for table to be flushed
        causes deadlocks to the coverage of MDL deadlock detector.
      sql/ha_ndbcluster.cc:
        Adjusted code after adding one more parameter for
        close_cached_tables() call - timeout for waiting for
        table to be flushed.
      sql/ha_ndbcluster_binlog.cc:
        Adjusted code after adding one more parameter for
        close_cached_tables() call - timeout for waiting for
        table to be flushed.
      sql/lock.cc:
        Removed COND_refresh condition variable. See comment
        for sql_base.cc for details.
      sql/mdl.cc:
        Now MDL deadlock detector takes into account information
        about waits for table flushes when searching for deadlock.
        To implement this change:
        - Declaration of enum_deadlock_weight and
          Deadlock_detection_visitor were moved to mdl.h header
          to make them available to the code in table.cc which
          implements deadlock detector traversal through edges
          of waiters graph representing waiting for flush.
        - Since now MDL_context may wait not only for metadata
          lock but also for table to be flushed an abstract
          Wait_for_edge class was introduced. Its descendants
          MDL_ticket and Flush_ticket incapsulate specifics
          of inspecting waiters graph when following through
          edge representing wait of particular type.
        
        We no longer require global IX metadata lock when acquiring
        SNW or SNRW locks. Such locks are needed only when metadata
        locks of these types are upgraded to X locks. This allows
        to use SNW locks in FLUSH TABLES <list> WITH READ LOCK
        implementation and keep the latter compatible with global
        read lock.
      sql/mdl.h:
        Now MDL deadlock detector takes into account information
        about waits for table flushes when searching for deadlock.
        To implement this change:
        - Declaration of enum_deadlock_weight and
          Deadlock_detection_visitor were moved to mdl.h header
          to make them available to the code in table.cc which
          implements deadlock detector traversal through edges
          of waiters graph representing waiting for flush.
        - Since now MDL_context may wait not only for metadata
          lock but also for table to be flushed an abstract
          Wait_for_edge class was introduced. Its descendants
          MDL_ticket and Flush_ticket incapsulate specifics
          of inspecting waiters graph when following through
          edge representing wait of particular type.
        - Deadlock_detection_visitor now has m_table_shares_visited
          member which allows to support recursive locking for
          LOCK_open. This is required when deadlock detector
          inspects waiters graph which contains several edges
          representing waits for flushes or needs to come through
          the such edge more than once.
      sql/mysqld.cc:
        Removed COND_refresh condition variable. See comment
        for sql_base.cc for details.
      sql/mysqld.h:
        Removed COND_refresh condition variable. See comment
        for sql_base.cc for details.
      sql/sql_base.cc:
        Changed approach to how threads are waiting for table
        to be flushed. Now thread that wants to wait for old
        table to go away subscribes for notification by adding
        Flush_ticket to table's share and waits using
        MDL_context::m_wait object. Once table gets flushed
        (i.e. all tables are closed and table share is ready
        to be destroyed) all such waiters are notified
        individually.
        Thanks to this change MDL deadlock detector can take
        such waits into account.
        
        To implement this/as result of this change:
        - tdc_wait_for_old_versions() was replaced with
          tdc_wait_for_old_version() which waits for individual
          old share to go away and which is called by open_table()
          after finding out that share is outdated. We don't
          need to perform back-off before such waiting thanks
          to the fact that deadlock detector now sees such waits.
        - As result Open_table_ctx::m_mdl_requests became
          unnecessary and was removed. We no longer allocate
          copies of MDL_request objects on MEM_ROOT when
          MYSQL_OPEN_FORCE_SHARED/SHARED_HIGH_PRIO flags are
          in effect.
        - close_cached_tables() and tdc_wait_for_old_version()
          share code which implements waiting for share to be
          flushed - the both use TABLE_SHARE::wait_until_flush()
          method. Thanks to this close_cached_tables() supports
          timeouts and has extra parameter for this.
        - Open_table_context::OT_MDL_CONFLICT enum element was
          renamed to OT_CONFLICT as it is now also used in cases
          when back-off is required to resolve deadlock caused
          by waiting for flush and not metadata lock.
        - In cases when we discover that current connection tries
          to open tables from different generation we now simply
          back-off and restart process of opening tables. To
          support this Open_table_context::OT_REOPEN_TABLES enum
          element was added.
        - COND_refresh condition variable became unnecessary and
          was removed.
        - mysql_notify_thread_having_shared_lock() no longer wakes
          up connections waiting for flush as all such connections
          can be waken up by deadlock detector if necessary.
      sql/sql_base.h:
        - close_cached_tables() now has one more parameter -
          timeout for waiting for table to be flushed.
        - Open_table_context::OT_MDL_CONFLICT enum element was
          renamed to OT_CONFLICT as it is now also used in cases
          when back-off is required to resolve deadlock caused
          by waiting for flush and not metadata lock.
          Added new OT_REOPEN_TABLES enum element to be used in
          cases when we need to restart open tables process even
          in the middle of transaction.
        - Open_table_ctx::m_mdl_requests became unnecessary and
          was removed.
      sql/sql_class.h:
        Added assert ensuring that we won't use LOCK_open mutex
        with THD::enter_cond(). Otherwise deadlocks can arise in
        MDL deadlock detector.
      sql/sql_parse.cc:
        Changed FLUSH TABLES <list> WITH READ LOCK to take SNW
        metadata locks instead of X locks on tables to be flushed.
        Since we no longer require global IX lock to be taken
        when SNW locks are taken this makes this statement
        compatible with FLUSH TABLES WITH READ LOCK statement.
        Since SNW locks allow other connections to have table
        opened FLUSH TABLES <list> WITH READ LOCK now has to
        wait during open_tables() for old version to go away.
        Such waits can lead to deadlocks which will be detected
        by MDL deadlock detector which now takes waits for table
        to be flushed into account.
        
        Also adjusted code after adding one more parameter for
        close_cached_tables() call - timeout for waiting for
        table to be flushed.
      sql/sql_yacc.yy:
        FLUSH TABLES <list> WITH READ LOCK now needs only SNW
        metadata locks on tables.
      sql/sys_vars.cc:
        Adjusted code after adding one more parameter for
        close_cached_tables() call - timeout for waiting for
        table to be flushed.
      sql/table.cc:
        Implemented new approach to how threads are waiting for
        table to be flushed. Now thread that wants to wait for
        old table to go away subscribes for notification by
        adding Flush_ticket to table's share and waits using
        MDL_context::m_wait object. Once table gets flushed
        (i.e. all tables are closed and table share is ready
        to be destroyed) all such waiters are notified
        individually. This change allows to make such waits
        visible inside of MDL deadlock detector.
        To do it:
        
        - Added list of waiters/Flush_tickets to TABLE_SHARE
          class.
        - Changed free_table_share() to postpone freeing of
          share memory until last waiter goes away and to
          wake up subscribed waiters.
        - Added TABLE_SHARE::wait_until_flushed() method which
          implements subscription to the list of waiters for
          table to be flushed and waiting for this event.
        
        Implemented interface which allows to expose waits for
        flushes to MDL deadlock detector:
        
        - Introduced Flush_ticket class a descendant of
          Wait_for_edge class.
        - Added TABLE_SHARE::find_deadlock() method which allows
          deadlock detector to find out what contexts are still
          using old version of table in question (i.e. to find
          out what contexts are waited for by owner of
          Flush_ticket).
      sql/table.h:
        In order to support new strategy of waiting for table flush
        (see comment for table.cc for details) added list of
        waiters/Flush_tickets to TABLE_SHARE class.
        
        Implemented interface which allows to expose waits for
        flushes to MDL deadlock detector:
        - Introduced Flush_ticket class a descendant of
          Wait_for_edge class.
        - Added TABLE_SHARE::find_deadlock() method which allows
          deadlock detector to find out what contexts are still
          using old version of table in question (i.e. to find
          out what contexts are waited for by owner of
          Flush_ticket).
      5bb44ae0
    • Konstantin Osipov's avatar
      Implement WL#5502 Remove dead 5.0 class Sensitive_cursor. · d16fa003
      Konstantin Osipov authored
      Remove dead and unused code.
      Update to reflect the code review requests.
      
      include/thr_lock.h:
        Remove declarations for THR_LOCK_OWNER,
        added along with the patch for sensitive cursors.
      mysys/thr_lock.c:
        Remove support for multiple thr_lock requestors
        per THD.
      sql/lock.cc:
        Revert the patch that added support for sensitive cursors.
      sql/sp_rcontext.cc:
        Updated the use of mysql_open_cursor().
      sql/sql_class.cc:
        Move the instance of Server_side_cursor
        from class Prepared_statement to class Statement.
      sql/sql_class.h:
        Move the isntance of Server_side_cursor
        from class Prepared_statement to class
        Statement.
        Remove multiple lock_ids of thr_lock.
      sql/sql_cursor.cc:
        Remove Sensitive_cursor implementation.
      sql/sql_cursor.h:
        Remove declarations for sensitive cursors.
      sql/sql_prepare.cc:
        Move the declaration of instance of Server_side_cursor
        from class Statement to class Prepared_statement, 
        where it's used.
      sql/sql_select.cc:
        Remove sensitive cursor support.
      sql/sql_select.h:
        Remove sensitive cursor support.
      sql/sql_union.cc:
        Remove sensitive cursor support.
      d16fa003
  9. 14 Jul, 2010 1 commit
  10. 13 Jul, 2010 1 commit
    • Sven Sandberg's avatar
      BUG#54729: sleep() capped to 5 seconds when executed in the sql thread or in an event · afde22b0
      Sven Sandberg authored
      Symptom:
      When the sql function SLEEP() was executed in the slave SQL thread or from an event (as in
      CREATE EVENT, not binlog event), then the timeout was capped to 5 seconds.
      
      Background:
      This bug was introduced in the fix of BUG#10374, in the function interruptible_wait() in
      item_func.cc.
      The function interruptible_wait(), called from item_func_sleep::val_int(), splits the
      sleep into 5 seconds units. After each unit, it checks if thd->is_connected() is true: if
      not, it stops sleeping. The purpose is to not use system resources to sleep when a client
      disconnects.
      However, thd->is_connected() returns false for the slave SQL thread and for the event
      worker thread, because they don't connect to the server the same way as client threads
      do.
      
      Fix:
      Make thd->is_connected() return true for all system threads.
      
      
      sql/sql_class.h:
        Made THD::is_connected() return true for all system threads.
      afde22b0
  11. 08 Jul, 2010 1 commit
    • Davi Arnaut's avatar
      Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled · 3143a4dc
      Davi Arnaut authored
      Essentially, the problem is that safemalloc is excruciatingly
      slow as it checks all allocated blocks for overrun at each
      memory management primitive, yielding a almost exponential
      slowdown for the memory management functions (malloc, realloc,
      free). The overrun check basically consists of verifying some
      bytes of a block for certain magic keys, which catches some
      simple forms of overrun. Another minor problem is violation
      of aliasing rules and that its own internal list of blocks
      is prone to corruption.
      
      Another issue with safemalloc is rather the maintenance cost
      as the tool has a significant impact on the server code.
      Given the magnitude of memory debuggers available nowadays,
      especially those that are provided with the platform malloc
      implementation, maintenance of a in-house and largely obsolete
      memory debugger becomes a burden that is not worth the effort
      due to its slowness and lack of support for detecting more
      common forms of heap corruption.
      
      Since there are third-party tools that can provide the same
      functionality at a lower or comparable performance cost, the
      solution is to simply remove safemalloc. Third-party tools
      can provide the same functionality at a lower or comparable
      performance cost. 
      
      The removal of safemalloc also allows a simplification of the
      malloc wrappers, removing quite a bit of kludge: redefinition
      of my_malloc, my_free and the removal of the unused second
      argument of my_free. Since free() always check whether the
      supplied pointer is null, redudant checks are also removed.
      
      Also, this patch adds unit testing for my_malloc and moves
      my_realloc implementation into the same file as the other
      memory allocation primitives.
      
      client/mysqldump.c:
        Pass my_free directly as its signature is compatible with the
        callback type -- which wasn't the case for free_table_ent.
      3143a4dc
  12. 04 Jul, 2010 1 commit
    • unknown's avatar
      The following statements support the CURRENT_USER() where a user is needed. · 7cd8cb29
      unknown authored
      DROP USER 
      RENAME USER CURRENT_USER() ...
      GRANT ... TO CURRENT_USER()
      REVOKE ... FROM CURRENT_USER()
      ALTER DEFINER = CURRENT_USER() EVENTbut, When these statements are binlogged, CURRENT_USER() just is binlogged
      as 'CURRENT_USER()', it is not expanded to the real user name. When slave 
      executes the log event, 'CURRENT_USER()' is expand to the user of slave 
      SQL thread, but SQL thread's user name always NULL. This breaks the replication.
      
      After this patch, session's user will be written into query log events 
      if these statements call CURREN_USER() or 'ALTER EVENT' does not assign a definer.
      
      
      mysql-test/include/diff_tables.inc:
        Expend its abilities.
        Now it can diff not only in sessions of 'master' and 'slave', but 
        other sessions as well.
      sql/log_event.cc:
        session's user will be written into Query_log_event, if is_current_user_used() is TRUE.
        On slave SQL thread, Only thd->invoker is written into Query_log_event,
        if it exists.
      sql/sql_acl.cc:
        On slave SQL thread, grantor should copy from thd->invoker, if it exists
      sql/sql_class.h:
        On slave SQL thread, thd->invoker is used to store the applying event's
        invoker.
      7cd8cb29
  13. 02 Jul, 2010 1 commit
    • Davi Arnaut's avatar
      Bug#53445: Build with -Wall and fix warnings that it generates · 1113efea
      Davi Arnaut authored
      Apart strict-aliasing warnings, fix the remaining warnings
      generated by GCC 4.4.4 -Wall and -Wextra flags.
      
      One major source of warnings was the in-house function my_bcmp
      which (unconventionally) took pointers to unsigned characters
      as the byte sequences to be compared. Since my_bcmp and bcmp
      are deprecated functions whose only difference with memcmp is
      the return value, every use of the function is replaced with
      memcmp as the special return value wasn't actually being used
      by any caller.
      
      There were also various other warnings, mostly due to type
      mismatches, missing return values, missing prototypes, dead
      code (unreachable) and ignored return values.
      
      BUILD/SETUP.sh:
        Remove flags that are implied by -Wall and -Wextra.
        Do not warn about unused parameters in C++.
      BUILD/check-cpu:
        Print only the compiler version instead of verbose banner.
        Although the option is gcc specific, the check was only
        being used for GCC specific checks anyway.
      client/mysql.cc:
        bcmp is no longer defined.
      client/mysqltest.cc:
        Pass a string to function expecting a format string.
        Replace use of bcmp with memcmp.
      cmd-line-utils/readline/Makefile.am:
        Always define _GNU_SOURCE when compiling GNU readline.
        Required to make certain prototypes visible.
      cmd-line-utils/readline/input.c:
        Condition for the code to be meaningful.
      configure.in:
        Remove check for bcmp.
      extra/comp_err.c:
        Use appropriate type.
      extra/replace.c:
        Replace use of bcmp with memcmp.
      extra/yassl/src/crypto_wrapper.cpp:
        Do not ignore the return value of fgets. Retrieve the file
        position if fgets succeed -- if it fails, the function will
        bail out and return a error.
      extra/yassl/taocrypt/include/blowfish.hpp:
        Use a single array instead of accessing positions of the sbox_
        through a subscript to pbox_.
      extra/yassl/taocrypt/include/runtime.hpp:
        One definition of such functions is enough.
      extra/yassl/taocrypt/src/aes.cpp:
        Avoid potentially ambiguous conditions.
      extra/yassl/taocrypt/src/algebra.cpp:
        Rename arguments to avoid shadowing related warnings.
      extra/yassl/taocrypt/src/blowfish.cpp:
        Avoid potentially ambiguous conditions.
      extra/yassl/taocrypt/src/integer.cpp:
        Do not define type within a anonymous union.
        Use a variable to return a value instead of
        leaving the result in a register -- compiler
        does not know the logic inside the asm.
      extra/yassl/taocrypt/src/misc.cpp:
        Define handler for pure virtual functions.
        Remove unused code.
      extra/yassl/taocrypt/src/twofish.cpp:
        Avoid potentially ambiguous conditions.
      extra/yassl/testsuite/test.hpp:
        Function must have C language linkage.
      include/m_string.h:
        Remove check which relied on bcmp being defined -- they weren't
        being used as bcmp is only visible when _BSD_SOURCE is defined.
      include/my_bitmap.h:
        Remove bogus helpers which were used only in a few files and
        were causing warnings about dead code.
      include/my_global.h:
        Due to G++ bug, always silence false-positive uninitialized
        variables warnings when compiling C++ code with G++.
        Remove bogus helper.
      libmysql/Makefile.shared:
        Remove built-in implementation of bcmp.
      mysql-test/lib/My/SafeProcess/safe_process.cc:
        Cast pid to largest possible type for a process identifier.
      mysys/mf_loadpath.c:
        Leave space of the ending nul.
      mysys/mf_pack.c:
        Replace bcmp with memcmp.
      mysys/my_bitmap.c:
        Dead code removal.
      mysys/my_gethwaddr.c:
        Remove unused variable.
      mysys/my_getopt.c:
        Silence bogus uninitialized variable warning.
        Do not cast away the constant qualifier.
      mysys/safemalloc.c:
        Cast to expected type.
      mysys/thr_lock.c:
        Silence bogus uninitialized variable warning.
      sql/field.cc:
        Replace bogus helper with a more appropriate logic which is
        used throughout the code.
      sql/item.cc:
        Remove bogus logical condition which always evaluates to TRUE.
      sql/item_create.cc:
        Simplify code to avoid signedness related warnings.
      sql/log_event.cc:
        Replace use of bcmp with memcmp.
        No need to use helpers for simple bit operations.
      sql/log_event_old.cc:
        Replace bmove_align with memcpy.
      sql/mysqld.cc:
        Move use declaration of variable to the ifdef block where it
        is used. Remove now-unnecessary casts and arguments.
      sql/set_var.cc:
        Replace bogus helpers with simple and classic bit operations.
      sql/slave.cc:
        Cast to expected type and silence bogus warning.
      sql/sql_class.h:
        Don't use enum values as bit flags, the supposed type safety is
        bogus as the combined bit flags are not a value in the enumeration.
      sql/udf_example.c:
        Only declare variable when necessary.
      sql/unireg.h:
        Replace use of bmove_align with memcpy.
      storage/innobase/os/os0file.c:
        Silence bogus warning.
      storage/myisam/mi_open.c:
        Remove bogus cast, DBUG_DUMP expects a pointer to unsigned
        char.
      storage/myisam/mi_page.c:
        Remove bogus cast, DBUG_DUMP expects a pointer to unsigned
        char.
      strings/bcmp.c:
        Remove built-in bcmp.
      strings/ctype-ucs2.c:
        Silence bogus warning.
      tests/mysql_client_test.c:
        Use a appropriate type as expected by simple_command().
      1113efea
  14. 30 Jun, 2010 1 commit
    • Alfranio Correia's avatar
      BUG#53259 Unsafe statement binlogged in statement format w/MyIsam temp tables · 846870d8
      Alfranio Correia authored
      BUG#54872 MBR: replication failure caused by using tmp table inside transaction 
            
      Changed criteria to classify a statement as unsafe in order to reduce the
      number of spurious warnings. So a statement is classified as unsafe when
      there is on-going transaction at any point of the execution if:
      
      1. The mixed statement is about to update a transactional table and
      a non-transactional table.
      
      2. The mixed statement is about to update a temporary transactional
      table and a non-transactional table.
            
      3. The mixed statement is about to update a transactional table and
      read from a non-transactional table.
      
      4. The mixed statement is about to update a temporary transactional
      table and read from a non-transactional table.
      
      5. The mixed statement is about to update a non-transactional table
      and read from a transactional table when the isolation level is
      lower than repeatable read.
      
      After updating a transactional table if:
      
      6. The mixed statement is about to update a non-transactional table
      and read from a temporary transactional table.
       
      7. The mixed statement is about to update a non-transactional table
       and read from a temporary transactional table.
      
      8. The mixed statement is about to update a non-transactionala table
         and read from a temporary non-transactional table.
           
      9. The mixed statement is about to update a temporary non-transactional
      table and update a non-transactional table.
           
      10. The mixed statement is about to update a temporary non-transactional
      table and read from a non-transactional table.
           
      11. A statement is about to update a non-transactional table and the
      option variables.binlog_direct_non_trans_update is OFF.
      
      The reason for this is that locks acquired may not protected a concurrent
      transaction of interfering in the current execution and by consequence in
      the result. So the patch reduced the number of spurious unsafe warnings.
      
      Besides we fixed a regression caused by BUG#51894, which makes temporary
      tables to go into the trx-cache if there is an on-going transaction. In
      MIXED mode, the patch for BUG#51894 ignores that the trx-cache may have
      updates to temporary non-transactional tables that must be written to the
      binary log while rolling back the transaction.
            
      So we fix this problem by writing the content of the trx-cache to the
      binary log while rolling back a transaction if a non-transactional
      temporary table was updated and the binary logging format is MIXED.
      846870d8
  15. 28 Jun, 2010 1 commit
  16. 27 Jun, 2010 1 commit
    • unknown's avatar
      The following statements support the CURRENT_USER() where a user is needed. · 95e5c868
      unknown authored
      DROP USER 
      RENAME USER CURRENT_USER() ...
      GRANT ... TO CURRENT_USER()
      REVOKE ... FROM CURRENT_USER()
      ALTER DEFINER = CURRENT_USER() EVENTbut, When these statements are binlogged, CURRENT_USER() just is binlogged
      as 'CURRENT_USER()', it is not expanded to the real user name. When slave 
      executes the log event, 'CURRENT_USER()' is expand to the user of slave 
      SQL thread, but SQL thread's user name always NULL. This breaks the replication.
      
      After this patch, session's user will be written into query log events 
      if these statements call CURREN_USER() or 'ALTER EVENT' does not assign a definer.
      
      
      mysql-test/include/diff_tables.inc:
        Expend its abilities.
        Now it can diff not only in sessions of 'master' and 'slave', but 
        other sessions as well.
      mysql-test/include/rpl_diff_tables.inc:
        Diff the same table between master and slaves.
      sql/log_event.cc:
        session's user will be written into Query_log_event, if is_current_user_used() is TRUE.
        On slave SQL thread, Only thd->variables.current_user is written into Query_log_event,
        if it exists.
      sql/sql_acl.cc:
        On slave SQL thread, grantor should copy from thd->variables.current_user, if it exists
      sql/sql_class.h:
        On slave SQL thread, thd->variables.current_user is used to store the applying event's
        invoker.
      95e5c868
  17. 24 Jun, 2010 1 commit
    • Martin Hansson's avatar
      Bug#41660: Sort-index_merge for non-first join table may · e0a4b838
      Martin Hansson authored
      require O(#scans) memory
      
      When an index merge operation was restarted, it would
      re-allocate the Unique object controlling the duplicate row
      ID elimination. Fixed by making the Unique object a member
      of QUICK_INDEX_MERGE_SELECT and thus reusing it throughout
      the lifetime of this object.
      e0a4b838
  18. 11 Jun, 2010 1 commit
    • Konstantin Osipov's avatar
      WL#5419 "LOCK_open scalability: make tdc_refresh_version · 39e13c00
      Konstantin Osipov authored
      an atomic counter"
      
      Split the large LOCK_open section in open_table(). 
      Do not call open_table_from_share() under LOCK_open.
      Remove thd->version.
      
      This fixes
      Bug#50589 "Server hang on a query evaluated using a temporary 
      table"
      Bug#51557 "LOCK_open and kernel_mutex are not happy together"
      Bug#49463 "LOCK_table and innodb are not nice when handler 
      instances are created".
      
      This patch has effect on storage engines that rely on
      ha_open() PSEA method being called under LOCK_open.
      In particular:
      
      1) NDB is broken and left unfixed. NDB relies on LOCK_open
      being kept as part of ha_open(), since it uses auto-discovery.
      While previously the NDB open code was race-prone, now
      it simply fails on asserts.
      
      2) HEAP engine had a race in ha_heap::open() when
      a share for the same table could be added twice
      to the list of shares, or a dangling reference to a share
      stored in HEAP handler. This patch aims to address this
      problem by 'pinning' the newly created share in the 
      internal HEAP engine share list until at least one
      handler instance is created using that share.
      
      
      include/heap.h:
        Add members to HP_CREATE_INFO.
        Declare heap_release_share().
      sql/lock.cc:
        Remove thd->version, use thd->open_tables->s->version instead.
      sql/repl_failsafe.cc:
        Remove thd->version.
      sql/sql_base.cc:
        - close_thread_table(): move handler cleanup code outside the critical section protected by LOCK_open.
        - remove thd->version
        - split the large critical section in open_table() that
        opens a new table from share and is protected by LOCK_open
        into 2 critical sections, thus reducing the critical path.
        - make check_if_table_exists() acquire LOCK_open internally.
        - use thd->open_tables->s->version instead of thd->refresh_version to make sure that all tables in
        thd->open_tables are in the same refresh series.
      sql/sql_base.h:
        Add declaration for check_if_table_exists().
      sql/sql_class.cc:
        Remove init_open_tables_state(), it's now equal to
        reset_open_tables_state().
      sql/sql_class.h:
        Remove thd->version, THD::init_open_tables_state().
      sql/sql_plugin.cc:
        Use table->m_needs_reopen to mark the table as stale
        rather than manipulate with thd->version, which is no more.
      sql/sql_udf.cc:
        Use table->m_needs_reopen to mark the table as stale
        rather than manipulate with thd->version, which is no more.
      sql/table.h:
        Remove an unused variable.
      sql/tztime.cc:
        Use table->m_needs_reopen to mark the table as stale
        rather than manipulate with thd->version, which is no more.
      storage/heap/CMakeLists.txt:
        Add heap tests to cmake build files.
      storage/heap/ha_heap.cc:
        Fix a race when ha_heap::ha_open() could insert two 
        HP_SHARE objects into the internal share list or store
        a dangling reference to a share in ha_heap instance,
        or wrongly set implicit_emptied.
      storage/heap/hp_create.c:
        Optionally pin a newly created share in the list of shares
        by increasing its open_count. This is necessary to 
        make sure that a newly created share doesn't disappear while
        a HP_INFO object is being created to reference it.
      storage/heap/hp_open.c:
        When adding a new HP_INFO object to the list of objects
        in the heap share, make sure the open_count is not increased
        twice.
      storage/heap/hp_test1.c:
        Adjust the test to new function signatures.
      storage/heap/hp_test2.c:
        Adjust the test to new function signatures.
      39e13c00
  19. 08 Jun, 2010 1 commit
    • Konstantin Osipov's avatar
      WL#4441 "LOCK_open: Remove requirement of mutex protecting · c5f5e8e5
      Konstantin Osipov authored
      thd->open_tables"
      
      thd->open_tables list is not normally accessed concurrently
      except for one case: when the connection has open SQL
      HANDLER tables, and we want to perform a DDL on the table,
      we want to abort waits on MyISAM thr_lock of those connections
      that prevent the DDL from proceeding, and iterate
      over thd->open_tables list to find out the tables on which
      the thread is waiting.
      
      In 5.5 we mostly use deadlock detection and soft deadlock 
      prevention, as opposed to "hard" deadlock prevention
      of 5.1, which would abort any transaction that
      may cause a deadlock. The only remaining case when
      neither deadlock detection nor deadlock prevention
      is implemented in 5.5 is HANDLER SQL, where we use
      old good thr_lock_abort() technique form 5.1. 
      
      Thus, replace use of LOCK_open to protect thd->open_tables
      with thd->LOCK_ha_data (a lock protecting various session
      private data).
      
      This is a port of the work done for 5.5.4 for review
      and inclusion into 5.5.5.
      
      sql/sql_base.cc:
        Use thd->LOCK_ha_data (systematically) to set
        thd->open_tables.
      sql/sql_class.h:
        Implement THD::set_open_tables().
      sql/sql_cursor.cc:
        Use thd->LOCK_ha_data (systematically) to set
        thd->open_tables.
      sql/sql_handler.cc:
        Use thd->LOCK_ha_data (systematically) to set
        thd->open_tables.
        Acquisition of LOCK_open is moved inside close_thread_table().
      sql/sql_table.cc:
        Acquisition of LOCK_open is moved inside close_thread_tables().
      c5f5e8e5
  20. 07 Jun, 2010 1 commit
    • Mats Kindahl's avatar
      WL#5363: Thread Pool Service Interface · 3682329c
      Mats Kindahl authored
      In order to allow thread schedulers to be dynamically loaded,
      it is necessary to make the following changes to the server:
      
      - Two new service interfaces
      
      - Modifications to InnoDB to inform the thread scheduler of state changes.
      
      - Changes to the VIO subsystem for checking if data is available on a socket.
      
      - Elimination of remains of the old thread pool implementation.
      
      The two new service interfaces introduces are:
      
      my_thread_scheduler
        A service interface to register a thread
        scheduler.
      
      thd_wait
        A service interface to inform thread scheduler
        that the thread is about to start waiting.
      
      In addition, the patch adds code that:
      
      - Add a call to thd_wait for table locks in mysys
        thd_lock.c by introducing a set function that
        can be used to set a callback to be used when
        waiting on a lock and resuming from waiting.
      
      - Calling the mysys set function from the server
        to set the callbacks correctly.
      
      3682329c
  21. 04 Jun, 2010 1 commit
    • Georgi Kodinov's avatar
      Bug #52315: utc_date() crashes when system time > year 2037 · a4cd7f2c
      Georgi Kodinov authored
                  
      Some of the server implementations don't support dates later
      than 2038 due to the internal time type being 32 bit.
      Added checks so that the server will refuse dates that cannot
      be handled by either throwing an error when setting date at 
      runtime or by refusing to start or shutting down the server if 
      the system date cannot be stored in my_time_t.
      a4cd7f2c
  22. 01 Jun, 2010 2 commits
    • Alfranio Correia's avatar
      BUG#50479 DDL stmt on row-only/stmt-only tables generate spurious binlog_format · c27b21ae
      Alfranio Correia authored
      errors
                  
      In the fix of BUG#39934 in 5.1-rep+3, errors are generated when
      binlog_format=row and a statement modifies a table restricted to
      statement-logging (ER_BINLOG_ROW_MODE_AND_STMT_ENGINE); or if
      binlog_format=statement and a statement modifies a table restricted to
      row-logging (ER_BINLOG_STMT_MODE_AND_ROW_ENGINE).
                  
      However, some DDL statements that lock tables (e.g. ALTER TABLE,
      CREATE INDEX and CREATE TRIGGER) were causing spurious errors,
      although no row might be inserted into the binary log.
                  
      To fix the problem, we tagged statements that may generate
      rows into the binary log and thence the warning messages are
      only printed out when the appropriate conditions hold and rows
      might be changed.
      
      sql/log_event.cc:
        Reorganized the Query_log_event's constructor based on the
        CF_CAN_GENERATE_ROW_EVENTS flag and as such any statement
        that has the associated flag should go through a cache
        before being written to the binary log.
      sql/share/errmsg-utf8.txt:
        Improved the error message ER_BINLOG_UNSAFE_MIXED_STATEMENT according to Paul's
        suggestion.
      sql/sql_class.cc:
        Created a hook to be used by innodb that checks if a statement
        may write rows to the binary log. In other words, if it has
        the CF_CAN_GENERATE_ROW_EVENTS flag associated.
      sql/sql_class.h:
        Defined the CF_CAN_GENERATE_ROW_EVENTS flag.
      sql/sql_parse.cc:
        Updated the sql_command_flags and added a function to check the 
        CF_CAN_GENERATE_ROW_EVENTS.
      sql/sql_parse.h:
        Added a function to check the CF_CAN_GENERATE_ROW_EVENTS.
      storage/innobase/handler/ha_innodb.cc:
        Added a call to the hook thd_generates_rows().
      storage/innobase/handler/ha_innodb.h:
        Defined an external reference to the hook thd_generates_rows().
      c27b21ae
    • Konstantin Osipov's avatar
      A follow up patch for the fix for Bug#51263 "Deadlock between · 099819d3
      Konstantin Osipov authored
       transactional SELECT and ALTER TABLE ...  REBUILD PARTITION".
      
      Move declarations of sql_base.cc classes to sql_base.h
      (previously declared in sql_class.h).
      Became possible after a header file split.
      
      
      
      
      
      sql/sql_base.cc:
        Make sql_base.h the first include in sql_base.cc.
      sql/sql_base.h:
        Add declarations of Prelocking_strategy and Open_table_context.
      sql/sql_class.h:
        Remove declarations of Prelocking_strategy and Open_table_context
        (moved).
      099819d3
  23. 31 May, 2010 1 commit
    • Davi Arnaut's avatar
      Bug#53445: Build with -Wall and fix warnings that it generates · 7ac43fce
      Davi Arnaut authored
      Fix various mismatches between function's language linkage. Any
      particular function that is declared in C++ but should be callable
      from C must have C linkage. Note that function types with different
      linkages are also distinct. Thus, if a function type is declared in
      C code, it will have C linkage (same if declared in a extern "C"
      block).
      
      client/mysql.cc:
        Mismatch between prototype and declaration.
      client/mysqltest.cc:
        mysqltest used to be C code. Use C linkage where appropriate.
      cmd-line-utils/readline/input.c:
        Isolate unreachable code.
      include/my_alloc.h:
        Function type must have C linkage.
      include/my_base.h:
        Function type must have C linkage.
      include/my_global.h:
        Add helper macros to avoid spurious namespace indentation.
      include/mysql.h.pp:
        Update ABI file.
      mysys/my_gethwaddr.c:
        Remove stray carriage return and fix coding style.
      plugin/semisync/semisync_master_plugin.cc:
        Callback function types have C linkage.
      plugin/semisync/semisync_slave_plugin.cc:
        Callback function types have C linkage.
      sql/derror.cc:
        Expected function type has C linkage.
      sql/field.cc:
        Use helper macro and fix indentation.
      sql/handler.cc:
        Expected function type has C linkage.
      sql/item_sum.cc:
        Correct function linkages. Remove now unnecessary cast.
      sql/item_sum.h:
        Add prototypes with the appropriate linkage as otherwise they
        are distinct.
      sql/mysqld.cc:
        Wrap functions in C linkage mode.
      sql/opt_range.cc:
        C language linkage is ignored for class member functions.
      sql/partition_info.cc:
        Add wrapper functions with C linkage for class member functions.
      sql/rpl_utility.h:
        Use helper macro and fix indentation.
      sql/sql_class.cc:
        Change type of thd argument -- THD is a class.
        Use helper macro and fix indentation.
      sql/sql_class.h:
        Change type of thd argument -- THD is a class.
      sql/sql_select.cc:
        Expected function type has C linkage.
      sql/sql_select.h:
        Move prototype to sql_test.h
      sql/sql_show.cc:
        Expected function type has C linkage.
      sql/sql_test.cc:
        Fix required function prototype and fix coding style.
      sql/sql_test.h:
        Removed unnecessary export and add another.
      storage/myisammrg/ha_myisammrg.cc:
        Expected function type has C linkage.
      storage/perfschema/pfs.cc:
        PSI headers are declared with C language linkage, which also
        applies to function types.
      7ac43fce
  24. 28 May, 2010 1 commit
    • Davi Arnaut's avatar
      Backport: Remove unused and ancient files, functions, and facilities. · 46e6ee71
      Davi Arnaut authored
      client/mysql.cc:
        Remove unused functions.
      client/sql_string.cc:
        Remove unused functions.
      include/my_pthread.h:
        Remove unused prototype.
      mysys/my_pthread.c:
        Remove unused function.
      sql/lock.cc:
        Remove unused function.
      sql/lock.h:
        Remove unused and duplicated prototypes.
      sql/sql_class.h:
        Removed unused variables.
      sql/sql_const.h:
        Remove unused defines.
      sql/sql_priv.h:
        Remove unused defines.
      sql/sql_string.cc:
        Remove unused prototype.
      sql/thr_malloc.cc:
        Remove unused function.
      sql/thr_malloc.h:
        Remove unused prototype.
      storage/myisam/CMakeLists.txt:
        Remove obsolete fulltext file.
      storage/myisam/Makefile.am:
        Remove obsolete files (were already commented out).
      storage/myisam/ft_eval.c:
        Remove obsolete fulltext file.
      storage/myisam/ft_eval.h:
        Remove obsolete fulltext file.
      storage/myisam/ft_stem.c:
        Remove obsolete fulltext file.
      storage/myisam/ft_test1.c:
        Remove obsolete fulltext file.
      storage/myisam/ft_test1.h:
        Remove obsolete fulltext file.
      46e6ee71
  25. 27 May, 2010 1 commit
    • Alfranio Correia's avatar
      BUG#53437 @@session.sql_bin_log support in substatements is incorrect · 106abcab
      Alfranio Correia authored
            
      The thd->variables.option_bits & OPTION_BIN_LOG is currently abused: 
      it's both a system variable and an implementation switch. The current
      approach to this option bit breaks the session variable encapsulation. 
            
      Besides it is allowed to change @@session.sql_bin_log within a
      transaction what may lead to not correctly logging a transaction.
            
      To fix the problems,  we created a thd->variables variable to represent
      the "sql_log_bin" and prohibited its update inside a transaction or
      sub-statement.
      
      mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result:
        Updated result file. The reason the warnings are removed is
        related to BUG#50312.
      mysql-test/suite/binlog/r/binlog_switch_inside_trans.result:
        Checks when is possible to change the option @@session.sql_log_bin.
      mysql-test/suite/binlog/t/binlog_switch_inside_trans.test:
        Checks when is possible to change the option @@session.sql_log_bin.
      mysql-test/suite/rpl/r/rpl_non_direct_stm_mixing_engines.result:
        Updated the result file with warnings that were being printed
        due to the wrong use of the thd->variables.option_bits and
        sql_log_bin_top_level variables.
      mysql-test/suite/rpl/r/rpl_stm_mixing_engines.result:
        Updated the result file with warnings that were being printed
        due to the wrong use of the thd->variables.option_bits and
        sql_log_bin_top_level variables.
      sql/share/errmsg-utf8.txt:
        Introduces two error messages to notify that the @@session.sql_log_bin
        cannot be changed inside a sub-statement or transaction.
      sql/sql_base.cc:
        Removes the variable sql_log_bin_toplevel and uses
        the session variable sql_log_bin.
      sql/sql_class.cc:
        Replaces the variable sql_log_bin_toplevel by the
        (variables.option_bits & OPTION_BIN_LOG).
      sql/sql_class.h:
        Removes the variable sql_log_bin_toplevel and creates 
        a session variable sql_log_bin.
      sql/sys_vars.cc:
        Checks when the sql_log_bin can be correctly updated.
      106abcab
  26. 25 May, 2010 1 commit
    • Dmitry Lenev's avatar
      Pre-requisite patch for bug #51263 "Deadlock between · 6c09fabf
      Dmitry Lenev authored
      transactional SELECT and ALTER TABLE ... REBUILD PARTITION".
      
      The goal of this patch is to decouple type of metadata
      lock acquired for table by open_tables() from type of
      table-level lock to be acquired on it.
      
      To achieve this we change approach to how we determine what
      type of metadata lock should be acquired on table to be open.
      Now instead of inferring it at open_tables() time from flags
      and type of table-level lock we rely on that type of metadata
      lock is properly set at parsing time and is not changed
      further.
      
      sql/ha_ndbcluster.cc:
        Now one needs to properly initialize table list element's
        MDL_request object before calling mysql_rm_table_part2().
      sql/lock.cc:
        lock_table_names() no longer initializes table list elements'
        MDL_request objects. Now proper initialization of these
        requests is a responsibility of the caller.
      sql/lock.h:
        Removed MYSQL_OPEN_TAKE_UPGRADABLE_MDL flag which became
        unnecessary. Thanks to the fact that we don't reset type of
        requests for metadata locks between re-executions we now can
        figure out that upgradable locks are requested by simply
        looking at their type which were set in the parser. As result
        this flag became redundant.
      sql/mdl.h:
        Added version of new operator which simplifies allocation of
        MDL_request objects on a MEM_ROOT.
      sql/sp_head.cc:
        Added comment explaining why it is OK to infer type of
        metadata lock to request from type of table-level lock
        for prelocking.
        Added enum_mdl_type argument to sp_add_to_query_tables()
        to simplify its usage in trigger implementation.
      sql/sp_head.h:
        Added enum_mdl_type argument to sp_add_to_query_tables()
        to simplify its usage in trigger implementation.
      sql/sql_base.cc:
        - open_table_get_mdl_lock():
          Preserve type of MDL_request for table list element which
          was set in the parser by creating MDL_request objects on
          memory root if MYSQL_OPEN_FORCE_SHARED_MDL or
          MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL flag were specified.
          Thanks to this and to the fact that we no longer reset
          type of requests for metadata locks between re-executions
          we no longer need to acquire exclusive metadata lock on
          table to be created in a special way. This lock is acquired
          by code handling acquiring of upgradable locks.
          Also changed signature/calling convention for this function
          to simplify its usage.
        - Accordingly special lock strategy for table list elements
          which was used for such locks became unnecessary and was
          removed. Other strategies were renamed.
        - Since we no longer have guarantee that MDL_request object
          which were not satisfied due to lock conflict belongs to
          table list element Open_table_context class and its methods
          were extended to remember pointer to MDL_request which has
          caused problem at request_backoff_action() time and use it
          in recover_from_failed_open(). Similar approach is used
          for cases when problem from which we need to recover is
          not related to MDL but to the table itself. In this case
          we store pointer to the element of table list.
        - Changed open_tables()/open_tables_check_upgradable_mdl()/
          open_tables_acquire_upgradable_mdl() not to rely on
          MYSQL_OPEN_TAKE_UPGRADABLE_MDL flag to understand when
          upgradable metadata locks should be acquired and not to
          infer type of MDL lock from type of table-level lock.
          Instead we assume that type of MDL to be acquired was set
          in the parser (we can do this as type of MDL_request is
          no longer reset between re-executions).
      sql/sql_class.h:
        Since we no longer have guarantee that MDL_request object
        which were not satisfied due to lock conflict belongs to
        table list element Open_table_context class and its methods
        were extended to remember pointer to MDL_request which has
        caused problem at request_backoff_action() time and use it
        in recover_from_failed_open(). Similar approach is used
        for cases when problem from which we need to recover is
        not related to MDL but to the table itself. In this case
        we store pointer to the element of table list.
      sql/sql_db.cc:
        Now one needs to properly initialize table list element's
        MDL_request object before calling mysql_rm_table_part2()
        or mysql_rename_tables().
      sql/sql_lex.cc:
        st_select_lex/st_select_lex_node::add_table_to_list() method
        now has argument which allows specify type of metadata lock
        to be requested for table list element being added.
      sql/sql_lex.h:
        - st_select_lex/st_select_lex_node::add_table_to_list()
          method now has argument which specifies type of metadata
          lock to be requested for table list element being added.
          This allows to explicitly set type of MDL lock to be
          acquired for a DDL statement in parser. It is also more
          future-proof than inferring type of MDL request from type
          of table-level lock.
        - Added Yacc_state::m_mdl_type member which specifies which
          type of metadata lock should be requested for tables to be
          added to table list by a grammar rule in cases when the same
          rule is used in several statements requiring different kinds
          of metadata locks.
      sql/sql_parse.cc:
        - st_select_lex::add_table_to_list() method now has argument
          which specifies type of metadata lock to be requested for
          table list element being added. This allows to explicitly
          set type of MDL lock to be acquired for a DDL statement in
          parser. It is also more future-proof than inferring type of
          MDL request from type of table-level lock.
        - EXCLUSIVE_DOWNGRADABLE_MDL lock strategy has a new name -
          OTLS_DOWNGRADE_IF_EXISTS.
        - Adjusted LOCK TABLES implementation to the fact that we no
          longer infer type of metadata lock to be acquired from table
          level lock and that type of MDL request is set at parsing.
          And thus MYSQL_OPEN_TAKE_UPGRADABLE_MDL flag became
          unnecessary.
      sql/sql_prepare.cc:
        TABLE_LIST's lock strategy SHARED_MDL was renamed to OTLS_NONE
        as now it means that metadata lock should not be changed during
        call to open_table() (if it has been already acquired) and is
        also used for exclusive metadata lock.
      sql/sql_show.cc:
        st_select_lex::add_table_to_list() method now has argument
        which specifies type of metadata lock to be requested for
        table list element being added.
      sql/sql_table.cc:
        - Adjusted mysql_admin_table()'s code to the fact that
          open_tables() no longer determines what kind of metadata
          lock should be obtained basing on type of table-level
          lock and flags. Instead type of metadata lock for table
          to be open should be set before calling open_tables().
        - Changed mysql_alter_table() code to the facts:
          a) that now it is responsibility of caller to properly
          initalize MDL_request in table list elements before calling
          lock_table_names()
          b) and that MYSQL_OPEN_TAKE_UPGRADABLE_MDL is no longer
          necessary since type of metadata lock to be obtained
          at open_tables() time is set during parsing.
        - Changed code of mysql_recreate_table() to properly set
          type of metadata and table-level lock to be obtained
          by mysql_alter_table() which it calls.
      sql/sql_trigger.cc:
        Instead of relying on MYSQL_OPEN_TAKE_UPGRADABLE_MDL flag to
        force open_tables() to take an upgradable lock we now specify
        exact type of lock to be taken when constructing table list
        element for table to be open for CREATE/DROP TRIGGER.
      sql/sql_view.cc:
        We no longer use TABLE_LIST::EXCLUSIVE_MDL strategy to force
        open_tables() to take an exclusive metadata lock on view to
        be created. Instead we rely on parser setting proper type of
        metadata lock to request and open_tables() acquiring it.
        This became possible thanks to the fact that we no longer
        reset type of MDL_request between statement re-executions.
      sql/sql_yacc.yy:
        Instead of inferring type of MDL_request for table to be
        open from type of table-level lock and flags passed to
        open_tables() we now explicitly specify them at parsing.
        This became possible thanks to the fact that we no longer
        reset type of MDL_request between statement re-executions.
        In future this should allow to decouple type of metadata
        lock from type of table-level lock.
        The only exception to this approach is statements implemented
        through mysql_admin_table() which re-uses same table list
        element several times with different types of table-level
        and metadata locks.
        We now also properly initialize MDL_request objects for table
        list elements which are later passed to lock_table_names()
        function.
      sql/table.cc:
        Do not reset type of MDL_request between statement
        re-executions. This became unnecessesary as we no longer
        change type of MDL_request residing in table list element.
        In its turn this change allows to set type of MDL_request
        only once - at parsing time.
      sql/table.h:
        Got rid of TABLE_LIST::EXCLUSIVE_MDL lock strategy.
        Now we can specify that we need to acquire exclusive lock
        on table to be processed by open_tables() through setting
        an appropriate type of MDL_request at parsing time (this
        became possible thanks to the fact that we no longer reset
        types of MDL_request's belonging to table list elements
        between statement re-execution).
        Strategy SHARED_MDL was renamed to OTLS_NONE as now it
        means that metadata lock should not be changed during call
        to open_table() (if it has been already acquired) and is
        also used for exclusive metadata lock.
        Strategy EXCLUSIVE_DOWNGRADABLE_MDL was renamed to
        OTLS_DOWNGRADE_IF_EXISTS.
      6c09fabf
  27. 14 May, 2010 1 commit
    • Alexander Nozdrin's avatar
      Patch for Bug#21818 (Return value of ROW_COUNT() is incorrect · c3ea9d9c
      Alexander Nozdrin authored
      for ALTER TABLE, LOAD DATA).
      
      ROW_COUNT is now assigned according to the following rules:
      
        - In my_ok():
          - for DML statements: to the number of affected rows;
          - for DDL statements: to 0.
      
        - In my_eof(): to -1 to indicate that there was a result set.
      
          We derive this semantics from the JDBC specification, where int
          java.sql.Statement.getUpdateCount() is defined to (sic) "return the
          current result as an update count; if the result is a ResultSet
          object or there are no more results, -1 is returned".
      
        - In my_error(): to -1 to be compatible with the MySQL C API and
          MySQL ODBC driver.
      
        - For SIGNAL statements: to 0 per WL#2110 specification. Zero is used
          since that's the "default" value of ROW_COUNT in the diagnostics area.
      
      sql/protocol.cc:
        Fix a typo.
      sql/sql_class.h:
        - Introduce THD::get_row_count_func() / THD::set_row_count_func();
        - Remove the CF_HAS_ROW_COUNT define
      sql/sql_parse.cc:
        CF_HAS_ROW_COUNT was eliminated.
      c3ea9d9c
  28. 12 May, 2010 1 commit
    • Staale Smedseng's avatar
      Bug #49756 Rows_examined is always 0 in the slow query log for · 5bb5e0f2
      Staale Smedseng authored
      update statements
            
      Only SELECT statements report any examined rows in the slow
      log. Slow UPDATE, DELETE and INSERT statements report 0 rows
      examined, unless the statement has a condition including a
      SELECT substatement.
            
      This patch adds counting of examined rows for the UPDATE and
      DELETE statements. An INSERT ... VALUES statement will still 
      not report any rows as examined.
      
      
      
      sql/sql_class.h:
        Added more docs for THD::examined_row_count.
      sql/sql_delete.cc:
        Add incrementing thd->examined_row_count.
      sql/sql_update.cc:
        Add incrementing thd->examined_row_count.
      5bb5e0f2
  29. 07 May, 2010 1 commit
    • Konstantin Osipov's avatar
      Draft patch that fixes and a sketches test cases for: · e389fc6f
      Konstantin Osipov authored
      Bug#20837 Apparent change of isolation level during transaction,
      Bug#46527 COMMIT AND CHAIN RELEASE does not make sense,
      Bug#53343 completion_type=1, COMMIT/ROLLBACK AND CHAIN don't 
      preserve the isolation level
      Bug#53346 completion_type has strange effect in a stored 
      procedure/prepared statement
      
      Make thd->tx_isolation mean strictly "current transaction 
      isolation level"
      Make thd->variables.tx_isolation mean "current session isolation
      level".
      The current transaction isolation level is now established
      at transaction start. If there was a SET TRANSACTION
      ISOLATION LEVEL statement, the value is taken from it.
      Otherwise, the session value is used.
      A change in a session value, made while a transaction is active,
      whereas still allowed, no longer has any effect on the
      current transaction isolation level. This is an incompatible
      change.
      A change in a session isolation level, made while there is
      no active transaction, overrides SET TRANSACTION statement,
      if there was any.
      Changed the impelmentation to not look at @@session.completion_type
      in the parser, and thus fixed Bug#53346.
      Changed the parser to not allow AND NO CHAIN RELEASE,
      and thus fixed Bug#46527.
      Changed the transaction API to take the current transaction
      isolation level into account:
      - BEGIN/COMMIT now do preserve the current transaction
      isolation level if chaining is on.
      - implicit commit, XA COMMIT or XA ROLLBACK or autocommit don't.
      e389fc6f
  30. 05 May, 2010 1 commit
    • Konstantin Osipov's avatar
      Clean-up, give better names, add comments to · 25d83b75
      Konstantin Osipov authored
      thd->in_multi_stmt_transaction() and thd->active_transaction().
      
      
      include/mysql_com.h:
        Comment SERVER_STATUS_IN_TRANS flag.
      sql/ha_ndbcluster.cc:
        Rename: thd->in_multi_stmt_transaction() -> 
        thd->in_multi_stmt_transaction_mode().
      sql/handler.cc:
        Add comments.
      sql/log.cc:
        Rename: thd->in_multi_stmt_transaction() -> 
        thd->in_multi_stmt_transaction_mode().
      sql/log_event.cc:
        Rename: thd->in_multi_stmt_transaction() -> 
        thd->in_multi_stmt_transaction_mode().
      sql/sql_base.cc:
        Rename: thd->in_multi_stmt_transaction() -> 
        thd->in_multi_stmt_transaction_mode().
      sql/sql_cache.cc:
        Rename: thd->active_transaction() ->
        thd->in_active_multi_stmt_transaction().
      sql/sql_class.cc:
        Rename: thd->in_multi_stmt_transaction() -> 
        thd->in_multi_stmt_transaction_mode().
      sql/sql_class.h:
        Rename and comment two transaction processing- related methods.
      sql/sql_parse.cc:
        Rename: thd->in_multi_stmt_transaction() -> 
        thd->in_multi_stmt_transaction_mode().
        Rename: thd->active_transaction() ->
        thd->in_active_multi_stmt_transaction().
      sql/sql_prepare.cc:
        Rename: thd->in_multi_stmt_transaction() -> 
        thd->in_multi_stmt_transaction_mode().
      sql/sql_rename.cc:
        Rename: thd->active_transaction() ->
        thd->in_active_multi_stmt_transaction().
      sql/sql_table.cc:
        Rename: thd->active_transaction() ->
        thd->in_active_multi_stmt_transaction().
      sql/sys_vars.cc:
        Rename: thd->active_transaction() ->
        thd->in_active_multi_stmt_transaction().
      sql/transaction.cc:
        Rename: thd->in_multi_stmt_transaction() -> 
        thd->in_multi_stmt_transaction_mode().
        Rename: thd->active_transaction() ->
        thd->in_active_multi_stmt_transaction().
      25d83b75
  31. 26 Apr, 2010 1 commit
    • Alfranio Correia's avatar
      BUG#53075 SBR: Strange warning around CONNECTION_ID · c7e6707c
      Alfranio Correia authored
      Statements with CONNECTION_ID were forced to be kept in the transactional
      cache and by consequence non-transactional changes that were supposed to
      be flushed ahead of the transaction were kept in the transactional cache.
      
      This happened because after BUG#51894 any statement whose thd's
      thread_specific_used was set was kept in the transactional cache. The idea
      was to keep changes on temporary tables in the transactional cache. However,
      the thread_specific_used was set not only for statements that accessed
      temporary tables but also when the CONNECTION_ID was used.
      
      To fix the problem, we created a new variable to keep track of updates
      to temporary tables.
      
      
      mysql-test/suite/rpl/r/rpl_temp_temporary.result:
        Added a test case.
      mysql-test/suite/rpl/t/rpl_temp_temporary.test:
        Added a test case.
      sql/log_event.cc:
        Uses the thread_temporary_used to decide if a statement should
        be kept in the transactional cache or not.
      sql/sql_class.cc:
        Sets the thread_temporary_used while calling the decide_logging_format.
      sql/sql_class.h:
        Defines the thread_temporary_used.
      sql/sql_parse.cc:
        Resets the thread_temporary_used.
      c7e6707c
  32. 20 Apr, 2010 1 commit
    • Alfranio Correia's avatar
      BUG#51894 Replication failure with SBR on DROP TEMPORARY TABLE inside a · 4bf7d53b
      Alfranio Correia authored
                transaction
      BUG#52616 Temp table prevents switch binlog format from STATEMENT to ROW
      
      Before the WL#2687 and BUG#46364, every non-transactional change that happened
      after a transactional change was written to trx-cache and flushed upon
      committing the transaction. WL#2687 and BUG#46364 changed this behavior and
      non-transactional changes are now written to the binary log upon committing
      the statement.
      
      A binary log event is identified as transactional or non-transactional through
      a flag in the Log_event which is set taking into account the underlie storage
      engine on what it is stems from. In the current bug, this flag was not being
      set properly when the DROP TEMPORARY TABLE was executed.
      
      However, while fixing this bug we figured out that changes to temporary tables
      should be always written to the trx-cache if there is an on-going transaction.
      Otherwise, binlog events in the reversed order would be produced.
      
      Regarding concurrency, keeping changes to temporary tables in the trx-cache is
      also safe as temporary tables are only visible to the owner connection.
      
      In this patch, we classify the following statements as unsafe:
         1 - INSERT INTO t_myisam SELECT * FROM t_myisam_temp
      
         2 - INSERT INTO t_myisam_temp SELECT * FROM t_myisam
      
         3 - CREATE TEMPORARY TABLE t_myisam_temp SELECT * FROM t_myisam
      
      On the other hand, the following statements are classified as safe:
      
         1 - INSERT INTO t_innodb SELECT * FROM t_myisam_temp
      
         2 - INSERT INTO t_myisam_temp SELECT * FROM t_innodb
      
      The patch also guarantees that transactions that have a DROP TEMPORARY are
      always written to the binary log regardless of the mode and the outcome:
      commit or rollback. In particular, the DROP TEMPORARY is extended with the
      IF EXISTS clause when the current statement logging format is set to row.
      
      Finally, the patch allows to switch from STATEMENT to MIXED/ROW when there
      are temporary tables but the contrary is not possible.
      
      mysql-test/extra/rpl_tests/rpl_binlog_max_cache_size.test:
        Updated the test case because 
           CREATE TEMPORARY TABLE t_innodb_temp SELECT * FROM t_myisam is not unsafe.
      mysql-test/extra/rpl_tests/rpl_implicit_commit_binlog.test:
        Updated the test case due to the new rules: changes to
        temporary tables are written to the binary log in the
        boundaries of a transaction if there is any.
      mysql-test/extra/rpl_tests/rpl_innodb.test:
        Removed comments from the test case that became false after the patch.
      mysql-test/extra/rpl_tests/rpl_loaddata.test:
        Suppressed warning messages due to the following cases:
        
           1 - INSERT INTO t_myisam SELECT * FROM t_myisam_temp
        
           2 - INSERT INTO t_myisam_temp SELECT * FROM t_myisam
      mysql-test/include/ctype_utf8_table.inc:
        Suppressed warning messages due to the following cases:
        
           1 - INSERT INTO t_myisam SELECT * FROM t_myisam_temp
        
           2 - INSERT INTO t_myisam_temp SELECT * FROM t_myisam
      mysql-test/r/ctype_cp932_binlog_stm.result:
        Updated the test case due to the new rules: changes to
        temporary tables are written to the binary log in the
        boundaries of a transaction if there is any.
      mysql-test/suite/binlog/r/binlog_database.result:
        Updated the test case due to the new rules: changes to
        temporary tables are written to the binary log in the
        boundaries of a transaction if there is any.
      mysql-test/suite/binlog/r/binlog_innodb_row.result:
        Updated the result file.
      mysql-test/suite/binlog/r/binlog_multi_engine.result:
        Updated the unsafe message.
      mysql-test/suite/binlog/r/binlog_row_binlog.result:
        Updated the test case due to the new rules: changes to
        temporary tables are written to the binary log in the
        boundaries of a transaction if there is any.
      mysql-test/suite/binlog/r/binlog_row_drop_tmp_tbl.result:
        Updated the test case due to the new rules: changes to
        temporary tables are written to the binary log in the
        boundaries of a transaction if there is any.
      mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result:
        Updated the test case due to the new rules: changes to
        temporary tables are written to the binary log in the
        boundaries of a transaction if there is any.
      mysql-test/suite/binlog/r/binlog_stm_binlog.result:
        Updated the result file.
      mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result:
        Updated the test case due to the new rules: changes to
        temporary tables are written to the binary log in the
        boundaries of a transaction if there is any.
      mysql-test/suite/binlog/t/binlog_tmp_table.test:
        Suppressed warning messages due to the following cases:
        
           1 - INSERT INTO t_myisam SELECT * FROM t_myisam_temp
        
           2 - INSERT INTO t_myisam_temp SELECT * FROM t_myisam
      mysql-test/suite/ndb/r/ndb_binlog_format.result:
        Updated the unsafe message.
      mysql-test/suite/rpl/r/rpl_concurrency_error.result:
        Updated the unsafe message.
      mysql-test/suite/rpl/r/rpl_mixed_binlog_max_cache_size.result:
        Updated the result file because 
           CREATE TEMPORARY TABLE t_innodb_temp SELECT * FROM t_myisam is not unsafe.
      mysql-test/suite/rpl/r/rpl_mixed_implicit_commit_binlog.result:
        Updated the test case due to the new rules: changes to
        temporary tables are written to the binary log in the
        boundaries of a transaction if there is any.
      mysql-test/suite/rpl/r/rpl_mixed_mixing_engines.result:
        Updated the test case due to the new rules: changes to
        temporary tables are written to the binary log in the
        boundaries of a transaction if there is any.
      mysql-test/suite/rpl/r/rpl_mixed_row_innodb.result:
        Added some comments to ease the understanding of the result file.
      mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
        Updated the test case due to the new rules: changes to
        temporary tables are written to the binary log in the
        boundaries of a transaction if there is any.
      mysql-test/suite/rpl/r/rpl_non_direct_row_mixing_engines.result:
        Updated the test case due to the new rules: changes to
        temporary tables are written to the binary log in the
        boundaries of a transaction if there is any.
      mysql-test/suite/rpl/r/rpl_non_direct_stm_mixing_engines.result:
        Updated the test case due to the new rules: changes to
        temporary tables are written to the binary log in the
        boundaries of a transaction if there is any.
      mysql-test/suite/rpl/r/rpl_row_drop.result:
        Updated the test case due to the new rules: changes to
        temporary tables are written to the binary log in the
        boundaries of a transaction if there is any.
      mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result:
        Updated the test case due to the new rules: changes to
        temporary tables are written to the binary log in the
        boundaries of a transaction if there is any.
      mysql-test/suite/rpl/r/rpl_row_mixing_engines.result:
        Updated the test case due to the new rules: changes to
        temporary tables are written to the binary log in the
        boundaries of a transaction if there is any.
      mysql-test/suite/rpl/r/rpl_stm_binlog_max_cache_size.result:
        Updated the result file because 
           CREATE TEMPORARY TABLE t_innodb_temp SELECT * FROM t_myisam is not unsafe.
      mysql-test/suite/rpl/r/rpl_stm_implicit_commit_binlog.result:
        Updated the test case due to the new rules: changes to
        temporary tables are written to the binary log in the
        boundaries of a transaction if there is any.
      mysql-test/suite/rpl/r/rpl_stm_innodb.result:
        Added some comments to ease the understanding of the result file.
      mysql-test/suite/rpl/r/rpl_stm_mixing_engines.result:
        Updated the test case due to the new rules: changes to
        temporary tables are written to the binary log in the
        boundaries of a transaction if there is any.
      mysql-test/suite/rpl/r/rpl_stm_stop_middle_group.result:
        Updated the unsafe message.
      mysql-test/suite/rpl/r/rpl_temp_temporary.result:
        Added a test case.
      mysql-test/suite/rpl/t/rpl000013.test:
        Suppressed warning messages due to the following cases:
        
           1 - INSERT INTO t_myisam SELECT * FROM t_myisam_temp
        
           2 - INSERT INTO t_myisam_temp SELECT * FROM t_myisam
        
           3 - CREATE TEMPORARY TABLE t_myisam_temp SELECT * FROM t_myisam
      mysql-test/suite/rpl/t/rpl_misc_functions.test:
        Suppressed warning messages.
      mysql-test/suite/rpl/t/rpl_temp_table.test:
        Suppressed warning messages due to the following cases:
        
           1 - INSERT INTO t_myisam SELECT * FROM t_myisam_temp
        
           2 - INSERT INTO t_myisam_temp SELECT * FROM t_myisam
        
           3 - CREATE TEMPORARY TABLE t_myisam_temp SELECT * FROM t_myisam
      mysql-test/suite/rpl/t/rpl_temp_temporary.test:
        Added a test case.
      mysql-test/suite/rpl/t/rpl_temporary.test:
        Suppressed warning messages due to the following cases:
        
           1 - INSERT INTO t_myisam SELECT * FROM t_myisam_temp
        
           2 - INSERT INTO t_myisam_temp SELECT * FROM t_myisam
        
           3 - CREATE TEMPORARY TABLE t_myisam_temp SELECT * FROM t_myisam
      mysql-test/suite/rpl_ndb/r/rpl_ndb_row_implicit_commit_binlog.result:
        Updated the test case due to the new rules: changes to
        temporary tables are written to the binary log in the
        boundaries of a transaction if there is any.
      mysql-test/suite/rpl_ndb/r/rpl_truncate_7ndb.result:
        Updated the test case to remove references to positions
        in the binary log.
      mysql-test/suite/rpl_ndb/t/rpl_truncate_7ndb.test:
        Updated the test case to remove references to positions
        in the binary log.
      mysql-test/t/create_select_tmp.test:
        Suppressed warning messages due to the following cases:
        
           1 - INSERT INTO t_myisam SELECT * FROM t_myisam_temp
        
           2 - INSERT INTO t_myisam_temp SELECT * FROM t_myisam
        
           3 - CREATE TEMPORARY TABLE t_myisam_temp SELECT * FROM t_myisam
      mysql-test/t/ctype_cp932_binlog_stm.test:
        Suppressed warning messages due to the following cases:
        
           1 - INSERT INTO t_myisam SELECT * FROM t_myisam_temp
        
           2 - INSERT INTO t_myisam_temp SELECT * FROM t_myisam
        
           3 - CREATE TEMPORARY TABLE t_myisam_temp SELECT * FROM t_myisam
      mysql-test/t/mysqlbinlog.test:
        Suppressed warning messages due to the following cases:
        
           1 - INSERT INTO t_myisam SELECT * FROM t_myisam_temp
        
           2 - INSERT INTO t_myisam_temp SELECT * FROM t_myisam
        
           3 - CREATE TEMPORARY TABLE t_myisam_temp SELECT * FROM t_myisam
      sql/log.cc:
        Improved the code by creating several functions to hide decision
        on type of engine changed, commit/abort, etc:  
        
        . stmt_has_updated_non_trans_table
        
        . trans_has_updated_non_trans_table
        
        . ending_trans
        
        Updated the binlog_rollback function and the use of the 
        OPTION_KEEP_LOG which indincates when a temporary table was
        either created or dropped and as such the command must be 
        logged if not in MIXED mode and even while rolling back the
        transaction.
      sql/log.h:
        Improved the code by creating several functions to hide decision
        on type of engine changed, commit/abort, etc.
      sql/log_event.cc:
        Removed the setting of the OPTION_KEEP_LOG as it is related to CREATE
        TEMPORARY and DROP TEMPORARY and not to the type of engine (i.e.
        transactional or non-transactional).
      sql/log_event_old.cc:
        Removed the setting of the OPTION_KEEP_LOG as it is related to CREATE
        TEMPORARY and DROP TEMPORARY and not to the type of engine (i.e.
        transactional or non-transactional).
      sql/share/errmsg-utf8.txt:
        Updated the unsafe message.
      sql/sql_class.cc:
        Classifies the following statements as unsafe:
           1 - INSERT INTO t_myisam SELECT * FROM t_myisam_temp
        
           2 - INSERT INTO t_myisam_temp SELECT * FROM t_myisam
        
        On the other hand, the following statements are classified as safe:
        
           1 - INSERT INTO t_innodb SELECT * FROM t_myisam_temp
        
           2 - INSERT INTO t_myisam_temp SELECT * FROM t_innodb
      sql/sql_class.h:
        It allows to switch from STATEMENT to MIXED/ROW when there are temporary
        tables but the contrary is not possible.
      sql/sql_table.cc:
        Fixed the case that a DROP/DROP TEMPORARY that affects a temporary table in MIXED
        mode is written as a DROP TEMPORARY TABLE IF EXISTS because the table may not exist in the slave and due to the IF EXISTS token an error will never happen
        while processing the statement in the slave.
        
        Removed a function that was not being used.
      4bf7d53b
  33. 14 Apr, 2010 1 commit
    • Sergey Vojtovich's avatar
      BUG#39053 - UNISTALL PLUGIN does not allow the storage engine · fe38084f
      Sergey Vojtovich authored
                  to cleanup open connections
      
      It was possible to UNINSTALL storage engine plugin when binding
      between THD object and storage engine is still active (e.g. in
      the middle of transaction).
      
      To avoid unclean deactivation (uninstall) of storage engine plugin
      in the middle of transaction, additional storage engine plugin
      lock is acquired by thd_set_ha_data().
      
      If ha_data is not null and storage engine plugin was not locked
      by thd_set_ha_data() in this connection before, storage engine
      plugin gets locked.
      
      If ha_data is null and storage engine plugin was locked by
      thd_set_ha_data() in this connection before, storage engine
      plugin lock gets released.
      
      If handlerton::close_connection() didn't reset ha_data, server does
      it immediately after calling handlerton::close_connection().
      
      Note that this is just a framework fix, storage engines must switch
      to thd_set_ha_data() from thd_ha_data() if they want to see fit.
      
      include/mysql/plugin.h:
        As thd_{get|set}_ha_data() have some extra logic now, they
        must be implemented on server side.
      include/mysql/plugin.h.pp:
        As thd_{get|set}_ha_data() have some extra logic now, they
        must be implemented on server side.
      sql/handler.cc:
        Make sure ha_data is reset and ha_data lock is released.
      sql/handler.h:
        hton is not supposed to be updated by ha_lock_engine(),
        make it const.
      sql/sql_class.cc:
        As thd_{get|set}_ha_data() have some extra logic now, they
        must be implemented on server side.
      sql/sql_class.h:
        Added ha_data lock.
      fe38084f
  34. 07 Apr, 2010 1 commit
    • Mats Kindahl's avatar
      WL#5030: Splitting mysql_priv.h · a53fa615
      Mats Kindahl authored
      Adding my_global.h first in all files using
      NO_EMBEDDED_ACCESS_CHECKS.
      
      Correcting a merge problem resulting from a changed definition
      of check_some_access compared to the original patches.
      a53fa615
  35. 31 Mar, 2010 1 commit
    • Mats Kindahl's avatar
      WL#5030: Split and remove mysql_priv.h · 3538238a
      Mats Kindahl authored
      This patch:
      
      - Moves all definitions from the mysql_priv.h file into
        header files for the component where the variable is
        defined
      - Creates header files if the component lacks one
      - Eliminates all include directives from mysql_priv.h
      - Eliminates all circular include cycles
      - Rename time.cc to sql_time.cc
      - Rename mysql_priv.h to sql_priv.h
      3538238a
  36. 29 Mar, 2010 1 commit
    • Tatiana A. Nurnberg's avatar
      Bug#48525: trigger changes "Column 'id' cannot be null" behaviour · 0d81b358
      Tatiana A. Nurnberg authored
      CHECK_FIELD_IGNORE was treated as CHECK_FIELD_ERROR_FOR_NULL;
      UPDATE...SET...NULL on NOT NULL fields behaved differently after
      a trigger.
      
      Now distinguishes between IGNORE and ERROR_FOR_NULL and save/restores
      check-field options.
      
      
      mysql-test/r/trigger.result:
        Show that UPDATE...SET...NULL on NOT NULL columns doesn't behave differently
        when run after a trigger.
      mysql-test/t/trigger.test:
        Show that UPDATE...SET...NULL on NOT NULL columns doesn't behave differently
        when run after a trigger.
      sql/field_conv.cc:
        CHECK_FIELD_IGNORE was treated as CHECK_FIELD_ERROR_FOR_NULL.
        Distinguish between the two.
      sql/sp_head.cc:
        Raise error as needed.
      sql/sql_class.cc:
        Save and restore check-fields options.
      sql/sql_class.h:
        Make room so we can save check-fields options.
      sql/sql_insert.cc:
        Raise error as needed.
      0d81b358
  37. 17 Mar, 2010 1 commit
    • Luis Soares's avatar
      BUG#51426: overflow for auto_increment column causes slave to stop · 3eb5791b
      Luis Soares authored
      In BUG#49562 we fixed the case where numeric user var events
      would not serialize the flag stating whether the value was signed
      or unsigned (unsigned_flag). This fixed the case that the slave
      would get an overflow while treating the unsigned values as
      signed.
            
      In this bug, we find that the unsigned_flag can sometimes change
      between the moment that the user value is recorded for binlogging
      purposes and the actual binlogging time. Since we take the
      unsigned_flag from the runtime variable data, at binlogging time,
      and the variable value is comes from the copy taken earlier in
      the execution, there may be inconsistency in the
      User_var_log_event between the variable value and its
      unsigned_flag.
            
      We fix this by also copying the unsigned_flag of the
      user_var_entry when its value is copied, for binlogging
      purposes. Later, at binlogging time, we use the copied
      unsigned_flag and not the one in the runtime user_var_entry
      instance.
      3eb5791b
  38. 13 Mar, 2010 1 commit