Debian Codegraph @

docs/api_reference/C/envremove.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_ENV-&gt;remove()</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="env.html" title="Chapter 5.  The DB_ENV Handle" />
11 <link rel="prev" href="envopen.html" title="DB_ENV-&gt;open()" />
12 <link rel="next" href="envset_alloc.html" title="DB_ENV-&gt;set_alloc()" />
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_ENV-&gt;remove()</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="envopen.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 5. 
26 The DB_ENV Handle
27 </th>
28 <td width="20%" align="right"> <a accesskey="n" href="envset_alloc.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="envremove"></a>DB_ENV-&gt;remove()</h2>
38 </div>
39 </div>
40 </div>
41 <pre class="programlisting">#include &lt;db.h&gt;
42
43 int
44 DB_ENV-&gt;remove(DB_ENV *dbenv, char *db_home, u_int32_t flags); </pre>
45 <p>
46 The <code class="methodname">DB_ENV-&gt;remove()</code> method destroys a Berkeley DB environment if it
47 is not currently in use. The environment regions, including any
48 backing files, are removed. Any log or database files and the
49 environment directory are not removed.
50 </p>
51 <p>
52 If there are processes that have called
53 <a class="xref" href="envopen.html" title="DB_ENV-&gt;open()">DB_ENV-&gt;open()</a> without calling
54 <a class="xref" href="envclose.html" title="DB_ENV-&gt;close()">DB_ENV-&gt;close()</a> (that
55 is, there are processes currently using the environment),
56 <code class="methodname">DB_ENV-&gt;remove()</code> will fail without further action unless the
57 <a class="link" href="envremove.html#envremove_DB_FORCE">DB_FORCE</a> flag is set,
58 in which case <code class="methodname">DB_ENV-&gt;remove()</code> will attempt to remove the
59 environment, regardless of any processes still using it.
60 </p>
61 <p>
62 The result of attempting to forcibly destroy the environment when it
63 is in use is unspecified. Processes using an environment often
64 maintain open file descriptors for shared regions within it. On UNIX
65 systems, the environment removal will usually succeed, and processes
66 that have already joined the region will continue to run in that
67 region without change. However, processes attempting to join the
68 environment will either fail or create new regions. On other systems
69 in which the <span class="bold"><strong>unlink</strong></span>(2) system call
70 will fail if any process has an open file descriptor for the file (for
71 example Windows/NT), the region removal will fail.
72 </p>
73 <p>
74 Calling <code class="methodname">DB_ENV-&gt;remove()</code> should not be necessary for most
75 applications because the Berkeley DB environment is cleaned up as part
76 of normal database recovery procedures. However, applications may want
77 to call <code class="methodname">DB_ENV-&gt;remove()</code> as part of application shut down to free up
78 system resources. For example, if the
79 <a class="link" href="envopen.html#envopen_DB_SYSTEM_MEM">DB_SYSTEM_MEM</a> flag
80 was specified to <a class="xref" href="envopen.html" title="DB_ENV-&gt;open()">DB_ENV-&gt;open()</a>,
81 it may be useful to call <code class="methodname">DB_ENV-&gt;remove()</code> in order to release system shared memory
82 segments that have been allocated. Or, on architectures in which
83 mutexes require allocation of underlying system resources, it may be
84 useful to call <code class="methodname">DB_ENV-&gt;remove()</code> in order to release those resources.
85 Alternatively, if recovery is not required because no database state
86 is maintained across failures, and no system resources need to be
87 released, it is possible to clean up an environment by simply removing
88 all the Berkeley DB files in the database environment's directories.
89 </p>
90 <p>
91 In multithreaded applications, only a single thread may call the
92 <code class="methodname">DB_ENV-&gt;remove()</code> method.
93 </p>
94 <p>
95 A <a class="link" href="env.html" title="Chapter 5.  The DB_ENV Handle">DB_ENV</a> handle that has
96 already been used to open an environment should not be used to call
97 the <code class="methodname">DB_ENV-&gt;remove()</code> method; a new <a class="link" href="env.html" title="Chapter 5.  The DB_ENV Handle">DB_ENV</a>
98 handle should be created for that purpose.
99 </p>
100 <p>
101 After <code class="methodname">DB_ENV-&gt;remove()</code> has been called, regardless of its return, the
102 Berkeley DB environment handle may not be accessed again.
103 </p>
104 <p>
105 The <code class="methodname">DB_ENV-&gt;remove()</code> <span>
106 <span>
107 method returns a non-zero error value on failure and 0 on success.
108 </span>
109
110 </span>
111 </p>
112 <div class="sect2" lang="en" xml:lang="en">
113 <div class="titlepage">
114 <div>
115 <div>
116 <h3 class="title"><a id="idp51712104"></a>Parameters</h3>
117 </div>
118 </div>
119 </div>
120 <div class="sect3" lang="en" xml:lang="en">
121 <div class="titlepage">
122 <div>
123 <div>
124 <h4 class="title"><a id="idp51675136"></a>db_home</h4>
125 </div>
126 </div>
127 </div>
128 <p>
129 The <span class="bold"><strong>db_home</strong></span> parameter names the
130 database environment to be removed.
131 </p>
132 <p>
133 When using a Unicode build on Windows (the default), the <span class="bold"><strong>db_home</strong></span> argument will be interpreted as a UTF-8
134 string, which is equivalent to ASCII for Latin characters.
135 </p>
136 </div>
137 <div class="sect3" lang="en" xml:lang="en">
138 <div class="titlepage">
139 <div>
140 <div>
141 <h4 class="title"><a id="idp51751088"></a>flags</h4>
142 </div>
143 </div>
144 </div>
145 <p>
146 The <span class="bold"><strong>flags</strong></span> parameter must be set to 0 or by
147 bitwise inclusively <span class="bold"><strong>OR</strong></span>'ing together one or more of the
148 following values:
149 </p>
150 <div class="itemizedlist">
151 <ul type="disc">
152 <li>
153 <p><a id="envremove_DB_FORCE"></a>
154 <code class="literal">DB_FORCE</code>
155 </p>
156 <p>
157 If set, the environment is removed, regardless of any
158 processes that may still using it, and no locks are acquired during this
159 process. (Generally, this flag is specified only when applications were
160 unable to shut down cleanly, and there is a risk that an application may have
161 died holding a Berkeley DB lock.)
162 </p>
163 </li>
164 <li>
165 <p><a id="envremove_DB_USE_ENVIRON"></a>
166 <code class="literal">DB_USE_ENVIRON</code>
167 </p>
168 <p>
169 The Berkeley DB process' environment may be permitted to specify information to
170 be used when naming files; see
171 <a href="../../programmer_reference/env_naming.html" class="olink">Berkeley DB File Naming</a>.
172 Because permitting users to specify which files are used can create security
173 problems, environment information will be used in file naming for all users
174 only if the <code class="literal">DB_USE_ENVIRON</code> flag is set.
175 </p>
176 </li>
177 <li>
178 <p><a id="envremove_DB_USE_ENVIRON_ROOT"></a>
179 <code class="literal">DB_USE_ENVIRON_ROOT</code>
180 </p>
181 <p>
182 The Berkeley DB process' environment may be permitted to specify information to
183 be used when naming files; see
184 <a href="../../programmer_reference/env_naming.html" class="olink">Berkeley DB File Naming</a>.
185 Because permitting users to specify which files are used can create security
186 problems, if the <code class="literal">DB_USE_ENVIRON_ROOT</code> flag is set, environment
187 information will be used in file naming only for users with appropriate
188 permissions (for example, users with a user-ID of 0 on <code class="literal">UNIX</code>
189 systems).
190 </p>
191 </li>
192 </ul>
193 </div>
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="idp51722944"></a>Errors</h3>
201 </div>
202 </div>
203 </div>
204 <p>
205 The <code class="methodname">DB_ENV-&gt;remove()</code> <span>
206 <span>
207 method may fail and return one of the following non-zero errors:
208 </span>
209
210 </span>
211 </p>
212 <div class="sect3" lang="en" xml:lang="en">
213 <div class="titlepage">
214 <div>
215 <div>
216 <h4 class="title"><a id="idp51772184"></a>EBUSY</h4>
217 </div>
218 </div>
219 </div>
220 <p>
221 The shared memory region was in use and the force flag was not set.
222 </p>
223 </div>
224 </div>
225 <div class="sect2" lang="en" xml:lang="en">
226 <div class="titlepage">
227 <div>
228 <div>
229 <h3 class="title"><a id="idp51770856"></a>Class</h3>
230 </div>
231 </div>
232 </div>
233 <p>
234 <a class="link" href="env.html" title="Chapter 5.  The DB_ENV Handle">DB_ENV</a>
235 </p>
236 </div>
237 <div class="sect2" lang="en" xml:lang="en">
238 <div class="titlepage">
239 <div>
240 <div>
241 <h3 class="title"><a id="idp51767832"></a>See Also</h3>
242 </div>
243 </div>
244 </div>
245 <p>
246 <a class="xref" href="env.html#envlist" title="Database Environments and Related Methods">Database Environments and Related Methods</a>
247 </p>
248 </div>
249 </div>
250 <div class="navfooter">
251 <hr />
252 <table width="100%" summary="Navigation footer">
253 <tr>
254 <td width="40%" align="left"><a accesskey="p" href="envopen.html">Prev</a> </td>
255 <td width="20%" align="center">
256 <a accesskey="u" href="env.html">Up</a>
257 </td>
258 <td width="40%" align="right"> <a accesskey="n" href="envset_alloc.html">Next</a></td>
259 </tr>
260 <tr>
261 <td width="40%" align="left" valign="top">DB_ENV-&gt;open() </td>
262 <td width="20%" align="center">
263 <a accesskey="h" href="index.html">Home</a>
264 </td>
265 <td width="40%" align="right" valign="top"> DB_ENV-&gt;set_alloc()</td>
266 </tr>
267 </table>
268 </div>
269 </body>
270 </html>