• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/router/db-4.8.30/docs/programmer_reference/
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>Database close</title>
7    <link rel="stylesheet" href="gettingStarted.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 Programmer's Reference Guide" />
10    <link rel="up" href="am.html" title="Chapter��3.�� Access Method Operations" />
11    <link rel="prev" href="am_sync.html" title="Flushing the database cache" />
12    <link rel="next" href="am_second.html" title="Secondary indexes" />
13  </head>
14  <body>
15    <div class="navheader">
16      <table width="100%" summary="Navigation header">
17        <tr>
18          <th colspan="3" align="center">Database close</th>
19        </tr>
20        <tr>
21          <td width="20%" align="left"><a accesskey="p" href="am_sync.html">Prev</a>��</td>
22          <th width="60%" align="center">Chapter��3.��
23		Access Method Operations
24        </th>
25          <td width="20%" align="right">��<a accesskey="n" href="am_second.html">Next</a></td>
26        </tr>
27      </table>
28      <hr />
29    </div>
30    <div class="sect1" lang="en" xml:lang="en">
31      <div class="titlepage">
32        <div>
33          <div>
34            <h2 class="title" style="clear: both"><a id="am_close"></a>Database close</h2>
35          </div>
36        </div>
37      </div>
38      <p>The <a href="../api_reference/C/dbclose.html" class="olink">DB-&gt;close()</a> database handle closes the <a href="../api_reference/C/db.html" class="olink">DB</a> handle.  By
39default, <a href="../api_reference/C/dbclose.html" class="olink">DB-&gt;close()</a> also flushes all modified records from the
40database cache to disk.</p>
41      <p>There is one flag that you can set to customize <a href="../api_reference/C/dbclose.html" class="olink">DB-&gt;close()</a>:</p>
42      <div class="variablelist">
43        <dl>
44          <dt>
45            <span class="term">
46              <a href="../api_reference/C/dbclose.html#dbclose_DB_NOSYNC" class="olink">DB_NOSYNC</a>
47            </span>
48          </dt>
49          <dd>Do not flush cached information to disk.</dd>
50        </dl>
51      </div>
52      <span class="bold">
53        <strong>It is important to understand that flushing cached information
54to disk only minimizes the window of opportunity for corrupted data, it
55does not eliminate the possibility.</strong>
56      </span>
57      <p>While unlikely, it is possible for database corruption to happen if a
58system or application crash occurs while writing data to the database. To
59ensure that database corruption never occurs, applications must either:</p>
60      <div class="itemizedlist">
61        <ul type="disc">
62          <li>Use transactions and logging with automatic recovery.</li>
63          <li>Use logging and application-specific recovery.</li>
64          <li>Edit a copy of the database, and, once all applications
65using the database have successfully called <a href="../api_reference/C/dbclose.html" class="olink">DB-&gt;close()</a>, use
66system operations (for example, the POSIX rename system call) to
67atomically replace the original database with the updated copy.</li>
68        </ul>
69      </div>
70    </div>
71    <div class="navfooter">
72      <hr />
73      <table width="100%" summary="Navigation footer">
74        <tr>
75          <td width="40%" align="left"><a accesskey="p" href="am_sync.html">Prev</a>��</td>
76          <td width="20%" align="center">
77            <a accesskey="u" href="am.html">Up</a>
78          </td>
79          <td width="40%" align="right">��<a accesskey="n" href="am_second.html">Next</a></td>
80        </tr>
81        <tr>
82          <td width="40%" align="left" valign="top">Flushing the database cache��</td>
83          <td width="20%" align="center">
84            <a accesskey="h" href="index.html">Home</a>
85          </td>
86          <td width="40%" align="right" valign="top">��Secondary indexes</td>
87        </tr>
88      </table>
89    </div>
90  </body>
91</html>
92