diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-18 13:22:53 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-18 13:22:53 +0000 |
commit | 347c164c35eddab388009470e6848cb361ac93f8 (patch) | |
tree | 2c0c44eac690f510bb0a35b2a13b36d606b77b6b /storage/innobase/fts/fts0fts.cc | |
parent | Releasing progress-linux version 1:10.11.7-4~progress7.99u1. (diff) | |
download | mariadb-347c164c35eddab388009470e6848cb361ac93f8.tar.xz mariadb-347c164c35eddab388009470e6848cb361ac93f8.zip |
Merging upstream version 1:10.11.8.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'storage/innobase/fts/fts0fts.cc')
-rw-r--r-- | storage/innobase/fts/fts0fts.cc | 62 |
1 files changed, 48 insertions, 14 deletions
diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index 0775d939..4d9a1d3a 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -2187,6 +2187,22 @@ fts_trx_row_get_new_state( return(result); } +/** Compare two doubly indirected pointers */ +static int fts_ptr2_cmp(const void *p1, const void *p2) +{ + const void *a= **static_cast<const void*const*const*>(p1); + const void *b= **static_cast<const void*const*const*>(p2); + return b > a ? -1 : a > b; +} + +/** Compare a singly indirected pointer to a doubly indirected one */ +static int fts_ptr1_ptr2_cmp(const void *p1, const void *p2) +{ + const void *a= *static_cast<const void*const*>(p1); + const void *b= **static_cast<const void*const*const*>(p2); + return b > a ? -1 : a > b; +} + /******************************************************************//** Create a savepoint instance. @return savepoint instance */ @@ -2209,8 +2225,8 @@ fts_savepoint_create( savepoint->name = mem_heap_strdup(heap, name); } - savepoint->tables = rbt_create( - sizeof(fts_trx_table_t*), fts_trx_table_cmp); + static_assert(!offsetof(fts_trx_table_t, table), "ABI"); + savepoint->tables = rbt_create(sizeof(fts_trx_table_t*), fts_ptr2_cmp); return(savepoint); } @@ -2258,6 +2274,19 @@ fts_trx_create( return(ftt); } +/** Compare two doc_id */ +static inline int doc_id_cmp(doc_id_t a, doc_id_t b) +{ + return b > a ? -1 : a > b; +} + +/** Compare two DOC_ID. */ +int fts_doc_id_cmp(const void *p1, const void *p2) +{ + return doc_id_cmp(*static_cast<const doc_id_t*>(p1), + *static_cast<const doc_id_t*>(p2)); +} + /******************************************************************//** Create an FTS trx table. @return FTS trx table */ @@ -2276,7 +2305,8 @@ fts_trx_table_create( ftt->table = table; ftt->fts_trx = fts_trx; - ftt->rows = rbt_create(sizeof(fts_trx_row_t), fts_trx_row_doc_id_cmp); + static_assert(!offsetof(fts_trx_row_t, doc_id), "ABI"); + ftt->rows = rbt_create(sizeof(fts_trx_row_t), fts_doc_id_cmp); return(ftt); } @@ -2300,7 +2330,8 @@ fts_trx_table_clone( ftt->table = ftt_src->table; ftt->fts_trx = ftt_src->fts_trx; - ftt->rows = rbt_create(sizeof(fts_trx_row_t), fts_trx_row_doc_id_cmp); + static_assert(!offsetof(fts_trx_row_t, doc_id), "ABI"); + ftt->rows = rbt_create(sizeof(fts_trx_row_t), fts_doc_id_cmp); /* Copy the rb tree values to the new savepoint. */ rbt_merge_uniq(ftt->rows, ftt_src->rows); @@ -2325,13 +2356,9 @@ fts_trx_init( { fts_trx_table_t* ftt; ib_rbt_bound_t parent; - ib_rbt_t* tables; - fts_savepoint_t* savepoint; - - savepoint = static_cast<fts_savepoint_t*>(ib_vector_last(savepoints)); - - tables = savepoint->tables; - rbt_search_cmp(tables, &parent, &table->id, fts_trx_table_id_cmp, NULL); + ib_rbt_t* tables = static_cast<fts_savepoint_t*>( + ib_vector_last(savepoints))->tables; + rbt_search_cmp(tables, &parent, &table, fts_ptr1_ptr2_cmp, nullptr); if (parent.result == 0) { fts_trx_table_t** fttp; @@ -3860,6 +3887,13 @@ fts_write_node( return(error); } +/** Sort an array of doc_id */ +void fts_doc_ids_sort(ib_vector_t *doc_ids) +{ + doc_id_t *const data= reinterpret_cast<doc_id_t*>(doc_ids->data); + std::sort(data, data + doc_ids->used); +} + /*********************************************************************//** Add rows to the DELETED_CACHE table. @return DB_SUCCESS if all went well else error code*/ @@ -3881,7 +3915,7 @@ fts_sync_add_deleted_cache( ut_a(ib_vector_size(doc_ids) > 0); - ib_vector_sort(doc_ids, fts_doc_id_cmp); + fts_doc_ids_sort(doc_ids); info = pars_info_create(); @@ -5575,8 +5609,8 @@ fts_savepoint_rollback_last_stmt( l_ftt = rbt_value(fts_trx_table_t*, node); rbt_search_cmp( - s_tables, &parent, &(*l_ftt)->table->id, - fts_trx_table_id_cmp, NULL); + s_tables, &parent, &(*l_ftt)->table, + fts_ptr1_ptr2_cmp, nullptr); if (parent.result == 0) { fts_trx_table_t** s_ftt; |