summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/btree/bt_curprev.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/third_party/wiredtiger/src/btree/bt_curprev.c')
-rw-r--r--src/third_party/wiredtiger/src/btree/bt_curprev.c134
1 files changed, 49 insertions, 85 deletions
diff --git a/src/third_party/wiredtiger/src/btree/bt_curprev.c b/src/third_party/wiredtiger/src/btree/bt_curprev.c
index 0099d1ae594..f8db9cd6233 100644
--- a/src/third_party/wiredtiger/src/btree/bt_curprev.c
+++ b/src/third_party/wiredtiger/src/btree/bt_curprev.c
@@ -40,7 +40,7 @@ __cursor_skip_prev(WT_CURSOR_BTREE *cbt)
uint64_t recno;
int i;
- session = (WT_SESSION_IMPL *)cbt->iface.session;
+ session = CUR2S(cbt);
restart:
/*
@@ -123,9 +123,8 @@ static inline int
__cursor_fix_append_prev(WT_CURSOR_BTREE *cbt, bool newpage, bool restart)
{
WT_SESSION_IMPL *session;
- WT_UPDATE *upd;
- session = (WT_SESSION_IMPL *)cbt->iface.session;
+ session = CUR2S(cbt);
/* If restarting after a prepare conflict, jump to the right spot. */
if (restart)
@@ -198,28 +197,14 @@ __cursor_fix_append_prev(WT_CURSOR_BTREE *cbt, bool newpage, bool restart)
cbt->iface.value.data = &cbt->v;
} else {
restart_read:
- WT_RET(__wt_txn_read_upd_list(session, cbt->ins->upd, &upd));
- if (upd == NULL) {
+ WT_RET(__wt_txn_read_upd_list(session, cbt, cbt->ins->upd));
+ if (cbt->upd_value->type == WT_UPDATE_INVALID) {
cbt->v = 0;
cbt->iface.value.data = &cbt->v;
- } else {
- /*
- * If this update has been restored from the disk, it needs to be freed after copying it
- * to the user cursor.
- */
- if (F_ISSET(upd, WT_UPDATE_RESTORED_FROM_DISK)) {
- switch (upd->type) {
- case WT_UPDATE_TOMBSTONE:
- cbt->iface.value.data = upd->data;
- __wt_free_update_list(session, &upd);
- break;
- default:
- return (__wt_value_return(cbt, upd));
- }
- }
- if (upd != NULL)
- cbt->iface.value.data = upd->data;
- }
+ } else if (cbt->upd_value->type == WT_UPDATE_TOMBSTONE)
+ cbt->iface.value.data = cbt->upd_value->buf.data;
+ else
+ WT_RET(__wt_value_return(cbt, cbt->upd_value));
}
cbt->iface.value.size = 1;
return (0);
@@ -235,9 +220,8 @@ __cursor_fix_prev(WT_CURSOR_BTREE *cbt, bool newpage, bool restart)
WT_BTREE *btree;
WT_PAGE *page;
WT_SESSION_IMPL *session;
- WT_UPDATE *upd;
- session = (WT_SESSION_IMPL *)cbt->iface.session;
+ session = CUR2S(cbt);
page = cbt->ref->page;
btree = S2BT(session);
@@ -265,35 +249,21 @@ new_page:
cbt->ins = __col_insert_search(cbt->ins_head, cbt->ins_stack, cbt->next_stack, cbt->recno);
if (cbt->ins != NULL && cbt->recno != WT_INSERT_RECNO(cbt->ins))
cbt->ins = NULL;
- upd = NULL;
/*
- * FIXME-PM-1523: Now we only do transaction read if we have an update chain and it doesn't work
+ * FIXME-WT-6127: Now we only do transaction read if we have an update chain and it doesn't work
* in durable history. Review this when we have a plan for fixed-length column store.
*/
+ __wt_upd_value_clear(cbt->upd_value);
if (cbt->ins != NULL)
restart_read:
- WT_RET(__wt_txn_read(session, cbt, NULL, cbt->recno, cbt->ins->upd, NULL, &upd));
- if (upd == NULL) {
+ WT_RET(__wt_txn_read(session, cbt, NULL, cbt->recno, cbt->ins->upd, NULL));
+ if (cbt->upd_value->type == WT_UPDATE_INVALID) {
cbt->v = __bit_getv_recno(cbt->ref, cbt->recno, btree->bitcnt);
cbt->iface.value.data = &cbt->v;
- } else {
- /*
- * If this update has been restored from the disk, it needs to be freed after copying it to
- * the user cursor.
- */
- if (F_ISSET(upd, WT_UPDATE_RESTORED_FROM_DISK)) {
- switch (upd->type) {
- case WT_UPDATE_TOMBSTONE:
- cbt->iface.value.data = upd->data;
- __wt_free_update_list(session, &upd);
- break;
- default:
- return (__wt_value_return(cbt, upd));
- }
- }
- if (upd != NULL)
- cbt->iface.value.data = upd->data;
- }
+ } else if (cbt->upd_value->type == WT_UPDATE_TOMBSTONE)
+ cbt->iface.value.data = cbt->upd_value->buf.data;
+ else
+ WT_RET(__wt_value_return(cbt, cbt->upd_value));
cbt->iface.value.size = 1;
return (0);
}
@@ -306,9 +276,8 @@ static inline int
__cursor_var_append_prev(WT_CURSOR_BTREE *cbt, bool newpage, bool restart)
{
WT_SESSION_IMPL *session;
- WT_UPDATE *upd;
- session = (WT_SESSION_IMPL *)cbt->iface.session;
+ session = CUR2S(cbt);
/* If restarting after a prepare conflict, jump to the right spot. */
if (restart)
@@ -327,17 +296,16 @@ new_page:
__cursor_set_recno(cbt, WT_INSERT_RECNO(cbt->ins));
restart_read:
- WT_RET(__wt_txn_read_upd_list(session, cbt->ins->upd, &upd));
- if (upd == NULL)
+ WT_RET(__wt_txn_read_upd_list(session, cbt, cbt->ins->upd));
+ if (cbt->upd_value->type == WT_UPDATE_INVALID)
continue;
- if (upd->type == WT_UPDATE_TOMBSTONE) {
- if (upd->txnid != WT_TXN_NONE && __wt_txn_upd_visible_all(session, upd))
+ if (cbt->upd_value->type == WT_UPDATE_TOMBSTONE) {
+ if (cbt->upd_value->txnid != WT_TXN_NONE &&
+ __wt_txn_upd_value_visible_all(session, cbt->upd_value))
++cbt->page_deleted_count;
- if (F_ISSET(upd, WT_UPDATE_RESTORED_FROM_DISK) && upd->type != WT_UPDATE_TOMBSTONE)
- __wt_free_update_list(session, &upd);
continue;
}
- return (__wt_value_return(cbt, upd));
+ return (__wt_value_return(cbt, cbt->upd_value));
}
/* NOTREACHED */
}
@@ -355,10 +323,9 @@ __cursor_var_prev(WT_CURSOR_BTREE *cbt, bool newpage, bool restart)
WT_INSERT *ins;
WT_PAGE *page;
WT_SESSION_IMPL *session;
- WT_UPDATE *upd;
uint64_t rle_start;
- session = (WT_SESSION_IMPL *)cbt->iface.session;
+ session = CUR2S(cbt);
page = cbt->ref->page;
rle_start = 0; /* -Werror=maybe-uninitialized */
@@ -398,18 +365,17 @@ restart_read:
/* Check any insert list for a matching record. */
cbt->ins_head = WT_COL_UPDATE_SLOT(page, cbt->slot);
cbt->ins = __col_insert_search_match(cbt->ins_head, cbt->recno);
- upd = NULL;
+ __wt_upd_value_clear(cbt->upd_value);
if (cbt->ins != NULL)
- WT_RET(__wt_txn_read_upd_list(session, cbt->ins->upd, &upd));
- if (upd != NULL) {
- if (upd->type == WT_UPDATE_TOMBSTONE) {
- if (upd->txnid != WT_TXN_NONE && __wt_txn_upd_visible_all(session, upd))
+ WT_RET(__wt_txn_read_upd_list(session, cbt, cbt->ins->upd));
+ if (cbt->upd_value->type != WT_UPDATE_INVALID) {
+ if (cbt->upd_value->type == WT_UPDATE_TOMBSTONE) {
+ if (cbt->upd_value->txnid != WT_TXN_NONE &&
+ __wt_txn_upd_value_visible_all(session, cbt->upd_value))
++cbt->page_deleted_count;
- if (F_ISSET(upd, WT_UPDATE_RESTORED_FROM_DISK))
- __wt_free_update_list(session, &upd);
continue;
}
- return (__wt_value_return(cbt, upd));
+ return (__wt_value_return(cbt, cbt->upd_value));
}
/*
@@ -449,8 +415,9 @@ restart_read:
continue;
}
- WT_RET(__wt_bt_col_var_cursor_walk_txn_read(session, cbt, page, &unpack, cip, &upd));
- if (upd == NULL)
+ WT_RET(__wt_bt_col_var_cursor_walk_txn_read(session, cbt, page, &unpack, cip));
+ if (cbt->upd_value->type == WT_UPDATE_INVALID ||
+ cbt->upd_value->type == WT_UPDATE_TOMBSTONE)
continue;
return (0);
}
@@ -474,10 +441,9 @@ __cursor_row_prev(WT_CURSOR_BTREE *cbt, bool newpage, bool restart)
WT_PAGE *page;
WT_ROW *rip;
WT_SESSION_IMPL *session;
- WT_UPDATE *upd;
bool kpack_used;
- session = (WT_SESSION_IMPL *)cbt->iface.session;
+ session = CUR2S(cbt);
page = cbt->ref->page;
key = &cbt->iface.key;
@@ -536,17 +502,16 @@ restart_read_insert:
if ((ins = cbt->ins) != NULL) {
key->data = WT_INSERT_KEY(ins);
key->size = WT_INSERT_KEY_SIZE(ins);
- WT_RET(__wt_txn_read_upd_list(session, ins->upd, &upd));
- if (upd == NULL)
+ WT_RET(__wt_txn_read_upd_list(session, cbt, ins->upd));
+ if (cbt->upd_value->type == WT_UPDATE_INVALID)
continue;
- if (upd->type == WT_UPDATE_TOMBSTONE) {
- if (upd->txnid != WT_TXN_NONE && __wt_txn_upd_visible_all(session, upd))
+ if (cbt->upd_value->type == WT_UPDATE_TOMBSTONE) {
+ if (cbt->upd_value->txnid != WT_TXN_NONE &&
+ __wt_txn_upd_value_visible_all(session, cbt->upd_value))
++cbt->page_deleted_count;
- if (F_ISSET(upd, WT_UPDATE_RESTORED_FROM_DISK))
- __wt_free_update_list(session, &upd);
continue;
}
- return (__wt_value_return(cbt, upd));
+ return (__wt_value_return(cbt, cbt->upd_value));
}
/* Check for the beginning of the page. */
@@ -574,17 +539,16 @@ restart_read_page:
rip = &page->pg_row[cbt->slot];
WT_RET(__cursor_row_slot_key_return(cbt, rip, &kpack, &kpack_used));
WT_RET(__wt_txn_read(
- session, cbt, &cbt->iface.key, WT_RECNO_OOB, WT_ROW_UPDATE(page, rip), NULL, &upd));
- if (upd == NULL)
+ session, cbt, &cbt->iface.key, WT_RECNO_OOB, WT_ROW_UPDATE(page, rip), NULL));
+ if (cbt->upd_value->type == WT_UPDATE_INVALID)
continue;
- if (upd->type == WT_UPDATE_TOMBSTONE) {
- if (upd->txnid != WT_TXN_NONE && __wt_txn_upd_visible_all(session, upd))
+ if (cbt->upd_value->type == WT_UPDATE_TOMBSTONE) {
+ if (cbt->upd_value->txnid != WT_TXN_NONE &&
+ __wt_txn_upd_value_visible_all(session, cbt->upd_value))
++cbt->page_deleted_count;
- if (F_ISSET(upd, WT_UPDATE_RESTORED_FROM_DISK))
- __wt_free_update_list(session, &upd);
continue;
}
- return (__wt_value_return(cbt, upd));
+ return (__wt_value_return(cbt, cbt->upd_value));
}
/* NOTREACHED */
}
@@ -604,7 +568,7 @@ __wt_btcur_prev(WT_CURSOR_BTREE *cbt, bool truncating)
bool newpage, restart;
cursor = &cbt->iface;
- session = (WT_SESSION_IMPL *)cbt->iface.session;
+ session = CUR2S(cbt);
WT_STAT_CONN_INCR(session, cursor_prev);
WT_STAT_DATA_INCR(session, cursor_prev);