summaryrefslogtreecommitdiff
path: root/src/cursor/cur_log.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cursor/cur_log.c')
-rw-r--r--src/cursor/cur_log.c62
1 files changed, 22 insertions, 40 deletions
diff --git a/src/cursor/cur_log.c b/src/cursor/cur_log.c
index 21a7f674c68..3ee6554b3c0 100644
--- a/src/cursor/cur_log.c
+++ b/src/cursor/cur_log.c
@@ -150,18 +150,22 @@ static int
__curlog_kv(WT_SESSION_IMPL *session, WT_CURSOR *cursor)
{
WT_CURSOR_LOG *cl;
- WT_ITEM item;
- uint32_t fileid, key_count, opsize, optype;
+ WT_DECL_RET;
+ uint32_t fileid, key_count, opsize, optype, raw;
cl = (WT_CURSOR_LOG *)cursor;
+ /* Temporarily turn off raw so we can do direct cursor operations. */
+ raw = F_MASK(cursor, WT_CURSTD_RAW);
+ F_CLR(cursor, WT_CURSTD_RAW);
+
/*
* If it is a commit and we have stepped over the header, peek to get
* the size and optype and read out any key/value from this operation.
*/
if ((key_count = cl->step_count++) > 0) {
- WT_RET(__wt_logop_read(session,
+ WT_ERR(__wt_logop_read(session,
&cl->stepp, cl->stepp_end, &optype, &opsize));
- WT_RET(__curlog_op_read(session, cl, optype, opsize, &fileid));
+ WT_ERR(__curlog_op_read(session, cl, optype, opsize, &fileid));
/* Position on the beginning of the next record part. */
cl->stepp += opsize;
} else {
@@ -181,39 +185,14 @@ __curlog_kv(WT_SESSION_IMPL *session, WT_CURSOR *cursor)
* The log cursor sets the LSN and step count as the cursor key and
* and log record related data in the value. The data in the value
* contains any operation key/value that was in the log record.
- * For the special case that the caller needs the result in raw form,
- * we create packed versions of the key/value.
*/
- if (FLD_ISSET(cursor->flags, WT_CURSTD_RAW)) {
- memset(&item, 0, sizeof(item));
- WT_RET(wiredtiger_struct_size((WT_SESSION *)session,
- &item.size, WT_LOGC_KEY_FORMAT, cl->cur_lsn->l.file,
- cl->cur_lsn->l.offset, key_count));
- WT_RET(__wt_realloc(session, NULL, item.size, &cl->packed_key));
- item.data = cl->packed_key;
- WT_RET(wiredtiger_struct_pack((WT_SESSION *)session,
- cl->packed_key, item.size, WT_LOGC_KEY_FORMAT,
- cl->cur_lsn->l.file, cl->cur_lsn->l.offset, key_count));
- __wt_cursor_set_key(cursor, &item);
-
- WT_RET(wiredtiger_struct_size((WT_SESSION *)session,
- &item.size, WT_LOGC_VALUE_FORMAT, cl->txnid, cl->rectype,
- optype, fileid, cl->opkey, cl->opvalue));
- WT_RET(__wt_realloc(session, NULL, item.size,
- &cl->packed_value));
- item.data = cl->packed_value;
- WT_RET(wiredtiger_struct_pack((WT_SESSION *)session,
- cl->packed_value, item.size, WT_LOGC_VALUE_FORMAT,
- cl->txnid, cl->rectype, optype, fileid, cl->opkey,
- cl->opvalue));
- __wt_cursor_set_value(cursor, &item);
- } else {
- __wt_cursor_set_key(cursor, cl->cur_lsn->l.file,
- cl->cur_lsn->l.offset, key_count);
- __wt_cursor_set_value(cursor, cl->txnid, cl->rectype, optype,
- fileid, cl->opkey, cl->opvalue);
- }
- return (0);
+ __wt_cursor_set_key(cursor, cl->cur_lsn->l.file, cl->cur_lsn->l.offset,
+ key_count);
+ __wt_cursor_set_value(cursor, cl->txnid, cl->rectype, optype, fileid,
+ cl->opkey, cl->opvalue);
+
+err: F_SET(cursor, raw);
+ return (ret);
}
/*
@@ -264,17 +243,19 @@ __curlog_search(WT_CURSOR *cursor)
WT_DECL_RET;
WT_LSN key;
WT_SESSION_IMPL *session;
- uint32_t counter, key_file, key_offset;
+ uint32_t counter, key_file, key_offset, raw;
cl = (WT_CURSOR_LOG *)cursor;
+ /* Temporarily turn off raw so we can do direct cursor operations. */
+ raw = F_MASK(cursor, WT_CURSTD_RAW);
+ F_CLR(cursor, WT_CURSTD_RAW);
CURSOR_API_CALL(cursor, session, search, NULL);
/*
* !!! We are ignoring the counter and only searching based on the LSN.
*/
- WT_ERR(__wt_cursor_get_key((WT_CURSOR *)cl,
- &key_file, &key_offset, &counter));
+ WT_ERR(__wt_cursor_get_key(cursor, &key_file, &key_offset, &counter));
WT_SET_LSN(&key, key_file, key_offset);
ret = __wt_log_scan(session, &key, WT_LOGSCAN_ONE,
__curlog_logrec, cl);
@@ -285,7 +266,8 @@ __curlog_search(WT_CURSOR *cursor)
WT_STAT_CONN_INCR(session, cursor_search);
WT_STAT_DATA_INCR(session, cursor_search);
-err: API_END_RET(session, ret);
+err: F_SET(cursor, raw);
+ API_END_RET(session, ret);
}
/*