Debian Codegraph @

docs/api_reference/CXX/dbsync.html

raw symbols SCIP
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 &lt;db_cxx.h&gt;
42
43 int
44 Db::sync(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
71 <span>
72 method either returns a non-zero error value or throws an
73 exception that encapsulates a non-zero error value on
74 failure, and returns 0 on success.
75 </span>
76 </span>
77 </p>
78 <div class="sect2" lang="en" xml:lang="en">
79 <div class="titlepage">
80 <div>
81 <div>
82 <h3 class="title"><a id="idp5957344"></a>Parameters</h3>
83 </div>
84 </div>
85 </div>
86 <div class="sect3" lang="en" xml:lang="en">
87 <div class="titlepage">
88 <div>
89 <div>
90 <h4 class="title"><a id="idp5903880"></a>flags</h4>
91 </div>
92 </div>
93 </div>
94 <p>
95 The <span class="bold"><strong>flags</strong></span> parameter is currently
96 unused, and must be set to 0.
97 </p>
98 </div>
99 </div>
100 <div class="sect2" lang="en" xml:lang="en">
101 <div class="titlepage">
102 <div>
103 <div>
104 <h3 class="title"><a id="idp5975448"></a>Errors</h3>
105 </div>
106 </div>
107 </div>
108 <p>
109 The <code class="methodname">Db::sync()</code> <span>
110
111 <span>
112 method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a>
113 exception, encapsulating one of the following non-zero errors, or return one
114 of the following non-zero errors:
115 </span>
116 </span>
117 </p>
118 <div class="sect3" lang="en" xml:lang="en">
119 <div class="titlepage">
120 <div>
121 <div>
122 <h4 class="title"><a id="idp5987040"></a> <span>DbRepHandleDeadException or</span> DB_REP_HANDLE_DEAD</h4>
123 </div>
124 </div>
125 </div>
126 <p>
127 When a client synchronizes with the master, it is possible for committed
128 transactions to be rolled back. This invalidates all the database and cursor
129 handles opened in the replication environment. Once this occurs, an attempt to use
130 such a handle will
131 <span>
132 throw a <a class="xref" href="dbrephandledead.html" title="DbRepHandleDeadException">DbRepHandleDeadException</a> (if
133 your application is configured to throw exceptions), or
134 </span>
135 return <code class="literal">DB_REP_HANDLE_DEAD</code>.
136 The application will need to discard the handle and open a new one in order to
137 continue processing.
138 </p>
139 </div>
140 <div class="sect3" lang="en" xml:lang="en">
141 <div class="titlepage">
142 <div>
143 <div>
144 <h4 class="title"><a id="idp5972824"></a><span>DbDeadlockException or </span>DB_REP_LOCKOUT</h4>
145 </div>
146 </div>
147 </div>
148 <p>
149 The operation was blocked by client/master synchronization.
150 </p>
151 <p>
152 <a class="xref" href="dbdeadlock.html" title="DbDeadlockException">DbDeadlockException</a> is thrown if
153 your Berkeley DB API is configured to throw exceptions.
154 Otherwise, <code class="literal">DB_REP_LOCKOUT</code> is returned.
155 </p>
156 </div>
157 <div class="sect3" lang="en" xml:lang="en">
158 <div class="titlepage">
159 <div>
160 <div>
161 <h4 class="title"><a id="idp5989072"></a>EINVAL</h4>
162 </div>
163 </div>
164 </div>
165 <p>
166 An invalid flag value or parameter was specified.
167 </p>
168 </div>
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="idp5959488"></a>Class</h3>
175 </div>
176 </div>
177 </div>
178 <p>
179 <a class="link" href="db.html" title="Chapter 2.  The Db Handle">Db</a>
180 </p>
181 </div>
182 <div class="sect2" lang="en" xml:lang="en">
183 <div class="titlepage">
184 <div>
185 <div>
186 <h3 class="title"><a id="idp5964200"></a>See Also</h3>
187 </div>
188 </div>
189 </div>
190 <p>
191 <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a>
192 </p>
193 </div>
194 </div>
195 <div class="navfooter">
196 <hr />
197 <table width="100%" summary="Navigation footer">
198 <tr>
199 <td width="40%" align="left"><a accesskey="p" href="dbstat_print.html">Prev</a> </td>
200 <td width="20%" align="center">
201 <a accesskey="u" href="db.html">Up</a>
202 </td>
203 <td width="40%" align="right"> <a accesskey="n" href="dbtruncate.html">Next</a></td>
204 </tr>
205 <tr>
206 <td width="40%" align="left" valign="top">Db::stat_print() </td>
207 <td width="20%" align="center">
208 <a accesskey="h" href="index.html">Home</a>
209 </td>
210 <td width="40%" align="right" valign="top"> Db::truncate()</td>
211 </tr>
212 </table>
213 </div>
214 </body>
215 </html>