1. 03 May, 2023 2 commits
  2. 02 May, 2023 7 commits
    • Monty's avatar
      MDEV-6768 Wrong result with aggregate with join with no result set · 7f96dd50
      Monty authored
      When a query does implicit grouping and join operation produces an empty
      result set, a NULL-complemented row combination is generated.
      However, constant table fields still show non-NULL values.
      
      What happens in the is that end_send_group() is called with a
      const row but without any rows matching the WHERE clause.
      This last part is shown by 'join->first_record' not being set.
      
      This causes item->no_rows_in_result() to be called for all items to reset
      all sum functions to their initial state. However fields are not set
      to NULL.
      
      The used fix is to produce NULL-complemented records for constant tables
      as well. Also, reset the constant table's records back in case we're
      in a subquery which may get re-executed.
      An alternative fix would have item->no_rows_in_result() also work
      with Item_field objects.
      
      There is some other issues with the code:
      - join->no_rows_in_result_called is used but never set.
      - Tables that are used with group functions are not properly marked as
        maybe_null, which is required if the table rows should be regarded as
        null-complemented (not existing).
      - The code that tries to detect if mixed_implicit_grouping should be set
        didn't take into account all usage of fields and sum functions.
      - Item_func::restore_to_before_no_rows_in_result() called the wrong
        function.
      - join->clear() does not use a table_map argument to clear_tables(),
        which caused it to ignore constant tables.
      - unclear_tables() does not correctly restore status to what is
        was before clear_tables().
      
      Main bug fix was to always use a table_map argument to clear_tables() and
      always use join->clear() and clear_tables() together with unclear_tables().
      
      Other fixes:
      - Fixed Item_func::restore_to_before_no_rows_in_result()
      - Set 'join->no_rows_in_result_called' when no_rows_in_result_set()
        is called.
      - Removed not used argument from setup_end_select_func().
      - More code comments
      - Ensure that end_send_group() modifies the same fields as are in the
        result set.
      - Changed return_zero_rows() to use pointers instead of references,
        similar to the rest of the code.
      7f96dd50
    • Monty's avatar
      Fixed "Trying to lock uninitialized mutex' in parallel replication · 4f731757
      Monty authored
      The problem was that mutex_init() was called after the worker was
      put into the domain_hash, which allowed other threads to access it
      before mutex was initialized.
      4f731757
    • Monty's avatar
      MDEV-28054 Various crashes upon INSERT/UPDATE after changing Aria settings · 4cb0d43a
      Monty authored
      The cause of the crash was that test was setting
      aria_sort_buffer_size to MAX_LONG_LONG, which caused an overflow in
      my_malloc() when trying to allocate the buffer + 8 bytes.
      
      Fixed by reducing max size of sort_buffer for Aria and MyISAM
      
      Other things:
      - Added code in maria_repair_parallell() to not allocate a big sort buffer
        for small files.
      - Updated size of minumim sort buffer in Aria
      4cb0d43a
    • Monty's avatar
      MDEV-26258 Various crashes/asserts/corruptions when Aria encryption is... · 1ef22e28
      Monty authored
      MDEV-26258 Various crashes/asserts/corruptions when Aria encryption is enabled/used, but the encryption plugin is not loaded
      
      The reason for the MDEV reported failures is that the tests are enabling
      encryption for Aria but not providing any encryption keys.
      
      Fixed by checking if encryption keys exists before creating the table.
      
      Other things:
      - maria.encrypt_wrong-key changed as we now get the error on CREATE
        instead during insert.
      1ef22e28
    • Julius Goryavsky's avatar
      wsrep-lib external submodule update · c6ef9b1c
      Julius Goryavsky authored
      c6ef9b1c
    • Daniele Sciascia's avatar
      MDEV-30838 Assertion `m_thd == _current_thd()' · ef227762
      Daniele Sciascia authored
      - Update wsrep-lib which contains fix for the assertion
      - Fix error handling for appending fragment to streaming log,
        make sure tables are closed after rollback.
      Signed-off-by: default avatarJulius Goryavsky <julius.goryavsky@mariadb.com>
      ef227762
    • sara's avatar
      MDEV-30414 sporadic failures with galera var retry autocommit · 4e942bcd
      sara authored
      changed tast case 2 to be deterministic
      Signed-off-by: default avatarJulius Goryavsky <julius.goryavsky@mariadb.com>
      4e942bcd
  3. 29 Apr, 2023 2 commits
  4. 28 Apr, 2023 4 commits
    • Angelique's avatar
      MDEV-30221: Move environmental macros to before master-slave · 1963a87b
      Angelique authored
      The fix was introduced, along with re-ordering to do other macros that check test environment capabilities before master/slave is set up.
      1963a87b
    • Sergei Petrunia's avatar
      MDEV-31067: selectivity_from_histogram >1.0 for a DOUBLE_PREC_HB histogram · 85cc8318
      Sergei Petrunia authored
      Variant #2.
      
      When Histogram::point_selectivity() sees that the point value of interest
      falls into one bucket, it tries to guess whether the bucket has many
      different (unpopular) values or a few popular values. (The number of
      rows is fixed, as it's a Height-balanced histogram).
      The basis for this guess is the "width" of the value range the bucket
      covers. Buckets covering wider value ranges are assumed to contain
      values with proportionally lower frequencies.
      
      This is just a [brave] guesswork. For a very narrow bucket, it may
      produce an estimate that's larger than total #rows in the bucket
      or even in the whole table.
      
      Remove the guesswork and replace it with basic logic: return
      either the per-table average selectivity of col=const, or selectivity
      of one bucket, whichever is lower.
      85cc8318
    • Sergei Golubchik's avatar
      MDEV-22756 SQL Error (1364): Field 'DB_ROW_HASH_1' doesn't have a default value · bc970573
      Sergei Golubchik authored
      exclude generated columns from the "has default value" check
      bc970573
    • Oleg Smirnov's avatar
      MDEV-31113 Server crashes in store_length /... · adbad5e3
      Oleg Smirnov authored
      MDEV-31113 Server crashes in store_length / Type_handler_string_result::make_sort_key with DISTINCT and group function
      
      Fix-up for commit 476b24d0
        Author: Monty
        Date:   Thu Feb 16 14:19:33 2023 +0200
          MDEV-20057 Distinct SUM on CROSS JOIN and grouped returns wrong result
      which misses initializing of sorder->suffix_length.
      In this commit the initialization is implemented by passing
      MY_ZEROFILL flag to the allocation of SORT_FIELD elements
      adbad5e3
  5. 27 Apr, 2023 2 commits
  6. 26 Apr, 2023 5 commits
  7. 25 Apr, 2023 2 commits
    • Andrei's avatar
      MDEV-30620 Trying to lock uninitialized LOCK_parallel_entry · e22a57da
      Andrei authored
      The error was seen by a number of mtr tests being caused
      by overdue initialization of rpl_parallel::LOCK_parallel_entry.
      Specifically, SHOW-SLAVE-STATUS might find in
      rpl_parallel::workers_idle() a gtid domain hash entry
      already inserted whose mutex had not done
      mysql_mutex_init().
      
      Fixed with swapping the mutex init and the its entry's stack insertion.
      
      Tested with a generous number of `mtr --repeat` of a few of the reported
      to fail tests, incl rpl.parallel_backup.
      e22a57da
    • Sergei Petrunia's avatar
      MDEV-31121: ANALYZE statement produces 0 for all timings in embedded server · a72b2c3f
      Sergei Petrunia authored
      Timers require my_timer_init() call.
      It was made only in mysqld_main(). Call it also from init_embedded_server().
      a72b2c3f
  8. 24 Apr, 2023 5 commits
    • Brandon Nesterenko's avatar
      MDEV-30430: Enabling system versioning on tables without primary key breaks replication · 29fb0410
      Brandon Nesterenko authored
      When replicating MDL events for a table that uses system versioning
      without primary keys, ensure that for data sets with duplicate
      records, the updates to these records with duplicates are enacted on
      the correct row. That is, there was a bug (reported in MDEV-30430)
      such that the function to find the row to update would stop after
      finding the first matching record. However, in the absence of
      primary keys, the version of the record is needed to compare the row
      to ensure we are updating the correct one.
      
      The fix, therefore, updates the record comparison functionality to
      use system version columns when there are no primary keys on the
      table.
      
      Reviewed By:
      ============
      Andrei Elkin <andrei.elkin@mariadb.com>
      29fb0410
    • Brandon Nesterenko's avatar
      MDEV-28798: Cosmetic Changes Only · 4ec3dca3
      Brandon Nesterenko authored
      Removed trailing whitespaces
      4ec3dca3
    • Brandon Nesterenko's avatar
      MDEV-28798: Previously Binlog Encrypted Master Segfaults on Binlog Dump with Using_Gtid=Slave_Pos · d3e7dba3
      Brandon Nesterenko authored
      Problem:
      ========
      A master can segfault if it can't set up decryption for its binary
      log during a binlog dump with Using_Gtid=Slave_Pos. If slave
      connects using GTID mode, the master will call into
      log.cc::get_gtid_list_event(), which iterate through binlog events
      looking for a Gtid_list_log_event. On an encrypted binlog that the
      master cannot decrypt, the first event will be a
      START_ENCRYPTION_EVENT which will call into the following decryption branch
      
      if (fdle->start_decryption((Start_encryption_log_event*) ev))
        errormsg= ‘Could not set up decryption for binlog.’;
      
      The event iteration however, does not stop in spite of this error.
      The master will try to read the next event, but segfault while
      trying to decrypt it because decryption failed to initialize.
      
      Solution:
      ========
      Break the event iteration if decryption cannot be set up.
      
      Reviewed By:
      ============
      Andrei Elkin <andrei.elkin@mariadb.com>
      d3e7dba3
    • Igor Babaev's avatar
      MDEV-31102 Crash when pushing condition into view defined as union · 5dc9a6b4
      Igor Babaev authored
      This bug could manifest itself at the first execution of prepared statement
      created for queries using a materialized view defined as union. A crash
      could happen for sure if the query contained a condition pushable into
      the view and this condition was over the column defined via a complex string
      expression requiring implicit conversion from one charset to another for
      some of its sub-expressions. The bug could cause crashes when executing
      PS for some other queries whose optimization needed building clones for
      such expressions.
      
      This bug was introduced in the patch for MDEV-29988 where the class
      Item_direct_ref_to_item was added. The implementations of the virtual
      methods get_copy() and build_clone() were invalid for the class and this
      could cause crashes after the method build_clone() was called for
      expressions containing objects of the Item_direct_ref_to_item type.
      
      Approved by Sergei Golubchik <serg@mariadb.com>
      5dc9a6b4
    • Alexander Barkov's avatar
      A cleanup for MDEV-30968 mariadb-backup does not copy Aria logs if aria_log_dir_path is used · d3e394b3
      Alexander Barkov authored
      Fixing buildbot failures on mariabackup.aria_log_dir_path_rel.
      
      The problem was that directory_exists() was called with the
      relative aria_log_dir_path value, while the current directory
      in mariadb-backup is not necessarily equal to datadir when MTR is running.
      
      Fix:
      
      - Moving building the absolute path un level upper:
        from the function copy_back_aria_logs() to the function copy_back().
      - Passing the built absolute path to both directory_exists() and
        copy_back_aria_logs() as a parameter.
      d3e394b3
  9. 22 Apr, 2023 1 commit
  10. 21 Apr, 2023 3 commits
    • Alexander Barkov's avatar
      MDEV-30968 mariadb-backup does not copy Aria logs if aria_log_dir_path is used · 9f98a2ac
      Alexander Barkov authored
      - `mariadb-backup --backup` was fixed to fetch the value of the
         @@aria_log_dir_path server variable and copy aria_log* files
         from @@aria_log_dir_path directory to the backup directory.
         Absolute and relative (to --datadir) paths are supported.
      
         Before this change aria_log* files were copied to the backup
         only if they were in the default location in @@datadir.
      
      - `mariadb-backup --copy-back` now understands a new my.cnf and command line
         parameter --aria-log-dir-path.
      
        `mariadb-backup --copy-back` in the main loop in copy_back()
         (when copying back from the backup directory to --datadir)
         was fixed to ignore all aria_log* files.
      
         A new function copy_back_aria_logs() was added.
         It consists of a separate loop copying back aria_log* files from
         the backup directory to the directory specified in --aria-log-dir-path.
         Absolute and relative (to --datadir) paths are supported.
         If --aria-log-dir-path is not specified,
         aria_log* files are copied to --datadir by default.
      
      - The function is_absolute_path() was fixed to understand MTR style
        paths on Windows with forward slashes, e.g.
         --aria-log-dir-path=D:/Buildbot/amd64-windows/build/mysql-test/var/...
      9f98a2ac
    • Daniel Black's avatar
      MDEV-30713 field length handling for CONNECT engine · da1c91fb
      Daniel Black authored
      fp->field_length was unsigned and therefore the negative
      condition around it.
      
      Backport of cc182aca fixes it, however to correct the
      consistent use of types pcf->Length needs to be unsigned
      too.
      
      At one point pcf->Precision is assigned from pcf->Length so
      that's also unsigned.
      
      GetTypeSize is assigned to length and has a length argument.
      A -1 default value seemed dangerious to case, so at least 0
      should assert if every hit.
      da1c91fb
    • Oleksandr Byelkin's avatar
      Merge branch '10.3' into 10.4 · 3d27f6d7
      Oleksandr Byelkin authored
      3d27f6d7
  11. 20 Apr, 2023 1 commit
    • Mikhail Chalov's avatar
      Minimize unsafe C functions usage - replace strcat() and strcpy() · fc6e8a3d
      Mikhail Chalov authored
      Similar to 567b6812 continue to replace use of strcat() and
      strcpy() with safer options strncat() and strncpy().
      
      All new code of the whole pull request, including one or several files
      that are either new files or modified ones, are contributed under the BSD-new
      license. I am contributing on behalf of my employer Amazon Web Services
      fc6e8a3d
  12. 19 Apr, 2023 5 commits
  13. 18 Apr, 2023 1 commit
    • Daniele Sciascia's avatar
      MDEV-30955 Explicit locks released too early in rollback path · feeeacc4
      Daniele Sciascia authored
      Assertion `thd->mdl_context.is_lock_owner()` fires when a client is
      disconnected, while transaction and and a table is opened through
      `HANDLER` interface.
      Reason for the assertion is that when a connection closes, its ongoing
      transaction is eventually rolled back in
      `Wsrep_client_state::bf_rollback()`. This method also releases explicit
      which are expected to survive beyond the transaction lifetime.
      This patch also removes calls to `mysql_ull_cleanup()`. User level
      locks are not supported in combination with Galera, making these calls
      unnecessary.
      feeeacc4