File: ex_log_8c-example.html

package info (click to toggle)
wiredtiger 3.1.0%2Bds-1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 23,708 kB
  • sloc: ansic: 103,581; python: 46,767; sh: 6,669; java: 6,055; cpp: 2,016; makefile: 1,007; xml: 176
file content (81 lines) | stat: -rw-r--r-- 35,705 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>WiredTiger: ex_log.c</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="wiredtiger.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><a href="http://wiredtiger.com/"><img alt="Logo" src="LogoFinal-header.png" alt="WiredTiger" /></a></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">
   &#160;<span id="projectnumber">Version 3.1.0</span>
   </div>
   <div id="projectbrief"><!-- 3.1.0 --></div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<div class="banner">
  <a href="https://github.com/wiredtiger/wiredtiger">Fork me on GitHub</a>
  <a class="last" href="http://groups.google.com/group/wiredtiger-users">Join my user group</a>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',false,false,'search.php','Search');
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('ex_log_8c-example.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">ex_log.c</div>  </div>
</div><!--header-->
<div class="contents">
<p>Shows how to access the database log files.</p>
<div class="fragment"><div class="line"><span class="comment">/*-</span></div><div class="line"><span class="comment"> * Public Domain 2014-2018 MongoDB, Inc.</span></div><div class="line"><span class="comment"> * Public Domain 2008-2014 WiredTiger, Inc.</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> * This is free and unencumbered software released into the public domain.</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> * Anyone is free to copy, modify, publish, use, compile, sell, or</span></div><div class="line"><span class="comment"> * distribute this software, either in source code form or as a compiled</span></div><div class="line"><span class="comment"> * binary, for any purpose, commercial or non-commercial, and by any</span></div><div class="line"><span class="comment"> * means.</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> * In jurisdictions that recognize copyright laws, the author or authors</span></div><div class="line"><span class="comment"> * of this software dedicate any and all copyright interest in the</span></div><div class="line"><span class="comment"> * software to the public domain. We make this dedication for the benefit</span></div><div class="line"><span class="comment"> * of the public at large and to the detriment of our heirs and</span></div><div class="line"><span class="comment"> * successors. We intend this dedication to be an overt act of</span></div><div class="line"><span class="comment"> * relinquishment in perpetuity of all present and future rights to this</span></div><div class="line"><span class="comment"> * software under copyright law.</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> * THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND,</span></div><div class="line"><span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span></div><div class="line"><span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.</span></div><div class="line"><span class="comment"> * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR</span></div><div class="line"><span class="comment"> * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,</span></div><div class="line"><span class="comment"> * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR</span></div><div class="line"><span class="comment"> * OTHER DEALINGS IN THE SOFTWARE.</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> * ex_log.c</span></div><div class="line"><span class="comment"> *      demonstrates how to use logging and log cursors.</span></div><div class="line"><span class="comment"> */</span></div><div class="line"><span class="preprocessor">#include &lt;test_util.h&gt;</span></div><div class="line"></div><div class="line"><span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *home1 = <span class="stringliteral">&quot;WT_HOME_LOG_1&quot;</span>;</div><div class="line"><span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *home2 = <span class="stringliteral">&quot;WT_HOME_LOG_2&quot;</span>;</div><div class="line"></div><div class="line"><span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> * <span class="keyword">const</span> uri = <span class="stringliteral">&quot;table:logtest&quot;</span>;</div><div class="line"></div><div class="line"><span class="preprocessor">#define CONN_CONFIG &quot;create,cache_size=100MB,log=(archive=false,enabled=true)&quot;</span></div><div class="line"><span class="preprocessor">#define MAX_KEYS        10</span></div><div class="line"></div><div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span></div><div class="line">setup_copy(<a name="_a0"></a><a class="code" href="struct_w_t___c_o_n_n_e_c_t_i_o_n.html">WT_CONNECTION</a> **wt_connp, <a name="_a1"></a><a class="code" href="struct_w_t___s_e_s_s_i_o_n.html">WT_SESSION</a> **sessionp)</div><div class="line">{</div><div class="line">        error_check(<a name="a2"></a><a class="code" href="group__wt.html#gacbe8d118f978f5bfc8ccb4c77c9e8813">wiredtiger_open</a>(home2, NULL, CONN_CONFIG, wt_connp));</div><div class="line"></div><div class="line">        error_check((*wt_connp)-&gt;open_session(*wt_connp, NULL, NULL, sessionp));</div><div class="line">        error_check((*sessionp)-&gt;create(</div><div class="line">            *sessionp, uri, <span class="stringliteral">&quot;key_format=S,value_format=S&quot;</span>));</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span></div><div class="line">compare_tables(<a class="code" href="struct_w_t___s_e_s_s_i_o_n.html">WT_SESSION</a> *session, <a class="code" href="struct_w_t___s_e_s_s_i_o_n.html">WT_SESSION</a> *sess_copy)</div><div class="line">{</div><div class="line">        <a name="_a3"></a><a class="code" href="struct_w_t___c_u_r_s_o_r.html">WT_CURSOR</a> *cursor, *curs_copy;</div><div class="line">        <span class="keywordtype">int</span> ret;</div><div class="line">        <span class="keyword">const</span> <span class="keywordtype">char</span> *key, *key_copy, *value, *value_copy;</div><div class="line"></div><div class="line">        error_check(session-&gt;<a name="a4"></a><a class="code" href="struct_w_t___s_e_s_s_i_o_n.html#afb5b4a69c2c5cafe411b2b04fdc1c75d">open_cursor</a>(session, uri, NULL, NULL, &amp;cursor));</div><div class="line">        error_check(</div><div class="line">            sess_copy-&gt;<a class="code" href="struct_w_t___s_e_s_s_i_o_n.html#afb5b4a69c2c5cafe411b2b04fdc1c75d">open_cursor</a>(sess_copy, uri, NULL, NULL, &amp;curs_copy));</div><div class="line"></div><div class="line">        <span class="keywordflow">while</span> ((ret = cursor-&gt;<a name="a5"></a><a class="code" href="struct_w_t___c_u_r_s_o_r.html#a0503f16bd8f3d05aa3552f229b3a8e1b">next</a>(cursor)) == 0) {</div><div class="line">                error_check(curs_copy-&gt;<a class="code" href="struct_w_t___c_u_r_s_o_r.html#a0503f16bd8f3d05aa3552f229b3a8e1b">next</a>(curs_copy));</div><div class="line">                error_check(cursor-&gt;<a name="a6"></a><a class="code" href="struct_w_t___c_u_r_s_o_r.html#af19f6f9d9c7fc248ab38879032620b2f">get_key</a>(cursor, &amp;key));</div><div class="line">                error_check(cursor-&gt;<a name="a7"></a><a class="code" href="struct_w_t___c_u_r_s_o_r.html#af85364a5af50b95bbc46c82e72f75c01">get_value</a>(cursor, &amp;value));</div><div class="line">                error_check(curs_copy-&gt;<a class="code" href="struct_w_t___c_u_r_s_o_r.html#af19f6f9d9c7fc248ab38879032620b2f">get_key</a>(curs_copy, &amp;key_copy));</div><div class="line">                error_check(curs_copy-&gt;<a class="code" href="struct_w_t___c_u_r_s_o_r.html#af85364a5af50b95bbc46c82e72f75c01">get_value</a>(curs_copy, &amp;value_copy));</div><div class="line">                <span class="keywordflow">if</span> (strcmp(key, key_copy) != 0 ||</div><div class="line">                    strcmp(value, value_copy) != 0) {</div><div class="line">                        fprintf(stderr,</div><div class="line">                            <span class="stringliteral">&quot;Mismatched: key %s, key_copy %s &quot;</span></div><div class="line">                            <span class="stringliteral">&quot;value %s value_copy %s\n&quot;</span>,</div><div class="line">                            key, key_copy, value, value_copy);</div><div class="line">                        exit (1);</div><div class="line">                }</div><div class="line">        }</div><div class="line">        scan_end_check(ret == <a name="a8"></a><a class="code" href="group__wt.html#ga3c9e1b494d95cf34404ab7a974af6bf8">WT_NOTFOUND</a>);</div><div class="line"></div><div class="line">        error_check(cursor-&gt;<a name="a9"></a><a class="code" href="struct_w_t___c_u_r_s_o_r.html#aeea071f192cab12245a50fbe71c3460b">close</a>(cursor));</div><div class="line"></div><div class="line">        ret = curs_copy-&gt;<a class="code" href="struct_w_t___c_u_r_s_o_r.html#a0503f16bd8f3d05aa3552f229b3a8e1b">next</a>(curs_copy);</div><div class="line">        scan_end_check(ret == <a class="code" href="group__wt.html#ga3c9e1b494d95cf34404ab7a974af6bf8">WT_NOTFOUND</a>);</div><div class="line"></div><div class="line">        error_check(curs_copy-&gt;<a class="code" href="struct_w_t___c_u_r_s_o_r.html#aeea071f192cab12245a50fbe71c3460b">close</a>(curs_copy));</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span></div><div class="line">print_record(uint32_t log_file, uint32_t log_offset, uint32_t opcount,</div><div class="line">   uint32_t rectype, uint32_t optype, uint64_t txnid, uint32_t fileid,</div><div class="line">   <a name="_a10"></a><a class="code" href="group__wt.html#struct_w_t___i_t_e_m">WT_ITEM</a> *key, <a class="code" href="group__wt.html#struct_w_t___i_t_e_m">WT_ITEM</a> *value)</div><div class="line">{</div><div class="line">        printf(</div><div class="line">            <span class="stringliteral">&quot;LSN [%&quot;</span> PRIu32 <span class="stringliteral">&quot;][%&quot;</span> PRIu32 <span class="stringliteral">&quot;].%&quot;</span> PRIu32</div><div class="line">            <span class="stringliteral">&quot;: record type %&quot;</span> PRIu32 <span class="stringliteral">&quot; optype %&quot;</span> PRIu32</div><div class="line">            <span class="stringliteral">&quot; txnid %&quot;</span> PRIu64 <span class="stringliteral">&quot; fileid %&quot;</span> PRIu32,</div><div class="line">            log_file, log_offset, opcount,</div><div class="line">            rectype, optype, txnid, fileid);</div><div class="line">        printf(<span class="stringliteral">&quot; key size %zu value size %zu\n&quot;</span>, key-&gt;<a name="a11"></a><a class="code" href="group__wt.html#abd8b1299dfb5c54dc049fa42a4680b55">size</a>, value-&gt;<a class="code" href="group__wt.html#abd8b1299dfb5c54dc049fa42a4680b55">size</a>);</div><div class="line">        <span class="keywordflow">if</span> (rectype == <a name="a12"></a><a class="code" href="group__wt.html#ga8cf04a003979e7852209079d4093d783">WT_LOGREC_MESSAGE</a>)</div><div class="line">                printf(<span class="stringliteral">&quot;Application Record: %s\n&quot;</span>, (<span class="keywordtype">char</span> *)value-&gt;<a name="a13"></a><a class="code" href="group__wt.html#a57f5e62aa968275d7e398cfa70e49450">data</a>);</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment"> * simple_walk_log --</span></div><div class="line"><span class="comment"> *      A simple walk of the log.</span></div><div class="line"><span class="comment"> */</span></div><div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span></div><div class="line">simple_walk_log(<a class="code" href="struct_w_t___s_e_s_s_i_o_n.html">WT_SESSION</a> *session, <span class="keywordtype">int</span> count_min)</div><div class="line">{</div><div class="line">        <a class="code" href="struct_w_t___c_u_r_s_o_r.html">WT_CURSOR</a> *cursor;</div><div class="line">        <a class="code" href="group__wt.html#struct_w_t___i_t_e_m">WT_ITEM</a> logrec_key, logrec_value;</div><div class="line">        uint64_t txnid;</div><div class="line">        uint32_t fileid, log_file, log_offset, opcount, optype, rectype;</div><div class="line">        <span class="keywordtype">int</span> count, ret;</div><div class="line"></div><div class="line">        error_check(session-&gt;<a class="code" href="struct_w_t___s_e_s_s_i_o_n.html#afb5b4a69c2c5cafe411b2b04fdc1c75d">open_cursor</a>(session, <span class="stringliteral">&quot;log:&quot;</span>, NULL, NULL, &amp;cursor));</div><div class="line">        count = 0;</div><div class="line">        <span class="keywordflow">while</span> ((ret = cursor-&gt;<a class="code" href="struct_w_t___c_u_r_s_o_r.html#a0503f16bd8f3d05aa3552f229b3a8e1b">next</a>(cursor)) == 0) {</div><div class="line">                count++;</div><div class="line">                error_check(cursor-&gt;<a class="code" href="struct_w_t___c_u_r_s_o_r.html#af19f6f9d9c7fc248ab38879032620b2f">get_key</a>(</div><div class="line">                    cursor, &amp;log_file, &amp;log_offset, &amp;opcount));</div><div class="line">                error_check(cursor-&gt;<a class="code" href="struct_w_t___c_u_r_s_o_r.html#af85364a5af50b95bbc46c82e72f75c01">get_value</a>(cursor, &amp;txnid,</div><div class="line">                    &amp;rectype, &amp;optype, &amp;fileid, &amp;logrec_key, &amp;logrec_value));</div><div class="line">                print_record(log_file, log_offset, opcount,</div><div class="line">                    rectype, optype, txnid, fileid, &amp;logrec_key, &amp;logrec_value);</div><div class="line">        }</div><div class="line">        scan_end_check(ret == <a class="code" href="group__wt.html#ga3c9e1b494d95cf34404ab7a974af6bf8">WT_NOTFOUND</a>);</div><div class="line">        error_check(cursor-&gt;<a class="code" href="struct_w_t___c_u_r_s_o_r.html#aeea071f192cab12245a50fbe71c3460b">close</a>(cursor));</div><div class="line"></div><div class="line">        <span class="keywordflow">if</span> (count &lt; count_min) {</div><div class="line">                fprintf(stderr,</div><div class="line">                    <span class="stringliteral">&quot;Expected minimum %d records, found %d\n&quot;</span>,</div><div class="line">                    count_min, count);</div><div class="line">                exit (1);</div><div class="line">        }</div><div class="line">}</div><div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span></div><div class="line">walk_log(<a class="code" href="struct_w_t___s_e_s_s_i_o_n.html">WT_SESSION</a> *session)</div><div class="line">{</div><div class="line">        <a class="code" href="struct_w_t___c_o_n_n_e_c_t_i_o_n.html">WT_CONNECTION</a> *wt_conn2;</div><div class="line">        <a class="code" href="struct_w_t___c_u_r_s_o_r.html">WT_CURSOR</a> *cursor, *cursor2;</div><div class="line">        <a class="code" href="group__wt.html#struct_w_t___i_t_e_m">WT_ITEM</a> logrec_key, logrec_value;</div><div class="line">        <a class="code" href="struct_w_t___s_e_s_s_i_o_n.html">WT_SESSION</a> *session2;</div><div class="line">        uint64_t txnid;</div><div class="line">        uint32_t fileid, opcount, optype, rectype;</div><div class="line">        uint32_t log_file, log_offset, save_file, save_offset;</div><div class="line">        <span class="keywordtype">int</span> first, i, in_txn, ret;</div><div class="line"></div><div class="line">        setup_copy(&amp;wt_conn2, &amp;session2);</div><div class="line">        error_check(session-&gt;<a class="code" href="struct_w_t___s_e_s_s_i_o_n.html#afb5b4a69c2c5cafe411b2b04fdc1c75d">open_cursor</a>(session, <span class="stringliteral">&quot;log:&quot;</span>, NULL, NULL, &amp;cursor));</div><div class="line">        error_check(session2-&gt;<a class="code" href="struct_w_t___s_e_s_s_i_o_n.html#afb5b4a69c2c5cafe411b2b04fdc1c75d">open_cursor</a>(</div><div class="line">            session2, uri, NULL, <span class="stringliteral">&quot;raw=true&quot;</span>, &amp;cursor2));</div><div class="line">        i = 0;</div><div class="line">        in_txn = 0;</div><div class="line">        txnid = 0;</div><div class="line">        save_file = save_offset = 0;</div><div class="line">        <span class="keywordflow">while</span> ((ret = cursor-&gt;<a class="code" href="struct_w_t___c_u_r_s_o_r.html#a0503f16bd8f3d05aa3552f229b3a8e1b">next</a>(cursor)) == 0) {</div><div class="line">                error_check(cursor-&gt;<a class="code" href="struct_w_t___c_u_r_s_o_r.html#af19f6f9d9c7fc248ab38879032620b2f">get_key</a>(</div><div class="line">                    cursor, &amp;log_file, &amp;log_offset, &amp;opcount));</div><div class="line">                <span class="comment">/*</span></div><div class="line"><span class="comment">                 * Save one of the LSNs we get back to search for it</span></div><div class="line"><span class="comment">                 * later.  Pick a later one because we want to walk from</span></div><div class="line"><span class="comment">                 * that LSN to the end (where the multi-step transaction</span></div><div class="line"><span class="comment">                 * was performed).  Just choose the record that is MAX_KEYS.</span></div><div class="line"><span class="comment">                 */</span></div><div class="line">                <span class="keywordflow">if</span> (++i == MAX_KEYS) {</div><div class="line">                        save_file = log_file;</div><div class="line">                        save_offset = log_offset;</div><div class="line">                }</div><div class="line">                error_check(cursor-&gt;<a class="code" href="struct_w_t___c_u_r_s_o_r.html#af85364a5af50b95bbc46c82e72f75c01">get_value</a>(cursor, &amp;txnid, &amp;rectype,</div><div class="line">                    &amp;optype, &amp;fileid, &amp;logrec_key, &amp;logrec_value));</div><div class="line"></div><div class="line">                print_record(log_file, log_offset, opcount,</div><div class="line">                    rectype, optype, txnid, fileid, &amp;logrec_key, &amp;logrec_value);</div><div class="line"></div><div class="line">                <span class="comment">/*</span></div><div class="line"><span class="comment">                 * If we are in a transaction and this is a new one, end</span></div><div class="line"><span class="comment">                 * the previous one.</span></div><div class="line"><span class="comment">                 */</span></div><div class="line">                <span class="keywordflow">if</span> (in_txn &amp;&amp; opcount == 0) {</div><div class="line">                        error_check(</div><div class="line">                            session2-&gt;<a name="a14"></a><a class="code" href="struct_w_t___s_e_s_s_i_o_n.html#a712226eca5ade5bd123026c624468fa2">commit_transaction</a>(session2, NULL));</div><div class="line">                        in_txn = 0;</div><div class="line">                }</div><div class="line"></div><div class="line">                <span class="comment">/*</span></div><div class="line"><span class="comment">                 * If the operation is a put, replay it here on the backup</span></div><div class="line"><span class="comment">                 * connection.</span></div><div class="line"><span class="comment">                 *</span></div><div class="line"><span class="comment">                 * !!!</span></div><div class="line"><span class="comment">                 * Minor cheat: the metadata is fileid 0, skip its records.</span></div><div class="line"><span class="comment">                 */</span></div><div class="line">                <span class="keywordflow">if</span> (fileid != 0 &amp;&amp;</div><div class="line">                    rectype == <a name="a15"></a><a class="code" href="group__wt.html#gafa49e810f6f760c2bcd2721ec2934991">WT_LOGREC_COMMIT</a> &amp;&amp; optype == <a name="a16"></a><a class="code" href="group__wt.html#ga696e6723bc1e3d4c3e5b5dde84fed73e">WT_LOGOP_ROW_PUT</a>) {</div><div class="line">                        <span class="keywordflow">if</span> (!in_txn) {</div><div class="line">                                error_check(session2-&gt;<a name="a17"></a><a class="code" href="struct_w_t___s_e_s_s_i_o_n.html#a7e26b16b26b5870498752322fad790bf">begin_transaction</a>(</div><div class="line">                                    session2, NULL));</div><div class="line">                                in_txn = 1;</div><div class="line">                        }</div><div class="line">                        cursor2-&gt;<a name="a18"></a><a class="code" href="struct_w_t___c_u_r_s_o_r.html#ad1088d719df40babc1f57d086691ebdc">set_key</a>(cursor2, &amp;logrec_key);</div><div class="line">                        cursor2-&gt;<a name="a19"></a><a class="code" href="struct_w_t___c_u_r_s_o_r.html#a27f7cbd0cd3e561f6a145704813ad64c">set_value</a>(cursor2, &amp;logrec_value);</div><div class="line">                        error_check(cursor2-&gt;<a name="a20"></a><a class="code" href="struct_w_t___c_u_r_s_o_r.html#aac90d9fbcc031570f924db55f8a1cee3">insert</a>(cursor2));</div><div class="line">                }</div><div class="line">        }</div><div class="line">        <span class="keywordflow">if</span> (in_txn)</div><div class="line">                error_check(session2-&gt;<a class="code" href="struct_w_t___s_e_s_s_i_o_n.html#a712226eca5ade5bd123026c624468fa2">commit_transaction</a>(session2, NULL));</div><div class="line"></div><div class="line">        error_check(cursor2-&gt;<a class="code" href="struct_w_t___c_u_r_s_o_r.html#aeea071f192cab12245a50fbe71c3460b">close</a>(cursor2));</div><div class="line">        <span class="comment">/*</span></div><div class="line"><span class="comment">         * Compare the tables after replay.  They should be identical.</span></div><div class="line"><span class="comment">         */</span></div><div class="line">        compare_tables(session, session2);</div><div class="line">        error_check(session2-&gt;<a name="a21"></a><a class="code" href="struct_w_t___s_e_s_s_i_o_n.html#a96f25dfa6447034aea1f67ab02ab5698">close</a>(session2, NULL));</div><div class="line">        error_check(wt_conn2-&gt;<a name="a22"></a><a class="code" href="struct_w_t___c_o_n_n_e_c_t_i_o_n.html#af535c517df851eeac8ebf3594d40b545">close</a>(wt_conn2, NULL));</div><div class="line"></div><div class="line">        error_check(cursor-&gt;<a name="a23"></a><a class="code" href="struct_w_t___c_u_r_s_o_r.html#afc1b42c22c9c85e1ba08ce3b34437565">reset</a>(cursor));</div><div class="line">        cursor-&gt;<a class="code" href="struct_w_t___c_u_r_s_o_r.html#ad1088d719df40babc1f57d086691ebdc">set_key</a>(cursor, save_file, save_offset, 0);</div><div class="line">        error_check(cursor-&gt;<a name="a24"></a><a class="code" href="struct_w_t___c_u_r_s_o_r.html#a7e25b2ced2cf3ec68bd5429bf921c79f">search</a>(cursor));</div><div class="line">        printf(<span class="stringliteral">&quot;Reset to saved...\n&quot;</span>);</div><div class="line">        <span class="comment">/*</span></div><div class="line"><span class="comment">         * Walk all records starting with this key.</span></div><div class="line"><span class="comment">         */</span></div><div class="line">        <span class="keywordflow">for</span> (first = 1;;) {</div><div class="line">                error_check(cursor-&gt;<a class="code" href="struct_w_t___c_u_r_s_o_r.html#af19f6f9d9c7fc248ab38879032620b2f">get_key</a>(</div><div class="line">                    cursor, &amp;log_file, &amp;log_offset, &amp;opcount));</div><div class="line">                <span class="keywordflow">if</span> (first) {</div><div class="line">                        first = 0;</div><div class="line">                        <span class="keywordflow">if</span> (save_file != log_file ||</div><div class="line">                            save_offset != log_offset) {</div><div class="line">                                fprintf(stderr,</div><div class="line">                                    <span class="stringliteral">&quot;search returned the wrong LSN\n&quot;</span>);</div><div class="line">                                exit (1);</div><div class="line">                        }</div><div class="line">                }</div><div class="line">                error_check(cursor-&gt;<a class="code" href="struct_w_t___c_u_r_s_o_r.html#af85364a5af50b95bbc46c82e72f75c01">get_value</a>(cursor, &amp;txnid, &amp;rectype,</div><div class="line">                    &amp;optype, &amp;fileid, &amp;logrec_key, &amp;logrec_value));</div><div class="line"></div><div class="line">                print_record(log_file, log_offset, opcount,</div><div class="line">                    rectype, optype, txnid, fileid, &amp;logrec_key, &amp;logrec_value);</div><div class="line"></div><div class="line">                ret = cursor-&gt;<a class="code" href="struct_w_t___c_u_r_s_o_r.html#a0503f16bd8f3d05aa3552f229b3a8e1b">next</a>(cursor);</div><div class="line">                <span class="keywordflow">if</span> (ret != 0)</div><div class="line">                        <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line">        scan_end_check(ret == <a class="code" href="group__wt.html#ga3c9e1b494d95cf34404ab7a974af6bf8">WT_NOTFOUND</a>);</div><div class="line"></div><div class="line">        error_check(cursor-&gt;<a class="code" href="struct_w_t___c_u_r_s_o_r.html#aeea071f192cab12245a50fbe71c3460b">close</a>(cursor));</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">int</span></div><div class="line">main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div><div class="line">{</div><div class="line">        <a class="code" href="struct_w_t___c_o_n_n_e_c_t_i_o_n.html">WT_CONNECTION</a> *wt_conn;</div><div class="line">        <a class="code" href="struct_w_t___c_u_r_s_o_r.html">WT_CURSOR</a> *cursor;</div><div class="line">        <a class="code" href="struct_w_t___s_e_s_s_i_o_n.html">WT_SESSION</a> *session;</div><div class="line">        <span class="keywordtype">int</span> count_min, i, record_count;</div><div class="line">        <span class="keywordtype">char</span> cmd_buf[256], k[32], v[32];</div><div class="line"></div><div class="line">        (void)argc;                                     <span class="comment">/* Unused variable */</span></div><div class="line">        (void)testutil_set_progname(argv);</div><div class="line"></div><div class="line">        count_min = 0;</div><div class="line"></div><div class="line">        (void)snprintf(cmd_buf, <span class="keyword">sizeof</span>(cmd_buf),</div><div class="line">            <span class="stringliteral">&quot;rm -rf %s %s &amp;&amp; mkdir %s %s&quot;</span>, home1, home2, home1, home2);</div><div class="line">        error_check(system(cmd_buf));</div><div class="line">        error_check(<a class="code" href="group__wt.html#gacbe8d118f978f5bfc8ccb4c77c9e8813">wiredtiger_open</a>(home1, NULL, CONN_CONFIG, &amp;wt_conn));</div><div class="line"></div><div class="line">        error_check(wt_conn-&gt;<a name="a25"></a><a class="code" href="struct_w_t___c_o_n_n_e_c_t_i_o_n.html#adad5965cd4a60f65b5ac01f7ca6d1fc0">open_session</a>(wt_conn, NULL, NULL, &amp;session));</div><div class="line">        error_check(</div><div class="line">            session-&gt;<a name="a26"></a><a class="code" href="struct_w_t___s_e_s_s_i_o_n.html#a358ca4141d59c345f401c58501276bbb">create</a>(session, uri, <span class="stringliteral">&quot;key_format=S,value_format=S&quot;</span>));</div><div class="line">        count_min++;</div><div class="line"></div><div class="line">        error_check(session-&gt;<a class="code" href="struct_w_t___s_e_s_s_i_o_n.html#afb5b4a69c2c5cafe411b2b04fdc1c75d">open_cursor</a>(session, uri, NULL, NULL, &amp;cursor));</div><div class="line">        <span class="comment">/*</span></div><div class="line"><span class="comment">         * Perform some operations with individual auto-commit transactions.</span></div><div class="line"><span class="comment">         */</span></div><div class="line">        <span class="keywordflow">for</span> (record_count = 0, i = 0; i &lt; MAX_KEYS; i++, record_count++) {</div><div class="line">                (void)snprintf(k, <span class="keyword">sizeof</span>(k), <span class="stringliteral">&quot;key%d&quot;</span>, i);</div><div class="line">                (void)snprintf(v, <span class="keyword">sizeof</span>(v), <span class="stringliteral">&quot;value%d&quot;</span>, i);</div><div class="line">                cursor-&gt;<a class="code" href="struct_w_t___c_u_r_s_o_r.html#ad1088d719df40babc1f57d086691ebdc">set_key</a>(cursor, k);</div><div class="line">                cursor-&gt;<a class="code" href="struct_w_t___c_u_r_s_o_r.html#a27f7cbd0cd3e561f6a145704813ad64c">set_value</a>(cursor, v);</div><div class="line">                error_check(cursor-&gt;<a class="code" href="struct_w_t___c_u_r_s_o_r.html#aac90d9fbcc031570f924db55f8a1cee3">insert</a>(cursor));</div><div class="line">                count_min++;</div><div class="line">        }</div><div class="line">        error_check(session-&gt;<a class="code" href="struct_w_t___s_e_s_s_i_o_n.html#a7e26b16b26b5870498752322fad790bf">begin_transaction</a>(session, NULL));</div><div class="line">        <span class="comment">/*</span></div><div class="line"><span class="comment">         * Perform some operations within a single transaction.</span></div><div class="line"><span class="comment">         */</span></div><div class="line">        <span class="keywordflow">for</span> (i = MAX_KEYS; i &lt; MAX_KEYS+5; i++, record_count++) {</div><div class="line">                (void)snprintf(k, <span class="keyword">sizeof</span>(k), <span class="stringliteral">&quot;key%d&quot;</span>, i);</div><div class="line">                (void)snprintf(v, <span class="keyword">sizeof</span>(v), <span class="stringliteral">&quot;value%d&quot;</span>, i);</div><div class="line">                cursor-&gt;<a class="code" href="struct_w_t___c_u_r_s_o_r.html#ad1088d719df40babc1f57d086691ebdc">set_key</a>(cursor, k);</div><div class="line">                cursor-&gt;<a class="code" href="struct_w_t___c_u_r_s_o_r.html#a27f7cbd0cd3e561f6a145704813ad64c">set_value</a>(cursor, v);</div><div class="line">                error_check(cursor-&gt;<a class="code" href="struct_w_t___c_u_r_s_o_r.html#aac90d9fbcc031570f924db55f8a1cee3">insert</a>(cursor));</div><div class="line">        }</div><div class="line">        error_check(session-&gt;<a class="code" href="struct_w_t___s_e_s_s_i_o_n.html#a712226eca5ade5bd123026c624468fa2">commit_transaction</a>(session, NULL));</div><div class="line">        count_min++;</div><div class="line">        error_check(cursor-&gt;<a class="code" href="struct_w_t___c_u_r_s_o_r.html#aeea071f192cab12245a50fbe71c3460b">close</a>(cursor));</div><div class="line"></div><div class="line">        error_check(</div><div class="line">            session-&gt;<a name="a27"></a><a class="code" href="struct_w_t___s_e_s_s_i_o_n.html#ac85541ca42d7596857d9f50e03c78eb5">log_printf</a>(session, <span class="stringliteral">&quot;Wrote %d records&quot;</span>, record_count));</div><div class="line">        count_min++;</div><div class="line"></div><div class="line">        <span class="comment">/*</span></div><div class="line"><span class="comment">         * Close and reopen the connection so that the log ends up with</span></div><div class="line"><span class="comment">         * a variety of records such as file sync and checkpoint.  We</span></div><div class="line"><span class="comment">         * have archiving turned off.</span></div><div class="line"><span class="comment">         */</span></div><div class="line">        error_check(wt_conn-&gt;<a class="code" href="struct_w_t___c_o_n_n_e_c_t_i_o_n.html#af535c517df851eeac8ebf3594d40b545">close</a>(wt_conn, NULL));</div><div class="line">        error_check(<a class="code" href="group__wt.html#gacbe8d118f978f5bfc8ccb4c77c9e8813">wiredtiger_open</a>(home1, NULL, CONN_CONFIG, &amp;wt_conn));</div><div class="line"></div><div class="line">        error_check(wt_conn-&gt;<a class="code" href="struct_w_t___c_o_n_n_e_c_t_i_o_n.html#adad5965cd4a60f65b5ac01f7ca6d1fc0">open_session</a>(wt_conn, NULL, NULL, &amp;session));</div><div class="line">        simple_walk_log(session, count_min);</div><div class="line">        walk_log(session);</div><div class="line">        error_check(wt_conn-&gt;<a class="code" href="struct_w_t___c_o_n_n_e_c_t_i_o_n.html#af535c517df851eeac8ebf3594d40b545">close</a>(wt_conn, NULL));</div><div class="line"></div><div class="line">        <span class="keywordflow">return</span> (EXIT_SUCCESS);</div><div class="line">}</div></div><!-- fragment --> </div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Copyright (c) 2008-2018 MongoDB, Inc.  All rights reserved.  Contact <a href="mailto:info@wiredtiger.com">info@wiredtiger.com</a> for more information.</li>
  </ul>
</div>
</body>
</html>