Commit graph

202647 commits

Author SHA1 Message Date
Aleksey Midenkov
0dcd30197a MDEV-25654 Unexpected ER_CRASHED_ON_USAGE and Assertion
`limit >= trx_id' failed in purge_node_t::skip

For fast alter partition ALTER lost hash fields in frm field
count. mysql_prepare_create_table() did not call add_hash_field()
because the logic of ALTER-ing field types implies automatic
promotion/demotion to/from hash index. So we don't pass hash algorithm
to mysql_prepare_create_table() and let it decide itself, but it
cannot decide it correctly for fast alter partition.

So now mysql_prepare_alter_table() is a bit more sophisticated on what
to pass in the algorithm. If not changed any fields it will force
mysql_prepare_create_table() to re-add hash fields by setting
HA_KEY_ALG_HASH.

The problem with the original logic is mysql_prepare_alter_table()
does not care 100% about hash property so the decision is blurred
between mysql_prepare_alter_table() and mysql_prepare_create_table().
2025-01-14 18:56:13 +03:00
Aleksey Midenkov
0cf2176b79 MDEV-34033 Exchange partition with virtual columns fails
MDEV-28127 did is_equal() which compared vcol expressions
literally. But another table vcol expression is not equal because of
different table name.

We implement another comparison method is_identical() which respects
different table name in vcol comparison. If any field item points to
table_A and compared field item points to table_B, such items are
treated as equal in (table_A, table_B) comparison. This is done by
cloning table_B expression and renaming any table_B entries to table_A
in it.
2025-01-14 18:56:13 +03:00
Aleksey Midenkov
92383f8db1 MDEV-26891 Segfault in Field::register_field_in_read_map upon INSERT
DELAYED with virtual columns

Segfault was cause by two different copies of same Field instance in
prepared delayed insert. One was made by
Delayed_insert::get_local_table() (see make_new_field()). That copy
went through parse_vcol_defs() and received new vcol_info->expr.

Another one was made by copy_keys_from_share() by this code:

        /*
          We are using only a prefix of the column as a key:
          Create a new field for the key part that matches the index
        */
        field= key_part->field=field->make_new_field(root, outparam, 0);
        field->field_length= key_part->length;

So, key_part and table got different objects of same field and the
crash was because key_part->field->vcol_info->expr is NULL.

The fix does update_keypart_vcol_info() to update vcol_info->expr in
key_part->field.

Cleanup: memdup_vcol() is static inline instead of macro + check OOM.
2025-01-14 18:56:13 +03:00
Aleksey Midenkov
d8adc52863 MDEV-22441 SCOPE_VALUE macro for temporary values
- Needless engaged_ removed;
  - SCOPE_VALUE, SCOPE_SET, SCOPE_CLEAR macros for neater declaration;
  - IF_CLASS / IF_NOT_CLASS SFINAE checkers to pass arg by value or
    reference;
  - inline keyword;
  - couple of refactorings of temporary free_list.
2025-01-14 18:56:13 +03:00
Eugene Kosov
52dd489515 MDEV-22441 implement a generic way to change a value of a variable in a scope
Example:
{
  auto _= make_scope_value(var, tmp_value);
}

make_scope_value(): a function which returns RAII object which temporary
changes a value of a variable

detail::Scope_value: actual implementation of such RAII class.
It shouldn't be used directly! That's why it's inside a namespace detail.
2025-01-14 18:54:43 +03:00
Aleksey Midenkov
b337e14440 WITHOUT_ABI_CHECK
ABI check takes several seconds on compilation. It is not needed in
repetitive build during the development process.
2025-01-14 18:54:43 +03:00
Sergei Golubchik
4469540d39 MDEV-35810 fix test results
followup for aa35f62f1c
2025-01-14 14:01:28 +01:00
Sergei Golubchik
b04fb9fb43 MDEV-34062 compilation failure on 32bit
extra/mariabackup/xtrabackup.cc:3407:15: error: conversion from ‘lsn_t’ {aka ‘long long unsigned int’} to ‘size_t’ {aka ‘unsigned int’} may change value [-Werror=conversion]

followup for 6acada713a
2025-01-14 13:59:22 +01:00
Sergei Golubchik
9d80422f79 MDEV-26266 disable the test on 10.11 for now 2025-01-14 13:49:24 +01:00
ParadoxV5
200c235244 MDEV-35429 my_snprintf fixes for 10.5+
* Innobase `os0file.cc`: use `PRIu64` over `llu`
  * These came after I prepared #3485.
* MyISAM `mi_check.c`: in impossible block length warning
  * I missed this one in #3485 (and #3360 too?).
2025-01-14 17:57:51 +11:00
Daniel Black
6868d965db MDEV-34825 FreeBSD fails to build under clang natively (postfix)
The fix in MDEV-34825/#3484/dff354e7df2f originally just took the FreeBSD carried
patch of inline ASM as it didn't have the __ppc_get_timebase function.

What clang does have is the __builtin_ppc_get_timebase, which was
replaced in the same commit, which was the fix taken from Alpine.

To reduce complexity - we only need one working function rather
than an equivalent asm implementation.

Noted by Marko, thanks!
2025-01-14 17:20:50 +11:00
Daniel Black
e55fe2c2e3 MDEV-32686 Use Red Hat package notes in compilation
This tests the compile using a spec file. This spec
file is defined by environment variables.

If the spec file doesn't exist (SLES/OpenSUSE),
isn't supported (e.g. clang), or has incorrect environment
variables the linker flag won't be used.

Stripping output avoid gcc ICE bug
https://bugzilla.redhat.com/show_bug.cgi?id=2336272

Launcher used to make env variables show up in the
build step rather than just the configure step.
2025-01-14 14:22:30 +11:00
Daniel Black
5335681f67 MDEV-32686: Debian: include ELF package notes
Providing build information compiled into the
executable provides the ability of core file
handlers to access information on the distro
and source package version. This information
can sometime be lost between the source and
an upstream bug report.

The Debian dh-package-notes includes the
makefile included in debian/rules that
sets linking flags to the right values.

The jammy version of dh-package-notes does
not include the same makefile implementation
as the others.

ref: https://systemd.io/ELF_PACKAGE_METADATA/

fix
2025-01-14 14:22:30 +11:00
Denis Protivensky
d1f2ceee1b MDEV-33064: Sync trx->wsrep state from THD on trx start
Replace trx->wsrep= 0 with an assert in trx_rollback_for_mysql()

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2025-01-14 02:17:22 +01:00
Denis Protivensky
901c6c7ab6 MDEV-33064: Sync trx->wsrep state from THD on trx start
InnoDB transactions may be reused after committed:
- when taken from the transaction pool
- during a DDL operation execution

In this case wsrep flag on trx object is cleared, which may cause wrong
execution logic afterwards (wsrep-related hooks are not run).

Make trx->wsrep flag initialize from THD object only once on InnoDB transaction
start and don't change it throughout the transaction's lifetime.
The flag is reset at commit time as before.

Unconditionally set wsrep=OFF for THD objects that represent InnoDB background
threads.

Make Wsrep_schema::store_view() operate in its own transaction.

Fix streaming replication transactions' fragments rollback to not switch
THD->wsrep value during transaction's execution
(use THD->wsrep_ignore_table as a workaround).

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2025-01-14 02:17:22 +01:00
Daniel Black
4b0ac5a12b MDEV-35838 libressl support differences in CRYPTO_set_mem_functions
Based on FreeBSD patch.

The FreeBSD inclusion of check_openssl_compatibility prevented
any use of the crypto callbacks and as such the later differences
where ignored.

The later differences in coc_malloc didn't propegate to the other
callback functions of CRYPTO_set_mem_functions where a reduced
argument list also applied.

Looking where[2] libressl added the functions it was of the
same prototype 10 years ago so omitting any version check.

[1] a34cf9c2db/databases/mariadb106-server/files/patch-mysys__ssl_openssl.c
[2] 5ebad8acea (diff-7f393e5489e6c5780773408f11ca27d9b3bb8f55b174631a1e9467a1dd3010b9R22)
2025-01-14 12:13:22 +11:00
Brandon Nesterenko
d8c841d0d4 MDEV-35096: History is stored in different partitions on different nodes when using SYSTEM VERSION
Row-injection updates don’t correctly set the historical partition
for tables with system versioning and system_time partitions. This
results in inconsistencies between the master and slave when
replicating transactions that target such tables (i.e. the primary
server would correctly distribute archived rows amongst its
partitions, whereas the replica would have all archived rows in a
single partition). The function
partition_info::vers_set_hist_part(THD*) is used to set the
partition; however, its initial check for
vers_require_hist_part(THD*) returns false, bypassing the rest of
the function (which sets up the partition to use). This is because
the actual check uses the LEX sql_command (via
LEX::vers_history_generating()) to determine if the command is valid
to generate history. Row injections don’t have sql_commands though.

This patch provides a fix which extends the check in
vers_history_generating() to additionally allow row injections to be
history generating (via the function LEX::is_stmt_row_injection()).

Special thanks to Jan Lindstrom <jan.lindstrom@galeracluster.com>
for his work in reproducing the bug, and providing an initial test
case.

Reviewed By
============
Kristian Nielsen <knielsen@knielsen-hq.org>
Aleksey Midenkov <midenok@mariadb.com>
2025-01-13 15:59:07 -07:00
Sergei Golubchik
8ef37ade17 MDEV-35745 Assertion failure, ASAN errors, crash in mhnsw_read_first/mhnsw_read_next
If the table has many deleted nodes, they can overflow
`candidates` even when `best` isn't full yet
2025-01-13 19:57:12 +01:00
Sergei Golubchik
0eaefafbaf MDEV-35769 ER_SQL_DISCOVER_ERROR upon updating vector key column using incorrect value
return as soon as the error status is known.

also, init_from_sql_statement_string() cannot be run if thd->is_error(),
assert it.
2025-01-13 19:57:12 +01:00
Sergei Golubchik
cca243bf02 MDEV-35768 Vector key is not used upon selecting from views / subqueries 2025-01-13 19:57:12 +01:00
Sergei Golubchik
61806af658 MDEV-35417 InnoDB crashes under ... AND DISABLE CHECKPOINT
restore pre-11.7 behavior when InnoDB was ignoring the
"AND DISABLE CHECKPOINT" clause of FTWGRL.

InnoDB isn't ready for it yet
2025-01-13 19:57:12 +01:00
Sergei Golubchik
8de5b58627 Bump the VERSION 2025-01-13 19:57:12 +01:00
Dave Gosselin
c618c6612f MDEV-35805 Update main.lowercase_table4 for new default collation
Update main.lowercase_table4 for new default collation at 11.6 as
described in https://mariadb.com/kb/en/setting-character-sets-and-collations/
2025-01-13 13:39:44 -05:00
Jan Lindström
133e26fd7d MDEV-34924 : gtid_slave_pos table neven been deleted on non replica nodes (wsrep_gtid_mode = 1)
Problem was caused by MDEV-31413 commit 277968aa where
mysql.gtid_slave_pos table was replicated by Galera.
However, as not all nodes in Galera cluster are replica
nodes, rows were not deleted from table.

In this fix this is corrected so that mysql.gtid_slave_pos
table is not replicated by Galera. Instead when Galera
node receives GTID event and wsrep_gtid_mode=1, this event
is stored to mysql.gtid_slave_pos table.

Added test case galera_2primary_replica for 2 async
primaries replicating to galera cluster.

Added test case galera_circular_replication where
async primary replicates to galera cluster and
one of the galera cluster nodes is master
to async replica.

Modified test case galera_restart_replica to monitor
gtid positions and rows in mysql.gtid_pos_table.
2025-01-13 19:14:26 +01:00
Marko Mäkelä
fe2f237768 MDEV-35808 Test case to handle undo tablespace truncation in Mariabackup
This is the test case from commit 46aaf328ce
(MDEV-35830) to cover backup_undo_trunc() in the regression tests of
earlier major versions of mariadb-backup.
2025-01-13 17:43:58 +02:00
Marko Mäkelä
46aaf328ce MDEV-35830 Fix innodb_undo_log_truncate in backup
recv_sys_t::parse(): Correctly handle the storing==BACKUP case,
and simplify some logic around storing==YES as well.

The added test mariabackup.undo_truncate is based on an idea of
Thirunarayanan Balathandayuthapani. It nondeterministically (not on
every run) covers this logic, including the function backup_undo_trunc(),
for both innodb_encrypt_log=ON and innodb_encrypt_log=OFF.

Reviewed by: Debarun Banerjee
2025-01-13 16:57:11 +02:00
Alexander Barkov
1327f40f96 MDEV-35596 Assertion `type_handler()->result_type() ==
value.type_handler()->result_type()' failed in
virtual bool Item_param::get_date(THD*, MYSQL_TIME*, date_mode_t)

Adding mtr tests forgotten in the previous commit.
2025-01-13 17:51:51 +04:00
Alexander Barkov
14f42e12a4 MDEV-35596 Assertion `type_handler()->result_type() ==
value.type_handler()->result_type()'
failed in virtual bool Item_param::get_date(THD*, MYSQL_TIME*, date_mode_t)

This is a cleanup for MDEV-25593. When binding from NULL, IGNORE or DEFAULT,
value.type_handler should be set to &type_handler_null,
to satisfy the DBUG_ASSERT in Item_param::get_date().
2025-01-13 16:29:11 +04:00
Oleksandr Byelkin
0d35fe6e57 MDEV-35326: Memory Leak in init_io_cache_ext upon SHUTDOWN
The problems were that:
1) resources was freed "asimetric" normal execution in send_eof,
 in case of error in destructor.
2) destructor was not called in case of SP for result objects.
(so if the last SP execution ended with error resorces was not
freeded on reinit before execution (cleanup() called before next
execution) and destructor also was not called due to lack of
delete call for the object)

Result cleanup() renamed to reset_for_next_ps_execution() to better
reflect function().

All result method revised and freeing resources made "symetric".

Destructor of result object called for SP.

Added skipped invalidation in case of error in insert.

Removed misleading naming of reset(thd) (could be mixed with
with reset()).
2025-01-13 10:04:27 +01:00
Marko Mäkelä
aa35f62f1c MDEV-35810 Missing error handling in log resizing
log_t::resize_start(): If the ib_logfile101 cannot be created,
be sure to reset log_sys.resize_lsn.

log_t::resize_abort(): In case SET GLOBAL innodb_log_file_size is
aborted, delete the ib_logfile101.
2025-01-13 10:41:40 +02:00
Marko Mäkelä
d5a417b9d5 MDEV-35827 The generic MY_RELAX_CPU is expensive
MY_RELAX_CPU(): On GCC and compatible compilers (including clang and
its derivatives), let us use a null inline assembler block as the
fallback. This should benefit s390x and LoongArch, for example.

Also, let us remove the generic fallback block that does exactly the
opposite of what this function aims to achieve: avoid hogging the
memory bus so that other threads will have a chance to let our spin
loop to proceed.

On RISC-V, we will use __builtin_riscv_pause() which is a valid
instruction encoding in all ISA versions according to
https://gcc.gnu.org/pipermail/gcc-patches/2021-January/562936.html
2025-01-13 09:14:30 +02:00
Marko Mäkelä
4fc3a44bab MDEV-33447 fixup: pmem_persist() on RISC-V and LoongArch
Let us enable pmem_persist() on RISC-V and LoongArch, because those are
available in the Debian CI.
In commit 3f9f5ca48e these were initially
disabled by default.

According to the available documentation, these instructions are
available in all ISA versions. On LoongArch there would also be
__builtin_loongarch_dbar() that generates the same code.
2025-01-13 07:28:40 +02:00
Marko Mäkelä
42e6058629 MDEV-35785 innodb_log_file_mmap is not defined on 32-bit systems
innodb_log_file_mmap: Use a constant documentation string that
refers to persistent memory also when it is not available in the build.

HAVE_INNODB_MMAP: Remove, and unconditionally enable this code.

log_mmap(): On 32-bit systems, ensure that the size fits in 32 bits.

log_t::resize_start(), log_t::resize_abort(): Only handle memory-mapping
if HAVE_PMEM is defined. The generic memory-mapped interface is only for
reading the log in recovery. Writable memory mappings are only for
persistent memory, that is, Linux file systems with mount -o dax.

Reviewed by: Debarun Banerjee, Otto Kekäläinen
2025-01-13 07:27:17 +02:00
ParadoxV5
faca9500fb MDEV-35430: Add cast to semi-sync wait skip msg
This came after I prepared #3493.
2025-01-13 13:57:46 +11:00
ParadoxV5
8b9c8631a4 MDEV-35818: Fix replace_binlog_file info message
`ATTRIBUITE_FORMAT` from #3360 uncovers issues on `my_snprintf` uses.
This commit fixes the one in `Binlog_commit_by_rotate::`
`replace_binlog_file()` about “required size too big”.

All I found is that it’s not present in 11.4
(after I prepared previous batches for all maintained branches),
for GitHub blame can’t process a file with over 10K lines.
2025-01-13 13:17:55 +11:00
Yuchen Pei
f862fe8b2b
MDEV-35641 bring call to use_all_columns() forward when reading from mysql.servers
TABLE::use_all_columns turn on all bits of read_set, which is
interpreted by innodb as a request to read all columns. Without doing
so before calling init_read_record(), innodb will not retrieve any
columns if mysql.servers table has been altered to use innodb as the
engine, and any foreign servers stored in the table are "lost".
2025-01-13 11:56:19 +11:00
Daniel Black
04408fff40 MDEV-35687 Various UBSAN function-type-mismatch debug_sync and myisam
storage/maria/ma_open.c:352:7: runtime error: call to function debug_sync(THD*, char const*, unsigned long)
through pointer to incorrect function type 'void (*)(void *, const char *, unsigned long)'

The THD argument is a void *. Because of the way myisam is .c files the
function prototype is mismatched.

As Marko pointed out the MYSQL_THD is declared as void * in C.

Thanks Jimmy Hú for noting that struct THD is the equalivalant in C to
the class THD. The C NULL was also different to the C++ nullptr.

Corrected the definations of MYSQL_THD and DEBUG_SYNC_C to be C and C++
compatible.
2025-01-13 10:46:05 +11:00
Xiaochuan Cui
6e86fe0063 MDEV-35528: mariadb-binlog cannot process more than 1 logfiles when --stop-datetime is specified
Fix regression introduced by commits 9588526 which attempted to address
MDEV-27037. With the regression, mariadb-binlog cannot process multiple
log files when --stop-datetime is specified.

The change is to keep recording timestamp of last processed event, and
after all log files are processed, if the last recorded timestamp has not
reached specified --stop-datetime, it will emit a warning. This applies
when processing local log files, or log files from remote servers.

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.

Co-authored-by: Brandon Nesterenko <brandon.nesterenko@mariadb.com>
Reviewed-by: Brandon Nesterenko <brandon.nesterenko@mariadb.com>
2025-01-12 11:03:10 -07:00
ParadoxV5
f361ad75b3 MDEV-35431: fix InnoDB flags error size specifier
This came after I prepared #3518.
2025-01-12 13:56:06 +11:00
Daniel Black
cb26d41d81 MDEV-35735: UBSAN: spider udf functions mismatch with UDF defination
The mismatch occurs on the function calls as in the sql/sql_udf.h the
types of "error" and "is_null" are unsigned char rather than char.

This is corrected for the udf functions:
* spider_direct_sql
* spider_direct_bg_sql
* spider_flush_table_mon_cache
* spider_copy_tables
* spider_ping_table

Reviewer: Yuchen Pei
2025-01-12 13:40:18 +11:00
Daniel Black
c3fd0f189a MDEV-33158: UBSAN - plugin.cc partial move to C++ casts
There were too many C casts rather than C++ casts here.

Started a partial conversion covering within-file scoped
changes.

Suggested by Brandon Nesterenko
2025-01-12 13:40:18 +11:00
Daniel Black
d7f27d7172 MDEV-33158: UBSAN via MYSQL_THDVAR_U{INT,LONG{,LONG}}
In plugins, use the correct resolver for ULONG and ULONGLONG
types.

InnoDB has a UINT type as evidenced by "Unknown variable type code 0x182
in plugin 'InnoDB'." so the implementation for UNSIGNED INT was added.

Any InnoDB mtr test that changes lock_wait_timeout,
spider_param_force_commit and some MyRocks unsigned thread server
variables can verify this change is correct.

Reviewer: Brandon Nesterenko
2025-01-12 13:40:18 +11:00
Daniel Black
f60a8a680e MDEV-35554 runtime error: call to function show_cached_thread_count()
through pointer to incorrect function type.

The argument is void* rather than char* and was missing
system_status_var * as an argument.

This shows up with UBSAN testing under clang.

Reviewer: Brandon Nesterenko
2025-01-12 13:40:18 +11:00
Daniel Black
f014d5872b MDEV-35554 call to function show_binlog_space_total()
through pointer to incorrect function type.

The argument is void* rather than char*.

This shows up with UBSAN testing under clang.
2025-01-12 09:51:51 +11:00
Vicențiu Ciorbaru
43233fe469 Fix -DBUILD_CONFIG=mysql_release to keep standard cmake flags
-DCMAKE_BUILD_TYPE=xxx sets some C compiler flags according to the build type.
-DBUILD_CONFIG was completely overwriting them in some compiler / arch
combinations and not in others. Make it consistently "append-only", not
overwrite.

Also, enforce the same set of flags for Release and RelWithDebInfo.

This reverts ff1f611a0d as it is no longer
necessary.

    Avoid assert()

    By default, CMAKE_BUILD_TYPE RelWithDebInfo or Release implies
    -DNDEBUG, which disables the assert() macro. MariaDB is deviating
    from that. Let us be explicit to use assert() only in debug builds.
2025-01-10 14:15:50 +02:00
Sergei Golubchik
221aa5e08f Merge branch '10.6' into 10.11 2025-01-10 13:14:42 +01:00
Sergei Golubchik
311e88c67a fix rocksdb tests for buildbot 2025-01-10 13:13:53 +01:00
Sergei Golubchik
542edc7743 MDEV-35720 fix the test case
* cleanup after itself
* disable cursor protocol for SELECT ... INTO
2025-01-10 13:13:29 +01:00
Marko Mäkelä
4704435068 MDEV-35802 Race condition in log_t::persist()
log_t::persist(): Remove the parameter holding_latch, and assert
latch_holding_any(). We used to avoid acquiring a latch when log
resizing was not in progress. That allowed a race condition to occur
where log_t::write_checkpoint() has just completed log resizing.
In that case, we could wrongly invoke pmem_persist() on the old
log_sys.buf instead of the new one, which was shortly before known
as log_sys.resize_buf.

log_write_persist(): A non-inline wrapper function that will
invoke log_sys.persist() while holding a shared log_sys.latch.
2025-01-10 08:15:09 +02:00
Marko Mäkelä
ff1f611a0d Avoid assert()
By default, CMAKE_BUILD_TYPE RelWithDebInfo or Release implies -DNDEBUG,
which disables the assert() macro. MariaDB is deviating from that.
Let us be explicit to use assert() only in debug builds.

This fixes up 1b8358d943
2025-01-10 06:50:50 +02:00