• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src/router/db-4.8.30/docs/api_reference/CXX/
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::upgrade()</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="dbtruncate.html" title="Db::truncate()" />
12    <link rel="next" href="dbverify.html" title="Db::verify()" />
13  </head>
14  <body>
15    <div class="navheader">
16      <table width="100%" summary="Navigation header">
17        <tr>
18          <th colspan="3" align="center">Db::upgrade()</th>
19        </tr>
20        <tr>
21          <td width="20%" align="left"><a accesskey="p" href="dbtruncate.html">Prev</a> </td>
22          <th width="60%" align="center">Chapter 2. 
23                The Db Handle
24        </th>
25          <td width="20%" align="right"> <a accesskey="n" href="dbverify.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="dbupgrade"></a>Db::upgrade()</h2>
35          </div>
36        </div>
37      </div>
38      <pre class="programlisting">#include &lt;db_cxx.h&gt;
39 
40int
41Db::upgrade(const char *file, u_int32_t flags);</pre>
42      <p>
43         The <code class="methodname">Db::upgrade()</code> method upgrades all of the databases included in
44         the file <span class="bold"><strong>file</strong></span>, if necessary.  If no
45         upgrade is necessary, <code class="methodname">Db::upgrade()</code> always returns success.
46    </p>
47      <p>
48         <span class="bold"><strong>Database upgrades are done in place and are
49         destructive. For example, if pages need to be allocated and no disk
50         space is available, the database may be left corrupted.  Backups
51         should be made before databases are upgraded.  See <a href="../../programmer_reference/am_upgrade.html" class="olink">Upgrading databases</a> for more
52         information.</strong></span>
53    </p>
54      <p>
55         Unlike all other database operations, <code class="methodname">Db::upgrade()</code> may only be done
56         on a system with the same byte-order as the database.
57    </p>
58      <p>
59         The <code class="methodname">Db::upgrade()</code> <span>
60            
61            <span>
62                method either returns a non-zero error value or throws an
63                exception that encapsulates a non-zero error value on
64                failure, and returns 0 on success.
65            </span>
66        </span>
67    </p>
68      <div class="sect2" lang="en" xml:lang="en">
69        <div class="titlepage">
70          <div>
71            <div>
72              <h3 class="title"><a id="id1653469"></a>Parameters</h3>
73            </div>
74          </div>
75        </div>
76        <div class="sect3" lang="en" xml:lang="en">
77          <div class="titlepage">
78            <div>
79              <div>
80                <h4 class="title"><a id="id1653666"></a>file</h4>
81              </div>
82            </div>
83          </div>
84          <p>
85                          The <span class="bold"><strong>file</strong></span> parameter is the physical
86                          file containing the databases to be upgraded.
87                     </p>
88        </div>
89        <div class="sect3" lang="en" xml:lang="en">
90          <div class="titlepage">
91            <div>
92              <div>
93                <h4 class="title"><a id="id1653652"></a>flags</h4>
94              </div>
95            </div>
96          </div>
97          <p>
98                          The <span class="bold"><strong>flags</strong></span> parameter must be set to 0
99                          or the following value:
100                     </p>
101          <div class="itemizedlist">
102            <ul type="disc">
103              <li>
104                <p><a id="upgrade_DB_DUPSORT"></a>
105                  <code class="literal">DB_DUPSORT</code>
106            </p>
107                <p>
108                 <span class="bold"><strong>This flag is only meaningful when upgrading
109                 databases from releases before the Berkeley DB 3.1 release.</strong></span>
110            </p>
111                <p>
112                 As part of the upgrade from the Berkeley DB 3.0 release to the 3.1
113                 release, the on-disk format of duplicate data items changed.  To
114                 correctly upgrade the format requires applications to specify whether
115                 duplicate data items in the database are sorted or not.  Specifying
116                 the DB_DUPSORT flag informs <code class="methodname">Db::upgrade()</code> that the duplicates are
117                 sorted; otherwise they are assumed to be unsorted.  Incorrectly
118                 specifying the value of this flag may lead to database corruption.
119            </p>
120                <p>
121                 Further, because the <code class="methodname">Db::upgrade()</code> method upgrades a physical file
122                 (including all the databases it contains), it is not possible to use
123                 <code class="methodname">Db::upgrade()</code> to upgrade files in which some of the databases it
124                 includes have sorted duplicate data items, and some of the databases
125                 it includes have unsorted duplicate data items.  If the file does not
126                 have more than a single database, if the databases do not support
127                 duplicate data items, or if all of the databases that support
128                 duplicate data items support the same style of duplicates (either
129                 sorted or unsorted), <code class="methodname">Db::upgrade()</code> will work correctly as long as the
130                 DB_DUPSORT flag is correctly specified.  Otherwise, the file cannot be
131                 upgraded using <code class="methodname">Db::upgrade;()</code> it must be upgraded manually by dumping
132                 and reloading the databases.
133            </p>
134              </li>
135            </ul>
136          </div>
137        </div>
138      </div>
139      <div class="sect2" lang="en" xml:lang="en">
140        <div class="titlepage">
141          <div>
142            <div>
143              <h3 class="title"><a id="id1653943"></a>Environment Variables</h3>
144            </div>
145          </div>
146        </div>
147        <p>
148                         If the database was opened within a database environment, the
149                         environment variable <code class="literal">DB_HOME</code> may be used as the path of the
150                         database environment home.
151                    </p>
152        <p>
153                            <code class="methodname">Db::upgrade()</code> is affected by any database directory specified using the
154                            <a class="xref" href="envset_data_dir.html" title="DbEnv::set_data_dir()">DbEnv::set_data_dir()</a>
155                            method, or by setting the "set_data_dir" string in the environment's
156                            <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a>
157                            file.
158                    </p>
159      </div>
160      <div class="sect2" lang="en" xml:lang="en">
161        <div class="titlepage">
162          <div>
163            <div>
164              <h3 class="title"><a id="id1653948"></a>Errors</h3>
165            </div>
166          </div>
167        </div>
168        <p>
169                         The <code class="methodname">Db::upgrade()</code> <span>
170            
171            <span>
172                method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a> 
173                exception, encapsulating one of the following non-zero errors, or return one
174                of the following non-zero errors:
175            </span>
176        </span>
177                    </p>
178        <div class="sect3" lang="en" xml:lang="en">
179          <div class="titlepage">
180            <div>
181              <div>
182                <h4 class="title"><a id="id1653951"></a>DB_OLD_VERSION</h4>
183              </div>
184            </div>
185          </div>
186          <p>
187                             The database cannot be upgraded by this version of the Berkeley DB
188                             software.
189                        </p>
190        </div>
191      </div>
192      <div class="sect2" lang="en" xml:lang="en">
193        <div class="titlepage">
194          <div>
195            <div>
196              <h3 class="title"><a id="id1653657"></a>Class</h3>
197            </div>
198          </div>
199        </div>
200        <p>
201                <a class="link" href="db.html" title="Chapter 2.  The Db Handle">Db</a>  
202            </p>
203      </div>
204      <div class="sect2" lang="en" xml:lang="en">
205        <div class="titlepage">
206          <div>
207            <div>
208              <h3 class="title"><a id="id1653723"></a>See Also</h3>
209            </div>
210          </div>
211        </div>
212        <p>
213                     <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a> 
214                </p>
215      </div>
216    </div>
217    <div class="navfooter">
218      <hr />
219      <table width="100%" summary="Navigation footer">
220        <tr>
221          <td width="40%" align="left"><a accesskey="p" href="dbtruncate.html">Prev</a> </td>
222          <td width="20%" align="center">
223            <a accesskey="u" href="db.html">Up</a>
224          </td>
225          <td width="40%" align="right"> <a accesskey="n" href="dbverify.html">Next</a></td>
226        </tr>
227        <tr>
228          <td width="40%" align="left" valign="top">Db::truncate() </td>
229          <td width="20%" align="center">
230            <a accesskey="h" href="index.html">Home</a>
231          </td>
232          <td width="40%" align="right" valign="top"> Db::verify()</td>
233        </tr>
234      </table>
235    </div>
236  </body>
237</html>
238