mirror of
https://github.com/MariaDB/server.git
synced 2025-02-05 13:22:17 +01:00
81f3e97bc8
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
54 lines
2 KiB
C++
54 lines
2 KiB
C++
/*****************************************************************************
|
|
|
|
Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
|
|
|
This program is free software; you can redistribute it and/or modify it under
|
|
the terms of the GNU General Public License as published by the Free Software
|
|
Foundation; version 2 of the License.
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
this program; if not, write to the Free Software Foundation, Inc.,
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
|
|
|
|
*****************************************************************************/
|
|
|
|
/******************************************************************//**
|
|
@file include/fts0priv.ic
|
|
Full text search internal header file
|
|
|
|
Created 2011/11/12 Sunny Bains
|
|
***********************************************************************/
|
|
|
|
/******************************************************************//**
|
|
Write the table id to the given buffer (including final NUL). Buffer must be
|
|
at least FTS_AUX_MIN_TABLE_ID_LENGTH bytes long.
|
|
@return number of bytes written */
|
|
UNIV_INLINE
|
|
int
|
|
fts_write_object_id(
|
|
/*================*/
|
|
ib_id_t id, /* in: a table/index id */
|
|
char* str) /* in: buffer to write the id to */
|
|
{
|
|
return(sprintf(str, "%016llx", (ulonglong) id));
|
|
}
|
|
|
|
/******************************************************************//**
|
|
Read the table id from the string generated by fts_write_object_id().
|
|
@return TRUE if parse successful */
|
|
UNIV_INLINE
|
|
ibool
|
|
fts_read_object_id(
|
|
/*===============*/
|
|
ib_id_t* id, /* out: an id */
|
|
const char* str) /* in: buffer to read from */
|
|
{
|
|
/* NOTE: this func doesn't care about whether current table
|
|
is set with HEX_NAME, the user of the id read here will check
|
|
if the id is HEX or DEC and do the right thing with it. */
|
|
return(sscanf(str, UINT64PFx, id) == 1);
|
|
}
|