1. 03 Oct, 2022 1 commit
    • Rucha Deodhar's avatar
      Crash in INSERT...SELECT..RETURNING with subquery · 7865c8c9
      Rucha Deodhar authored
      Underlying causes of all bugs mentioned below are same. This patch fixes
      all of them:
      1) MDEV-25028: ASAN use-after-poison in
      base_list_iterator::next or Assertion `sl->join == 0' upon
      INSERT .. RETURNING via PS
      2) MDEV-25187: Assertion `inited == NONE || table->open_by_handler'
      failed or Direct leak in init_dynamic_array2 upon INSERT .. RETURNING
      and memory leak in init_dynamic_array2
      3) MDEV-28740: crash in INSERT RETURNING subquery in prepared statements
      4) MDEV-27165: crash in base_list_iterator::next
      5) MDEV-29686: Assertion `slave == 0' failed in
      st_select_lex_node::attach_single
      
      Analysis:
      consider this statement:
      INSERT(1)...SELECT(2)...(SELECT(3)...) RETURNING (SELECT(4)...)
      
      When RETURNING is encountered, add_slave() changes how selects are linked.
      It makes the builtin_select(1) slave of SELECT(2). This causes
      losing of already existing slave(3) (which is nested select of SELECT of
      INSERT...SELECT). When really, builtin_select (1) shouldn't be slave to
      SELECT(2) because it is not nested within it. Also, push_select() to use
      correct context also changed how select are linked.
      During reinit_stmt_before_use(), we expect the selects to
      be cleaned-up and have join=0. Since these selects are not linked correctly,
      clean-up doesn't happen correctly so join is not NULL. Hence the crash.
      
      Fix:
      IF we are parsing RETURNING, make is_parsing_returning= true for
      current select. get rid of add_slave(). In place of push_select(), used
      push_context() to have correct context (the context of builtin_select)
      to resolve items in item_list. And add these items to item_list of
      builtin_select.
      7865c8c9
  2. 02 Oct, 2022 1 commit
  3. 01 Oct, 2022 3 commits
  4. 30 Sep, 2022 6 commits
  5. 29 Sep, 2022 3 commits
    • Sergei Golubchik's avatar
      correctness assert · 6b685ea7
      Sergei Golubchik authored
      thd_get_ha_data() can be used without a lock, but only from the
      current thd thread, when calling from anoher thread it *must*
      be protected by thd->LOCK_thd_data
      
      * fix group commit code to take thd->LOCK_thd_data
      * remove innobase_close_connection() from the innodb background thread,
        it's not needed after 87775402 and was failing the assert with
        current_thd==0
      6b685ea7
    • Sergei Golubchik's avatar
      fix sporadic failures on main.kill · f9605eb2
      Sergei Golubchik authored
      KILL QUERY ID 0 was sometimes finding con3 that was still in the process
      of disconnecting and had query_id==0 (as it didn't run any queries)
      f9605eb2
    • Igor Babaev's avatar
      MDEV-29361 Infinite recursive calls when detecting CTE dependencies · 28ae3618
      Igor Babaev authored
      This patch resolves the problem of improper name resolution of table
      references to embedded CTEs for some queries. This improper binding could
      lead to
        - infinite sequence of calls of recursive functions
        - crashes due to resolution of null pointers
        - wrong result sets returned by queries
        - bogus error messages
      
      If the definition of a CTE contains with clauses then such CTE is called
      embedding CTE while CTEs from the with clauses are called embedded CTEs.
      If a table reference used in the definition of an embedded CTE cannot be
      resolved within the unit that contains this reference it still may be
      resolved against a CTE definition from the with clause with one of the
      embedding CTEs.
      A table reference can be resolved against a CTE definition if it used in
      the the scope of this definition and it refers to the name of the CTE.
      Table reference t is in the scope of the CTE definition of CTE cte if
      - the definition of cte is an element of a with clause declared as
        RECURSIVE and the reference t belongs either to the unit to which
        this with clause is attached or to one of the elements of this clause
      - the definition of cte is an element of a with clause without RECURSIVE
        specifier and the reference t belongs either to the unit to which this
        with clause is attached or to one of the elements from this clause that
        are placed before the definition of cte.
      If a table reference can be resolved against several CTE definitions then
      it is bound to the most embedded.
      
      The code before this patch not always resolved table references used in
      embedded CTE according to the above rules.
      
      Approved by Oleksandr Byelkin <sanja@mariadb.com>
      28ae3618
  6. 28 Sep, 2022 5 commits
    • Sergei Golubchik's avatar
      MDEV-29368 Assertion `trx->mysql_thd == thd' failed in innobase_kill_query... · de130323
      Sergei Golubchik authored
      MDEV-29368 Assertion `trx->mysql_thd == thd' failed in innobase_kill_query from process_timers/timer_handler and use-after-poison in innobase_kill_query
      
      This is a 10.5 version of 9b750dcb, fix for
      MDEV-23536 Race condition between KILL and transaction commit
      
      InnoDB needs to remove trx from thd before destroying it (trx), otherwise
      a concurrent KILL might get a pointer from thd to a destroyed trx.
      
      ha_close_connection() should allow engines to clear ha_data in
      hton->on close_connection(). To prevent the engine from being unloaded
      while hton->close_connection() is running, we remove the lock from
      ha_data and unlock the plugin manually.
      de130323
    • Sergei Golubchik's avatar
      cleanup: kill test · 74ac683a
      Sergei Golubchik authored
      split it into debug and non-debug tests
      74ac683a
    • Sergei Golubchik's avatar
      debug_sync: ignore "sort" kills and disconnects · d7d3ad69
      Sergei Golubchik authored
      only "hard" kills will now interrupt debug_sync waits.
      this is needed to have debug_sync points that work during disconnect
      d7d3ad69
    • Mikhail Chalov's avatar
      Use memory safe snprintf() in Connect Engine and elsewhere (#2210) · 9de9f105
      Mikhail Chalov authored
      Continue with similar changes as done in 19af1890 to replace sprintf(buf, ...)
      with snprintf(buf, sizeof(buf), ...), specifically in the "easy" cases where buf
      is allocated with a size known at compile time.
      
      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, Inc.
      9de9f105
    • Daniel Black's avatar
      MDEV-29614 mariadb-upgrade calls mysql and mysql-check (#2279) · 620d520d
      Daniel Black authored
      rather than mariadb/mariadb-check
      620d520d
  7. 27 Sep, 2022 2 commits
  8. 26 Sep, 2022 9 commits
  9. 23 Sep, 2022 4 commits
    • Marko Mäkelä's avatar
      Fix build without either ENABLED_DEBUG_SYNC or DBUG_OFF · 3c92050d
      Marko Mäkelä authored
      There are separate flags DBUG_OFF for disabling the DBUG facility
      and ENABLED_DEBUG_SYNC for enabling the DEBUG_SYNC facility.
      Let us allow debug builds without DEBUG_SYNC.
      
      Note: For CMAKE_BUILD_TYPE=Debug, CMakeLists.txt will continue to
      define ENABLED_DEBUG_SYNC.
      3c92050d
    • Andrew Hutchings's avatar
      MDEV-25767 Fix CONNECT ODBC WHERE condition crash (#2243) · 66cd1c33
      Andrew Hutchings authored
      When an UPDATE or DELETE was executed with a WHERE condition it would
      crash the MariaDB server. This is because the code expects the WHERE
      condition to have generated a query string but it hasn't.
      
      Also updates the ODBC test results for current MariaDB version.
      66cd1c33
    • Marko Mäkelä's avatar
      Merge 10.3 into 10.4 · 13eae188
      Marko Mäkelä authored
      13eae188
    • Marko Mäkelä's avatar
      MDEV-29613 Improve WITH_DBUG_TRACE=OFF · a69cf6f0
      Marko Mäkelä authored
      In commit 28325b08
      a compile-time option was introduced to disable the macros
      DBUG_ENTER and DBUG_RETURN or DBUG_VOID_RETURN.
      
      The parameter name WITH_DBUG_TRACE would hint that it also
      covers DBUG_PRINT statements. Let us do that: WITH_DBUG_TRACE=OFF
      shall disable DBUG_PRINT() as well.
      
      A few InnoDB recovery tests used to check that some output from
      DBUG_PRINT("ib_log", ...) is present. We can live without those checks.
      
      Reviewed by: Vladislav Vaintroub
      a69cf6f0
  10. 22 Sep, 2022 3 commits
  11. 21 Sep, 2022 2 commits
    • Alexey Botchkov's avatar
      Backport fix for MDEV-29352 to 10.3-10.5 · f5e4e154
      Alexey Botchkov authored
      The fix for MDEV-29352 was pushed to 10.6+ but the code causing the
      bug is old and the bug is unlikely to be a recent regression in 10.6.
      So, we apply the fix also to older versions, 10.3-10.5.
      
      The original commit message:
      
      MDEV-29352 SIGSEGV's in strlen and unknown location on optimized builds at SHUTDOWN
      
      When the UDF creation frails to write the newly created UDF into
      the related system table, the UDF is still created in memory.
      
      However, as it is now, the related DLL is unloaded in this case right
      in the mysql_create_function. And failure happens when the UDF handle
      is freed and tries to unload the respective DLL which is still unloaded.
      f5e4e154
    • Ian Gilfillan's avatar
      MDEV-29275 Fix server/Docs typos · b9c1c07f
      Ian Gilfillan authored
      b9c1c07f
  12. 20 Sep, 2022 1 commit