1. 08 Feb, 2018 3 commits
    • Marko Mäkelä's avatar
      Revert an accidental change · bbdb47ff
      Marko Mäkelä authored
      trx_undo_rec_copy(): Use a debug assertion. In a non-debug build,
      with len<0 (which this assertion is really testing for)
      we should still typically crash due to running out of memory.
      bbdb47ff
    • Marko Mäkelä's avatar
      Remove dict_table_t::is_clust() · 7660d8c9
      Marko Mäkelä authored
      Replace all occurrences of the is_clust() method with is_primary(),
      because that is what is actually meant. (Also the change buffer
      tree would count as a clustered index.)
      7660d8c9
    • Marko Mäkelä's avatar
      MDEV-14407 Assertion failure during rollback · 609d0a91
      Marko Mäkelä authored
      Rollback attempted to dereference DB_ROLL_PTR=0, which cannot possibly
      be a valid undo log pointer. A safer canonical value would be
      roll_ptr_t(1) << ROLL_PTR_INSERT_FLAG_POS
      which is what was chosen in MDEV-12288, corresponding to reset_trx_id.
      
      No deterministic test case for the bug was found. The simplest test
      cases may be related to MDEV-11415, which suppresses undo logging for
      ALGORITHM=COPY operations. In those operations, in the spirit of
      MDEV-12288, we should actually have written reset_trx_id instead of
      using the transaction identifier of the current transaction
      (and a bogus value of DB_ROLL_PTR=0). However, thanks to MySQL Bug#28432
      which I had fixed in MySQL 5.6.8 as part of WL#6255, access to the
      rebuilt table by earlier-started transactions should actually have been
      refused with ER_TABLE_DEF_CHANGED.
      
      reset_trx_id: Move the definition to data0type.cc and the declaration
      to data0type.h.
      
      btr_cur_ins_lock_and_undo(): When undo logging is disabled, use the
      safe value that corresponds to reset_trx_id.
      
      btr_cur_optimistic_insert(): Validate the DB_TRX_ID,DB_ROLL_PTR before
      inserting into a clustered index leaf page.
      
      ins_node_t::sys_buf[]: Replaces row_id_buf and trx_id_buf and some
      heap usage.
      
      row_ins_alloc_sys_fields(): Init ins_node_t::sys_buf[] to reset_trx_id.
      
      row_ins_buf(): Only if undo logging is enabled, copy trx->id
      to node->sys_buf. Otherwise, rely on the initialization in
      row_ins_alloc_sys_fields().
      
      row_purge_reset_trx_id(): Invoke mlog_write_string() with reset_trx_id
      directly. (No functional change.)
      
      trx_undo_page_report_modify(): Assert that the DB_ROLL_PTR is not 0.
      
      trx_undo_get_undo_rec_low(): Assert that the roll_ptr is valid before
      trying to dereference it.
      
      dict_index_t::is_primary(): Check if the index is the primary key.
      
      PageConverter::adjust_cluster_record(): Fix
      MDEV-15249 Crash in MVCC read after IMPORT TABLESPACE
      by resetting the system fields to reset_trx_id instead of writing
      the current transaction ID (which will be committed at the
      end of the IMPORT TABLESPACE) and DB_ROLL_PTR=0.
      This can partially be viewed as a follow-up fix of MDEV-12288,
      because IMPORT should already then have written
      DB_TRX_ID=0 and DB_ROLL_PTR=1<<55 to prevent unnecessary
      DB_TRX_ID lookups in subsequent accesses to the table.
      609d0a91
  2. 07 Feb, 2018 8 commits
  3. 06 Feb, 2018 7 commits
  4. 05 Feb, 2018 2 commits
  5. 04 Feb, 2018 4 commits
    • Alexander Barkov's avatar
      d67dcb7b
    • Alexander Barkov's avatar
    • Alexander Barkov's avatar
      MDEV-15176 Storing DATETIME-alike VARCHAR data into TIME produces wrong results · 28d4cf0c
      Alexander Barkov authored
      When storing '0001-01-01 10:20:30x', execution went throw the last code
      branch in Field_time::store_TIME_with_warning(), around the test
      for (ltime->year || ltime->month). This then resulted into wrong results
      because:
      
      1. Field_time::store_TIME() does not check YYYYMM against zero.
        It assumes that ltime->days and ltime->hours are already properly set.
        So it mixed days to hours, even when YYYYMM was not zero.
      
      2. Field_time_hires::store_TIME() does not check YYYYMM against zero.
        It assumes that ltime->year, ltime->month, ltime->days and ltime->hours
        are already properly set. So it always mixed days and even months(!) and years(!)
        to hours, using pack_time(). This gave even worse results comparing to #2.
      
      3. Field_timef::store_TIME() did not check the entire YYYYMM for being zero.
        It only checked MM, but did not check YYYY. In case of a zero MM,
        it mixed days to hours, even if YYYY was not zero.
        The wrong code was in TIME_to_longlong_time_packed().
      
      In the new reduction Field_time::store_TIME_with_warning() is responsible
      to prepare the YYYYYMMDD part properly in all code branches
      (with trailing garbage like 'x' and without trailing garbage).
      It was reorganized into a more straightforward style.
      
      Field_time:store_TIME(), Field_time_hires::store_TIME() and
      TIME_to_longlong_time_packed() were fixed to do a DBUG_ASSERT
      on non-zero ltime->year or ltime->month. The code testing ltime->month
      was removed from TIME_to_longlong_time_packed(), as it's now
      properly done on the caller level.
      
      Truncation was moved from Field_timef::store_TIME() to
      Field_time::store_TIME_with_warning().
      
      So now all thee methods Field_time*::store_TIME() assume a properly
      set input value:
      - Only zero ltime->year and ltime->month are allowed.
      - The value must be already properly truncated according to decimals()
        (this will help to add rounding soon, see MDEV-8894)
      
      A "const" qualifier was added to the argument of Field_time*::store_TIME().
      28d4cf0c
    • Marko Mäkelä's avatar
      Clarify a comment after MDEV-15061 · d6ed077f
      Marko Mäkelä authored
      d6ed077f
  6. 03 Feb, 2018 1 commit
  7. 02 Feb, 2018 5 commits
    • Alexander Barkov's avatar
      Setting Field::field_index for Virtual_tmp_table fields · 705283f7
      Alexander Barkov authored
      Virtial_tmp_table did not set the "field_index" member for its Fields.
      Fixing Virtual_tmp_table::add() to set "field_index" to the Field's ordinal position
      inside the table, like a normal TABLE does, for consistency.
      
      Although, this flaw did not seem to cause any bugs, having field_index properly
      set is helpful for debugging purposes.
      705283f7
    • Sachin Setiya's avatar
      This commit solves a couple of issues · c8299e62
      Sachin Setiya authored
      1st. Create_field does not have function vers_sys_field() kind of handy
      function, second I think Create_field and Field should not divert much , and
      Field does have this function.
      
      2nd. Versioning column does not have NOT_NULL_FLAG, since they can never be
      null. So I have added NOT_NULL_FLAG.
      
      3rd. Since I added NOT_NULL_FLAG this created one issue , versioning column
      of datatype bigint unsigned were getting NO_DEFAULT_VALUE_FLAG. This makes
      test like versioning.insert to fail, Reason being If a column gets this
      flag if we insert 'default' value it will generate error(that is why ) test
      was failing. So now versioning column wont get NO_DEFAULT_VALUE_FLAG flag.
      c8299e62
    • Sachin Setiya's avatar
      MDEV-14849 CREATE + ALTER with user-invisible columns produce ... · 16be7469
      Sachin Setiya authored
      Problem:-
        create or replace table t1 (pk int auto_increment primary key invisible, i int);
        alter table t1 modify pk int invisible;
       This last alter makes a invisible column which is not null and does not
       have default value.
      
      Analysis:-
       This is caused because our error check for NOT_NULL_FLAG and
       NO_DEFAULT_VALUE_FLAG flag misses this sql_field , but this is not the fault
       of error check :).Actually this field come via mysql_prepare_alter_table
       and it does not have NO_DEFAULT_VALUE_FLAG flag turned on. (If it was create
       table NO_DEFAULT_VALUE_FLAG would have turned on Column_definition::check)
       and this would have generated error.
      
      Solution:-
       I have moved the error check to kind last of mysql_prepare_create_table
       because upto this point we have applied NO_DEFAULT_VALUE_FLAG to required
       column.
      16be7469
    • Sachin Setiya's avatar
      Mdev-15085 Invisible Column Non-constant Default value results... · 2d73b581
      Sachin Setiya authored
      Problem:- If we create table field with dynamic default value then that
       field always gets NULL value.
      
      Analyze:- This is because in fill_record we simple continue at Invisible
       column because we though that share->default_values(default value is
       always copied into table->record[0] before insert) will have a default
       value for them(which is true for constant defaults , but not for dynamic
       defaults).
      
      Solution:- We simple set all_fields_have_value to null , and this will
      make call to update_default_fields (in the case of dynamic default), And
      default expr will be evaluted and value will be set in field.
      2d73b581
    • Monty's avatar
      Added name to MEM_ROOT for esier debugging · d69642de
      Monty authored
      This will make it easier to how memory allocation is done when debugging
      with either DBUG or gdb.
      
      Will especially help when debugging stored procedures
      
      Main change is a name argument as second argument to init_alloc_root()
      init_sql_alloc()
      
      Other things:
      - Added DBUG_ENTER/EXIT to some Virtual_tmp_table functions
      d69642de
  8. 01 Feb, 2018 1 commit
  9. 31 Jan, 2018 9 commits
    • Igor Babaev's avatar
      Fixed mdev-15120 CTE table should not belong to database, that is in use · 1951e7f0
      Igor Babaev authored
      When identifying a table name the following should be taken into account:
      a CTE name cannot be qualified with a database name, otherwise the table
      name is considered as the name of a non-CTE table.
      1951e7f0
    • Sergey Vojtovich's avatar
      MDEV-15104 - Optimise MVCC snapshot · bc7a1dc1
      Sergey Vojtovich authored
      With trx_sys_t::rw_trx_ids removal, MVCC snapshot overhead became
      slightly higher. That is instead of copying an array we now have to
      iterate LF_HASH. All this done under trx_sys.mutex protection.
      
      This patch moves MVCC snapshot out of trx_sys.mutex.
      
      Clean-ups:
      
      Removed MVCC: doesn't make too much sense to keep it in a separate class
      anymore.
      
      Refactored ReadView so that it now calls register()/deregister() routines
      (it was vice versa before).
      
      ReadView doesn't have friends anymore. :(
      
      Even less trx_sys.mutex references.
      bc7a1dc1
    • Alexander Barkov's avatar
      A cleanup in sp_rcontext, as requested by Monty · 1e5e3d56
      Alexander Barkov authored
      - Changing sp_rcontext::m_var_items from list of Item to list of Item_field
      - Renaming sp_rcontext::get_item() to get_variable() and changing
        its return type from Item* to Item_field *
      - Adding sp_rcontext::get_parameter() and sp_rcontext::set_parameter(),
        wrappers for get_variable() and set_variable() with extra DBUG_ASSERT.
        Using new methods instead of get_variable()/set_variable() in
        relevant places.
      1e5e3d56
    • Sergey Vojtovich's avatar
      MDEV-15104 - Remove trx_sys_t::serialisation_list · c0d5d7c0
      Sergey Vojtovich authored
      serialisation_list was supposed to instantly give minimum registered
      transaction serialisation number. However maintaining and accessing
      this list requires global mutex protection.
      
      Since we already take MVCC snapshot by iterating trx_sys_t::rw_trx_hash,
      it is cheap to integrate minimum registered transaction lookup into this
      iteration.
      c0d5d7c0
    • Oleksandr Byelkin's avatar
      MDEV-15133: array bound (bulk) parameters of NULL propagate on next rows · df2d6782
      Oleksandr Byelkin authored
      Setting non_null value drops null_value flag.
      Part 2 of 3.
      Part 1 was 10.2 fix.
      Part 3 is test for Connector C.
      df2d6782
    • Sergey Vojtovich's avatar
      MDEV-15104 - Remove trx_sys_t::rw_trx_ids · 53cc9aa5
      Sergey Vojtovich authored
      Take snapshot of registered read-write transaction identifiers directly
      from rw_trx_hash. It immediately saves one trx_sys.mutex lock, reduces
      size of another critical section protected by this mutex, and makes
      further optimisations like removing trx_sys_t::serialisation_list
      possible.
      
      Downside of this approach is bigger overhead for view opening, because
      iterating LF_HASH is more expensive compared to taking snapshot of an
      array. However for low concurrency overhead difference is negligible,
      while for high concurrency mutex is much bigger evil.
      
      Currently we still take trx_sys.mutex to serialise ReadView creation.
      This is required to keep serialisation_list ordered by trx->no as well
      as not to let purge thread to create more recent snapshot while another
      thread gets suspended during creation of older snapshot. This will
      become completely mutex free along with serialisation_list removal.
      
      Compared to previous implementation removing element from rw_trx_hash
      and serialisation_list is not atomic. We disregard all possible bad
      consequences (if there're any) since it will be solved along with
      serialisation_list removal.
      53cc9aa5
    • Sergey Vojtovich's avatar
      Reduce number of trx_sys.mutex references · af566d8a
      Sergey Vojtovich authored
      trx->state change must be guarded by trx->mutex.
      Moved mutex locking to MVCC::view_close().
      af566d8a
    • Marko Mäkelä's avatar
      Follow-up fix to MDEV-15132 Avoid accessing the TRX_SYS page · dcc09afa
      Marko Mäkelä authored
      trx_undo_mem_create_at_db_start(): Do not read TRX_UNDO_TRX_NO
      unless the field is known to be valid, that is, the transaction
      has been serialized and trx_purge_add_undo_to_history() has been
      invoked.
      
      Normally InnoDB pages would be zero-initialized on allocation
      (since MySQL 5.5 or so), but the undo log pages skip that
      mechanism. So, reused undo log pages can contain garbage.
      Undo log headers can start at any offset (there can be
      multiple undo log headers in the same undo log page).
      Therefore, because the TRX_UNDO_TRX_NO is never explicitly
      initialized on undo log header creation, its contents may
      be garbage.
      dcc09afa
    • Daniel Black's avatar
      MariaBackup: gcc7 - snprintf output overflow warning · 7eb084fe
      Daniel Black authored
      extra/mariabackup/xtrabackup.cc: In function ‘ulint xb_process_datadir(const char*, const char*, handle_datadir_entry_func_t)’:
      extra/mariabackup/xtrabackup.cc:4534:1: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=]
       xb_process_datadir(
       ^~~~~~~~~~~~~~~~~~
      mariabackup/xtrabackup.cc:4607:11: note: ‘snprintf’ output 2 or more bytes (assuming 4001) into a destination of size 4000
         snprintf(dbpath, sizeof(dbpath), "%s/%s", path, dbinfo.name);
         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      7eb084fe