1<!--$Id: db_sync.so,v 10.37 2007/10/24 16:06:06 bostic Exp $-->
2<!--Copyright (c) 1997,2008 Oracle.  All rights reserved.-->
3<!--See the file LICENSE for redistribution information.-->
4<html>
5<head>
6<title>Berkeley DB: DB-&gt;sync</title>
7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
9</head>
10<body bgcolor=white>
11<table width="100%"><tr valign=top>
12<td>
13<b>DB-&gt;sync</b>
14</td>
15<td align=right>
16<a href="../api_c/api_core.html"><img src="../images/api.gif" alt="API"></a>
17<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td>
18</tr></table>
19<hr size=1 noshade>
20<tt>
21<b><pre>
22#include &lt;db.h&gt;
23<p>
24int
25DB-&gt;sync(DB *db, u_int32_t flags);
26</pre></b>
27<hr size=1 noshade>
28<b>Description: DB-&gt;sync</b>
29<p>The DB-&gt;sync method flushes any cached information to disk.</p>
30<p>If the database is in memory only, the DB-&gt;sync method has no effect and
31will always succeed.</p>
32<p><b>It is important to understand that flushing cached information to disk
33only minimizes the window of opportunity for corrupted data.</b> Although
34unlikely, it is possible for database corruption to happen if a system
35or application crash occurs while writing data to the database.  To
36ensure that database corruption never occurs, applications must either:
37use transactions and logging with automatic recovery; use logging and
38application-specific recovery; or edit a copy of the database, and once
39all applications using the database have successfully called
40<a href="../api_c/db_close.html">DB-&gt;close</a>, atomically replace the original database with the
41updated copy.</p>
42<p>The DB-&gt;sync method
43returns a non-zero error value on failure
44and 0 on success.
45</p>
46<b>Parameters</b> <br>
47 <b>flags</b><ul compact><li>The <b>flags</b> parameter is currently unused, and must be set to 0.</ul>
48<br>
49<br><b>Errors</b>
50<p>The DB-&gt;sync method
51may fail and return one of the following non-zero errors:</p>
52<br>
53<b>DB_REP_HANDLE_DEAD</b><ul compact><li>The database handle has been invalidated because a replication election
54unrolled a committed transaction.</ul>
55<br>
56<br>
57<b>DB_REP_LOCKOUT</b><ul compact><li>The operation was blocked by client/master synchronization.</ul>
58<br>
59<br>
60<b>EINVAL</b><ul compact><li>An
61invalid flag value or parameter was specified.</ul>
62<br>
63<hr size=1 noshade>
64<br><b>Class</b>
65<a href="../api_c/db_class.html">DB</a>
66<br><b>See Also</b>
67<a href="../api_c/db_list.html">Databases and Related Methods</a>
68</tt>
69<table width="100%"><tr><td><br></td><td align=right>
70<a href="../api_c/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a>
71</td></tr></table>
72<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
73</body>
74</html>
75