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 Golubchik
cleanup: change mhnsw_read_first() API to take the value not Item*
Yuchen Pei
MDEV-25848 Call set_optimizer_costs for the hlindex table

This fixes msan uninitialised value failures for MVI
Sergei Golubchik
Tree<> - a typesafe wrapper for TREE
Marko Mäkelä
Merge 13.2 into main
Yuchen Pei
MDEV-25848 Make older servers refuse a table with an ARRAY index

An ARRAY index is stored in the frm as a regular key with algorithm
HA_KEY_ALG_ARRAY (8), and nothing else marks the table. An older server
opens such a table, counts the ARRAY key as a regular index on the JSON
column and:
- prints it as KEY (j) in SHOW CREATE TABLE, which can't be reloaded;
- fails indexed lookups, as the engine has no such index;
- crashes in SHOW INDEX / INFORMATION_SCHEMA.STATISTICS
- writes rows without updating the side table, so the index drifts;
- leaves the side table behind on DROP TABLE.

Write a new extra2 section, EXTRA2_NEWEST_KEY_ALGORITHM=132, with one
byte holding the newest key algorithm used in the table, if a key uses
an algorithm newer than HA_KEY_ALG_VECTOR. As 132 >=
EXTRA2_ENGINE_IMPORTANT, older servers refuse to open the table. This
server checks that the section matches the highest key algorithm.

This closes finding #12.

Tested with actual servers:

First on new server (at this patch):

MariaDB [test]> CREATE TABLE t (a int primary key, j JSON, INDEX i1 (CAST(j AS UNSIGNED ARRAY))) engine=innodb;
Query OK, 0 rows affected (0.007 sec)

MariaDB [test]> INSERT INTO t VALUES (1, '[5, 6]'), (2, '[5]'), (3, '[7]');
Query OK, 3 rows affected (0.002 sec)
Records: 3  Duplicates: 0  Warnings: 0

Then on old server (820699c7e88c8858dbcab16caf9af587333559e9):

MariaDB [test]> show create table t;
ERROR 1033 (HY000): Incorrect information in file: './test/t.frm'
MariaDB [test]> SELECT * FROM t;
ERROR 1033 (HY000): Incorrect information in file: './test/t.frm'
MariaDB [test]> SHOW INDEX FROM t;
ERROR 1033 (HY000): Incorrect information in file: './test/t.frm'
MariaDB [test]> SELECT * FROM information_schema.STATISTICS;
// [... 81 lines elided]
77 rows in set, 1 warning (0.022 sec)

MariaDB [test]> show warnings;
+---------+------+-----------------------------------------------+
| Level  | Code | Message                                      |
+---------+------+-----------------------------------------------+
| Warning | 1033 | Incorrect information in file: './test/t.frm' |
+---------+------+-----------------------------------------------+
1 row in set (0.000 sec)

MariaDB [test]> INSERT INTO t VALUES (5, '[7]');
ERROR 1033 (HY000): Incorrect information in file: './test/t.frm'
MariaDB [test]> CHECK TABLE t;
+--------+-------+----------+-----------------------------------------------+
| Table  | Op    | Msg_type | Msg_text                                      |
+--------+-------+----------+-----------------------------------------------+
| test.t | check | Error    | Incorrect information in file: './test/t.frm' |
| test.t | check | error    | Corrupt                                      |
+--------+-------+----------+-----------------------------------------------+
2 rows in set (0.000 sec)

MariaDB [test]> drop table t;
Query OK, 0 rows affected (0.001 sec)

Note: A separate bug, to be fixed separately:

Finally on new server again:

MariaDB [test]> show create table t;
ERROR 1146 (42S02): Table 'test.t' doesn't exist
MariaDB [test]> CREATE TABLE t (a int primary key, j JSON, INDEX i1 (CAST(j AS UNSIGNED ARRAY))) engine=innodb;
ERROR 1050 (42S01): Table '`test`.`t#i#01`' already exists
Yuchen Pei
MDEV-25848 Fix a compiling failure
Jan Lindström
MDEV-33763 : Buffered error logging for Server error log

New read-only system variables (set at startup, need --log-error):
* log_error_file_buffer_size: error log buffer size, default 0 (off)
* log_error_file_rotate_size: rotate the error log above this size,
  default 1073741824
* log_error_file_rotations: number of rotated files kept, default 0

Changes:
* When log_error_file_buffer_size is set, the error log is written
  through the file logger (mysys/file_logger.c), which keeps messages
  in an in-memory buffer. The logger has its own descriptor of the
  error log file. stdout and stderr stay open on the same file for
  direct writes, and are reopened on the new file after each rotation.
* FLUSH ERROR LOGS writes the buffered messages to the old file and
  opens the error log file again.
* At shutdown the buffered messages are written and the logger is
  closed. Later messages go to stderr.
* On a fatal signal the buffered messages are written before the crash
  report.
* The file logger does not call my_error() on a write error, because
  my_error() can write to the error log. A failed buffered write
  returns -1, and the server then writes the message to stderr.
* After a failed rotation the next write opens the log file again.
* print_buffer_to_file() uses one static buffer, allocated on first use
  (MAX_LOG_BUFFER_SIZE+1), grown as needed and freed at shutdown.
* vprint_msg_to_log() writes lines longer than 1024 bytes in full, up
  to 1 MB.
* Galera messages use the same error log path. Debug messages are
  written only if wsrep_debug is set.
* Add a unit test for write errors of the file logger, and mtr tests
  for the three variables, buffered logging, rotation, a crash after
  rotation, FLUSH ERROR LOGS and long lines.

Assisted-by: https://mariadb.org/governance/governance-ai-policy/
Assisted-by: Claude:claude-4.6-sonnet
Yuchen Pei
MDEV-25848 Index scalars and nested arrays like MEMBER OF does

MEMBER OF treats a scalar document as a 1-element array (boxing).
looks into nested arrays (flattening). The array index only indexed
the top-level elements of a top-level array, and returned an ignorable
error otherwise. This caused INSERT IGNORE to store a row that MEMBER
OF matches but the index does not.

In this patch we index every scalar of the document at any array
depth, a scalar document as one entry, and skip objects. SQL NULL is
not an error any more either: it has no entries.

The indexing of scalars at any array depth is useful for
JSON_CONTAINS, and MEMBER OF rechecks so still correct.

This closes finding #5.
Sergei Golubchik
MDEV-25848 use xxh3 hash of string values, not actual values

That is, keep 8-byte prefix of the original string value and xxh3
hash of the tail. Prefix keeps strings generally sorted, otherwise
the performance pathologically decreases (compared to btree or
non-hashed variant) when keys are accessed in a predictable order.

Keys that are shorter than 17 bytes are stored as is.

Benchmark: single threaded. 1,000,000 random 256-byte strings.
stored then retrieved. As '["string"]' json and directly
as varchar(256) in a normal btree index.

MyISAM:
* btree 02:07
* json  02:04
* xxh3  01:54

Note that MyISAM prefix compresses keys, which helps to put
a lot more long strings on one page, reducing benefits of short keys.

InnoDB:
* btree 04:51
* json  04:53
* xxh3  03:25
Sergei Golubchik
cleanup: extract duplicated no_part_keypart() check
Sergei Golubchik
cleanup: is_local_field() -> get_local_field()

removes the need for a separate cast after the check,
and guarantees that the correct item is used as Item_field
(and not something else was mistakenly cast due to a typo)
Yuchen Pei
MDEV-25848 A JSON column needs CHECK (json_valid(<the column itself>))

dc0b0388e96b983b472c7a347c6f5340ee019198 added a json type, and

CREATE TABLE t1 (
  j json
);

translates to

CREATE TABLE t1 (
  j LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
    CHECK (json_valid(j))
);

The check of the CHECK constraint was too lax: it did not check that
the argument of json_valid was the column itself. In this commit we
fix this hole
Sergei Golubchik
MDEV-25848 Support for Multi-Valued Indexes

* New type of high-level indexes - JSON ARRAY
* sql/index/json.{h,cc}
  * table structure (value varbinary(255), tref varbinary(N), PK(value,tref))
  * insert/update/delete/search works, search uses keyread
  * on insert json array is parsed, values are inserted
    * prefixed by the type tag, only simple types are supported
  * records_in_range works, but only for equalities (MEMBER OF)
* MySQL-compatible syntax `INDEX ((CAST(col AS type ARRAY)))`, but
  * col is a bare name, not an expression, expressions are part of MDEV-35853
  * type is ignored, not stored, also part of MDEV-35853
  * thus `'[1, 0.2, true, "foo", null]'` works fine, type not enforced
  * thus SHOW CREATE TABLE prints `... AS JSON ARRAY`
* `const MEMBER OF (col)` uses index, via
  * range optimizer, QUICK_RANGE_SELECT_ARRAY
  * Item_func_member_of::get_mm_tree()/etc
Thirunarayanan Balathandayuthapani
MDEV-32067 InnoDB linear read-ahead had better be logical

The traditional linear read-ahead, enabled by innodb_read_ahead_threshold,
only helps when consecutively accessed pages have adjacent page numbers.
That is rarely true for B-tree leaf pages: after splits, merges and page
reuse, the logical order of leaves has nothing to do with their physical
page numbers. So for a scan of scattered leaves the old read-ahead either
did nothing or read the wrong pages, and a partly cached buffer pool could
switch it off.

This replaces linear read-ahead of index pages with a logical read-ahead
that prefetches the leaf pages a scan is going to visit, discovered from
the B-tree during the traversal. The window starts at 4 leaves and doubles
on every refill, up to 64 leaves, and it is capped at 1/256 of the buffer
pool per scan. records_in_range() reports the first and last leaf page of
a range, and the optimizer forwards that extent to the storage engine, so
that the read-ahead is sized and bounded by the scan. A LIMIT of 2 or less
disables the read-ahead, and a range that fits in one leaf reads only half
of the first batch.

handler::multi_range_read_info_const(), DsMrr_impl::dsmrr_info_const():
Take a page_range parameter. The default MRR implementation aggregates the
per-range leaf extents reported by records_in_range().

handler::advise_page_range(): New virtual function that tells the engine the
estimated leaf extent of an upcoming range scan.

Carry the extent through TRP_RANGE and QUICK_RANGE_SELECT.
QUICK_RANGE_SELECT::reset() calls advise_page_range()
before multi_range_read_init().

buf_read_ahead_linear(): Removed, together with the pending-read throttle.
The read-ahead in flight is bounded by the window, the per-scan cap and the
availability of free blocks.

buf_read_ahead_one(): Read ahead a single leaf page. It cannot be disabled.

buf_read_ahead_pages(): Read ahead a set of known B-tree leaf pages. It
keeps one spare buffer block and allocates another only after the spare
block was used for a posted read, to reduce contention on buf_pool.mutex.
ROW_FORMAT=COMPRESSED tablespaces use a separate instantiation that needs
no spare block.

buf_read_release_count(): Free the spare block and update the read-ahead
statistics in one critical section of buf_pool.mutex.

buf_read_ahead_random(): Split into a decision part and an action part

buf_read_page_low(): No longer invokes buf_LRU_stat_inc_io() for
synchronous reads.

btr_ra_batch: Collects leaf page numbers, and records the level-1 page and
the child page number of the last node pointer collected, so that the
read-ahead can be resumed later.

btr_ra_batch::collect() scans the node pointers of a
PAGE_LEVEL=1 page from a given record in scan order.

btr_ra_batch::resume_rec() finds the record to resume from by locating the
last collected child by value, walking only genuine records so that a
concurrent page reorganization cannot cause an invalid read.

btr_cur_t::search_leaf(), btr_cur_t::open_leaf(): At PAGE_LEVEL=1, after the
descent has located the child to follow, collect the leaf page numbers
starting at that child in the scan direction.

dict_index_t::get_child(), dict_index_t::get_child_offset(): Read the child
page number of a node pointer without rec_get_offsets().

btr_pcur_move_to_next_page(), btr_pcur_move_backward_from_page(): Read ahead
the following or preceding sibling with buf_read_ahead_one(). The backward
move first tries to latch the preceding page without waiting.

btr_copy_blob_prefix(): No longer reads ahead, and no longer relies on
FIL_PAGE_PREV/NEXT.

dict_stats_prefetch_sample_children(): ANALYZE TABLE prefetches the child
pages of the sampled records before diving below them.

ha_innobase::ReadAhead: The per-handler state of the read-ahead.

advise(): Records the estimated leaf extent of the scan. It is used only to
size and bound the read-ahead; it never limits the pages that the scan reads.

window_for_extent(), set_limit(): Derive the largest window from the advised
extent, falling back to an estimate from the LIMIT.

start(): For a just-positioned scan, prefetch the collected batch and set up
the rolling cursor.

refill(): As the scan advances in general_fetch(), resume the level-1
collection under an index S-latch, continue on the sibling level-1 pages,
and prefetch the next batch, bounded by the advised last leaf, or by the end
of the index if the extent is unknown.

ha_innobase::search_with_readahead(): Position the cursor while collecting
the leaf pages, and start the read-ahead. It is used by index_read()
and rnd_init()/general_fetch(). general_fetch() sets active_handler_stats
before reading ahead, so that the prefetched pages are attributed to the query.

btr_cur_t::get_parent(): Replaces btr_page_get_parent(),
btr_page_get_father_block() and btr_page_get_father(). It needs no record
offsets array.

trx_undo_t::get_prev_rec(), trx_undo_t::get_prev_rec_from_prev_page():
Replace trx_undo_get_prev_rec() and its helper. They are members of the undo
log object and always latch shared. Undo log pages no longer invoke linear
read-ahead.

row_search_mvcc(): The row_prebuilt_t* is now the first parameter.
Sergei Golubchik
skip hlindex update if its columns aren't in the write_set
Marko Mäkelä
MDEV-42741 test case fixup

Reliably find the first LSN of the archive.

Assisted-by: Claude:claude-opus-5-5
Yuchen Pei
Fix crash caused by incorrectly assigning MULTIPLE to an ARRAY key when adding an index to a table with an existing ARRAY INDEX

Missing ARRAY key type causes hliton to not be assigned in
mysql_prepare_create_table_finalize. This further causes the ARRAY key
not to be placed at the end of the key list, which it should be.

Later in TABLE_SHARE::init_from_binary_frm_image it still assumes the
last key is an hlindex key. When it is not, this non-hlindex last key
has NULL hliton, causing options() to access field of the NULL t
argument passed to it by the caller thus crash.
Sergei Golubchik
cleanup: KEY::type() and KEY::is_hlindex() methods
Susil
MDEV-42244 multi_source.mix_semisync_async: wait for the ACK counter

The test multi_source.mix_semisync_async checks that a multi-source
slave with one semi-sync and one async connection sends ACKs only for
the semi-sync one. It failed now and then in buildbot, because SHOW
STATUS showed Rpl_semi_sync_slave_send_ack one lower than the result
file. The test now waits until the slave has counted the ACKs it sent
before it reads the counter. This is a test only change: the server
works as designed and its behavior does not change.

Repl_semi_sync_slave::slave_reply() increments the counter only after
net_flush() has sent the ACK. The master is released by the ACK itself,
and --sync_with_master waits only for the SQL thread, so neither waits
for the slave I/O thread to count the ACK. When the I/O thread was slow
between the send and the increment, the test read the old value.

Before each of the two reads the test now waits, with
include/wait_for_status_var.inc, for the counter to reach the number of
ACKs sent so far. The wait uses >=, so an extra ACK that is already
counted shows up as a result file difference and not as a 60 second
timeout. The expected values are the ones the result file already has,
so the result file does not change.

Assisted-by: Claude:claude-sonnet-5-5
Khaled Riyad
MDEV-42486 Prepared statement returns incorrect result after subquery data changes

Item_in_optimizer caches the result of "NULL IN (SELECT ...)" for a
non-correlated subquery in result_for_null_param, so that later rows
with a NULL left value do not evaluate the subquery again. The cache
was never reset in Item_in_optimizer::cleanup(), so the next execution
of a prepared statement or stored routine reused the result computed
from the data of an earlier execution.

Reset result_for_null_param to UNKNOWN in cleanup().
Mohammad Tafzeel Shams
MDEV-39647: Deleted Virtual secondary records might never get purged

Virtual column values are not stored in the clustered index. To check
whether a secondary index record that includes a virtual column can be
purged, row_purge_vc_matches_cluster() and row_vers_build_cur_vrow_low()
read those values from the undo log by invoking
trx_undo_prev_version_build() with TRX_UNDO_PREV_IN_PURGE.

Since MDEV-24402, this read was skipped if purge_sys.end_view saw the
transaction. That happens as soon as a purge batch has ended inside the
undo log of the transaction, even though the remaining undo log records
of the transaction have not been freed. With no values to compare,
row_purge_vc_matches_cluster() assumed a match, row_purge_is_unsafe()
returned true, and the delete-marked secondary index record was never
removed. CHECK TABLE...EXTENDED reported "Clustered index record not
found".

Changes:

- trx_undo_prev_version_build(): For TRX_UNDO_PREV_IN_PURGE, always read
the undo log record, using purge_sys_t::view_guard::PURGE. Only purge
tasks set this flag. The callers never read past the undo log record
being purged, and purge only frees undo log records before purge_sys.head.

- trx_undo_prev_version(): For TRX_UNDO_PREV_IN_PURGE, do not skip a
delete-marked previous version whose writer the view sees. With
view_guard::PURGE that view is purge_sys.view, which always sees the
transaction being purged. When an INSERT reused a delete-marked record
(TRX_UNDO_UPD_DEL_REC) and changed the size of a column, no virtual
column values were compared and the secondary index record was never
removed. Purge does not dereference BLOBs of the previous version.

- innodb.purge_secondary updates an indexed virtual column several
times in one transaction, with innodb_purge_batch_size=1 so that its
undo log is purged across several batches. It then deletes the row and
inserts it again with a longer value in one transaction, so that the
INSERT reuses the delete-marked clustered index record. CHECK
TABLE...EXTENDED must not report any leftover secondary index records.
Sergei Golubchik
cleanup: move mhnsw behind the hlindex interface

* new hlindex home: sql/index/
* API classes:
  * hlindexton - singleton, global methods. it creates
  * hlindex_share - a physical index (like TABLE_SHARE), it creates
  * hlindex - one index cursor (like handler or TABLE)
* TABLE stores hlindex, TABLE_SHARE stores hlindex_share, no more void*
* move vector_hnsw.h to its new home sql/index, added sql/index/hlindex.h
* MHNSW_Share is stored in mhnsw_share, Search_context in mhnsw_index
* KEY::options() method
Sergei Petrunia
MDEV-37732: TPROC-H, Query 21 is much slower in 11.4 than in 10.11

The problem was in Duplicate_weedout_picker::check_qep(). It computes
updated record_count - the number of record combinations left after the
strategy removes the subquery's duplicates. The logic was incorrect.
Consider EXAMPLE-1:

  select * from t1 where t1.col1 in (select col2 from t2 where corr_cond)

  and the join order of
    t2, full scan rows=1M
    t1, ref access on t1.col1=t2.col2, rows=10

Here, it would compute updated record_count=10, based on #rows in t1's
access method. This number can be a large under-estimate: each of 1M
rows in t2 can have 10 matches in t1.

The fix: compute the "Subquery Fanout" - how many (duplicate) matches
the subquery generates for one record combination of the outer tables -
and use it in Duplicate Weedout. After Duplicate Elimination is applied:

  updated_record_count = record_count / subquery_fanout.

For semi-join nests that can use SJ-Materialization, the fanout is
derived from the materialized table size estimate. For other nests,
optimize_semijoin_nests() builds a join plan for the subquery's tables
and computes:

  subquery_fanout = subquery_output_rows / n_distinct(subquery_select_list)

where n_distinct is estimated with the GROUP BY cardinality estimation
code (estimate_distinct_cardinality()). Correlation conditions may
decrease the fanout; we ignore that here.

When building that plan, tables outside the semi-join nest are assumed
to be already in the join prefix (JOIN::sjm_assumed_prefix) for the
purpose of table dependency checks. This allows subquery tables that
depend on outer tables (e.g. through an outer join's ON expression) to
be put into the plan. Outer tables' columns are still not used for ref
access.

Applying this to EXAMPLE-1: subquery_fanout is the average number of t2
rows per distinct t2.col2 value, and
  updated_record_count= 1M * 10 / subquery_fanout.

The fix is controlled by @@new_mode='FIX_SEMIJOIN_DUPS_WEEDOUT_CHECK'
and is OFF by default in this patch.
Mohammad Tafzeel Shams
MDEV-42647 Non-core dictionary tables not loaded with innodb_force_recovery=6

Fix for MDEV-32042 moved the loading of the InnoDB data dictionary
tables from dict_boot() to srv_start(), after recv_sys.apply(true).
This code was placed inside a block that is skipped when
innodb_force_recovery=6, so dict_sys.sys_virtual, sys_foreign and
sys_foreign_cols would remain NULL. Opening a table with virtual
columns would crash, and FOREIGN KEY constraints would be ignored.

Changes :
srv_start(): Invoke srv_load_tables() also when the redo log apply
is skipped, like dict_boot() did before MDEV-32042.

dict_load_virtual_col(): Return DB_CORRUPTION if SYS_VIRTUAL is
not available.

innodb.sys_virtual_missing_debug : Added new test to cover missing
SYS_VIRTUAL table.
Yuchen Pei
MDEV-25848 Initialise range->end_key fields for GEOM_FLAG in sel_arg_range_seq_next

This fixes msan failures exposed in main.opt_trace_index_merge
testcases introduced by MDEV-25848 commit
54ea632746068ea85019744f27fe8b0aaeb6e2f4
Marko Mäkelä
MDEV-42350 fixup: Ensure the minimum log file size

Assisted-by: Claude:claude-opus-5-5
Marko Mäkelä
MDEV-42741 innodb_log_archive=ON debug assertion failure

commit 518761d1d72154d2ca686f2314ad640763f67ced (MDEV-42350)
introduced a bogus debug assertion that would fail when the
checkpoint mini-transaction at the end of a log file comprises
some FILE_MODIFY records.

recv_sys_t::find_checkpoint(): Correct the debug assertion by
referring to the actual end of the FILE_CHECKPOINT mini-transaction.

recv_sys_t::find_checkpoint_archived(): Remember the end of the latest
FILE_CHECKPOINT mini-transaction in the debug-only variable
found_checkpoint_end.

Co-developed by: Thirunarayanan Balathandayuthapani
Assisted-by: Claude:claude-opus-5-5
Khaled Riyad
MDEV-42486 Prepared statement returns incorrect result after subquery data changes

Item_in_optimizer caches the result of "NULL IN (SELECT ...)" for a
non-correlated subquery in result_for_null_param, so that later rows
with a NULL left value do not evaluate the subquery again. The cache
was never reset in Item_in_optimizer::cleanup(), so the next execution
of a prepared statement or stored routine reused the result computed
from the data of an earlier execution.

Reset result_for_null_param to UNKNOWN in cleanup().
Thirunarayanan Balathandayuthapani
MDEV-42713 InnoDB: Cannot replay rename because the target file exists

Problem:
=======
After commit 9759167322ac9c647ca42c3e9e43a3d19fa5b18e(MDEV-41548),
recv_rename_files() replays every FILE_RENAME record in log order,
applying a record whenever the tablespace is currently named after
the record's source file. That cannot tell "not yet executed"
from "executed, then renamed away and back".

If a tablespace was renamed t1->t3->t1 and another tablespace then
took the name t3 (t2->t3), and all the renames had completed before
the crash, the first record (t1->t3) still matches the
current name t1. Replaying it tries to rename onto t3.ibd,
which now belongs to the other tablespace, and
recovery fails with "Cannot replay rename of tablespace
because the target file exists".

Solution:
========
recv_rename_files(): Find the last FILE_RENAME record that was
already executed, that is the latest log position at which file name
of every renamed tablespace equals the destination name that the
records give it. Then replay only the records after that position,
in log order. If no position matches report an error.
Yuchen Pei
MDEV-25848 Use table->s->total_keys for hint keyinfo_array

Before this, keyinfo_array has the same size as table->s->keys, which
does not count ARRAY key. This causes out of bounds failure when
accessing keyinfo_array.
Yuchen Pei
MDEV-25848 Stale update_needed fixed

update_needed is computed by checking that the hlindex key is in
write_set. When done before mark_columns_needed_for_insert() marked
default and virtual columns, the stale write_set could result in false
negative: update is needed but update_needed is false.

This patch fixes that and closes finding #4.
Yuchen Pei
MDEV-25848 Allow optimizer key hints to have an effect when the key is MVI

IGNORE INDEX, USE/FORCE INDEX of other keys, IGNORED, and
NO_RANGE_OPTIMIZATION now work
Sergei Petrunia
MDEV-25848: record/replay hlindex records_in_range() in optimizer context

check_quick_select_array() now goes through hook_hl_records_in_range(),
which records or replaces both the row estimate and the cost
(record_hl_records_in_range / infuse_hl_records_in_range). The calls are
stored in a new per-table "hl_records_in_range_calls" array.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Sergei Golubchik
cleanup: remove dead code
Mohammad Tafzeel Shams
MDEV-42647 Non-core dictionary tables not loaded with innodb_force_recovery=6

Fix for MDEV-32042 moved the loading of the InnoDB data dictionary
tables from dict_boot() to srv_start(), after recv_sys.apply(true).
This code was placed inside a block that is skipped when
innodb_force_recovery=6, so dict_sys.sys_virtual, sys_foreign and
sys_foreign_cols would remain NULL. Opening a table with virtual
columns would crash, and FOREIGN KEY constraints would be ignored.

Changes :
srv_start(): Invoke srv_load_tables() also when the redo log apply
is skipped, like dict_boot() did before MDEV-32042.

dict_load_virtual_col(): Return DB_CORRUPTION if SYS_VIRTUAL is
not available.

innodb.sys_virtual_missing_debug : Added new test to cover missing
SYS_VIRTUAL table.
Yuchen Pei
MDEV-25848 Do not ask the engine for the key of HA_ERR_BAD_FIELD_VALUE

get_dup_key() called info(HA_STATUS_ERRKEY) for HA_ERR_BAD_FIELD_VALUE,
so print_error() named a key column for engine geometry errors. InnoDB
sets the error key to the clustered index when an UPDATE makes a
geometry column empty, so the error named the first PRIMARY KEY column
("Incorrect int value: '1' for column id"), and a multi-column PRIMARY
KEY failed the usable_key_parts == 1 assertion in print_error().

This closes finding #10.
Yuchen Pei
MDEV-25848 Call hlindex_read_end in the QUICK_RANGE_SELECT_ARRAY destructor

In QUICK_RANGE_SELECT_ARRAY::get_next, hlindex_read_end() is only
called when the read result is EOF. This is skipped with LIMIT clause
not reading all rows. For a DELETE ... LIMIT ... statement this means
inited is not restored to NONE and delete_handler is not deleted
(leak). We fix this by calling hlindex_read_end in the
QUICK_RANGE_SELECT_ARRAY destructor, just like in JOIN_TAB::cleanup().

This closes finding #8.