1. 24 Jan, 2019 8 commits
    • Andrei Elkin's avatar
      MDEV-10963 Fragmented BINLOG query · 5d48ea7d
      Andrei Elkin authored
      The problem was originally stated in
        http://bugs.mysql.com/bug.php?id=82212
      The size of an base64-encoded Rows_log_event exceeds its
      vanilla byte representation in 4/3 times.
      When a binlogged event size is about 1GB mysqlbinlog generates
      a BINLOG query that can't be send out due to its size.
      
      It is fixed with fragmenting the BINLOG argument C-string into
      (approximate) halves when the base64 encoded event is over 1GB size.
      The mysqlbinlog in such case puts out
      
          SET @binlog_fragment_0='base64-encoded-fragment_0';
          SET @binlog_fragment_1='base64-encoded-fragment_1';
          BINLOG @binlog_fragment_0, @binlog_fragment_1;
      
      to represent a big BINLOG.
      For prompt memory release BINLOG handler is made to reset the BINLOG argument
      user variables in the middle of processing, as if @binlog_fragment_{0,1} = NULL
      is assigned.
      
      Notice the 2 fragments are enough, though the client and server still may
      need to tweak their @@max_allowed_packet to satisfy to the fragment
      size (which they would have to do anyway with greater number of
      fragments, should that be desired).
      
      On the lower level the following changes are made:
      
      Log_event::print_base64()
        remains to call encoder and store the encoded data into a cache but
        now *without* doing any formatting. The latter is left for time
        when the cache is copied to an output file (e.g mysqlbinlog output).
        No formatting behavior is also reflected by the change in the meaning
        of the last argument which specifies whether to cache the encoded data.
      
      Rows_log_event::print_helper()
        is made to invoke a specialized fragmented cache-to-file copying function
        which is
      
      copy_cache_to_file_wrapped()
        that takes care of fragmenting also optionally wraps encoded
        strings (fragments) into SQL stanzas.
      
      my_b_copy_to_file()
        is refactored to into my_b_copy_all_to_file(). The former function
        is generalized
        to accepts more a limit argument to constraint the copying and does
        not reinitialize anymore the cache into reading mode.
        The limit does not do any effect on the fully read cache.
      5d48ea7d
    • Andrei Elkin's avatar
      MDEV-14605 Changes to "ON UPDATE CURRENT_TIMESTAMP" fields are not · f9ac7032
      Andrei Elkin authored
                 always logged properly with binlog_row_image=MINIMAL
      
      There are two issues fixed in this commit.
      The first is an observation of a multi-table UPDATE binlogged
      in row-format in binlog_row_image=MINIMAL mode. While the UPDATE aims
      at a table with an ON-UPDATE attribute its binlog after-image misses
      to record also installed default value.
      The reason for that turns out missed marking of default-capable fields
      in TABLE::write_set.
      
      This is fixed to mark such fields similarly to 10.2's MDEV-10134 patch (db7edfed)
      that introduced it. The marking follows up 93d1e5ce's idea
      to exploit TABLE:rpl_write_set introduced there though,
      and thus does not mess (in 10.1) with the actual MDEV-10134 agenda.
      The patch makes formerly arg-less TABLE::mark_default_fields_for_write()
      to accept an argument which would be TABLE:rpl_write_set.
      
      The 2nd issue is extra columns in in binlog_row_image=MINIMAL before-image
      while merely a packed primary key is enough. The test main.mysqlbinlog_row_minimal
      always had a wrong result recorded.
      This is fixed to invoke a function that intended for read_set
      possible filtering and which is called (supposed to) in all type of MDL, UPDATE
      including; the test results have gotten corrected.
      
      At *merging* from 10.1->10.2 the 1st "main" part of the patch is unnecessary
      since the bug is not observed in 10.2, so only hunks from
      
        sql/sql_class.cc
      
      are required.
      f9ac7032
    • Alexander Barkov's avatar
      MDEV-18195 ASAN use-after-poison in my_strcasecmp_utf8 / Item::eq upon... · 17c75bd2
      Alexander Barkov authored
      MDEV-18195 ASAN use-after-poison in my_strcasecmp_utf8 / Item::eq upon prepared statement with ORDER BY NAME_CONST
      
      ASAN noticed a freed memory access during EXECUTE in this script:
        PREPARE stmt FROM "SELECT 'x' ORDER BY NAME_CONST( 'f', 'foo' )";
        EXECUTE stmt;
      
      In case of a PREPARE statement, all Items, including Item_name_const,
      are created on Prepared_statement::main_mem_root.
      Item_name_const::fix_fields() did not take this into account
      and could allocate the value of Item::name on a wrong memory root,
      in this code:
      
        if (is_autogenerated_name)
        {
          set_name(thd, item_name->c_ptr(), (uint) item_name->length(),
                   system_charset_info);
        }
      
      When fix_fields() is called in the reported SQL script, THD's arena already
      points to THD::main_mem_root rather than to Prepared_statement::main_mem_root,
      so Item::name was allocated on THD::main_mem_root.
      Then, at the end of the dispatch_command() for the PREPARE statement,
      THD::main_mem_root got cleared. So during EXECUTE, Item::name
      pointed to an already freed memory.
      
      This patch changes the code to set the implicit name for Item_name_const
      at the constructor time rather than at fix_fields time. This guarantees
      that Item_name_const and its Item::name always reside on the same memory root.
      
      Note, this change makes the code for Item_name_const symmetric with other
      constant-alike items that set their default implicit names at the constructor
      call time rather than at fix_fields() time:
      - Item_string
      - Item_int
      - Item_real
      - Item_decimal
      - Item_null
      - Item_param
      17c75bd2
    • Geoff Montee's avatar
    • Marko Mäkelä's avatar
      Merge 10.0 into 10.1 · 65350042
      Marko Mäkelä authored
      65350042
    • Andrei Elkin's avatar
    • Sergei Golubchik's avatar
      MDEV-17868 mysqltest fails to link with system PCRE libraries · edeba0c8
      Sergei Golubchik authored
      pcre needs symbols from pcreposix
      (but this is only an issue when linking with system static libraries)
      edeba0c8
    • Thirunarayanan Balathandayuthapani's avatar
      MDEV-17376 Server fails to set ADD_PK_INDEX, DROP_PK_INDEX if unique index nominated as PK · a0f3b9f9
      Thirunarayanan Balathandayuthapani authored
      Problem:
      ========
      Server fails to notify the engine by not setting the ADD_PK_INDEX and
      DROP_PK_INDEX When there is a
       i) Change in candidate for primary key.
       ii) New candidate for primary key.
      
      Fix:
      ====
      Server sets the ADD_PK_INDEX and DROP_PK_INDEX while doing alter for the
      above problematic case.
      a0f3b9f9
  2. 23 Jan, 2019 10 commits
  3. 21 Jan, 2019 3 commits
  4. 18 Jan, 2019 2 commits
    • Varun Gupta's avatar
      MDEV-14440: Assertion `inited==RND' failed in handler::ha_rnd_end · 2061e00c
      Varun Gupta authored
      In the function QUICK_RANGE_SELECT::init_ror_merged_scan we create a seperate handler if the handler in
      head->file cannot be reused. The flag free_file tells us if we have a seperate handler or not.
      There are cases where you might create a handler and then there might be a failure(running ALTER)
      and then we have to revert the handler back to the original one. The code does that
      but it does not reset the flag 'free_file' in this case.
      Also backported f2c41807.
      2061e00c
    • Marko Mäkelä's avatar
      MDEV-18237 InnoDB: Unable to drop FTS index aux table and further errors (possibly bogus) · 1d72db45
      Marko Mäkelä authored
      row_drop_table_for_mysql(): Fix a regression introduced in MDEV-16515.
      Similar to the follow-up fixes MDEV-16647 and MDEV-17470, we must make
      the internal tables of FULLTEXT INDEX immune to kills, to avoid noise
      and resource leakage on DROP TABLE or ALTER TABLE. (Orphan internal tables
      would be dropped at the next InnoDB startup only.)
      1d72db45
  5. 17 Jan, 2019 4 commits
  6. 16 Jan, 2019 3 commits
  7. 15 Jan, 2019 5 commits
  8. 14 Jan, 2019 3 commits
  9. 07 Jan, 2019 1 commit
    • Jan Lindström's avatar
      MDEV-15740: InnoDB does not flush redo log when it shoul · 1d56d875
      Jan Lindström authored
      During database recovery, a transaction with wsrep XID is
      recovered from InnoDB in prepared state. However, when the
      transaction is looked up with trx_get_trx_by_xid() in
      innobase_commit_by_xid(), trx->xid gets cleared in
      trx_get_trx_by_xid_low() and commit time serialization history
      write does not update the wsrep XID in trx sys header for
      that recovered trx. As a result the transaction gets
      committed during recovery but the wsrep position does not
      get updated appropriately.
      
      As a fix, we preserve trx->xid for Galera over transaction
      commit in recovery phase.
      
      Fix authored by: Teemu Ollakka (GaleraCluster) and Marko Mäkelä.
      
      	modified:   mysql-test/suite/galera/disabled.def
      	modified:   mysql-test/suite/galera/r/galera_gcache_recover_full_gcache.result
      	modified:   mysql-test/suite/galera/r/galera_gcache_recover_manytrx.result
      	modified:   mysql-test/suite/galera/t/galera_gcache_recover_full_gcache.test
      	modified:   mysql-test/suite/galera/t/galera_gcache_recover_manytrx.test
      	modified:   storage/innobase/trx/trx0trx.cc
      	modified:   storage/xtradb/trx/trx0trx.cc
      1d56d875
  10. 06 Jan, 2019 1 commit
    • Varun Gupta's avatar
      MDEV-13784: query causes seg fault · d0d0f88f
      Varun Gupta authored
      When we have a nested subquery then a subquery that was a dependent subquery
      may change to an independent one when we optimizer the inner subqueries.
      This is handled st_select_lex::optimize_unflattened_subqueries.
      Currently a subquery that was changed to independent from dependent after optimization
      phase incorrectly shows dependent in the output of Explain, this happens because we
      don't update used_tables for the WHERE clause, ON clause, etc after the optimization phase.
      d0d0f88f