• 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/api_reference/C/
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-&gt;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-&gt;truncate()" />
12    <link rel="next" href="dbverify.html" title="DB-&gt;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-&gt;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-&gt;upgrade()</h2>
35          </div>
36        </div>
37      </div>
38      <pre class="programlisting">#include &lt;db.h&gt;
39
40int
41DB-&gt;upgrade(DB *db, const char *file, u_int32_t flags);  </pre>
42      <p>
43         The <code class="methodname">DB-&gt;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-&gt;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-&gt;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-&gt;upgrade()</code> <span>
60            <span>
61                  method returns a non-zero error value on failure and 0 on success.
62            </span>
63            
64        </span>
65    </p>
66      <p>
67         The <code class="methodname">DB-&gt;upgrade()</code> method is the underlying method used by the <a class="link" href="db_upgrade.html" title="db_upgrade">db_upgrade</a> utility. See the
68         <a class="link" href="db_upgrade.html" title="db_upgrade">db_upgrade</a> utility
69         source code for an example of using <code class="methodname">DB-&gt;upgrade()</code> in a IEEE/ANSI Std
70         1003.1 (POSIX) environment.
71    </p>
72      <div class="sect2" lang="en" xml:lang="en">
73        <div class="titlepage">
74          <div>
75            <div>
76              <h3 class="title"><a id="id1652465"></a>Parameters</h3>
77            </div>
78          </div>
79        </div>
80        <div class="sect3" lang="en" xml:lang="en">
81          <div class="titlepage">
82            <div>
83              <div>
84                <h4 class="title"><a id="id1652202"></a>file</h4>
85              </div>
86            </div>
87          </div>
88          <p>
89                          The <span class="bold"><strong>file</strong></span> parameter is the physical
90                          file containing the databases to be upgraded.
91                     </p>
92        </div>
93        <div class="sect3" lang="en" xml:lang="en">
94          <div class="titlepage">
95            <div>
96              <div>
97                <h4 class="title"><a id="id1652203"></a>flags</h4>
98              </div>
99            </div>
100          </div>
101          <p>
102                          The <span class="bold"><strong>flags</strong></span> parameter must be set to 0
103                          or the following value:
104                     </p>
105          <div class="itemizedlist">
106            <ul type="disc">
107              <li>
108                <p><a id="upgrade_DB_DUPSORT"></a>
109                  <code class="literal">DB_DUPSORT</code>
110            </p>
111                <p>
112                 <span class="bold"><strong>This flag is only meaningful when upgrading
113                 databases from releases before the Berkeley DB 3.1 release.</strong></span>
114            </p>
115                <p>
116                 As part of the upgrade from the Berkeley DB 3.0 release to the 3.1
117                 release, the on-disk format of duplicate data items changed.  To
118                 correctly upgrade the format requires applications to specify whether
119                 duplicate data items in the database are sorted or not.  Specifying
120                 the DB_DUPSORT flag informs <code class="methodname">DB-&gt;upgrade()</code> that the duplicates are
121                 sorted; otherwise they are assumed to be unsorted.  Incorrectly
122                 specifying the value of this flag may lead to database corruption.
123            </p>
124                <p>
125                 Further, because the <code class="methodname">DB-&gt;upgrade()</code> method upgrades a physical file
126                 (including all the databases it contains), it is not possible to use
127                 <code class="methodname">DB-&gt;upgrade()</code> to upgrade files in which some of the databases it
128                 includes have sorted duplicate data items, and some of the databases
129                 it includes have unsorted duplicate data items.  If the file does not
130                 have more than a single database, if the databases do not support
131                 duplicate data items, or if all of the databases that support
132                 duplicate data items support the same style of duplicates (either
133                 sorted or unsorted), <code class="methodname">DB-&gt;upgrade()</code> will work correctly as long as the
134                 DB_DUPSORT flag is correctly specified.  Otherwise, the file cannot be
135                 upgraded using <code class="methodname">DB-&gt;upgrade;()</code> it must be upgraded manually by dumping
136                 and reloading the databases.
137            </p>
138              </li>
139            </ul>
140          </div>
141        </div>
142      </div>
143      <div class="sect2" lang="en" xml:lang="en">
144        <div class="titlepage">
145          <div>
146            <div>
147              <h3 class="title"><a id="id1652587"></a>Environment Variables</h3>
148            </div>
149          </div>
150        </div>
151        <p>
152                         If the database was opened within a database environment, the
153                         environment variable <code class="literal">DB_HOME</code> may be used as the path of the
154                         database environment home.
155                    </p>
156        <p>
157                            <code class="methodname">DB-&gt;upgrade()</code> is affected by any database directory specified using the
158                            <a class="xref" href="envset_data_dir.html" title="DB_ENV-&gt;set_data_dir()">DB_ENV-&gt;set_data_dir()</a>
159                            method, or by setting the "set_data_dir" string in the environment's
160                            <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a>
161                            file.
162                    </p>
163      </div>
164      <div class="sect2" lang="en" xml:lang="en">
165        <div class="titlepage">
166          <div>
167            <div>
168              <h3 class="title"><a id="id1652513"></a>Errors</h3>
169            </div>
170          </div>
171        </div>
172        <p>
173                         The <code class="methodname">DB-&gt;upgrade()</code> <span>
174            <span>
175                 method may fail and return one of the following non-zero errors:
176            </span>
177            
178        </span>
179                    </p>
180        <div class="sect3" lang="en" xml:lang="en">
181          <div class="titlepage">
182            <div>
183              <div>
184                <h4 class="title"><a id="id1652503"></a>DB_OLD_VERSION</h4>
185              </div>
186            </div>
187          </div>
188          <p>
189                             The database cannot be upgraded by this version of the Berkeley DB
190                             software.
191                        </p>
192        </div>
193      </div>
194      <div class="sect2" lang="en" xml:lang="en">
195        <div class="titlepage">
196          <div>
197            <div>
198              <h3 class="title"><a id="id1652518"></a>Class</h3>
199            </div>
200          </div>
201        </div>
202        <p>
203                <a class="link" href="db.html" title="Chapter��2.�� The DB Handle">DB</a>  
204            </p>
205      </div>
206      <div class="sect2" lang="en" xml:lang="en">
207        <div class="titlepage">
208          <div>
209            <div>
210              <h3 class="title"><a id="id1652531"></a>See Also</h3>
211            </div>
212          </div>
213        </div>
214        <p>
215                     <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a> 
216                </p>
217      </div>
218    </div>
219    <div class="navfooter">
220      <hr />
221      <table width="100%" summary="Navigation footer">
222        <tr>
223          <td width="40%" align="left"><a accesskey="p" href="dbtruncate.html">Prev</a>��</td>
224          <td width="20%" align="center">
225            <a accesskey="u" href="db.html">Up</a>
226          </td>
227          <td width="40%" align="right">��<a accesskey="n" href="dbverify.html">Next</a></td>
228        </tr>
229        <tr>
230          <td width="40%" align="left" valign="top">DB-&gt;truncate()��</td>
231          <td width="20%" align="center">
232            <a accesskey="h" href="index.html">Home</a>
233          </td>
234          <td width="40%" align="right" valign="top">��DB-&gt;verify()</td>
235        </tr>
236      </table>
237    </div>
238  </body>
239</html>
240