1. 28 Apr, 2010 1 commit
    • Konstantin Osipov's avatar
      Committing on behalf or Dmitry Lenev: · 1ab519d9
      Konstantin Osipov authored
      Fix for bug #46947 "Embedded SELECT without FOR UPDATE is
      causing a lock", with after-review fixes.
      
      SELECT statements with subqueries referencing InnoDB tables
      were acquiring shared locks on rows in these tables when they
      were executed in REPEATABLE-READ mode and with statement or
      mixed mode binary logging turned on.
      
      This was a regression which were introduced when fixing
      bug 39843.
      
      The problem was that for tables belonging to subqueries
      parser set TL_READ_DEFAULT as a lock type. In cases when
      statement/mixed binary logging at open_tables() time this
      type of lock was converted to TL_READ_NO_INSERT lock at
      open_tables() time and caused InnoDB engine to acquire
      shared locks on reads from these tables. Although in some
      cases such behavior was correct (e.g. for subqueries in
      DELETE) in case of SELECT it has caused unnecessary locking.
      
      This patch tries to solve this problem by rethinking our
      approach to how we handle locking for SELECT and subqueries.
      Now we always set TL_READ_DEFAULT lock type for all cases
      when we read data. When at open_tables() time this lock
      is interpreted as TL_READ_NO_INSERT or TL_READ depending
      on whether this statement as a whole or call to function
      which uses particular table should be written to the
      binary log or not (if yes then statement should be properly
      serialized with concurrent statements and stronger lock
      should be acquired).
      
      Test coverage is added for both InnoDB and MyISAM.
      
      This patch introduces an "incompatible" change in locking
      scheme for subqueries used in SELECT ... FOR UPDATE and
      SELECT .. IN SHARE MODE.
      In 4.1 the server would use a snapshot InnoDB read for 
      subqueries in SELECT FOR UPDATE and SELECT .. IN SHARE MODE
      statements, regardless of whether the binary log is on or off.
      If the user required a different type of read (i.e. locking read),
      he/she could request so explicitly by providing FOR UPDATE/IN SHARE MODE
      clause for each individual subquery.
      On of the patches for 5.0 broke this behaviour (which was not documented
      or tested), and started to use locking reads fora all subqueries in SELECT ... 
      FOR UPDATE/IN SHARE MODE. This patch restored 4.1 behaviour.
      
      mysql-test/include/check_concurrent_insert.inc:
        Added auxiliary script which allows to check if statement
        reading table allows concurrent inserts in it.
      mysql-test/include/check_no_concurrent_insert.inc:
        Added auxiliary script which allows to check that statement
        reading table doesn't allow concurrent inserts in it.
      mysql-test/include/check_no_row_lock.inc:
        Added auxiliary script which allows to check if statement
        reading table doesn't take locks on its rows.
      mysql-test/include/check_shared_row_lock.inc:
        Added auxiliary script which allows to check if statement
        reading table takes shared locks on some of its rows.
      mysql-test/r/bug39022.result:
        After bug #46947 'Embedded SELECT without FOR UPDATE is
        causing a lock' was fixed test case for bug 39022 has to
        be adjusted in order to trigger execution path on which
        original problem was encountered.
      mysql-test/r/innodb_mysql_lock2.result:
        Added coverage for handling of locking in various cases when
        we read data from InnoDB tables (includes test case for
        bug #46947 'Embedded SELECT without FOR UPDATE is causing a
        lock').
      mysql-test/r/lock_sync.result:
        Added coverage for handling of locking in various cases when
        we read data from MyISAM tables.
      mysql-test/t/bug39022.test:
        After bug #46947 'Embedded SELECT without FOR UPDATE is
        causing a lock' was fixed test case for bug 39022 has to
        be adjusted in order to trigger execution path on which
        original problem was encountered.
      mysql-test/t/innodb_mysql_lock2.test:
        Added coverage for handling of locking in various cases when
        we read data from InnoDB tables (includes test case for
        bug #46947 'Embedded SELECT without FOR UPDATE is causing a
        lock').
      mysql-test/t/lock_sync.test:
        Added coverage for handling of locking in various cases when
        we read data from MyISAM tables.
      sql/log_event.cc:
        Since LEX::lock_option member was removed we no longer can
        rely on its value in Load_log_event::print_query() to
        determine that log event correponds to LOAD DATA CONCURRENT
        statement (this was not correct in all situations anyway).
        A new Load_log_event's member was introduced as a replacement.
        It is initialized at event object construction time and
        explicitly indicates whether LOAD DATA was concurrent.
      sql/log_event.h:
        Since LEX::lock_option member was removed we no longer can
        rely on its value in Load_log_event::print_query() to
        determine that log event correponds to LOAD DATA CONCURRENT
        statement (this was not correct in all situations anyway).
        A new Load_log_event's member was introduced as a replacement.
        It is initialized at event object construction time and
        explicitly indicates whether LOAD DATA was concurrent.
      sql/sp_head.cc:
        sp_head::reset_lex():
          Before parsing substatement reset part of parser state
          which needs this (e.g. set Yacc_state::m_lock_type to
          default value).
      sql/sql_acl.cc:
        Since LEX::reset_n_backup_query_tables_list() now also
        resets LEX::sql_command member (as it became part of
        Query_tables_list class) we have to restore it in cases
        when while working with proxy Query_table_list we assume
        that LEX::sql_command still corresponds to original SQL
        command being executed (for example, when we are logging
        statement to the binary log while having Query_tables_list
        reset and backed up).
      sql/sql_base.cc:
        Changed read_lock_type_for_table() to return a weak TL_READ
        type of lock in cases when we are executing statement which
        won't update tables directly and table doesn't belong to
        statement's prelocking list and thus can't be used by a
        stored function. It is OK to do so since in this case table
        won't be used by statement or function call which will be
        written to the binary log, so serializability requirements
        for it can be relaxed.
        One of results from this change is that SELECTs on InnoDB
        tables no longer takes shared row locks for tables which
        are used in subqueries (i.e. bug #46947 is fixed).
        Another result is that for similar SELECTs on MyISAM tables
        concurrent inserts are allowed.
        In order to implement this change signature of
        read_lock_type_for_table() function was changed to take
        pointers to Query_tables_list and TABLE_LIST objects.
      sql/sql_base.h:
        - Function read_lock_type_for_table() now takes pointers
          to Query_tables_list and TABLE_LIST elements as its
          arguments since to correctly determine lock type it needs
          to know what statement is being performed and whether table
          element for which lock type to be determined belongs to
          prelocking list.
      sql/sql_lex.cc:
        - Removed LEX::lock_option and st_select_lex::lock_option
          members. Places in parser that were using them now use
          Yacc_state::m_lock_type instead.
        - To emphasize that LEX::sql_command member is used during
          process of opening and locking of tables it was moved to
          Query_tables_list class. It is now reset by
          Query_tables_list::reset_query_tables_list() method.
      sql/sql_lex.h:
        - Removed st_select_lex::lock_option member as there is no
          real need for per-SELECT lock type (HIGH_PRIORITY option
          should apply to the whole statement. FOR UPDATE/LOCK IN
          SHARE MODE clauses can be handled without this member).
          The main effect which was achieved by introduction of this
          member, i.e. using TL_READ_DEFAULT lock type for
          subqueries, is now achieved by setting LEX::lock_option
          (or rather its replacement - Yacc_state::m_lock_type) to
          TL_READ_DEFAULT in almost all cases.
        - To emphasize that LEX::sql_command member is used during
          process of opening and locking of tables it was moved to
          Query_tables_list class.
        - Replaced LEX::lock_option with Yacc_state::m_lock_type
          in order to emphasize that this value is relevant only
          during parsing. Unlike for LEX::lock_option the default
          value for Yacc_state::m_lock_type is TL_READ_DEFAULT.
          Note that for cases when it is OK to take a "weak" read
          lock (e.g. simple SELECT) this lock type will be converted
          to TL_READ at open_tables() time. So this change won't
          cause negative change in behavior for such statements.
          OTOH this change ensures that, for example, for SELECTs
          which are used in stored functions TL_READ_NO_INSERT lock
          is taken when necessary and as result calls to such stored
          functions can be written to the binary log with correct
          serialization.
      sql/sql_load.cc:
        Load_log_event constructor now requires a parameter that
        indicates whether LOAD DATA is concurrent.
      sql/sql_parse.cc:
        LEX::lock_option was replaced with Yacc_state::m_lock_type.
        And instead of resetting the latter implicitly in
        mysql_init_multi_delete() we do it explicitly in the
        places in parser which call this function.
      sql/sql_priv.h:
        - To be able more easily distinguish high-priority SELECTs
          in st_select_lex::print() method added flag for
          HIGH_PRIORITY option.
      sql/sql_select.cc:
        Changed code not to rely on LEX::lock_option to determine
        that it is high-priority SELECT. It was replaced with
        Yacc_state::m_lock_type which is accessible only at
        parse time. So instead of LEX::lock_option we now rely
        on a newly introduced flag for st_select_lex::options -
        SELECT_HIGH_PRIORITY.
      sql/sql_show.cc:
        Since LEX::reset_n_backup_query_tables_list() now also
        resets LEX::sql_command member (as it became part of
        Query_tables_list class) we have to restore it in cases
        when while working with proxy Query_table_list we assume
        that LEX::sql_command still corresponds to original SQL
        command being executed.
      sql/sql_table.cc:
        Since LEX::reset_query_tables_list() now also resets
        LEX::sql_command member (as it became part of
        Query_tables_list class) we have to restore value of this
        member when this method is called by mysql_admin_table(),
        to make this code safe for re-execution.
      sql/sql_trigger.cc:
        Since LEX::reset_n_backup_query_tables_list() now also
        resets LEX::sql_command member (as it became part of
        Query_tables_list class) we have to restore it in cases
        when while working with proxy Query_table_list we assume
        that LEX::sql_command still corresponds to original SQL
        command being executed (for example, when we are logging
        statement to the binary log while having Query_tables_list
        reset and backed up).
      sql/sql_update.cc:
        Function read_lock_type_for_table() now takes pointers
        to Query_tables_list and TABLE_LIST elements as its
        arguments since to correctly determine lock type it needs
        to know what statement is being performed and whether table
        element for which lock type to be determined belongs to
        prelocking list.
      sql/sql_yacc.yy:
        - Removed st_select_lex::lock_option member as there is no
          real need for per-SELECT lock type (HIGH_PRIORITY option
          should apply to the whole statement. FOR UPDATE/LOCK IN
          SHARE MODE clauses can be handled without this member).
          The main effect which was achieved by introduction of this
          member, i.e. using TL_READ_DEFAULT lock type for
          subqueries, is now achieved by setting LEX::lock_option
          (or rather its replacement - Yacc_state::m_lock_type) to
          TL_READ_DEFAULT in almost all cases.
        - Replaced LEX::lock_option with Yacc_state::m_lock_type
          in order to emphasize that this value is relevant only
          during parsing. Unlike for LEX::lock_option the default
          value for Yacc_state::m_lock_type is TL_READ_DEFAULT.
          Note that for cases when it is OK to take a "weak" read
          lock (e.g. simple SELECT) this lock type will be converted
          to TL_READ at open_tables() time. So this change won't
          cause negative change in behavior for such statements.
          OTOH this change ensures that, for example, for SELECTs
          which are used in stored functions TL_READ_NO_INSERT lock
          is taken when necessary and as result calls to such stored
          functions can be written to the binary log with correct
          serialization.
        - To be able more easily distinguish high-priority SELECTs
          in st_select_lex::print() method we now use new flag
          in st_select_lex::options bit-field.
      1ab519d9
  2. 22 Apr, 2010 1 commit
  3. 21 Apr, 2010 6 commits
    • Alexander Nozdrin's avatar
      90d0c4ff
    • Alexander Nozdrin's avatar
      Patch for Bug#53022: Compilation of "embedded" is broken. · df9eb6ef
      Alexander Nozdrin authored
      The bug was a side effect of WL#5030 (fix header files) and
      WL#5161 (CMake).
      
      The problem was that CMake-generated config.h (and my_config.h
      as a copy of it) had a header guard. GNU autotools-generated
      [my_]config.h did not. During WL#5030 the order of header files
      was changed, so the following started to happen (using GNU autotools,
      in embedded server):
        - my_config.h included, defining HAVE_OPENSSL
        - my_global.h included, un-defining  HAVE_OPENSSL
        - zlib.h included, including config.h,
          defining HAVE_OPENSSL again.
      
      The fix is to change the order of header file, moving zlib.h
      to the top of the header list. More proper fix would be to wrap
      unguarded auto-generated [my_]config.h by guarded non-generated
      header file.
      df9eb6ef
    • Alfranio Correia's avatar
      BUG#51894 Replication failure with SBR on DROP TEMPORARY TABLE inside a · dbf7c215
      Alfranio Correia authored
                transaction
      BUG#52616 Temp table prevents switch binlog format from STATEMENT to ROW
      
      Post-merge fixes.
      
      
      mysql-test/include/commit.inc:
        Changed the test case as drop temporary is now written to the binary log in row mode.
      mysql-test/r/commit_1innodb.result:
        Changed the test case as drop temporary is now written to the binary log in row mode.
      mysql-test/r/ctype_cp932_binlog_stm.result:
        Disabled warning messages because the test runs in both statement and mixed modes.
      mysql-test/t/ctype_cp932_binlog_stm.test:
        Disabled warning messages because the test runs in both statement and mixed modes.
      mysql-test/t/mysqlbinlog.test:
        Removed the --short-form due to BUG#18337 what was suppressing the
        select * from t5 /* must be (1),(1) */ in row format.
      dbf7c215
    • Jon Olav Hauglid's avatar
      merge from mysql-trunk-runtime · c5317dfb
      Jon Olav Hauglid authored
      c5317dfb
    • Jon Olav Hauglid's avatar
      merge from mysql-trunk-bugfixing · 53cbbcc8
      Jon Olav Hauglid authored
      53cbbcc8
    • Mats Kindahl's avatar
      Merging with mysql-trunk-bugfixing · b5c45fb6
      Mats Kindahl authored
      b5c45fb6
  4. 20 Apr, 2010 3 commits
    • Mats Kindahl's avatar
      WL#5030: Splitting mysql_priv.h · c0817bac
      Mats Kindahl authored
      Removing traces of mysql_priv.h from comments and other
      non-source files that were missed before.
      c0817bac
    • Alfranio Correia's avatar
      BUG#51894 Replication failure with SBR on DROP TEMPORARY TABLE inside a · 20f5c421
      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.
      20f5c421
    • Jon Olav Hauglid's avatar
      merge from mysql-trunk-bugfixing · ac787366
      Jon Olav Hauglid authored
      ac787366
  5. 19 Apr, 2010 5 commits
  6. 18 Apr, 2010 1 commit
  7. 16 Apr, 2010 1 commit
  8. 15 Apr, 2010 9 commits
    • Luis Soares's avatar
      automerge: merged bundle from bug report into latest · 091745c8
      Luis Soares authored
      mysql-trunk-bugfixing (bug 52341).
      091745c8
    • Luis Soares's avatar
      Automerge: merged bug bundle from bug report into latest · 769787ca
      Luis Soares authored
      mysql-trunk-bugfixing.
      769787ca
    • Jon Olav Hauglid's avatar
      Bug #47459 Assertion in Diagnostics_area::set_eof_status on OPTIMIZE TABLE · cf8df9ca
      Jon Olav Hauglid authored
      This assertion could be triggered during execution of OPTIMIZE TABLE for
      InnoDB tables. As part of optimize for InnoDB tables, the table is recreated
      and then opened again. If the reopen failed for any reason, the assertion
      would be triggered. This could for example be caused by a concurrent DROP
      TABLE executed by a different connection. The reason for the assertion was
      that any failures during reopening were ignored.
      
      This patch fixes the problem by making sure that the result of reopening the
      table is checked and that any error messages are sent to the client.
      
      Test case added to innodb_mysql_sync.test.
      cf8df9ca
    • Jon Olav Hauglid's avatar
      Bug #51391 Deadlock involving events during rqg_info_schema test · 4347e302
      Jon Olav Hauglid authored
      This was a deadlock between CREATE/ALTER/DROP EVENT and a query
      accessing both the mysql.event table and I_S.GLOBAL_VARIABLES.
      
      The root of the problem was that the LOCK_event_metadata mutex was
      used to both protect the "event_scheduler" global system variable
      and the internal event data structures used by CREATE/ALTER/DROP EVENT.
      
      The deadlock would occur if CREATE/ALTER/DROP EVENT held
      LOCK_event_metadata while trying to open the mysql.event table,
      at the same time as the query had mysql.event open, trying to
      lock LOCK_event_metadata to access "event_scheduler".
      
      This bug was fixed in the scope of Bug#51160 by using only
      LOCK_global_system_variables to protect "event_scheduler".
      This makes it so that the query above won't lock LOCK_event_metadata,
      thereby preventing this deadlock from occuring.
      
      This patch contains no code changes.
      Test case added to lock_sync.test.
      4347e302
    • Sergey Vojtovich's avatar
    • Sergey Vojtovich's avatar
      BUG#46587 - archive storage engine headers don't include · 535093e4
      Sergey Vojtovich authored
                  my_global.h first
      
      We may end up with a compilation failure on certain platforms
      because zlib.h is included before my_global.h.
      
      Fixed by moving zlib.h inclusion down after my_global.h.
      
      storage/archive/azlib.h:
        zlib.h must be included after my_global.h.
      535093e4
    • Sergey Vojtovich's avatar
      BUG#47059 - In audit plugin I cannot see the event subclasses, · 8e793916
      Sergey Vojtovich authored
                  e.g.MYSQL_AUDIT_GENERAL_ERROR
      
      General audit API (MYSQL_AUDIT_GENERAL_CLASS) didn't expose event
      subclass to plugins.
      
      This patch exposes event subclass to plugins via
      struct mysql_event_general::event_subclass.
      
      This change is not compatible with existing general audit plugins.
      Audit interface major version has been incremented.
      
      include/mysql/plugin_audit.h:
        Expose event subclass to audit general plugins.
      plugin/audit_null/audit_null.c:
        Added distinct counters for general event sub-classes.
        
        Removed printf() from deinit(). One can easily see number of
        calls via status variables.
        
        To make code nicer, modified class mask to use macro instead
        of hardcoded number.
        
        Incremented audit plugin minor version.
      sql/sql_audit.cc:
        Expose event subclass to audit general plugins.
      8e793916
    • Alexander Nozdrin's avatar
      471d515f
    • Jon Olav Hauglid's avatar
      Bug #51327 MyISAM table is automatically repaired on ALTER · 48ac4ff5
      Jon Olav Hauglid authored
                 even if myisam-recover is OFF
      
      The problem was that a corrupted MyISAM table was auto repaired
      even if the myisam_recover_options server variable (or the 
      myisam_recover option) was set to OFF.
      
      The reason was that the auto_repair() function, which is supposed
      to say if auto repair is to be used, did not use the server variable
      setting correctly. This bug was a regression introduced by WL#4738.
      
      This patch fixes the problem by making sure auto_repair() returns
      FALSE if myisam_recover_options is set to OFF.
      
      Test case added to myisam.test.
      48ac4ff5
  9. 14 Apr, 2010 3 commits
    • Alexander Nozdrin's avatar
      A patch for Bug#52444 (mysql_upgrade fails b/w 5.1 -> 5.5 (Celosia)). · 9bde9c08
      Alexander Nozdrin authored
      The problem was that the code that works with stored routines was present
      in mysql_system_tables.sql. This is wrong because until upgrade is finished,
      stored routines may be (and were) not available.
      
      The fix is to move that code to the end of mysql_system_tables_fix.sql.
      9bde9c08
    • Jon Olav Hauglid's avatar
      Bug #52593 SHOW CREATE TABLE is blocked if table is locked · d3d459a7
      Jon Olav Hauglid authored
                 for write by another connection
      
      The problem was that if a table was locked in one connection by
      LOCK TABLES ... WRITE, REPAIR TABLE or OPTIMIZE TABLE, SHOW CREATE
      TABLE from another connection would be blocked. As SHOW CREATE TABLE
      only reads metadata about the table, such blocking is not needed.
      
      The problem was that when SHOW CREATE TABLE tried to get a metadata
      lock on the table in order to open it, it used the wrong type of
      metadata lock request. It used MDL_SHARED_READ which is used when
      the intent is to read both table metadata and table data. Instead
      it should have used MDL_SHARED_HIGH_PRIO which signifies an intent
      to only read metadata.
      
      This patch fixes the problem by making sure SHOW CREATE TABLE uses
      the MDL_SHARED_HIGH_PRIO metadata lock request type when trying to
      open the table. The patch also fixes a similar problem with the
      mysql_list_fields API call.
      
      Test case added to show_check.test.
      d3d459a7
    • Jon Olav Hauglid's avatar
      Bug #52367 Deadlock involving SET GLOBAL EVENT_SCHEDULER = OFF · 3ff33e5d
      Jon Olav Hauglid authored
                 during rqg_mdl_deadlock test
      
      The problem was that if two connection threads simultaneously tries
      to execute "SET GLOBAL EVENT_SCHEDULER = OFF", one of them could
      hang waiting for the scheduler to stop.
      
      The first connection thread would kill the event scheduler thread
      and then start waiting for it to exit. The second connection thread
      would then find the event scheduler thread in the process of exiting
      and also wait for it to exit. However, since the event scheduler 
      thread used signal to wake only one waiting thread, the other connection
      thread would be left waiting.
      
      This bug was a regression introduced by the fix for Bug#51160.
      Before #51160 it was not possible for two connection threads to 
      try to stop the event scheduler thread simultaneously.
      
      This patch fixes the problem my making sure the event scheduler
      thread uses broadcast to notify all waiters that it is exiting.
      
      No test case added as this would require adding debug sync points
      to parts of the code where sync points are currently not used.
      The patch has been tested with the non-deterministic test case
      from the bug description as well as using the RQG.
      3ff33e5d
  10. 13 Apr, 2010 8 commits
    • Konstantin Osipov's avatar
      A fix for Bug#11918 "SP does not accept variables in LIMIT clause" · 4288e329
      Konstantin Osipov authored
      Allow stored procedure variables in LIMIT clause.
      Only allow variables of INTEGER types. 
      Handle negative values by means of an implicit cast to UNSIGNED 
      (similarly to prepared statement placeholders).
      Add tests.
      Make sure replication works by not doing NAME_CONST substitution
      for variables in LIMIT clause.
      Add replication tests.
      
      mysql-test/r/sp.result:
        Update results (Bug#11918).
      mysql-test/suite/rpl/r/rpl_sp.result:
        Update results (Bug#11918).
      mysql-test/suite/rpl/t/rpl_sp.test:
        Add a test case for Bug#11918.
      mysql-test/t/sp.test:
        Add a test case for Bug#11918.
      sql/item.cc:
        Mark sp variables in LIMIT clause (a hack for replication).
      sql/item.h:
        Mark sp variables in LIMIT clause (a hack for replication).
      sql/share/errmsg-utf8.txt:
        Add a new error message (a type mismatch for LIMIT
        clause parameter).
      sql/sp_head.cc:
        Binlog rewrite sp variables in LIMIT clause without NAME_CONST
        substitution.
      sql/sql_string.cc:
        Implement append_ulonglong method.
      sql/sql_string.h:
        Declare append_ulonglong().
      sql/sql_yacc.yy:
        Support stored procedure variables in LIMIT.
      4288e329
    • Vladislav Vaintroub's avatar
      merge · 71799f6f
      Vladislav Vaintroub authored
      71799f6f
    • Alexander Nozdrin's avatar
      Post-fix for Bug#13174. · a3295460
      Alexander Nozdrin authored
      a3295460
    • Vladislav Vaintroub's avatar
      merge · 7a3d0f0e
      Vladislav Vaintroub authored
      7a3d0f0e
    • Konstantin Osipov's avatar
      Backport of: · 3227ba70
      Konstantin Osipov authored
      ChangeSet@1.2703, 2007-12-07 09:35:28-05:00, cmiller@zippy.cornsilk.net +40 -0
      Bug#13174: SHA2 function
      Patch contributed from Bill Karwin, paper unnumbered CLA in Seattle
      
      Implement SHA2 functions.
      
      Chad added code to make it work with YaSSL.  Also, he removed the 
      (probable) bug of embedded server never using SSL-dependent 
      functions.  (libmysqld/Makefile.am didn't read ANY autoconf defs.)
      
      Function specification:
        SHA2( string cleartext, integer hash_length ) 
          -> string hash, or NULL
      where hash_length is one of 224, 256, 384, or 512.  If either is 
      NULL or a length is unsupported, then the result is NULL.  The 
      resulting string is always the length of the hash_length parameter
      or is NULL.
      
      Include the canonical hash examples from the NIST in the test
      results.
      ---
      Polish and address concerns of reviewers.
      
      
      .bzrignore:
        Added libmysqld/sha2.cc to the ignore list.
      client/mysql.cc:
        Add condition to remove code for embedded server.
      client/mysqltest.cc:
        Add condition to remove code for embedded server.
      include/Makefile.am:
        New header file to header list.
      include/mysql_embed.h:
        Embedded servers can use SSL-library functions too!
      include/sha2.h:
        Compatibility layer to make YaSSL behave like OpenSSL.
      include/sslopt-case.h:
        Remove SSL-communication parameters from command lines.
      include/sslopt-longopts.h:
        Remove SSL-communication parameters from command lines.
      include/sslopt-vars.h:
        Don't declare variables that are only used in SSL communication, if
        we are compiling the embedded server.
      include/violite.h:
        Don't even compile the SSL-communication function if we're in the
        embedded server.
        ---
        Remove CPP condition indentation.
      libmysqld/CMakeLists.txt:
        Add new file to source list.
      libmysqld/Makefile.am:
        Include standard DEFS in embedded compilation.  It's an undiscovered
        but that it's not there.
        
        Add new file to source list.
      libmysqld/examples/Makefile.am:
        Include autoconf DEFS.
      libmysqld/lib_sql.cc:
        Initialize SSL-related variables in embedded server.
      mysql-test/include/have_ssl_crypto_functs.inc:
        Distinguish between communication and crypto.
        Use the tristate value of "have_ssl" variable to know whether to
        test or not for SSL-provided crypto functions.
      mysql-test/r/func_digest.result:
        
        Test against the sample test vectors in the NIST Secure
        Hash Standard (http://csrc.nist.gov/cryptval/shs.htm)
      mysql-test/r/func_encrypt_nossl.result:
        Update results to the new error message text.
      mysql-test/r/have_ssl_is_yes_or_disabled_only.require:
        Distinguish between communication and crypto.
        
        Use the tristate value of "have_ssl" variable to know whether to
        test or not for SSL-provided crypto functions.
      mysql-test/suite/rpl/t/rpl_ssl.test:
        Distinguish between communication and crypto.
      mysql-test/suite/rpl/t/rpl_ssl1.test:
        Distinguish between communication and crypto.
      mysql-test/t/func_des_encrypt.test:
        Distinguish between communication and crypto.
      mysql-test/t/func_digest.test:
        Test against the sample test vectors in the NIST Secure
        Hash Standard (http://csrc.nist.gov/cryptval/shs.htm)
        
        Also, test that various parameters (legal and illegal)
        do what we expect.
        ---
        Distinguish between communication and crypto.
      mysql-test/t/func_encrypt.test:
        Distinguish between communication and crypto.
      mysql-test/t/openssl_1.test:
        Don't test SSL communication if we're in the embedded server.
        ---
        Distinguish between communication and crypto.
      mysql-test/t/ssl-big.test:
        Don't test SSL communication if we're in the embedded server.
        ---
        Distinguish between communication and crypto.
      mysql-test/t/ssl.test:
        Don't test SSL communication if we're in the embedded server.
        ---
        Distinguish between communication and crypto.
      mysql-test/t/ssl_8k_key.test:
        Don't test SSL communication if we're in the embedded server.
        ---
        Distinguish between communication and crypto.
      mysql-test/t/ssl_compress.test:
        Don't test SSL communication if we're in the embedded server.
        ---
        Distinguish between communication and crypto.
      mysql-test/t/ssl_connect.test:
        Don't test SSL communication if we're in the embedded server.
        ---
        Distinguish between communication and crypto.
      sql-common/client.c:
        SSL is useful for more functionality than just connecting.  Test
        for whether we are not embedded server also.
      sql/CMakeLists.txt:
        Add new source file to source list so that we have access to SHA2
        functions.
      sql/Makefile.am:
        Add new source file to source list so that we have access to SHA2
        functions.
      sql/item_create.cc:
        Bootstrap the SHA2 function into the server.
      sql/item_strfunc.cc:
        Add new SHA2 Item class methods.
        
        Clean up two minor problems.
        ---
        Remove extraneous debugging.
        ---
        We must check nullness of a parameter only /after/ computing its
        value.
      sql/item_strfunc.h:
        Declare new SHA2 Item class.
      sql/mysqld.cc:
        For embedded server, don't refer to SSL-communications variables
        or values.
        ---
        Remove CPP condition indentation.
      sql/sha2.cc:
        Compatibility layer to make YaSSL behave like OpenSSL.
        ---
        Add comment for generated functions.
      sql/sql_acl.cc:
        For embedded server, don't refer to SSL-communications variables
        or values.
      sql/sql_connect.cc:
        SSL is useful for more functionality than just connecting.  Test
        for whether we are not embedded server also.
      sql/sys_vars.cc:
        For embedded server, don't refer to SSL-communications variables
        or values.
      3227ba70
    • Vladislav Vaintroub's avatar
      merge · 9615eac6
      Vladislav Vaintroub authored
      9615eac6
    • Vladislav Vaintroub's avatar
      Fix perfschema unittests build on Windows · cd35dd73
      Vladislav Vaintroub authored
      pthread_t is not defined unless my_pthread.h is included.
      cd35dd73
    • unknown's avatar
      Bug#51980 mysqld service crashes with a simple COUNT(DISTINCT) query over a view · 6a5b47a4
      unknown authored
      Problem: Segmentation fault in add_group_and_distinct_keys() when accessing
      field of what is assumed to be an Item_field object.
      
      Cause: In case of views, the item added to list by is_indexed_agg_distinct() 
      was not of type Item_field, but Item_ref.
      
      Resolution:  Add the real Item_field object, the one referred to by 
      Item_ref object, to the list, instead.
      
      mysql-test/r/count_distinct.result:
        Results for test case for Bug#51980.
      mysql-test/t/count_distinct.test:
        Test case for Bug#51980.
        Table needs to contain at least two rows to avoid const table optimization.
      sql/sql_select.cc:
        Make sure it is the actual Item_field object that is pushed to the out_args
        list of is_indexed_agg_distinct(), and not Item_ref objects.
      6a5b47a4
  11. 12 Apr, 2010 2 commits