diff options
author | Will Korteland <will.korteland@mongodb.com> | 2022-10-05 22:11:21 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-10-05 22:46:35 +0000 |
commit | 1d608c4dc61a970fb9b1495011589fec09cbb7a7 (patch) | |
tree | 9c6187f4cacba261c5a327589734d25412226ad4 /src/third_party/wiredtiger/src/cursor/cur_table.c | |
parent | b3ff86d9951eb54a63fa1e2d6e7371e6b9271bdd (diff) | |
download | mongo-1d608c4dc61a970fb9b1495011589fec09cbb7a7.tar.gz |
Import wiredtiger: 4cd41efb1253f5f1193fd50d28fb6359b054a644 from branch mongodb-master
ref: e4d5a9a368..4cd41efb12
for: 6.2.0-rc0
WT-9589 Fix complex colgroup bounds visibility (#8265)
Diffstat (limited to 'src/third_party/wiredtiger/src/cursor/cur_table.c')
-rw-r--r-- | src/third_party/wiredtiger/src/cursor/cur_table.c | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/src/third_party/wiredtiger/src/cursor/cur_table.c b/src/third_party/wiredtiger/src/cursor/cur_table.c index 331c54e0418..83a1ff6ba67 100644 --- a/src/third_party/wiredtiger/src/cursor/cur_table.c +++ b/src/third_party/wiredtiger/src/cursor/cur_table.c @@ -433,22 +433,28 @@ err: static int __curtable_reset(WT_CURSOR *cursor) { - WT_CURSOR *primary; + WT_CURSOR **cp; WT_CURSOR_TABLE *ctable; WT_DECL_RET; WT_SESSION_IMPL *session; + u_int i; ctable = (WT_CURSOR_TABLE *)cursor; - /* Grab the primary cursor to reset the bounds. */ - primary = *ctable->cg_cursors; JOINABLE_CURSOR_API_CALL_PREPARE_ALLOWED(cursor, session, reset, NULL); APPLY_CG(ctable, reset); - /* If a user calls cursor reset also reset the bounds. */ + /* + * The bounded cursor API clears bounds on external calls to cursor->reset. We determine this by + * guarding the call to cursor bound reset with the API_USER_ENTRY macro. Doing so prevents + * internal API calls from resetting cursor bounds unintentionally, e.g. cursor->remove. In the + * case of the table cursor we walk each cursor and directly reset the bounds on them without + * going through curfile_reset for that reason. + */ if (API_USER_ENTRY(session)) - __wt_cursor_bound_reset(primary); + for (i = 0, cp = ctable->cg_cursors; i < WT_COLGROUPS(ctable->table); i++, cp++) + __wt_cursor_bound_reset(*cp); err: API_END_RET(session, ret); @@ -837,18 +843,33 @@ err: static int __curtable_bound(WT_CURSOR *cursor, const char *config) { - WT_CURSOR *primary; + WT_CURSOR **cp, *primary; + WT_CURSOR_BOUNDS_STATE saved_bounds; WT_CURSOR_TABLE *ctable; WT_DECL_RET; WT_SESSION_IMPL *session; + u_int i; + WT_CLEAR(saved_bounds); ctable = (WT_CURSOR_TABLE *)cursor; + primary = *ctable->cg_cursors; JOINABLE_CURSOR_API_CALL(cursor, session, bound, NULL); - /* Grab the primary cursor and call bound function. */ - primary = *ctable->cg_cursors; - WT_ERR(primary->bound(primary, config)); + /* Save the current state of the bounds in case we fail to apply the new state. */ + WT_ERR(__wt_cursor_bounds_save(session, primary, &saved_bounds)); + + /* Call bound function on all column groups. */ + for (i = 0, cp = ctable->cg_cursors; i < WT_COLGROUPS(ctable->table); i++, cp++) + WT_ERR((*cp)->bound(*cp, config)); err: + /* If applying bounds fails on one colgroup cursor, restore the previous state. */ + if (ret != 0) + for (i = 0, cp = ctable->cg_cursors; i < WT_COLGROUPS(ctable->table); i++, cp++) + WT_TRET(__wt_cursor_bounds_restore(session, *cp, &saved_bounds)); + + __wt_scr_free(session, &saved_bounds.lower_bound); + __wt_scr_free(session, &saved_bounds.upper_bound); + API_END_RET(session, ret); } |