1. 14 Apr, 2021 4 commits
  2. 13 Apr, 2021 8 commits
    • Julius Goryavsky's avatar
      MDEV-25307: The value of the auto-increment variables changes during the test · 9ff737b2
      Julius Goryavsky authored
      Part #2, specifically for the 10.5+ branch:
      
      The auto-increment parameters can change sporadically during the
      execution of the mtr test "galera_vote_rejoin_ddl", causing it to
      fail. This patch creates an environment where unpredictable changes
      to these auto-increment settings do not occur during the test.
      9ff737b2
    • Sergei Golubchik's avatar
      -DMYSQL_MAINTAINER_MODE=NO · 55a7682a
      Sergei Golubchik authored
      also add =WARN as an alias for =OFF
      and clarify the help text
      55a7682a
    • Marko Mäkelä's avatar
      MDEV-24745 Generic CRC-32C computation wrongly uses SSE4.2 instructions · 58f184a4
      Marko Mäkelä authored
      In commit d25f806d (MDEV-22749)
      the CRC-32C implementation of MariaDB was broken on some
      IA-32 and AMD64 builds, depending on the compiler version and
      build options. This was verified for IA-32 on GCC 10.2.1.
      
      Even though we try to identify the SSE4.2 extensions and the
      availaibility of the PCLMULQDQ instruction by executing CPUID,
      the fall-back code could be generated with extended instructions,
      because the entire file mysys/crc32/crc32c.c was being compiled
      with -msse4.2 -mpclmul. This would cause SIGILL on a PINSRD
      instruction on affected IA-32 targets (such as some Intel Atom
      processors). This might also affect old AMD64 processors
      (predating the 2007 Intel Nehalem microarchitecture), if some
      compiler chose to emit the offending instructions.
      
      While it is fine to pass a target-specific option to a target-specific
      compilation unit (like -mpclmul to a PCLMUL-specific compilation unit),
      that is not safe for mixed-architecture compilation units.
      
      For mixed-architecture compilation units, the correct way is to set
      target attributes on the target-specific functions.
      
      There does not seem to be a way to pass target attributes to
      function template instantiation. Hence, we must replace the
      ExtendImpl template with plain functions crc32_sse42() and
      crc32_slow().
      
      We will also remove some inconsistency between
      my_crc32_implementation() and mysys_namespace::crc32::Choose_Extend().
      
      The function crc32_pclmul_enabled() will be moved to mysys/crc32/crc32c.cc
      so that the detection code will be compiled without -msse4.2 -mpclmul.
      
      The AMD64 PCLMUL accelerated crc32c_3way() will be moved to a new
      file crc32c_amd64.cc. In this way, only a few functions that depend
      on -msse4.2 in mysys/crc32/crc32c.cc can be declared with
      __attribute__((target("sse4.2"))), and most of the file can be compiled
      for the generic target.
      
      Last, the file mysys/crc32ieee.cc will be omitted on 64-bit POWER,
      because it was dead code (no symbols were exported).
      
      Reviewed by: Vladislav Vaintroub
      58f184a4
    • Anel Husakovic's avatar
      MDEV-23015: mariadb-setpermission seems incompatible with DBI:MariaDB · 18a82901
      Anel Husakovic authored
      - Commit 5cc2096f introduced in `10.5` changed DBI:DBD to DBD:MariaDB in this case with redudant `mysql` option.
      - According to database handle (dbh) and `connect` method one should follow
        https://metacpan.org/pod/DBD::MariaDB#Class-Methods with proper created data source name (dsn).
      - Adding socket precedance over port.
      - Adding skipping the comments when reading the `my.cnf` file.
      - MDEV-23016: mariadb-setpermission included
      18a82901
    • Marko Mäkelä's avatar
      MDEV-24620 ASAN heap-buffer-overflow in btr_pcur_restore_position() · b8c8692f
      Marko Mäkelä authored
      Between btr_pcur_store_position() and btr_pcur_restore_position()
      it is possible that purge empties a table and enlarges
      index->n_core_fields and index->n_core_null_bytes.
      Therefore, we must cache index->n_core_fields in
      btr_pcur_t::old_n_core_fields so that btr_pcur_t::old_rec can be
      parsed correctly.
      
      Unfortunately, this is a huge change, because we will replace
      "bool leaf" parameters with "ulint n_core"
      (passing index->n_core_fields, or 0 for non-leaf pages).
      For special cases where we know that index->is_instant() cannot hold,
      we may also pass index->n_fields.
      b8c8692f
    • Marko Mäkelä's avatar
      Merge 10.2 into 10.3 · 6e6318b2
      Marko Mäkelä authored
      6e6318b2
    • Thirunarayanan Balathandayuthapani's avatar
      MDEV-24971 InnoDB access freed virtual column after rollback of secondary index · e262eb16
      Thirunarayanan Balathandayuthapani authored
      - Fixing post-fix failure. In clean_new_vcol_index(), InnoDB has the wrong
      offset to store the virtual column
      e262eb16
    • Dmitry Shulga's avatar
      MDEV-25197: The statement set password=password('') executed in PS mode fails... · 61f84bba
      Dmitry Shulga authored
      MDEV-25197: The statement set password=password('') executed in PS mode fails in case it is run by a user with expired password
      
      A user connected to a server with an expired password
      can't change password with the statement "SET password=..."
      if this statement is run in PS mode. In mentioned use case a user
      gets the error ER_MUST_CHANGE_PASSWORD on attempt to run
      the statement  PREPARE stmt FOR "SET password=...";
      
      The reason of failure to reset password by a locked user using the
      statement PREPARE stmt FOR "SET password=..." is that PS-related
      statements are not listed among the commands allowed for execution
      by a user with expired password. However, simple adding of PS-related
      statements (PREPARE FOR/EXECUTE/DEALLOCATE PREPARE ) to the list of
      statements allowed for execution by a locked user is not enough
      to solve problems, since it opens the opportunity for a locked user
      to execute any statement in the PS mode.
      
      To exclude this opportunity, additional checking that the statement
      being prepared for execution in PS-mode is the SET statement has to be added.
      This extra checking has been added by this patch into the method
      Prepared_statement::prepared() that executed on preparing any statement
      for execution in PS-mode.
      61f84bba
  3. 12 Apr, 2021 10 commits
    • Dmitriy Karpovskiy's avatar
      MDEV-24135: Print warnings in XML, save test retries in XML, save the... · f776fa96
      Dmitriy Karpovskiy authored
      MDEV-24135: Print warnings in XML, save test retries in XML, save the combinations in XML, replace the special symbols in the XML comment
      f776fa96
    • Alexander Barkov's avatar
    • Monty's avatar
      Fixed assert in WSREP if one started with --wsrep_provider=.. --wsrep_on=OFF · e14b6826
      Monty authored
      Assert was:
      mariadbd: /my/maria-10.6/wsrep-lib/src/client_state.cpp:256:
      int wsrep::client_state::after_statement(): Assertion `state() == s_exec'
      
      The reason was because of two faults:
      - A missing test for WSREP(thd) when checking wsrep_after_statement(()
      - THD->wsrep_cs().state was set to s_idle instead of s_none
      e14b6826
    • Oleksandr Byelkin's avatar
      MDEV-25182 Complex query in Store procedure corrupts results · 68e0defc
      Oleksandr Byelkin authored
      At the second execution of the PS
      1. mark_as_dependent() is called with the same parameters as at the first
         execution (select#4 and select#3)
      2. as outer_select (select#3) has been already merged at the first
         execution of PS it cannot be reached using the outer_select() function
         anymore (and so can not stop iteration).
      3. as a result all selects towards the top level select including the
         select for 'ca' are marked as uncacheable.
      4. Marked uncacheable it executed incorrectly triggering filling its
         temporary table several times and using freed memory at the end.
      
      To avoid the problem we use name resolution context to go "up".
      
      NOTE: problem also exists in 10.2 but has no visible effect on execution.
      That is why the problem is fixed in 10.2.
      
      The patch also add debug logging of important procedures and
      better specify parameters types of st_select_lex::mark_as_dependent.
      68e0defc
    • Dmitry Shulga's avatar
      MDEV-25108: Running of the EXPLAIN EXTENDED statement produces extra warning... · f8bf2a01
      Dmitry Shulga authored
      MDEV-25108: Running of the EXPLAIN EXTENDED statement produces extra warning in case it is executed in PS (prepared statement) mode
      
      The EXPLAIN EXTENDED statement run as a prepared statement can produce extra
      warning comparing with a case when EXPLAIN EXTENDED statement is run as
      a regular statement. For example, the following test case
        CREATE TABLE t1 (c int);
        CREATE TABLE t2 (d int);
        EXPLAIN EXTENDED SELECT (SELECT 1 FROM t2 WHERE d = c) FROM t1;
      
      produces the extra warning
        "Field or reference 'c' of SELECT #2 was resolved in SELECT #1"
      in case the above mentioned "EXPLAIN EXTENDED" statement is executed
      in PS mode, that is by submitting the following statements:
         PREPARE stmt FROM "EXPLAIN EXTENDED SELECT (SELECT 1 FROM t2 WHERE d = c) FROM t1";
         EXECUTE stmt;
      
      The reason of the extra warning emittion is in a way items
      are handled (being fixed) during execution of the JOIN::prepare() method.
      The method Item_field::fix_fields() calls the find_field_in_tables()
      function in case a field hasn't been associated yet with the item.
      Implementation of the find_field_in_tables() function first checks whether
      a table containing the required field was already opened and cached.
      It is done by checking the data member item->cached_table. This data member
      is set on handling the PRERARE FROM statement and checked on executing
      the EXECUTE statement. If the data member item->cached_table is set
      the find_field_in_tables() function invoked and the
      mark_select_range_as_dependent() function called if the field
      is an outer referencee. The mark_select_range_as_dependent() function
      calls the mark_as_dependent() function that finally invokes
      the push_warning_printf() function that produces extra warning.
      
      To fix the issue, calling of push_warning_printf() is elimited in case
      it was run indirectly in result of hanlding already opened table from
      the Item_field::fix_fields() method.
      f8bf2a01
    • Julius Goryavsky's avatar
      MDEV-21484: galera_sst_mariabackup_encrypt_with_key test failed · e95cdc45
      Julius Goryavsky authored
      This commit removes the mtr test galera_sst_mariabackup_encrypt_with_key
      from the list of disabled tests because the problem with it has already
      been fixed.
      e95cdc45
    • Thirunarayanan Balathandayuthapani's avatar
      MDEV-24971 InnoDB access freed virtual column after rollback of secondary index · cf2c6b7f
      Thirunarayanan Balathandayuthapani authored
      Problem:
      ========
       InnoDB fails to clean the index stub if it fails to add the
      virtual index which contains new virtual column. But it clears
      the newly virtual column from index in clear_added_indexes()
      during inplace_alter_table. On commit, InnoDB evicts and
      reload the table. In case of rollback, it doesn't happen.
      InnoDB clears the ABORTED index while opening the table
      or doing the DDL. In the mean time, InnoDB can access
      the dropped virtual index columns while creating prebuilt
      or rollback of concurrent DML.
      
      Solution:
      ==========
      (1) InnoDB should maintain newly added virtual column while
      rollbacking the newly added virtual index.
      (2) InnoDB must not defer the index removal
      if the alter table is executed with LOCK=EXCLUSIVE.
      (3) For LOCK=SHARED, InnoDB should check whether the table
      has any other transaction lock other than alter transaction
      before deferring the index stub.
      
      Replaced has_new_v_col with dict_add_vcol_info in dict_index_t to
      indicate whether the index has any new virtual column.
      
      dict_index_t::has_new_v_col(): Returns whether the index has
      newly added virtual column, it doesn't say which columns are
      newly added virtual column
      
      ha_innobase_inplace_ctx::is_new_vcol(): Return whether the
      given column is added as a part of the current alter.
      
      ha_innobase_inplace_ctx::clean_new_vcol_index(): Copy the newly
      added virtual column to new_vcol_info in dict_index_t. Replace
      the column in the index fields with virtual column stored
      in new_vcol_info.
      
      dict_index_t::assign_new_v_col(): Store the number of virtual
      column added in index as a part of alter table.
      
      dict_index_t::get_n_new_vcol(): Get the number of newly added
      virtual column
      
      dict_index_t::assign_drop_v_col(): Allocate the memory for
      adding new virtual column in new_vcol_info.
      
      dict_index_t::add_drop_v_col(): Add the newly added virtual
      column in new_vcol_info.
      
      dict_table_t::has_lock_for_other_trx(): Whether the table has
      any other transaction lock than given transaction.
      
      row_merge_drop_indexes(): Add parameter alter_trx and check
      whether the table has any other lock than alter transaction.
      cf2c6b7f
    • Marko Mäkelä's avatar
      MDEV-18802 Assertion table->stat_initialized failed in dict_stats_update_if_needed() · ea2d44d0
      Marko Mäkelä authored
      When a table has been evicted from dict_sys and reloaded internally by
      InnoDB for FOREIGN KEY processing, statistics may not be initialized,
      but nevertheless row_update_cascade_for_mysql() could invoke
      dict_stats_update_if_needed(). In that case, we cannot really update
      the statistics. For tables that have STATS_PERSISTENT=1 and
      STATS_AUTO_RECALC=1, ANALYZE TABLE might have to be executed later.
      
      dict_stats_update_if_needed(): Replace the assertion with
      a conditional early return.
      ea2d44d0
    • Marko Mäkelä's avatar
      MDEV-24434 Assertion trx->in_rw_trx_list... in trx_sys_any_active_transactions() · 75dd7a04
      Marko Mäkelä authored
      trx_sys_any_active_transactions(): Remove a bogus debug assertion.
      In trx_commit_in_memory() and trx_erase_lists(), we will remove
      the transaction from trx_sys->rw_trx_list and set the state to
      TRX_STATE_COMMITTED_IN_MEMORY.
      75dd7a04
    • Otto Kekäläinen's avatar
      Deb: Stop depending on empty transitional package dh-systemd · 058d93d4
      Otto Kekäläinen authored
      MariaDB Server still supports Ubuntu 16.04 "Xenial" until it goes EOL
      in April 30, 2021. Thus we need to include a customization for backwards
      compatibility.
      
      This change is intended to be applied for all MariaDB versions still
      supported, i.e. 10.2 to 10.6.
      058d93d4
  4. 11 Apr, 2021 5 commits
  5. 09 Apr, 2021 3 commits
  6. 08 Apr, 2021 6 commits
  7. 07 Apr, 2021 4 commits
    • Monty's avatar
      MDEV-25334 FTWRL/Backup blocks DDL on temporary tables with binlog enabled,... · 4e2ca422
      Monty authored
      MDEV-25334 FTWRL/Backup blocks DDL on temporary tables with binlog enabled, assertion fails in Diagnostics_area::set_error_status
      
      Fixed by adding a MDL_BACKUP_COMMIT lock before altering temporary tables
      whose creation was logged to binary log (in which case the ALTER TABLE
      must also be logged)
      4e2ca422
    • Thirunarayanan Balathandayuthapani's avatar
      MDEV-25019 memory allocation failures during startup because · 72da83ff
      Thirunarayanan Balathandayuthapani authored
      	server failure in different, confusing ways
      
      InnoDB fails to free the buffer pool instance mutex and zip mutex
      If the allocation of buffer pool instance chunk fails. So it leads
      to freeing of buffer pool before freeing the mutexes and
      leads to double freeing of memory while freeing the mutex
      during shutdown.
      72da83ff
    • Alexander Barkov's avatar
      MDEV-22775 [HY000][1553] Changing name of primary key column with foreign key constraint fails. · 58780b5a
      Alexander Barkov authored
      Problem:
      
      The problem happened because of a conceptual flaw in the server code:
      
      a. The table level CHARSET/COLLATE clause affected all data types,
        including numeric and temporal ones:
      
         CREATE TABLE t1 (a INT) CHARACTER SET utf8 [COLLATE utf8_general_ci];
      
        In the above example, the Column_definition_attributes
        (and then the FRM record) for the column "a" erroneously inherited
        "utf8" as its character set.
      
      b. The "ALTER TABLE t1 CONVERT TO CHARACTER SET csname" statement
         also erroneously affected Column_definition_attributes::charset
         for numeric and temporal data types and wrote "csname" as their
         character set into FRM files.
      
      So now we have arbitrary non-relevant charset ID values for numeric
      and temporal data types in all FRM files in the world :)
      
      The code in the server and the other engines did not seem to be affected
      by this flaw. Only InnoDB inplace ALTER was affected.
      
      Solution:
      
      Fixing the code in the way that only character string data types
      (CHAR,VARCHAR,TEXT,ENUM,SET):
      - inherit the table level CHARSET/COLLATE clause
      - get the charset value according to "CONVERT TO CHARACTER SET csname".
      
      Numeric and temporal data types now always get &my_charset_numeric
      in Column_definition_attributes::charset and always write its ID into FRM files:
      - no matter what the table level CHARSET/COLLATE clause is, and
      - no matter what "CONVERT TO CHARACTER SET" says.
      
      Details:
      
      1. Adding helper classes to pass small parts of HA_CREATE_INFO
         into Type_handler methods:
      
         - Column_derived_attributes - to pass table level CHARSET/COLLATE,
           so columns that do not have explicit CHARSET/COLLATE clauses
           can derive them from the table level, e.g.
      
             CREATE TABLE t1 (a VARCHAR(1), b CHAR(1)) CHARACTER SET utf8;
      
         - Column_bulk_alter_attributes - to pass bulk attribute changes
           generated by the ALTER related code. These bulk changes affect
           multiple columns at the same time:
      
             ALTER TABLE ... CONVERT TO CHARACTER SET csname;
      
         Note, passing the whole HA_CREATE_INFO directly to Type_handler
         would not be good: HA_CREATE_INFO is huge and would need not desired
         dependencies in sql_type.h and sql_type.cc. The Type_handler API should
         use smallest possible data types!
      
      2. Type_handler::Column_definition_prepare_stage1() is now responsible
         to set Column_definition::charset properly, according to the data type,
         for example:
      
         - For string data types, Column_definition_attributes::charset is set from
           the table level CHARSET/COLLATE clause (if not specified explicitly in
           the column definition).
      
         - For numeric and temporal fields, Column_definition_attributes::charset is
           set to &my_charset_numeric, no matter what the table level
           CHARSET/COLLATE says.
      
         - For GEOMETRY, Column_definition_attributes::charset is set to
           &my_charset_bin, no matter what the table level CHARSET/COLLATE says.
      
         Previously this code (setting `charset`) was outside of of
         Column_definition_prepare_stage1(), namely in
         mysql_prepare_create_table(), and was erroneously called for
         all data types.
      
      3. Adding Type_handler::Column_definition_bulk_alter(), to handle
         "ALTER TABLE .. CONVERT TO". Previously this code was inside
         get_sql_field_charset() and was erroneously called for all data types.
      
      4. Removing the Schema_specification_st parameter from
         Type_handler::Column_definition_redefine_stage1().
         Column_definition_attributes::charset is now fully properly initialized by
         Column_definition_prepare_stage1(). So we don't need access to the
         table level CHARSET/COLLATE clause in Column_definition_redefine_stage1()
         any more.
      
      5. Other changes:
         - Removing global function get_sql_field_charset()
      
         - Moving the part of the former get_sql_field_charset(), which was
           responsible to inherit the table level CHARSET/COLLATE clause to
           new methods:
            -- Column_definition_attributes::explicit_or_derived_charset() and
            -- Column_definition::prepare_charset_for_string().
           This code is only needed for string data types.
           Previously it was erroneously called for all data types.
      
         - Moving another part, which was responsible to apply the
           "CONVERT TO" clause, to
           Type_handler_general_purpose_string::Column_definition_bulk_alter().
      
         - Replacing the call for get_sql_field_charset() in sql_partition.cc
           to sql_field->explicit_or_derived_charset() - it is perfectly enough.
           The old code was redundant: get_sql_field_charset() was called from
           sql_partition.cc only when there were no a "CONVERT TO CHARACTER SET"
           clause involved, so its purpose was only to inherit the table
           level CHARSET/COLLATE clause.
      
         - Moving the code handling the BINCMP_FLAG flag from
           mysql_prepare_create_table() to
           Column_definition::prepare_charset_for_string():
           This code is responsible to resolve the BINARY comparison style
           into the corresponding _bin collation, to do the following transparent
           rewrite:
              CREATE TABLE t1 (a VARCHAR(10) BINARY) CHARSET utf8;  ->
              CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_bin);
           This code is only needed for string data types.
           Previously it was erroneously called for all data types.
      
      6. Renaming Table_scope_and_contents_source_pod_st::table_charset
         to alter_table_convert_to_charset, because the only purpose it's used for
         is handlering "ALTER .. CONVERT". The new name is much more self-descriptive.
      58780b5a
    • Daniel Black's avatar
      MDEV-19508: SI_KERNEL is not on all implementations · f69c1c9d
      Daniel Black authored
      SI_USER is, however in FreeBSD there are a couple of non-kernel
      user signal infomations above SI_KERNEL.
      
      Put a fallback just in case there is nothing available.
      f69c1c9d