1. 13 May, 2022 1 commit
    • Andrei's avatar
      MDEV-28550 improper handling of replication event group that contains · 726bd8c9
      Andrei authored
      GTID_LIST_EVENT or INCIDENT_EVENT.
      
      It's legal to have either of the two inside a group. E.g
        Gtid_event, Gtid_log_list_event, Query_1, ... Xid_log_event
      is permitted.
      However, the slave IO thread treated both
      as the terminal even when the group represents a DDL query.
      That causes a premature Gtid state update so the slave IO would think
      the whole group has been collected while in fact Query_1 etc are yet to process.
      
      Fixed with correcting a condition to compute the terminal event
      of the group.
      Tested with rpl_mysqlbinlog_slave_consistency (of 10.9) and
      rpl_gtid_errorlog.test.
      726bd8c9
  2. 06 May, 2022 4 commits
    • Andrei's avatar
      MDEV-28310 Missing binlog data for INSERT .. ON DUPLICATE KEY UPDATE · a5dc12ee
      Andrei authored
      MDEV-21810 MBR: Unexpected "Unsafe statement" warning for unsafe IODKU
      
      MDEV-17614 fixes to replication unsafety for INSERT ON DUP KEY UPDATE
      on two or more unique key table left a flaw. The fixes checked the
      safety condition per each inserted record with the idea to catch a user-created
      value to an autoincrement column and when that succeeds the autoincrement column
      would become the source of unsafety too.
      It was not expected that after a duplicate error the next record's
      write_set may become different and the unsafe decision for that
      specific record will be computed to screw the Query's binlogging
      state and when @@binlog_format is MIXED nothing gets bin-logged.
      
      This case has been already fixed in 10.5.2 by 91ab42a8 that
      relocated/optimized THD::decide_logging_format_low() out of the record insert
      loop. The safety decision is computed once and at the right time.
      Pertinent parts of the commit are cherry-picked.
      
      Also a spurious warning about unsafety is removed when MIXED
      @@binlog_format; original MDEV-17614 test result corrected.
      The original test of MDEV-17614 is extended and made more readable.
      a5dc12ee
    • Oleksandr Byelkin's avatar
      MDEV-28402 ASAN heap-use-after-free in create_tmp_table, Assertion `l_offset... · 141ab971
      Oleksandr Byelkin authored
      MDEV-28402 ASAN heap-use-after-free in create_tmp_table, Assertion `l_offset >= 0 && table->s->rec_buff_length - l_offset > 0'
      
      Make default() function follow Item_field and use get_tmp_table_item() for
      change_to_use_tmp_fields().
      141ab971
    • Sergei Petrunia's avatar
      624cb973
    • Marko Mäkelä's avatar
      MDEV-28478: INSERT into SPATIAL INDEX in TEMPORARY table writes log · 20ae4816
      Marko Mäkelä authored
      row_ins_sec_index_entry_low(): If a separate mini-transaction is
      needed to adjust the minimum bounding rectangle (MBR) in the parent
      page, we must disable redo logging if the table is a temporary table.
      For temporary tables, no log is supposed to be written, because
      the temporary tablespace will be reinitialized on server restart.
      
      rtr_update_mbr_field(): Plug a memory leak.
      20ae4816
  3. 05 May, 2022 2 commits
    • Sergei Petrunia's avatar
      MDEV-28437: Assertion `!eliminated' failed: Part #2 · 84e32eff
      Sergei Petrunia authored
      In SELECT_LEX::update_used_tables(),
      do not run the loop setting tl->table->maybe_null
      when tl is an eliminated table
      
      (Rationale: First, with current table elimination, tl already
       has maybe_null=1. Second, one should not care what flags
       eliminated tables had)
      84e32eff
    • Sergei Petrunia's avatar
      MDEV-28437: Assertion `!eliminated' failed in Item_subselect::exec · 8dbfaa2a
      Sergei Petrunia authored
      (This is the assert that was added in fix for MDEV-26047)
      
      Table elimination may remove an ON expression from an outer join.
      However SELECT_LEX::update_used_tables() will still call
      
        item->walk(&Item::eval_not_null_tables)
      
      for eliminated expressions. If the subquery is constant and cheap
      Item_cond_and will attempt to evaluate it, which will trigger an
      assert.
      The fix is not to call update_used_tables() or eval_not_null_tables()
      for ON expressions that were eliminated.
      8dbfaa2a
  4. 04 May, 2022 2 commits
    • Sergei Petrunia's avatar
      MDEV-19398: Assertion `item1->type() == Item::FIELD_ITEM ... · ba4927e5
      Sergei Petrunia authored
      Window Functions code tries to minimize the number of times it
      needs to sort the select's resultset by finding "compatible"
      OVER (PARTITION BY ... ORDER BY ...) clauses.
      
      This employs compare_order_elements(). That function assumed that
      the order expressions are Item_field-derived objects (that refer
      to a temp.table). But this is not always the case: one can
      construct queries order expressions are arbitrary item expressions.
      
      Add handling for such expressions: sort them according to the window
      specification they appeared in.
      This means we cannot detect that two compatible PARTITION BY clauses
      that use expressions can share the sorting step.
      But at least we won't crash.
      ba4927e5
    • anel's avatar
      Use proper pid namespace · 794bebf9
      anel authored
          Problem:
          ==============
          By testing `pgrep` with `--ns` option,
          introduced with MDEV-21331, commit fb7c1b94,
          I noted that:
          a) `--ns`  cannot use more than single PID.
          b) `--ns` is returning the processes of the namespace to which supplied PID belongs to.
          So by that sense command `pgrep -x --ns $$ mysqld` will always return an error and skip
          checking of the existing PID of the server.
      
          Solution:
          ==============
          Suggested solution is to add `--nslist pid`, since `--ns` needs to know in which namespace type it should look for.
          See `pgrep --help` for different namespace types.
          Note also that this works *only* if script is run as a `root` (we have that case here).
      
          Current PR is a part of:
          1. MDEV-21331: sync preinst and postrm script
          2. MDEV-15718: check for exact mysqld process
      
          This commit:
          a) fixes fb7c1b94
          b) Closes PR #2068 (obsolete)
          c) Closes PR #2069 (obsolete)
      
          Thanks Faustin Lammler <faustin@mariadb.org> for testing and verifying
          Reviewed by <>
      794bebf9
  5. 02 May, 2022 2 commits
    • Oleksandr Byelkin's avatar
      New CC 3.1 · 70555454
      Oleksandr Byelkin authored
      70555454
    • Alexander Barkov's avatar
      MDEV-28446 mariabackup prepare fails for incrementals if a new schema is... · 680ca152
      Alexander Barkov authored
      MDEV-28446 mariabackup prepare fails for incrementals if a new schema is created after full backup is taken
      
      When "mariabackup --target-dir=$basedir --incremental-dir=$incremental_dir"
      is running and is moving a new table file (e.g. `db1/t1.new`) from the
      incremental directory to the base directory, it needs to verify that the base
      backup database directory (e.g. `$basedir/db1`) really exists
      (or create it otherwise).
      
      The table `db1/t1` can come from a new database `db1` which
      was created during the base mariabackup execution time.
      
      In such case the directory `db1` exists only in the incremental directory,
      but does not exist in the base directory.
      680ca152
  6. 28 Apr, 2022 3 commits
  7. 27 Apr, 2022 3 commits
    • Marko Mäkelä's avatar
      c711abd1
    • Marko Mäkelä's avatar
      MDEV-28416 Incorrect AUTO_INCREMENT may be issued when close to UINT64_MAX · 44a27a26
      Marko Mäkelä authored
      ha_innobase::get_auto_increment(): In the overflow check, account
      for 64-bit unsigned integer wrap-around.
      
      Based on mysql/mysql-server@25ecfe7f49b5a649e96d462cb90602de9de3b919
      44a27a26
    • Marko Mäkelä's avatar
      MDEV-28415 ALTER TABLE on a large table hangs InnoDB · f21a8756
      Marko Mäkelä authored
      buf_flush_page(): Never wait for a page latch, even in checkpoint
      flushing (flush_type == BUF_FLUSH_LIST), to prevent a hang of the
      page cleaner threads when a large number of pages is latched.
      
      In mysql/mysql-server@9542f3015b00330ef537f6223565b28b82a5b325
      it was claimed that such a hang only affects CREATE FULLTEXT INDEX.
      Their fix was to retain buffer-fix but release exclusive latch
      on non-leaf pages, and subsequently write to those pages while
      they are not associated with the mini-transaction, which would
      trip a debug assertion in the MariaDB version of
      mtr_t::memo_modify_page() and cause potential corruption
      when using the default MariaDB setting innodb_log_optimize_ddl=OFF.
      
      This change essentially backports a small part of
      commit 7cffb5f6 (MDEV-23399)
      from MariaDB Server 10.5.7.
      f21a8756
  8. 26 Apr, 2022 8 commits
    • Sergei Golubchik's avatar
      MDEV-28020 CHECKSUM TABLE calculates different checksums · 39990135
      Sergei Golubchik authored
      Two bugs here:
      
      1. CHECKSUM TABLE asserted that all fields in the table are arranged
         sequentially in the record, but virtual columns are always at the
         end, violating this assertion
      2. virtual columns were not calculated for CHECKSUM, so CHECKSUM
         was using, essentially, garbage left from the previous statement.
         (that's why the test must use INSERT IGNORE to have this "previous
         statement" mark vcols not null)
      
      Fix: don't include virtual columns into the table CHECKSUM. Indeed,
      they cannot be included as the engine does not see virtual columns,
      so in-engine checksum cannot include them, meaning in-server checksum
      should not either
      39990135
    • Oleksandr Byelkin's avatar
      New C/C version · 44e7c312
      Oleksandr Byelkin authored
      *again* after 388032e9 has reverted 25ccf8f6 by mistake
      44e7c312
    • Andrei's avatar
      MDEV-27697. Removed a false assert. · 388032e9
      Andrei authored
      388032e9
    • Alexey Botchkov's avatar
      MDEV-25317 Assertion `scale <= precision' failed in decimal_bin_size And... · eca207c4
      Alexey Botchkov authored
      MDEV-25317 Assertion `scale <= precision' failed in decimal_bin_size And Assertion `scale >= 0 && precision > 0 && scale <= precision' failed in decimal_bin_size_inline/decimal_bin_size.
      
      Precision should be kept below DECIMAL_MAX_SCALE for computations.
      It can be bigger in Item_decimal. I'd fix this too but it changes the
      existing behaviour so problemmatic to ix.
      eca207c4
    • Andrei's avatar
      MDEV-27697. Two affected tests fixed. · 945245ae
      Andrei authored
      A result file is updated in one case and former error simulation got
      refined.
      945245ae
    • Sergei Petrunia's avatar
      MDEV-26047: MariaDB server crash at Item_subselect::init_expr_cache_tracker · 5100b20b
      Sergei Petrunia authored
      The cause of crash:
      remove_redundant_subquery_clauses() removes redundant item expressions.
      The primary goal of this is to remove the subquery items.
      The removal process unlinks the subquery from SELECT_LEX tree, but does
      not remove it from SELECT_LEX:::ref_pointer_array or from JOIN::all_fields.
      Then, setup_subquery_caches() tries to wrap the subquery item in an
      expression cache, which fails, the first reason for failure being that
      the item doesn't have a query plan.
      
      Solution: do not wrap eliminated items with expression cache.
      (also added an assert to check that we do not attempt to execute them).
      
      This may look like an incomplete fix: why don't we remove any mention
      of eliminated item everywhere? The difficulties here are:
      * items can be "un-removed" (see set_fake_select_as_master_processor)
      * it's difficult to remove an element from ref_pointer_array: Item_ref
      objects refer to elements of that array, so one can't shift elements in
      it. Replacing eliminated subselect with a dummy Item doesn't look like a
      good idea, either.
      5100b20b
    • Rucha Deodhar's avatar
      MDEV-20207: Assertion ! is_set() failed in Diagnostics_area::set_eof_status · 9b2d3666
      Rucha Deodhar authored
      upon HANDLER READ
      
      Analysis: The error state is not stored while checking condition and key
      name.
      Fix: Return true while checking condition and key name if error is reported
      because geometry object can't be created from the data in the index value
      for HANDLER READ.
      9b2d3666
    • Oleksandr Byelkin's avatar
      New CC version · 25ccf8f6
      Oleksandr Byelkin authored
      25ccf8f6
  9. 25 Apr, 2022 8 commits
    • Sergei Golubchik's avatar
      MDEV-6899 extra semicolon in show create event syntax · 3988dfff
      Sergei Golubchik authored
      to detect the end of SP definition correctly we need to know where
      the parser stopped parsing the SP. lip->get_cpp_ptr() shows the
      current parsing position, lip->get_cpp_tok_start() shows the start of
      the last parsed token. The actual value depends on whether
      the parser has performed a look-ahead. For example, in
      
        CREATE PROCEDURE ... BEGIN ... END ;
      
      the parser reads 'END' and knows that this ends the procedure definition,
      it does not need to read the next token for this. But in
      
        CREATE PROCEDURE ... SELECT 1 ;
      
      the parser cannot know that the procedure ends at '1'. It has to read
      the semicolon first (it could be '1 + 2' for example).
      
      In the first case, the "current parsing position" is after END, before
      the semicolon, in the second case it's *after* the semicolon. Note that
      SP definition in both cases ends before the semicolon.
      
      To be able to detect the end of SP deterministically, we need the parser
      to do the look-ahead always or never.
      
      The bug fix introduces a new parser token FORCE_LOOKAHEAD. Lexer never
      returns it, so this token can never match. But the parser cannot know
      it so it will have to perform a look-ahead to determine that the next
      token is not FORCE_LOOKAHEAD. This way we deterministically end
      SP parsing with a look-ahead.
      3988dfff
    • Sergei Golubchik's avatar
      7753eae1
    • Sergei Golubchik's avatar
      cleanup: main.create_select test · 1a94d2fd
      Sergei Golubchik authored
      1a94d2fd
    • Sergei Golubchik's avatar
      MDEV-28403 ASAN heap-use-after-free in String::copy / get_field_default_value · 9b7886bb
      Sergei Golubchik authored
      This reverts commit 5ba77222
      but keeps the test. A different fix for
      
      MDEV-21028 Server crashes in Query_arena::set_query_arena upon SELECT from view
      
      internal temporary tables should use THD as expr_area
      9b7886bb
    • Igor Babaev's avatar
      MDEV-27212 Crash in Item_equal::sort on second execution of stored procedure · c5e68b6d
      Igor Babaev authored
      This bug could cause a crash of the server at the second call of a stored
      procedure when it executed a query containing a mergeable derived table /
      view whose specification used another mergeable derived_table or view and a
      subquery with outer reference in the select list of the specification.
      Such queries could cause the same problem when they were executed for the
      second time in a prepared mode.
      The problem appeared due to a typo mistake in the legacy code of the function
      create_view_field() that prevented building Item_direct_view_ref wrapper
      for the mentioned outer reference at the second execution of the query and
      setting the depended_from field for the outer reference.
      
      Approved by Oleksandr Byelkin <sanja@mariadb.com>
      c5e68b6d
    • Andrei's avatar
      MDEV-27697 slave must recognize incomplete replication event group · 1bcdc3e9
      Andrei authored
      In cases of a faulty master or an incorrect binlog event producer, that slave is working with,
      sends an incomplete group of events slave must react with an error to not to log
      into the relay-log any new events that do not belong to the incomplete group.
      
      Fixed with extending received event properties check when slave connects to master
      in gtid mode.
      Specifically for the event that can be a part of a group its relay-logging is
      permitted only when its position within the group is validated.
      Otherwise slave IO thread stops with ER_SLAVE_RELAY_LOG_WRITE_FAILURE.
      1bcdc3e9
    • Alexander Barkov's avatar
    • Alexander Barkov's avatar
      MDEV-28405 main.information_schema_tables fails sporadically with... · 3fec38d9
      Alexander Barkov authored
      MDEV-28405 main.information_schema_tables fails sporadically with ER_NEED_REPREPARE or extra warning
      3fec38d9
  10. 24 Apr, 2022 1 commit
  11. 23 Apr, 2022 1 commit
    • Daniel Black's avatar
      MDEV-28263 mariadb-tzinfo-to-sql binlog fixes · a7923b37
      Daniel Black authored
      The --skip-write-binlog message was confusing that it only had
      an effect if the galera was enabled. There are uses beyond galera
      so we apply SET SESSION SQL_LOG_BIN=0 as implied by the option
      without being conditional on the wsrep status.
      
      Remove wsrep.mysql_tzinfo_to_sql_symlink{,_skip} tests as they offered
      no additional coverage beyond main.mysql_tzinfo_to_sql_symlink as no
      server testing was done.
      
      Introduced a variant of the galera.mariadb_tzinfo_to_sql as
      galera.mysql_tzinfo_to_sql, which does testing using the mysql client
      rather than directly importing into the server via mysqltest.
      
      Update man page and mysql_tzinfo_to_sql to having a --skip-write-binlog
      option.
      
      merge notes:
      10.4:
      - conflicts in tztime.cc can revert to this version of --help text.
      - tztime.cc - merge execute immediate @prep1, and leave %s%s trunc_tables, lock_tables
        after that.
      10.6:
      - Need to remove the not_embedded.inc in mysql_tzinfo_to_sql.test and
        replace it with no_protocol.inc
      - leave both mysql_tzinfo_to_sql.test and mariadb_tzinfo_to_sql.sql
        tests.
      - sql/tztime.cc - keep entirely 10.6 version.
      a7923b37
  12. 22 Apr, 2022 2 commits
    • Dmitry Shulga's avatar
      MDEV-27758: Errors when building Connect engine on os x 11.6.2 · bc7ba7af
      Dmitry Shulga authored
      Added checking for support of vfork by a platform where
      building being done. Set HAVE_VFORK macros in case vfork()
      system call is supported. Use vfork() system call if the
      macros HAVE_VFORK is set, else use fork().
      bc7ba7af
    • Sergei Petrunia's avatar
      MDEV-25994: Crash with union of my_decimal type in ORDER BY clause · 3c209bfc
      Sergei Petrunia authored
      When single-row subquery fails with "Subquery reutrns more than 1 row"
      error, it will raise an error and return NULL.
      
      On the other hand, Item_singlerow_subselect sets item->maybe_null=0
      for table-less subqueries like "(SELECT not_null_value)"  (*)
      
      This discrepancy (item with maybe_null=0 returning NULL) causes the
      code in Type_handler_decimal_result::make_sort_key_part() to crash.
      
      Fixed this by allowing inference (*) only when the subquery is NOT a
      UNION.
      3c209bfc
  13. 21 Apr, 2022 1 commit
  14. 20 Apr, 2022 1 commit
  15. 19 Apr, 2022 1 commit