diff options
Diffstat (limited to 'src/third_party/wiredtiger/src/cursor/cur_std.c')
-rw-r--r-- | src/third_party/wiredtiger/src/cursor/cur_std.c | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/src/third_party/wiredtiger/src/cursor/cur_std.c b/src/third_party/wiredtiger/src/cursor/cur_std.c index 776ad980d3f..de5115845c7 100644 --- a/src/third_party/wiredtiger/src/cursor/cur_std.c +++ b/src/third_party/wiredtiger/src/cursor/cur_std.c @@ -856,7 +856,7 @@ __wt_cursor_cache_get(WT_SESSION_IMPL *session, const char *uri, uint64_t hash_v * than flag values, so fix them up according to the given configuration. */ F_CLR(cursor, - WT_CURSTD_APPEND | WT_CURSTD_PREFIX_SEARCH | WT_CURSTD_RAW | WT_CURSTD_OVERWRITE); + WT_CURSTD_APPEND | WT_CURSTD_OVERWRITE | WT_CURSTD_PREFIX_SEARCH | WT_CURSTD_RAW); F_SET(cursor, overwrite_flag); /* * If this is a btree cursor, clear its read_once flag. @@ -1084,7 +1084,7 @@ __wt_cursor_reconfigure(WT_CURSOR *cursor, const char *config) WT_ERR_NOTFOUND_OK(ret, false); /* Set the prefix search near flag. */ - if ((ret = __wt_config_getones(session, config, "prefix_key", &cval)) == 0) { + if ((ret = __wt_config_getones(session, config, "prefix_search", &cval)) == 0) { if (cval.val) { /* Prefix search near configuration can only be used for row-store. */ if (WT_CURSOR_RECNO(cursor)) @@ -1114,6 +1114,52 @@ err: } /* + * __wt_cursor_largest_key -- + * WT_CURSOR->largest_key default implementation.. + */ +int +__wt_cursor_largest_key(WT_CURSOR *cursor) +{ + WT_DECL_ITEM(key); + WT_DECL_RET; + WT_SESSION_IMPL *session; + bool ignore_tombstone; + + ignore_tombstone = F_ISSET(cursor, WT_CURSTD_IGNORE_TOMBSTONE); + CURSOR_API_CALL(cursor, session, largest_key, NULL); + + if (F_ISSET(session->txn, WT_TXN_SHARED_TS_READ)) + WT_ERR_MSG(session, EINVAL, "largest key cannot be called with a read timestamp"); + + WT_ERR(__wt_scr_alloc(session, 0, &key)); + + /* Reset the cursor to give up the cursor position. */ + WT_ERR(cursor->reset(cursor)); + + /* Ignore deletion */ + F_SET(cursor, WT_CURSTD_IGNORE_TOMBSTONE); + + /* Call cursor prev with read uncommitted isolation level. */ + WT_WITH_TXN_ISOLATION(session, WT_ISO_READ_UNCOMMITTED, ret = cursor->prev(cursor)); + WT_ERR(ret); + + /* Copy the key as we will reset the cursor after that. */ + WT_ERR(__wt_buf_set(session, key, cursor->key.data, cursor->key.size)); + WT_ERR(cursor->reset(cursor)); + WT_ERR(__wt_buf_set(session, &cursor->key, key->data, key->size)); + /* Set the key as external. */ + F_SET(cursor, WT_CURSTD_KEY_EXT); + +err: + if (!ignore_tombstone) + F_CLR(cursor, WT_CURSTD_IGNORE_TOMBSTONE); + __wt_scr_free(session, &key); + if (ret != 0) + WT_TRET(cursor->reset(cursor)); + API_END_RET(session, ret); +} + +/* * __wt_cursor_dup_position -- * Set a cursor to another cursor's position. */ |