| 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->sync()</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="db.html" title="Chapter 2. The DB Handle" /> |
| 11 | <link rel="prev" href="dbstat_print.html" title="DB->stat_print()" /> |
| 12 | <link rel="next" href="dbtruncate.html" title="DB->truncate()" /> |
| 13 | </head> |
| 14 | <body> |
| 15 | <div xmlns="" class="navheader"> |
| 16 | <div class="libver"> |
| 17 | <p>Library Version 11.2.5.3</p> |
| 18 | </div> |
| 19 | <table width="100%" summary="Navigation header"> |
| 20 | <tr> |
| 21 | <th colspan="3" align="center">DB->sync()</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="dbstat_print.html">Prev</a> </td> |
| 25 | <th width="60%" align="center">Chapter 2. |
| 26 | The DB Handle |
| 27 | </th> |
| 28 | <td width="20%" align="right"> <a accesskey="n" href="dbtruncate.html">Next</a></td> |
| 29 | </tr> |
| 30 | </table> |
| 31 | <hr /> |
| 32 | </div> |
| 33 | <div class="sect1" lang="en" xml:lang="en"> |
| 34 | <div class="titlepage"> |
| 35 | <div> |
| 36 | <div> |
| 37 | <h2 class="title" style="clear: both"><a id="dbsync"></a>DB->sync()</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <pre class="programlisting">#include <db.h> |
| 42 | |
| 43 | int |
| 44 | DB->sync(DB *db, u_int32_t flags); </pre> |
| 45 | <p> |
| 46 | The <code class="methodname">DB->sync()</code> method flushes any cached information to disk. |
| 47 | This method operates on the database file level, so if the file |
| 48 | contains multiple database handles then this method will flush to |
| 49 | disk any information that is cached for any of those handles. |
| 50 | </p> |
| 51 | <p> |
| 52 | If the database is in memory only, the <code class="methodname">DB->sync()</code> method has no |
| 53 | effect and will always succeed. |
| 54 | </p> |
| 55 | <p> |
| 56 | <span class="bold"><strong>It is important to understand that flushing |
| 57 | cached information to disk only minimizes the window of opportunity |
| 58 | for corrupted data.</strong></span> Although unlikely, it is possible for |
| 59 | database corruption to happen if a system or application crash occurs |
| 60 | while writing data to the database. To ensure that database |
| 61 | corruption never occurs, applications must either: use transactions |
| 62 | and logging with automatic recovery; use logging and |
| 63 | application-specific recovery; or edit a copy of the database, and |
| 64 | once all applications using the database have successfully called |
| 65 | <a class="xref" href="dbclose.html" title="DB->close()">DB->close()</a>, atomically |
| 66 | replace the original database with the updated copy. |
| 67 | </p> |
| 68 | <p> |
| 69 | The <code class="methodname">DB->sync()</code> <span> |
| 70 | <span> |
| 71 | method returns a non-zero error value on failure and 0 on success. |
| 72 | </span> |
| 73 | |
| 74 | </span> |
| 75 | </p> |
| 76 | <div class="sect2" lang="en" xml:lang="en"> |
| 77 | <div class="titlepage"> |
| 78 | <div> |
| 79 | <div> |
| 80 | <h3 class="title"><a id="idp50671976"></a>Parameters</h3> |
| 81 | </div> |
| 82 | </div> |
| 83 | </div> |
| 84 | <div class="sect3" lang="en" xml:lang="en"> |
| 85 | <div class="titlepage"> |
| 86 | <div> |
| 87 | <div> |
| 88 | <h4 class="title"><a id="idp50712344"></a>flags</h4> |
| 89 | </div> |
| 90 | </div> |
| 91 | </div> |
| 92 | <p> |
| 93 | The <span class="bold"><strong>flags</strong></span> parameter is currently |
| 94 | unused, and must be set to 0. |
| 95 | </p> |
| 96 | </div> |
| 97 | </div> |
| 98 | <div class="sect2" lang="en" xml:lang="en"> |
| 99 | <div class="titlepage"> |
| 100 | <div> |
| 101 | <div> |
| 102 | <h3 class="title"><a id="idp50705744"></a>Errors</h3> |
| 103 | </div> |
| 104 | </div> |
| 105 | </div> |
| 106 | <p> |
| 107 | The <code class="methodname">DB->sync()</code> <span> |
| 108 | <span> |
| 109 | method may fail and return one of the following non-zero errors: |
| 110 | </span> |
| 111 | |
| 112 | </span> |
| 113 | </p> |
| 114 | <div class="sect3" lang="en" xml:lang="en"> |
| 115 | <div class="titlepage"> |
| 116 | <div> |
| 117 | <div> |
| 118 | <h4 class="title"><a id="idp50635984"></a> DB_REP_HANDLE_DEAD</h4> |
| 119 | </div> |
| 120 | </div> |
| 121 | </div> |
| 122 | <p> |
| 123 | When a client synchronizes with the master, it is possible for committed |
| 124 | transactions to be rolled back. This invalidates all the database and cursor |
| 125 | handles opened in the replication environment. Once this occurs, an attempt to use |
| 126 | such a handle will |
| 127 | |
| 128 | return <code class="literal">DB_REP_HANDLE_DEAD</code>. |
| 129 | The application will need to discard the handle and open a new one in order to |
| 130 | continue processing. |
| 131 | </p> |
| 132 | </div> |
| 133 | <div class="sect3" lang="en" xml:lang="en"> |
| 134 | <div class="titlepage"> |
| 135 | <div> |
| 136 | <div> |
| 137 | <h4 class="title"><a id="idp50712128"></a>DB_REP_LOCKOUT</h4> |
| 138 | </div> |
| 139 | </div> |
| 140 | </div> |
| 141 | <p> |
| 142 | The operation was blocked by client/master synchronization. |
| 143 | </p> |
| 144 | </div> |
| 145 | <div class="sect3" lang="en" xml:lang="en"> |
| 146 | <div class="titlepage"> |
| 147 | <div> |
| 148 | <div> |
| 149 | <h4 class="title"><a id="idp50637776"></a>EINVAL</h4> |
| 150 | </div> |
| 151 | </div> |
| 152 | </div> |
| 153 | <p> |
| 154 | An invalid flag value or parameter was specified. |
| 155 | </p> |
| 156 | </div> |
| 157 | </div> |
| 158 | <div class="sect2" lang="en" xml:lang="en"> |
| 159 | <div class="titlepage"> |
| 160 | <div> |
| 161 | <div> |
| 162 | <h3 class="title"><a id="idp50696280"></a>Class</h3> |
| 163 | </div> |
| 164 | </div> |
| 165 | </div> |
| 166 | <p> |
| 167 | <a class="link" href="db.html" title="Chapter 2. The DB Handle">DB</a> |
| 168 | </p> |
| 169 | </div> |
| 170 | <div class="sect2" lang="en" xml:lang="en"> |
| 171 | <div class="titlepage"> |
| 172 | <div> |
| 173 | <div> |
| 174 | <h3 class="title"><a id="idp50716688"></a>See Also</h3> |
| 175 | </div> |
| 176 | </div> |
| 177 | </div> |
| 178 | <p> |
| 179 | <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a> |
| 180 | </p> |
| 181 | </div> |
| 182 | </div> |
| 183 | <div class="navfooter"> |
| 184 | <hr /> |
| 185 | <table width="100%" summary="Navigation footer"> |
| 186 | <tr> |
| 187 | <td width="40%" align="left"><a accesskey="p" href="dbstat_print.html">Prev</a> </td> |
| 188 | <td width="20%" align="center"> |
| 189 | <a accesskey="u" href="db.html">Up</a> |
| 190 | </td> |
| 191 | <td width="40%" align="right"> <a accesskey="n" href="dbtruncate.html">Next</a></td> |
| 192 | </tr> |
| 193 | <tr> |
| 194 | <td width="40%" align="left" valign="top">DB->stat_print() </td> |
| 195 | <td width="20%" align="center"> |
| 196 | <a accesskey="h" href="index.html">Home</a> |
| 197 | </td> |
| 198 | <td width="40%" align="right" valign="top"> DB->truncate()</td> |
| 199 | </tr> |
| 200 | </table> |
| 201 | </div> |
| 202 | </body> |
| 203 | </html> |