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

3265 Commits

Author SHA1 Message Date
Marko Mäkelä
84a39c73e3 Merge 13.1 into main 2026-09-10 09:07:23 +03:00
Alexander Barkov
bfabe0e530 MDEV-39518 Allow prepared statements in stored functions in assignment right hand
Allowing prepared statements in stored functions when
a stored function is used in an assignment right hand.

Both DEFAULT clause of a variable initialization and
the right side of the SET statement are supported:

  CREATE PROCEDURE p1()
  BEGIN
    -- case 1: DEFAULT clause
    DECLARE spvar1 INT DEFAULT f1_with_ps(); -- OK

    -- case 2: SP variable assignment statement
    DECLARE spvar2 INT;
    SET spvar2= f1_with_ps(); -- OK
  END;

- Only assignments to SP variables works for now:
  * SET spvar= func_with_ps(); -- OK
  * SET @uvar= func_with_ps(); -- Error

- Only bare function calls are supported for now. Using a function in
  an expression does not make it PS-safe yet:
    SET v= f1()+0;

- The parser now does not reject PS statements in stored functions.
  PS applicability in stored functions is now detected at run time.
  Note, PS statements in triggers are still prohibited by the parser.

- Functions with PS do not acquire MDL locks on tables, and no MDL is
  taken on the routines themselves either. They work like procedures in
  terms of table opening and routine locking: a concurrent DROP FUNCTION
  can complete while such a function is executing.

- Functions with PS are not replicated as a single `SELECT f1()` call.
  They are replicated per-statement, like procedures.

Helper changes:
- Changing the return result for LEX::sp_variable_declarations_init()
  from void to bool to catch errors in the caller properly.

Misc:
- This patch incorporates fixes for the following bugs found during debugging:
  MDEV-40224,MDEV-40225,MDEV-40226,MDEV-40227,MDEV-40240,
  MDEV-40285,MDEV-40288,MDEV-40315,MDEV-40318,MDEV-40890,MDEV-40900,
  MDEV-40901,MDEV-40913,MDEV-40914,MDEV-41013,MDEV-41015,MDEV-41019

Assisted-by: Claude - reviews and minor clean-ups
2026-09-08 08:12:46 +04:00
Oleksandr Byelkin
b140f801e6 Merge branch '13.0' into 13.1 2026-09-04 12:21:02 +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
Sergei Petrunia
6f9e2e6509 Renames: record/infuse functions to match the target function name 2026-08-12 14:31:56 +03:00
bsrikanth-mariadb
85595ce69c MDEV-36523: Load basic stats from trace into optimizer
This task loads the stats of the tables that are used in a query,
from the trace into the optimizer. This feature is controlled
by optimizer_replay_context, and points to an user defined variable name,
that has the context information.
The stats such as num_of_records present in the table, indexes if present,
their names, along with the average number of records_per_key
with in each index, cost of reading an index are loaded from the trace.
Additionally, stats from range analysis i.e. ranges, and the
corresponding number of records, along with their costs are also
loaded from the trace.

The trace context which is in JSON format is firstly set into the
user defined session variable, and this variable name is set to
optimizer_replay_context system variable.
Later, when a user issues a query, the contents of the json context is
parsed and an in memory representation is built using the class
Optimizer_context_replay. This class is then used by the optimizer
to update and save original values of the tables, indexes, and range stats
in the methods "set_statistics_for_table()" of sql_statistics.cc, and
"check_quick_select()" of opt_range.cc.
After the query gets finished, the statistics that were updated
in the optimizer are restored back to the saved original values.

The entry point for parsing the json structure is in
"mysql_execute_command()" of sql_parse.cc, and similarly exit point
i.e. to restore the saved stats of the optimizer is at the end
of the same method.

Two new warning/error messages are introduced:
ER_JSON_OPTIMIZER_REPLAY_CONTEXT_PARSE_FAILED, and
ER_JSON_OPTIMIZER_REPLAY_CONTEXT_MATCH_FAILED
2026-08-12 14:31:52 +03:00
Yuchen Pei
5a3d98a36c MDEV-24813 Signal full scan to storage engines.
When starting to do a full table/index scan without a WHERE or JOIN
condition, tell the storage engine so and the corresponding
ulong-truncated LIMIT.

Include an innodb implementation: added an innodb switch
table_lock_on_full_scan, so that when the switch is on, on receiving
the full scan signal from the sql layer, if the truncated LIMIT is
ULONG_MAX (likely no LIMIT), attempt to acquire a table lock.

Updated tests that have different results with the switch on.

The three deadlock_*_race tests cannot reach their DEBUG_SYNC race
under a table lock (it degenerates to a timeout), and the three I_S
tests only restate a lock-mode change already covered
by innodb_full_scan.test.

(Comment and code edited by Sergei Petrunia <sergey@mariadb.com> and
Thirunarayanan Balathandayuthapani <thiru@mariadb.com>)
2026-08-11 11:32:01 +10:00
Alexey Yurchenko
aba2caa893 MDEV-40179 Found N prepared transactions after mariabackup SST
With log_bin=ON a transaction is committed via two-phase commit (the
binary log is the second participant), so it passes through the InnoDB
XA-prepare state. While a donor is held in BLOCK_COMMIT for a mariabackup
backup, its parallel appliers (wsrep_slave_threads > 1) leave one or more
such writesets prepared-but-not-yet-committed, and the snapshot captures
them. On a freshly SST'd joiner nothing resolves these prepared
transactions: binlog crash recovery does not run (the joiner has no in-use
binlog to recover from), and the wsrep continuity-based commit is inactive
because wsrep_emulate_bin_log is FALSE when log_bin is ON. The leftover
prepared transactions then abort startup with "Found <N> prepared
transactions!". Note this does not depend on the prepared set being
non-contiguous - even a contiguous run aborts, because nothing commits
or rolls it back.

Rollback these transactions in xarecover_handlerton(). If rollback fails
flag error to cause unireg_abort().
2026-08-10 08:04:50 +03:00
Alexey Yurchenko
5785e9cbc2 MDEV-38147 error 1950 after mariabackup SST with gtid_strict_mode=ON
After a mariabackup SST the joiner could fail with

  ER_GTID_STRICT_OUT_OF_ORDER (error 1950)

while re-binlogging transactions received over IST.

The cause is that the binary log copied from the donor carries a
Gtid_list whose position can be ahead of the storage-engine snapshot
because getting snapshot and binlog are no mutually atomic, so transactions
can be present in the copied binlog that are not committed in the copied
engine snapshot.
After the SST the joiner reports the (committed) engine position to the
cluster, IST resends those transactions, and re-binlogging them under
gtid_strict_mode=ON collides with the ahead Gtid_list -> error 1950.
(MDEV-34483 made the engine snapshot stop short of the binlog, which is
what exposed this.)

The copied binary log carries no transactions the joiner needs - only a
Gtid_list - so instead of shipping and then having to truncate/reconcile
it, the joiner now starts a fresh binary log and seeds its GTID position
from the storage-engine checkpoint during recovery. That checkpoint is
the committed cluster position, i.e. exactly where IST resumes, so the
joiner's binary log stays in lockstep with the rest of the cluster and
no out-of-order GTID can occur.

This works for both wsrep_gtid_mode settings; only the binlog domain of
the cluster stream differs:

  - wsrep_gtid_mode=ON : wsrep_gtid_domain_id (cluster writes are
    re-tagged to it), which is the domain stored in the checkpoint;
  - wsrep_gtid_mode=OFF: gtid_domain_id (cluster writes keep the node's
    configured domain).

Async-replica positions (mysql.gtid_slave_pos) are part of the engine
snapshot and survive the SST unchanged, so a Galera node can still serve
as an async master or replica across the SST.

This commit:
 - sql/log.cc: adds wsrep_seed_binlog_gtid_state(), called from
   do_binlog_recovery() when the joiner has no binary log, seeding the
   binlog GTID state for the cluster domain to the SE checkpoint position.
 - scripts/wsrep_sst_mariabackup.sh: no longer moves the donor's binary
   log into place on the joiner.
 - extra/mariabackup: backward compatibility: keep shipping binlog file
   in SST but
   - on donor fix the race between rotation and shipping so that the file
     shipped is the one that had been rotated;
   - on joiner discard shipped binlog in favour of one generated by
     wsrep_seed_binlog_gtid_state().
 - sql/wsrep_sst.cc: logs the position actually adopted from storage
   (the authoritative post-SST position) rather than the script-reported
   one.
 - sql/handler.cc: downgrades the "Discovered discontinuity in recovered
   wsrep transaction XIDs" message in wsrep_order_and_check_continuity()
   from warning to debug level. With parallel appliers a snapshot
   routinely captures prepared XIDs that are not contiguous with the
   engine checkpoint, so this is normal during SST recovery and of no
   value in regular operation; the transactions past the checkpoint are
   re-delivered by the cluster (IST/SST) regardless.
 - Adds an MDEV-38147 MTR test reproducing the issue.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-10 08:04:50 +03:00
forkfun
b8dbc264f0 Merge branch '13.0' into 'main' 2026-08-03 13:42:39 +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
Yuchen Pei
323625512a MDEV-37739 Move filename canonicalisation out of handlerton method to ha_delete_table
Just like when creating a table, the name canonicalisation happens in
ha_create_table.

This still allows table name canonicalisation to still take place
normally (e.g. in a DROP TABLE statement), but also fixes call the
handlerton method to drop partitions from DDL recovery, as for files
corresponding to partitions, in the format of
<table_name>#P#<partition_name>, consistently only table names are
canonicalised. For example in ha_partition::drop_partitions, first the
table name is canonicalised, before the #P#<partition_name> part is
appended, and the full name is passed to file->delete_table.

Strengthen some previous failing testcases to show that partition
names don't get lowered.
2026-07-03 17:15:43 +10:00
Thirunarayanan Balathandayuthapani
666b2aca09 MDEV-38842 Server fails to drop .ibd file when vector table creation fails
Problem:
========
When creating tables with vector indexes, if the secondary table
creation fails after the main table is successfully created,
the server was not properly cleaning up the main table's .ibd file.
Stale file exists because create_table_impl() always called
ddl_log_complete() on any error, which disables DDL log entries
instead of executing them for cleanup. The main table would be
left behind even though the overall CREATE TABLE operation failed.

Solution:
=========
ha_create_table(): Make it responsible for cleaning up
everything it created when it returns an error.
On failure of the high level index creation, drop the main
table and shadow table.
2026-07-03 11:28:35 +05:30
Bill Jin
f40ea8f4e6 MDEV-39548 Further cleanup of MDL_request boilerplate
- Change thd->backup_commit_lock from MDL_request* to MDL_ticket*,
  and convert related call sites in handler.cc, log.cc, sql_class.cc,
  and xa.cc to use MDL_ACQUIRE_LOCK.

- Convert reload_acl_and_cache() in sql_reload.cc, purge_master_logs()
  and reset_master() in sql_repl.cc to MDL_ACQUIRE_LOCK, holding the
  ticket in a local MDL_ticket* (these functions used a local
  MDL_request originally and should not touch thd->backup_commit_lock).

- Convert acquire_lock() in partition_info.cc to MDL_ACQUIRE_LOCK.

- Add MDL_REQUEST_LIST_ADD() helper for enqueuing lock requests into
  MDL_request_list, and convert call sites in sql_base.cc and sp.cc.

All new code of the whole pull request, including one or several files
that are either new files or modified ones, are contributed under the
BSD-new license. I am contributing on behalf of my employer Amazon Web
Services, Inc.
2026-06-05 13:15:49 +04:00
Monty
3f6214aa32 MDEV-37070 Implement table options to enable/disable features
Added ADAPTIVE_HASH_INDEX=DEFAULT|YES|NO table and index option to InnoDB.
The table and index options only have an effect if InnoDB adaptive hash
index feature is enabled.

- Having the ADAPTIVE_HASH_INDEX TABLE option set to NO will disable
  adaptive hash index for all indexes in the table that do not have
  the index option adaptive_hash_index=yes.
- Having the ADAPTIVE_HASH_INDEX TABLE option set to YES will enable the
  adaptive hash index for all indexes in the table that do not have
  the index option adaptive_hash_index=no.
- Using adaptive_hash_index=default deletes the old setting.
- One can also use OFF/ON as the options. This is to make it work similar
  as other existing options.
- innodb.adaptive_hash_index has been changed from a bool to an enum with
  values OFF, ON and IF_SPECIFIED. If IF_SPECIFIED is used, adaptive
  hash index is only used for tables and indexes that specify
  adaptive_hash_index=on.
- The following new options can be used to further optimize adaptive hash
  index for an index (default is unset/auto for all of them):
   - complete_fields:
     - 0 to the number of columns the key is defined on (max 64)
   - bytes_from_incomplete_field:
     - This is only usable for memcmp()-comparable index fields, such as
       VARBINARY or INT. For example, a 3-byte prefix on an INT will
       return an identical hash value for 0‥255, another one for 256‥511,
       and so on.
     - Range is min 0 max 16383.
   - for_equal_hash_point_to_last_record:
     - Default is unset/auto, NO points to the first record, known as
       left_side in the code; YES points to the last record.
       Example: we have an INT column with the values 1,4,10 and bytes=3,
       will that hash value point to the record 1 or the record 10?
       Note: all values will necessarily have the same hash value
       computed on the big-endian byte prefix 0x800000, for all of the
       values 0x80000001, 0x80000004, 0x8000000a. InnoDB inverts the
       sign bit in order to have memcmp()-compatible comparison.

Example:
CREATE TABLE t1 (a int primary key, b varchar(100), c int,
index (b) adaptive_hash_index=no, index (c))
engine=innodb, adaptive_hash_index=yes;

Notable changes in InnoDB
- btr_search.enabled was changed from a bool to a ulong enum to be
  able to handle options OFF, ON and IF_SPECIFIED. ulong is needed
  to compile with MariaDB enum variables.
- To be able to find all instances where btr_search.enabled was used
  I changed all code to use btr_search.get_enabled() when accessing
  the value and used btr_search.is_enabled(index) to test if AHI is
  enabled for the index.
- btr_search.enable() was changed to always take two parameters,
  resize and value of enabled. This was needed as enabled can now
  have values OFF (0), ON (1), and IF_SPECIFIED (2).
- store all AHI-related options in per-index dict_index_t::ahi
  bit-packed 32-bit atomic field dict_index_t::ahi::enabled_fixed_mask
  - static assertions and debug assertions ensure that all options fit
    into the 32-bit field
  - packing details:
    - enabled, adaptive_hash_index (first 2 bits)
    - fields, complete_fields (7 bits)
    - bytes, bytes_from_incomplete_field (14 bits)
    - left, ~for_equal_hash_point_to_last_record (1 bit)
    - have_fields, fields set flag (1 bit)
    - have_bytes, bytes set flag (1 bit)
    - have_left, left set flag (last 1 bit)
    - 5 bits spare after have_left
  - manipulation of the bit-packed field avoids usage of branches or
    conditional instructions to minimize the performance impact of
    the new options
- in btr_search_update_hash_ref() apply the per-index AHI options
  using bit-masking to override internal heuristic values with user
  preferences
- add innodb.index_ahi_option test:
  - test a combination of per-table and per-index AHI options
  - use a stored procedure which checks if AHI is used during a burst of
    index lookups checking delta in adaptive_hash_searches InnoDB
    monitor variable
  - test that the maximum number of fields per (secondary) index is 64
    (32 PK + 32 secondary key columns)
  - test that crash recovery retains table/index metadata
  - test AHI with partitioned tables
  - verify that changing AHI preferences for table/index is instant DDL
  - boundary checks for complete_fields and bytes_from_incomplete_field
- add innodb.index_ahi_option_debug test:
  - test debug builds with index_ahi_option_debug_check debug variable
    enabled to verify that the proper per-index AHI options are applied
    during index lookups
  - test that "illegal" per-index AHI options are non-destructive and
    just lead to automatic parameter clamping and possibly no AHI usage
  - test toggling global AHI status with concurrent AHI access

Visible user changes:
- select @@global.adaptive_hash_index will now return a string instead
  of 0 or 1.

Other notable changes:
- In sql/create_options.cc:
  - In function set_one_value() avoid reading after the end of the
    current string.

Co-authored-by: Monty <monty@mariadb.org>
Co-authored-by: Marko Mäkelä <marko.makela@mariadb.com>
Co-authored-by: Alessandro Vetere <iminelink@gmail.com>
Co-authored-by: Thirunarayanan Balathandayuthapani <thiru@mariadb.com>
2026-05-28 14:59:14 +02:00
Oleksandr Byelkin
d195db57ff Merge branch '13.0' 2026-05-27 12:49:36 +02:00
Oleksandr Byelkin
9f98f82b14 Merge branch '11.8' into 12.3 2026-05-26 21:15:58 +02:00
Bill Jin
5a9af15a2c MDEV-39548 Cleanup MDL_request boilerplate with ACQUIRE_LOCK macro
Add new acquire_lock() overloads on MDL_context that combine MDL_request
initialization and lock acquisition into a single call, returning
MDL_ticket* directly. Convert applicable call sites across the codebase
to use the new ACQUIRE_LOCK macro.

All new code of the whole pull request, including one or several files
that are either new files or modified ones, are contributed under the
BSD-new license. I am contributing on behalf of my employer Amazon Web
Services, Inc.
2026-05-26 20:00:43 +04:00
Oleksandr Byelkin
f572addcc1 Merge branch '12.3' into 13.0 2026-05-22 09:52:05 +02:00
Oleksandr Byelkin
3f388a1cce Merge branch '11.8' into 12.3 2026-05-22 09:27:18 +02:00
a18792721831
69a8a1222b MDEV-33814 Wrong error message "Can't create table" on "ALTER TABLE"
When ALTER TABLE uses the copy algorithm, ha_create_table() is
invoked to build the shadow table. A failure there was previously
reported as "Can't create table", which is misleading because the
user never issued a CREATE.

Fix (per review by @midenok): keep errno 1005 / SQLSTATE HY000
unchanged and only swap the message text when HA_CREATE_TMP_ALTER
is set, via a new translatable template ER_CANT_CREATE_TMP_ALTER_TABLE
in errmsg-utf8.txt (no SQLSTATE clause -- it is a message template
rather than a wire error code).

The user-visible error becomes:

  ERROR 1005 (HY000): Can't create temporary table for ALTER TABLE \
    `db`.`tbl` (errno: N "...")

No existing error handler, stored procedure, tool, or application
that matches on errno 1005 or SQLSTATE HY000 is affected.

Notes on the 12.3 rebase:
 * In 12.3 the ER_CANT_CREATE_TABLE reporting logic has been moved
   from ha_create_table() into its new helper ha_create_table_from_share().
   The HA_CREATE_TMP_ALTER branch is added in the helper so that both
   the main shadow table and any high-level (vector) index sub-tables
   go through the same path. Vector index sub-tables use a zero-
   initialised index_cinfo, so HA_CREATE_TMP_ALTER is never set for
   them and they still get the plain "Can't create table" message.

Review follow-ups (Round 6, @midenok):
 * Moved the test content from suite/innodb/t/alter_table_error_message.test
   into main/alter_table.test (no duplicate --include directives);
   dropped the extra .test/.result files accordingly.
 * Added the standard "End of 12.3 tests" section marker at the end.
 * Removed the unnecessary DROP TABLE IF EXISTS cluster_t; in the
   cleanup step (the test is deterministic, the table no longer
   exists at that point).

Review follow-ups (Round 7, test re-record + errmsg formatting):
 * Fixed ER_CANT_CREATE_TMP_ALTER_TABLE template to use the exact
   ER_CANT_CREATE_TABLE format specifiers, so error frames produced
   by my_error() are byte-identical to the existing error (only the
   fixed prefix changes).
 * Re-recorded innodb.innodb-index.result and innodb.foreign_key.result
   which now observe the new "Can't create temporary table for ALTER
   TABLE" message in ALTER TABLE error paths that used to print
   "Can't create table".
 * No code changes outside of the intentional message swap; all other
   .result files remain untouched.

Review follow-ups (Round 8, additional test re-record from CI):
 * Re-recorded innodb.table_flags.result for the MDEV-38079 scenario
   (ALTER TABLE t1 PAGE_COMPRESSED=1, ALGORITHM=COPY under
   INNODB_DEFAULT_ROW_FORMAT=REDUNDANT) -- this ALTER path now reports
   the new "Can't create temporary table for ALTER TABLE" message.
   Verified on all 10 page size / checksum combinations (4k/8k/16k/
   32k/64k x strict_crc32/strict_full_crc32).
 * Re-recorded parts.engine_defined_part_attributes.result for the
   ALTER TABLE `t4` PARTITION BY RANGE(...) ENCRYPTED path. The four
   remaining "Can't create table" occurrences in the same file refer
   to pure CREATE TABLE failures and correctly retain the original
   message.
 * No code or test-case logic changes; only .result re-recordings.

Signed-off-by: a18792721831 <735809899@qq.com>
CLA: a18792721831 <735809899@qq.com>
2026-05-05 11:33:38 +03:00
Yuchen Pei
3a7f7ce521 Merge branch '11.4' into 11.8 2026-04-20 13:16:55 +10:00
SAY-5
80a11062e2 fix occured typo in handler.cc
Signed-off-by: SAY-5 <SAY-5@users.noreply.github.com>
2026-04-17 09:31:38 +10:00
Thirunarayanan Balathandayuthapani
9f00ff0f58 MDEV-39081 InnoDB: tried to purge non-delete-marked record, assertion fails in row_purge_del_mark_error
Reason:
=======
Following the changes in MDEV-38734, the server no longer marks
all indexed virtual columns during an UPDATE operation.
Consequently, ha_innobase::update() populates the upd_t vector
with old_vrow but omits the actual data for these virtual columns.

Despite this omission, trx_undo_page_report_modify() continues to
write metadata for indexed virtual columns into the undo log. Because
the actual values are missing from the update vector, the undo log
entry is recorded without the historical data for these columns.

When the purge thread processes the undo log to reconstruct a
previous record state for MVCC, it identifies an indexed virtual
column but finds no associated data.

The purge thread incorrectly interprets this missing data as a NULL
value, rather than a "missing/unrecorded" value. The historical
record is reconstructed with an incorrect NULL for the virtual column.
This causes the purge thread to incorrectly identify and purge
records that are not actually delete-marked, leading to abort
of server.

Solution:
=========
ha_innobase::column_bitmaps_signal(): Revert the column-marking
logic to the state prior to commit a4e4a56720, ensuring all
indexed virtual columns are unconditionally marked during an UPDATE.

The previous "optimization" attempted to manually detect indexed
column changes before marking virtual columns. The manual check
for indexed column modifications is redundant. InnoDB already
provides the UPD_NODE_NO_ORD_CHANGE flag within row_upd_step().
This flag is being used in trx_undo_page_report_modify() and
trx_undo_read_undo_rec() should log or read virtual column values.

Refactored column_bitmaps_signal() to accept a mark_for_update
parameter that controls when indexed virtual columns are marked.
TABLE::mark_columns_needed_for_update() is the only place that needs
mark_for_update=true because only UPDATE operations need to mark
indexed virtual columns for InnoDB's undo logging mechanism.

INSERT operation is already handled by
TABLE::mark_virtual_columns_for_write(insert_fl=true).
Even the commit a4e4a56720 changes are
going to affect TABLE::mark_virtual_column_for_write(false) and
It is called during UPDATE operation, and that's when
column_bitmaps_signal() needs to mark  indexed virtual columns.

Online DDL has separate code path which is handled by
row_log_mark_virtual_cols() for all DML operations
2026-04-14 19:26:36 +05:30
Alexander Barkov
e581d1b5e0 MDEV-38436 Remove Type_handler::Column_definition_fix_attributes()
The method Type_handler::Column_definition_fix_attributes() was an
addition for Type_handler::Column_definition_set_attributes().

The code in virtual implementations of Column_definition_fix_attributes()
has now been joined to corresponding virtual implementations of
Column_definition_set_attributes().

After this change everything is done in Column_definition_set_attributes().

This makes the code clearer. Previous implementation was rather confusing.
For example, for temporal data types:
(1) After Column_definition_set_attributes():
  - Column_definition::length meant the fractional precision
  - Column_definition::decimals was set to 0
(2) After Column_definition_fix_attributes():
  - Column_definition::length means the full character length
  - Column_definition::decimals means the fractional precision

Now everything gets set to (2) right in Column_definition_set_attributes().
2026-04-06 15:00:16 +04:00
Marko Mäkelä
02aedc1065 Merge 11.8 into 12.3 2026-03-24 09:49:17 +02:00
Marko Mäkelä
e6b8cacfb9 Merge 11.4 into 11.8 2026-03-23 11:57:44 +02:00
Marko Mäkelä
f55deca2b2 Merge 10.11 into 11.4 2026-02-19 11:19:00 +02:00
Marko Mäkelä
8d15311b90 Merge 10.6 into 10.11 2026-02-19 09:46:55 +02:00
Thirunarayanan Balathandayuthapani
8882f8fe6c MDEV-37886 PAGE_COMPRESSED ALTER TABLE operations inconsistent with innodb_file_per_table setting
Problem:
=======
InnoDB DDL does ALTER TABLE PAGE_COMPRESSED=1 because:
1. check_if_supported_inplace_alter() reads srv_file_per_table
during precheck and does allow INSTANT operation.
2. User does change innodb_file_per_table later.
But prepare phase read srv_file_per_table again during execution.
3. If the global variable changed between these phases, causes
server abort for page_compressed tables.

Solution:
=========
- Add a file_per_table member to Alter_inplace_info to
capture the innodb_file_per_table value during the
precheck phase and use that consistent value throughout
the entire ALTER TABLE operation.
- Converted boolean flags (online, ignore, error_if_not_empty,
mdl_exclusive_after_prepare) from individual boolean
members to bitfields packed in a single byte
- Reduced Alter_inplace_info structure size by 24 bytes
2026-02-18 12:08:25 +05:30
Sergei Golubchik
79ad188d46 MDEV-37815 table engine attributes in partitioning is broken
remove copying of part_elem->option_struct to table->s->option_struct.
It meant that most of the time a handler had no access to its options
(that's why some handlers resorted to a complex process of guessing the
correct partition) and couldn't work concurrenty. Instead

* introduce handler::option_struct which will point to
  table->s->option_struct or part_elem->option_struct as appropriate,
  the handler can use it any time as needed. A handler should not use
  table->s->option_struct unless it really knows what it's doing and has
  verified that it doesn't break partitioning
* rename option_struct in table->s to option_struct_table and in
  part_elem to option_struct_part to emphasize it's semantics and
  prevent incorrect usage.
* fix engines accordingly.
2026-02-06 17:46:52 +01:00
Kristian Nielsen
7ea9e14ed2 Fix bad merge that broke Galera
Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2026-01-25 22:16:01 +01:00
Kristian Nielsen
7081f2a58e Binlog-in-engine: New binlog implementation integrated in InnoDB
Implement an improved binlog implementation that is integrated into
the storage engine. The new implementation is enabled with the
--binlog-storage-engine option. Initially the InnoDB storage engine
implements the binlog.

Integrating the binlog in the storage engine improves performance,
since it makes the InnoDB redo log the single source of truth and
avoids the need for expensive two-phase commit between binlog and
engine. It also makes it possible to disable durability (set
--innodb-flush-log-at-trx-commit=0) to further improve performance,
while still preserving the ability to recover the binlog and database
into a consistent state after a crash.

The new binlog implementation also greatly improves the internal
design and implementation of the binlog, and enables future
enhancements for replication.

This is a squash of the original 11.4-based patch series.

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2026-01-23 03:21:03 +01:00
Sergei Golubchik
27c98794bb Merge branch '11.8' into 12.2 2026-01-08 12:02:45 +01:00
Sergei Golubchik
c1fcedf443 Merge branch '11.4' into 11.8 2026-01-05 20:34:44 +01:00
Marko Mäkelä
678ff03ee7 Merge 10.11 into 11.4 2026-01-02 11:53:09 +02:00
Yuchen Pei
db26f446fd MDEV-35562 Do not emit warning when deleting .par file in quick_rm_table
...just like the when deleting the .frm file in the same function.
This improves consistency: internal duplicate deletion of .par file
and .frm file both fail silently.
2025-12-16 11:57:17 +11:00
Andrei Elkin
d613f03c20 MDEV-37541 Race of rolling back and committing transaction to binlog
Two transactions could binlog their completions in opposite to how it
is done in Engine. That is is rare situations ROLLBACK in Engine of
the dependency parent transaction could be scheduled by the
transaction before its binlogging. That give a follower dependency
child one get binlogged ahead of the parent.

For fixing this bug its necessary to ensure the binlogging phase is
always first one in the internal one-phase rollback protocol.

The commit combines
1. a code polishing piece over a part of MDEV-21117 that
   made binlog handlerton always commit first in no-2pc cases and
2. the same rule now applies to the rollback.

An added test demonstrates how the child could otherwise reach binlog
before its parent.
2025-12-02 17:16:02 +02:00
Andrei Elkin
22db2df60c Merge commit '2fd25d77f031f48f501344b5d77aeea62b42da88' into
bb-10.11-release with will be replace by 10.11 specific one.
2025-12-02 17:12:55 +02:00
Andrei Elkin
2fd25d77f0 MDEV-37541 Race of rolling back and committing transaction to binlog
Two transactions could binlog their completions in opposite to how it
is done in Engine. That is is rare situations ROLLBACK in Engine of
the dependency parent transaction could be scheduled by the
transaction before its binlogging. That give a follower dependency
child one get binlogged ahead of the parent.

For fixing this bug its necessary to ensure the binlogging phase is
always first one in the internal one-phase rollback protocol.

The commit makes sure the binlog handlerton always rollbacks as first
handlerton in no-2pc cases.

An added test demonstrates how the child could otherwise reach binlog
before its parent.
2025-11-27 19:34:19 +02:00
Oleksandr Byelkin
fd15fd2765 Merge branch 'bb-12.1-release' into bb-12.2-release 2025-11-06 07:29:30 +01:00
Oleksandr Byelkin
ba00960fda Merge branch 'bb-11.8-release' into bb-12.1-release 2025-11-05 08:58:12 +01:00
Sergei Golubchik
f230c0ff6e Merge branch '10.11' into 11.4 2025-11-04 13:44:16 +01:00
Sergei Golubchik
5ce9a03602 Merge branch '11.4' into 11.8 2025-11-04 12:39:27 +01:00
Sergei Golubchik
1093a2f3b8 Merge branch '10.11' into 11.4 2025-11-03 14:23:51 +01:00