diff options
author | Michael Cahill <michael.cahill@mongodb.com> | 2015-09-11 16:23:54 +1000 |
---|---|---|
committer | Michael Cahill <michael.cahill@mongodb.com> | 2015-09-11 16:23:54 +1000 |
commit | 58c7ad85c90619d4fa0e7e4df3b9f4d643b9b73b (patch) | |
tree | 63cfbe95d22f14a3d3366d68976df0d739318e9c /src/third_party/wiredtiger/src/btree/bt_cursor.c | |
parent | 8b205afd0ae74fd7351bc183e39b8931044f3987 (diff) | |
download | mongo-58c7ad85c90619d4fa0e7e4df3b9f4d643b9b73b.tar.gz |
Import wiredtiger-wiredtiger-2.6.1-1056-g5205bb1.tar.gz from wiredtiger branch mongodb-3.2
Diffstat (limited to 'src/third_party/wiredtiger/src/btree/bt_cursor.c')
-rw-r--r-- | src/third_party/wiredtiger/src/btree/bt_cursor.c | 59 |
1 files changed, 40 insertions, 19 deletions
diff --git a/src/third_party/wiredtiger/src/btree/bt_cursor.c b/src/third_party/wiredtiger/src/btree/bt_cursor.c index 9f41e3ae684..458a1985e28 100644 --- a/src/third_party/wiredtiger/src/btree/bt_cursor.c +++ b/src/third_party/wiredtiger/src/btree/bt_cursor.c @@ -70,7 +70,7 @@ __cursor_fix_implicit(WT_BTREE *btree, WT_CURSOR_BTREE *cbt) * __cursor_valid -- * Return if the cursor references an valid key/value pair. */ -static inline int +static inline bool __cursor_valid(WT_CURSOR_BTREE *cbt, WT_UPDATE **updp) { WT_BTREE *btree; @@ -133,10 +133,10 @@ __cursor_valid(WT_CURSOR_BTREE *cbt, WT_UPDATE **updp) if (cbt->ins != NULL && (upd = __wt_txn_read(session, cbt->ins->upd)) != NULL) { if (WT_UPDATE_DELETED_ISSET(upd)) - return (0); + return (false); if (updp != NULL) *updp = upd; - return (1); + return (true); } /* @@ -155,7 +155,7 @@ __cursor_valid(WT_CURSOR_BTREE *cbt, WT_UPDATE **updp) * keys, check for retrieval past the end of the page. */ if (cbt->recno >= page->pg_fix_recno + page->pg_fix_entries) - return (0); + return (false); /* * Updates aren't stored on the page, an update would have @@ -170,7 +170,7 @@ __cursor_valid(WT_CURSOR_BTREE *cbt, WT_UPDATE **updp) * "slots", check if search returned a valid slot. */ if (cbt->slot >= page->pg_var_entries) - return (0); + return (false); /* * Updates aren't stored on the page, an update would have @@ -181,7 +181,7 @@ __cursor_valid(WT_CURSOR_BTREE *cbt, WT_UPDATE **updp) cip = &page->pg_var_d[cbt->slot]; if ((cell = WT_COL_PTR(page, cip)) == NULL || __wt_cell_type(cell) == WT_CELL_DEL) - return (0); + return (false); break; case BTREE_ROW: /* @@ -189,7 +189,7 @@ __cursor_valid(WT_CURSOR_BTREE *cbt, WT_UPDATE **updp) * key as an on-page object, we're done. */ if (cbt->ins != NULL) - return (0); + return (false); /* * Check if searched returned a valid slot (the failure mode is @@ -198,19 +198,19 @@ __cursor_valid(WT_CURSOR_BTREE *cbt, WT_UPDATE **updp) * mirrors the column-store test). */ if (cbt->slot >= page->pg_row_entries) - return (0); + return (false); /* Updates are stored on the page, check for a delete. */ if (page->pg_row_upd != NULL && (upd = __wt_txn_read( session, page->pg_row_upd[cbt->slot])) != NULL) { if (WT_UPDATE_DELETED_ISSET(upd)) - return (0); + return (false); if (updp != NULL) *updp = upd; } break; } - return (1); + return (true); } /* @@ -517,7 +517,7 @@ retry: WT_RET(__cursor_func_init(cbt, 1)); WT_ERR(__cursor_col_search(session, cbt, NULL)); if (F_ISSET(cursor, WT_CURSTD_APPEND)) - cbt->iface.recno = 0; + cbt->iface.recno = WT_RECNO_OOB; /* * If not overwriting, fail if the key exists. Creating a @@ -911,7 +911,7 @@ __wt_btcur_compare(WT_CURSOR_BTREE *a_arg, WT_CURSOR_BTREE *b_arg, int *cmpp) * __cursor_equals -- * Return if two cursors reference the same row. */ -static inline int +static inline bool __cursor_equals(WT_CURSOR_BTREE *a, WT_CURSOR_BTREE *b) { switch (a->btree->type) { @@ -923,21 +923,21 @@ __cursor_equals(WT_CURSOR_BTREE *a, WT_CURSOR_BTREE *b) * one being returned to the application. */ if (((WT_CURSOR *)a)->recno == ((WT_CURSOR *)b)->recno) - return (1); + return (true); break; case BTREE_ROW: if (a->ref != b->ref) - return (0); + return (false); if (a->ins != NULL || b->ins != NULL) { if (a->ins == b->ins) - return (1); + return (true); break; } if (a->slot == b->slot) - return (1); + return (true); break; } - return (0); + return (false); } /* @@ -1153,6 +1153,19 @@ err: if (FLD_ISSET(S2C(session)->log_flags, WT_CONN_LOG_ENABLED)) } /* + * __wt_btcur_init -- + * Initialize an cursor used for internal purposes. + */ +void +__wt_btcur_init(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt) +{ + memset(cbt, 0, sizeof(WT_CURSOR_BTREE)); + + cbt->iface.session = &session->iface; + cbt->btree = S2BT(session); +} + +/* * __wt_btcur_open -- * Open a btree cursor. */ @@ -1168,14 +1181,22 @@ __wt_btcur_open(WT_CURSOR_BTREE *cbt) * Close a btree cursor. */ int -__wt_btcur_close(WT_CURSOR_BTREE *cbt) +__wt_btcur_close(WT_CURSOR_BTREE *cbt, int lowlevel) { WT_DECL_RET; WT_SESSION_IMPL *session; session = (WT_SESSION_IMPL *)cbt->iface.session; - ret = __curfile_leave(cbt); + /* + * The in-memory split and lookaside table code creates low-level btree + * cursors to search/modify leaf pages. Those cursors don't hold hazard + * pointers, nor are they counted in the session handle's cursor count. + * Skip the usual cursor tear-down in that case. + */ + if (!lowlevel) + ret = __curfile_leave(cbt); + __wt_buf_free(session, &cbt->_row_key); __wt_buf_free(session, &cbt->_tmp); |