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

9610 Commits

Author SHA1 Message Date
Oleksandr Byelkin
b140f801e6 Merge branch '13.0' into 13.1 2026-09-04 12:21:02 +02:00
ParadoxV5
ba0d134749 MDEV-39880: Reïmplement MDEV-37146 to include MDEV-39519
MDEV-39519 added MySQL 8 compatibility to `mariadb-dump --dump-slave`
by attempting `SHOW REPLICA STATUS` first and then `SHOW SLAVE STATUS`.
This conflicted with MDEV-37146, where `mariadb-dump --dump-slave`
queries either `SELECT … FROM information_schema.SLAVE_STATUS`
or `SHOW ALL SLAVES STATUS` depending on the server version.

This commit merges MDEV-37146 and MDEV-39519:
* Use MDEV-39519’s strategy based on syntax error handling.
* Use MDEV-37146’s preference order:
  1. `SELECT … FROM information_schema.SLAVE_STATUS`
  2. `SHOW ALL SLAVES STATUS`
  3. `SHOW REPLICA STATUS` (for MySQL compatibility _only_)
* Send `STOP`/`START REPLICA SQL_THREAD FOR CHANNEL '…'`
  commands for both MariaDB 10.7+ and MySQL.
* Refactor column indices to variables set when a query succeeds.
* Partially revert MDEV-37146’s removal of `--dump-slave`’s support for
  pre-GTID & pre-multi-source, but tailored for MySQL compatibility;
  coverage for MariaDB pre-10.0 is not fully restored.

Reviewed-by: Brandon Nesterenko <brandon.nesterenko@mariadb.com>
2026-09-04 12:15:36 +02:00
Oleksandr Byelkin
71dd635f68 Merge tag '12.3' into 13.0 2026-09-04 12:14:15 +02:00
Oleksandr Byelkin
f860f2a937 Merge branch '11.8' into 12.3 2026-08-20 08:27:14 +02:00
Oleksandr Byelkin
3b8db45403 Merge branch '11.4' into 11.8 2026-08-19 11:28:01 +02: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
monthdev
2129804256 MDEV-20749 Improve mysqlbinlog --flashback error reporting
Handle corrupted row events by reporting whether the field length could
not be determined from metadata or whether the field extends past the
row buffer instead of falling out through debug-only assertion paths
or ad hoc exits during flashback row conversion. Propagate flashback
conversion failures through the normal mysqlbinlog error path so debug
builds produce the intended diagnostics cleanly.

Add replication tests covering corrupted BLOB metadata and corrupted
BLOB length prefixes using server-side debug injection to write broken
binlog contents and mysqltest-friendly mysqlbinlog invocation patterns.

Reviewed-by: Brandon Nesterenko <brandon.nesterenko@mariadb.com>
Reviewed-by: Georgi Kodinov <joro@mariadb.org>
2026-08-17 13:46:32 +03:00
Sergei Golubchik
c28b4efdd4 cleanup: mariadb-dump
remove dead code, handling of MariaDB/MySQL servers that didn't
have SQL_QUOTE_SHOW_CREATE.

SQL_QUOTE_SHOW_CREATE was added in 2000
(commit 5762523b78, MySQL 3.23.25-beta)
2026-08-14 17:30:08 +02:00
Sergei Golubchik
0e46653911 cleanup: remove buggy str2int, replace with a template
remove one str->int implementation (we still have 10+ more),
replace with a convenience template that calls my_strntoll_8bit()
2026-08-14 17:30:08 +02:00
Alexander Barkov
0ee34e07bd MDEV-39587 Package-wide TYPE for variable declarations
SET sql_mode=ORACLE;
DELIMITER $$
CREATE OR REPLACE PACKAGE pkg AS
  -- Declare a package public data type
  TYPE varchar_array IS TABLE OF VARCHAR(2000) INDEX BY INTEGER;
END;
$$
DELIMITER ;
DELIMITER $$

CREATE OR REPLACE PROCEDURE p1 AS
  v pkg.varchar_array; -- Use the package public data type
BEGIN
  v(0):='test';
  SELECT v(0);
END;
$$
DELIMITER ;

Note, the change is done only for sql_mode=ORACLE, because the TYPE
declaration is not available for the default mode.

Where package-wide types are available
--------------------------------------
- Variabe list type:
    DECLARE var pkg1.type1;

- RETURN type for a package routine:
    CREATE FUNCTION .. RETURN pkg1.type1 ...

- Parameter type for a package routine:
    PROCEDURE p1(param1 pkg1.type1);

- Assoc array element type:
    TYPE assoc1_t IS TABLE OF pkg1.type1 ...

- REF CURSOR RETURN type:
    TYPE cur1_t IS REF CURSOR RETURN pkg1.type1;

Change details
--------------

- Adding a member Lex_length_and_dec_st::m_foreign_module_type
  It's set to true when the data type was initialized from a TYPE
  in foreign routine (e.g. in PACKAGE spec).
  It's needed to prevent use of qualified identifiers in public contexts,
  i.e. in schema public routine parameter types and schema publuc function
  RETURN types.
  Adding a helper method sp_head::check_applicability() which prevents
  use of qualified types in public context.

- Adding a helper method sp_head::raise_unknown_data_type().

- Adding methods LEX::set_field_type_typedef_package_spec() for
  2-step and 3-step qualified indentifiers.
  It's used in field_type_all_with_typedefs which covers cases:
  - Variabe list type        : DECLARE var pkg1.type1;
  - RETURN type              : CREATE FUNCTION .. RETURN pkg1.type1 ...
  - Parameter type           : PROCEDURE p1(param1 pkg1.type1);
  - Assoc array element type : TYPE assoc1_t IS TABLE OF pkg1.type1 ...

- Adding a method LEX::declare_type_ref_cursor_return_typedef().
  It handles cases when a new TYPE REF CURSOR RETURN is declared,
  for both for qualified RETURN types and non-qualified RETURN types:
  - TYPE cur0_t IS REF CURSOR RETURN rec1_t;
  - TYPE cur0_t IS REF CURSOR RETURN pkg1.rec1_t;
  - TYPE cur0_t IS REF CURSOR RETURN db1.pkg1.rec1_t;

  The code was moved from LEX::declare_type_ref_cursor() into
  LEX::declare_type_ref_cursor_return_typedef() and extended
  to cover qualified RETURN types.

- Adding a method Sql_path::find_package_spec_type().
  It iterates through all schemas specified in @@path and searches
  for the given type in the given package.

- Adding a helper method sp_pcontext::type_defs_add_ref_cursor()
  to reuse the code.

- Adding a new method sp_package::get_typedef() to search
  for TYPE definitions in PACKAGE specifications.

- Adding a new method sp_head::get_typedef_package_spec()
  to search for TYPE definitions used by a PROCEDURE or FUNCTION.

- Adding a helper method
    Sp_handler::sp_cache_routine_reentrant_suppress_errors
  Adding a method Sp_handler::find_package_spec().
2026-08-13 23:15:53 +04:00
Sergei Petrunia
80de6a791d Make mtr accept and ignore "--disable_replay next_query|test_file text" command 2026-08-12 14:31:57 +03:00
Sergei Petrunia
bc5a978668 Revert the --replay-server mtr feature 2026-08-12 14:31:57 +03:00
bsrikanth-mariadb
dfb1a1e24a clear optimizer_record_context after error/warning has occured during
replay

If not done, then context recording is performed for subsequent
non-explain queries. This could result in counter mismatches.
2026-08-12 14:31:56 +03:00
Sergei Petrunia
2940645031 Make --replay-server --replay-server-trace delete old traces at start. 2026-08-12 14:31:56 +03:00
Sergei Petrunia
2a86ebd553 Make --replay-server support "Optimizer Context Stopword": subquery_runs
If a stopword is present in the optimizer context, we do not try to
replay it.
2026-08-12 14:31:55 +03:00
Sergei Petrunia
3205c23a6f Add --replay-server-trace option.
Using

  ./mtr --replay-server --replay-server-trace

will now create files:

1.  mysql-test/main/$test_name.opt_trace.original
2.  mysql-test/main/$test_name.opt_trace.replay

The files show queries and optimizer trace outputs for the queries where:
1. We did try replaying in the server.
2. EXPLAIN output on the primary server and replay were different.
2026-08-12 14:31:55 +03:00
Sergei Petrunia
5395da104b Fix --replay-server error reporting: print query that caused error 2026-08-12 14:31:55 +03:00
Sergei Petrunia
ad402fb9ab MDEV-39368: Run "SET foreign_key_checks=0" on the replay server.
This is to avoid FK mismatch errors.
2026-08-12 14:31:55 +03:00
bsrikanth-mariadb
87b243dc9f MDEV-39368: fix warnings in mysqltest.cc
Compiling mysqltest.cc produced size conversion warnings and they were treated
as errors in windows. Fixing them as part of this commit.
2026-08-12 14:31:54 +03:00
Sergei Petrunia
6128c1d906 MDEV-39368: Make is_explain_query() reject EXPLAIN ...FOR CONNECTION,
Also make it use regexes
2026-08-12 14:31:54 +03:00
Sergei Petrunia
21323c89a5 MDEV-39368: Print errors for context preparation queries into query output.
I don't think we can print warnings, we would get spurious test failures.
2026-08-12 14:31:54 +03:00
Sergei Petrunia
c1580a4895 MDEV-39368: Add "--disable_replay testfile reason" support.
Disable replay use for the whole file.
2026-08-12 14:31:54 +03:00
Sergei Petrunia
5ec27db5ca MDEV-39368: Add disable_replay command, first variant.
Usage:
--disable_replay next_query <arbitrary reason text>

If the next query after this is an EXPLAIN, its processing will be disabled.
2026-08-12 14:31:54 +03:00
Sergei Petrunia
fc926f8b5d MDEV-39368: Improve error reporting.
A whole class of errors were not printed to the test output.
2026-08-12 14:31:54 +03:00
Sergei Petrunia
74e6822a96 MDEV-39368: When replay query fails, print "*** REPLAY FAILED ***" instead of EXPLAIN output. 2026-08-12 14:31:53 +03:00
Sergei Petrunia
6d859f2a76 MDEV-39368: When replay query fails, print the original query location in test file 2026-08-12 14:31:53 +03:00
Sergei Petrunia
cffd73443c MDEV-39368: Fix wrong behavior for empty Replay Context
If the previous command was EXPLAIN, it would use its context.
If the previous command was not an EXPLAIN, nothing would be printed.
2026-08-12 14:31:53 +03:00
Sergei Petrunia
27756fba9b MDEV-39368: Print warnings for replay EXPLAINs. 2026-08-12 14:31:53 +03:00
Sergei Petrunia
a69878afae MDEV-39368: Do not try to replay EXPLAIN FOR CONNECTION 2026-08-12 14:31:53 +03:00
Sergei Petrunia
399f45a5d2 Remove garbage comment 2026-08-12 14:31:53 +03:00
Sergei Petrunia
596c09031a Enable replay for any EXPLAIN query, do not require "FORMAT=JSON". 2026-08-12 14:31:53 +03:00
Sergei Petrunia
837457ade9 Don't display result column name twice. 2026-08-12 14:31:53 +03:00
Sergei Petrunia
e9849b7c02 MDEV-39368: Run set optimizer_replay_context='' for cleanup. 2026-08-12 14:31:53 +03:00
Sergei Petrunia
2177acc02e MDEV-39368: Make mtr write queries into log/replay_queries.log 2026-08-12 14:31:53 +03:00
Sergei Petrunia
d24d431dfd MDEV-39368: Make --replay-server[-manual] save the output of last EXPLAIN in the replay.
The last command is set "optimizer_replay_context=null"...
2026-08-12 14:31:53 +03:00
Sergei Petrunia
bc35e4d615 MDEV-39368: Trace replay: add --extra-server support, part 1. 2026-08-12 14:31:53 +03: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
b8dbc264f0 Merge branch '13.0' into 'main' 2026-08-03 13:42:39 +02:00
Sergei Golubchik
dee8add860 memory leak in mariadb-import --lock-tables 2026-08-02 10:42:43 +02:00
Sergei Golubchik
6552e45061 MDEV-40340 mariadb-import --lock-tables crashes
don't change `argv` pointer, it's needed later for --lock-tables
2026-08-02 10:42:43 +02:00
Sergei Golubchik
2a4cfdde2b mysqldump: remove dead and broken code
since 2006 (3840774309) mysqldump tried to be smart when dumping
events - it tried to automatically detected a delimiter per event
that was not present in the event body, using ";;" by default.

This never worked, was broken since the first commit. It either used
the default ";;" or failed after trying the same ";;" delimiter
2147483646 times.

All other objects (routines, triggers, etc) used a hard-coded ";;"
for 20 years, which apparently worked fine. Let's remove the old
broken logic and dump events like all other objects,
2026-08-02 10:42:43 +02:00
forkfun
1a4bb1bbfd Merge branch '12.3' into '13.0' 2026-07-30 16:15:40 +02:00
forkfun
33240f3c96 Merge branch '11.8' into '12.3' 2026-07-30 11:41:55 +02:00
forkfun
eaca80bf32 Merge branch '11.4' into '11.8' 2026-07-29 12:27:46 +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
df64bf8114 MDEV-40217 restore error handling
get_table_structure() needs to distinguish between
the error condition and 0 fields to dump
2026-07-25 20:51:43 +02:00