1
0
mirror of https://github.com/MariaDB/server.git synced 2026-10-23 18:49:29 +03:00
Commit Graph

9320 Commits

Author SHA1 Message Date
Oleksandr Byelkin
5fc864ece4 Fix MSAN failure in mysqltest with --cursor-protocol after CC update
CONC-821 in Connector/C 3.3.21 no longer resets *length for string
binds, so for NULL just assume 0.
2026-10-21 14:09:00 +02:00
Oleksandr Byelkin
94cdbdf6d5 Revert "Fix MSAN failure in mysqltest with --cursor-protocol after CC update"
This reverts commit 22270903f1.
2026-10-21 14:09:00 +02:00
Oleksandr Byelkin
22270903f1 Fix MSAN failure in mysqltest with --cursor-protocol after CC update
CONC-821 in Connector/C 3.3.21 no longer resets *length for string
binds, so for NULL values the length array in append_stmt_result()
stayed uninitialized. Zero-fill it on allocation.
2026-10-20 19:22:57 +02:00
Khaled Riyad
8bee0f3610 MDEV-41408 MTR prepared statement protocol skipping statements starting with '('
With --ps-protocol, mysqltest runs a SELECT a second time and compares
the results. The regex ps2_re only matched a leading SELECT, so a
statement starting with '(' was executed only once.

Allow any number of '(', each optionally followed by spaces, before
SELECT in ps2_re.
2026-10-12 19:38:02 +03:00
GoldenEmperor1177
22ff9c9edc MDEV-40453 Reject overflowing mysqltest expressions
What was wrong:
The mysqltest expression evaluator did signed arithmetic without
checking that the result fits in long long. Boundary expressions
triggered undefined behavior or returned mathematically wrong wrapped
values, e.g. -9223372036854775808 / -1 gave -9223372036854775808, and
unsigned 18446744073709551615 + 1 gave 0.

How it is fixed:
Check unary minus, +, -, *, / and abs() before evaluating and die() with
an "Evaluation error: ... overflow" message when the result is not
representable in 64 bits. Unsigned +, - and * are checked the same way;
an unsigned difference that is negative but fits in long long is
returned as a signed value. A negative signed operand mixed with an
unsigned one is rejected instead of being silently converted. Valid
boundary results are kept: -9223372036854775808 % -1 = 0 and
-4611686018427387904 * 2 = -9223372036854775808. Unary minus on an
unsigned value still wraps, as conv(-~0, ...) in
main.mysqltest_string_functions relies on it.

How it is tested:
main.mysqltest_expression_evaluation: the former wrapping cases now
expect an error, and signed and unsigned overflow cases were added.
main.mysqltest, main.mysqltest_string_functions and the other tests
using $() pass, also with --ps-protocol.
2026-10-01 09:31:34 +10:00
ParadoxV5
52289d4555 MDEV-40996 Support --sync_with_master 0, $variable in mysqltest
`--sync_with_master` uses `get_string()`,
which has `$variable` support, but it only uses the read buffer,
which is written with the unexpanded string and not the variable value.

Reviewed-by: KhaledR57 <khaled57.dev@gmail.com>
2026-09-11 15:49:07 +03:00
Otto Kekäläinen
2753b5919a Promote getting GitHub stars in client prompt
Ask users to give MariaDB a star by having an extra line in the MariaDB
client prompt:

    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is X
    Server version: Y
    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

    Help others discover MariaDB. Star it on GitHub: https://github.com/MariaDB/server

    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

    MariaDB [(none)]>

Test file updated with:
nano --noconvert --nonewlines mysql-test/main/mysql-interactive.result

This change is similar to 346c7afe9b
applied on 'main', but without the SERVER_MATURITY_LEVEL check in order
to have this text visible in stable releases and actually help get the
GitHub star count up, and without the server log entry.
2026-09-08 13:29:45 +03:00
Oleksandr Byelkin
1a4be9dcd3 Merge branch '10.11' into mariadb-10.11.19 2026-08-26 09:37:54 +02:00
Abdelrahman Hedia
eeb8cb8587 MDEV-29803: Change mariadb-binlog --gtid-strict-mode default to OFF
The --gtid-strict-mode option in mariadb-binlog was introduced in MDEV-4989
with a default of ON. This causes mariadb-binlog to refuse to display
events when it encounters out-of-order GTIDs, which commonly happens
when replaying a remote binlog into a server and then reading back the
resulting local binlog files.

This is overly restrictive for a diagnostic/display tool. While the
server's gtid_strict_mode makes sense as a safety mechanism, applying
the same strict validation by default in the client tool prevents users
from even inspecting problematic binlog files.

Change the default to OFF so that mariadb-binlog processes binlog files
without erroring on out-of-order GTIDs by default. Users who want strict
validation can still explicitly pass --gtid-strict-mode.

Added regression test binlog.mdev_29803 that verifies:
- Default (OFF): reading binlog files with replayed events succeeds
- Explicit --gtid-strict-mode: still produces the expected error
2026-08-25 12:16:02 +03:00
Oleksandr Byelkin
e2b15641ec Merge branch '10.6' into 10.11 2026-08-19 08:13:54 +02:00
Sergei Golubchik
ee74a71df6 mariadb-test: don't use strlen/strend, support lines with embedded \0
add a test
2026-08-07 22:54:50 +02:00
Teemu Ollakka
d29da23e13 mysqltest: fix do_exec() status decoding for signal-killed processes
WEXITSTATUS() only produces a meaningful value when the process
exited normally. If the command was killed by a signal, it silently
returned status 0, hiding the failure. Check WIFEXITED/WIFSIGNALED
and map signal deaths to the shell's 128+signal convention.
2026-08-05 09:05:20 +02:00
KhaledR57
39569c6606 MDEV-37859 mysqltest hex() fails on string arguments
func_hex() passed every argument through convert_base_helper(), which
parses the argument as a base 10 number. A string argument therefore
died with "invalid number 'abc' for base 10" instead of being converted.

HEX() is the only one of the base conversion functions that accepts a
string. In the server BIN() and OCT() are built as Item_func_conv() with
fixed bases and are numeric only, while HEX() has a dedicated Item with
a separate string path, because HEX() is the counterpart of UNHEX() and
has to serialise bytes.

Dispatch on the argument type: numeric arguments keep the existing
CONV(N, 10, 16) behaviour, string arguments are converted byte by byte
with String::set_hex(), which is the same call the server uses in
Item_func_hex::val_str_ascii_from_val_str().
2026-07-28 09:13:49 +02:00
KhaledR57
768796e81a MDEV-37865: IF() function is returning incorrect error
get_expr_function_type() compared a parsed function name against
function_table[] using strncasecmp() bounded by the length of the parsed
name. The comparison stopped at that length and never checked that the
table entry ended there, so any name that is a prefix of a known
function resolved to that function.

"if" matched "ifnull" and produced a misleading arity error. Names that
prefixed a function with a compatible signature were worse and
dispatched silently: l("AB") ran lcase(),t("  x  ") ran trim().
A typo in a test script ran a different function and the test still passed.

Store each entry's length in function_table[] with STRING_WITH_LEN() and
require it to match the parsed length. Report the unmatched name in the
"Unknown function" error.
2026-07-27 15:40:26 +02:00
Sergei Golubchik
afbab154f1 post-merge fixes
* restore result=NULL after free in mysqlshow.c (to prevent double-free)
* remove DBUG_EVALUATE_IF again
* remove useless 'stop slave' from a test
* restore charset encoding in mysqltest.{test,result}
* correct error for unparseable BINLOG data is ER_SYNTAX_ERROR now
* restore old libfmt on rhel-7, gcc 4.8.5 cannot compile anything newer
2026-07-24 17:06:39 +02:00
forkfun
ad7f29afb3 Merge branch 10.6 into 10.11 2026-07-23 11:12:27 +02:00
Sergei Golubchik
ce0b7254d5 MDEV-40311 also fix mariadb-show and mariadb-convert-table-format 2026-07-22 13:22:03 +02:00
Sergei Golubchik
2b28d1c424 MDEV-40311 mariadb-dump doesn't always quote identifiers
covers:
* DROP TRIGGER
* CHANGE MASTER
* CREATE FUNCTION
* CREATE SERVER
* INSTALL PLUGIN
2026-07-22 13:22:03 +02:00
Sergei Golubchik
b2e0351a91 MDEV-40065 bundled command-line clients don't always enforce length limits on server results
replace strmov/strxmov with strnmov, strmake, or my_snprintf
2026-07-22 13:22:02 +02:00
KhaledR57
fc2cca05b6 MDEV-40353 Add eval parameter to write_file and append_file
mysqltest substituted variables in the file name of write_file and
append_file, but not in the content, so tests had to fall back to
"exec echo ... >> file" to put a computed value into a file.

Add an optional third parameter, eval, which makes the content go
through do_eval(). It is off by default, because existing tests write
content that contains a literal $ or backslash.
2026-07-22 11:52:12 +02:00
Vladislav Vaintroub
2217477fb8 MDEV-40243 Fix Infer MEMORY_LEAK_C leaks in mysqldump/mysqlshow
Infer reported MEMORY_LEAK_C at several client sites. Fix the genuine leaks:

client/mysqldump.c (dump_events_for_db): event_list_res (and, on the inner
paths, event_res) were leaked on the error DBUG_RETURN(1) paths
(switch_character_set_results, SHOW CREATE EVENT failure, create_delimiter,
switch_db_collation, restore_db_collation). Route those paths through a
single "err:" cleanup label that frees both results (event_res is kept NULL
outside the inner loop so the shared cleanup is safe) and also restores the
session state (results charset, and UNLOCK TABLES when locking) like the
normal exit does.

client/mysqlshow.c (list_fields): when --keys is given, the columns result
set was overwritten by the "show keys" result without being freed. Free it
before running the keys query, and NULL the pointer so it cannot dangle if
that query fails.

The client/mysqltest.cc reports are false positives (do_save_master_pos only
leaves the result unfreed right before a noreturn die(); read_stmt_results
frees on every path), so no change is needed there.
2026-07-02 18:45:45 +03:00
Kristian Nielsen
40d6228811 Fix inconsistent terminology
Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2026-06-15 10:43:23 +02:00
Daniel Black
8923afa5c2 MDEV-39584: update help sql tables and replace KB links
scripts/fill_help_tables.sql from
https://github.com/mariadb-corporation/mariadb-docs/ as of
3fb208fcdfed06beb52ef9e305017de2387ff012

Other URL changes are taken from the HTTP redirection URL
from the old KB.

Some test cases where impacted:
* ps_missed_cmds{,_bin_prot} - used a topic_id of 0 that is
 now used, used MAX_INT instead.

* range_notembedded used the help data as a test case. As its not
  a stable table data, replaces with static data. Test case valid
  by ensuring the ANALYZE EXPLAIN and optimizer trace had the same
  structure. Also valided the MDEV-24739/MDEV-25069 bug fixes from
  where the test case originaled, when reverted, exhibited the
  previous behavour before the bug fixes.
2026-05-15 13:30:21 +10:00
Daniel Black
e4bdee5a0d MDEV-36453 UBSAN: main.mysqltest - runtime error: null pointer
..passed as argument 2, which is declared to never be null
(dynstr_append_mem).

dynstr_append_mem, uses memcpy to append to the string which in the glibc
library is declared to not take null string as the src. Defensively we
declare dynstr_append_mem to not take a null argument too.

mariadb-test, to prevent it calling dynstr_append_mem with a null
mtr variable value, one that hasn't been initialized, we return an
error if the value is null. The result of this is the $6 in the test
case is never assigned a value and would error.

With this resolved, strchr, if the string isn't found, a null pointer is
returned. UBSAN will complain both about incrementing a pointer beyond
the boundary, and also incrementing if it is null.
2026-05-04 17:30:39 +10:00
Jan Lindström
9815fe389b MGL-67 : Add --galera-info parameter for mysqldump tool
Added --galera-info parameter for mysqldump tool and this
will add SET GLOBAL wsrep_start_position line at the
end of the dump. This line is based on added wsrep status
variable wsrep-checkpoint-position.

Added also status variable wsrep-se-checkpoint.
2026-04-21 13:00:39 +03:00
Marko Mäkelä
58f507206f Merge 10.6 into 10.11 2026-04-20 11:07:30 +03:00
Mikhail Pochatkin
cbcff6324a MDEV-39173 Replace sprintf with snprintf, remove deprecated pragma
Remove the unscoped #pragma GCC diagnostic ignored
"-Wdeprecated-declarations" from include/violite.h and replace all
sprintf/vsprintf calls with snprintf/vsnprintf across the codebase.

Where possible, pass actual buffer sizes as function parameters
instead of using hardcoded constants or recomputing strlen().
Notable API changes:
- get_date(): added to_len parameter for buffer size
- nice_time(), end_timer() in client/mysql.cc: added buff_size
- generate_new_name(): added name_size parameter
- calc_md5(): added buffer_size parameter (fixes off-by-one)
- MD5_HASH_TO_STRING macro: added _size parameter
- Added MYSQL_UDF_MAX_RESULT_LENGTH constant in mysql_com.h

Also fixed a pre-existing bug in sql/rpl_mi.cc where the ellipsis
"..." was written to the wrong buffer (dbuff instead of buff).

Vendored code is excluded: extra/readline, extra/wolfssl,
wsrep-lib, libmariadb, storage/mroonga/vendor, zlib.
2026-04-16 19:00:12 +10:00
Oleksandr Byelkin
31be75cbcb MDEV-39287 (10.6 part) Fix compilation problems with glibc 2.43/gcc 16/fedora 44
Use 'const' where possible.
Use string copy to make dbug usage safe
Check safetiness of myisam/aria usage (made by Monty)
2026-04-14 11:32:09 +02:00
Sergei Golubchik
21303c6bfe MDEV-38777 mariadb-test Build regression in FreeBSD - 2026Q1 releases 2026-04-12 18:07:59 +02:00
Georgi (Joro) Kodinov
fb9d6e444c MDEV-35986 - Use memory safe snprintf() in client
Replace sprintf(buf, ...) with snprintf(buf, sizeof(buf), ...),
where buf is allocated with a size known at compile time.

This makes sure we are not writing outside array/string bounds which will
lead to undefined behaviour. In case the code is trying to write outside bounds
- safe version of functions simply cut the string messages so we process this
gracefully.
2026-04-02 16:07:07 +03:00
Marko Mäkelä
29be734aaf Merge 10.6 into 10.11 2026-03-31 11:48:18 +03:00
forkfun
0bbec68242 MDEV-32770 mariadb-dump produces not loadable dump due to temporary view structure
When mariadb-dump produces a dump, it first creates a temporary placeholder for views
to satisfy potential dependencies before their actual creation later in the dump file.
Previously, these views were populated with int literals for their columns (1 AS `col_name`).
This could cause syntax or type-resolution errors during restoration if another view depended
on this placeholder view.

This commit changes the placeholder column values from 1 to NULL, as it is more permissive
and allowing the dump to be restored successfully.
2026-03-27 15:17:51 +01:00
forkfun
1f95fe6fd3 MDEV-36183 mariadb-dump backup corrupt if stored procedure ends with comment
When a stored procedure, trigger, or event ends with a line comment (#comment
or --comment), mariadb-dump would append the custom delimiter (;;) on the same line.
This caused the comment to "comment out" the delimiter, leading to syntax errors
during restoration.

Fixed by ensuring a newline is inserted before the delimiter in the dump output.
2026-03-27 15:17:51 +01:00
Sergei Golubchik
3a1cc22713 let's be explicit about what abs() to use
fixes main.mysqltest_string_functions failure on centos7
with gcc 4.8.5
2026-03-25 16:52:43 +01:00
Mohamed
52e9f3e7aa MDEV-38494 .mariadb_history rename race condition
When multiple mariadb sessions exit at the same time, they all write
to the same $HISTFILE.TMP then rename it to $HISTFILE.  The second
rename fails with Errcode 2 because the first already moved the file.

Fix: include the process PID in the temp file name so each session
uses its own unique path and no rename collision can occur.
2026-03-18 12:54:41 +01:00
Sergei Golubchik
d223be1180 MDEV-38778 mariadbcheck --silent
silence non-errors from admin commands, as it's what --silent
is documented to do
2026-02-22 15:45:17 +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
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
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
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