Commit graph

9,405 commits

Author SHA1 Message Date
Sergei Golubchik
40f7084661 Merge branch '10.11' into 11.4 2026-01-28 21:52:18 +01:00
Sergei Golubchik
b29d3779e4 Merge branch '10.6' into 10.11 2026-01-28 14:22:20 +01:00
gkodinov
76fc1861ca MDEV-38642: Missing Null terminator in the definition of mysqldump's --system typelib
There was a missing NULL element terminator for --system's type
library definition.

This was causing a crash in find_type_eol when e.g. an incomplete
value was passed to --system where it keeps iterating until it
 finds the NULL as a typelib element.

Fixed by appending a NullS to the definition.
Test case added.
2026-01-23 15:27:56 +01:00
Oleksandr Byelkin
b505b7421a 10.6 adjasts 2026-01-21 14:40:41 +01:00
KhaledR57
7ae02de3a5 MDEV-36107 MDEV-36108 Enhance mysqltest language with expression evaluation and variable substitutions
mysqltest had limited scripting capabilities, requiring complex
workarounds for mathematical calculations and string manipulations
in test cases. This commit solves these limitations by adding a new
`$(...)` syntax that enables direct evaluation of mathematical, logical,
and string expressions within test scripts.

Expression Evaluation (MDEV-36107):
- Recursive descent parser supporting arithmetic, logical, comparison,
  and bitwise operators with proper precedence
- Support for integers (decimal, hex, binary), booleans, strings, and
  NULL values
- Variable substitution within expressions
- Integration with existing mysqltest control flow

String Functions (MDEV-36108):
- Base conversion functions supporting bases 2-62
- String manipulation and processing functions
- Regular expression functions
- Conditional and numeric utility functions

The implementation enhances mysqltest's scripting capabilities while
maintaining full backward compatibility.
2026-01-21 14:40:41 +01:00
Sergei Golubchik
84eec86b37 mysqldump --no-autocommit
* put autocommit/commit outside of LOCK/UNLOCK.
* use uppercase like all other commands
* restore the old value of autocommit
2026-01-14 19:44:30 +01:00
Marko Mäkelä
678ff03ee7 Merge 10.11 into 11.4 2026-01-02 11:53:09 +02:00
Mohammad El-Shennawy
88efded2d2 MDEV-36269: improve error handling for source command
- refactor batch_readline_init to mysql.cc for proper error handling
- add unit test and move it to the end of main/mysql_client_test.test
to resolve embedded test failures
- remove unnecessary code and duplicates to clean up implementation
- redirect error message from stderr to stdout in .test file
- use labels to avoid code duplication
- handle windows check for block device
- ensure file failing to open in windows because being a directory
 is different from any other reason for clear error message
2025-12-10 19:00:09 +04:00
Sergei Golubchik
bcb77590f0 cleanup: CREATE_TYPELIB_FOR() helper
(cherry picked from commit d046aca0c7)
2025-10-25 00:19:11 +07:00
Marko Mäkelä
e8ef8c0055 Merge 10.11 into 11.4 2025-09-24 13:40:09 +03:00
Daniel Black
8c7077346c MDEV-35224 ASAN error in mariadb client with \c
Mariadb monitor when a line is cancelled, provided
its more than one line, passes that text to the
add_history of libedit. This string that has been
passed however isn't null terminated resulting
in an ASAN error within the libedit code.

fix_history where the add_history is called
is called by the com_clear, associated with
the \c command, and com_go. An using the c_ptr
adds a null character onto the end of the string.
2025-09-24 10:27:53 +10:00
Oleksandr Byelkin
15b1426c3a Merge branch '10.11' into bb-11.4-release 2025-09-15 16:17:33 +02:00
Oleksandr Byelkin
0707dac202 Merge branch '10.6' into 10.11 2025-09-12 13:08:40 +02:00
Vladislav Vaintroub
2ccf6a245f MDEV-37483 - fix output differences Linux vs Windows in the test
- Do not mix latin1 and utf8 in the test and result file.
  Not only it looks strange, and it does not work on Windows either.

- Fix --default-character-set usage in mariadb-import.
  Prior to patch   it was just using platform default when communicating
  with server. Now, it uses the charset provided by the option.

- Use --default-character-set=utf8mb4 in test, to have
  uniform output across different OSes.
2025-09-12 11:12:17 +02:00
Daniel Black
bf60478fd6 MDEV-34388/MDEV-36701: mysql status_info_cb disable varargs warnings
Clang complains that the callback is using a variadic based on an enum.

client/mysql.cc:3207:16: error: passing an object that undergoes default argument promotion to 'va_start' has undefined behavior [-Werror,-Wvarargs]
 3207 |   va_start(ap, type);

This is part of the C/C API this has been referred as bug:
* CONC-789 MARIADB_OPT_STATUS_CALLBACK Variadic around enums is undefined behaviour

In the mean time, we are just disabling the warning.

Reviewer: Jimmy Hu <jimmy.hu@mariadb.com>
2025-09-11 10:02:43 +10:00
Daniel Black
4b058a33df Revert "MDEV-36701 command line client doesn't check session_track information (fix)"
This reverts commit 3e43606de6.

This caused Clang-18+ UBSAN errors:

SUMMARY: UndefinedBehaviorSanitizer: function-type-mismatch libmariadb/libmariadb/mariadb_lib.c:2723:17

+/libmariadb/libmariadb/mariadb_lib.c:2628:3: runtime error: call to function
  status_info_cb(void*, enum_mariadb_status_info, enum_session_state_type, st_ma_const_string*)
  through pointer to incorrect function type 'void (*)(void *, enum enum_mariadb_status_info, ...)'
+/client/mysql.cc:3204: note: status_info_cb(void*, enum_mariadb_status_info, enum_session_state_type, st_ma_const_string*) defined here

Reviewer: Jimmy Hu <jimmy.hu@mariadb.com>
2025-09-11 10:02:43 +10:00
Dave Gosselin
47df0ba17c Cherry-pick of 'mariadb-test: wait on disconnect' from 12.1
Cherry-picks mysqltest.cc and rpl_semi_sync_shutdown_await_ack changes
from 12.1 to fix a race condition on disconnect.
2025-09-10 13:57:07 -04:00
Sergei Golubchik
ff12ec86a5 MDEV-37483 mariadb-dump -T doesn't convert table names
use my_charset_filename to build file names from table names.
this guarantees that file name will be always valid for any
table name, no matter what characters it contains and what file name
rules local filesystem has.

mariadb-import now converts back, if possible.
2025-09-04 17:20:02 +02:00
Sergei Golubchik
75b000372b cleanup: reusable build_path_for_table() function 2025-09-04 17:20:02 +02:00
Monty
f65dda628d Fixed that one can compile MariaDB with ASAN with -Wframe-larger-than=16384
Added PRAGMA_DISABLE_CHECK_STACK_FRAME around some functions
2025-09-04 18:08:38 +03:00
Marko Mäkelä
257f4b30ef Merge 10.11 into 11.4 2025-09-03 10:32:56 +03:00
Nikita Malyavin
0108664a8a Merge branch 10.11 into 11.4
# Conflicts:
#	sql/handler.h
#	sql/log_event.h
#	sql/log_event_server.cc
2025-09-02 15:58:39 +02:00
Daniel Black
3e43606de6 MDEV-36701 command line client doesn't check session_track information (fix)
Corrects clang Wvargs warning:

client/mysql.cc:3205:16: warning: passing an object that undergoes default argument promotion to 'va_start' has undefined behavior [-Wvarargs]

Because there is only one mode we are interested in that is tested
before the varargs this is safe to do.
2025-08-07 11:34:17 +10:00
Daniel Black
4f9221ae88 MDEV-36542: remove _lint macro which is unused
Attribute noreturn functions don't need
a return afterwards.

aria_pack was missing the noreturn attribute
on its my_end function.
2025-07-29 13:15:02 +10:00
Daniel Black
6fd57f478f MDEV-36542 Remove UNINIT_VAR(x)=x under UBSAN
Clang processes the "int x=x" code from UNINIT_VAR
literally resulting in an uninitialized read and write.
This is something we want to avoid. Gcc does the same
without emitting warnings.

As the UNINIT_VAR was around avoiding compiler false detection,
and clang doesn't false detect, is default action is a
noop.

Static analysers (examined Infer and SonarQube) are
clang based and have the same detection.

Using a __clang__ instead of WITH_UBSAN would acheived
a better result, however reviewer wanted to keep WITH_UBSAN
only.

LINT_INIT_STRUCT is no longer required, even a gcc-4.8.5
doesn't warn with this construct removed which matches
the comment that it was fixed in gcc ~4.7.

mysql.cc - all paths in com_go populate buff before use.

json: Item_func_json_merge::val_str
  LINT_INIT(js2) unneeded as usage in the previous statements
  it is explicitly initialized to NULL.

Item_func_json_contains_path::val_bool n_found is guarded
by an uninitialized read by mode_one and from
gcc-13.3.0 in Ubuntu 24.04 this is detected. As the only
remaining use of LINIT_INIT this usage has been applied
with the expanded macro with the unused _lint define removed.

The LINT_INIT macro is removed.

_ma_ck_delete - org_key only valid under share->now_transactional
likewise with _ma_ck_write_btree_with_log

connect engine never used anything that FORCE_INIT_OF_VARS
would change.

Reviewer: Monty
2025-07-29 13:15:02 +10:00
Sergei Golubchik
c4ed889b74 Merge branch '10.11' into 11.4 2025-07-28 19:40:10 +02:00
ParadoxV5
76c79d4fd8 MDEV-37060: Don’t check Encrpyted Server IDs in mariadb-binlog
MSAN found that `mariadb-binlog --force-read` checks encrypted events
too for whether `--do-server-ids`/`ignore-server-ids` includes any of
their (uninitialized) Server IDs.
This fix extends the condition to stop skipping `UNKNOWN_EVENT`s by
Server ID in addition to `ROTATE_EVENT`s.

An alternative solution is to zero-initialize the `server_id` field of
`Unknown_log_event` or even its supertype, `Log_event`.
Though to avoid hiding `use-of-uninitialized-value` mistakes in the
future, leaving unset fields uninitialized is more assured;
not to mention the potential of ID 0 still in use.

Reviewed-by: Brandon Nesterenko <brandon.nesterenko@mariadb.com>
Acked-by: Daniel Black <daniel@mariadb.org>
2025-07-22 14:22:06 +10:00
Sergei Golubchik
aef0468c18 cleanup: select ... into tests
* automatically disable ps2 and cursor protocol when the
  select statement returns no result set
* remove manual {disable|enable}_{ps2|cursor}_protocol from around
  `select ... into` in tests
* other misc collateral test cleanups

Cherry-pick from 11.8
2025-07-17 09:18:18 +02:00
Sergei Golubchik
29277bf9d9 MDEV-36701 command line client doesn't check session_track information
subscribe for SESSION_TRACK_SCHEMA messages and change the db accordingly
2025-07-17 09:18:18 +02:00
ParadoxV5
bd3ee3a9a2 MDEV-34614 mysqlbinlog warn on EOF before GTID in --stop-position
This commit adds warnings for `--stop-position` GTIDs that were
not reached at EOF, mainly as a follow-up to MDEV-27037 “Mysqlbinlog
should output a warning if EOF is found before its stop condition”

`--stop-position` warnings inform possible mistakes in the input,
especially for progress reporting of scripts/wrappers.
MDEV-34614 enhances MDEV-27037 with individualized GTID validation, for
GTID range selection weren’t in all versions that MDEV-27037 targeted.

The `Gtid_event_filter` family provides the the warning
mechanism polymorphically and through the new public method
`verify_completed_state`. This design is hierarchically extensible
(e.g., to `--ignore-server-ids`).

This commit also includes minor touchups:
* `rpl_gtid.cc`: adjust cases when a `Window_gtid_event_filter` has only
  one of `--start-` and `--stop-position` (without intensive refactors)
* `rpl_gtid.cc`: function docs improvements
* `rpl_gtid.h`: Remove unimplemented, red-herring function prototype
  `Window_gtid_event_filter::verify_gtid_is_expected`

Reviewed-by: Brandon Nesterenko <brandon.nesterenko@mariadb.com>
2025-07-14 18:07:04 -06:00
ParadoxV5
b6385e00b6 MDEV-7611 mysqldump --dump-slave always starts stopped slave
Store the _SLAVE_ STATUS when pausing replicas for
`mariadb-dump --dump-slave`; use that (instead of a new
SHOW _SLAVE_ STATUS) to resume replicas when the program ends.

> When making a dump with --dump-slave option, upon completion mysqldump
> starts slave threads [IO & SQL for all multi-source connections] even
> if they were not stopped by mysqldump itself.
> This behavior breaks delayed/manually synchronized
> slaves which have not to be running all the time.
> ⸺ MDEV-7611

Co-authored-by: Max Samoilenko <maxim.samoilenko@gmail.com>
Reviewed-by: Brandon Nesterenko <brandon.nesterenko@mariadb.com>
2025-07-10 18:31:36 -06:00
Oleksandr Byelkin
89c7e2b9c7 Merge branch '10.11' into 11.4
Some checks failed
Build on Windows ARM64 / build (push) Has been cancelled
2025-06-17 09:50:22 +02:00
Marko Mäkelä
3da36fa130 Merge 10.6 into 10.11 2025-05-26 08:10:47 +03:00
Aleksey Midenkov
fbd736c872 mysqltest: result_format fix
--result_format 2 command fails with assertion:

DbugExit (why=0x7fffffff49e0 "missing DBUG_RETURN or DBUG_VOID_RETURN
macro in function \"do_result_format_version\"\n") at
../src/dbug/dbug.c:2045
2025-05-21 11:10:09 +03:00
Marko Mäkelä
1c7209e828 Merge 10.6 into 10.11 2025-05-21 07:36:35 +03:00
Marko Mäkelä
82d7419e06 MDEV-34388: Stack overflow on Alpine Linux
page_is_corrupted(): Do not allocate the buffers from stack,
but from the heap, in xb_fil_cur_open().

row_quiesce_write_cfg(): Issue one type of message when we
fail to create the .cfg file.

update_statistics_for_table(), read_statistics_for_table(),
delete_statistics_for_table(), rename_table_in_stat_tables():
Use a common stack buffer for Index_stat, Column_stat, Table_stat.

ha_connect::FileExists(): Invoke push_warning_printf() so that
we can avoid allocating a buffer for snprintf().

translog_init_with_table(): Do not duplicate TRANSLOG_PAGE_SIZE_BUFF.

Let us also globally enable the GCC 4.4 and clang 3.0 option
-Wframe-larger-than=16384 to reduce the possibility of introducing
such stack overflow in the future.  For RocksDB and Mroonga we relax
these limits.

Reviewed by: Vladislav Lesin
2025-05-20 17:27:05 +03:00
Oleksandr Byelkin
a8d4642375 Merge branch '10.11' into 11.4 2025-04-26 10:53:02 +02:00
Brandon Nesterenko
588f7a5af7 MDEV-35694: Mysqlbinlog --stop-position should warn if EOF not reached with --read-from-remote-server
MDEV-27037 added functionality to warn users that a specified
stop-position or stop-datetime was never reached. It only worked for
local files though. The patch in MDEV-35528 changed the
implementation for stop-datetime to work to provide the warning also
when using --read-from-remote-server. The PR for that MDEV (#3670)
was limited to only the stop-datetime field.

This patch updates the --stop-position warning to also work with
--read-from-remote-server.

Reviewed By:
============
Andrei Elkin <andrei.elkin@mariadb.com>
Jimmy Hu <jimmy.hu@mariadb.com>
2025-04-21 14:21:55 -06:00
Sergei Golubchik
28425cc276 Merge branch '10.11' into 11.4 2025-03-31 22:28:52 +02:00
Sergei Golubchik
730dcf7e6d Merge branch '10.6' into 10.11 2025-03-31 17:57:43 +02:00
Sergei Golubchik
51cc77f212 Merge branch '10.5' into 10.6 2025-03-31 12:12:50 +02:00
Marko Mäkelä
f5bd250f5b Merge 10.11 into 11.4 2025-03-28 13:55:21 +02:00
Sergei Golubchik
04771ff6b1 MDEV-28209 New mysql_upgrade message on minor-only upgrades is confusing 2025-03-27 21:25:05 +01:00
Sergei Golubchik
6aa860be27 MDEV-36268 mariadb-dump used wrong quoting character
use ' not " and use quote_for_equal()
2025-03-27 21:25:05 +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
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
Sergei Golubchik
7d657fda64 Merge branch '10.11 into 11.4 2025-01-30 12:01:11 +01:00
Sergei Golubchik
e69f8cae1a Merge branch '10.6' into 10.11 2025-01-30 11:55:13 +01:00
Sergei Golubchik
92a6789638 C/C 3.4.4 2025-01-29 23:57:17 +01:00
Kristian Nielsen
72e1cc8f52 MDEV-35806: Error in read_log_event() corrupts relay log writer, crashes server
In Log_event::read_log_event(), don't use IO_CACHE::error of the relay log's
IO_CACHE to signal an error back to the caller. When reading the active
relay log, this flag is also being used by the IO thread, and setting it can
randomly cause the IO thread to wrongly detect IO error on writing and
permanently disable the relay log.

This was seen sporadically in test case rpl.rpl_from_mysql80. The read
error set by the SQL thread in the IO_CACHE would be interpreted as a
write error by the IO thread, which would cause it to throw a fatal
error and close the relay log. And this would later cause CHANGE
MASTER to try to purge a closed relay log, resulting in nullptr crash.

SQL thread is not able to parse an event read from the relay log. This
can happen like here when replicating unknown events from a MySQL master,
potentially also for other reasons.

Also fix a mistake in my_b_flush_io_cache() introduced back in 2001
(fa09f2cd7e) where my_b_flush_io_cache() could wrongly return an error set
in IO_CACHE::error, even if the flush operation itself succeeded.

Also fix another sporadic failure in rpl.rpl_from_mysql80 where the outout
of MASTER_POS_WAIT() depended on timing of SQL and IO thread.

Reviewed-by: Monty <monty@mariadb.org>
Reviewed-by: Andrei Elkin <andrei.elkin@mariadb.com>
Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2025-01-24 09:15:20 +00:00