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->log_archive()</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="lsn.html" title="Chapter��7.�� The DB_LSN Handle" /> 11 <link rel="prev" href="envget_lg_regionmax.html" title="DB_ENV->get_lg_regionmax()" /> 12 <link rel="next" href="logcursor.html" title="DB_ENV->log_cursor()" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">DB_ENV->log_archive()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="envget_lg_regionmax.html">Prev</a>��</td> 22 <th width="60%" align="center">Chapter��7.�� 23 The DB_LSN Handle 24 </th> 25 <td width="20%" align="right">��<a accesskey="n" href="logcursor.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="logarchive"></a>DB_ENV->log_archive()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db.h> 39 40int 41DB_ENV->log_archive(DB_ENV *env, char *(*listp)[], u_int32_t flags); </pre> 42 <p> 43 The <code class="methodname">DB_ENV->log_archive()</code> method returns an array of log or database 44 filenames. 45 </p> 46 <p> 47 By default, <code class="methodname">DB_ENV->log_archive()</code> returns the names of all of the 48 log files that are no longer in use (for example, that are no longer involved in active 49 transactions), and that may safely be archived for catastrophic recovery and then removed 50 from the system. If there are no filenames to return, the memory location to which 51 <span class="bold"><strong>listp</strong></span> refers will be set to NULL. 52 </p> 53 <p> 54 55 Arrays of log filenames are stored in allocated memory. If application-specific allocation 56 routines have been declared (see <a class="xref" href="envset_alloc.html" title="DB_ENV->set_alloc()">DB_ENV->set_alloc()</a> 57 for more information), they are used to allocate the memory; otherwise, the standard 58 C library <span class="bold"><strong>malloc</strong></span>(3) is used. The caller is responsible 59 for deallocating the memory. To deallocate the memory, free the memory reference; 60 references inside the returned memory need not be individually freed. 61 </p> 62 <p> 63 Log cursor handles (returned by the <a class="xref" href="logcursor.html" title="DB_ENV->log_cursor()">DB_ENV->log_cursor()</a> 64 method) may have open file descriptors for log files in the database environment. Also, 65 the Berkeley DB interfaces to the database environment logging subsystem (for example, 66 <a class="xref" href="logput.html" title="DB_ENV->log_put()">DB_ENV->log_put()</a> and <a class="xref" href="txnabort.html" title="DB_TXN->abort()">DB_TXN->abort()</a> ) may allocate log cursors and have open file descriptors 67 for log files as well. On operating systems where filesystem related system calls (for 68 example, rename and unlink on Windows/NT) can fail if a process has an open file descriptor 69 for the affected file, attempting to move or remove the log files listed by 70 <code class="methodname">DB_ENV->log_archive()</code> may fail. All Berkeley DB internal use of log 71 cursors operates on active log files only and furthermore, is short-lived in nature. So, 72 an application seeing such a failure should be restructured to close any open log cursors 73 it may have, and otherwise to retry the operation until it succeeds. (Although the latter 74 is not likely to be necessary; it is hard to imagine a reason to move or rename a log file 75 in which transactions are being logged or aborted.) 76 </p> 77 <p> 78 See <a class="link" href="db_archive.html" title="db_archive">db_archive</a> for more information on 79 database archival procedures. 80 </p> 81 <p> 82 The <code class="methodname">DB_ENV->log_archive()</code> method is the underlying method used by the 83 <a class="link" href="db_archive.html" title="db_archive">db_archive</a> utility. 84 See the <a class="link" href="db_archive.html" title="db_archive">db_archive</a> 85 utility source code for an example of using <code class="methodname">DB_ENV->log_archive()</code> in 86 a IEEE/ANSI Std 1003.1 (POSIX) environment. 87 </p> 88 <p> 89 The <code class="methodname">DB_ENV->log_archive()</code> <span> 90 <span> 91 method returns a non-zero error value on failure and 0 on success. 92 </span> 93 94 </span> 95 </p> 96 <div class="sect2" lang="en" xml:lang="en"> 97 <div class="titlepage"> 98 <div> 99 <div> 100 <h3 class="title"><a id="id1680126"></a>Parameters</h3> 101 </div> 102 </div> 103 </div> 104 <div class="sect3" lang="en" xml:lang="en"> 105 <div class="titlepage"> 106 <div> 107 <div> 108 <h4 class="title"><a id="id1680787"></a>flags</h4> 109 </div> 110 </div> 111 </div> 112 <p> 113 The <span class="bold"><strong>flags</strong></span> parameter must be set to 0 114 or by bitwise inclusively <span class="bold"><strong>OR</strong></span>'ing 115 together one or more of the following values: 116 </p> 117 <div class="itemizedlist"> 118 <ul type="disc"> 119 <li> 120 <p><a id="archive_DB_ARCH_ABS"></a> 121 <code class="literal">DB_ARCH_ABS</code> 122 </p> 123 <p> 124 All pathnames are returned as absolute pathnames, instead of relative 125 to the database home directory. 126 </p> 127 </li> 128 <li> 129 <p><a id="archive_DB_ARCH_DATA"></a> 130 <code class="literal">DB_ARCH_DATA</code> 131 </p> 132 <p> 133 Return the database files that need to be archived in order to recover 134 the database from catastrophic failure. If any of the database files 135 have not been accessed during the lifetime of the current log files, 136 <code class="methodname">DB_ENV->log_archive()</code> will not include them in this list. It is also 137 possible that some of the files referred to by the log have since been 138 deleted from the system. 139 </p> 140 <p> 141 The <code class="literal">DB_ARCH_DATA</code> and <code class="literal">DB_ARCH_LOG flags</code> are mutually exclusive. 142 </p> 143 </li> 144 <li> 145 <p><a id="archive_DB_ARCH_LOG"></a> 146 <code class="literal">DB_ARCH_LOG</code> 147 </p> 148 <p> 149 Return all the log filenames, regardless of whether or not they are in 150 use. 151 </p> 152 <p> 153 The <code class="literal">DB_ARCH_DATA</code> and <code class="literal">DB_ARCH_LOG flags</code> are mutually exclusive. 154 </p> 155 </li> 156 <li> 157 <p><a id="archive_DB_ARCH_REMOVE"></a> 158 <code class="literal">DB_ARCH_REMOVE</code> 159 </p> 160 <p> 161 Remove log files that are no longer needed; no filenames are returned. 162 Automatic log file removal is likely to make catastrophic recovery 163 impossible. 164 </p> 165 <p> 166 The <code class="literal">DB_ARCH_REMOVE</code> flag may not be specified with any other flag. 167 </p> 168 </li> 169 </ul> 170 </div> 171 </div> 172 <div class="sect3" lang="en" xml:lang="en"> 173 <div class="titlepage"> 174 <div> 175 <div> 176 <h4 class="title"><a id="id1681073"></a>listp</h4> 177 </div> 178 </div> 179 </div> 180 <p> 181 The <span class="bold"><strong>listp</strong></span> parameter references memory 182 into which the allocated array of log or database filenames is copied. 183 If there are no filenames to return, the memory location to which 184 <span class="bold"><strong>listp</strong></span> refers will be set to NULL. 185 </p> 186 </div> 187 </div> 188 <div class="sect2" lang="en" xml:lang="en"> 189 <div class="titlepage"> 190 <div> 191 <div> 192 <h3 class="title"><a id="id1681092"></a>Errors</h3> 193 </div> 194 </div> 195 </div> 196 <p> 197 The <code class="methodname">DB_ENV->log_archive()</code> <span> 198 <span> 199 method may fail and return one of the following non-zero errors: 200 </span> 201 202 </span> 203 </p> 204 <div class="sect3" lang="en" xml:lang="en"> 205 <div class="titlepage"> 206 <div> 207 <div> 208 <h4 class="title"><a id="id1680583"></a>EINVAL</h4> 209 </div> 210 </div> 211 </div> 212 <p> 213 An invalid flag value or parameter was specified. 214 </p> 215 </div> 216 </div> 217 <div class="sect2" lang="en" xml:lang="en"> 218 <div class="titlepage"> 219 <div> 220 <div> 221 <h3 class="title"><a id="id1681176"></a>Class</h3> 222 </div> 223 </div> 224 </div> 225 <p> 226 <a class="link" href="env.html" title="Chapter��5.�� The DB_ENV Handle">DB_ENV</a>, 227 <a class="link" href="logc.html" title="The DB_LOGC Handle">DB_LOGC</a>, 228 <a class="link" href="lsn.html" title="Chapter��7.�� The DB_LSN Handle">DB_LSN</a> 229 </p> 230 </div> 231 <div class="sect2" lang="en" xml:lang="en"> 232 <div class="titlepage"> 233 <div> 234 <div> 235 <h3 class="title"><a id="id1680870"></a>See Also</h3> 236 </div> 237 </div> 238 </div> 239 <p> 240 <a class="xref" href="lsn.html#loglist" title="Logging Subsystem and Related Methods">Logging Subsystem and Related Methods</a> 241 </p> 242 </div> 243 </div> 244 <div class="navfooter"> 245 <hr /> 246 <table width="100%" summary="Navigation footer"> 247 <tr> 248 <td width="40%" align="left"><a accesskey="p" href="envget_lg_regionmax.html">Prev</a>��</td> 249 <td width="20%" align="center"> 250 <a accesskey="u" href="lsn.html">Up</a> 251 </td> 252 <td width="40%" align="right">��<a accesskey="n" href="logcursor.html">Next</a></td> 253 </tr> 254 <tr> 255 <td width="40%" align="left" valign="top">DB_ENV->get_lg_regionmax()��</td> 256 <td width="20%" align="center"> 257 <a accesskey="h" href="index.html">Home</a> 258 </td> 259 <td width="40%" align="right" valign="top">��DB_ENV->log_cursor()</td> 260 </tr> 261 </table> 262 </div> 263 </body> 264</html> 265