mariadb/storage/innobase/unittest
Marko Mäkelä 81f3e97bc8 MDEV-33383: Corrupted red-black tree due to incorrect comparison
fts_doc_id_cmp(): Replaces several duplicated functions for
comparing two doc_id_t*. On IA-32, AMD64, ARMv7, ARMv8, RISC-V
this should make use of some conditional ALU instructions.
On POWER there will be conditional jumps. Unlike the original
functions, these will return the correct result even if the
difference of the two doc_id does not fit in the int data type.
We use static_assert() and offsetof() to check at compilation time
that this function is compatible with the rbt_create() calls.

fts_query_compare_rank(): As documented, return -1 and not 1
when the rank are equal and r1->doc_id < r2->doc_id. This will
affect the result of ha_innobase::ft_read().

fts_ptr2_cmp(), fts_ptr1_ptr2_cmp(): These replace
fts_trx_table_cmp(), fts_trx_table_id_cmp().
The fts_savepoint_t::tables will be sorted by dict_table_t*
rather than dict_table_t::id. There was no correctness bug in
the previous comparison predicates. We can avoid one level of
unnecessary pointer dereferencing in this way.
Actually, fts_savepoint_t is duplicating trx_t::mod_tables.
MDEV-33401 was filed about removing it.

The added unit test innodb_rbt-t covers both the previous buggy comparison
predicate and the revised fts_doc_id_cmp(), using keys which led to
finding the bug. Thanks to Shaohua Wang from Alibaba for providing the
example and the revised comparison predicate.

Reviewed by: Thirunarayanan Balathandayuthapani
2024-02-12 17:01:45 +02:00
..
CMakeLists.txt MDEV-33383: Corrupted red-black tree due to incorrect comparison 2024-02-12 17:01:45 +02:00
innodb_fts-t.cc MDEV-19522 fixup: Use correct printf format 2021-10-21 15:53:35 +03:00
innodb_rbt-t.cc MDEV-33383: Corrupted red-black tree due to incorrect comparison 2024-02-12 17:01:45 +02:00