1. 30 Aug, 2023 1 commit
    • Anel Husakovic's avatar
      MDEV-31231: Remove JavaWrappers.jar from mariadb-test-data and create new... · 7ba9c7fb
      Anel Husakovic authored
      MDEV-31231: Remove JavaWrappers.jar from mariadb-test-data and create new mariadb-plugin-connect-jdbc package
      
      - Jar file created
      ```bash
      $ find .|grep JdbcInterface
      ./storage/connect/connect_jars/JdbcInterface.jar
      ```
      - Debian package created
      ```bash
      $ dpkg -c mariadb-plugin-connect-jdbc_11.2.0+maria~ubu2004_amd64.deb
      drwxr-xr-x root/root         0 2023-05-16 09:50 ./
      drwxr-xr-x root/root         0 2023-05-16 09:50 ./usr/
      drwxr-xr-x root/root         0 2023-05-16 09:50 ./usr/share/
      drwxr-xr-x root/root         0 2023-05-16 09:50 ./usr/share/doc/
      drwxr-xr-x root/root         0 2023-05-16 09:50 ./usr/share/doc/mariadb-plugin-connect-jdbc/
      -rw-r--r-- root/root       253 2023-05-16 09:50 ./usr/share/doc/mariadb-plugin-connect-jdbc/changelog.gz
      -rw-r--r-- root/root      2502 2023-05-09 15:14 ./usr/share/doc/mariadb-plugin-connect-jdbc/copyright
      drwxr-xr-x root/root         0 2023-05-16 09:50 ./usr/share/mariadb/
      -rw-r--r-- root/root      7538 2023-05-16 09:50 ./usr/share/mariadb/JdbcInterface.jar
      ```
      
      - Tested on RPM
      ```
      $ ls -la|grep connect
      -rw-r--r--  1 root root  2633772 May 23 11:27 MariaDB-connect-engine-11.2.0-1.el7.x86_64.rpm
      -rw-r--r--  1 root root  3430040 May 23 11:27 MariaDB-connect-engine-debuginfo-11.2.0-1.el7.x86_64.rpm
      -rw-r--r--  1 root root     9872 May 23 11:27 MariaDB-connect-engine-jdbc-11.2.0-1.el7.x86_64.rpm
      -rw-r--r--  1 root root       36 May 23 11:21 install_manifest_connect-engine-jdbc.txt
      -rw-r--r--  1 root root      123 May 23 11:21 install_manifest_connect-engine.txt
      -rw-r--r--  1 root root        0 May 23 11:21 install_manifest_connect-engineSymlinks.txt
      
      $ rpm -qlp MariaDB-connect-engine-jdbc-11.2.0-1.el7.x86_64.rpm
      /usr/share/mariadb
      /usr/share/mariadb/JdbcInterface.jar
      
      $ for o in --conflicts --enhances --obsoletes --provides --recommends --requires --suggests --supplements ; do echo opt $o; rpm -q $o /home/dan/repos/build-mariadb-server-11.2/MariaDB-connect-engine-jdbc-11.2.0-1.fc38.x86_64.rpm; done
      opt --conflicts
      opt --enhances
      opt --obsoletes
      opt --provides
      MariaDB-connect-engine-jdbc = 11.2.0-1.fc38
      MariaDB-connect-engine-jdbc(x86-64) = 11.2.0-1.fc38
      opt --recommends
      MariaDB-connect-engine
      mariadb-java-client
      mysql-connector-java
      postgresql-jdbc
      opt --requires
      java-1.8.0-openjdk-headless
      rpmlib(CompressedFileNames) <= 3.0.4-1
      rpmlib(FileDigests) <= 4.6.0-1
      rpmlib(PayloadFilesHavePrefix) <= 4.0-1
      rpmlib(PayloadIsZstd) <= 5.4.18-1
      opt --suggests
      opt --supplements
      ```
      
      Closes PR #1890  (MDEV-26218)
      
      Reviewer: <daniel@mariadb.org>
      7ba9c7fb
  2. 29 Aug, 2023 1 commit
    • Alexander Barkov's avatar
      MDEV-32026 lowercase_table2.test failures in 11.3 · 9cb75f33
      Alexander Barkov authored
      Also fixes MDEV-32025 Crashes in MDL_key::mdl_key_init with lower-case-table-names=2
      
      Change overview:
      - In changes made in MDEV-31948, MDEV-31982 the code path
        which originaly worked only in case of lower-case-table-names==1
        also started to work in case of lower-case-table-names==2 in a mistake.
      
        Restoring the original check_db_name() compatible behavior
        (but without re-using check_db_name() itself).
      - MDEV-31978 erroneously added a wrong DBUG_ASSERT. Removing.
      
      Details:
      
      - In mysql_change_db() the database name should be lower-cased only
        in case of lower_case_table_names==1. It should not be lower-cased
        for lower_case_table_names==2. The problem was caused by MDEV-31948.
        The new code version restored the pre-MDEV-31948 behavior, which
        used check_db_name() behavior.
      
      - Passing lower_case_table_names==1 instead of just lower_case_table_names
        to the "casedn" parameter to DBNameBuffer constructor in sql_parse.cc
        The database name should not be lower-cased for lower_case_table_names==2.
        This restores pre-MDEV-31982 behavioir which used check_db_name() here.
      
      - Adding a new data type Lex_ident_db_normalized, it stores database
        names which are both checked and normalized to lower case
        in case lower_case_table_names==1 and lower_case_table_names==2.
      
      - Changing the data type for the "db" parameter to Lex_ident_db_normalized in
        lock_schema_name(), lock_db_routines(), find_db_tables_and_rm_known_files().
      
        This is to avoid incorrectly passing a non-normalized name in the future.
      
      - Restoring the database name normalization in mysql_create_db_internal()
        and mysql_rm_db_internal() before calling lock_schema_name().
        The problem was caused MDEV-31982.
      
      - Adding database name normalization in mysql_alter_db_internal()
        and mysql_upgrade_db(). This fixes MDEV-32026.
      
      - Removing a wrong assert in Create_sp_func::create_with_db() was incorrect:
      
          DBUG_ASSERT(Lex_ident_fs(*db).ok_for_lower_case_names());
      
        The database name comes to here checked, but not normalized
        to lower case with lower-case-table-names=2.
        The assert was erroneously added by MDEV-31978.
      
      - Recording lowercase_tables2.results and lowercase_tables4.results
        according to
          MDEV-29446 Change SHOW CREATE TABLE to display default collations
        These tests are skipped on buildbot on all platforms, so this change
        was forgotten in the patch for MDEV-29446.
      9cb75f33
  3. 26 Aug, 2023 1 commit
    • Alexander Barkov's avatar
      MDEV-32019 Replace my_casedn_str(local_buffer) to CharBuffer::copy_casedn() · cb37c99d
      Alexander Barkov authored
      Replacing my_casedn_str() called on local char[] buffer variables
      to CharBuffer::copy_casedn() calls.
      
      This is a sub-task for MDEV-31531 Remove my_casedn_str()
      
      Details:
      - Adding a helper template class IdentBuffer (a CharBuffer descendant),
        which assumes utf8 data. Like CharBuffer, it's initialized to an empty
        string in the constructor, but can be populated with lower-cased data
        later.
      
      - Adding a helper template class IdentBufferCasedn, which initializes
        to lower case right in the constructor.
      
      - Removing char[] buffers, replacing them to IdentBuffer and IdentBufferCasedn.
      
      - Changing the data type of "db" and "table" parameters from
        "const char*" to LEX_CSTRING in the following functions:
      
          find_field_in_table_ref()
          insert_fields()
          set_thd_db()
          mysql_grant()
      
        to reuse IdentBuffer easeir.
      cb37c99d
  4. 25 Aug, 2023 1 commit
    • Alexander Barkov's avatar
      MDEV-32013 Add Field::val_lex_string_strmake() · e0949cd6
      Alexander Barkov authored
      There are two functions to extract a Field::val_str() value
      as a LEX_STRING or LEX_CSTRING pointing to the data allocated on a MEM_ROOT:
      
        char *get_field(MEM_ROOT *mem, Field *field);
        bool get_field(MEM_ROOT *mem, Field *field, class String *res);
      
      The first function requires strlen() calls to make a LEX_CSTRING/LEX_STRING.
      The second function requires a redundant String buffer,
      which is used only as a temporary proxy value pointing to a MEM_ROOT fragment
      (and does not use any String dynamic allocation methods).
      
      This patch add a native way to extract a Field::val_str() value
      as a LEX_STRING or LEX_CSTRING pointing to a MEM_ROOT fragment.
      It helps to remove redundant strlen() calls and redundant String buffers.
      
      - Adding a new method:
      
          LEX_STRING Field::val_lex_string_strmake(MEM_ROOT *mem);
      
      - Reusing the new method Field::val_lex_string_strmake() in;
      
          bool get_field(MEM_ROOT *mem, Field *field, String *res);
      
        Also, moving it from table.cc to a static function in sql_help.cc.
        It is used in sql_help.cc only, and we don't want it to be reused
        in other parts of the code (to avoid redundant String buffers).
      
      - Reusing the new method Field::val_lex_string_strmake() in this function:
      
          char *get_field(MEM_ROOT *mem, Field *field);
      
      - Replacing get_field() to Field::val_lex_string_strmake() in these files:
      
          sql_plugin.cc  (redundant String buffers were removed)
          sql_udf.cc     (redundant strlen() calls were removed)
      
      Note, this function:
      
         char *get_field(MEM_ROOT *mem, Field *field);
      
      is still used in a number of files:
      
         event_data_objects.cc
         event_db_repository.cc
         sql_acl.cc
         sql_servers.cc
      
      These remaining calls will be removed by separate patches,
      and get_field() will be removed after that.
      e0949cd6
  5. 24 Aug, 2023 2 commits
  6. 23 Aug, 2023 4 commits
    • Alexander Barkov's avatar
      MDEV-31992 Automatic conversion from LEX_STRING to LEX_CSTRING · 8951f7d9
      Alexander Barkov authored
      - Adding automatic conversion operator from LEX_STRING to LEX_CSTRING
        Now a LEX_STRING can be passed directly to any function expecting
        a LEX_CSTRING parameter passed by value or by reference.
      - Removing a number of duplicate methods accepting LEX_STRING.
        Now the code used the LEX_CSTRING version.
      8951f7d9
    • Alexander Barkov's avatar
      MDEV-31991 Split class Database_qualified_name · 9b0b314b
      Alexander Barkov authored
      - Moving some of Database_qualidied_name methods into a new class
        Identifier_chain2.
      
      - Changing the data type of the following variables from
        Database_qualified_name to Identifier_chain2:
      
        * q_pkg_proc in LEX::call_statement_start()
        * q_pkg_func in LEX::make_item_func_call_generic()
      
      Rationale:
      
      The data type of Database_qualified_name::m_db will be changed
      to Lex_ident_db soon. So Database_qualified_name won't be able
      to store the `pkg.routine` part of `db.pkg.routine` any more,
      because `pkg` must not depend on lower-case-table-names.
      9b0b314b
    • Alexander Barkov's avatar
      MDEV-31989 Cleanup Lex_ident_fs::check_body() · b5418521
      Alexander Barkov authored
      - Changing the data type of the global variable any_db from
        LEX_CSTRING to Lex_ident_db
      
      - Removing the dependency on system_charset_info from
        Lex_ident_fs::check_body(), using my_charset_utf8mb3_general_ci directly,
        because system_charset_info is initialized much later than any_db.
        system_charset_info cannot be changed dynamically any way.
      
      - Removing the unsed old code from Lex_ident_fs::check_body().
        This code was last used in MySQL-4.0 and won't be used in the future.
      b5418521
    • Alexander Barkov's avatar
      MDEV-31986 Remove old check_db_name() from make_table_name_list() · 21218d3c
      Alexander Barkov authored
      - Replacing the old style inplace check_db_name() in make_table_name_list()
        to the new style non-modifying code
      - Adding "const" qualifier to the "db" parameter to ha_discover_table_names()
        and its dependency functions.
      21218d3c
  7. 22 Aug, 2023 2 commits
    • Alexander Barkov's avatar
      MDEV-31982 Remove check_db_name() from prepare_db_action() · d15e2902
      Alexander Barkov authored
      - Adding a new class Lex_ident_db, to store normalized database names:
        lower-cased if lower-case-table-name says so,
        and checked to be a valid database name using Lex_ident_fs::check_db_name()
      
      - Reusing the new class in parameters to functions:
          prepare_db_action()
          mysql_create_db()
          mysql_alter_db()
          mysql_rm_db()
          mysql_upgrade_db()
      
      This change removed two old-style check_db_name() calls.
      d15e2902
    • Alexander Barkov's avatar
      MDEV-31978 Turn ok_for_lower_case_names() to a method in Lex_ident_fs · ebbf5662
      Alexander Barkov authored
      - Changing the global function ok_for_lower_case_names()
        into a method in class Lex_ident_fs.
      
      - Changing a few functions/methods to get the database name
        as a "const LEX_CSTRING" instead of a "const char *".
        All these functions/methods use ok_for_lower_case_names()
        inside. This change helps to avoid new strlen() calls, and also
        removes a few old strlen() calls.
      ebbf5662
  8. 21 Aug, 2023 2 commits
    • Alexander Barkov's avatar
      MDEV-31974 Remove global function normalize_db_name() · 7a7296bd
      Alexander Barkov authored
      The function normalize_db_name() fully repeated the functionality
      of the class DBNameBuffer. This patch  removes normalize_db_name()
      and replaces it to a DBNameBuffer based code.
      7a7296bd
    • Alexander Barkov's avatar
      MDEV-31972 Change parameter of make_sp_name*() from LEX_CSTRING to Lex_ident_sys_st · 495c32d9
      Alexander Barkov authored
      Changing LEX_CSTRING* parameters of LEX::make_sp_name() to Lex_ident_sys_st.
      
      This makes the code clear because a value of Lex_ident_sys_st has
      some guaranteed additional constraints over a base LEX_CSTRING:
      
      - Its LEX_CSTRING::str is not NULL (sql_yacc.yy would abort otherwise)
      - Its LEX_CSTRING::str is 0-terminated
      - Its a valid utf8 string
      - The string pointed by LEX_CSTRING::str was created on THD::mem_root
      
      Also changing "pass by pointer" to "pass by reference",
      as these parameters can never be NULL - they are Bison stack variables.
      495c32d9
  9. 18 Aug, 2023 3 commits
    • Alexander Barkov's avatar
      MDEV-31948 Add class DBNameBuffer, split check_db_name() into stages · b956a6a2
      Alexander Barkov authored
      - Adding a class Lex_ident_fs, to store identifiers for on-disk
        database objects, such as databases, tables, triggers.
      
      - Moving the validation code from check_db_name()
        to non-modifying methods in Lex_ident_fs:
      
          Lex_ident_fs::check_body()
          Lex_ident_fs::check_db_name()
      
        Adding a new method Lex_ident_fs::check_db_name_with_error(),
        which performs validation and raises an error on validation failure.
      
        Unlike the old function check_db_name(), the new class Lex_ident_fs
        does not lower-case the identifier during the validation.
        Lower-casing must be done before calling Lex_ident_fs validation methods.
      
      - Adding a low level helper template class CharBuffer which can:
        * store exact or lower-cased strings with a short fixed maximum length
        * return the value as a LEX_CSTRING efficiently
      
      - Adding a helper template class DBNameBuffer (deriving from CharBuffer), to
        allocate optionally lower-cased database identifiers on stack when relevant.
        Useful for temporary values which don't need to be allocated on MEM_ROOT.
      
      - Using DBNameBuffer in mysql_change_db()
      
      - Using DBNameBuffer in show_create_db()
      b956a6a2
    • Alexander Barkov's avatar
      MDEV-31954 Cleanup in check_table_name() and check_db_name() · 8528eacc
      Alexander Barkov authored
      - Renaming the parameter `check_for_path_char` to a more
        self-descriptive `disallow_path_chars`
      - Renaming the variable `name_length` in check_table_name()
        to a more self-descriptive `char_length`.
      - Fix the `while` loop in check_table_name() into a
        `for` loop and replace multiple {{char_length++}}
        (the former {{name_length++}}) statements to a signle increment
        statement in the `for` loop header.
      8528eacc
    • Alexander Barkov's avatar
  10. 17 Aug, 2023 1 commit
    • Junqi Xie's avatar
      MDEV-30610 Update RocksDB to v8.1.1 · 485c9b1f
      Junqi Xie authored
      MariaRocks is currently lagging behind the main branch of the RocksDB engine. This commit brings MariaRocks up to date with the latest release of RocksDB by backporting changes from Facebook’s MyRocks. These changes include API updates, bug fixes, and improvements for compatibility with RocksDB v8.1.1. Some system variables and metadata tables are modified to reflect the internal changes in RocksDB.
      
      Additionally, this commit backports improved and more stable test cases from Facebook’s MyRocks, including tests for the write_unprepared isolation level of RocksDB. It also reverts workarounds for MDEV-29875 and MDEV-31057 and adds support for the latest compilation options.
      
      The default value of the following system variables are changed:
      * rocksdb_stats_level: 1 (kExceptHistogramOrTimers)
      * rocksdb_wal_recovery_mode: 2 (kPointInTimeRecovery)
      
      The following system variables are added:
      * rocksdb_cancel_manual_compactions
      * rocksdb_enable_iterate_bounds
      * rocksdb_enable_pipelined_write
      * rocksdb_enable_remove_orphaned_dropped_cfs
      * rocksdb_manual_compaction_bottommost_level
      * rocksdb_max_background_compactions
      * rocksdb_max_background_flushes
      * rocksdb_max_bottom_pri_background_compactions
      * rocksdb_skip_locks_if_skip_unique_check
      * rocksdb_track_and_verify_wals_in_manifest
      * rocksdb_write_batch_flush_threshold
      
      The following system variables are deprecated:
      * rocksdb_hash_index_allow_collision
      * rocksdb_new_table_reader_for_compaction_inputs
      
      The following dynamic metadata table is added:
      * INFORMATION_SCHEMA.ROCKSDB_LIVE_FILES_METADATA
      
      The following status variables are added:
      * rocksdb_manual_compactions_cancelled
      * rocksdb_manual_compactions_pending
      
      The following status variables are removed:
      * rocksdb_block_cache_filter_bytes_evict
      * rocksdb_block_cache_index_bytes_evict
      * rocksdb_block_cachecompressed_hit
      * rocksdb_block_cachecompressed_miss
      * rocksdb_no_file_closes
      * rocksdb_num_iterators
      * rocksdb_number_deletes_filtered
      * rocksdb_write_timedout
      485c9b1f
  11. 16 Aug, 2023 1 commit
  12. 15 Aug, 2023 21 commits
    • Nikita Malyavin's avatar
      MDEV-31812 Add switch to old_mode to disable non-locking ALTER · 8aa1a9e6
      Nikita Malyavin authored
      Add LOCK_ALTER_TABE_COPY bit to old_mode. Disables online copy by default,
      but still allows to force it with explicit lock=none
      8aa1a9e6
    • Nikita Malyavin's avatar
      MDEV-31804 Assertion `thd->m_transaction_psi == __null' fails · a1af5255
      Nikita Malyavin authored
      ... upon replicating online ALTER
      
      When an online event is applied and slave_exec_mode is idempotent,
      Write_rows_log_event::do_before_row_operations had reset
      thd->lex->sql_command to SQLCOM_REPLACE.
      
      This led to that a statement was detected as a row-type during binlogging,
      and was logged as not standalone.
      
      So the corresponding Gtid_log_event, when applied on replica, did not exit
      early and created a new PSI transaction. Hence the difference with
      non-online ALTER.
      a1af5255
    • Nikita Malyavin's avatar
      Cleanup: make slave_exec_mode of its enum type and pack Log_event better · c373e6c3
      Nikita Malyavin authored
      Pack these fields together:
      event_owns_temp_buf
      cache_type
      slave_exec_mode
      checksum_alg
      
      Make them bitfields to fit a single 2-byte hole.
      
      This saves 24 bytes per event.
      
      SLAVE_EXEC_MODE_LAST_BIT is rewritten as
      
      > SLAVE_EXEC_MODE_LAST= SLAVE_EXEC_MODE_IDEMPOTENT
      
      to avoid a false-positive -Wbitfield-enum-conversion warning:
      Bit-field 'slave_exec_mode' is not wide enough to store all enumerators of
      'enum_slave_exec_mode'.
      c373e6c3
    • Nikita Malyavin's avatar
      MDEV-31838 Assertion fails upon replication online alter with MINIMAL row · 982b6895
      Nikita Malyavin authored
      Replica honors its own binlog_row_image value when it sets up read_set.
      When a slave thread is applying replicated row events in parallel with the
      running online alter, we need all columns to be read from the table
      (for the online alter logged row event) not only those that were present in
      the pre-image for the replicated row event.
      
      Avoid shrinking the set when online alter is running, i.e. leave it all set
      982b6895
    • Nikita Malyavin's avatar
      MDEV-31781 ALTER TABLE ENGINE=s3 fails · c4adaed0
      Nikita Malyavin authored
      s3 is read-only. No need to update to a read-only engine with LOCK=NONE.
      c4adaed0
    • Nikita Malyavin's avatar
      MDEV-31777 ER_GET_ERRNO upon online alter on CONNECT table · 30c965f8
      Nikita Malyavin authored
      Forbid Online for CONNECT.
      30c965f8
    • Nikita Malyavin's avatar
      MDEV-31631 Adding auto-increment to table with history online misbehaves · 44ca37ef
      Nikita Malyavin authored
      Adding an auto_increment column online leads to an undefined behavior.
      Basically any DEFAULTs that depend on a row order in the table, or on
      the non-deterministic (in scope of the ALTER TABLE statement) function
      is UB.
      
      For example, NOW() is considered generally non-deterministic
      (Item_func_now_utc is marked with VCOL_NON_DETERMINISTIC), but it's fixed
      in scope of a single statement.
      
      Same for any other function that depends only on the session/status vars
      apart from its arguments.
      
      Only two UB cases are known:
      * adding new AUTO_INCREMENT column. Modifying the existing column may be
      fine under certain circumstances, see MDEV-31058.
      * adding new column with DEFAULT(nextval(...)). Modifying the existing
      column is possible, since its value will be always present in the online
      event, except for the NULL -> NOT NULL modification
      44ca37ef
    • Nikita Malyavin's avatar
      MDEV-31776 Online ALTER reports the number of affected rows incorrectly · e026a366
      Nikita Malyavin authored
      Add a new virtual function that will increase the inserted rows count
      for the insert log event and decrease it for the delete event.
      
      Reuses Rows_log_event::m_row_count on the replication side, which was only
      set on the logging side.
      e026a366
    • Nikita Malyavin's avatar
      MDEV-31775 Server crash upon online alter on sequence · 9c855425
      Nikita Malyavin authored
      Forbid online for sequences. It doesn't work now and sequence tables are
      always only one row, so not worth the extra complexity.
      9c855425
    • Nikita Malyavin's avatar
    • Nikita Malyavin's avatar
    • Andrei's avatar
      MDEV-31755 Replica's DML event deadlocks wit online alter table · bac8f189
      Andrei authored
      The deadlock was caused by too strong MDL acquired by the start ALTER.
      
      Replica's ALTER TABLE replication consists of two phases:
      1. Start ALTER (SA) -- the event is emittd in the very beginning,
      allowing replication start ALTER in parallel
      2. Commit ALTER (CA) -- ensures that master finishes successfully
      
      CA is normally received by wait_for_master call.
      If parallel DML was run, the following sequence will take place:
      
      |- SA
      |- DML
      |- CA
      
      If CA is handled after MDL upgrade, it'll will deadlock with DML.
      
      While MDL is shared by the start ALTER wait for its 2nd part
      to allow concurrent DMLs to grab the lock.
      
      The fix uses wait_for_master reentrancy -- no need to avoid a second call
      in the end of mysql_alter_table.
      
      Since SA and CA are marked with FL_DDL, the DML issued in-between cannot be
      rescheduled before or after them. However, SA "commits" (by he call of
      write_bin_log_start_alter and, subsequently,
      thd->wakeup_subsequent_commits) before the copy stage begins, unlocking
      the DMLs to run on this table. That is, these DMLs will be executed
      concurrently with the copy stage, making Online alter effective on replicas
      as well
      
      Co-authored-by: Nikita Malyavin (nikitamalyavin@gmail.com)
      bac8f189
    • Nikita Malyavin's avatar
      e1b9ab19
    • Nikita Malyavin's avatar
      MDEV-31677 Assertion failed upon online ALTER with binlog_row_image=NOBLOB · 70491fb0
      Nikita Malyavin authored
      Make binlog_prepare_row_images accept image type as an argument.
      70491fb0
    • Nikita Malyavin's avatar
    • Nikita Malyavin's avatar
      MDEV-31646 Online alter applies binlog cache limit to cache writes · d5e59c98
      Nikita Malyavin authored
      1. Make online disk writes unlimited, same as filesort does.
      2. Make proper error handling -- in 32-bit build IO_CACHE capacity limit is
      4GB, so it is quite possible to overfill there.
      3. Event_log::write_cache complicated with event reparsing, and as it was
      proven by QA, contains some mistakes. Rewrite introbuce a simpler and much
      faster version, not featuring reparsing and therefore copying a whole
      buffer at once. This also disables checksums and crypto.
      4. Handle read_log_event errors correctly: error returned is -1 (eof
      signal for alter table), and my_error is not called. Call my_error and
      always return 1. There's no test for this, since it shouldn't happen,
      see the next bullet.
      5. An event could be written partially in case of error, if it's bigger
      than the IO_CACHE buffer. Restore the position where it was before the
      error was emitted.
      
      As a result, online alter is untied of several binlog variables, which was
      a second aim of this patch.
      d5e59c98
    • Nikita Malyavin's avatar
      MDEV-31601 Some ALTER TABLEs fail ... with a wrong error message · 2cecb5a6
      Nikita Malyavin authored
      Report correct algorithm in the error message.
      2cecb5a6
    • Nikita Malyavin's avatar
      follow-up MDEV-30430: fix versioning.rpl · 8a165d7c
      Nikita Malyavin authored
      Don't skip row_end if it wasn't set explicitly.
      
      Also another segfault was caused by accessing rpl_write_set on slave during
      the row update/delete.
      The reason was a default_column_bitmaps() call, which also sets
      rpl_write_set to NULL.
      Previously, the related behavior was changed in commit afd3ee97ad, where
      one such call was removed from Update_rows_log_event::do_exec_row, but the
      same one was mistakenly left in Delete_rows_log_event. Now it's also
      removed.
      8a165d7c
    • Nikita Malyavin's avatar
      fix main.mysql57_virtual, main.alter_table, innodb.alter_algorithm · 43cb98b4
      Nikita Malyavin authored
      The correct (best) algorithm is now chosen for ALGORITHM=DEFAULT
      and alter_algorithm=DEFAULT
      
      See also MDEV-30906
      43cb98b4
    • Nikita Malyavin's avatar
      MDEV-30984 Online ALTER table is denied with non-informative error messages · c382de72
      Nikita Malyavin authored
      Group all the checks in online_alter_check_supported().
      
      There is now two groups of checks:
      1. A technical availability of online, that is checked before open_tables,
      and affects table_list->lock_type. It's supposed to be safe to make it
      TL_READ even if COPY algorithm will fall back to not-online, since MDL is
      SHARED_UPGRADEABLE anyway.
      2. An 'online' availability for a COPY algorithm. It can be done as late as
      just before the copy_data_between_tables call. The lock_type influence is
      disclosed above, so the only other place it affects is
      Alter_info::supports_lock, where `online` flag is only used to decide
      whether to report the error at the inplace preparation stage. We'd want to
      make that at the last resort, which is COPY preparation, if no algorithm is
      chosen by the user. So it's event better now.
      
      Some changes are required to the autoinc support detection, as the check
      now happens after mysql_prepare_alter_table:
      * alter_info->drop_list is empty
      * instead, dropped columns are in tmp_set
      * alter_info->create_list now has every field that's in the new table.
      * the column definition's change.str will be nonnull whether the column
        remains in the new table (vs whether it was changed, as before).
        But it also has `field` field set.
      * IF EXISTS doesn't have to be dealt anymore
      
      This infers that the changes are now checked in more detail: a field's
      definition shouldn't be changed, vs a field shouldn't be mentioned in
      the CHANGE list, as it was before. This is reflected by the line 193 test.
      c382de72
    • Nikita Malyavin's avatar