diff options
author | Andrew Morton <andrew.morton@mongodb.com> | 2023-05-16 22:21:26 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-05-17 00:50:01 +0000 |
commit | fa0e0ce777f0c3a438449a6bd1fb1b96fa5d8531 (patch) | |
tree | 459a82960061e9beadbf949d59a20c0025a642da /src/third_party/wiredtiger/src/include/btree_cmp_inline.h | |
parent | 376eae9eefe9f752d8d9b5189528f1353c019e54 (diff) | |
download | mongo-fa0e0ce777f0c3a438449a6bd1fb1b96fa5d8531.tar.gz |
Import wiredtiger: 8dc1c0b0f1381773a0d13d5751ec724f23f77709 from branch mongodb-master
ref: 04dcc36204..8dc1c0b0f1
for: 7.1.0-rc0
WT-11049 Always check prefix skipped search results in diagnostic builds
Diffstat (limited to 'src/third_party/wiredtiger/src/include/btree_cmp_inline.h')
-rw-r--r-- | src/third_party/wiredtiger/src/include/btree_cmp_inline.h | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/third_party/wiredtiger/src/include/btree_cmp_inline.h b/src/third_party/wiredtiger/src/include/btree_cmp_inline.h index d71315e0964..672627883b0 100644 --- a/src/third_party/wiredtiger/src/include/btree_cmp_inline.h +++ b/src/third_party/wiredtiger/src/include/btree_cmp_inline.h @@ -176,6 +176,7 @@ __wt_lex_compare_skip(const WT_ITEM *user_item, const WT_ITEM *tree_item, size_t { size_t len, usz, tsz; const uint8_t *userp, *treep; + int ret_val; usz = user_item->size; tsz = tree_item->size; @@ -231,15 +232,30 @@ __wt_lex_compare_skip(const WT_ITEM *user_item, const WT_ITEM *tree_item, size_t len += remain; } #endif + ret_val = 0; /* * Use the non-vectorized version for the remaining bytes and for the small key sizes. */ for (; len > 0; --len, ++userp, ++treep, ++*matchp) - if (*userp != *treep) - return (*userp < *treep ? -1 : 1); + if (*userp != *treep) { + ret_val = *userp < *treep ? -1 : 1; + break; + } /* Contents are equal up to the smallest length. */ - return ((usz == tsz) ? 0 : (usz < tsz) ? -1 : 1); + if (ret_val == 0) + ret_val = ((usz == tsz) ? 0 : (usz < tsz) ? -1 : 1); + /* In diagnostic mode ensure that short comparisons work as expected */ +#ifdef HAVE_DIAGNOSTIC + { + int full_cmp_ret; + full_cmp_ret = __wt_lex_compare(user_item, tree_item); + WT_ASSERT_ALWAYS(NULL, full_cmp_ret == ret_val, + "Comparison that skipped prefix returned different result than a full comparison"); + } +#endif + + return (ret_val); } /* |