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.
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.
- 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
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.
- 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.
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>
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>
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.
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.
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
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>
* 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
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>
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>
--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
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
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>
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.
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.
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>