| 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>DbEnv::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 DbEnv Handle" /> |
| 11 | <link rel="prev" href="envopen.html" title="DbEnv::open()" /> |
| 12 | <link rel="next" href="envset_alloc.html" title="DbEnv::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">DbEnv::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 DbEnv 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>DbEnv::remove()</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <pre class="programlisting">#include <db_cxx.h> |
| 42 | |
| 43 | int |
| 44 | DbEnv::remove(const char *db_home, u_int32_t flags);</pre> |
| 45 | <p> |
| 46 | The <code class="methodname">DbEnv::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="DbEnv::open()">DbEnv::open()</a> without calling |
| 54 | <a class="xref" href="envclose.html" title="DbEnv::close()">DbEnv::close()</a> (that |
| 55 | is, there are processes currently using the environment), |
| 56 | <code class="methodname">DbEnv::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">DbEnv::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">DbEnv::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">DbEnv::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="DbEnv::open()">DbEnv::open()</a>, |
| 81 | it may be useful to call <code class="methodname">DbEnv::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">DbEnv::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">DbEnv::remove()</code> method. |
| 93 | </p> |
| 94 | <p> |
| 95 | A <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> handle that has |
| 96 | already been used to open an environment should not be used to call |
| 97 | the <code class="methodname">DbEnv::remove()</code> method; a new <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> |
| 98 | handle should be created for that purpose. |
| 99 | </p> |
| 100 | <p> |
| 101 | After <code class="methodname">DbEnv::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">DbEnv::remove()</code> <span> |
| 106 | |
| 107 | <span> |
| 108 | method either returns a non-zero error value or throws an |
| 109 | exception that encapsulates a non-zero error value on |
| 110 | failure, and returns 0 on success. |
| 111 | </span> |
| 112 | </span> |
| 113 | </p> |
| 114 | <div class="sect2" lang="en" xml:lang="en"> |
| 115 | <div class="titlepage"> |
| 116 | <div> |
| 117 | <div> |
| 118 | <h3 class="title"><a id="idp7092448"></a>Parameters</h3> |
| 119 | </div> |
| 120 | </div> |
| 121 | </div> |
| 122 | <div class="sect3" lang="en" xml:lang="en"> |
| 123 | <div class="titlepage"> |
| 124 | <div> |
| 125 | <div> |
| 126 | <h4 class="title"><a id="idp7091800"></a>db_home</h4> |
| 127 | </div> |
| 128 | </div> |
| 129 | </div> |
| 130 | <p> |
| 131 | The <span class="bold"><strong>db_home</strong></span> parameter names the |
| 132 | database environment to be removed. |
| 133 | </p> |
| 134 | <p> |
| 135 | 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 |
| 136 | string, which is equivalent to ASCII for Latin characters. |
| 137 | </p> |
| 138 | </div> |
| 139 | <div class="sect3" lang="en" xml:lang="en"> |
| 140 | <div class="titlepage"> |
| 141 | <div> |
| 142 | <div> |
| 143 | <h4 class="title"><a id="idp7095456"></a>flags</h4> |
| 144 | </div> |
| 145 | </div> |
| 146 | </div> |
| 147 | <p> |
| 148 | The <span class="bold"><strong>flags</strong></span> parameter must be set to 0 or by |
| 149 | bitwise inclusively <span class="bold"><strong>OR</strong></span>'ing together one or more of the |
| 150 | following values: |
| 151 | </p> |
| 152 | <div class="itemizedlist"> |
| 153 | <ul type="disc"> |
| 154 | <li> |
| 155 | <p><a id="envremove_DB_FORCE"></a> |
| 156 | <code class="literal">DB_FORCE</code> |
| 157 | </p> |
| 158 | <p> |
| 159 | If set, the environment is removed, regardless of any |
| 160 | processes that may still using it, and no locks are acquired during this |
| 161 | process. (Generally, this flag is specified only when applications were |
| 162 | unable to shut down cleanly, and there is a risk that an application may have |
| 163 | died holding a Berkeley DB lock.) |
| 164 | </p> |
| 165 | </li> |
| 166 | <li> |
| 167 | <p><a id="envremove_DB_USE_ENVIRON"></a> |
| 168 | <code class="literal">DB_USE_ENVIRON</code> |
| 169 | </p> |
| 170 | <p> |
| 171 | The Berkeley DB process' environment may be permitted to specify information to |
| 172 | be used when naming files; see |
| 173 | <a href="../../programmer_reference/env_naming.html" class="olink">Berkeley DB File Naming</a>. |
| 174 | Because permitting users to specify which files are used can create security |
| 175 | problems, environment information will be used in file naming for all users |
| 176 | only if the <code class="literal">DB_USE_ENVIRON</code> flag is set. |
| 177 | </p> |
| 178 | </li> |
| 179 | <li> |
| 180 | <p><a id="envremove_DB_USE_ENVIRON_ROOT"></a> |
| 181 | <code class="literal">DB_USE_ENVIRON_ROOT</code> |
| 182 | </p> |
| 183 | <p> |
| 184 | The Berkeley DB process' environment may be permitted to specify information to |
| 185 | be used when naming files; see |
| 186 | <a href="../../programmer_reference/env_naming.html" class="olink">Berkeley DB File Naming</a>. |
| 187 | Because permitting users to specify which files are used can create security |
| 188 | problems, if the <code class="literal">DB_USE_ENVIRON_ROOT</code> flag is set, environment |
| 189 | information will be used in file naming only for users with appropriate |
| 190 | permissions (for example, users with a user-ID of 0 on <code class="literal">UNIX</code> |
| 191 | systems). |
| 192 | </p> |
| 193 | </li> |
| 194 | </ul> |
| 195 | </div> |
| 196 | </div> |
| 197 | </div> |
| 198 | <div class="sect2" lang="en" xml:lang="en"> |
| 199 | <div class="titlepage"> |
| 200 | <div> |
| 201 | <div> |
| 202 | <h3 class="title"><a id="idp7073920"></a>Errors</h3> |
| 203 | </div> |
| 204 | </div> |
| 205 | </div> |
| 206 | <p> |
| 207 | The <code class="methodname">DbEnv::remove()</code> <span> |
| 208 | |
| 209 | <span> |
| 210 | method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a> |
| 211 | exception, encapsulating one of the following non-zero errors, or return one |
| 212 | of the following non-zero errors: |
| 213 | </span> |
| 214 | </span> |
| 215 | </p> |
| 216 | <div class="sect3" lang="en" xml:lang="en"> |
| 217 | <div class="titlepage"> |
| 218 | <div> |
| 219 | <div> |
| 220 | <h4 class="title"><a id="idp7119248"></a>EBUSY</h4> |
| 221 | </div> |
| 222 | </div> |
| 223 | </div> |
| 224 | <p> |
| 225 | The shared memory region was in use and the force flag was not set. |
| 226 | </p> |
| 227 | </div> |
| 228 | </div> |
| 229 | <div class="sect2" lang="en" xml:lang="en"> |
| 230 | <div class="titlepage"> |
| 231 | <div> |
| 232 | <div> |
| 233 | <h3 class="title"><a id="idp7117336"></a>Class</h3> |
| 234 | </div> |
| 235 | </div> |
| 236 | </div> |
| 237 | <p> |
| 238 | <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> |
| 239 | </p> |
| 240 | </div> |
| 241 | <div class="sect2" lang="en" xml:lang="en"> |
| 242 | <div class="titlepage"> |
| 243 | <div> |
| 244 | <div> |
| 245 | <h3 class="title"><a id="idp7114064"></a>See Also</h3> |
| 246 | </div> |
| 247 | </div> |
| 248 | </div> |
| 249 | <p> |
| 250 | <a class="xref" href="env.html#envlist" title="Database Environments and Related Methods">Database Environments and Related Methods</a> |
| 251 | </p> |
| 252 | </div> |
| 253 | </div> |
| 254 | <div class="navfooter"> |
| 255 | <hr /> |
| 256 | <table width="100%" summary="Navigation footer"> |
| 257 | <tr> |
| 258 | <td width="40%" align="left"><a accesskey="p" href="envopen.html">Prev</a> </td> |
| 259 | <td width="20%" align="center"> |
| 260 | <a accesskey="u" href="env.html">Up</a> |
| 261 | </td> |
| 262 | <td width="40%" align="right"> <a accesskey="n" href="envset_alloc.html">Next</a></td> |
| 263 | </tr> |
| 264 | <tr> |
| 265 | <td width="40%" align="left" valign="top">DbEnv::open() </td> |
| 266 | <td width="20%" align="center"> |
| 267 | <a accesskey="h" href="index.html">Home</a> |
| 268 | </td> |
| 269 | <td width="40%" align="right" valign="top"> DbEnv::set_alloc()</td> |
| 270 | </tr> |
| 271 | </table> |
| 272 | </div> |
| 273 | </body> |
| 274 | </html> |