117 lines
6.5 KiB
HTML
117 lines
6.5 KiB
HTML
<!--$Id: env_remove.html 63573 2008-05-23 21:43:21Z trent.nelson $-->
|
|
<!--Copyright (c) 1997,2008 Oracle. All rights reserved.-->
|
|
<!--See the file LICENSE for redistribution information.-->
|
|
<html>
|
|
<head>
|
|
<title>Berkeley DB: DB_ENV->remove</title>
|
|
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
|
|
<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
|
|
</head>
|
|
<body bgcolor=white>
|
|
<table width="100%"><tr valign=top>
|
|
<td>
|
|
<b>DB_ENV->remove</b>
|
|
</td>
|
|
<td align=right>
|
|
<a href="../api_c/api_core.html"><img src="../images/api.gif" alt="API"></a>
|
|
<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td>
|
|
</tr></table>
|
|
<hr size=1 noshade>
|
|
<tt>
|
|
<b><pre>
|
|
#include <db.h>
|
|
<p>
|
|
int
|
|
DB_ENV->remove(DB_ENV *dbenv, char *db_home, u_int32_t flags);
|
|
</pre></b>
|
|
<hr size=1 noshade>
|
|
<b>Description: DB_ENV->remove</b>
|
|
<p>The DB_ENV->remove method destroys a Berkeley DB environment if it is not
|
|
currently in use. The environment regions, including any backing files,
|
|
are removed. Any log or database files and the environment directory are
|
|
not removed.</p>
|
|
<p>If there are processes that have called <a href="../api_c/env_open.html">DB_ENV->open</a> without
|
|
calling <a href="../api_c/env_close.html">DB_ENV->close</a> (that is, there are processes currently
|
|
using the environment), DB_ENV->remove will fail without further
|
|
action unless the <a href="../api_c/env_remove.html#DB_FORCE">DB_FORCE</a> flag is set, in which case
|
|
DB_ENV->remove will attempt to remove the environment, regardless
|
|
of any processes still using it.</p>
|
|
<p>The result of attempting to forcibly destroy the environment when it is
|
|
in use is unspecified. Processes using an environment often maintain open
|
|
file descriptors for shared regions within it. On UNIX systems, the
|
|
environment removal will usually succeed, and processes that have already
|
|
joined the region will continue to run in that region without change.
|
|
However, processes attempting to join the environment will either fail
|
|
or create new regions. On other systems in which the <b>unlink</b>(2) system call will fail if any process has an open file descriptor for
|
|
the file (for example Windows/NT), the region removal will fail.</p>
|
|
<p>Calling DB_ENV->remove should not be necessary for most applications
|
|
because the Berkeley DB environment is cleaned up as part of normal database
|
|
recovery procedures. However, applications may want to call
|
|
DB_ENV->remove as part of application shut down to free up system
|
|
resources. For example, if the <a href="../api_c/env_open.html#DB_SYSTEM_MEM">DB_SYSTEM_MEM</a> flag was specified
|
|
to <a href="../api_c/env_open.html">DB_ENV->open</a>, it may be useful to call DB_ENV->remove in
|
|
order to release system shared memory segments that have been allocated.
|
|
Or, on architectures in which mutexes require allocation of underlying
|
|
system resources, it may be useful to call DB_ENV->remove in order
|
|
to release those resources. Alternatively, if recovery is not required
|
|
because no database state is maintained across failures, and no system
|
|
resources need to be released, it is possible to clean up an environment
|
|
by simply removing all the Berkeley DB files in the database environment's
|
|
directories.</p>
|
|
<p>In multithreaded applications, only a single thread may call
|
|
DB_ENV->remove.</p>
|
|
<p>A <a href="../api_c/env_class.html">DB_ENV</a> handle that has already been used to open an environment
|
|
should not be used to call the DB_ENV->remove method; a new
|
|
<a href="../api_c/env_class.html">DB_ENV</a> handle should be created for that purpose.</p>
|
|
<p>After DB_ENV->remove has been called, regardless of its return,
|
|
the Berkeley DB environment handle may not be accessed again.</p>
|
|
<p>The DB_ENV->remove method
|
|
returns a non-zero error value on failure
|
|
and 0 on success.
|
|
</p>
|
|
<b>Parameters</b> <br>
|
|
<b>db_home</b><ul compact><li>The <b>db_home</b> parameter names the database environment to be removed.</ul>
|
|
<p>When using a Unicode build on Windows (the default), the <b>db_home</b>
|
|
argument will be interpreted as a UTF-8 string, which is equivalent to
|
|
ASCII for Latin characters.</p>
|
|
<b>flags</b><ul compact><li>The <b>flags</b> parameter must be set to 0 or by bitwise inclusively <b>OR</b>'ing together one
|
|
or more of the following values:
|
|
<br>
|
|
<b><a name="DB_FORCE">DB_FORCE</a></b><ul compact><li>If the <a href="../api_c/env_remove.html#DB_FORCE">DB_FORCE</a> flag is set, the environment is removed, regardless
|
|
of any processes that may still using it, and no locks are acquired
|
|
during this process. (Generally, the <a href="../api_c/env_remove.html#DB_FORCE">DB_FORCE</a> flag is
|
|
specified only when applications were unable to shut down cleanly, and there
|
|
is a risk that an application may have died holding a Berkeley DB lock.)</ul>
|
|
<a name="2"><!--meow--></a>
|
|
<b><a name="DB_USE_ENVIRON">DB_USE_ENVIRON</a></b><ul compact><li>The Berkeley DB process' environment may be permitted to specify information
|
|
to be used when naming files; see <a href="../ref/env/naming.html">Berkeley DB File Naming</a>. Because permitting users to specify which files
|
|
are used can create security problems, environment information will be
|
|
used in file naming for all users only if the DB_USE_ENVIRON
|
|
flag is set.</ul>
|
|
<b><a name="DB_USE_ENVIRON_ROOT">DB_USE_ENVIRON_ROOT</a></b><ul compact><li>The Berkeley DB process' environment may be permitted to specify information
|
|
to be used when naming files; see <a href="../ref/env/naming.html">Berkeley DB File Naming</a>. Because permitting users to specify which files
|
|
are used can create security problems, if the
|
|
DB_USE_ENVIRON_ROOT flag is set, environment information will
|
|
be used for file naming only for users with appropriate permissions (for
|
|
example, users with a user-ID of 0 on UNIX systems).</ul>
|
|
<br></ul>
|
|
<br>
|
|
<br><b>Errors</b>
|
|
<p>The DB_ENV->remove method
|
|
may fail and return one of the following non-zero errors:</p>
|
|
<br>
|
|
<b>EBUSY</b><ul compact><li>The shared memory region was in use and the force flag was not set.</ul>
|
|
<br>
|
|
<hr size=1 noshade>
|
|
<br><b>Class</b>
|
|
<a href="../api_c/env_class.html">DB_ENV</a>
|
|
<br><b>See Also</b>
|
|
<a href="../api_c/env_list.html">Database Environments and Related Methods</a>
|
|
</tt>
|
|
<table width="100%"><tr><td><br></td><td align=right>
|
|
<a href="../api_c/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a>
|
|
</td></tr></table>
|
|
<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font>
|
|
</body>
|
|
</html>
|