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
bsrikanth-mariadb
MDEV-39433: Crash when recording context for a sequence query

With optimizer_record_context enabled, a simple query involving sequence
such as:

create sequence s1;
Explain select * from s1;

is crashing in store_optimizer_costs(). There are no costs associated
with sequence tables, and their fields, and hence when trying to access
cost information for them, a crash occurs.

Solution
========
Don't try to store stats or cost information for sequences
Monty
MDEV-40029 Add support for bit fields to HEAP

This adds support for BIT_FIELD in record and keys for HEAP tables.

The HEAP engine now has HA_CAN_BIT_FIELD set in table_flags()

Multiple bugs in BIT field handling was found fixed. Some in HEAP table
code, other bugs was affecting usage of BIT fields as keys.
Sergei Petrunia
Rename include/get_rec_idx_ranges_from_opt_ctx.inc, cleaner printouts

New name: include/opt_context_list_tables_and_ranges.inc
bsrikanth-mariadb
store index_name instead of index number everywhere in the context

Multi_range_read_const_call_record, and dump_mrr_info_calls()
already store index names. However, cost_index_read_call_record,
dump_index_read_calls() were using index numbers.

To be consistent, this PR changes index methods, and classes
to use index name instead of index number.
Sergei Petrunia
Renames: (record|infuse)multi_range_read_info_const
Sergei Petrunia
More include file renames.
bsrikanth-mariadb
Disable main.subselect_sj_mat testfile to be run in replay mode

loose scan semi-join strategy is using rec_per_key instead of
actual_rec_per_key to know the output number of rows. Disabling the
entire testfile, as several tests fail. The fix would be made as part of
MDEV-39942.
Sergei Golubchik
update test results
Rex Johnston
MDEV-39499 Updates to derived-with-keys, window functions determining

..records per key

Enabling derived keys optimization for derived.col = const pushed
conditions.

Estimating records per key in derived key for the optimizer
based on form and/or size of components of a derived table.

Consider any derived table of the form

SELECT ..., ROW_NUMBER ()  OVER (PARTITION BY c1,c2 order by ...)
FROM t1, t2, t3 ...
WHERE ...

If the optimizer generates a key on this derived table because of
a constraint being pushed into it, it currently will not consider key
components of the form  col = const

We lift this constraint and add code to TABLE::add_tmp_key to search
for a window function ROW_NUMBER().  From the partition list c1, c2 we
can in infer an estimate of the number of rows we expect to see for
each key value.  In the absence of EITS, we still have an number of
expected records in our referred to table and will fall back to using
that as a worst case scenario.

As a consequence of forcing best_access_path to now consider a generated
index's records per key on any type of derived table, we see a number of
optimization changes, for example a range optimizer might now be
considered best and might return IMPOSSIBLE_RANGE (seen in
rowid_filter_myisam.result).
Alexander Barkov
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 DEFALT 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 spvar= f1_with_ps(); -- OK
  END;

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

- Functions with PS do not acquire MDL locks on tables.
  They work like procedures in terms of table opening.

- Functions with PS are not replicated as a single `SELECT f1()` call.
  They are replicated per-statement, like procedures.
Sergei Petrunia
Rename list_ranges -> multi_range_read_info_const_calls
Sergei Petrunia
Revert the --replay-server mtr feature
Eric
MDEV-38144: update Optional_metadata_fields to use MariaDB types

Currently Optional_metadata_fields has many members that use classes
from the C++ standard library, most notably the use of std::vector and
std::string. This is inconsistent with the coding standards, as MariaDB
defines its own types for arrays/lists/strings. This patch updates
these variables to use existing MariaDB types.

Additionally, the structure of the fields is changed. Instead of having
a separate list to track each metadata field; the structure now exists
at the column level (Column_metadata), and it has individual member
variables to describe its metadata. This allows for more
straightforward memory management, as everything will now be allocated
at once.

There is also a bug fix in this patch. Prior to this refactor, YEAR
columns would not consume their "unsigned" bit flag, resulting in
numeric columns after a YEAR type to have incorrect signage. This is
now fixed.

Reviewed-by: Brandon Nesterenko <[email protected]>
Arcadiy Ivanov
Fix CI regressions from MDEV-38975 forward-port to main

Seven code fixes, a new test, and test re-recordings for issues found
by CI on PR #5222.

**NULL dereference in `create_tmp_field()`**: `SYS_REFCURSOR` plugin
returns NULL from `make_new_field()` (cursor values cannot be
materialized). The feature added `result->flags |= FIELD_PART_OF_TMP_UNIQUE`
without a NULL check. Added `if (result)` guard.

**xmltype identity loss and recursive CTE reclength mismatch in
`Item_type_holder::create_tmp_field_ex()`**: the blob_key dispatch now
requires both: (1) `type_handler_for_tmp_table()` returns
`blob_key_type_handler()`, AND (2) `dynamic_cast<Type_handler_blob_common*>`
confirms the original type is a native blob. Condition 1 excludes xmltype
(its override returns itself). Condition 2 excludes VARCHAR types promoted
via `varstring_type_handler()` -> `too_big_for_varchar()` ->
`blob_type_handler()`. Without condition 2, wide VARCHAR in recursive CTEs
(e.g. `cast('...' as varchar(1000))`) was promoted to `Field_blob_key` in
the main UNION DISTINCT table (`part_of_unique_key=true`) but stayed as
`Field_varchar` in the incremental table (`part_of_unique_key=false`),
causing a `reclength` mismatch assertion in
`select_union_recursive::send_data()` (`main.json_equals` crash).

**Spurious `reclength > HA_MAX_REC_LENGTH` in `pick_engine()`**: the
original `choose_engine()` (both 10.11 and upstream/main) never had a
reclength check. MDEV-38975 introduced it when replacing the
`blob_fields` condition. HEAP has no internal reclength limit --
`hp_create.c` stores `uint reclength` and allocates blocks of that size;
`max_supported_record_length()` is only checked in `unireg.cc` during
user-facing CREATE TABLE. I_S tables like SLAVE_STATUS routinely have
reclength ~880KB (13 bare `Varchar()` columns). The check forced them to
Aria where `fill_slave_status()` returned 0 rows. Removed the check and
the unused `reclength` parameter from `pick_engine()`.

**Multi-update `tmp_memory_table_size` override**: the 10.11 feature
overrode `big_tables=FALSE` for multi-update dedup tables. The forward-port
translated this as `tmp_memory_table_size=SIZE_T_MAX` when the variable
was 0. But `big_tables=FALSE` was a soft "don't force disk" hint, while
`tmp_memory_table_size=SIZE_T_MAX` overrides the user's explicit
`tmp_memory_table_size=0` directive. Since main removed `big_tables`
entirely (MDEV-19713), the override is not needed. Removed.

**Zero-length key rejection in `check_tmp_key()`**: reject `key_len == 0`
to prevent useless zero-length keys from being created by `add_tmp_key()`.
Reachable when all key parts are CHAR(0) NOT NULL: `key_length()` returns
0, the field is not nullable (no HA_KEY_NULL_LENGTH) and not
VARCHAR/BLOB/GEOMETRY (no HA_KEY_BLOB_LENGTH), so `fld_store_len` is 0
for every part. Without this guard, `check_tmp_key()` would accept the
key (0 <= max_key_length), and the optimizer would create a ref key that
cannot distinguish any rows. Added `heap.char0_key` test exercising this
via a materialized derived table with CHAR(0) NOT NULL join columns.

**Non-deterministic `column_compression` test**: HEAP blob support allows
compressed VARCHAR/TEXT temp tables to stay in HEAP instead of falling to
Aria, changing row iteration order. Added `--sorted_result` to the two
MDEV-24726 subqueries that lack `ORDER BY`.

Test changes:
- `spatial_utility_function_collect`: added ORDER BY to window function
  that lacked it (results were engine-row-order-dependent)
- `tmp_space_usage`: removed multi-update override; forced disk for
  MDEV-34016/34060 Aria-specific test sections (blob I_S tables now
  stay in MEMORY)
- `blob_update_overflow`: replaced `SHOW STATUS LIKE 'Created_tmp_%'`
  with targeted I_S query (Created_tmp_files varies on sanitizer builds)
- `column_compression`: added `--sorted_result` for MDEV-24726 queries
- `char0_key` (new): CHAR(0) NOT NULL derived table ref key rejection
- Re-recorded 8 tests for expected "temp table stays in MEMORY" changes
bsrikanth-mariadb
Don't enable ps protocol for a negative test in opt_context_store_ddls

context for the previous insert statement is being used for the new
query having a syntax error. This is happening now because, insert
statements are also able record contexts -
Done as part of commit 294165195824a9aae01130ff8525c04f0f49b122
Rex Johnston
MDEV-40012  start cleanup of claude's worker side multi-table join

Attached standalone functions to their obvious object, DBUG_ tracing in
functions that clearly need it, NOT FINISHED.

Looks to me like the buffering code where the worker has finished it's
part of the join and writes it's output in chunks doesn't work properly.
Probably not relevant as this whole buffering needs to be sidestepped.
Rucha Deodhar
MDEV-34723: NEW and OLD in a trigger as row variables

Implementation:
NEW and OLD represent the entire table row. So it can be thought of as
list of Item_trigger_field. When we are in a trigger and NEW or OLD is
encountered, create Item_trigger_row object with same constructor as
Item_trigger_field, it will also be used later while creating
Item_trigger_field objects. Populate the m_fields list while
fixing fields. Create a corresponding instruction sp_instr_set_trigger_row
which will be used to set the values
Alexander Barkov
MDEV-39022 Add `LOCAL spvar` syntax for prepared statements and SYS_REFCURSORs

This patch adds the following syntax:

OPEN c0 FOR LOCAL spvar_with_ps_name;
PREPARE LOCAL spvar_with_ps_name FROM 'dynamic sql';
EXECUTE LOCAL spvar_with_ps_name;
DEALLOCATE PREPARE LOCAL spvar_with_ps_name;

OPEN c0 FOR PREPARE stmt;
Abdelrahman Hedia
MDEV-28213 Skip ignored domain IDs during GTID validation

When a slave is configured with IGNORE_DOMAIN_IDS or DO_DOMAIN_IDS,
the master's binlog dump thread should skip GTID state validation for
those filtered domains. This avoids false ER_GTID_POSITION_NOT_FOUND
errors when the slave does not have (or need) the current GTID state
for domains it is filtering.

Before sending COM_BINLOG_DUMP, the slave now tells the master which
domains it filters by setting a user variable. Only one of
IGNORE_DOMAIN_IDS or DO_DOMAIN_IDS can be active at a time, so the slave
sends just the configured list through either
@slave_connect_state_domain_ids_ignore or
@slave_connect_state_domain_ids_do. The master parses the list into a
Domain_id_filter attached to the slave_connection_state and consults it
while locating the binlog file and validating the slave start position.

Using a user variable keeps this backwards compatible: an older master
simply stores the unknown variable and ignores it, and an older slave
never sends it (the filter stays NULL and every domain is validated as
before).

Changes:
- sql/slave.cc: in get_master_version_and_clock(), figure out which of
  IGNORE_DOMAIN_IDS / DO_DOMAIN_IDS is configured and send that single
  list to the master. Add build_domain_ids_query() to format the
  "SET @<var>='id1,id2,...'" statement.
- sql/sql_repl.cc: in init_binlog_sender(), read the slave's user
  variable (get_user_var_string()), lazily allocate a Domain_id_filter,
  parse the comma-separated ids (load_domain_ids_from_string()) and sort
  them. Skip filtered domains in contains_all_slave_gtid(),
  check_slave_start_position(), gtid_find_binlog_pos() and
  gtid_find_engine_pos(), and document the behaviour at
  gtid_check_binlog_file().
- sql/rpl_gtid.cc: skip filtered domains in
  rpl_binlog_state_base::is_before_pos(); initialise and delete the
  domain_filter in slave_connection_state's constructor/destructor.
- sql/rpl_gtid.h: add the Domain_id_filter *domain_filter member to
  slave_connection_state (under HAVE_REPLICATION).
- sql/rpl_mi.h, sql/rpl_mi.cc: add the Domain_id_filter::var_name_ignore
  and var_name_do user-variable name constants.
- include/rpl_gtid_base.h: forward-declare Domain_id_filter.
- mysql-test/suite/rpl/t/rpl_gtid_ignored_domain_ids_validation.test,
  mysql-test/suite/rpl/r/rpl_gtid_ignored_domain_ids_validation.result:
  new test covering IGNORE_DOMAIN_IDS and DO_DOMAIN_IDS with purged
  binlogs.

Reviewed-by: Georgi Kodinov <[email protected]>
Reviewed-by: Brandon Nesterenko <[email protected]>
Michal Schorm
MDEV-39169 Replace deprecated network functions in resolveip

Replace inet_aton/inet_addr/gethostbyname/gethostbyaddr with
their modern POSIX equivalents inet_pton/getaddrinfo/getnameinfo.
This adds IPv6 support to resolveip and removes dependency on the
deprecated h_errno global.

Handle IPv6 unspecified address (::) as Null-IP-Addr, consistent
with existing IPv4 INADDR_ANY handling for 0.0.0.0.

Add MTR test covering IPv4/IPv6 reverse lookups, special
addresses, multiple arguments, mixed address types, and
invalid hostname handling.

Co-Authored-By: Claude AI <[email protected]>
bsrikanth-mariadb
Disable a couple of main.cte_recursive tests when run in replay-server mode

They can be re-enabled after MDEV-39978 is resolved
Rex Johnston
MDEV-40012 Parallel Query: execute the join in the worker threads

Each parallel worker now runs the whole select-project[-join] query over
its own chunk of the driving table -- WHERE filtering, select-list
projection and the joins to the other tables -- and ships the final
result rows to the manager, which only concatenates them and sends them
to the client. This replaces the model where workers shipped raw source
records and the manager ran the join.

make_join_readinfo()'s gate (can_run_query_in_workers) chooses the
worker-side path for an inner select-project[-join] with a parallel-
scannable driving table: no tmp table (group/distinct/order/window/
buffer), no LIMIT/SQL_CALC_FOUND_ROWS/procedure/aggregate, no outer join
or semijoin, and every non-driving table reached by eq_ref/ref/full
scan. do_select() then runs run_worker_side_join() instead of the nested
loop; anything ineligible runs serially.

Each worker opens a private copy of every non-const table, deep-clones
and field-rebinds the conditions and select list, and rebuilds each ref
(clone_table_ref, mirroring create_ref_for_key). It scans its driving
chunk, runs its own inner nested loop (cp_buffer_from_ref +
ha_index_read_map / ha_index_next_same for ref/eq_ref, rnd scan
otherwise), projects each full match into a private result table and
ships the row image; the manager drains and sends.

A killed worker's own ER_QUERY_INTERRUPTED is no longer treated as a
fatal evaluation error (PWT_error_handler guards with !thd->killed) so
kills keep propagating through kill_signal with the correct kill type.

Tests: parallel_query_worker_side (single table) and parallel_query_join
(eq_ref, ref with fan-out, 3-table chain, full-scan inner table) compare
the parallel result set against serial. parallel_query / parallel_query_oom
moved to a plain SELECT (which now runs worker-side) and were re-recorded.

Co_Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Sergei Petrunia
Rename: list_index_read_costs -> cost_for_index_read_calls
Sergei Petrunia
Rename "list_contexts" to "tables"
Fariha Shaikh
MDEV-38936 Proactive handling of InnoDB tablespace full condition

InnoDB write failures occur when tablespace files exceed filesystem size
limits. Current behavior logs errors but continues accepting
transactions, causing repeated failures and potential data integrity
issues.

Add proactive monitoring by emitting warnings when InnoDB tablespaces
approach a configurable size threshold.

Key features:
- Two new system variables:
  * innodb_tablespace_size_warning_threshold (default 0, disabled):
    Maximum tablespace size in bytes before warnings begin
  * innodb_tablespace_size_warning_pct (default 85%): Percentage of
    threshold at which to start emitting warnings
- Warning frequency:
  * Below warning_pct: No warnings
  * At or above warning_pct: Every 1% increase (85%, 86%, 87%, etc.)
- Per-tablespace tracking with automatic reset on TRUNCATE/DROP or
  threshold/percentage changes
- Zero overhead when threshold is 0
- Progressive warnings capped at 100%

Implementation adds fil_space_t::extend() which consolidates file
extension, size_in_header update, and size warning checks.
Per-tablespace warning state is tracked in fil_space_t
(m_last_size_warning_pct, m_last_warning_threshold, m_last_warning_pct).

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.
Arcadiy Ivanov
MDEV-38975: HEAP engine BLOB/TEXT/JSON/GEOMETRY support with indexable blob columns

Remove the HA_NO_BLOBS restriction from the HEAP engine, allowing
the optimizer to keep temporary tables with BLOB/TEXT columns in
memory when they fit within max_heap_table_size / tmp_memory_table_size
limits.  Additionally, advertise HA_CAN_GEOMETRY so explicit
CREATE TABLE ... ENGINE=MEMORY with GEOMETRY columns works.

Unlike other HEAP blob implementations (e.g. Percona), this patch
provides full HASH index support on blob columns, enabling efficient
lookups, GROUP BY, and DISTINCT operations directly in HEAP without
falling back to disk.

Architecture
------------

BLOB data is stored using continuation records -- additional fixed-size
records allocated from the same HP_BLOCK that holds regular rows.  This
reuses existing allocation, free list, and size accounting with minimal
structural change, and avoids per-blob my_malloc() calls.

The existing single-byte visibility flag is extended into a flags byte
with bits for HP_ROW_HAS_CONT, HP_ROW_IS_CONT, HP_ROW_CONT_ZEROCOPY,
HP_ROW_SINGLE_REC, and HP_ROW_MULTIPLE_REC.  Continuation records are
grouped into variable-length runs -- contiguous sequences within a leaf
block.  Only the first record of each run carries a 10-byte header
(next_cont pointer + run_rec_count); inner records are pure payload.

Three storage formats, detected by flag bits via inline predicates:

  Case A (HP_ROW_SINGLE_REC): single record, no header, data at
  offset 0.  Zero-copy read.

  Case B (HP_ROW_CONT_ZEROCOPY): single run, multiple records.
  Header in rec 0, data contiguous in rec 1..N-1.  Zero-copy read
  via chain + recbuffer.

  Case C (HP_ROW_MULTIPLE_REC): one or more runs linked via
  next_cont.  Reassembly into blob_buff required.

Run allocation uses a two-phase strategy: (1) peek-then-unlink walk
of the free list detecting contiguous groups, (2) tail allocation
from HP_BLOCK for remaining data.  A Step 3 scavenge fallback
walks the entire free list when tail allocation fails.

HP_SHARE::total_records tracks all physical records (primary +
continuation), while HP_SHARE::records remains the logical count
used by hash bucket mapping.

Reassembly buffer (HP_INFO::blob_buff) follows the same pattern as
InnoDB's blob_heap -- allocated once, grown via my_realloc, freed
on heap_reset()/close.  Zero-copy cases (A/B) return pointers
directly into HP_BLOCK with no copy.

Full HASH index key handling for BLOB columns: hp_rec_hashnr(),
hp_rec_key_cmp(), hp_key_cmp(), hp_make_key(), hp_hashnr() are
extended for HA_BLOB_PART segments.  Hash pre-check optimization
skips expensive blob materialization when hashes differ.  PAD SPACE
collation semantics are preserved for blob key comparisons.

Field_blob_key (Monty) produces HEAP-native key format (4-byte length
+ 8-byte data pointer) directly, eliminating key buffer translation
between the SQL layer and HEAP engine.

SQL layer changes
-----------------

pick_engine() (new, extracted from choose_engine()): replaced the
blob_fields check with a reclength > HA_MAX_REC_LENGTH guard.
choose_engine() calls pick_engine() with the real reclength.
pick_engine() is also called early in finalize() with reclength=0
to predict whether the engine will be HEAP, enabling blob-aware
GROUP BY key setup that avoids unnecessary m_using_unique_constraint.

finalize(): HEAP+blob uses fixed-width rows; GROUP BY key setup sets
key_part_flag from field, uses item max_length for blob key sizing.
store_length initialized for all GROUP BY key parts.  key_type uses
field->binary() to determine FIELDFLAG_BINARY vs text collation.
DISTINCT key setup skips null-bits helper for HEAP.

remove_duplicates(): blob check moved before HEAP check to fall
through to remove_dup_with_compare().

Aggregator_distinct::add(): overflow-to-disk conversion via
create_internal_tmp_table_from_heap() for non-dup write errors.

Expression cache disabled for HEAP+blob (key format incompatibility).

FULLTEXT early detection in mysql_derived_prepare(): forces disk
engine via TMP_TABLE_FORCE_MYISAM when outer query uses MATCH.

Deferred blob chain free (MDEV-39732): heap_delete() saves chain
pointers to pending_blob_chains, flushed on next mutation or
heap_reset()/close.  Prevents dangling zero-copy pointers during
binlog_log_row().

REPLACE safety (MDEV-39825): HP_SHARE::write_can_replace flag
forces copy mode in hp_read_blobs(), preventing blob data corruption
from freed-then-reused continuation records during REPLACE.

Geometry GROUP_CONCAT fix (MDEV-39761): downgrade Field_geom to
Field_blob for GROUP_CONCAT temp tables in both expression creation
paths.  Type_handler_geometry::type_handler_for_tmp_table() added.

Geometry GROUP BY key fix (MDEV-39871): detect when new_key_field()
produced non-blob Field_varstring for a blob column, replace with
Field_blob_key.

Performance
-----------

Non-blob tables: zero regression.  Every blob-specific code path is
guarded by if (share->blob_count).  No new allocations, no format
changes, no hash function changes for non-blob keys.

Blob tables: eliminates file creation/deletion overhead and page cache
management.  For single-run blobs (common case), the read path is
entirely zero-copy.

Limitations
-----------

1. No BTREE indexes on blob columns (HASH only)
2. No partial-key prefix indexing for blobs
3. 2x memory for Case C reads only (A/B are 1x)
4. No blob compression
5. 65,535 records per run (uint16 cap, auto-split)
6. max_heap_table_size applies to continuation records
7. Expression cache disabled for HEAP+blob
8. FULLTEXT forces disk engine

Linked bugs fixed:

- MDEV-39703: mroonga fulltext test ordering
- MDEV-39723: ER_DUP_ENTRY on GROUP BY with blob column
- MDEV-39724: crash in hp_is_single_rec with GROUP BY
- MDEV-39732: slave crash in hp_free_run_chain on blob replication
- MDEV-39761: Field_geom::store() assertion in GROUP_CONCAT
- MDEV-39782: RBR ER_KEY_NOT_FOUND on HEAP blob UPDATE
- MDEV-39825: blob data corruption on REPLACE into HEAP table
- MDEV-39871: crash in my_hash_sort_bin on GROUP BY with geometry

Reviewed by: Michael Widenius <[email protected]>
  Monty reviewed the entire patch. Areas where he suggested changes
  or contributed code:
  - Field_blob_key class (HEAP-native blob key format, 4-byte length +
    data pointer)
  - Duplicate key fix on HEAP-to-Aria conversion
  - hp_blob_key_length() uint32 fix
  - hp_rec_hashnr_stored removal
  - type_handler_for_tmp_table() param cleanup
  - Type_handler_geometry::type_handler_for_tmp_table() virtual
  - blob pointer bzero()
  - find_unique_row() double-materialization fix
  - Tail reclaim review
  - Batch tail allocation review
  - hp_update.c cleanup
  - Field_blob_compressed temp table fix
  - row_pack_length() dedup
  - pack_length_no_ptr() removal
  - Race condition fix in HEAP
  - MDEV-39703 mroonga test fix
  - MDEV-39825 write_can_replace optimization
  - is_text_key_segment removal (field->binary() simplification)
  - Documentation (Docs/internal-temporary-tables.txt)
Contribution by: Alexander Barkov <[email protected]>
  Type_handler::make_and_init_table_field_ex() -- refactored temp table
  field creation from inline code in sql_select.cc into type handler
  virtual methods (sql_type.cc, sql_type_geom.cc), enabling clean
  per-type-handler field creation for HEAP blob promotion.
Sergei Petrunia
Rename list_records_in_range -> records_in_range_calls
Alexander Barkov
MDEV-39587 Package-wide TYPE for variable declarations

SET sql_mode=ORACLE;
DELIMITER $$
CREATE OR REPLACE PACKAGE pkg AS
  -- Declare a package public data type
  TYPE varchar_array IS TABLE OF VARCHAR(2000) INDEX BY INTEGER;
END;
$$
DELIMITER ;
DELIMITER $$

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

- Adding a helper method
    Sp_handler::sp_cache_routine_reentrant_suppress_errors
  Adding a method Sp_handler::find_package_spec().
Bill Jin
MDEV-39176 Allow parenthesized SELECT INTO in stored procedures

Add a recursive grammar rule to accept parenthesized SELECT ... INTO
statements inside stored procedures, improving compatibility with MySQL
which allows this syntax.

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.
Brandon Nesterenko
MDEV-38144: Update test results to show bug regression

The c_unsigned INT UNSIGNED would continue to show as unsigned without
the fix because the YEAR is also considered unsigned. Fixed the test to
use a signed INT after YEAR so the bug would show as the INT field
consuming the (unconsumed-by-year) UNSIGNED INT bit.

Also fixed bad spacing.
Lawrin Novitsky
More of "uninitialized use"
Sergei Petrunia
Make mtr accept and ignore  "--disable_replay next_query|test_file text" command
bsrikanth-mariadb
update opt_context_replay_basic to include variable standard_compliant_cte
Yuchen Pei
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.

(Comment and code edited by Sergei Petrunia)

MDEV-24813 Drop low-value table_lock test combinations

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.

- Addressed review comments
Lawrin Novitsky
More of "uninitialized use"
bsrikanth-mariadb
Add standard_compliant_cte to opt_related_sys_vars list

Fixes a test in main.cte_recursive
Monty
MDEV-40030 Add support for CHECK TABLE for memory tables

CHECK TABLE is now supported, but will only return ok or fail.
Still good enough for testing heap table consistenty.
Arcadiy Ivanov
MDEV-40033 Free-list contiguous block tracking for HEAP engine

Replace the HEAP engine's O(records) per-record free-list traversal
with O(blocks) by grouping contiguous deleted records into logical
blocks. Each block uses two sentinel records (block-start at the
lowest address, block-end at the highest) to represent an arbitrarily
large contiguous group. Interior "dark" records are implicitly
covered by the block's address range and have their metadata bytes
cleared by `hp_clear_dark_records()`.

**Block metadata layout** (stored inline in deleted records):
- Byte 8 (`HP_DEL_FLAG_OFFSET`): `del_flag` -- `HP_DEL_BLOCK_START`
  (2) on the first record, `HP_DEL_BLOCK_END` (1) on the last, 0 on
  dark records and singles
- Bytes 9-10 (`HP_DEL_COUNT_OFFSET`): `uint16` block record count,
  stored only on the block-start record

**`visible` minimum** bumped from `sizeof(char*)` (8) to
`HP_DEL_METADATA_SIZE` (11) for all tables. This has zero memory
impact: `recbuffer = ALIGN(visible + 1, 8)` absorbs the shift
entirely (16 bytes for all small records).

**Delete neighbor coalescing**: `hp_push_free_block_coalesce()`
(in `hp_delete.c`) normalizes the free-list head by treating a
single record as a block of count 1, then checks adjacency in
two directions (above/below). Handles all merge cases uniformly:
single-to-single, single-to-block, block-to-single, and
block-to-block. Combined count capped at `UINT_MAX16`; falls
back to `hp_push_free_record` / `hp_push_free_block` when no
adjacency. `hp_push_free_record_coalesce()` is a thin inline
wrapper.

**Dark record clearing** is centralized in `hp_clear_dark_records`,
a strided loop that zeroes only the essential metadata bytes per
record (`del_link`, `del_flag`, `visible`) rather than the
entire `recbuffer`. Used by both `hp_push_free_block` and
`hp_push_free_block_coalesce`.

**New API in `heapdef.h`:**
- Push: `hp_push_free_record()`, `hp_push_free_block()`,
  `hp_push_free_record_coalesce()`
- Consume: `hp_pop_free_record()`, `hp_take_free_block()`
- Traverse: `hp_is_free_block_end()`, `hp_free_block_first()`,
  `hp_is_free_block_start()`, `hp_free_block_start_count()`

Non-inline functions: `hp_push_free_block()` and
`hp_push_free_block_coalesce()` in `hp_delete.c`;
`hp_take_free_block()` in `hp_write.c`.

**Caller updates:**
- `hp_delete.c`: `heap_delete()` calls
  `hp_push_free_record_coalesce()` for single-record deletes
- `hp_write.c`: error-path push and `next_free_record_pos()` pop
  use `hp_push_free_record()` / `hp_pop_free_record()`
- `hp_blob.c`: `hp_free_run_chain()` uses coalescing versions;
  `hp_take_free_list_runs()` extracted from Steps 1 and 3 of
  `hp_write_one_blob()`, parameterized by `min_avail`; blob
  allocation uses `hp_take_free_block()` / `hp_pop_free_record()`
- `hp_scan.c`: batch-skip entire deleted blocks
- `_check.c`: block-aware free-list count and scan
- `hp_shrink_tail()`: reclaims entire blocks at the tail

**Unit tests** (`hp_test_freelist-t.c`): 13 new tests (252
assertions): block formation, pop/shrink, collapse to single,
partial block take, scan batch-skip, shrink-tail with blocks,
interleaved singles and blocks, ascending/descending delete
coalescing, non-adjacent gap, coalesced block reuse by blob
insert, block-to-block via adjacent blob chains.
Dave Gosselin
MDEV-39323: CROSS JOIN query returns wrong result with NOT BETWEEN

For 1 NOT BETWEEN c0 AND c2 with c0 float and c2 int, the range
optimizer was building a SEL_TREE for only c0 > 1 and dropping the
c2 < 1 disjunct.  can_optimize_range_const rejected c2 because of
a type mismatch.

The case from the ticket returned no rows (instead of the expected six
rows) because the index range scan on c0 fetched only matches for c0 >
1 but then they were discarded by the t1.c1 = t1.c2 predicate.

Plan before the fix (range scan on c0, key_len 5):
  +----+-------+-------+------+---------+------+
  | id | table | type  | key  | key_len | rows |
  +----+-------+-------+------+---------+------+
  |  1 | t1    | range | c0  |      5 |    1 |
  |  1 | t2    | index | c0  |      6 |    3 |
  +----+-------+-------+------+---------+------+

Plan after the fix (Item_func_between::get_mm_tree returns no
usable range tree, so the optimizer falls back to using the
covering index scan on i0):
  +----+-------+-------+------+---------+------+
  | id | table | type  | key  | key_len | rows |
  +----+-------+-------+------+---------+------+
  |  1 | t2    | index | c0  |      6 |    6 |
  |  1 | t1    | index | i0  |      14 |    8 |
  +----+-------+-------+------+---------+------+

In Item_func_between::get_mm_tree, when can_optimize_range_const fails
for a range bound argument and the predicate is negated, we now
abandon the whole tree instead of continuing the loop.  The new code
mirrors the existing guard in the same function for non FIELD_ITEM
arguments.

The bug was introduced by MDEV-36235 which added
can_optimize_range_const without considering the negated path.
While we could fine tune the rejection behavior in
can_optimize_range_const, I think that should be a separate patch as
it requires careful consideration for each pair of types that could
be supplied to [NOT] BETWEEN and that's outside the scope of this
ticket (which is intended to fix the wrong result issue).

This behavior matches MySQL 9.
Sergei Petrunia
Renames: record/infuse functions to match the target function name