Home - Waterfall Grid T-Grid Console Builders Recent Builds Buildslaves Changesources - JSON API - About

Console View


Categories: connectors experimental galera main
Legend:   Passed Failed Warnings Failed Again Running Exception Offline No data

connectors experimental galera main
Sergei Petrunia
Fix comments for simplify_joins() and other non-functional cleanup.
Alexey Botchkov
MDEV-38809 RBR fails upon DML with XML type.

Add Field_xmltype::rpl_conv_type_from() function to control
replication data types.
Aleksey Midenkov
MDEV-38710 Assertion is_lock_owner on error returning from auto-create in mysql_admin_table

Followup commit for 4802bfe4f90.

After returning error from check_vers_constants() the stack
immediately returns error status up to mysql_admin_table() where it
does close_thread_tables(). The latter expects MDL acquired.

The bug discloses the generic problem of fallback mechanism throwing
an error when the upper frame does close_thread_tables().
PranavKTiwari
MDEV-38839: Fix assertion in close_thread_tables() for CREATE TABLE...SELECT FOR UPDATE with MyISAM temp tables in MIXED mode.
Cause: FOR UPDATE on MyISAM temp tables uses a write lock (no row-level locking), incorrectly marking a read as a write. This blocks binlog_truncate_trx_cache() and triggers an assertion.
Fix: In decide_logging_format(), check tbl->updating to detect real writes. For read-only access, mark as STMT_READS_TEMP_NON_TRANS_TABLE instead of write, preventing incorrect behavior.
Aleksey Midenkov
MDEV-28619 Server crash and UBSAN null-pointer-use in Window_funcs_sort::setup

Optimization in st_select_lex_unit::prepare() removes ORDER BY for
certain subqueries. That excludes ORDER BY items from being fixed, but
sl->window_funcs still contains window function items and those
related to optimized out ORDER BY are unfixed. The error about missing
window spec is thrown when the item is fixed. Hence we get redundant
processing of window function items without checking window spec
existence.

The fix removes the related window function items when ORDER BY is
optimized out. ORDER accumulates window_funcs at parser stage which
are then removed from SELECT_LEX::window_funcs. The fix also updates
similar optimization in mysql_make_view().
Daniel Black
deb: format debian/control of videx
Vladislav Vaintroub
Fix merge

New [ERROR] entries can now appear in error log, when dropping a
a non-existent event.
Marko Mäkelä
Merge 12.3 into main
Marko Mäkelä
WIP MDEV-14992 BACKUP SERVER

This introduces a basic driver Sql_cmd_backup, storage engine interfaces,
and basic copying of InnoDB data files.
On Windows, we pass a target directory name; elsewhere, we pass a
target directory handle.

fil_space_t::write_or_backup: Keep track of in-flight page writes and
pending backup operation. We must not allow them concurrently, because
that could lead into torn pages in the backup.

fil_space_t::backup_end: The first page number that is not being backed up
(by default 0, to indicate that no backup is in progress).

TRX_STATE_BACKUP: A special InnoDB transaction state indicating association
with BACKUP SERVER, which allows us to pass some context in trx_t from
innodb_backup_end() to innodb_backup_finalize().

log_t::backup: Whether BACKUP SERVER is in progress. The purpose of this
is to make BACKUP SERVER prevent the concurrent execution of
SET GLOBAL innodb_log_archive=OFF or SET GLOBAL innodb_log_file_size
when innodb_log_archive=OFF.

log_sys.archived_checkpoint: Keep track of the earliest available
checkpoint, corresponding to log_sys.archived_lsn. This reflects
SET GLOBAL innodb_log_recovery_start (which is settable now), for
incremental backup.

buf_flush_list_space(): Check for concurrent backup before writing each
page. This is inefficient, but this function may be invoked from multiple
threads concurrently, and it cannot be changed easily, especially for
fil_crypt_thread().

FIXME: MoveFileEx() after CreateHardLink() fails on Windows

TODO: Implement open(O_DIRECTORY) and openat(2) compatible API on Windows,
to have a uniform interface (passing a target directory handle, not name).

TODO: Implement finer-grained locking around copying page ranges.

TODO: Implement other storage engine interfaces.

TODO: Implement the necessary locking around backup_end.

TODO: Fix the space.get_create_lsn() < checkpoint logic.
Marko Mäkelä
MDEV-16926 fixup: GCC 16 -Wmaybe-uninitialized

Year::year_precision(): Make static, so that VYear::VYear
and VYear_op::VYear_op() will avoid invoking this function with
an unnecessary "this" pointer to an uninitialized object.
Daniel Black
MDEV-30953: mariadb-server-galera - separate systemd component

There was elements of mariadb.service exclusively for galera.

Separate these out to a galera.conf file installed in
/usr/lib/systemd/systemd/mariadb.service.d/galera.conf.
PranavKTiwari
MDEV-38839: Fix assertion in close_thread_tables() for CREATE TABLE...SELECT FOR UPDATE with MyISAM temp tables in MIXED mode.
Cause: FOR UPDATE on MyISAM temp tables uses a write lock (no row-level locking), incorrectly marking a read as a write. This blocks binlog_truncate_trx_cache() and triggers an assertion.
Fix: In decide_logging_format(), check tbl->updating to detect real writes. For read-only access, mark as STMT_READS_TEMP_NON_TRANS_TABLE instead of write, preventing incorrect behavior
Mohammad Tafzeel Shams
MDEV-22186: Add innodb_buffer_pool_in_core_dump to exclude InnoDB buffer pool from cores

Problem:
There is no control to include or exclude large InnoDB buffer pool from
core files, which can lead to unnecessarily large core dumps or prevent
capturing useful memory state.

Solution:
Introduce a new global dynamic system variable innodb_buffer_pool_in_core_dump
that allows excluding InnoDB buffer pool from core dumps using MADV_DONTDUMP
where supported. When enabled the server marks relevant memory regions to be
omitted from core files. The madvise state is dynamically updated when the
variable changes.

This variable is only available on Linux & FreeBSD.

Additionally, a test helper script is introduced to inspect
/proc/<pid>/smaps and verify whether large memory regions are marked
for trimming.

- innodb_buffer_pool_in_core_dump
  Global boolean system variable controlling whether InnoDB buffer
  pool should be excluded from core dumps.
  Default: OFF on non-debug builds with MADV_DONTDUMP support,
  ON otherwise.

- innodb_buffer_pool_in_core_dump_update()
  Update hook that sets innodb_buffer_pool_in_core_dump and triggers runtime
  updates of madvise state for the buffer pool.

- buf_pool_t::in_core_dump
  Variable backing @@innodb_buffer_pool_in_core_dump.

- buf_pool_t::core_advise()
  Advises MADV_DONTDUMP or MADV_DODUMP according to latest
  innodb_buffer_pool_in_core_dump value.

- buf_pool_t::create()
  Updates madvise flag to the buffer pool memory based on
  innodb_buffer_pool_in_core_dump.
  Also moves the mutex initialization at the beginiing of function.

- buf_pool_t::resize()
  Updates the madvise flag for buffer pool to keep it in sync with
  the innodb_buffer_pool_in_core_dump.

- check_core_dump_trim.inc
  Test helper that inspects /proc/<pid>/smaps to detect memory regions
  with the dd VmFlag and determine whether the core file is expected
  to be trimmed based on buffer pool and log buffer sizes.
Tuukka Pasanen
MDEV-30953: Add package for Galera server for RPM

Following the previous commit, we apply the same
to RPM.

Add new package Mariadb-server-galera to RPM build
recude mariadb-server package dependencies.
Galera cluster scripts and libraries are currently
in package mariadb-server. Move Galera cluster
scripts and libraries to new package mariadb-server-galera
as most of the people does not need them and
it allows to slim down mariadb-server package

The MariaDB-test package unlike its Debian
equal, didn't depend on the MariaDB-server
(and now it does), except if WITH_WSREP is
specified in which case it depends on the
MariaDB-server-galera package

Also from a865a7c23bd8c06bf1de0a759703f898f6c180c2
lsof, socat and pv are RECOMMENDS.
* lsof/socat - when selinux is enabled, these aren't used
* pv - the galera sst scripts will silently ignore its absence

Updated/Edited by: Daniel Black <[email protected]>
Abhishek Bansal
MDEV-38264: Fix failed assertion in json_find_path with trailing commas

The function json_skip_array_and_count() was trapping syntax errors
(e.g., trailing commas) in a local engine copy. Because the error state
wasn't propagated back to the main engine, json_find_path() would
proceed with an inconsistent state, eventually triggering an assertion
failure.

This patch ensures that any error encountered during the lookahead
scan is propagated to the primary engine. This allows the parser to
fail gracefully with a syntax error instead of crashing.
Tuukka Pasanen
MDEV-30953: Add package for Galera server (Deb)

MDEV-38744 removed the galera as a server dependency,
and we've decided to put it back.

While we put it back and there's a fresh release
series, lets incorporate some packaging improvements.

Historicly, since 10.1 when Galera became part
of the server the MariaDB-server package included
all the dependencies of Galera, its SST scripts,
in case the user wanted them. There where many
cases where this wasn't the case. As we
separate out to a separate mariadb-server-galera
package, we give the option if they want a
galera install and have its dependencies, or
a more minimal installation.

To facilitate this:

Add new package mariadb-server-galera to Debian to
recude mariadb-server package dependencies.
Galera cluster scripts and libraries are currently
in package mariadb-server. Move Galera cluster
scripts and libraries to new package mariadb-server-galera
as most of the people does not need them and
it allows to slim down mariadb-server package

More explictly:

As such this moves the following files that were previously
in the MariaDB-server packgage to the MariaDB-server-galera package:
* README-wsrep
* Galera SST scripts
* /etc/systemd/system/[email protected]/use_galera_new_cluster.conf

The dependencies of the Galera SST scripts are moved to
the dependencies of the MariaDB-server-galera package.

As the installation of this package is a key indication that
galera is required 60-galera.cnf in the configuration has
explict galera required configuration items set. The
wsrep_cluster_address will however be required to be set by the
user. When the user test this they must also enable
wsrep_on.

The galera-4 is also a dependency of MariaDB-server-galera package
rather than the MariaDB-server package.

MariaDB users previously using galera installed instance, that are
doing a major upgrade will need to be aware that the new package
is required.

Non-galera users during a major upgrade are going to get a slightly
smaller install, and a bunch of previous installed dependencies that
are no longer required and can be removed.

The mariadb-test package change its dependency from mariadb-server
to mariadb-server-galera so all the requirement of the server
are there.

Updated/Edited by: Daniel Black <[email protected]>
Vladislav Vaintroub
Merge branch '11.8' into 12.3
Marko Mäkelä
Merge 10.11 into 11.4
ShenLin
MDEV-39041: Execute permissions required to make dh_link execute this to expand $DEB_HOST_MULTIARCH
Aleksey Midenkov
MDEV-28619 with_flags cleanup

The best practice is to init as much info as possible in class
constructor. with_flags access may be needed before fix_fields() or
fix_fields() may be not called at all like it takes place in
MDEV-28619. The fix for MDEV-28619 requires WINDOW_FUNC check on
unfixed item.
Aleksey Midenkov
MDEV-38798 Assertion `mdl_key->length() == 3' failed in MDL_map::find_or_insert

Originally two MDL_EXCLUSIVE are used for pure alias of derived table
and its schema which is empty db name. It is concurrency performance
overhead and there is no obvious reason why such MDL should exist.

MDEV-33985 changed pure alias check from `db.str` to `db.length` and
that allowed `empty_c_string` to be pure alias too. It is important
for MDEV-33985 fix with sequences. Now such kind of pure alias skips
MDL initialization and thus derived table fails falsely on BACKUP
namespace as it is default namespace for 0-filled structure (see TODO
comments).

The fix a) keeps MDL_NOT_INITIALIZED for uninitialized MDL and that
was the consequence of MDL_INTENTION_EXCLUSIVE value 0 (see TODO
comment).

And b) does not update MDL type for pure alias when view is
initialized, so it is MDL_NOT_INITIALIZED. `lock_table_names()` code
naturally skips such kind of MDL with (mdl_request.type <
MDL_SHARED_UPGRADABLE) condition when processing tables list.
Daniel Black
systemd: deprecate MYSQLD_OPTS

It was added without a good use case as
all MariaDB options where available to
uses to put in configuration files.

Put a notice of deprecation for now.
Michal Schorm
MDEV-18359, MDEV-26905: Fix invalid XML in charsets Index.xml

Summary:
The charset definition files sql/share/charsets/Index.xml and
mysql-test/std_data/ldml/Index.xml contained duplicate "flag" attributes
on single <collation> elements, violating XML well-formedness rules.
Standard XML parsers (xmllint, libxml2, etc.) reject duplicate attributes,
making these files unparseable by any spec-compliant tool.

Root Cause:
When nopad_bin collations were added, their flags were specified as
XML attributes: flag="binary" flag="nopad". The XML specification
(Section 3.1, Well-Formedness Constraint: Unique Att Spec) prohibits
duplicate attribute names on a single element. MariaDB's custom XML
parser in strings/xml.c happened to process both duplicates because
it handles attributes sequentially in a while loop, but this is
non-standard behavior that breaks interoperability with standard
XML tooling.

What the patch does:
Converts all 24 occurrences of duplicate flag attributes from
self-closing elements with duplicate attributes to elements with
child <flag> nodes. This follows the existing pattern already used
by many collations in the same file (e.g., big5_chinese_ci,
latin1_swedish_ci, utf8mb3_general_ci).

Before (invalid XML):
  <collation name="latin2_nopad_bin" id="1101" flag="binary" flag="nopad"/>

After (valid XML):
  <collation name="latin2_nopad_bin" id="1101">
    <flag>binary</flag>
    <flag>nopad</flag>
  </collation>

No C code changes are required. The _CS_FLAG handler in
strings/ctype.c (around line 621) already processes <flag> child
elements using bitwise OR (|=) to accumulate flags, so both "binary"
(MY_CS_BINSORT) and "nopad" (MY_CS_NOPAD) flags are correctly applied.

Files modified:
- sql/share/charsets/Index.xml (23 collations fixed)
- mysql-test/std_data/ldml/Index.xml (1 collation fixed)

Complete list of 24 collations fixed:

sql/share/charsets/Index.xml:
1. latin2_nopad_bin    (id=1101)
2. dec8_nopad_bin      (id=1093)
3. cp850_nopad_bin      (id=1104)
4. hp8_nopad_bin        (id=1096)
5. koi8r_nopad_bin      (id=1098)
6. swe7_nopad_bin      (id=1106)
7. ascii_nopad_bin      (id=1089)
8. cp1251_nopad_bin    (id=1074)
9. hebrew_nopad_bin    (id=1095)
10. latin7_nopad_bin    (id=1103)
11. koi8u_nopad_bin      (id=1099)
12. greek_nopad_bin      (id=1094)
13. cp1250_nopad_bin    (id=1090)
14. cp1257_nopad_bin    (id=1082)
15. latin5_nopad_bin    (id=1102)
16. armscii8_nopad_bin  (id=1088)
17. cp866_nopad_bin      (id=1092)
18. keybcs2_nopad_bin    (id=1097)
19. macce_nopad_bin      (id=1067)
20. macroman_nopad_bin  (id=1077)
21. cp852_nopad_bin      (id=1105)
22. cp1256_nopad_bin    (id=1091)
23. geostd8_nopad_bin    (id=1117)

mysql-test/std_data/ldml/Index.xml:
24. ascii2_nopad_bin    (id=325)

Validation:
- xmllint --noout passes cleanly on both files after the fix
- Zero duplicate flag attributes remain (verified with grep)
- The fix is consistent with the existing pattern used by other
  collations in the same files

Co-Authored-By: Claude AI <[email protected]>
Sergei Petrunia
Fix comments for simplify_joins() and other non-functional cleanups.
Marko Mäkelä
Merge 11.8 into 12.3
Varun Deep Saini
MDEV-35548: Fix out-of-bounds array access in json_get_path_start

json_get_path_start() set p->last_step to p->steps - 1, creating a
pointer before the beginning of the steps[] array. This is undefined
behavior flagged by UBSAN as "index -1 out of bounds for type
json_path_step_t[32]".

Use NULL as the sentinel value instead, and check for NULL in
json_get_path_next() rather than comparing against p->steps.

Backport to 10.6 of commit 4f546897b87144f4219094c5a852d766d5a46b74.

Additional test case from Rucha Deodhar

Signed-off-by: Varun Deep Saini <[email protected]>
Signed-off-by: Varun Deep Saini <[email protected]>
Daniel Black
wsrep_info plugin config file created
Aleksey Midenkov
MDEV-25365 Server hangs or crashes in Query_cache::move_by_type upon FLUSH QUERY CACHE

Caused by Bug#988 in 702b5ad.

How it works

QUERY blocks has all its tables in the array coming after
Query_cache_block header. Each such table element
(Query_cache_block_table) is also an element of doubly-linked circular
list associated with TABLE block used to find all queries by a
table. TABLE block data() is actually Query_cache_table: identificator
for table elements by real name. Every element in the circular list
has `parent` set to such Query_cache_table, except the list root. The
list root is the only Query_cache_block_table element owned by a TABLE
block, all other elements are owned by QUERY blocks. Thus TABLE block
n_tables is always 1.

FREE blocks are transformed into gap pointed by `border`. All the
QUERY and TABLE blocks are moved in place of the gap providing free
space defragmentation. Moving is done by creating new block at the
location of the gap and then doing memmove() from an old block to new
block. This may involve blocks overlap when the distance between the
blocks is less than the block size.

What was broken

When the old and the new QUERY blocks overlap, pointer can be in range
of both of them and checking the range does not guarantee affiliation
of the pointer with the old block. Such intra-block checks added by
Bug#988 can wrongly work on an already updated pointer.

In the test case small gap allows both tables 16 and 17 to be in the
overlapping region of old and new blocks. Iteration 16 updated
`prev->next` on the normal manner and the `prev` was table 17.
Iteration 17 sees this `next` as a pointer coming from an old block
though really it is already for a new block (as small gap shift allows
table 16 to be in both blocks), and it shifts it to the wrong
location. That have broken TABLE block circular chain.

How it was fixed

The fix modifies intra-block checks to work only in the forward
direction. F.ex., current table jx references intra-block by `next`
another table jy in later iteration (jx < jy) and we shift this `next`
pointer. Then by normal code (pre-Bug#988) we update `next->prev`. At
iteration jy we skip intra-block check for `prev` as it is in the past
iteration and was updated by iteration jx. The same happens for the
opposite direction, there is no semantic difference between `next` and
`prev` pointers.
Raghunandan Bhat
MDEV-38562: `mariabackup` exits with success (0) despite "No space left on device" errors

Problem:
  `mariabackup` ignores `my_close()` failures, resulting in false
  success report with a 'completed OK!' message.

Fix:
  Update `local_close()` function in `mariabackup` to check `my_close()`
  failures and enusre errors are reported.
Rucha Deodhar
MDEV-39213: json range syntax crash

Analysis:
When json is being parsed, the step decreases without a out-of-bound check
resulting in failure.
Fix:
Before decreasing the step, check if it will result into out of bound.
Marko Mäkelä
MDEV-37949: Implement innodb_log_archive

The InnoDB write-ahead log file in the old innodb_log_archive=OFF
format is named ib_logfile0, pre-allocated to innodb_log_file_size and
written as a ring buffer. This is good for write performance and space
management, but unsuitable for arbitrary point-in-time recovery or for
facilitating efficient incremental backup.

innodb_log_archive=ON: A new format where InnoDB will create and
preallocate files ib_%016x.log, instead of writing a circular file
ib_logfile0. Each file will be pre-allocated to innodb_log_file_size.
Once a log fills up, we will create and pre-allocate another log file,
to which log records will be written.  Upon the completion of the first
log checkpoint in a recently created log file, the old log file will
be marked read-only, signaling that there will be no further writes to
that file, and that the file may safely be moved to long-term storage.

The file name includes the log sequence number (LSN) at file offset
12288 (log_t::START_OFFSET). Each checkpoint is identified by storing
a 64-bit big-endian offset into an optional sequence of FILE_MODIFY
records followed by a FILE_CHECKPOINT record, between 12288 and the
end of the file.

The innodb_encrypt_log format is identified by storing the encryption
information at the start of the log file. The first 64-bit value will
be 1, which is an invalid checkpoint offset. Each
innodb_log_archive=ON log must use the same encryption parameters.
Changing innodb_encrypt_log or related parameters is only possible by
setting innodb_log_archive=OFF and restarting the server, which will
permanently lose the history of the archived log.

The maximum number of log checkpoints that the innodb_log_archive=ON
file header can represent is limited to 12288/8=1536 when using
innodb_encrypt_log=OFF. If we run out of slots in a log file, each
subsequently completed checkpoint in that log file will overwrite the
last slot in the checkpoint header, until we switch to the next log.

innodb_log_recovery_start: The checkpoint LSN to start recovery from.
This will be useful when recovering from an archived log. This is useful
for restoring an incremental backup (applying InnoDB log files that were
copied since the previous restore).

innodb_log_recovery_target: The requested LSN to end recovery at.
When this is set, all persistent InnoDB tables will be read-only, and
no writes to the log are allowed. The intended purpose of this setting
is to prepare an incremental backup, as well as to allow data
retrieval as of a particular logical point of time.

Setting innodb_log_recovery_target>0 is much like setting
innodb_read_only=ON, with the exception that the data files may be
written to by crash recovery, and locking reads will conflict with any
incomplete transactions as necessary, and all transaction isolation
levels will work normally (not hard-wired to READ UNCOMMITTED).

srv_read_only_mode: When this is set (innodb_read_only=ON), also
recv_sys.rpo (innodb_log_recovery_target) will be set to the current LSN.
This ensures that it will suffice to check only one of these variables
when blocking writes to persistent tables.

The status variable innodb_lsn_archived will reflect the LSN
since when a complete InnoDB log archive is available. Its initial
value will be that of the new parameter innodb_log_archive_start.
If that variable is 0 (the default), the innodb_lsn_archived will
be recovered from the available log files. If innodb_log_archive=OFF,
innodb_lsn_archived will be adjusted to the latest checkpoint every
time a log checkpoint is executed. If innodb_log_archive=ON, the value
should not change.

SET GLOBAL innodb_log_archive=!@@GLOBAL.innodb_log_archive will take
effect as soon as possible, possibly after a log checkpoint has been
completed. The log file will be renamed between ib_logfile0 and
ib_%016x.log as appropriate.

When innodb_log_archive=ON, the setting SET GLOBAL innodb_log_file_size
will affect subsequently created log files when the file that is being
currently written is running out. If we are switching log files exactly
at the same time, then a somewhat misleading error message
"innodb_log_file_size change is already in progress" will be issued.

no_checkpoint_prepare.inc: A new file, to prepare for subsequent
inclusion of no_checkpoint_end.inc. We will invoke the server to
parse the log and to determine the latest checkpoint.

All --suite=encryption tests that use innodb_encrypt_log
will be skipped for innodb_log_archive=ON, because enabling
or disabling encryption on the log is not possible without
temporarily setting innodb_log_archive=OFF and restarting
the server. The idea is to add the following arguments to an
invocation of mysql-test/mtr:

--mysqld=--loose-innodb-log-archive \
--mysqld=--loose-innodb-log-recovery-start=12288 \
--mysqld=--loose-innodb-log-file-mmap=OFF \
--skip-test=mariabackup

Alternatively, specify --mysqld=--loose-innodb-log-file-mmap=ON
to cover both code paths.

The mariabackup test suite must be skipped when using the
innodb_log_archive=ON format, because mariadb-backup will only
support the old ib_logfile0 format (innodb_log_archive=OFF).

A number of tests would fail when the parameter
innodb_log_recovery_start=12288 is present, which is forcing
recovery to start from the beginning of the history
(the database creation). The affected tests have been adjusted with
explicit --innodb-log-recovery-start=0 to override that:

(0) Some injected corruption may be "healed" by replaying the log
from the beginning. Some tests expect an empty buffer pool after
a restart, with no page I/O due to crash recovery.
(1) Any test that sets innodb_read_only=ON would fail with an error
message that the setting prevents crash recovery, unless
innodb_log_recovery_start=0.
(2) Any test that changes innodb_undo_tablespaces would fail in crash
recovery, because crash recovery assumes that the undo tablespace ID
that is available from the undo* files corresponds with the start of
the log. This is an unforunate design bug which we cannot fix easily.

log_sys.first_lsn: The start of the current log file, to be consulted
in log_t::write_checkpoint() when renaming files.

log_sys.archived_lsn: New field: The value of innodb_lsn_archived.

log_sys.end_lsn: New field: The log_sys.get_lsn() when the latest
checkpoint was initiated. That is, the start LSN of a possibly empty
sequence of FILE_MODIFY records followed by FILE_CHECKPOINT.

log_sys.resize_target: The value of innodb_log_file_size that will be
used for creating the next archive log file once the current file (of
log_sys.file_size) fills up.

log_sys.archive: New field: The value of innodb_log_archive.

log_sys.next_checkpoint_no: Widen to uint16_t. There may be up to
12288/8=1536 checkpoints in the header.

log_sys.log: If innodb_log_archive=ON, this file handle will be kept
open also in the PMEM code path.

log_sys.resize_log: If innodb_log_archive=ON, we may have two log
files open both during normal operation and when parsing the log. This
will store the other handle (old or new file).

log_sys.resize_buf: In the memory-mapped code path, this will point
to the file resize_log when innodb_log_archive=ON.

recv_sys.log_archive: All innodb_log_archive=ON files that will be
considered in recovery.

recv_sys.was_archive: A flag indicating that an innodb_log_archive=ON
file is in innodb_log_archive=OFF format.

log_sys.is_pmem, log_t::is_mmap_writeable(): A new predicate.
If is_mmap_writeable(), we assert and guarantee buf_size == capacity().

log_t::checkpoint_age_max(): Return the maximum checkpoint age.
When innodb_log_archive=ON the limit is innodb_log_file_size larger.

log_t::archive_new_write(): Create and allocate a new log file, and
write the outstanding data to both the current and the new file, or
only to the new file, until write_checkpoint() completes the first
checkpoint in the new file. If the log file would overflow,
increase innodb_log_file_size to the next multiple of 4096 bytes.

log_t::archive_create(bool): Create and allocate an archive log file.
On POSIX, ensure that we get the exact correct file size by invoking
ftruncate() on POSIX, because os_file_set_size() would only
truncate files on Microsoft Windows.  Remember the file handle
of the current log in resize_log, so that write_checkpoint() will be
able to make it read-only.

log_t::archived_mmap_switch_prepare(): Invoke archive_create() unless
another thread already did it.

log_t::archived_mmap_switch_complete(): Switch to the buffer that was
created in log_t::archived_mmap_switch_prepare(). Remember the old
log_sys.buf in log_sys.checkpoint_buf, to be unmapped in
log_t::write_checkpoint().

buf_flush_archive_create(): Create a spare archive log file if needed.

buf_flush_page_cleaner(): Invoke buf_flush_archive_create() about
one second after a checkpoint where we switched archived log files.
This allows any writer threads to resume activity after we completed
the previous checkpoint.

log_t::write_checkpoint(): Allow an old checkpoint to be completed in
the old log file even after a new one has been created. If we are
writing the first checkpoint in a new log file, we will mark the old
log file read-only. We will also update log_sys.first_lsn unless it
was already updated in ARCHIVED_MMAP code path. In that code path,
there is the special case where log_sys.resize_buf == nullptr and
log_sys.checkpoint_buf points to log_sys.resize_log (the old log file
that is about to be made read-only). In this case, log_sys.first_lsn
will already point to the start of the current log_sys.log, even
though the switch has not been fully completed yet.
Try to preallocate the next archive file if needed, with the goal that
when we need the file it will already be ready for use.

log_t::write_checkpoint(), log_checkpoint_low(), log_checkpoint(),
buf_flush_sync_for_checkpoint(): Return the LSN on which to invoke
archive_create(), or 0 if no spare archive log file needs to be created.

log_t::header_rewrite(my_bool): Rewrite the log file header before or
after renaming the log file, and write a message about the change,
so that there will be a chance to recover in case the server is being
killed during this operation.  The recovery of the last ib_%016%.log
does tolerate also the ib_logfile0 format.

log_t::set_archive(my_bool,THD): Implement SET GLOBAL innodb_log_archive.
An error will be returned if non-archived SET GLOBAL innodb_log_file_size
(log file resizing) is in progress. Wait for checkpoint if necessary.
The current log file will be renamed to either ib_logfile0 or
ib_%016x.log, as appropriate. In SET GLOBAL innodb_log_archive=OFF,
we trigger a write-ahead of the log if necessary, to prevent overrun.

log_t::archive_rename(): Rename an archived log to ib_logfile0 on recovery
in case there had been a crash during set_archive().

log_t::archive_set_size(): A new function, to ensure that
log_sys.resize_target is set on startup.

log_checkpoint_low(): Do not prevent a checkpoint at the start of a file.
We want the first innodb_log_archive=ON file to start with a checkpoint.

log_t::create(lsn_t): Initialize last_checkpoint_lsn. Initialize the
log header as specified by log_sys.archive (innodb_log_archive).

log_write_buf(): Add the parameter max_length, the file wrap limit.

log_write_up_to(), mtr_t::commit_log_release<bool mmap=true>():
If we are switching log files, invoke buf_flush_ahead(lsn, false)
to ensure that a log checkpoint will be completed in the new file.

mtr_t::finish_writer(): Specialize for innodb_log_archive=ON.

mtr_t::commit_file(): Ensure that log archive rotation will complete.

log_t::append_prepare<log_t::ARCHIVED_MMAP>(): Special case.

log_t::append_prepare(): Remove the call to set_check_for_checkpoint()
that was duplicating logic in log_close().

log_t::get_path(): Get the name of the current log file.

log_t::get_circular_path(size_t): Get the path name of a circular file.
Replaces get_log_file_path().

log_t::get_archive_path(lsn_t): Return a name of an archived log file.

log_t::append_archive_name(): Append the archive log file name
to a path string.

log_t::checkpoint_margin(): Replaces log_checkpoint_margin().
If a new archived log file has been created, wait for the
first checkpoint in that file. Revise the formula when
log_sys.need_checkpoint needs to hold. When innodb_log_archive=ON,
we can allow the checkpoint to be older by innodb_log_file_size.

log_close(): Relax the log_sys.need_checkpoint condition
for innodb_log_archive=ON.

srv_log_rebuild_if_needed(): Never rebuild if innodb_log_archive=ON.
The setting innodb_log_file_size will affect the creation of
subsequent log files. The parameter innodb_encrypt_log cannot be
changed while the log is in the innodb_log_archive=ON format.

log_t::attach(), log_mmap(): Add the parameter log_access,
to distinguish memory-mapped or read-only access.

log_t::attach(): When disabling innodb_log_file_mmap, read
checkpoint_buf from the last innodb_log_archive=ON file.

log_t::clear_mmap(): Clear the tail of the checkpoint buffer
if is_mmap_writeable().

log_t::set_recovered(): Invoke clear_mmap(), and restore the
log buffer to the correct position.

recv_sys_t::apply(): Let log_t::clear_mmap() enable log writes.

log_file_is_zero(): Check if a log file starts with NUL bytes
(is a preallocated file).

recv_sys_t::find_checkpoint(): Find and remember the checkpoint position
in the last file when innodb_log_recovery_start points to an older file.
When innodb_log_file_mmap=OFF, restore log_sys.checkpoint_buf from
the latest log file. If the last archive log file is actually
in innodb_log_archive=OFF format despite being named ib_%016.log,
try to recover it in that format. If the circular ib_logfile0 is missing,
determine the oldest archived log file with contiguous LSN.
If innodb_log_archive=ON, refuse to start if ib_logfile0 exists.
Open non-last non-preallocated archived log file in read/write mode.

recv_sys_t::find_checkpoint_archived(): Validate each checkpoint in
the current file header, and by default aim to recover from the last
valid one. Terminate the search if the last validated checkpoint
spanned two files. If innodb_log_recovery_start has been specified,
attempt to validate it even if there is no such information stored
in the checkpoint header.

log_parse_file(): Do not invoke fil_name_process() during
recv_sys_t::find_checkpoint_archived(), when we tolerate FILE_MODIFY
records while looking for a FILE_CHECKPOINT record.

recv_scan_log(): Invoke log_t::archived_switch_recovery() upon
reaching the end of the current archived log file.

log_t::archived_switch_recovery_prepare(): Make use of
recv_sys.log_archive and open all but the last file read-only.

log_t::archived_switch_recovery(): Switch files in the pread() code path.

log_t::archived_mmap_switch_recovery_complete(): Switch files in the
memory-mapped code path.

recv_warp: A pointer wrapper for memory-mapped parsing that spans two
archive log files.

recv_sys_t::parse_mmap(): Use recv_warp for innodb_log_archive=ON.

recv_sys_t::parse(): Tweak some logic for innodb_log_archive=ON.

log_t::set_recovered_checkpoint(): Set the checkpoint on recovery.
Updates also the end_lsn.

log_t::set_recovered_lsn(): Also update flush_lock and write_lock,
to ensure that log_write_up_to() will be a no-op. Invoke
unstash_archive_file() in case there was a garbage (pre-allocated)
file at the end which was not parsed at all.

log_t::persist(): Even if the flushed_to_disk_lsn does not change,
we may want to reset the write_lsn_offset.
Alexandru Diaconu
MDEV-38791 TO_DATE() allows duplicate format specifiers

The Oracle-mode TO_DATE() function incorrectly parsed strings containing
conflicting format specifiers within the Day-name family (e.g., 'DAY DY')
without throwing an ER_STD_INVALID_ARGUMENT error.

This patch completes the existing validation framework for family-based
conflict checks in item_timefunc.cc during format string parsing.
Specifically, it adds formats_used() checks for FMT_DAY, ensuring that
specifiers within the Day-name family strictly block each other. This
aligns the Day-name handling with the already existing checks for the
Year, Month, Hour, and Meridian families.

Compatible specifiers, such as YYYY and DDD (Year and Day of Year),
remain unaffected and parse successfully. A comprehensive MTR test
suite has been added to func_to_date.test to cover standard and
edge-case conflicts.

Reported-by: Elena Stepanova <elenastepanova@github>

Signed-off-by: Alexandru Diaconu <[email protected]>
Marko Mäkelä
Merge 10.6 into 10.11
Aleksey Midenkov
MDEV-25365 More query cache debug trace

Usage:

mtr --mysqld=--debug=d,qcache,query:i:O,/tmp/qcache_full.log
sed -nre '/(move_by_type|dispatch_command|pack_cache)/ p' \
    < /tmp/qcache_full.log \
    > /tmp/qcache.log
forkfun
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.
Marko Mäkelä
Merge 11.4 into 11.8
Jan Lindström
MDEV-38917 : Galera test failure on galera.galera_sst_mysqldump

This regression is caused by commit c380e165973 (MDEV-38833 "Suboptimal
or dead code at server startup"). Problem is that there should never
be an expectation that InnoDB bootstrap is crash-safe. Therefore,
after wsrep has initialized wsrep schema force checkpoint. This
ensured that InnoDB has successfully bootstrapped and wsrep chema
is initialized. This checkpoint ensures that wsrep-recover
is successful.

Other changes:
* Splitted galera_sst_mysqldump to two parts wsrep_sst_mysqldump
  and wsrep_sst_mysqldump_debug that is run only on debug builds.
* Changed wserp_schema initialization not to use std::string
  because it is unnecessary.
* Force checkpoint after wsrep_schema has been created.
* Make test wsrep_sst_mysqldump_with_key smaller
* Stabilize test cases
PranavKTiwari
MDEV-38839: Fix assertion in close_thread_tables on CREATE TABLE...SELECT FOR UPDATE with MyISAM temp table in MIXED binlog mode

Cause: FOR UPDATE on MyISAM temp tables uses a write lock (no row-level locking), incorrectly marking a read as a write. This blocks binlog_truncate_trx_cache() and triggers an assertion.

Fix: In decide_logging_format(), check tbl->updating to detect real writes. For read-only access, mark as STMT_READS_TEMP_NON_TRANS_TABLE instead of write, preventing incorrect behavior.
forkfun
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.
Aleksey Midenkov
Compilation: writing to an object of type ‘ORDER’

/home/buildbot/amd64-last-N-failed/build/sql/sql_window.cc: In function ‘ORDER* concat_order_lists(MEM_ROOT*, ORDER*, ORDER*)’:
/home/buildbot/amd64-last-N-failed/build/sql/sql_window.cc:2976:13: error: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘ORDER’ {aka ‘struct st_order’} with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Werror=class-memaccess]
2976 |      memcpy(copy, cur, sizeof(ORDER));
      |      ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/buildbot/amd64-last-N-failed/build/sql/field.h:29,
                from /home/buildbot/amd64-last-N-failed/build/sql/sql_class.h:32,
                from /home/buildbot/amd64-last-N-failed/build/sql/sql_acl.h:21,
                from /home/buildbot/amd64-last-N-failed/build/sql/sql_parse.h:19,
                from /home/buildbot/amd64-last-N-failed/build/sql/sql_window.cc:18:
/home/buildbot/amd64-last-N-failed/build/sql/table.h:236:16: note: ‘ORDER’ {aka ‘struct st_order’} declared here
  236 | typedef struct st_order {
      |                ^~~~~~~~
/home/buildbot/amd64-last-N-failed/build/sql/sql_window.cc: In member function ‘bool Window_funcs_sort::setup(THD*, SQL_SELECT*, List_iterator<Item_window_func>&, JOIN_TAB*)’:
/home/buildbot/amd64-last-N-failed/build/sql/sql_window.cc:3151:11: error: ‘void* memset(void*, int, size_t)’ clearing an object of type ‘ORDER’ {aka ‘struct st_order’} with no trivial copy-assignment; use assignment or value-initialization instead [-Werror=class-memaccess]
3151 |    memset(order, 0, sizeof(*order));
      |    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/buildbot/amd64-last-N-failed/build/sql/field.h:29,
                from /home/buildbot/amd64-last-N-failed/build/sql/sql_class.h:32,
                from /home/buildbot/amd64-last-N-failed/build/sql/sql_acl.h:21,
                from /home/buildbot/amd64-last-N-failed/build/sql/sql_parse.h:19,
                from /home/buildbot/amd64-last-N-failed/build/sql/sql_window.cc:18:
/home/buildbot/amd64-last-N-failed/build/sql/table.h:236:16: note: ‘ORDER’ {aka ‘struct st_order’} declared here
  236 | typedef struct st_order {
      |                ^~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [sql/CMakeFiles/sql.dir/build.make:2640: sql/CMakeFiles/sql.dir/sql_window.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:10639: sql/CMakeFiles/sql.dir/all] Error 2
make: *** [Makefile:166: all] Error 2