1<?xml version="1.0" encoding="UTF-8" standalone="no"?> 2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3<html xmlns="http://www.w3.org/1999/xhtml"> 4 <head> 5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 6 <title>DB_ENV->log_put()</title> 7 <link rel="stylesheet" href="apiReference.css" type="text/css" /> 8 <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> 9 <link rel="start" href="index.html" title="Berkeley DB C API Reference" /> 10 <link rel="up" href="lsn.html" title="Chapter 7. The DB_LSN Handle" /> 11 <link rel="prev" href="logprintf.html" title="DB_ENV->log_printf()" /> 12 <link rel="next" href="envlog_set_config.html" title="DB_ENV->log_set_config()" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">DB_ENV->log_put()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="logprintf.html">Prev</a> </td> 22 <th width="60%" align="center">Chapter 7. 23 The DB_LSN Handle 24 </th> 25 <td width="20%" align="right"> <a accesskey="n" href="envlog_set_config.html">Next</a></td> 26 </tr> 27 </table> 28 <hr /> 29 </div> 30 <div class="sect1" lang="en" xml:lang="en"> 31 <div class="titlepage"> 32 <div> 33 <div> 34 <h2 class="title" style="clear: both"><a id="logput"></a>DB_ENV->log_put()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db.h> 39 40int 41DB_ENV->log_put(DB_ENV *env, 42 DB_LSN *lsn, const DBT *data, u_int32_t flags); </pre> 43 <p> 44 The <code class="methodname">DB_ENV->log_put()</code> method appends records to the log. The 45 <a class="link" href="lsn.html" title="Chapter 7. The DB_LSN Handle">DB_LSN</a> of the put record is 46 returned in the <span class="bold"><strong>lsn</strong></span> parameter. 47 </p> 48 <p> 49 The <code class="methodname">DB_ENV->log_put()</code> <span> 50 <span> 51 method returns a non-zero error value on failure and 0 on success. 52 </span> 53 54 </span> 55 </p> 56 <div class="sect2" lang="en" xml:lang="en"> 57 <div class="titlepage"> 58 <div> 59 <div> 60 <h3 class="title"><a id="id1681935"></a>Parameters</h3> 61 </div> 62 </div> 63 </div> 64 <div class="sect3" lang="en" xml:lang="en"> 65 <div class="titlepage"> 66 <div> 67 <div> 68 <h4 class="title"><a id="id1682012"></a>data</h4> 69 </div> 70 </div> 71 </div> 72 <p> 73 The <span class="bold"><strong>data</strong></span> parameter is the record to 74 write to the log. 75 </p> 76 <p> 77 The caller is responsible for providing any necessary structure to 78 <span class="bold"><strong>data</strong></span>. (For example, in a write-ahead 79 logging protocol, the application must understand what part of 80 <span class="bold"><strong>data</strong></span> is an operation code, what part 81 is redo information, and what part is undo information. In addition, 82 most transaction managers will store in <span class="bold"><strong>data</strong></span> the 83 <a class="link" href="lsn.html" title="Chapter 7. The DB_LSN Handle">DB_LSN</a> of the previous log 84 record for the same transaction, to support chaining back through the 85 transaction's log records during undo.) 86 </p> 87 </div> 88 <div class="sect3" lang="en" xml:lang="en"> 89 <div class="titlepage"> 90 <div> 91 <div> 92 <h4 class="title"><a id="id1682095"></a>flags</h4> 93 </div> 94 </div> 95 </div> 96 <p> 97 The <span class="bold"><strong>flags</strong></span> parameter must be set to 0 98 or the following value: 99 </p> 100 <div class="itemizedlist"> 101 <ul type="disc"> 102 <li> 103 <p><a id="put_DB_FLUSH"></a> 104 <code class="literal">DB_FLUSH</code> 105 </p> 106 <p> 107 The log is forced to disk after this record is written, guaranteeing 108 that all records with <a class="link" href="lsn.html" title="Chapter 7. The DB_LSN Handle">DB_LSN</a> 109 values less than or equal to the one being "put" are on disk 110 before <code class="methodname">DB_ENV->log_put()</code> returns. 111 </p> 112 </li> 113 </ul> 114 </div> 115 </div> 116 <div class="sect3" lang="en" xml:lang="en"> 117 <div class="titlepage"> 118 <div> 119 <div> 120 <h4 class="title"><a id="id1682220"></a>lsn</h4> 121 </div> 122 </div> 123 </div> 124 <p> 125 The <span class="bold"><strong>lsn</strong></span> parameter references memory 126 into which the <a class="link" href="lsn.html" title="Chapter 7. The DB_LSN Handle">DB_LSN</a> of 127 the put record is copied. 128 </p> 129 </div> 130 </div> 131 <div class="sect2" lang="en" xml:lang="en"> 132 <div class="titlepage"> 133 <div> 134 <div> 135 <h3 class="title"><a id="id1682360"></a>Errors</h3> 136 </div> 137 </div> 138 </div> 139 <p> 140 The <code class="methodname">DB_ENV->log_put()</code> <span> 141 <span> 142 method may fail and return one of the following non-zero errors: 143 </span> 144 145 </span> 146 </p> 147 <div class="sect3" lang="en" xml:lang="en"> 148 <div class="titlepage"> 149 <div> 150 <div> 151 <h4 class="title"><a id="id1681639"></a>EINVAL</h4> 152 </div> 153 </div> 154 </div> 155 <p> 156 If the record to be logged is larger than the maximum log record; or 157 if an invalid flag value or parameter was specified. 158 </p> 159 </div> 160 </div> 161 <div class="sect2" lang="en" xml:lang="en"> 162 <div class="titlepage"> 163 <div> 164 <div> 165 <h3 class="title"><a id="id1681640"></a>Class</h3> 166 </div> 167 </div> 168 </div> 169 <p> 170 <a class="link" href="env.html" title="Chapter 5. The DB_ENV Handle">DB_ENV</a>, 171 <a class="link" href="logc.html" title="The DB_LOGC Handle">DB_LOGC</a>, 172 <a class="link" href="lsn.html" title="Chapter 7. The DB_LSN Handle">DB_LSN</a> 173 </p> 174 </div> 175 <div class="sect2" lang="en" xml:lang="en"> 176 <div class="titlepage"> 177 <div> 178 <div> 179 <h3 class="title"><a id="id1682089"></a>See Also</h3> 180 </div> 181 </div> 182 </div> 183 <p> 184 <a class="xref" href="lsn.html#loglist" title="Logging Subsystem and Related Methods">Logging Subsystem and Related Methods</a> 185 </p> 186 </div> 187 </div> 188 <div class="navfooter"> 189 <hr /> 190 <table width="100%" summary="Navigation footer"> 191 <tr> 192 <td width="40%" align="left"><a accesskey="p" href="logprintf.html">Prev</a> </td> 193 <td width="20%" align="center"> 194 <a accesskey="u" href="lsn.html">Up</a> 195 </td> 196 <td width="40%" align="right"> <a accesskey="n" href="envlog_set_config.html">Next</a></td> 197 </tr> 198 <tr> 199 <td width="40%" align="left" valign="top">DB_ENV->log_printf() </td> 200 <td width="20%" align="center"> 201 <a accesskey="h" href="index.html">Home</a> 202 </td> 203 <td width="40%" align="right" valign="top"> DB_ENV->log_set_config()</td> 204 </tr> 205 </table> 206 </div> 207 </body> 208</html> 209