An error occurred fetching the project authors.
  1. 14 Dec, 2011 1 commit
    • Andrei Elkin's avatar
      Bug#13437900 - VALGRIND REPORTS A LEAK FOR REPL_IGNORE_SERVER_IDS · ed3e19ac
      Andrei Elkin authored
      There was memory leak when running some tests on PB2.
      The reason of the failure is an early return from change_master()
      that was supposed to deallocate a dyn-array.
      
      Actually the same bug58915 was fixed in trunk with relocating the dyn-array
      destruction into THD::cleanup_after_query() which can't be bypassed.
      The current patch backports magne.mahre@oracle.com-20110203101306-q8auashb3d7icxho
      and adds two optimizations: were done: the static buffer for the dyn-array to base on,
      and the array initialization is called precisely when it's necessary rather than
      per each CHANGE-MASTER as before.
      
      
      mysql-test/suite/rpl/t/rpl_empty_master_host.test:
        the test is binlog-format insensitive so it will be run with MIXED mode only.
      mysql-test/suite/rpl/t/rpl_server_id_ignore.test:
        the test is binlog-format insensitive so it will be run with MIXED mode only.
      sql/sql_class.cc:
        relocating the dyn-array
        destruction into THD::cleanup_after_query().
      sql/sql_lex.cc:
        LEX.mi zero initialization is done in LEX().
      sql/sql_lex.h:
        Optimization for repl_ignore_server_ids to base on a static buffer
        which size is chosen to fit to most common use cases.
      sql/sql_repl.cc:
        dyn-array destruction is relocated to THD::cleanup_after_query().
      sql/sql_yacc.yy:
        Refining logics of Lex->mi.repl_ignore_server_ids initialization.
        The array is initialized once a corresponding option in CHANGE MASTER token sequence
        is found.
      ed3e19ac
  2. 24 Aug, 2011 1 commit
    • Bjorn Munch's avatar
      Backporting fix from trunk (revid 3381), original comment: · 9906e9cf
      Bjorn Munch authored
        Blind attempt to fix BUG 12881278 - MAIN.MYISAM TEST FAILS ON LINUX
        
        The printed text is truncated on char 63:
        
          "MySQL thread id 1236, OS thread handle 0x7ff187b96700, query id"
        
        still I do not understand how this truncation could have caused the
        main.myisam failure but anyway - the buffer needs to be increased.
      9906e9cf
  3. 15 Aug, 2011 1 commit
    • Alexander Nozdrin's avatar
      Cherry-picking patch for 12777649 from mysql-5.5 · cfb4a7c2
      Alexander Nozdrin authored
      to mysql-5.5.16-release.
      
      Original revision:
      # revision-id: georgi.kodinov@oracle.com-20110812135004-3z3yjy7krf374clu
      # parent: georgi.kodinov@oracle.com-20110812112536-dmh9i67tm8pqvz1a
      # committer: Georgi Kodinov <Georgi.Kodinov@Oracle.com>
      # branch nick: B12777649-5.5
      # timestamp: Fri 2011-08-12 16:50:04 +0300
      # message:
      #   Bug #12777649: "OS THREAD ID" REMOVED 
      #   
      #   Pushed Calvin's patch.
      cfb4a7c2
  4. 12 Aug, 2011 1 commit
  5. 02 Aug, 2011 1 commit
    • Sergey Glukhov's avatar
      Bug#11766594 59736: SELECT DISTINCT.. INCORRECT RESULT WITH DETERMINISTIC FUNCTION IN WHERE C · 3468b55a
      Sergey Glukhov authored
      There is an optimization of DISTINCT in JOIN::optimize()
      which depends on THD::used_tables value. Each SELECT statement
      inside SP resets used_tables value(see mysql_select()) and it
      leads to wrong result. The fix is to replace THD::used_tables
      with LEX::used_tables.
      
      
      mysql-test/r/sp.result:
        test case
      mysql-test/t/sp.test:
        test case
      sql/sql_base.cc:
        THD::used_tables is replaced with LEX::used_tables
      sql/sql_class.cc:
        THD::used_tables is replaced with LEX::used_tables
      sql/sql_class.h:
        THD::used_tables is replaced with LEX::used_tables
      sql/sql_insert.cc:
        THD::used_tables is replaced with LEX::used_tables
      sql/sql_lex.cc:
        THD::used_tables is replaced with LEX::used_tables
      sql/sql_lex.h:
        THD::used_tables is replaced with LEX::used_tables
      sql/sql_prepare.cc:
        THD::used_tables is replaced with LEX::used_tables
      sql/sql_select.cc:
        THD::used_tables is replaced with LEX::used_tables
      3468b55a
  6. 20 Jul, 2011 1 commit
  7. 30 Jun, 2011 1 commit
  8. 16 Jun, 2011 1 commit
    • Dmitry Lenev's avatar
      Fix for bug #12641342 - "61401: UPDATE PERFORMANCE DEGRADES · 5b225518
      Dmitry Lenev authored
      GRADUALLY IF A TRIGGER EXISTS".
      
      This bug manifested itself in two ways:
      
      - Firstly execution of any data-changing statement which
        required prelocking (i.e. involved stored function or
        trigger) as part of transaction slowed down a bit all
        subsequent statements in this transaction. So performance
        in transaction which periodically involved such statements
        gradually degraded over time.
      - Secondly execution of any data-changing statement which
        required prelocking as part of transaction prevented
        concurrent FLUSH TABLES WITH READ LOCK from proceeding
        until the end of transaction instead of end of particular
        statement.
        
      The problem was caused by incorrect handling of metadata lock
      used in FTWRL implementation for statements requiring prelocked 
      mode. 
      Each statement which changes data acquires global IX lock
      with STATEMENT duration. This lock is supposed to block 
      concurrent FTWRL from proceeding until the statement ends.
      
      When entering prelocked mode, durations of all metadata locks
      acquired so far were changed to EXPLICIT, to prevent 
      substatements from releasing these locks. When prelocked mode
      was left, durations of metadata locks were changed to
      TRANSACTIONAL (with a few exceptions) so they can be properly
      released at the end of transaction. 
      Unfortunately, this meant that the global IX lock blocking
      FTWRL with STATEMENT duration was moved to TRANSACTIONAL
      duration after execution of statement requiring prelocking.
      
      Since each subsequent statement that required prelocking and
      tried to acquire global IX lock with STATEMENT duration got
      a new instance of MDL_ticket, which was later moved to
      TRANSACTIONAL duration, this led to unwarranted growth of
      number of tickets with TRANSACITONAL duration in this
      connection's MDL_context. As result searching for other
      tickets in it became slow and acquisition of other metadata
      locks by this transaction started to hog CPU.
      
      Moreover, this also meant that after execution of statement
      requiring prelocking concurrent FTWRL was blocked
      until the end of transaction instead of end of statement.
      
      This patch solves this problem by not moving locks to EXPLICIT
      duration when thread enters prelocked mode (unless it is a real 
      LOCK TABLES mode). This step turned out to be not really 
      necessary as substatements don't try to release metadata locks.
      Consequently, the global IX lock blocking FTWRL keeps its
      STATEMENT duration and is properly released at the end of
      statement and the above issue goes away.
      
      mysql-test/r/flush.result:
        Added test for bug #12641342 - "61401: UPDATE PERFORMANCE
        DEGRADES GRADUALLY IF A TRIGGER EXISTS".
      mysql-test/t/flush.test:
        Added test for bug #12641342 - "61401: UPDATE PERFORMANCE
        DEGRADES GRADUALLY IF A TRIGGER EXISTS".
      sql/mdl.h:
        Added comment describing various types of metadata lock
        duration.
      sql/sql_class.cc:
        Since we no longer change duration of metadata locks to EXPLICIT
        when entering prelocked mode (unless it is a real LOCK TABLES)
        there is no need to restore proper duration of the locks when
        leaving prelocked mode.
      sql/sql_class.h:
        Do not change duration of metadata locks to EXPLICIT when
        entering prelocking mode (unless it is a real LOCK TABLES).
        This allows to avoid problems with restoring correct duration
        when leaving this mode. It is possible to do this as
        substatements won't release metadata locks in any case.
      sql/sql_parse.cc:
        Added assert checking that we won't release metadata locks
        when in substatement.
      5b225518
  9. 18 May, 2011 2 commits
    • Mayank Prasad's avatar
      Bug#11764633 : 57491: THD->MAIN_DA.IS_OK() ASSERT IN EMBEDDED · d608ad2d
      Mayank Prasad authored
      Issue:
      While running embedded server, if client issues TEE command (\T foo/bar) and
      "foo/bar" directory doesn't exist, it is suppose to give error. But it was
      aborting.  This was happening because wrong error handler was being called.
      
      Solution:
      Modified calls to correct error handler. In embedded server case, there are 
      two error handler (client and server) which are supposed to be called based 
      on which context code is in. If it is in client context, client error handler
      should be called otherwise server.
      
      Test case:
      Test case automation is not possible as current (following) code doesn't 
      allow '\T' to be executed from command line (OR command read from a file):
      [client/mysql.cc]
      ...
       static int
       com_tee(String *buffer __attribute__((unused)),
               char *line __attribute__((unused)))
       {
         char file_name[FN_REFLEN], *end, *param;
      
         if (status.batch) << THIS IS TRUE WHILE EXECUTING FROM COMMAND LINE.
            return 0;
       ...
      So, not adding test case in GA. WIll add a test case in mysql-trunk after 
      removing above code so that this could be properly tested before GA.
      
      libmysqld/lib_sql.cc:
        Added code to call client/server error handler based on in control is in 
        client/server code respectively.
      sql/mysql_priv.h:
        Added comments for THR_THD, THR_MALLOC keys.
      sql/sql_class.cc:
        Function definition of new function restore_global to removes thread specific 
        data from stack (which was stored in store global).
      sql/sql_class.h:
        Function declaration of new function restore_global.
      d608ad2d
    • Mayank Prasad's avatar
      merge from 5.1 for bug#11764633 · 47f7fc43
      Mayank Prasad authored
      47f7fc43
  10. 16 May, 2011 1 commit
    • Guilhem Bichot's avatar
      Fix for BUG#11755168 '46895: test "outfile_loaddata" fails (reproducible)'. · 12c42b98
      Guilhem Bichot authored
      In sql_class.cc, 'row_count', of type 'ha_rows', was used as last argument for
      ER_TRUNCATED_WRONG_VALUE_FOR_FIELD which is
      "Incorrect %-.32s value: '%-.128s' for column '%.192s' at row %ld".
      So 'ha_rows' was used as 'long'.
      On SPARC32 Solaris builds, 'long' is 4 bytes and 'ha_rows' is 'longlong' i.e. 8 bytes.
      So the printf-like code was reading only the first 4 bytes.
      Because the CPU is big-endian, 1LL is 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01
      so the first four bytes yield 0. So the warning message had "row 0" instead of
      "row 1" in test outfile_loaddata.test:
      -Warning	1366	Incorrect string value: '\xE1\xE2\xF7' for column 'b' at row 1
      +Warning	1366	Incorrect string value: '\xE1\xE2\xF7' for column 'b' at row 0
      
      All error-messaging functions which internally invoke some printf-life function
      are potential candidate for such mistakes.
      One apparently easy way to catch such mistakes is to use
      ATTRIBUTE_FORMAT (from my_attribute.h).
      But this works only when call site has both:
      a) the format as a string literal
      b) the types of arguments.
      So:
        func(ER(ER_BLAH), 10);
      will silently not be checked, because ER(ER_BLAH) is not known at
      compile time (it is known at run-time, and depends on the chosen
      language).
      And
        func("%s", a va_list argument);
      has the same problem, as the *real* type of arguments is not
      known at this site at compile time (it's known in some caller).
      Moreover,
        func(ER(ER_BLAH));
      though possibly correct (if ER(ER_BLAH) has no '%' markers), will not
      compile (gcc says "error: format not a string literal and no format
      arguments").
      
      Consequences:
      1) ATTRIBUTE_FORMAT is here added only to functions which in practice
      take "string literal" formats: "my_error_reporter" and "print_admin_msg".
      2) it cannot be added to the other functions: my_error(),
      push_warning_printf(), Table_check_intact::report_error(),
      general_log_print().
      
      To do a one-time check of functions listed in (2), the following
      "static code analysis" has been done:
      1) replace
        my_error(ER_xxx, arguments for substitution in format)
      with the equivalent
        my_printf_error(ER_xxx,ER(ER_xxx), arguments for substitution in
      format),
      so that we have ER(ER_xxx) and the arguments *in the same call site*
      2) add ATTRIBUTE_FORMAT to push_warning_printf(),
      Table_check_intact::report_error(), general_log_print()
      3) replace ER(xxx) with the hard-coded English text found in
      errmsg.txt (like: ER(ER_UNKNOWN_ERROR) is replaced with
      "Unknown error"), so that a call site has the format as string literal
      4) this way, ATTRIBUTE_FORMAT can effectively do its job
      5) compile, fix errors detected by ATTRIBUTE_FORMAT
      6) revert steps 1-2-3.
      The present patch has no compiler error when submitted again to the
      static code analysis above.
      It cannot catch all problems though: see Field::set_warning(), in
      which a call to push_warning_printf() has a variable error
      (thus, not replacable by a string literal); I checked set_warning() calls
      by hand though.
      
      See also WL 5883 for one proposal to avoid such bugs from appearing
      again in the future.
      
      The issues fixed in the patch are:
      a) mismatch in types (like 'int' passed to '%ld')
      b) more arguments passed than specified in the format.
      This patch resolves mismatches by changing the type/number of arguments,
      not by changing error messages of sql/share/errmsg.txt. The latter would be wrong,
      per the following old rule: errmsg.txt must be as stable as possible; no insertions
      or deletions of messages, no changes of type or number of printf-like format specifiers,
      are allowed, as long as the change impacts a message already released in a GA version.
      If this rule is not followed:
      - Connectors, which use error message numbers, will be confused (by insertions/deletions
      of messages)
      - using errmsg.sys of MySQL 5.1.n with mysqld of MySQL 5.1.(n+1)
      could produce wrong messages or crash; such usage can easily happen if
      installing 5.1.(n+1) while /etc/my.cnf still has --language=/path/to/5.1.n/xxx;
      or if copying mysqld from 5.1.(n+1) into a 5.1.n installation.
      When fixing b), I have verified that the superfluous arguments were not used in the format
      in the first 5.1 GA (5.1.30 'bteam@astra04-20081114162938-z8mctjp6st27uobm').
      Had they been used, then passing them today, even if the message doesn't use them
      anymore, would have been necessary, as explained above.
      
      include/my_getopt.h:
        this function pointer is used only with "string literal" formats, so we can add
        ATTRIBUTE_FORMAT.
      mysql-test/collections/default.experimental:
        test should pass now
      sql/derror.cc:
        by having a format as string literal, ATTRIBUTE_FORMAT check becomes effective.
      sql/events.cc:
        Change justified by the following excerpt from sql/share/errmsg.txt:
        ER_EVENT_SAME_NAME
                eng "Same old and new event name"
        ER_EVENT_SET_VAR_ERROR
                eng "Error during starting/stopping of the scheduler. Error code %u"
      sql/field.cc:
        ER_TOO_BIG_SCALE 42000 S1009
                eng "Too big scale %d specified for column '%-.192s'. Maximum is %lu."
        ER_TOO_BIG_PRECISION 42000 S1009
                eng "Too big precision %d specified for column '%-.192s'. Maximum is %lu."
        ER_TOO_BIG_DISPLAYWIDTH 42000 S1009
                eng "Display width out of range for column '%-.192s' (max = %lu)"
      sql/ha_ndbcluster.cc:
        ER_OUTOFMEMORY HY001 S1001
                eng "Out of memory; restart server and try again (needed %d bytes)"
        (sizeof() returns size_t)
      sql/ha_ndbcluster_binlog.cc:
        Too many arguments for:
        ER_GET_ERRMSG  
                eng "Got error %d '%-.100s' from %s"
        Patch by Jonas Oreland.
      sql/ha_partition.cc:
        print_admin_msg() is used only with a literal as format, so ATTRIBUTE_FORMAT
        works.
      sql/handler.cc:
        ER_OUTOFMEMORY HY001 S1001
                eng "Out of memory; restart server and try again (needed %d bytes)"
        (sizeof() returns size_t)
      sql/item_create.cc:
        ER_TOO_BIG_SCALE 42000 S1009
                eng "Too big scale %d specified for column '%-.192s'. Maximum is %lu."
        ER_TOO_BIG_PRECISION 42000 S1009
                eng "Too big precision %d specified for column '%-.192s'. Maximum is %lu."
        'c_len' and 'c_dec' are char*, passed as %d !! We don't know their value
        (as strtoul() failed), but they are likely big, so we use INT_MAX.
        'len' is ulong.
      sql/item_func.cc:
        ER_WARN_DATA_OUT_OF_RANGE 22003 
                eng "Out of range value for column '%s' at row %ld"
        ER_CANT_FIND_UDF  
                eng "Can't load function '%-.192s'"
      sql/item_strfunc.cc:
        ER_TOO_BIG_FOR_UNCOMPRESS  
                eng "Uncompressed data size too large; the maximum size is %d (probably, length of uncompressed data was corrupted)"
        max_allowed_packet is ulong.
      sql/mysql_priv.h:
        sql_print_message_func is a function _pointer_.
      sql/sp_head.cc:
        ER_SP_RECURSION_LIMIT
                eng "Recursive limit %d (as set by the max_sp_recursion_depth variable) was exceeded for routine %.192s"
        max_sp_recursion_depth is ulong
      sql/sql_acl.cc:
        ER_PASSWORD_NO_MATCH 42000 
                eng "Can't find any matching row in the user table"
        ER_CANT_CREATE_USER_WITH_GRANT 42000
                eng "You are not allowed to create a user with GRANT"
      sql/sql_base.cc:
        ER_NOT_KEYFILE  
                eng "Incorrect key file for table '%-.200s'; try to repair it"
        ER_TOO_MANY_TABLES  
                eng "Too many tables; MySQL can only use %d tables in a join"
        MAX_TABLES is size_t.
      sql/sql_binlog.cc:
        ER_UNKNOWN_ERROR  
                eng "Unknown error"
      sql/sql_class.cc:
        ER_TRUNCATED_WRONG_VALUE_FOR_FIELD  
                eng "Incorrect %-.32s value: '%-.128s' for column '%.192s' at row %ld"
        WARN_DATA_TRUNCATED 01000 
                eng "Data truncated for column '%s' at row %ld"
      sql/sql_connect.cc:
        ER_HANDSHAKE_ERROR 08S01 
                eng "Bad handshake"
        ER_BAD_HOST_ERROR 08S01 
                eng "Can't get hostname for your address"
      sql/sql_insert.cc:
        ER_WRONG_VALUE_COUNT_ON_ROW 21S01 
                eng "Column count doesn't match value count at row %ld"
      sql/sql_parse.cc:
        ER_WARN_HOSTNAME_WONT_WORK  
                eng "MySQL is started in --skip-name-resolve mode; you must restart it without this switch for this grant to work"
        ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT
        	eng "Too high level of nesting for select"
        ER_UNKNOWN_ERROR  
                eng "Unknown error"
      sql/sql_partition.cc:
        ER_OUTOFMEMORY HY001 S1001
                eng "Out of memory; restart server and try again (needed %d bytes)"
      sql/sql_plugin.cc:
        ER_OUTOFMEMORY HY001 S1001
                eng "Out of memory; restart server and try again (needed %d bytes)"
      sql/sql_prepare.cc:
        ER_OUTOFMEMORY HY001 S1001
                eng "Out of memory; restart server and try again (needed %d bytes)"
        ER_UNKNOWN_STMT_HANDLER  
                eng "Unknown prepared statement handler (%.*s) given to %s"
        length value (for '%.*s') must be 'int', per the doc of printf()
        and the code of my_vsnprintf().
      sql/sql_show.cc:
        ER_OUTOFMEMORY HY001 S1001
                eng "Out of memory; restart server and try again (needed %d bytes)"
      sql/sql_table.cc:
        ER_TOO_BIG_FIELDLENGTH 42000 S1009
                eng "Column length too big for column '%-.192s' (max = %lu); use BLOB or TEXT instead"
      sql/table.cc:
        ER_NOT_FORM_FILE  
                eng "Incorrect information in file: '%-.200s'"
        ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE
                eng "Column count of mysql.%s is wrong. Expected %d, found %d. Created with MySQL %d, now running %d. Please use mysql_upgrade to fix this error."
        table->s->mysql_version is ulong.
      sql/unireg.cc:
        ER_TOO_LONG_TABLE_COMMENT
          eng "Comment for table '%-.64s' is too long (max = %lu)"
        ER_TOO_LONG_FIELD_COMMENT
          eng "Comment for field '%-.64s' is too long (max = %lu)"
        ER_TOO_BIG_ROWSIZE 42000 
                eng "Row size too large. The maximum row size for the used table type, not counting BLOBs, is %ld. You have to change some columns to TEXT or BLOBs"
      12c42b98
  11. 28 Apr, 2011 1 commit
    • Georgi Kodinov's avatar
      Bug #11764517: 57359: POSSIBLE TO CIRCUMVENT SECURE_FILE_PRIV · 59d75160
      Georgi Kodinov authored
        USING '..' ON WINDOWS
      
      Backport of the fix to 5.0 (to be null-merged to 5.1).
      Moved the test into the main test suite. 
      Made mysql-test-run.pl to not use symlinks for sdtdata as the symlinks
      are now properly recognized by secure_file_priv.
      Made sure the paths in load_file(), LOAD DATA and SELECT .. INTO OUTFILE 
      that are checked against secure_file_priv in a correct way similarly to 5.1 
      by the extended is_secure_file_path() backport before the comparison.
      Added an extensive test with all the variants of upper/lower case, 
      slash/backslash and case sensitivity.
      Added few comments to the code.
      59d75160
  12. 20 Apr, 2011 1 commit
  13. 15 Apr, 2011 3 commits
    • Alexander Nozdrin's avatar
      A patch for Bug#11763166 (55847: SHOW WARNINGS returns empty · 060541c0
      Alexander Nozdrin authored
      result set when SQLEXCEPTION is active.
      
      The problem was in a hackish THD::no_warnings_for_error attribute.
      When it was set, an error was not written to Warning_info -- only
      Diagnostics_area state was changed. That means, Diagnostics_area
      might contain error state, which is not present in Warning_info.
      
      The user-visible problem was that in some cases SHOW WARNINGS
      returned empty result set (i.e. there were no warnings) while
      the previous SQL statement failed. According to the MySQL
      protocol errors must be presented in warning list.
      
      The main idea of this patch is to remove THD::no_warnings_for_error.
      There were few places where it was used:
        - sql_admin.cc, handling of REPAIR TABLE USE_FRM.
        - sql_show.cc, when calling fill_schema_table_from_frm().
        - sql_show.cc, when calling fill_table().
      The fix is to either use internal-error-handlers, or to use
      temporary Warning_info storing warnings, which might be ignored.
      
      This patch is needed to fix Bug 11763162 (55843).
      060541c0
    • Mikael Ronström's avatar
    • Mikael Ronström's avatar
      7e3b316e
  14. 07 Apr, 2011 1 commit
    • Marko Mäkelä's avatar
      Bug #11766513 - 59641: Prepared XA transaction in system after hard crash · 0ff2a182
      Marko Mäkelä authored
      causes future shutdown hang
      
      InnoDB would hang on shutdown if any XA transactions exist in the
      system in the PREPARED state. This has been masked by the fact that
      MySQL would roll back any PREPARED transaction on shutdown, in the
      spirit of Bug #12161 Xa recovery and client disconnection.
      
      [mysql-test-run] do_shutdown_server: Interpret --shutdown_server 0 as
      a request to kill the server immediately without initiating a
      shutdown procedure.
      
      xid_cache_insert(): Initialize XID_STATE::rm_error in order to avoid a
      bogus error message on XA ROLLBACK of a recovered PREPARED transaction.
      
      innobase_commit_by_xid(), innobase_rollback_by_xid(): Free the InnoDB
      transaction object after rolling back a PREPARED transaction.
      
      trx_get_trx_by_xid(): Only consider transactions whose
      trx->is_prepared flag is set. The MySQL layer seems to prevent
      attempts to roll back connected transactions that are in the PREPARED
      state from another connection, but it is better to play it safe. The
      is_prepared flag was introduced in the InnoDB Plugin.
      
      trx_n_prepared: A new counter, counting the number of InnoDB
      transactions in the PREPARED state.
      
      logs_empty_and_mark_files_at_shutdown(): On shutdown, allow
      trx_n_prepared transactions to exist in the system.
      
      trx_undo_free_prepared(), trx_free_prepared(): New functions, to free
      the memory objects of PREPARED transactions on shutdown. This is not
      needed in the built-in InnoDB, because it would collect all allocated
      memory on shutdown. The InnoDB Plugin needs this because of
      innodb_use_sys_malloc.
      
      trx_sys_close(): Invoke trx_free_prepared() on all remaining
      transactions.
      0ff2a182
  15. 04 Mar, 2011 1 commit
  16. 16 Feb, 2011 2 commits
  17. 10 Feb, 2011 2 commits
  18. 27 Jan, 2011 1 commit
  19. 20 Jan, 2011 1 commit
  20. 17 Dec, 2010 1 commit
  21. 15 Dec, 2010 1 commit
    • Davi Arnaut's avatar
      Bug#58136: Crash in vio_close at concurrent disconnect and KILL · 4e2cf441
      Davi Arnaut authored
      The problem is a race between a session closing its vio
      (i.e. after a COM_QUIT) at the same time it is being killed by
      another thread. This could trigger a assertion in vio_close()
      as the two threads could end up closing the same vio, at the
      same time. This could happen due to the implementation of
      SIGNAL_WITH_VIO_CLOSE, which closes the vio of the thread
      being killed.
      
      The solution is to serialize the close of the Vio under
      LOCK_thd_data, which protects THD data.
      
      No regression test is added as this is essentially a debug
      issue and the test case would be quite convoluted as we would
      need to synchronize a session that is being killed -- which
      is a bit difficult since debug sync points code does not
      synchronize killed sessions.
      
      sql/mysqld.cc:
        Drop lock parameter from close_connection, its not necessary
        any more. The newly introduced THD::disconnect method will take
        care of locking.
      sql/mysqld.h:
        Change prototype, add a default parameter for the error code.
      sql/sql_class.cc:
        In case SIGNAL_WITH_VIO_CLOSE is defined, the active vio is
        closed and cleared. Subsequent calls will only close the vio
        owned by the session.
      4e2cf441
  22. 18 Nov, 2010 1 commit
    • Alexander Barkov's avatar
      Bug#57306 SHOW PROCESSLIST does not display string literals well. · 185e189d
      Alexander Barkov authored
      Problem: Extended characters outside of ASCII range where not displayed
      properly in SHOW PROCESSLIST, because thd_info->query was always sent as 
      system_character_set (utf8). This was wrong, because query buffer
      is never converted to utf8 - it is always have client character set.
      
      Fix: sending query buffer using query character set
      
        @ sql/sql_class.cc
        @ sql/sql_class.h
          Introducing a new class CSET_STRING, a LEX_STRING with character set.
          Adding set_query(&CSET_STRING)
          Adding reset_query(), to use instead of set_query(0, NULL).
      
        @ sql/event_data_objects.cc
          Using reset_query()
      
        @ sql/log_event.cc
          Using reset_query()
          Adding charset argument to set_query_and_id().
      
        @ sql/slave.cc
          Using reset_query().
      
        @ sql/sp_head.cc
          Changing backing up and restore code to use CSET_STRING.
      
        @ sql/sql_audit.h
          Using CSET_STRING.
          In the "else" branch it's OK not to use
          global_system_variables.character_set_client.
          &my_charset_latin1, which is set in constructor, is fine
          (verified with Sergey Vojtovich).
      
        @ sql/sql_insert.cc
          Using set_query() with proper character set: table_name is utf8.
      
        @ sql/sql_parse.cc
          Adding character set argument to set_query_and_id().
          (This is the main point where thd->charset() is stored
           into thd->query_string.cs, for use in "SHOW PROCESSLIST".)
          Using reset_query().
          
        @ sql/sql_prepare.cc
          Storing client character set into thd->query_string.cs.
      
        @ sql/sql_show.cc
          Using CSET_STRING to fetch and send charset-aware query information
          from threads.
      
        @ storage/myisam/ha_myisam.cc
          Using set_query() with proper character set: table_name is utf8.
      
        @ mysql-test/r/show_check.result
        @ mysql-test/t/show_check.test
          Adding tests
      185e189d
  23. 15 Nov, 2010 1 commit
    • Jorgen Loland's avatar
      Bug#54812: assert in Diagnostics_area::set_ok_status · 1945734c
      Jorgen Loland authored
                 during EXPLAIN
      
      Before the patch, send_eof() of some subclasses of 
      select_result (e.g., select_send::send_eof()) could 
      handle being called after an error had occured while others 
      could not. The methods that were not well-behaved would trigger
      an ASSERT on debug builds. Release builds were not affected.
      
      Consider the following query as an example for how the ASSERT
      could be triggered:
      
      A user without execute privilege on f() does
         SELECT MAX(key1) INTO @dummy FROM t1 WHERE f() < 1;
      resulting in "ERROR 42000: execute command denied to user..." 
      
      The server would end the query by calling send_eof(). The 
      fact that the error had occured would make the ASSERT trigger. 
      
      select_dumpvar::send_eof() was the offending method in the
      bug report, but the problem also applied to other 
      subclasses of select_result. This patch uniforms send_eof() 
      of all subclasses of select_result to handle being called 
      after an error has occured. 
      
      mysql-test/r/not_embedded_server.result:
        Added test for BUG#54812
      mysql-test/t/not_embedded_server.test:
        Added test for BUG#54812
      sql/sql_class.cc:
        send_eof() of all subclasses of select_result can now handle being
        called after an error has occured.
      sql/sql_insert.cc:
        send_eof() of all subclasses of select_result can now handle being
        called after an error has occured.
        Also fix call to abort() in select_create::send_eof(), which was supposed to abort the result set, not terminate the server. This call to abort() should have been changed when the function was renamed from abort_result_set() but was forgotten. New test case added by BUG#54812 covered this line and terminated server.
      sql/sql_prepare.cc:
        send_eof() of all subclasses of select_result can now handle being
        called after an error has occured.
      sql/sql_update.cc:
        send_eof() of all subclasses of select_result can now handle being
        called after an error has occured.
      1945734c
  24. 11 Nov, 2010 1 commit
    • Dmitry Lenev's avatar
      Patch that refactors global read lock implementation and fixes · 6bf6272f
      Dmitry Lenev authored
      bug #57006 "Deadlock between HANDLER and FLUSH TABLES WITH READ
      LOCK" and bug #54673 "It takes too long to get readlock for
      'FLUSH TABLES WITH READ LOCK'".
      
      The first bug manifested itself as a deadlock which occurred
      when a connection, which had some table open through HANDLER
      statement, tried to update some data through DML statement
      while another connection tried to execute FLUSH TABLES WITH
      READ LOCK concurrently.
      
      What happened was that FTWRL in the second connection managed
      to perform first step of GRL acquisition and thus blocked all
      upcoming DML. After that it started to wait for table open
      through HANDLER statement to be flushed. When the first connection
      tried to execute DML it has started to wait for GRL/the second
      connection creating deadlock.
      
      The second bug manifested itself as starvation of FLUSH TABLES
      WITH READ LOCK statements in cases when there was a constant
      stream of concurrent DML statements (in two or more
      connections).
      
      This has happened because requests for protection against GRL
      which were acquired by DML statements were ignoring presence of
      pending GRL and thus the latter was starved.
      
      This patch solves both these problems by re-implementing GRL
      using metadata locks.
      
      Similar to the old implementation acquisition of GRL in new
      implementation is two-step. During the first step we block
      all concurrent DML and DDL statements by acquiring global S
      metadata lock (each DML and DDL statement acquires global IX
      lock for its duration). During the second step we block commits
      by acquiring global S lock in COMMIT namespace (commit code
      acquires global IX lock in this namespace).
      
      Note that unlike in old implementation acquisition of
      protection against GRL in DML and DDL is semi-automatic.
      We assume that any statement which should be blocked by GRL
      will either open and acquires write-lock on tables or acquires
      metadata locks on objects it is going to modify. For any such
      statement global IX metadata lock is automatically acquired
      for its duration.
      
      The first problem is solved because waits for GRL become
      visible to deadlock detector in metadata locking subsystem
      and thus deadlocks like one in the first bug become impossible.
      
      The second problem is solved because global S locks which
      are used for GRL implementation are given preference over
      IX locks which are acquired by concurrent DML (and we can
      switch to fair scheduling in future if needed).
      
      Important change:
      FTWRL/GRL no longer blocks DML and DDL on temporary tables.
      Before this patch behavior was not consistent in this respect:
      in some cases DML/DDL statements on temporary tables were
      blocked while in others they were not. Since the main use cases
      for FTWRL are various forms of backups and temporary tables are
      not preserved during backups we have opted for consistently
      allowing DML/DDL on temporary tables during FTWRL/GRL.
      
      Important change:
      This patch changes thread state names which are used when
      DML/DDL of FTWRL is waiting for global read lock. It is now
      either "Waiting for global read lock" or "Waiting for commit
      lock" depending on the stage on which FTWRL is.
      
      Incompatible change:
      To solve deadlock in events code which was exposed by this
      patch we have to replace LOCK_event_metadata mutex with
      metadata locks on events. As result we have to prohibit
      DDL on events under LOCK TABLES.
      
      This patch also adds extensive test coverage for interaction
      of DML/DDL and FTWRL.
      
      Performance of new and old global read lock implementations
      in sysbench tests were compared. There were no significant
      difference between new and old implementations.
      
      mysql-test/include/check_ftwrl_compatible.inc:
        Added helper script which allows to check that a statement is
        compatible with FLUSH TABLES WITH READ LOCK.
      mysql-test/include/check_ftwrl_incompatible.inc:
        Added helper script which allows to check that a statement is
        incompatible with FLUSH TABLES WITH READ LOCK.
      mysql-test/include/handler.inc:
        Adjusted test case to the fact that now DROP TABLE closes
        open HANDLERs for the table to be dropped before checking
        if there active FTWRL in this connection.
      mysql-test/include/wait_show_condition.inc:
        Fixed small error in the timeout message. The correct name
        of variable used as parameter for this script is "$condition"
        and not "$wait_condition".
      mysql-test/r/delayed.result:
        Added test coverage for scenario which triggered assert in
        metadata locking subsystem.
      mysql-test/r/events_2.result:
        Updated test results after prohibiting event DDL operations
        under LOCK TABLES.
      mysql-test/r/flush.result:
        Added test coverage for bug #57006 "Deadlock between HANDLER
        and FLUSH TABLES WITH READ LOCK".
      mysql-test/r/flush_read_lock.result:
        Added test coverage for various aspects of FLUSH TABLES WITH
        READ LOCK functionality.
      mysql-test/r/flush_read_lock_kill.result:
        Adjusted test case after replacing custom global read lock
        implementation with one based on metadata locks. Use new
        debug_sync point. Do not disable concurrent inserts as now
        InnoDB we always use InnoDB table.
      mysql-test/r/handler_innodb.result:
        Adjusted test case to the fact that now DROP TABLE closes
        open HANDLERs for the table to be dropped before checking
        if there active FTWRL in this connection.
      mysql-test/r/handler_myisam.result:
        Adjusted test case to the fact that now DROP TABLE closes
        open HANDLERs for the table to be dropped before checking
        if there active FTWRL in this connection.
      mysql-test/r/mdl_sync.result:
        Adjusted test case after replacing custom global read lock
        implementation with one based on metadata locks. Replaced
        usage of GRL-specific debug_sync's with appropriate sync
        points in MDL subsystem.
      mysql-test/suite/perfschema/r/dml_setup_instruments.result:
        Updated test results after removing global
        COND_global_read_lock condition variable.
      mysql-test/suite/perfschema/r/func_file_io.result:
        Ensure that this test doesn't affect subsequent tests.
        At the end of its execution enable back P_S instrumentation
        which this test disables at some point.
      mysql-test/suite/perfschema/r/func_mutex.result:
        Ensure that this test doesn't affect subsequent tests.
        At the end of its execution enable back P_S instrumentation
        which this test disables at some point.
      mysql-test/suite/perfschema/r/global_read_lock.result:
        Adjusted test case to take into account that new GRL
        implementation is based on MDL.
      mysql-test/suite/perfschema/r/server_init.result:
        Adjusted test case after replacing custom global read
        lock implementation with one based on MDL and replacing
        LOCK_event_metadata mutex with metadata lock.
      mysql-test/suite/perfschema/t/func_file_io.test:
        Ensure that this test doesn't affect subsequent tests.
        At the end of its execution enable back P_S instrumentation
        which this test disables at some point.
      mysql-test/suite/perfschema/t/func_mutex.test:
        Ensure that this test doesn't affect subsequent tests.
        At the end of its execution enable back P_S instrumentation
        which this test disables at some point.
      mysql-test/suite/perfschema/t/global_read_lock.test:
        Adjusted test case to take into account that new GRL
        implementation is based on MDL.
      mysql-test/suite/perfschema/t/server_init.test:
        Adjusted test case after replacing custom global read
        lock implementation with one based on MDL and replacing
        LOCK_event_metadata mutex with metadata lock.
      mysql-test/suite/rpl/r/rpl_tmp_table_and_DDL.result:
        Updated test results after prohibiting event DDL under
        LOCK TABLES.
      mysql-test/t/delayed.test:
        Added test coverage for scenario which triggered assert in
        metadata locking subsystem.
      mysql-test/t/events_2.test:
        Updated test case after prohibiting event DDL operations
        under LOCK TABLES.
      mysql-test/t/flush.test:
        Added test coverage for bug #57006 "Deadlock between HANDLER
        and FLUSH TABLES WITH READ LOCK".
      mysql-test/t/flush_block_commit.test:
        Adjusted test case after changing thread state name which
        is used when COMMIT waits for FLUSH TABLES WITH READ LOCK
        from "Waiting for release of readlock" to "Waiting for commit
        lock".
      mysql-test/t/flush_block_commit_notembedded.test:
        Adjusted test case after changing thread state name which is
        used when DML waits for FLUSH TABLES WITH READ LOCK. Now we
        use "Waiting for global read lock" in this case.
      mysql-test/t/flush_read_lock.test:
        Added test coverage for various aspects of FLUSH TABLES WITH
        READ LOCK functionality.
      mysql-test/t/flush_read_lock_kill-master.opt:
        We no longer need to use make_global_read_lock_block_commit_loop
        debug tag in this test. Instead we rely on an appropriate
        debug_sync point in MDL code.
      mysql-test/t/flush_read_lock_kill.test:
        Adjusted test case after replacing custom global read lock
        implementation with one based on metadata locks. Use new
        debug_sync point. Do not disable concurrent inserts as now
        InnoDB we always use InnoDB table.
      mysql-test/t/lock_multi.test:
        Adjusted test case after changing thread state names which
        are used when DML or DDL waits for FLUSH TABLES WITH READ
        LOCK to "Waiting for global read lock".
      mysql-test/t/mdl_sync.test:
        Adjusted test case after replacing custom global read lock
        implementation with one based on metadata locks. Replaced
        usage of GRL-specific debug_sync's with appropriate sync
        points in MDL subsystem. Updated thread state names which
        are used when DDL waits for FTWRL.
      mysql-test/t/trigger_notembedded.test:
        Adjusted test case after changing thread state names which
        are used when DML or DDL waits for FLUSH TABLES WITH READ
        LOCK to "Waiting for global read lock".
      sql/event_data_objects.cc:
        Removed Event_queue_element::status/last_executed_changed
        members and Event_queue_element::update_timing_fields()
        method. We no longer use this class for updating mysql.events
        once event is chosen for execution. Accesses to instances of
        this class in scheduler thread require protection by
        Event_queue::LOCK_event_queue mutex and we try to avoid
        updating table while holding this lock.
      sql/event_data_objects.h:
        Removed Event_queue_element::status/last_executed_changed
        members and Event_queue_element::update_timing_fields()
        method. We no longer use this class for updating mysql.events
        once event is chosen for execution. Accesses to instances of
        this class in scheduler thread require protection by
        Event_queue::LOCK_event_queue mutex and we try to avoid
        updating table while holding this lock.
      sql/event_db_repository.cc:
        - Changed Event_db_repository methods to not release all
          metadata locks once they are done updating mysql.events
          table. This allows to keep metadata lock protecting
          against GRL and lock protecting particular event around
          until corresponding DDL statement is written to the binary
          log.
        - Removed logic for conditional update of "status" and
          "last_executed" fields from update_timing_fields_for_event()
          method. In the only case when this method is called now
          "last_executed" is always modified and tracking change
          of "status" is too much hassle.
      sql/event_db_repository.h:
        Removed logic for conditional update of "status" and
        "last_executed" fields from Event_db_repository::
        update_timing_fields_for_event() method.
        In the only case when this method is called now "last_executed"
        is always modified and tracking change of "status" field is
        too much hassle.
      sql/event_queue.cc:
        Changed event scheduler code not to update mysql.events
        table while holding Event_queue::LOCK_event_queue mutex.
        Doing so led to a deadlock with a new GRL implementation.
        This deadlock didn't occur with old implementation due to
        fact that code acquiring protection against GRL ignored
        pending GRL requests (which lead to GRL starvation).
        One of goals of new implementation is to disallow GRL
        starvation and so we have to solve problem with this
        deadlock in a different way.
      sql/events.cc:
        Changed methods of Events class to acquire protection
        against GRL while perfoming DDL statement and keep it
        until statement is written to the binary log.
        Unfortunately this step together with new GRL implementation
        exposed deadlock involving Events::LOCK_event_metadata
        and GRL. To solve it Events::LOCK_event_metadata mutex was
        replaced with a metadata lock on event. As a side-effect
        events DDL has to be prohibited under LOCK TABLES even in
        cases when mysql.events table was explicitly locked for
        write.
      sql/events.h:
        Replaced Events::LOCK_event_metadata mutex with a metadata
        lock on event.
      sql/ha_ndbcluster.cc:
        Updated code after replacing custom global read lock
        implementation with one based on MDL. Since MDL subsystem
        should now be able to detect deadlocks involving metadata
        locks and GRL there is no need for special handling of
        active GRL.
      sql/handler.cc:
        Replaced custom implementation of global read lock with
        one based on metadata locks. Consequently when doing
        commit instead of calling method of Global_read_lock
        class to acquire protection against GRL we simply acquire
        IX in COMMIT namespace.
      sql/lock.cc:
        Replaced custom implementation of global read lock with
        one based on metadata locks. This step allows to expose
        wait for GRL to deadlock detector of MDL subsystem and
        thus succesfully resolve deadlocks similar to one behind
        bug #57006 "Deadlock between HANDLER and FLUSH TABLES
        WITH READ LOCK". It also solves problem with GRL starvation
        described in bug #54673 "It takes too long to get readlock
        for 'FLUSH TABLES WITH READ LOCK'" since metadata locks used
        by GRL give preference to FTWRL statement instead of DML
        statements (if needed in future this can be changed to
        fair scheduling).
        
        Similar to old implementation of acquisition of GRL is
        two-step. During the first step we block all concurrent
        DML and DDL statements by acquiring global S metadata lock
        (each DML and DDL statement acquires global IX lock for
        its duration). During the second step we block commits by
        acquiring global S lock in COMMIT namespace (commit code
        acquires global IX lock in this namespace).
        
        Note that unlike in old implementation acquisition of
        protection against GRL in DML and DDL is semi-automatic.
        We assume that any statement which should be blocked by GRL
        will either open and acquires write-lock on tables or acquires
        metadata locks on objects it is going to modify. For any such
        statement global IX metadata lock is automatically acquired
        for its duration.
        
        To support this change:
        - Global_read_lock::lock/unlock_global_read_lock and
          make_global_read_lock_block_commit methods were changed
          accordingly.
        - Global_read_lock::wait_if_global_read_lock() and
          start_waiting_global_read_lock() methods were dropped.
          It is now responsibility of code acquiring metadata locks
          opening tables to acquire protection against GRL by
          explicitly taking global IX lock with statement duration.
        - Global variables, mutex and condition variable used by
          old implementation was removed.
        - lock_routine_name() was changed to use statement duration for
          its global IX lock. It was also renamed to lock_object_name()
          as it now also used to take metadata locks on events.
        - Global_read_lock::set_explicit_lock_duration() was added which
          allows not to release locks used for GRL when leaving prelocked
          mode.
      sql/lock.h:
        - Renamed lock_routine_name() to lock_object_name() and changed
          its signature to allow its usage for events.
        - Removed broadcast_refresh() function. It is no longer needed
          with new GRL implementation.
      sql/log_event.cc:
        Release metadata locks with statement duration at the end
        of processing legacy event for LOAD DATA. This ensures that
        replication thread processing such event properly releases
        its protection against global read lock.
      sql/mdl.cc:
        Changed MDL subsystem to support new MDL-based implementation
        of global read lock.
        
        Added COMMIT and EVENTS namespaces for metadata locks. Changed
        thread state name for GLOBAL namespace to "Waiting for global
        read lock".
        
        Optimized MDL_map::find_or_insert() method to avoid taking
        m_mutex mutex when looking up MDL_lock objects for GLOBAL
        or COMMIT namespaces. We keep pre-created MDL_lock objects
        for these namespaces around and simply return pointers to
        these global objects when needed.
        
        Changed MDL_lock/MDL_scoped_lock to properly handle
        notification of insert delayed handler threads when FTWRL
        takes global S lock.
        
        Introduced concept of lock duration. In addition to locks with
        transaction duration which work in the way which is similar to
        how locks worked before (i.e. they are released at the end of
        transaction), locks with statement and explicit duration were
        introduced.
        Locks with statement duration are automatically released at the
        end of statement. Locks with explicit duration require explicit
        release and obsolete concept of transactional sentinel.
        
        * Changed MDL_request and MDL_ticket classes to support notion
          of duration.
        * Changed MDL_context to keep locks with different duration in
          different lists. Changed code handling ticket list to take
          this into account.
        * Changed methods responsible for releasing locks to take into
          account duration of tickets. Particularly public
          MDL_context::release_lock() method now only can release
          tickets with explicit duration (there is still internal
          method which allows to specify duration). To release locks
          with statement or transaction duration one have to use
          release_statement/transactional_locks() methods.
        * Concept of savepoint for MDL subsystem now has to take into
          account locks with statement duration. Consequently
          MDL_savepoint class was introduced and methods working with
          savepoints were updated accordingly.
        * Added methods which allow to set duration for one or all
          locks in the context.
      sql/mdl.h:
        Changed MDL subsystem to support new MDL-based implementation
        of global read lock.
        
        Added COMMIT and EVENTS namespaces for metadata locks.
        
        Introduced concept of lock duration. In addition to locks with
        transaction duration which work in the way which is similar to
        how locks worked before (i.e. they are released at the end of
        transaction), locks with statement and explicit duration were
        introduced.
        Locks with statement duration are automatically released at the
        end of statement. Locks with explicit duration require explicit
        release and obsolete concept of transactional sentinel.
        
        * Changed MDL_request and MDL_ticket classes to support notion
          of duration.
        * Changed MDL_context to keep locks with different duration in
          different lists. Changed code handling ticket list to take
          this into account.
        * Changed methods responsible for releasing locks to take into
          account duration of tickets. Particularly public
          MDL_context::release_lock() method now only can release
          tickets with explicit duration (there is still internal
          method which allows to specify duration). To release locks
          with statement or transaction duration one have to use
          release_statement/transactional_locks() methods.
        * Concept of savepoint for MDL subsystem now has to take into
          account locks with statement duration. Consequently
          MDL_savepoint class was introduced and methods working with
          savepoints were updated accordingly.
        * Added methods which allow to set duration for one or all
          locks in the context.
      sql/mysqld.cc:
        Removed global mutex and condition variables which were used
        by old implementation of GRL.
        Also we no longer need to initialize Events::LOCK_event_metadata
        mutex as it was replaced with metadata locks on events.
      sql/mysqld.h:
        Removed global variable, mutex and condition variables which
        were used by old implementation of GRL.
      sql/rpl_rli.cc:
        When slave thread closes tables which were open for handling
        of RBR events ensure that it releases global IX lock which
        was acquired as protection against GRL.
      sql/sp.cc:
        Adjusted code to the new signature of lock_object/routine_name(),
        to the fact that one now needs specify duration of lock when
        initializing MDL_request and to the fact that savepoints for MDL
        subsystem are now represented by MDL_savepoint class.
      sql/sp_head.cc:
        Ensure that statements in stored procedures release statement
        metadata locks and thus release their protectiong against GRL
        in proper moment in time.
        Adjusted code to the fact that one now needs specify duration
        of lock when initializing MDL_request.
      sql/sql_admin.cc:
        Adjusted code to the fact that one now needs specify duration
        of lock when initializing MDL_request.
      sql/sql_base.cc:
        - Implemented support for new approach to acquiring protection
          against global read lock. We no longer acquire such protection
          explicitly on the basis of statement flags. Instead we always
          rely on code which is responsible for acquiring metadata locks
          on object to be changed acquiring this protection. This is
          achieved by acquiring global IX metadata lock with statement
          duration. Code doing this also responsible for checking that
          current connection has no active GRL by calling an
          Global_read_lock::can_acquire_protection() method.
          Changed code in open_table() and lock_table_names()
          accordingly.
          Note that as result of this change DDL and DML on temporary
          tables is always compatible with GRL (before it was
          incompatible in some cases and compatible in other cases).
        - To speed-up code acquiring protection against GRL introduced
          m_has_protection_against_grl member in Open_table_context
          class. It indicates that protection was already acquired
          sometime during open_tables() execution and new attempts
          can be skipped.
        - Thanks to new GRL implementation calls to broadcast_refresh()
          became unnecessary and were removed.
        - Adjusted code to the fact that one now needs specify duration
          of lock when initializing MDL_request and to the fact that
          savepoints for MDL subsystem are now represented by
          MDL_savepoint class.
      sql/sql_base.h:
        Adjusted code to the fact that savepoints for MDL subsystem are
        now represented by MDL_savepoint class.
        Also introduced Open_table_context::m_has_protection_against_grl
        member which allows to avoid acquiring protection against GRL
        while opening tables if such protection was already acquired.
      sql/sql_class.cc:
        Changed THD::leave_locked_tables_mode() after transactional
        sentinel for metadata locks was obsoleted by introduction of
        locks with explicit duration.
      sql/sql_class.h:
        - Adjusted code to the fact that savepoints for MDL subsystem
          are now represented by MDL_savepoint class.
        - Changed Global_read_lock class according to changes in
          global read lock implementation:
          * wait_if_global_read_lock and start_waiting_global_read_lock
            are now gone. Instead code needing protection against GRL
            has to acquire global IX metadata lock with statement
            duration itself. To help it new can_acquire_protection()
            was introduced. Also as result of the above change
            m_protection_count member is gone too.
          * Added m_mdl_blocks_commits_lock member to store metadata
            lock blocking commits.
          * Adjusted code to the fact that concept of transactional
            sentinel was obsoleted by concept of lock duration.
        - Removed CF_PROTECT_AGAINST_GRL flag as it is no longer
          necessary. New GRL implementation acquires protection
          against global read lock automagically when statement
          acquires metadata locks on tables or other objects it
          is going to change.
      sql/sql_db.cc:
        Adjusted code to the fact that one now needs specify duration
        of lock when initializing MDL_request.
      sql/sql_handler.cc:
        Removed call to broadcast_refresh() function. It is no longer
        needed with new GRL implementation.
        Adjusted code after introducing duration concept for metadata
        locks. Particularly to the fact transactional sentinel was
        replaced with explicit duration.
      sql/sql_handler.h:
        Renamed mysql_ha_move_tickets_after_trans_sentinel() to
        mysql_ha_set_explicit_lock_duration() after transactional
        sentinel was obsoleted by locks with explicit duration.
      sql/sql_insert.cc:
        Adjusted code handling delaying inserts after switching to
        new GRL implementation. Now connection thread initiating
        delayed insert has to acquire global IX lock in addition
        to metadata lock on table being inserted into. This IX lock
        protects against GRL and similarly to SW lock on table being
        inserted into has to be passed to handler thread in order to
        avoid deadlocks.
      sql/sql_lex.cc:
        LEX::protect_against_global_read_lock member is no longer
        necessary since protection against GRL is automatically
        taken by code acquiring metadata locks/opening tables.
      sql/sql_lex.h:
        LEX::protect_against_global_read_lock member is no longer
        necessary since protection against GRL is automatically
        taken by code acquiring metadata locks/opening tables.
      sql/sql_parse.cc:
        - Implemented support for new approach to acquiring protection
          against global read lock. We no longer acquire such protection
          explicitly on the basis of statement flags. Instead we always
          rely on code which is responsible for acquiring metadata locks
          on object to be changed acquiring this protection. This is
          achieved by acquiring global IX metadata lock with statement
          duration. This lock is automatically released at the end of
          statement execution.
        - Changed implementation of CREATE/DROP PROCEDURE/FUNCTION not
          to release metadata locks and thus protection against of GRL
          in the middle of statement execution.
        - Adjusted code to the fact that one now needs specify duration
          of lock when initializing MDL_request and to the fact that
          savepoints for MDL subsystem are now represented by
          MDL_savepoint class.
      sql/sql_prepare.cc:
        Adjusted code to the to the fact that savepoints for MDL
        subsystem are now represented by MDL_savepoint class.
      sql/sql_rename.cc:
        With new GRL implementation there is no need to explicitly
        acquire protection against GRL before renaming tables.
        This happens automatically in code which acquires metadata
        locks on tables being renamed.
      sql/sql_show.cc:
        Adjusted code to the fact that one now needs specify duration
        of lock when initializing MDL_request and to the fact that
        savepoints for MDL subsystem are now represented by
        MDL_savepoint class.
      sql/sql_table.cc:
        - With new GRL implementation there is no need to explicitly
          acquire protection against GRL before dropping tables.
          This happens automatically in code which acquires metadata
          locks on tables being dropped.
        - Changed mysql_alter_table() not to release lock on new table
          name explicitly and to rely on automatic release of locks
          at the end of statement instead. This was necessary since
          now MDL_context::release_lock() is supported only for locks
          for explicit duration.
      sql/sql_trigger.cc:
        With new GRL implementation there is no need to explicitly
        acquire protection against GRL before changing table triggers.
        This happens automatically in code which acquires metadata
        locks on tables which triggers are to be changed.
      sql/sql_update.cc:
        Fix bug exposed by GRL testing. During prepare phase acquire
        only S metadata locks instead of SW locks to keep prepare of
        multi-UPDATE compatible with concurrent LOCK TABLES WRITE
        and global read lock.
      sql/sql_view.cc:
        With new GRL implementation there is no need to explicitly
        acquire protection against GRL before creating view.
        This happens automatically in code which acquires metadata
        lock on view to be created.
      sql/sql_yacc.yy:
        LEX::protect_against_global_read_lock member is no longer
        necessary since protection against GRL is automatically
        taken by code acquiring metadata locks/opening tables.
      sql/table.cc:
        Adjusted code to the fact that one now needs specify duration
        of lock when initializing MDL_request.
      sql/table.h:
        Adjusted code to the fact that one now needs specify duration
        of lock when initializing MDL_request.
      sql/transaction.cc:
        Replaced custom implementation of global read lock with
        one based on metadata locks. Consequently when doing
        commit instead of calling method of Global_read_lock
        class to acquire protection against GRL we simply acquire
        IX in COMMIT namespace.
        Also adjusted code to the fact that MDL savepoint is now
        represented by MDL_savepoint class.
      6bf6272f
  25. 23 Oct, 2010 1 commit
    • unknown's avatar
      Bug#27606 GRANT statement should be replicated with DEFINER information · 06c49d57
      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.
      06c49d57
  26. 22 Oct, 2010 1 commit
    • Davi Arnaut's avatar
      Bug#37780: Make KILL reliable (main.kill fails randomly) · 2881b801
      Davi Arnaut authored
      - A prerequisite cleanup patch for making KILL reliable.
      
      The test case main.kill did not work reliably.
      
      The following problems have been identified:
      
      1. A kill signal could go lost if it came in, short before a
      thread went reading on the client connection.
      
      2. A kill signal could go lost if it came in, short before a
      thread went waiting on a condition variable.
      
      These problems have been solved as follows. Please see also
      added code comments for more details.
      
      1. There is no safe way to detect, when a thread enters the
      blocking state of a read(2) or recv(2) system call, where it
      can be interrupted by a signal. Hence it is not possible to
      wait for the right moment to send a kill signal. It has been
      decided, not to fix it in the code.  Instead, the test case
      repeats the KILL statement until the connection terminates.
      
      2. Before waiting on a condition variable, we register it
      together with a synchronizating mutex in THD::mysys_var. After
      this, we need to test THD::killed again. At some places we did
      only test it in a loop condition before the registration. When
      THD::killed had been set between this test and the registration,
      we entered waiting without noticing the killed flag. Additional
      checks ahve been introduced where required.
      
      In addition to the above, a re-write of the main.kill test
      case has been done. All sleeps have been replaced by Debug
      Sync Facility synchronization. A couple of sync points have
      been added to the server code.
      
      To avoid further problems, if the test case fails in spite of
      the fixes, the test case has been added to the "experimental"
      list for now.
      
      - Most of the work on this patch is authored by Ingo Struewing
      
      
      mysql-test/t/kill.test:
        Re-wrote test case to use Debug Sync points instead of sleeps
      sql/event_queue.cc:
        Fixed kill detection in Event_queue::cond_wait() by adding a check
        after enter_cond().
      sql/lock.cc:
        Moved Debug Sync points behind enter_cond().
        Fixed comments.
      sql/slave.cc:
        Fixed kill detection in start_slave_thread() by adding a check
        after enter_cond().
      sql/sql_class.cc:
        Swapped order of kill and close in THD::awake().
        Added comments.
      sql/sql_class.h:
        Added a comment to THD::killed.
      sql/sql_parse.cc:
        Added a sync point in do_command().
      sql/sql_select.cc:
        Added a sync point in JOIN::optimize().
      2881b801
  27. 01 Sep, 2010 1 commit
    • Magne Mahre's avatar
      Bug#39932 "create table fails if column for FK is in different · 64b63926
      Magne Mahre authored
                case than in corr index".
            
      Server was unable to find existing or explicitly created supporting
      index for foreign key if corresponding statement clause used field
      names in case different than one used in key specification and created
      yet another supporting index.
      In cases when name of constraint (and thus name of generated index)
      was the same as name of existing/explicitly created index this led
      to duplicate key name error.
            
      The problem was that unlike all other code Key_part_spec::operator==()
      compared field names in case sensitive fashion. As result routines
      responsible for getting rid of redundant generated supporting indexes
      for foreign key were not working properly for versions of field names
      using different cases.
      
      (backported from mysql-trunk)
      
      
      sql/sql_class.cc:
        Make field name comparison case-insensitive like it is
        in the rest of server.
      64b63926
  28. 20 Aug, 2010 1 commit
    • Alfranio Correia's avatar
      BUG#53452 Inconsistent behavior of binlog_direct_non_transactional_updates with · ac6026ce
      Alfranio Correia authored
      temp table
                  
      This patch introduces two key changes in the replication's behavior.
                  
      Firstly, it reverts part of BUG#51894 which puts any update to temporary tables
      into the trx-cache. Now, updates to temporary tables are handled according to
      the type of their engines as a regular table.
                  
      Secondly, an unsafe mixed statement, (i.e. a statement that access transactional
      table as well non-transactional or temporary table, and writes to any of them),
      are written into the trx-cache in order to minimize errors in the execution when
      the statement logging format is in use.
                  
      Such changes has a direct impact on which statements are classified as unsafe
      statements and thus part of BUG#53259 is reverted.
      ac6026ce
  29. 17 Aug, 2010 1 commit
  30. 10 Aug, 2010 1 commit
    • Alfranio Correia's avatar
      BUG#50312 Warnings for unsafe sub-statement not returned to client · 88b32056
      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.
      88b32056
  31. 09 Aug, 2010 1 commit
  32. 30 Jul, 2010 1 commit
    • Alexander Nozdrin's avatar
      Auto-merge from mysql-trunk-bugfixing. · a0ab253f
      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.
      a0ab253f
  33. 28 Jul, 2010 1 commit
  34. 27 Jul, 2010 2 commits
    • Konstantin Osipov's avatar
      Implement WL#5502 Remove dead 5.0 class Sensitive_cursor. · 740c0d3a
      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.
      740c0d3a
    • Konstantin Osipov's avatar
      A pre-requisite patch for the fix for Bug#52044. · 36290c09
      Konstantin Osipov authored
      This patch also fixes Bug#55452 "SET PASSWORD is
      replicated twice in RBR mode".
      
      The goal of this patch is to remove the release of 
      metadata locks from close_thread_tables().
      This is necessary to not mistakenly release
      the locks in the course of a multi-step
      operation that involves multiple close_thread_tables()
      or close_tables_for_reopen().
      
      On the same token, move statement commit outside 
      close_thread_tables().
      
      Other cleanups:
      Cleanup COM_FIELD_LIST.
      Don't call close_thread_tables() in COM_SHUTDOWN -- there
      are no open tables there that can be closed (we leave
      the locked tables mode in THD destructor, and this
      close_thread_tables() won't leave it anyway).
      
      Make open_and_lock_tables() and open_and_lock_tables_derived()
      call close_thread_tables() upon failure.
      Remove the calls to close_thread_tables() that are now
      unnecessary.
      
      Simplify the back off condition in Open_table_context.
      
      Streamline metadata lock handling in LOCK TABLES 
      implementation.
      
      Add asserts to ensure correct life cycle of 
      statement transaction in a session.
      
      Remove a piece of dead code that has also become redundant
      after the fix for Bug 37521.
      
      mysql-test/r/variables.result:
        Update results: set @@autocommit and statement transaction/
        prelocked mode.
      mysql-test/r/view.result:
        A harmless change in CHECK TABLE <view> status for a broken view.
        If previously a failure to prelock all functions used in a view 
        would leave the connection in LTM_PRELOCKED mode, now we call
        close_thread_tables() from open_and_lock_tables()
        and leave prelocked mode, thus some check in mysql_admin_table() that
        works only in prelocked/locked tables mode is no longer activated.
      mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result:
        Fixed Bug#55452 "SET PASSWORD is replicated twice in
        RBR mode": extra binlog events are gone from the
        binary log.
      mysql-test/t/variables.test:
        Add a test case: set autocommit and statement transaction/prelocked
        mode.
      sql/event_data_objects.cc:
        Simplify code in Event_job_data::execute().
        Move sp_head memory management to lex_end().
      sql/event_db_repository.cc:
        Move the release of metadata locks outside
        close_thread_tables().
        Make sure we call close_thread_tables() when
        open_and_lock_tables() fails and remove extra
        code from the events data dictionary.
        Use close_mysql_tables(), a new internal
        function to properly close mysql.* tables
        in the data dictionary.
        Contract Event_db_repository::drop_events_by_field,
        drop_schema_events into one function.
        When dropping all events in a schema,
        make sure we don't mistakenly release all
        locks acquired by DROP DATABASE. These
        include locks on the database name
        and the global intention exclusive
        metadata lock.
      sql/event_db_repository.h:
        Function open_event_table() does not require an instance 
        of Event_db_repository.
      sql/events.cc:
        Use close_mysql_tables() instead of close_thread_tables()
        to bootstrap events, since the latter no longer
        releases metadata locks.
      sql/ha_ndbcluster.cc:
        - mysql_rm_table_part2 no longer releases
        acquired metadata locks. Do it in the caller.
      sql/ha_ndbcluster_binlog.cc:
        Deploy the new protocol for closing thread
        tables in run_query() and ndb_binlog_index
        code.
      sql/handler.cc:
        Assert that we never call ha_commit_trans/
        ha_rollback_trans in sub-statement, which
        is now the case.
      sql/handler.h:
        Add an accessor to check whether THD_TRANS object
        is empty (has no transaction started).
      sql/log.cc:
        Update a comment.
      sql/log_event.cc:
        Since now we commit/rollback statement transaction in 
        mysql_execute_command(), we need a mechanism to communicate
        from Query_log_event::do_apply_event() to mysql_execute_command()
        that the statement transaction should be rolled back, not committed.
        Ideally it would be a virtual method of THD. I hesitate
        to make THD a virtual base class in this already large patch.
        Use a thd->variables.option_bits for now.
        
        Remove a call to close_thread_tables() from the slave IO
        thread. It doesn't open any tables, and the protocol
        for closing thread tables is more complicated now.
        
        Make sure we properly close thread tables, however, 
        in Load_data_log_event, which doesn't
        follow the standard server execution procedure
        with mysql_execute_command().
        @todo: this piece should use Server_runnable
        framework instead.
        Remove an unnecessary call to mysql_unlock_tables().
      sql/rpl_rli.cc:
        Update Relay_log_info::slave_close_thread_tables()
        to follow the new close protocol.
      sql/set_var.cc:
        Remove an unused header.
      sql/slave.cc:
        Remove an unnecessary call to
        close_thread_tables().
      sql/sp.cc:
        Remove unnecessary calls to close_thread_tables()
        from SP DDL implementation. The tables will
        be closed by the caller, in mysql_execute_command().
        When dropping all routines in a database, make sure
        to not mistakenly drop all metadata locks acquired
        so far, they include the scoped lock on the schema.
      sql/sp_head.cc:
        Correct the protocol that closes thread tables
        in an SP instruction.
        Clear lex->sphead before cleaning up lex
        with lex_end to make sure that we don't
        delete the sphead twice. It's considered
        to be "cleaner" and more in line with
        future changes than calling delete lex->sphead
        in other places that cleanup the lex.
      sql/sp_head.h:
        When destroying m_lex_keeper of an instruction,
        don't delete the sphead that all lex objects
        share. 
        @todo: don't store a reference to routine's sp_head
        instance in instruction's lex.
      sql/sql_acl.cc:
        Don't call close_thread_tables() where the caller will
        do that for us.
        Fix Bug#55452 "SET PASSWORD is replicated twice in RBR 
        mode" by disabling RBR replication in change_password()
        function.
        Use close_mysql_tables() in bootstrap and ACL reload
        code to make sure we release all metadata locks.
      sql/sql_base.cc:
        This is the main part of the patch:
        - remove manipulation with thd->transaction
        and thd->mdl_context from close_thread_tables().
        Now this function is only responsible for closing
        tables, nothing else.
        This is necessary to be able to easily use
        close_thread_tables() in procedures, that
        involve multiple open/close tables, which all
        need to be protected continuously by metadata
        locks.
        Add asserts ensuring that TABLE object
        is only used when is protected by a metadata lock.
        Simplify the back off condition of Open_table_context,
        we no longer need to look at the autocommit mode.
        Make open_and_lock_tables() and open_normal_and_derived_tables()
        close thread tables and release metadata locks acquired so-far 
        upon failure. This simplifies their usage.
        Implement close_mysql_tables().
      sql/sql_base.h:
        Add declaration for close_mysql_tables().
      sql/sql_class.cc:
        Remove a piece of dead code that has also become redundant
        after the fix for Bug 37521.
        The code became dead when my_eof() was made a non-protocol method,
        but a method that merely modifies the diagnostics area.
        The code became redundant with the fix for Bug#37521, when 
        we started to cal close_thread_tables() before
        Protocol::end_statement().
      sql/sql_do.cc:
        Do nothing in DO if inside a substatement
        (the assert moved out of trans_rollback_stmt).
      sql/sql_handler.cc:
        Add comments.
      sql/sql_insert.cc:
        Remove dead code. 
        Release metadata locks explicitly at the
        end of the delayed insert thread.
      sql/sql_lex.cc:
        Add destruction of lex->sphead to lex_end(),
        lex "reset" method called at the end of each statement.
      sql/sql_parse.cc:
        Move close_thread_tables() and other related
        cleanups to mysql_execute_command()
        from dispatch_command(). This has become
        possible after the fix for Bug#37521.
        Mark federated SERVER statements as DDL.
        
        Next step: make sure that we don't store
        eof packet in the query cache, and move
        the query cache code outside mysql_parse.
        
        Brush up the code of COM_FIELD_LIST.
        Remove unnecessary calls to close_thread_tables().
        
        When killing a query, don't report "OK"
        if it was a suicide.
      sql/sql_parse.h:
        Remove declaration of a function that is now static.
      sql/sql_partition.cc:
        Remove an unnecessary call to close_thread_tables().
      sql/sql_plugin.cc:
        open_and_lock_tables() will clean up
        after itself after a failure.
        Move close_thread_tables() above
        end: label, and replace with close_mysql_tables(),
        which will also release the metadata lock
        on mysql.plugin.
      sql/sql_prepare.cc:
        Now that we no longer release locks in close_thread_tables()
        statement prepare code has become more straightforward.
        Remove the now redundant check for thd->killed() (used
        only by the backup project) from Execute_server_runnable.
        Reorder code to take into account that now mysql_execute_command()
        performs lex->unit.cleanup() and close_thread_tables().
      sql/sql_priv.h:
        Add a new option to server options to interact
        between the slave SQL thread and execution
        framework (hack). @todo: use a virtual
        method of class THD instead.
      sql/sql_servers.cc:
        Due to Bug 25705 replication of 
        DROP/CREATE/ALTER SERVER is broken.
        Make sure at least we do not attempt to 
        replicate these statements using RBR,
        as this violates the assert in close_mysql_tables().
      sql/sql_table.cc:
        Do not release metadata locks in mysql_rm_table_part2,
        this is done by the caller.
        Do not call close_thread_tables() in mysql_create_table(),
        this is done by the caller. 
        Fix a bug in DROP TABLE under LOCK TABLES when,
        upon error in wait_while_table_is_used() we would mistakenly
        release the metadata lock on a non-dropped table.
        Explicitly release metadata locks when doing an implicit
        commit.
      sql/sql_trigger.cc:
        Now that we delete lex->sphead in lex_end(),
        zero the trigger's sphead in lex after loading
        the trigger, to avoid double deletion.
      sql/sql_udf.cc:
        Use close_mysql_tables() instead of close_thread_tables().
      sql/sys_vars.cc:
        Remove code added in scope of WL#4284 which would
        break when we perform set @@session.autocommit along
        with setting other variables and using tables or functions.
        A test case added to variables.test.
      sql/transaction.cc:
        Add asserts.
      sql/tztime.cc:
        Use close_mysql_tables() rather than close_thread_tables().
      36290c09