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::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::sync</b>
14</td>
15<td align=right>
16<a href="/api_cxx/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_cxx.h&gt;
23<p>
24int
25Db::sync(u_int32_t flags);
26</pre></b>
27<hr size=1 noshade>
28<b>Description: Db::sync</b>
29<p>The Db::sync method flushes any cached information to disk.</p>
30<p>If the database is in memory only, the Db::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_cxx/db_close.html">Db::close</a>, atomically replace the original database with the
41updated copy.</p>
42<p>The Db::sync method
43either returns a non-zero error value
44or throws an exception that encapsulates a non-zero error value on
45failure, and returns 0 on success.
46</p>
47<b>Parameters</b> <br>
48 <b>flags</b><ul compact><li>The <b>flags</b> parameter is currently unused, and must be set to 0.</ul>
49<br>
50<br><b>Errors</b>
51<p>The Db::sync method
52may fail and throw
53<a href="/api_cxx/except_class.html">DbException</a>,
54encapsulating one of the following non-zero errors, or return one of
55the following non-zero errors:</p>
56<br>
57<b>DB_REP_HANDLE_DEAD</b><ul compact><li>The database handle has been invalidated because a replication election
58unrolled a committed transaction.</ul>
59<br>
60<br>
61<b>DB_REP_LOCKOUT</b><ul compact><li>The operation was blocked by client/master synchronization.</ul>
62<br>
63<br>
64<b>EINVAL</b><ul compact><li>An
65invalid flag value or parameter was specified.</ul>
66<br>
67<hr size=1 noshade>
68<br><b>Class</b>
69<a href="/api_cxx/db_class.html">Db</a>
70<br><b>See Also</b>
71<a href="/api_cxx/db_list.html">Databases and Related Methods</a>
72</tt>
73<table width="100%"><tr><td><br></td><td align=right>
74<a href="/api_cxx/api_core.html"><img src="/images/api.gif" alt="API"></a><a href="/ref/toc.html"><img src="/images/ref.gif" alt="Ref"></a>
75</td></tr></table>
76<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
77</body>
78</html>
79