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

9456 Commits

Author SHA1 Message Date
Oleksandr Byelkin
019030adc9 Merge branch '10.11' into 11.4 2026-10-21 09:30:28 +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
Sergei Golubchik
50dd408f81 Merge branch '10.11' into 11.4 2026-10-15 20:25:34 +02:00
Marko Mäkelä
4a141daf84 Merge 10.11 into 11.4 2026-10-13 07:49:28 +03:00
Marko Mäkelä
7ee06258b5 Merge 10.11 into 11.4 2026-10-13 07:04:14 +03: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
Khaled Riyad
fd85202eb2 MDEV-41150 mariadb client: Ctrl-C does not interrupt tab separated result output
Ctrl-C sets interrupted_query and sends KILL QUERY to the server, but the
result is already fetched into the client by then, so killing the query
cannot stop the output. Only the printing loop can, by checking
interrupted_query.

print_table_data(), print_table_data_html(), print_table_data_xml() and
print_table_data_vertically() check it, print_tab_data() did not, so the
output of -s, -N and -B could not be interrupted.

Add the same check to print_tab_data().

No test case: the suite drives the client through a pty with socat, where
0x03 is not turned into a signal, and there is no other way in the suite to
signal a client while it is printing.
2026-10-10 16:24:23 +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
Marko Mäkelä
07b8693fee MDEV-15736 fixup: clang -Wunused-but-set-global 2026-09-16 14:44:00 +03: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
Kristian Nielsen
35c17e9d2e Merge 10.11 -> 11.4 2026-08-30 17:39:50 +02: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
170b1d7073 Merge branch '10.11' into 11.4 2026-08-19 08:40:05 +02: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
forkfun
08eeb6a417 Merge branch '10.11' into '11.4' 2026-07-28 13:14:38 +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
Daniel Black
1e972a8d70 Merge 10.11 into 11.4 2026-07-14 12:49:36 +10:00
Daniel Black
1fff140f0c MDEV-40313 mariadb client creates .mariadb_histor instead of .mariadb_history
`histfile_size` in `client/mysql.cc` is calculated using the string
"/.mysql_history" (15 chars) rather than "/.mariadb_history" (17 chars).

Because the buffer is only allocated to that shorter length, the resulting
filename is truncated by 2 characters.

Thanks David Lu for the bug report and diagnosis.
2026-07-09 11:52:52 +10: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
85ec122c15 Merge 10.11 to 11.4
Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2026-06-15 12:50:45 +02: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
Oleksandr Byelkin
7598e4e95d Merge branch '10.11' into 11.4 2026-05-08 08:00:01 +02: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
Yuchen Pei
c6fadc6e33 Merge branch '10.11' into 11.4 2026-04-16 11:28:26 +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ä
7c5cac0d51 Merge 10.11 into 11.4 2026-04-01 10:49:05 +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
Marko Mäkelä
b07a36ee32 Merge 10.11 into 11.4 2026-03-23 08:44:54 +02: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
Marko Mäkelä
a6c9013965 Merge 10.11 into 11.4 2026-03-11 14:18:49 +02:00