libdb/docs/api_reference/C/dbsync.html
2011-09-13 13:44:24 -04:00

203 lines
7.6 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>DB-&gt;sync()</title>
<link rel="stylesheet" href="apiReference.css" type="text/css" />
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
<link rel="start" href="index.html" title="Berkeley DB C API Reference" />
<link rel="up" href="db.html" title="Chapter 2.  The DB Handle" />
<link rel="prev" href="dbstat_print.html" title="DB-&gt;stat_print()" />
<link rel="next" href="dbtruncate.html" title="DB-&gt;truncate()" />
</head>
<body>
<div xmlns="" class="navheader">
<div class="libver">
<p>Library Version 11.2.5.2</p>
</div>
<table width="100%" summary="Navigation header">
<tr>
<th colspan="3" align="center">DB-&gt;sync()</th>
</tr>
<tr>
<td width="20%" align="left"><a accesskey="p" href="dbstat_print.html">Prev</a> </td>
<th width="60%" align="center">Chapter 2. 
The DB Handle
</th>
<td width="20%" align="right"> <a accesskey="n" href="dbtruncate.html">Next</a></td>
</tr>
</table>
<hr />
</div>
<div class="sect1" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both"><a id="dbsync"></a>DB-&gt;sync()</h2>
</div>
</div>
</div>
<pre class="programlisting">#include &lt;db.h&gt;
int
DB-&gt;sync(DB *db, u_int32_t flags); </pre>
<p>
The <code class="methodname">DB-&gt;sync()</code> method flushes any cached information to disk.
This method operates on the database file level, so if the file
contains multiple database handles then this method will flush to
disk any information that is cached for any of those handles.
</p>
<p>
If the database is in memory only, the <code class="methodname">DB-&gt;sync()</code> method has no
effect and will always succeed.
</p>
<p>
<span class="bold"><strong>It is important to understand that flushing
cached information to disk only minimizes the window of opportunity
for corrupted data.</strong></span> 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 class="xref" href="dbclose.html" title="DB-&gt;close()">DB-&gt;close()</a>, atomically
replace the original database with the updated copy.
</p>
<p>
The <code class="methodname">DB-&gt;sync()</code> <span>
<span>
method returns a non-zero error value on failure and 0 on success.
</span>
</span>
</p>
<div class="sect2" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a id="id3874748"></a>Parameters</h3>
</div>
</div>
</div>
<div class="sect3" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a id="id3874737"></a>flags</h4>
</div>
</div>
</div>
<p>
The <span class="bold"><strong>flags</strong></span> parameter is currently
unused, and must be set to 0.
</p>
</div>
</div>
<div class="sect2" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a id="id3873529"></a>Errors</h3>
</div>
</div>
</div>
<p>
The <code class="methodname">DB-&gt;sync()</code> <span>
<span>
method may fail and return one of the following non-zero errors:
</span>
</span>
</p>
<div class="sect3" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a id="id3874308"></a> DB_REP_HANDLE_DEAD</h4>
</div>
</div>
</div>
<p>
When a client synchronizes with the master, it is possible for committed
transactions to be rolled back. This invalidates all the database and cursor
handles opened in the replication environment. Once this occurs, an attempt to use
such a handle will
return <code class="literal">DB_REP_HANDLE_DEAD</code>.
The application will need to discard the handle and open a new one in order to
continue processing.
</p>
</div>
<div class="sect3" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a id="id3874733"></a>DB_REP_LOCKOUT</h4>
</div>
</div>
</div>
<p>
The operation was blocked by client/master synchronization.
</p>
</div>
<div class="sect3" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a id="id3874899"></a>EINVAL</h4>
</div>
</div>
</div>
<p>
An invalid flag value or parameter was specified.
</p>
</div>
</div>
<div class="sect2" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a id="id3874732"></a>Class</h3>
</div>
</div>
</div>
<p>
<a class="link" href="db.html" title="Chapter 2.  The DB Handle">DB</a>
</p>
</div>
<div class="sect2" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a id="id3874809"></a>See Also</h3>
</div>
</div>
</div>
<p>
<a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a>
</p>
</div>
</div>
<div class="navfooter">
<hr />
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left"><a accesskey="p" href="dbstat_print.html">Prev</a> </td>
<td width="20%" align="center">
<a accesskey="u" href="db.html">Up</a>
</td>
<td width="40%" align="right"> <a accesskey="n" href="dbtruncate.html">Next</a></td>
</tr>
<tr>
<td width="40%" align="left" valign="top">DB-&gt;stat_print() </td>
<td width="20%" align="center">
<a accesskey="h" href="index.html">Home</a>
</td>
<td width="40%" align="right" valign="top"> DB-&gt;truncate()</td>
</tr>
</table>
</div>
</body>
</html>