Debian Codegraph @

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