Commit graph

198057 commits

Author SHA1 Message Date
Sergei Golubchik
4ae97333f0 11.1 branch 2023-03-10 12:41:52 +01:00
Monty
ceb0e7f944 Fixes to mysql_install_db
- Change to use 'mariadbd' instead of 'mysqld' in help texts and other
  visible places.
- Start binary 'mariadbd' instead of 'mysqld'. This will remove a warning
  in 11.0 when running mysql_install_db.
- Use my_print_defaults --mariadbd instead of --mysqld
- Use --skip-log-error if the user don't have access to log-error file.
  This it needed to allow mysql_install_db to work silenty for users that
  has not write access to /var/log.

Other things:
- Updated my_print_defaults to support --mariadbd
2023-03-10 11:04:49 +02:00
Sergei Golubchik
d77aaa6994 MCOL-5437 columnstore fails to compile to due old cs->casedn_multiply use
update columnstore
2023-03-10 09:59:22 +01:00
Marko Mäkelä
f169dfb41a Merge 10.5 into 10.6 2023-03-10 09:35:50 +02:00
Daniel Black
b600671f75 MDEV-30810 errmsg-utf8.txt no longer uses charsets
Charset names in the 'languages' line are not used any more.

Removing to avoid confusion.

All messages in errmsg-utf8.txt are in utf8 now.

Charset names should have been removed in MySQL-5.5 during: https://dev.mysql.com/worklog/task/?id=751

Bump version number.
2023-03-10 08:53:58 +11:00
Marko Mäkelä
08267ba0c8 MDEV-30819 InnoDB fails to start up after downgrading from MariaDB 11.0
While downgrades are not supported and misguided attempts at it could
cause serious corruption especially after
commit b07920b634
it might be useful if InnoDB would start up even after an upgrade to
MariaDB Server 11.0 or later had removed the change buffer.

innodb_change_buffering_update(): Disallow anything else than
innodb_change_buffering=none when the change buffer is corrupted.

ibuf_init_at_db_start(): Mention a possible downgrade in the corruption
error message. If innodb_change_buffering=none, ignore the error but do
not initialize ibuf.index.

ibuf_free_excess_pages(), ibuf_contract(), ibuf_merge_space(),
ibuf_update_max_tablespace_id(), ibuf_delete_for_discarded_space(),
ibuf_print(): Check for !ibuf.index.

ibuf_check_bitmap_on_import(): Remove some unnecessary code.
This function is only accessing change buffer bitmap pages in a
data file that is not attached to the rest of the database.
It is not accessing the change buffer tree itself, hence it does
not need any additional mutex protection.

This has been tested both by starting up MariaDB Server 10.8 on
a 11.0 data directory, and by running ./mtr --big-test while
ibuf_init_at_db_start() was tweaked to always fail.
2023-03-09 16:16:58 +02:00
Sergei Golubchik
b4c7f5e670 Merge branch '10.10' into 10.11 2023-03-09 12:16:27 +01:00
Weijun Huang
231c0eb7a6 MDEV-23000: Ensure we get a warning from THD::drop_temporary_table() in case of disk errors 2023-03-09 08:51:00 +11:00
Sergei Golubchik
5f33351f48 MCOL-5437 columnstore fails to compile to due old cs->casedn_multiply use
update columnstore
2023-03-08 21:23:01 +01:00
Robin Newhouse
20d2c9038a Fix mini-benchmark
The mini-benchmark.sh script failed to run in the latest Fedora
distributions in GitLab CI. It requires `lscpu` resolved by installing
util-linux.

Additionally, executing the benchmark inside a Docker container had
failed because of increased Docker security in recent updates. In
particular the `renice` and `taskset` operations are not permitted.
Neither are the required `perf` operations.
https://docs.docker.com/engine/security/seccomp/

Allow these operations to fail gracefully, and test then skip `perf`,
allowing the remaining benchmark activities to proceed.

Other minor changes to the CI are included such as allowing sanitizer
jobs to fail and using "needs" in the mini-benchmark pipeline.

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.
2023-03-08 13:26:45 +00:00
Ekaterine Papava
6b8370a90f MDEV-30789: Add Georgian error messages and locale
Test case and minor fixes by Daniel Black

Reviewer: Alexander Barkov
2023-03-08 11:22:57 +11:00
EkaterinePapava
b56c613e2d MDEV-30789 Add Georgian translation (error messages) 2023-03-07 15:49:24 +00:00
Monty
97ff62b99b Fixed the cost for HASH join
Removed an old '* 2' from the HASH join cost. This was made obsolete by
a later patch that added cost for copying the data out from the join buffer
to table->record.

I also added some 'echo' to some test cases to make it easier to debug
test case changes.

Test case changes:
- subselect3_jcl6 and subselect_sj2_jcl6 result changes as materialized
  tables changed to hash join + first_match
2023-03-07 14:27:26 +02:00
Monty
7a277a3352 Allow firstmatch to use HASH joins
Firstmatch_picker::check_qep() has an optimization that allows firstmatch
to be used together with join buffer under some conditions. In this
case the cost was assumed to be same as what best_access_path()
had calculated.

However if HASH+join_buffer was used, then
fix_semijoin_strategies_for_picked_join_order() would remove the
join_buffer (which would cause a full join to be used) and the cost
assumption by Firstmatch_picker::check_qep() would be wrong.
Later check_join_cache_usage() sees that it's a full scan and decides
it can use join buffering, (But not the hash join).

Fixed by also allowing HASH joins with firstmatch.
This removes the need to change disable and re-enable join buffer.

Test case changes:
- HASH join used with firstmatch (Using join buffer (flat, BNLH join))
- Filtered could change with firstmatch as the conversion with and without
  join_buffered lost the filtering information.
- The not "re-enabling join buffer" is shown in main.optimizer_trace

Original code by Sergei, optimized by Monty.

Author: Sergei Petrunia <sergey@mariadb.com>, monty@mariadb.org
2023-03-07 14:27:26 +02:00
Julius Goryavsky
1e58b8afc0 move alloca() definition from all *.h files to one new header file 2023-03-07 11:13:20 +01:00
Thirunarayanan Balathandayuthapani
2458badf9b MDEV-30798 deadlock between CHECK TABLE and bulk insert
- Deadlock happens when bulk insert acquires the space latch
before acquiring the index root page and check table does the
opposite. Workaround is to avoid validating the index for
check table when bulk insert is in progress for the table.
2023-03-07 13:00:59 +05:30
Thirunarayanan Balathandayuthapani
062ba0bd4a MDEV-30183 Assertion `!memcmp(rec_trx_id, old_pk_trx_id->data, 6 + 7)' failed in row_log_table_apply_update
- This failure caused by commit 358921ce32
row_ins_duplicate_online() should consider if the record is an exact
match of the tuple when number of matching fields equals with number of
unique fields + DB_TRX_ID + DB_ROLL_PTR
2023-03-06 23:40:13 +05:30
Marko Mäkelä
b1646d0433 MDEV-30567 rec_get_offsets() is not optimal
rec_init_offsets_comp_ordinary(), rec_init_offsets(),
rec_get_offsets_reverse(), rec_get_nth_field_offs_old():
Simplify some bitwise arithmetics to avoid conditional jumps,
and add branch prediction hints with the assumption that most
variable-length columns are short.

Tested by: Matthias Leich
2023-03-06 17:17:32 +02:00
Marko Mäkelä
c5fdb988b7 Merge 10.11 into 11.0 2023-03-06 16:06:52 +02:00
Hugo Wen
2d6a806367 Add parameter of key file path for AWS KMS plugin
AWS KMS plugin saves all key files under the root folder of data
directory. Increasing of the key IDs and key rotations will generate a
lot of key files under the root folder, looks messy and hard to
maintain the folder permission etc.

Now introduce a new plugin parameter `aws_key_management_keyfile_dir` to
define the directory for saving the key files for better maintenance.

Detailed parameter information as following:
```
        VARIABLE_NAME: AWS_KEY_MANAGEMENT_KEYFILE_DIR
        SESSION_VALUE: NULL
         GLOBAL_VALUE: <Directory path>
  GLOBAL_VALUE_ORIGIN: COMMAND-LINE
        DEFAULT_VALUE:
       VARIABLE_SCOPE: GLOBAL
        VARIABLE_TYPE: VARCHAR
     VARIABLE_COMMENT: Define the directory in which to save key files
                       for the AWS key management plugin. If not set,
                       the root datadir will be used
            READ_ONLY: YES
COMMAND_LINE_ARGUMENT: REQUIRED
    GLOBAL_VALUE_PATH: NULL
```

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.
2023-03-06 13:22:46 +00:00
Marko Mäkelä
9267160c11 Merge 10.10 into 10.11 2023-03-06 13:39:12 +02:00
Marko Mäkelä
4ccb2be65f Merge 10.9 into 10.10 2023-03-06 13:38:39 +02:00
Marko Mäkelä
46a7603813 Merge 10.8 into 10.9 2023-03-06 13:38:16 +02:00
Marko Mäkelä
669a0c6efb Merge 10.6 into 10.8 2023-03-06 13:37:12 +02:00
Marko Mäkelä
25c048066a Merge 10.5 into 10.6 2023-03-06 13:36:06 +02:00
Marko Mäkelä
948fb3c27d Fix GCC 5.3.1 -Wsign-compare
This fixes up commit 57c526ffb8
2023-03-06 12:01:15 +02:00
Andrew Hutchings
68542c6e50 Fix warning in mariadb-install-db
If you are running mariadb-install-db from a source tree instead of
installation it was executing `mysqld` instead of `mariadb` which showed
the deprecation warning. This patch fixes that as well as fixing
messages and links to other things that have been renamed.
2023-03-06 15:16:55 +11:00
Monty
922fcc6a0e Use range instead of ref when we know that range is equal or better.
This stabilizes main.order_by_optimizer_innodb, where the result varies
depending on the rec_per_key status from the engine.

The logic to prefer range over a const ref:
- If range of has only one part and it uses more key parts than ref, then
  use the range.

Example:
WHERE key_part1=1 and key_part2 > #
Here we will prefer a range over (key_part1,key_part2) instead a ref
over key_part1.
2023-03-03 13:25:21 +02:00
Marko Mäkelä
077425a659 MDEV-30311 system-wide max transaction id corrupted after changing the undo tablespaces
This fixes a regression due to MDEV-19229. InnoDB would fail to maintain
the maximum transaction ID when it changes and reinitializes the number
of undo tablespaces. InnoDB should maintain the maximum transaction ID
in TRX_RSEG_MAX_TRX_ID of system rollback segment header.

srv_undo_tablespaces_reinit(): Preserve the system-wide maximum
transaction identifier in the TRX_RSEG_MAX_TRX_ID field of
the first rollback segment. If needed, upgrade the page to the
MariaDB 10.3 format first. All this must be done in the same
atomic mini-transaction that will reinitialize the TRX_SYS page.

Before MariaDB Server 10.3, InnoDB persisted the maximum transaction
identifier only in the TRX_SYS page. MariaDB 10.3 started to treat that
page as a read-only directory of rollback segments, and the maximum
transaction identifier will be recovered from TRX_RSEG_MAX_TRX_ID or
from undo logs. Since a change of innodb_undo_tablespaces is only
allowed when no undo log records exist, the only place to store the
persistent maximum transaction identifier is in TRX_RSEG_MAX_TRX_ID
of one of the rollback segment header pages.

The bug was observed when the database was upgraded directly from MySQL 5.7
or earlier, or from MariaDB Server 10.2 or earlier, to multiple
innodb_undo_tablespaces. On a restart of MariaDB after the upgrade,
the transaction identifier would be reported to be smaller than during
the upgrade:

2023-03-03 10:43:57 0 [Note] InnoDB: log sequence number 2762352; transaction id 1794
2023-03-03 10:44:17 0 [Note] InnoDB: log sequence number 2786076; transaction id 770
2023-03-03 11:38:43 +02:00
Alexander Barkov
0bf400a19a A cleanup for MDEV-30695 Refactor case folding data types in Asian collations
Adding "const" qualifiers to casefold_info_st::page
2023-03-03 04:49:28 +04:00
Monty
ae05097714 Fixed crashing bug in recursive SQL if write to tmp table would fail
This error was discovered while working on
MDEV-30540 Wrong result with IN list length reaching
           IN_PREDICATE_CONVERSION_THRESHOLD

If there is read error from handler::ha_rnd_next() during a recursive
query, st_select_lex_unit::exec_recursive() will crash as it will try to
get the error code from a structure that was deleted by the callee.
The code was using the construct:
   sl->join->exec();
   saved_error=sl->join->error;
This does not work as sl->join was freed by the exec() and sl->join would
be set to 0.
Fixed by having JOIN::exec() return the error code.
The included test case simulates the error in ha_rnd_next(), which causes
a crash without the patch.
scovered whle working on
MDEV-30540 Wrong result with IN list length reaching
           IN_PREDICATE_CONVERSION_THRESHOLD

If there is read error from handler::ha_rnd_next() during a recursive
query, st_select_lex_unit::exec_recursive() will crash as it will try to
get the error code from a structure that was deleted by the callee.
The code was using the construct:
   sl->join->exec();
   saved_error=sl->join->error;
This does not work as sl->join was freed by the exec() and sl->join was
set to 0.
Fixed by having JOIN::exec() return the error code.
The included test case simulates the error in ha_rnd_next(), which causes
a crash without the patch.
2023-03-02 13:11:54 +02:00
Monty
bc3596fe12 MMAP does not work reliable on windows
This error was discovered while working on
MDEV-30540 Wrong result with IN list length reaching
           IN_PREDICATE_CONVERSION_THRESHOLD

Failing test: cte_recursive.test

If one writes to a file, then truncates it and then call mmap() over the
file_size + 7, then the file size changes to 7. (On Linux mmap() does not
change file size).
This caused _ma_read_rnd_dynamic_record() to believe that there are more
records in the data file, which is not the case, and the table will be
marked as corrupted.
Fixed by disabling mmap() in Aria on Windows.
2023-03-02 13:11:54 +02:00
Monty
bd9ca2a0e3 MDEV-30540 Wrong result with IN list length reaching IN_PREDICATE_CONVERSION_THRESHOLD
The problem was the mysql_derived_prepare() did not correctly set
'distinct' when creating a temporary derivated table.

Fixed by separating checking for distinct for queries with and without
UNION.

Other things:
- Fixed bug in generate_derived_keys_for_table() where we set the wrong
  bit for join_tab->keys
- Cleaned up JOIN::drop_unused_derived_keys()
- Changed TABLE::use_index() to keep unique keys and update
  share->key_parts

Author: Sergei Petrunia <sergey@mariadb.com>, monty@mariadb.org
2023-03-02 13:11:54 +02:00
Monty
eb441f6cb7 Fixed wrong DBUG_PRINT 2023-03-02 13:11:54 +02:00
Monty
37edbbf2d3 Don't log delete_all_rows() for temporary Aria files to transaction log
- This was just a small performance issue, not a crashing bug.
2023-03-02 13:11:54 +02:00
Monty
bf9aa8687f Fixes to make dbug traces from Windows easier to compare with Unix traces
- Remove DBUG calls from my_winfile.c where call and parameters
  are already printed by mysys.
- Remove DBUG from my_get_osfhandle() and my_get_open_flags() to remove
  DBUG noise.
- Updated convert-debug-for-diff to take into account windows.
- Changed some DBUG_RETURN(function()) to tmp=function(); DBUG_RETURN(tmp);
  This is needed as Visual C++ prints for DBUG binaries a trace for
  func_a()
  {
    DBUG_ENTER("func_a");
    DBUG_RETURN(func_b())
  }
  as
  >func_a
  <func_a
  >func_b
  <func_b
instead of when using gcc:
  >func_a
  | >func_b
  | <func_b
  <func_a
2023-03-02 13:11:54 +02:00
Thirunarayanan Balathandayuthapani
49e2b50d59 MDEV-30341 Reset check_foreigns, check_unique_secondary variables
- InnoDB fails to reset the check_foreigns and check_unique_secondary
in trx_t::free(), trx_t::commit_cleanup(). This lead to bulk insert
in internal innodb fts table operation.
2023-03-02 15:49:21 +05:30
Thirunarayanan Balathandayuthapani
550b8d76b3 MDEV-30752 Assertion `!index->is_ibuf()' failed around
cmp_dtuple_rec_with_match_bytes

- InnoDB shouldn't use the adaptive hash index for change buffer indexes.
2023-03-02 11:22:40 +05:30
Daniel Black
a1211a4eda Deb: use MariaDB naming
Use MariaDB named executables.

Also remove unnecessary slave references.

rename 50-mysql-clients.cnf -> 50-mariadb-clients.cnf

50-mysqld_safe.cnf -> 50-mariadb_safe.cnf
2023-03-02 14:23:25 +11:00
Sergei Golubchik
6d923362bd CONC-637 Build fails when specifying -DPLUGIN_AUTH_GSSAPI_CLIENT=OFF 2023-02-28 20:15:56 +01:00
Marko Mäkelä
085d0ac238 Merge 10.5 into 10.6 2023-02-28 16:05:21 +02:00
Marko Mäkelä
c14a39431b MDEV-30753 Possible corruption due to trx_purge_free_segment()
Starting with commit 0de3be8cfd (MDEV-30671),
the field TRX_UNDO_NEEDS_PURGE lost its previous meaning.
The following scenario is possible:

(1) InnoDB is killed at a point of time corresponding to the durable
execution of some fseg_free_step_not_header() but not
trx_purge_remove_log_hdr().
(2) After restart, the affected pages are allocated for something else.
(3) Purge will attempt to access the newly reallocated pages when looking
for some old undo log records.

trx_purge_free_segment(): Invoke trx_purge_remove_log_hdr() as the first
thing, to be safe. If the server is killed, some pages will never be
freed. That is the lesser evil. Also, before each mtr.start(), invoke
log_free_check() to prevent ib_logfile0 overrun.
2023-02-28 15:39:23 +02:00
Marko Mäkelä
a75cd0a734 MDEV-30671 follow-up: Remove the field TRX_UNDO_NEEDS_PURGE
Because downgrades from 11.0 to older MariaDB server are not possible
due to the removal of the InnoDB change buffer, there is no need to
access the field TRX_UNDO_NEEDS_PURGE anymore.
2023-02-28 13:21:31 +02:00
Marko Mäkelä
7a834d6248 Merge 10.11 into 11.0 2023-02-28 13:14:08 +02:00
Marko Mäkelä
95d51369c9 Merge 10.10 into 10.11 2023-02-28 10:52:42 +02:00
Marko Mäkelä
f14d9fa09a Merge 10.9 into 10.10 2023-02-28 10:43:29 +02:00
Marko Mäkelä
c3246e4bf0 Merge 10.8 into 10.9 2023-02-28 10:37:11 +02:00
Marko Mäkelä
6ac44ac3ab Merge 10.6 into 10.8 2023-02-28 10:36:17 +02:00
Monty
57c526ffb8 Added detection of memory overwrite with multi_malloc
This patch also fixes some bugs detected by valgrind after this
patch:

- Not enough copy_func elements was allocated by Create_tmp_table() which
  causes an memory overwrite in Create_tmp_table::add_fields()
  I added an ASSERT() to be able to detect this also without valgrind.
  The bug was that TMP_TABLE_PARAM::copy_fields was not correctly set
  when calling create_tmp_table().
- Aria::empty_bits is not allocated if there is no varchar/char/blob
  fields in the table.  Fixed code to take this into account.
  This cannot cause any issues as this is just a memory access
  into other Aria memory and the content of the memory would not be used.
- Aria::last_key_buff was not allocated big enough. This may have caused
  issues with rtrees and ma_extra(HA_EXTRA_REMEMBER_POS) as they
  would use the same memory area.
- Aria and MyISAM didn't take extended key parts into account, which
  caused problems when copying rec_per_key from engine to sql level.
- Mark asan builds with 'asan' in version strihng to detect these in
  not_valgrind_build.inc.
  This is needed to not have main.sp-no-valgrind fail with asan.
2023-02-27 19:25:44 +02:00
Monty
50c8e65b38 Fixed bug in optimizer_costs.test
The test failed if one had disabled some engines during compilation
2023-02-27 14:41:31 +02:00