db_sync.html   [plain text]


<!--$Id: db_sync.so,v 10.37 2007/10/24 16:06:06 bostic Exp $-->
<!--Copyright (c) 1997,2008 Oracle.  All rights reserved.-->
<!--See the file LICENSE for redistribution information.-->
<html>
<head>
<title>Berkeley DB: Db::sync</title>
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
</head>
<body bgcolor=white>
<table width="100%"><tr valign=top>
<td>
<b>Db::sync</b>
</td>
<td align=right>
<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></td>
</tr></table>
<hr size=1 noshade>
<tt>
<b><pre>
#include &lt;db_cxx.h&gt;
<p>
int
Db::sync(u_int32_t flags);
</pre></b>
<hr size=1 noshade>
<b>Description: Db::sync</b>
<p>The Db::sync method flushes any cached information to disk.</p>
<p>If the database is in memory only, the Db::sync method has no effect and
will always succeed.</p>
<p><b>It is important to understand that flushing cached information to disk
only minimizes the window of opportunity for corrupted data.</b> Although
unlikely, it is possible for database corruption to happen if a system
or application crash occurs while writing data to the database.  To
ensure that database corruption never occurs, applications must either:
use transactions and logging with automatic recovery; use logging and
application-specific recovery; or edit a copy of the database, and once
all applications using the database have successfully called
<a href="../api_cxx/db_close.html">Db::close</a>, atomically replace the original database with the
updated copy.</p>
<p>The Db::sync method
either returns a non-zero error value
or throws an exception that encapsulates a non-zero error value on
failure, and returns 0 on success.
</p>
<b>Parameters</b> <br>
 <b>flags</b><ul compact><li>The <b>flags</b> parameter is currently unused, and must be set to 0.</ul>
<br>
<br><b>Errors</b>
<p>The Db::sync method
may fail and throw
<a href="../api_cxx/except_class.html">DbException</a>,
encapsulating one of the following non-zero errors, or return one of
the following non-zero errors:</p>
<br>
<b>DB_REP_HANDLE_DEAD</b><ul compact><li>The database handle has been invalidated because a replication election
unrolled a committed transaction.</ul>
<br>
<br>
<b>DB_REP_LOCKOUT</b><ul compact><li>The operation was blocked by client/master synchronization.</ul>
<br>
<br>
<b>EINVAL</b><ul compact><li>An
invalid flag value or parameter was specified.</ul>
<br>
<hr size=1 noshade>
<br><b>Class</b>
<a href="../api_cxx/db_class.html">Db</a>
<br><b>See Also</b>
<a href="../api_cxx/db_list.html">Databases and Related Methods</a>
</tt>
<table width="100%"><tr><td><br></td><td align=right>
<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>
</td></tr></table>
<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
</body>
</html>