Commit graph

202447 commits

Author SHA1 Message Date
Marko Mäkelä
3f914afd3a Merge 10.6 into 10.11 2025-01-02 12:39:56 +02:00
Monty
95975b921e MDEV-35720 Add query_time to statistics
Added Query_time (total time spent running queries) to status_variables.

Other things:
- Added SHOW_MICROSECOND_STATUS type that shows an ulonglong variable
  in microseconds converted to a double (in seconds).
- Changed Busy_time and Cpu_time to use SHOW_MICROSECOND_STATUS, which
  simplified the code and avoids some double divisions for each query.

Reviewed-by: Sergei Golubchik <serg@mariadb.org>
2024-12-30 16:13:20 +02:00
Monty
7fcaab7aaa MDEV-20912 Add support for utf8mb4_0900_* collations in MariaDB Server
This is done by mapping most of the existing MySQL unicode 0900 collations
to MariadB 1400 unicode collations. The assumption is that 1400 is a super
set of 0900 for all practical purposes.

I also added a new function 'compare_collations()' and changed most code
to use this instead of comparing character sets directly.
This enables one to seamlessly mix-and-match the corresponding 0900 and
1400 sets. Field comparision and alter table treats the character sets
as identical.

All MySQL 8.0 0900 collations are supported except:
- utf8mb4_ja_0900_as_cs
- utf8mb4_ja_0900_as_cs_ks
- utf8mb4_ru_0900_as_cs
- utf8mb4_zh_0900_as_cs

These do not have corresponding entries in the MariadB 01400 collations.

Other things:
- Added COMMENT colum to information_schema.collations. For utf8mb4_0900
  colletions it contains the corresponding alias collation.
2024-12-28 10:23:49 +02:00
Monty
ed5bba8a32 Fixed failing test case innodb.log_file_size_online 2024-12-27 16:14:51 +02:00
Oleg Smirnov
24e5d56400 MDEV-35680 Table number > MAX_TABLES causes overflow of table_map at main.join test
Fix a regression introduced by commit d98ac851 (MDEV-29935, MDEV-26247) causing
MAX_TABLES overflow in `setup_table_map()`. The check for MAX_TABLES was moved
outside of the loop that increments table numbers, allowing overflows during
loop iterations. Since setup_table_map() operates on a 64-bit bitmap, table
numbers exceeding 64 triggered the UBSAN check.
This commit returns the overflow check within the loop and adds a debug
assertion to `setup_table_map()` to ensure no bitmap overrun occurs.
2024-12-24 15:54:56 +07:00
Eric Herman
d878d80bc4 MDEV-35695: mtr failure suggests wrong url
When running the ./mtr tests and getting failures, rather than provide a
dead-link to mysql.com, this points developers to the Jira instance.

Signed-off-by: Eric Herman <eric@freesa.org>
2024-12-21 00:08:08 +11:00
Yuchen Pei
e021770667
MDEV-34911 Sargable substr(col, 1, n) = str
Make Item_func_eq of the following forms sargable by updating the relevant range
analysis methods:

1. substr(col, 1, n) = str
2. str = substr(col, 1, n)
3. left(col, n) = str
4. str = left(col, n)

where col is a indexed column and str is a const and inexpensive item
of length n.

We do this by factoring out Item_func_like::get_mm_leaf() and apply it
to a string obtained from escaping str and then appending a wildcard
"%" to it.

The addition of the two Functype enums, LEFT_FUNC and SUBSTR_FUNC,
requires changes in the spider group by handler to continue handling
LEFT and SUBSTR correctly.

Co-authored-by: Yuchen Pei <ycp@mariadb.com>
Co-authored-by: Sergei Petrunia <sergey@mariadb.com>
2024-12-20 13:25:28 +11:00
Eric Herman
ae998c22b2 MDEV-35683: add basic unit test for DYNAMIC_ARRAY
This demonstrates and tests the basic usage of DYNAMIC_ARRAY.

Additional tests could be added to demonstrate and test the
remaining functions and capabilities.

Signed-off-by: Eric Herman <eric@freesa.org>
2024-12-20 11:07:53 +11:00
Lena Startseva
bc32705f46 MDEV-31005: Make working cursor-protocol
Excluded cases in main.vector,
	main.ctype_utf8,
	main.type_timestamp,
	main.log_slow_always_query_time

Fix for v.11.7
2024-12-19 15:33:39 +00:00
Marko Mäkelä
a54d151fc1 Merge 10.6 into 10.11 2024-12-19 15:38:53 +02:00
Marko Mäkelä
f2ffcd949b MDEV-35657: Add work-arounds for clang 11 2024-12-19 14:18:55 +02:00
Marko Mäkelä
e5c4c0842d MDEV-35443: opt_search_plan_for_table() may degrade to full table scan
opt_calc_index_goodness(): Correct an inaccurate condition.
We can very well use a clustered index of a table that is subject
to online rebuild. But we must not choose an index that has not been
committed (it is a secondary index that was not fully created)
or that is corrupted or not a normal B-tree index.

opt_search_plan_for_table(): Remove some redundant code, now that
opt_calc_index_goodness() checks against corrupted indexes.

The test case allows this code to be exercised. The main observation
in the following:
	./mtr --rr innodb.stats_persistent
	rr replay var/log/mysqld.1.rr/latest-trace
should be that when opt_search_plan_for_table() is being invoked by
dict_stats_update_persistent() on the being-altered statistics table
in the 2nd call after ha_innobase::inplace_alter_table(),
and the fix in opt_calc_index_goodness() is absent,
it would choose the code path if (n_fields == 0), that is, a full
table scan, instead of searching for the record. The GDB commands to
execute in "rr replay" would be as follows:
	break ha_innobase::inplace_alter_table
	continue
	break opt_search_plan_for_table
	continue
	continue
	next
	next
	…

Reviewed by: Vladislav Lesin
2024-12-19 14:05:16 +02:00
Daniele Sciascia
07b77e862c MDEV-35660 Assertion `trx->xid.is_null()' failed
The assertion fails during wsrep recovery step, in function
innobase_rollback_by_xid(). The transaction's xid is normally
cleared as part of lookup by xid, unless the transaction has
a wsrep specific xid.
This is a regression from MDEV-24035 (commit ddd7d5d8e3)
which removed the part clears xid before rollback for transaction
with a wsrep specific xid.
2024-12-19 08:55:59 +01:00
mariadb-DebarunBanerjee
3f22f5f2fe MDEV-35679 Potential issue in Secondary Index with ROW_FORMAT=COMPRESSED and Change buffering enabled
In function buf_page_create_low(), remove duplicate code that
over-write the ibuf_exist variable incorrectly when only compressed
page is loaded in buffer pool. This would help removing any old change
buffer record immediately before re-using the page.
2024-12-18 20:46:26 +05:30
Julius Goryavsky
3cd9f9d1b3 Merge branch '10.5' into '10.6' 2024-12-18 05:09:23 +01:00
Dave Gosselin
a226f12675 MDEV-35578 innodb_gis.rtree_debug fails on mac
strerror_s on Linux will, for unknown error codes, display
'Unknown error <codenum>' and our tests are written with this assumption.
However, on macOS, sterror_s returns 'Unknown error: <codenum>' in the
same case, which breaks tests.  Make my_strerror consistent across the
platforms by removing the ':' when present.
2024-12-18 11:28:25 +11:00
Eric Herman
7734c85c31 unittest output improvement for json_normalize-t
The ok() function outputs the TAP context string in both the success
and failure cases. The strings were worded to make sense in the
failure case, yet were confusing in the success case. This changes
the strings to be appropriate, and even more informative in either
the success or failure cases.  In the cases where input, expected,
and result values are included in the context string, they have been
adjusted such that expected and actual result values are aligned for
easy visual comparison.

Signed-off-by: Eric Herman <eric@freesa.org>
2024-12-18 10:12:34 +11:00
Kristian Nielsen
a090a3c571 MDEV-33239: mysqlbinlog always stops at timestamp 0xffffffff
Do not use the magic value 0xffffffff as meaning "no --stop-datetime option
specified", as this is a valid timestamp value. Use an explicit boolean flag
instead.

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2024-12-17 17:54:17 +01:00
Kristian Nielsen
9e7762e718 MDEV-35233: RBR does not work with CSV tables
Handle null bits for record comparison in row events the same way as in
handler::calculate_checksum(), forcing bits that can be undefined to 1.
These bits are the trailing unused bits, as well as the first bit for
tables not using HA_OPTION_PACK_RECORD.

The csv storage engine leaves these bits at 0, while the row-based
replication has them set to 1, which otherwise cause can't find record error.

Reviewed-by: Monty <monty@mariadb.org>
Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2024-12-17 17:34:29 +01:00
Julius Goryavsky
7b0f59da43 wsrep mtr suite: update for galera library 26.4.21 2024-12-17 09:57:29 +01:00
Julius Goryavsky
c93ffd5e58 galera: wsrep-lib submodule update 2024-12-17 09:53:19 +01:00
Daniele Sciascia
eadf96cea4 MDEV-26266 Update wsrep-lib
Update wsrep-lib to fix the issue and add the MTR test case from
the ticket.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-12-17 09:52:32 +01:00
Daniele Sciascia
75dd0246f8 Remove error handling from wsrep_sync_wait()
Let the wsrep-lib error be set/overriden at the end of
dispatch_command().

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-12-17 09:52:32 +01:00
Daniele Sciascia
d72c5d1ace Fixup for MDEV-35446
The previous commit for fixing MDEV-35446 disabled setting
Galera errors on COM_STMT_PREPARE commands.
As a side effect, a number of tests were started to fail
due to the client receiving different error codes from the
ones expected in the test dependending on whether --ps-protocol
was used.
Also, in the case of test galera_ftwrl, it was found that
it is expected that during COM_STMT_PREPARE command, we
may perform a sync wait operation, which can fail with
LOCK_WAIT_TIMEOUT error.
The revised fix consists in anticipating the call to
wsrep_after_command_before_result(), so that we check for
BF aborts or errors during statement prepare, before sending
back the statement metadata message to client.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-12-17 09:52:32 +01:00
Jan Lindström
ee2dc336d7 TODO-5067 addendum : Add test case for Galera library protocol versions
Add missing file

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-12-17 09:52:32 +01:00
Jan Lindström
28463b2824 TODO-5067 : Add test case for Galera library protocol versions
This version of test requires Galera library 26.4.21 to work.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-12-17 09:52:32 +01:00
Dave Gosselin
7c9cbe684b MDEV-35648 Update partition lc2 tests for mac
Partition tests requiring lower_case_table_names = 2 (default on macOS)
fail on mac because the product has changed over time but the tests were
not run regularly enough to observe their breakage.
2024-12-17 15:28:33 +11:00
Yuchen Pei
671f80c738
Merge branch '10.5' into 10.6 2024-12-17 11:06:09 +11:00
Yuchen Pei
77c9917663
MDEV-34716 Fix mysql.servers socket max length too short
The limit of socket length on unix according to libc is 108, see
sockaddr_un::sun_path, but in the table it is a string of max length
64, which results in truncation of socket and failure to connect by
plugins using servers such as spider.
2024-12-17 10:40:57 +11:00
Andrei Elkin
bc6121819c MDEV-35098 rpl.rpl_mysqldump_gtid_slave_pos fails in buildbot
The test turns out to be senstive to @@global.gtid_cleanup_batch_size.
With a rather small default value of the latter
SELECTing from mysql.gtid_slave_pos may not be deterministic: tests
that run before may increase a pending for automitic deletion batch.

The test is refined to set its own value for the batch size which
is virtually unreachable.

Thanks to Kristian Nielsen for the analysis.
2024-12-16 19:43:41 +02:00
Marko Mäkelä
c982a143fc MDEV-35494 fixup: Always initialize latch
It turns out that init() always checks in debug builds that
some fields of the latch had been filled with zero.
2024-12-16 13:23:13 +02:00
Lena Startseva
aa49770d79 MDEV-31005: Make working cursor-protocol
Excluded cases in main./secure_file_priv_win

Fix for v.10.5
2024-12-16 10:08:56 +00:00
Marko Mäkelä
c391fb1ff1 MDEV-35577 Broken recovery after SET GLOBAL innodb_log_file_size
If InnoDB is killed in such a way that there had been no writes
to a newly resized ib_logfile101 after it replaced ib_logfile0
in log_t::write_checkpoint(), it is possible that recovery will
accidentally interpret some garbage at the end of the log as valid.

log_t::write_buf(): To prevent the corruption, write an extra NUL byte
at the end of log_sys.resize_buf, like we always did for the main
log_sys.buf. To remove some conditional branches from a time critical
code path, we instantiate a separate template for the rare case that the
log is being resized. Define as __attribute__((always_inline)) so that
this will be inlined also in the rare case the log is being resized.

log_t::writer: Pointer to the current implementation of
log_t::write_buf(). For quick access, this is located in the
same cache line with log_sys.latch, which protects it.

log_t::writer_update(): Update log_sys.writer.

log_t::resize_write_buf(): Remove ATTRIBUTE_NOINLINE ATTRIBUTE_COLD.
Now that log_t::write_buf() will be instantiated separately for the
rare case of log resizing being in progress, there is no need to forbid
this code from being inlined.

Thanks to Thirunarayanan Balathandayuthapani for finding the
root cause of this bug and suggesting the fix of writing an extra
NUL byte.

Reviewed by: Debarun Banerjee
2024-12-16 11:50:00 +02:00
Sergei Golubchik
17cb65593a MDEV-22964: archive.archive and main.mysqlbinlog_{row,stmt}_compressed)
zlib-ng results in different compression length. The compression
length isn't that important as the test output examines the uncompressed
results.

fixes for zlib-ng

backport of 75488a57f2
2024-12-16 10:04:07 +11:00
Oleg Smirnov
d98ac8511e MDEV-26247 MariaDB Server SEGV on INSERT .. SELECT
This problem occured for statements like `INSERT INTO t1 SELECT 1`,
which do not have tables in the SELECT part. In such scenarios
SELECT_LEX::insert_tables was not properly set at `setup_tables()`,
and this led to either incorrect execution or a crash

Reviewer: Oleksandr Byelkin <sanja@mariadb.com>
2024-12-14 14:04:21 +07:00
Oleg Smirnov
e640373389 Revert "MDEV-26427 MariaDB Server SEGV on INSERT .. SELECT"
This reverts commit 49e14000ee
as it introduces regression MDEV-29935 and has to be reconsidered
in general
2024-12-14 13:08:17 +07:00
Oleksandr Byelkin
271b73770c MDEV-30263 Assertion failure in Protocol::end_statement upon HANDLER READ with invalid timestamp
Process save_in_field() return codes as in other places (<0 is real
error)
2024-12-13 16:27:14 +01:00
mariadb-DebarunBanerjee
c7698a0b70 MDEV-35626 Race condition between buf_page_create_low() and read completion
This regression is introduced in 10.6 by following commit.
commit 35d477dd1d
MDEV-34453 Trying to read 16384 bytes at 70368744161280

The page state could change after being buffer-fixed and needs to be
read again after locking the page.
2024-12-13 18:36:47 +05:30
Alexander Barkov
d1f42fc80f MDEV-21589 AddressSanitizer: memcpy-param-overlap in Static_binary_string::q_append or String::append
Item_func_concat_ws::val_str():
- collects the result into the string "str" passed as a parameter.
- calls val_str(&tmp_buffer) to get arguments.

At some point due to heuristic it decides to swap the buffers:
- collect the result into &tmp_buffer
- call val_str(str) to get arguments

Item_func_password::val_str_ascii() returns a String pointing to its
member tmp_value[SCRAMBLED_PASSWORD_CHAR_LENGTH+1].

As a result, it's possible that both str and tmp_buffer in
Item_func_concat_ws::val_str() point to Item_func_password::tmp_value.
Then, memcmp() called on overlapping memory fragrments.

Fixing Item_func_password::val_str_ascii() to use Item::copy()
instead of Item::set().
2024-12-13 11:09:29 +01:00
Marko Mäkelä
1097164d3f MDEV-35619 Assertion failure in row_purge_del_mark_error
trx_sys_t::find_same_or_older_in_purge(): Correct a mistake that
was made in commit 19acb0257e
(MDEV-35508) and make the caching logic correspond to the one in
trx_sys_t::find_same_or_older(). In the more common code path
for 64-bit systems, the condition !hot was inadvertently inverted,
making us wrongly skip calls to find_same_or_older_low() when the
transaction may still be active.

Furthermore, the call should have been to find_same_or_older_low()
and not the wrapper find_same_or_older().
2024-12-13 11:41:47 +02:00
Sergei Golubchik
b66d421d60 MDEV-35046 update test results
followup for 3f114a0930
2024-12-13 10:40:04 +01:00
Dmitry Shulga
54c1031b74 MDEV-34958: after Trigger doesn't work correctly with bulk insert
This bug has the same nature as the issues
  MDEV-34718: Trigger doesn't work correctly with bulk update
  MDEV-24411: Trigger doesn't work correctly with bulk insert

To fix the issue covering all use cases, resetting the thd->bulk_param
temporary to the value nullptr before invoking triggers and restoring
its original value on finishing execution of a trigger is moved to the method
  Table_triggers_list::process_triggers
that be invoked ultimately for any kind of triggers.
2024-12-13 16:19:39 +07:00
Alexander Barkov
0b7fa4c267 MDEV-31219 Assertion `fixed' failed in Item_func_hybrid_field_type / Frame_positional_cursor
add_special_frame_cursors() did not check the return
value offset_func->fix_fields(). It can return an error
if the data type does not support the operator "minus".
2024-12-13 09:40:31 +01:00
Yuchen Pei
432856c473
MDEV-35571 Check for LIMIT ROWS EXAMINED exceeded in UNION ALL
When UNION ALL is used with LIMIT ROWS EXAMINED, and when the limit is
exceeded for a SELECT that is not the last in the UNION, interrupt the
execution and call end_eof on the result. This makes sure that the
results are sent, and the query result status is conclusive rather
than empty, which would cause an assertion failure.
2024-12-13 15:44:01 +11:00
Julius Goryavsky
155203c352 Merge branch '10.5' into '10.6' 2024-12-13 01:45:35 +01:00
Julius Goryavsky
3e34e4c161 MDEV-34820: wsrep_sst_mariabackup get_footprint() portability and accuracy fix
Added get_footprint() implementation for FreeBSD (and for other
non-Linux systems), and added "apparent file size" mode for Linux
to take into account the real file size (without compression) when
used with filesystems like ZFS.
2024-12-13 01:41:14 +01:00
Julius Goryavsky
b52f88edf8 MDEV-35387: wsrep_sst_rsync crash if aria_log_dir_path is defined
This commit fixes some functions in wsrep_sst_common
to ensure that now and in the future return codes from
a number of helper functions will be zero on success.
2024-12-13 01:41:07 +01:00
Julius Goryavsky
71a9b3bf16 galera sst scripts: fix for error hangling code
Fixed some issues in the script code, mainly related
to handling situations when a failure occurs:

1) the signal handler in the mariadb-backup SST script
   was using an uninitialized variable when trying to kill
   a hung streaming process;
2) inaccurate error messages were being logged sometime;
3) after completing SST, temporary or old (extra) files
   could remain in database directories.
2024-12-13 01:36:59 +01:00
Daniel Black
6dcd9de2a9 MDEV-34669: ER_NEED_REPREPARE on SELECT DEFAULT(name) FROM table1_containing_sequence
A prepared SELECT statement because of CF_REEXECUTION_FRAGILE needs to
check the table is the same definition as previously otherwise a
re-prepare of the statement can occur.

When running many 'SELECT DEFAULT(name) FROM table1_containing_sequence'
in parallel the TABLE_LIST::is_the_same_definition may be called when
m_table_ref_type is TABLE_REF_NULL because it hasn't been checked yet.

In this case populate the TABLE_LIST with the values determined by the
TABLE_SHARE and allow the execution to continue.

As a result of this, the main.ps_ddl test doesn't need to reprepare
as the defination hasn't changed. This is another case where
TABLE_LIST::is_the_same_definition is called when m_table_ref_type is
TABLE_REF_NULL, but that doesn't mean that the defination is different.
2024-12-13 08:07:00 +11:00
Alexander Barkov
ab9182470d MDEV-31366 Assertion `thd->start_time' failed in bool LOGGER::slow_log_print(THD*, const char*, size_t, ulonglong)
Fixing a wrong DBUG_ASSERT.

thd->start_time and thd->start_time_sec_part cannot be 0 at the same time.

But thd->start_time can be 0 when thd->start_time_sec_part is not 0,
e.g. after:

SET timestamp=0.99;
2024-12-12 20:32:56 +01:00