| 1 |
/***************************************************************************** |
| 2 |
|
| 3 |
Copyright (c) 2011, 2026, Oracle and/or its affiliates. |
| 4 |
|
| 5 |
This program is free software; you can redistribute it and/or modify it under |
| 6 |
the terms of the GNU General Public License, version 2.0, as published by the |
| 7 |
Free Software Foundation. |
| 8 |
|
| 9 |
This program is designed to work with certain software (including |
| 10 |
but not limited to OpenSSL) that is licensed under separate terms, |
| 11 |
as designated in a particular file or component or in included license |
| 12 |
documentation. The authors of MySQL hereby grant you an additional |
| 13 |
permission to link the program and your derivative works with the |
| 14 |
separately licensed software that they have either included with |
| 15 |
the program or referenced in the documentation. |
| 16 |
|
| 17 |
This program is distributed in the hope that it will be useful, but WITHOUT |
| 18 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 19 |
FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0, |
| 20 |
for more details. |
| 21 |
|
| 22 |
You should have received a copy of the GNU General Public License along with |
| 23 |
this program; if not, write to the Free Software Foundation, Inc., |
| 24 |
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 25 |
|
| 26 |
*****************************************************************************/ |
| 27 |
|
| 28 |
/** @file include/fts0priv.ic |
| 29 |
Full text search internal header file |
| 30 |
|
| 31 |
Created 2011/11/12 Sunny Bains |
| 32 |
***********************************************************************/ |
| 33 |
|
| 34 |
/** Write the table id to the given buffer (including final NUL). Buffer must be |
| 35 |
at least FTS_AUX_MIN_TABLE_ID_LENGTH bytes long. |
| 36 |
@param[in] id a table/index id |
| 37 |
@param[in] str buffer to write the id to |
| 38 |
@return number of bytes written */ |
| 39 |
static inline int fts_write_object_id(ib_id_t id, char *str) { |
| 40 |
return (sprintf(str, UINT64PFx, id)); |
| 41 |
} |
| 42 |
|
| 43 |
static inline bool fts_read_object_id(ib_id_t *id, const char *str) { |
| 44 |
/* NOTE: this func doesn't care about whether current table |
| 45 |
is set with HEX_NAME, the user of the id read here will check |
| 46 |
if the id is HEX or DEC and do the right thing with it. */ |
| 47 |
return (sscanf(str, UINT64PFx, id) == 1); |
| 48 |
} |
| 49 |
|
| 50 |
/** Compare two fts_trx_table_t instances. |
| 51 |
@return < 0 if n1 < n2, 0 if n1 == n2, > 0 if n1 > n2 */ |
| 52 |
static inline int fts_trx_table_cmp(const void *p1, /*!< in: id1 */ |
| 53 |
const void *p2) /*!< in: id2 */ |
| 54 |
{ |
| 55 |
const dict_table_t *table1 = |
| 56 |
(*static_cast<const fts_trx_table_t *const *>(p1))->table; |
| 57 |
|
| 58 |
const dict_table_t *table2 = |
| 59 |
(*static_cast<const fts_trx_table_t *const *>(p2))->table; |
| 60 |
|
| 61 |
return ((table1->id > table2->id) ? 1 : (table1->id == table2->id) ? 0 : -1); |
| 62 |
} |
| 63 |
|
| 64 |
/** Compare a table id with a fts_trx_table_t table id. |
| 65 |
@return < 0 if n1 < n2, 0 if n1 == n2,> 0 if n1 > n2 */ |
| 66 |
static inline int fts_trx_table_id_cmp(const void *p1, /*!< in: id1 */ |
| 67 |
const void *p2) /*!< in: id2 */ |
| 68 |
{ |
| 69 |
const uintmax_t *table_id = static_cast<const uintmax_t *>(p1); |
| 70 |
const dict_table_t *table2 = |
| 71 |
(*static_cast<const fts_trx_table_t *const *>(p2))->table; |
| 72 |
|
| 73 |
return ((*table_id > table2->id) ? 1 : (*table_id == table2->id) ? 0 : -1); |
| 74 |
} |