1. 13 Oct, 2022 1 commit
    • Oleg Smirnov's avatar
      MDEV-20609 Full table scan in INFORMATION_SCHEMA.PARAMETERS/ROUTINES · beb9a545
      Oleg Smirnov authored
      Queries to INFORMATION_SCHEMA.PARAMETERS and ROUTINES tables are always
      performed using full index scan of the mysql.proc primary key
      on fields (`db`,`name`,`type`). This can be done in a much more effective
      way if `db` and `name` field values can be derived from the WHERE statement,
      like here:
        SELECT * FROM INFORMATION_SCHEMA.PARAMETERS
          WHERE SPECIFIC_SCHEMA = 'test' AND SPECIFIC_NAME = 'my_func'
      or here:
        SELECT * FROM information_schema.ROUTINES
          WHERE ROUTINE_SCHEMA='test' AND ROUTINE_NAME='my_func'.
      
      In such cases index range scan may be employed instead of full index
      scan. This commit makes the server retrieve lookup field values from
      the SQL statement and perform index range scan instead of full index
      scan if possible.
      beb9a545
  2. 04 Oct, 2022 10 commits
  3. 03 Oct, 2022 2 commits
    • Oleksandr Byelkin's avatar
      Merge branch '10.5' into 10.6 · fe449aff
      Oleksandr Byelkin authored
      fe449aff
    • 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
  4. 02 Oct, 2022 2 commits
  5. 01 Oct, 2022 3 commits
  6. 30 Sep, 2022 10 commits
  7. 29 Sep, 2022 9 commits
    • Aleksey Midenkov's avatar
      MDEV-29620 Assertion `next_insert_id == 0' failed in handler::ha_external_lock · aa08a744
      Aleksey Midenkov authored
      ha_release_auto_increment() must be done before F_UNLCK.
      Non-atomic case is handled by select_insert::binlog_query().
      aa08a744
    • Aleksey Midenkov's avatar
      MDEV-29628 Memory leak after CREATE OR REPLACE with foreign key · c579d66b
      Aleksey Midenkov authored
      MDEV-28933 added a condition to avoid keeping cached foreign keys when
      renaming into temporary table. Such foreign keys must be freed.
      c579d66b
    • Aleksey Midenkov's avatar
      MDEV-29609 create_not_windows test fails with different result · cb583b2f
      Aleksey Midenkov authored
      make_tmp_name() creates temporary name with prefix containing PID and
      TID. This prefix influences max length of the rest of the name (the
      whole name is limited by NAME_LEN). During the test run PID and TID
      can change. PID increases when the server restarts. TID is incremented
      with the new connections (generated by next_thread_id(), is not the
      posix thread ID).
      
      During the test run PID can increase max 2 decimal positions: from
      tens to thousands this requires ~900 restarts. TID depends on
      connection count, but for test we assume it will not trespass 100000
      connections which is 5 decimal positions. So it should be enough to
      reserve 7 characters for PID and TID increment.
      
      The patch reserves more: it reserves 12 characters for 7-decimal PID
      and 5-decimal TID plus 4 chars of additional reserve (for future
      prefix changes) and assumes minimal legth of the prefix is 30 bytes:
      
      #sql-backup-PID-TID-
      #sql-create-PID-TID-
      
      4-6-PID-TID- is 10 + 4 + PID + TID, so PID + TID is 16 chars (7 + 5 + 4).
      cb583b2f
    • Aleksey Midenkov's avatar
      MDEV-29544 SIGSEGV in HA_CREATE_INFO::finalize_locked_tables · dcd66c38
      Aleksey Midenkov authored
      Usually when we get into finalize_locked_tables() with error
      m_locked_tables_count was not decremented. m_locked_tables_count is
      decremented when we drop the original table and if we failed that
      m_locked_tables_count is expected intact.
      
      The bug comes from the fact that finalize_atomic_replace() violates
      the above contract. It does HA_EXTRA_PREPARE_FOR_DROP and decrements
      m_locked_tables_count. Then it tries rename_table_and_triggers() and
      fails. With decremented m_locked_tables_count reopen_tables() does
      nothing and we don't get new value for pos_in_locked_tables->table.
      
      The test case demonstrates ER_ERROR_ON_RENAME where non-atomic CREATE
      OR REPLACE would not fail. The original RENAME TABLE fails under such
      broken environment, so nothing is wrong with atomic CREATE OR REPLACE
      failing there too.
      dcd66c38
    • Sergei Golubchik's avatar
      MDEV-29608 Default SSL makes mysqlslap much slower, tests fail with timeout · 1ac8149b
      Sergei Golubchik authored
      mysqlslap has an unusual semantics of the --iterations option, so that
      $ mysqlslap --concurrency=16 --iterations=1000
      performs 16,000 connections. Because of that it gets many times slower
      with --ssl
      
      Let's disable ssl for mysqlslap in mysql-test
      1ac8149b
    • Sergei Golubchik's avatar
      after merge update *.result · 530d19a3
      Sergei Golubchik authored
      530d19a3
    • 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
  8. 28 Sep, 2022 3 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