1
0
mirror of https://github.com/MariaDB/server.git synced 2025-04-18 21:44:20 +03:00

202987 Commits

Author SHA1 Message Date
Daniel Black
3d54cd6cf5 update C/C 2025-03-25 09:56:10 +01:00
Marko Mäkelä
33a462e0b1 MDEV-36373 Bogus Warning: ... storage is corrupted
ha_innobase::statistics_init(), ha_innobase::info_low():
Correctly handle a DB_READ_ONLY return value from dict_stats_save().
Fixes up commit 6e6a1b316ca8df5116613fbe4ca2dc37b3c73bd1 (MDEV-35000)
2025-03-25 08:48:08 +02:00
Jan Lindström
1277f9b451 MDEV-36372: Compilation is broken with the PLUGIN_PARTITION=NO
Fixed a compilation error caused by MDEV-27861 that
occurs when building with cmake -DPLUGIN_PARTITION=NO,
because the default_part_plugin variable is only
visible when WITH_PARTITION_STORAGE_ENGINE is defined.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2025-03-25 02:50:37 +01:00
Faustin Lammler
ab468e33af Add a sanity check for backups
The check makes sure that the backup contains the latest PR information
(based on title and PR number).
2025-03-25 08:30:12 +11:00
Alexander Barkov
3bbe11acd9 MDEV-20912 Add support for utf8mb4_0900_* collations in MariaDB Server
Fixing a wrong alias utf8mb4_0900_bin:
- was utf8mb4_bin
- changed to utf8mb4_nopad_bin

MySQL 0900 collations are NOPAD, including utf8mb4_0900_bin.
2025-03-24 21:10:09 +04:00
Amar Jilani
b0ec99398f MDEV-21375: Get option group suffix from $MARIADB_GROUP_SUFFIX in addition to $MYSQL_GROUP_SUFFIX
Add check for MARIADB_GROUP_SUFFIX environment variable when
--default-group-suffix argument is not passed. This environment variable
will take precedence over the MYSQL_GROUP_SUFFIX environment variable if
both are set.

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.
2025-03-24 15:36:35 +04:00
Aleksey Midenkov
4c695c85bd MDEV-34775 Wrong reopen of already open routine due to auto-create in SP
MDEV-34171 denied removing indirect routines/tables after
recover_from_failed_open() for auto-create partition case. Now we are
going further and keep them for any failed table reopen.

MDEV-34171 did not handle correctly open_and_process_routine() after
that skip of sp_remove_not_own_routines(). Now it is fixed by
sroutine_to_open correct usage.
2025-03-24 09:01:07 +03:00
Dmitry Shulga
cc831f16c8 MDEV-36079: Stored routine with a cursor crashes on the second execution if a DDL statement happened
Attempt to run a cursor after change in metadata of tables it depends on
resulted in firing assertion on allocating a memory from a memory root
marked as read only.

On every execution of a cursor its Query_arena is set up as a statement
arena (see sp_lex_keeper::cursor_reset_lex_and_exec_core()).
As a consequence, any memory allocations happened on execution of
the cursor's query should be taken from the cursor's memory root.
The reason of allocating a memory from the memory root marked as read
only is that the cursor's memory root points to a memory root of
sp_head that could be already marked as read only after first
successful execution and this relation isn't changed on re-parsing of
the cursor's query.

To fix the issue, memory root of cursor is adjusted in the method
sp_lex_instr::parse_expr() to point to the new memory root just
created for re-parsing of failed query.
2025-03-24 12:39:31 +07:00
Vasilii Lakhin
5f7c2a617f Fix typos in C comments in miscellaneous files 2025-03-24 13:36:28 +11:00
Alexander Barkov
98a75d111c MDEV-36322 Comparison ROW(stored_func(),1)=ROW(1,1) calls the function twice per row
Item_func_sp::execute() was called two times per row in this scenario:

SELECT ROW(f1(),1) = ROW(1,1), @counter FROM seq_1_to_5;

- the first time from Item_func_sp::bring_value()
- the second time from Item_func_sp::val_int()

Fix:

Changing Item_func_sp::bring_value() to call execute() only
when the result type is ROW_RESULT.
2025-03-22 07:11:51 +04:00
Alexander Barkov
5f7e883336 MDEV-36322 Comparison ROW(stored_func(),1)=ROW(1,1) calls the function twice per row
Item_func_sp::execute() was called two times per row in this scenario:

SELECT ROW(f1(),1) = ROW(1,1), @counter FROM seq_1_to_5;

- the first time from Item_func_sp::bring_value()
- the second time from Item_func_sp::val_int()

Fix:

Changing Item_func_sp::bring_value() to call execute() only
when the result type is ROW_RESULT.
2025-03-21 23:47:02 +04:00
Brad Smith
05be1865a9 Fix building with Clang and GCC on RISC-V
Clang does not have the builtin __builtin_riscv_pause().
2025-03-21 18:28:36 +01:00
Faustin Lammler
c34bb80b3d MDBF-1000: wrong urls 2025-03-21 18:49:45 +02:00
Thirunarayanan Balathandayuthapani
f1deebbb0b MDEV-35420 Server aborts while deleting the record in spatial index
- This issue caused by commit a032f14b342c782b82dfcd9235805bee446e6fe8(MDEV-33559).
In MDEV-33559, matched_rec::block was changed to pointer
and assinged with the help of buf_block_alloc(). But patch
fails to check for the block can be nullptr in
rtr_check_discard_page().

rtr_cur_search_with_match(): Acquire rtr_match_mutex before
creating shadow block for the matched records

rtr_pcur_move_to_next(): Copy the shadow block to page cursor
block under rtr_match_mutex
2025-03-21 15:26:21 +01:00
KhaledR57
f813c8541a MDEV-34621 Fix division by zero in mariadb-slap when iterations=0
mariadb-slap crashes with a floating point exception when run with
-iterations=0 due to division by zero in generate_stats(). This occurs
when calculating average timing by dividing by the number of iterations.

To fix this, the solution checks if iterations == 0 before performing
the division, and returns early from the function in such cases.
2025-03-21 14:01:52 +04:00
Dmitry Shulga
56bc6901d6 MDEV-34501: SIGSEGV in pfs_start_mutex_wait_v1, __strlen_avx2, or __strlen_evex from safe_mutex_lock on CREATE DEFINER when using skip-grant-tables
Attempt to create a procedure with the DEFINER clause resulted in
abnormal server termination in case the server run with the option
--skip-grant-tables=1.

The reason of abnormal termination is that on handling of the DEFINER
clause, not initialized data members of acl_cache is accessed, that led
to server crash.

Behaviour of the server for considered use case must be the same
as for embedded server. Than means, if a security subsytem wasn't
initialized (server is started with the option --skip-grant-tables=1)
return success from get_current_user() without further access to the
acl_cache that obviously not initialized.

Additionlly, AUTHID::is_role was modified to handle the case when
a host part of the user name isn't provided. Treat this case as if
the empty host name is provided.
2025-03-21 09:25:15 +01:00
Faustin Lammler
31adb3030c MDBF-1000: implement an export for the server repository
No MariaDB server code is touched here, this is only about GitHub
actions CI.
2025-03-21 12:18:10 +11:00
Aleksey Midenkov
64ea539f76 MDEV-36208 dbug_print_table_row is broken: prints empty rows in debugger 2025-03-20 19:14:35 +01:00
Marko Mäkelä
2a92cf8b0c MDEV-35000 fixup: GCC 4.8.5 -Wconversion
Old GCC versions would issue bogus -Wconversion.
Let us silence this one with a redundant cast.
2025-03-20 15:29:43 +02:00
Dave Gosselin
923094b4cd MDEV-36094 Row ID filtering for reverse-ordered scans
The fix for MDEV-34413 added support for Index Condition Pushdown with reverse
ordered scans.  This makes Rowid filtering work with reverse-ordered scans, too,
so enable it.  For example, InnoDB can now check the pushed index condition and
then check the rowid filter on success, in the ORDER BY ... DESC case.
2025-03-20 08:28:24 -04:00
Dave Gosselin
24b5c3021d MDEV-36094 Row ID filtering for reverse-ordered scans
Add tests showing that RowID filtering is not enabled for
reverse-ordered scans.
2025-03-20 08:28:24 -04:00
Christian Hesse
02893e875b MDEV-35969 wsrep: set new status for service manager
On WSREP state transfer the status in service manager changes to:

    WSREP state transfer (role ...) ongoing...

This status was not changed after state transfer was complete. Let's
change it again to reflect now situation:

    WSREP state transfer (role ...) comleted.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2025-03-20 05:03:51 +01:00
Christian Hesse
0b8762822e MDEV-35969 wsrep: add more details in service manager status
Let's show the difference between donor and joiner.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2025-03-20 05:03:42 +01:00
Yuchen Pei
b50df7bbd4
MDEV-36220 Correct length in memcpy saving and restoring found NULL record in loose index scan of min
Use reclength because rec_buff_length is the actual reclength with
padding, whose use could cause ASAN unknown-crash, presumably caused
by memory violation.
2025-03-20 10:31:34 +11:00
Dave Gosselin
7e4233746e MDEV-34413 Index Condition Pushdown for reverse ordered scans
Allows index condition pushdown for reverse ordered scans, a previously
disabled feature due to poor performance.  This patch adds a new
API to the handler class called set_end_range which allows callers to
tell the handler what the end of the index range will be when scanning.
Combined with a pushed index condition, the handler can scan the index
efficiently and not read beyond the end of the given range.  When
checking if the pushed index condition matches, the handler will also
check if scanning has reached the end of the provided range and stop if
so.

If we instead only enabled ICP for reverse ordered scans without
also calling this new API, then the handler would perform unnecessary
index condition checks.  In fact this would continue until the end of
the index is reached.

These changes are agnostic of storage engine.  That is, any storage
engine that supports index condition pushdown will inhereit this new
behavior as it is implemented in the SQL and storage engine
API layers.

The partitioned tables storage meta-engine (ha_partition) adds an
override of set_end_range which recursively calls set_end_range on its
child storage engine (handler) implementations.

This commit updates the test made in an earlier commit to show that
ICP matches happen for the reverse ordered case.

This patch is based on changes written by Olav Sandstaa in
MySQL commit da1d92fd46071cd86de61058b6ea39fd9affcd87
2025-03-19 16:03:29 -04:00
Dave Gosselin
261d5520a2 MDEV-34413 Index Condition Pushdown for reverse-ordered scans
Adds tests which show that ICP was not enabled for reverse-ordered scans
prior to this mdev.  A later commit for this same mdev records again
these same tests, showing that ICP for reverse-ordered scans is
enabled and working.
2025-03-19 16:03:29 -04:00
Alexander Barkov
2ae721f2ad MDEV-36179 Assertion `0' failed in virtual bool Type_handler_row::Item_save_in_value(THD*, Item*, st_value*) const
sp_head::execute_procedure() and sp_head::execute_function() did not
check that Item_param could be passed as an actual parameter to a ROW type
formal parameter of a stored routine. Example:

CREATE PROCEDURE p0(OUT a ROW(a INT,b INT)) ...;
PREPARE s0 'CALL p0(?)';
EXECUTE p0 USING @a;

In case of passing a user variable as an OUT parameter it led to
a crash after executing routine instructions, when copying formal
OUT parameters to the bound actual parameters.

Fix:
Check cases when Item_param is being bound to a ROW type formal parameter.
Raise an error if so. The new check is done for all parameter modes:
IN, OUT, INOUT, for a consistent error message.

The new check is done before executing the routine instructions.
2025-03-19 16:50:23 +04:00
ParadoxV5
15848a75a7 MDEV-36238 Functional Tests for --master-info-file and --show-slave-auth-info
Add MTR tests in the `multi_source` suite to validate future changes
that they does not affect the function of these two `mariadbd` options
```
master_info_file
rpl_show_slave_auth_info
```

Reviewed-by: Susil Kumar Behera <susil.behera@mariadb.com>
2025-03-18 18:17:02 -06:00
Sergey Vojtovich
c3f21762e9 Corrections to parent "speedup collation" commit
Rather than populating collation_name_hash in a separate loop, call
my_hash_insert() from appropriate methods.
2025-03-18 18:40:43 +04:00
Jitesh Chawla
543ebbcf8e MDEV-35876 - speedup collation/charset lookup
Replaces O(n) linear scans for collation lookups with O(1) hash lookups
to eliminate performance bottlenecks as collation counts grow.
2025-03-18 18:40:43 +04:00
Marko Mäkelä
1756b0f37d MDEV-35813: more robust test case
Let us integrate the test case with innodb.page_cleaner so that there
will be less interference from log writes due to checkpoints.
Also, make the test compatible with ./mtr --cursor-protocol.
2025-03-18 10:41:38 +02:00
Marko Mäkelä
0e8e0065d6 MDEV-35813 test case 2025-03-17 16:21:09 +02:00
Dmitry Shulga
408a637b87 MDEV-29344: engines/iuds.insert_time cannot run with PS protocol (syntax error)
The syntax error produced on running the test engines/iuds.insert_time
in PS-mode was caused by presence of the C-Style comment containing
the single quote at the end of SQL statement, something like
the following one:
  /* doesn't throw error */;
Presence of the single quote was interpreted by mysqltest utility as
indication of real string literal, that resulted in consuming every
characters following that mark as a literal, including the delimiter
character ';'. It led to concatenation of lines into a single
multi-statement that was sent from mysqltest to MariaDB server for
processing. In case mysqltest is run in regular mode (that is,
not PS-mode), multi-statement is handled successfully on server side,
but in case PS-mode is on, multi-statement is supplied in COM_STMT_PREPARE
that caused the parsing error since multi-statements is not supported by
statement prepare command.

To fix the issue, in case mysqltest encounters the C-Style comment
is should switch to reading next following characters without any
processing until it hit the closing C-style comment marks '*/',
with one exception if the sequence of characters '/*' followed by
the exclamation mark, that means the hint introducer has been read.
2025-03-17 18:11:51 +07:00
mariadb-DebarunBanerjee
a8e35a1cc6 MDEV-36149 UBSAN in X is outside the range of representable values of type 'unsigned long' | page_cleaner_flush_pages_recommendation
Currently it is allowed to set innodb_io_capacity to very large value
up to unsigned 8 byte maximum value 18446744073709551615. While
calculating the number of pages to flush, we could sometime go beyond
innodb_io_capacity. Specifically, MDEV-24369 has introduced a logic
for aggressive flushing when dirty page percentage in buffer pool
exceeds innodb_max_dirty_pages_pct. So, when innodb_io_capacity is
set to very large value and dirty page percentage exceeds the
threshold, there is a multiplication overflow in Innodb page cleaner.

Fix: We should prevent setting io_capacity to unrealistic values and
define a practical limit to it. The patch introduces limits for
innodb_io_capacity_max and innodb_io_capacity to the maximum of 4 byte
unsigned integer i.e. 4294967295 (2^32-1). For 16k page size this limit
translates to 64 TiB/sec write IO speed which looks sufficient.

Reviewed by: Marko Mäkelä
2025-03-17 11:44:09 +05:30
Sam Bull
839828e57f MDEV-36009: Systemd: Restart on OOM
Per https://github.com/systemd/systemd/issues/36529 OOM counts
as a on-abnormal condition. To ensure that MariaDB testart on
OOM the Restart is changes to on-abnormal which an extension
on the current on-abort condition.
2025-03-15 18:10:37 +07:00
Kristian Nielsen
d931bb8174 MDEV-36287: Server crash in SHOW SLAVE STATUS concurrent with STOP SLAVE
In SHOW SLAVE STATUS, do not access members of the SQL thread's THD without
holding mi->run_lock. Otherwise the THD can go away in case of concurrent
STOP SLAVE, leading to invalid memory references and server crash.

Reviewed-by: Monty <monty@mariadb.org>
Reviewed-by: Brandon Nesterenko <brandon.nesterenko@mariadb.com>
Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2025-03-15 11:16:00 +01:00
Kristian Nielsen
acaf07daed Add --source include/long_test.inc to some tests
This will make mysql-test-run.pl try to schedule these long-running
(> 60 seconds) tests early in --parallel runs, which helps avoid that
the testsuite gets stuck with a few long-running tests at the end
while most other test workers are idle.

This speed up mtr --parallel=96 with 25 seconds for me.

Reviewed-by: Brandon Nesterenko <brandon.nesterenko@mariadb.com>
Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2025-03-15 11:15:54 +01:00
Kristian Nielsen
b6b6bb8d36 Fix sporadic failures of rpl.rpl_gtid_crash
- Suppress a couple errors the slave can get as the master crashes.

 - The mysql-test-run occasionally takes 120 seconds between crashing
   the master and starting it back up for some (unknown) reason. For
   now, work-around that by letting the slave try for 500 seconds to
   connect to master before giving up instead of only 100 seconds.

Reviewed-by: Brandon Nesterenko <brandon.nesterenko@mariadb.com>
Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2025-03-15 11:15:36 +01:00
Marko Mäkelä
c3c5cd9377 MDEV-35813 Unnecessary InnoDB log writes in INSERT…SELECT
ha_innobase::extra(): Conditionally avoid a log write that had been
added in commit e5b9dc15368c7597a70569048eebfc5e05e98ef4 (MDEV-25910)
because it may be invoked as part of select_insert::prepare_eof()
and not only during DDL operations.

Reviewed by: Sergei Golubchik
2025-03-14 16:02:01 +01:00
Sergey Vojtovich
feb1cf9086 Corrections to parent "fix typos" commmit 2025-03-14 12:08:56 +04:00
Vasilii Lakhin
717c12de0e Fix typos in C comments inside sql/ 2025-03-14 12:08:56 +04:00
Brandon Nesterenko
01cf1cb84b MDEV-7850: Optimize Query_log_event::begin_event()
* Use bfill() to pad a Query_log_event (from GTID event) instead
of a loop.
 * Add error conditions

Co-author: Monty <monty@mariadb.org>
2025-03-13 14:23:16 -06:00
Kristian Nielsen
04e114aec0 Fix sporadic failure of rpl.parallel_backup_xa_debug
The test case set debug_sync=RESET without waiting for the server thread to
receive the prior signal. This can cause the signal to be lost, the thread to
not wake up, and thus the test to time out.

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2025-03-13 18:58:12 +01:00
Kristian Nielsen
6810cdae1b Add --source include/long_test.inc to a few long-running tests
Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2025-03-13 11:26:02 +01:00
Marko Mäkelä
38e420ba6e Merge 10.11 into 11.4 2025-03-11 13:47:46 +02:00
Kristian Nielsen
2641409731 Fix redundant ER_PRIOR_COMMIT_FAILED in parallel replication
wait_for_prior_commit() can be called multiple times per event group,
only do my_error() the first time the call fails.

Remove redundant set_overwrite_status() calls.

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
Reviewed-by: Monty <monty@mariadb.org>
2025-03-11 12:45:59 +01:00
Yuchen Pei
55efe47d3c
MDEV-36118 Fix wrong result with MAX in loose index scan
Loose index scan currently only supports ASC key. When searching for
the next MAX value, the search starts from the rightmost range and
moves towards the left. If the key has "moved" as the result of a
successful ha_index_read_map() call when handling a previous range, we
check if the key is to the left of the current range, and if so, we
can skip to the next range.

The existing check on whether the loop has iterated at least once is
not sufficient, as an unsuccessful ha_index_read_map() often (always?)
does not "move" the key.
2025-03-11 15:29:05 +11:00
Marko Mäkelä
652f33e0a4 MDEV-30000: Force an InnoDB checkpoint in mariadb-backup
At the start of mariadb-backup --backup, trigger a flush of the
InnoDB buffer pool, so that as little log as possible will have
to be copied.

The previously debug-build-only interface
SET GLOBAL innodb_log_checkpoint_now=ON;
will be made available on all builds, and
mariadb-backup --backup will invoke it, unless the option
--skip-innodb-log-checkpoint-now is specified.

Reviewed by: Vladislav Vaintroub
2025-03-10 08:48:43 +02:00
Thirunarayanan Balathandayuthapani
5b686cc8f9 MDEV-36253 Redundant check in wf_incremental_process()
- Remove the redundant check of TRX_SYS page change in
wf_incremental_process()

- Remove the double casting of srv_undo_tablespaces
in write_backup_config_file()

- Remove the unused variables like checkpoint_lsn_start
and checkpoint_no_start.

This is a regression which caused by commit 1c55b845e0fe337e647ba230288ed13e966cb7c7.
2025-03-10 11:48:18 +05:30
Monty
eef94c9d46 MDEV-36248 Connect crashes server because of duplicate 'free()' in GetUser
If connect engineis not able to allocate connect_work_space memory for
GetUser() it will call free() twice with the same value (g).

g was freed first in user_connect::user_init() which calls PlugExit() on
errors and then again in ~user_connect() which also calls PlugExit().

Fixed by setting g to 0 in user_init() after calling PlugExit()
This code was tested 'by hand' by setting connect.work_space=600G

Other things:
- Removed some very old not relevant comments in touched code
- Added comments to clarify how some memory was freed
- Fixed indentation in changed functions.
2025-03-09 16:01:53 +02:00