| 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::dbrename()</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="envdbremove.html" title="DbEnv::dbremove()" /> |
| 12 | <link rel="next" href="enverr.html" title="DbEnv::err()" /> |
| 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::dbrename()</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="envdbremove.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="enverr.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="envdbrename"></a>DbEnv::dbrename()</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <pre class="programlisting">#include <db_cxx.h> |
| 42 | |
| 43 | int |
| 44 | DbEnv::dbrename(DbTxn *txnid, const char *file, |
| 45 | const char *database, const char *newname, u_int32_t flags);</pre> |
| 46 | <p> |
| 47 | The <code class="methodname">DbEnv::dbrename()</code> method renames the database specified by the |
| 48 | <span class="bold"><strong>file</strong></span> and <span class="bold"><strong>database</strong></span> parameters to <span class="bold"><strong>newname</strong></span>. If no <span class="bold"><strong>database</strong></span> is specified, the underlying file |
| 49 | represented by <span class="bold"><strong>file</strong></span> is renamed |
| 50 | using the value supplied to <span class="bold"><strong>newname</strong></span>, |
| 51 | incidentally renaming all of the databases it contained. |
| 52 | </p> |
| 53 | <p> |
| 54 | Applications should not rename databases that are currently in use. |
| 55 | If an underlying file is being renamed and logging is currently |
| 56 | enabled in the database environment, no database in the file may be |
| 57 | open when the <code class="methodname">DbEnv::dbrename()</code> method is called. |
| 58 | </p> |
| 59 | <p> |
| 60 | The <code class="methodname">DbEnv::dbrename()</code> <span> |
| 61 | |
| 62 | <span> |
| 63 | method either returns a non-zero error value or throws an |
| 64 | exception that encapsulates a non-zero error value on |
| 65 | failure, and returns 0 on success. |
| 66 | </span> |
| 67 | </span> |
| 68 | </p> |
| 69 | <p> |
| 70 | <code class="methodname">DbEnv::dbrename()</code> is affected by any database directory specified using the |
| 71 | <a class="xref" href="envset_data_dir.html" title="DbEnv::set_data_dir()">DbEnv::set_data_dir()</a> |
| 72 | method, or by setting the <code class="literal">set_data_dir</code> string in the environment's |
| 73 | <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file. |
| 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="idp6707816"></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="idp6708008"></a>txnid</h4> |
| 88 | </div> |
| 89 | </div> |
| 90 | </div> |
| 91 | <p> |
| 92 | If the operation is part of an application-specified transaction, the |
| 93 | <span class="bold"><strong>txnid</strong></span> parameter is a transaction |
| 94 | handle returned from <a class="xref" href="txnbegin.html" title="DbEnv::txn_begin()">DbEnv::txn_begin()</a>; if the |
| 95 | operation is part of a Berkeley DB Concurrent Data Store group, the |
| 96 | <span class="bold"><strong>txnid</strong></span> parameter is a handle returned |
| 97 | from <a class="xref" href="envcdsgroup_begin.html" title="DbEnv::cdsgroup_begin()">DbEnv::cdsgroup_begin()</a>; |
| 98 | otherwise NULL. If no transaction handle is specified, but the |
| 99 | <code class="literal">DB_AUTO_COMMIT</code> flag is specified to either this method or the |
| 100 | environment handle, the operation will be implicitly |
| 101 | transaction protected. |
| 102 | </p> |
| 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="idp6709064"></a>file</h4> |
| 109 | </div> |
| 110 | </div> |
| 111 | </div> |
| 112 | <p> |
| 113 | The <span class="bold"><strong>file</strong></span> parameter is the physical |
| 114 | file which contains the database(s) to be renamed. |
| 115 | </p> |
| 116 | <p> |
| 117 | When using a Unicode build on Windows (the default), the |
| 118 | <span class="bold"><strong>file</strong></span> argument will |
| 119 | be interpreted as a UTF-8 string, which is equivalent to ASCII for Latin |
| 120 | characters. |
| 121 | </p> |
| 122 | </div> |
| 123 | <div class="sect3" lang="en" xml:lang="en"> |
| 124 | <div class="titlepage"> |
| 125 | <div> |
| 126 | <div> |
| 127 | <h4 class="title"><a id="idp6685512"></a>database</h4> |
| 128 | </div> |
| 129 | </div> |
| 130 | </div> |
| 131 | <p> |
| 132 | The <span class="bold"><strong>database</strong></span> parameter is the |
| 133 | database to be renamed. |
| 134 | </p> |
| 135 | </div> |
| 136 | <div class="sect3" lang="en" xml:lang="en"> |
| 137 | <div class="titlepage"> |
| 138 | <div> |
| 139 | <div> |
| 140 | <h4 class="title"><a id="idp6703744"></a>newname</h4> |
| 141 | </div> |
| 142 | </div> |
| 143 | </div> |
| 144 | <p> |
| 145 | The <span class="bold"><strong>newname</strong></span> parameter is the new name |
| 146 | of the database or file. |
| 147 | </p> |
| 148 | </div> |
| 149 | <div class="sect3" lang="en" xml:lang="en"> |
| 150 | <div class="titlepage"> |
| 151 | <div> |
| 152 | <div> |
| 153 | <h4 class="title"><a id="idp6705288"></a>flags</h4> |
| 154 | </div> |
| 155 | </div> |
| 156 | </div> |
| 157 | <p> |
| 158 | The <span class="bold"><strong>flags</strong></span> parameter |
| 159 | must be set to 0 or the following value: |
| 160 | </p> |
| 161 | <div class="itemizedlist"> |
| 162 | <ul type="disc"> |
| 163 | <li> |
| 164 | <p> |
| 165 | <code class="literal">DB_AUTO_COMMIT</code> |
| 166 | </p> |
| 167 | <p> |
| 168 | Enclose the <code class="methodname">DbEnv::dbrename()</code> |
| 169 | call within a transaction. If the call |
| 170 | succeeds, changes made by the operation will be recoverable. If the |
| 171 | call fails, the operation will have made no changes. |
| 172 | </p> |
| 173 | </li> |
| 174 | </ul> |
| 175 | </div> |
| 176 | </div> |
| 177 | </div> |
| 178 | <div class="sect2" lang="en" xml:lang="en"> |
| 179 | <div class="titlepage"> |
| 180 | <div> |
| 181 | <div> |
| 182 | <h3 class="title"><a id="idp6716864"></a>Environment Variables</h3> |
| 183 | </div> |
| 184 | </div> |
| 185 | </div> |
| 186 | <p> |
| 187 | The environment variable <code class="literal">DB_HOME</code> may be used as the path of |
| 188 | the database environment home. |
| 189 | </p> |
| 190 | </div> |
| 191 | <div class="sect2" lang="en" xml:lang="en"> |
| 192 | <div class="titlepage"> |
| 193 | <div> |
| 194 | <div> |
| 195 | <h3 class="title"><a id="idp6705936"></a>Errors</h3> |
| 196 | </div> |
| 197 | </div> |
| 198 | </div> |
| 199 | <p> |
| 200 | The <code class="methodname">DbEnv::dbrename()</code> <span> |
| 201 | |
| 202 | <span> |
| 203 | method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a> |
| 204 | exception, encapsulating one of the following non-zero errors, or return one |
| 205 | of the following non-zero errors: |
| 206 | </span> |
| 207 | </span> |
| 208 | </p> |
| 209 | <div class="sect3" lang="en" xml:lang="en"> |
| 210 | <div class="titlepage"> |
| 211 | <div> |
| 212 | <div> |
| 213 | <h4 class="title"><a id="idp6717944"></a><span>DbDeadlockException or </span>DB_LOCK_DEADLOCK</h4> |
| 214 | </div> |
| 215 | </div> |
| 216 | </div> |
| 217 | <p> |
| 218 | A transactional database environment operation was selected to resolve |
| 219 | a deadlock. |
| 220 | </p> |
| 221 | <p> |
| 222 | <a class="xref" href="dbdeadlock.html" title="DbDeadlockException">DbDeadlockException</a> is thrown if |
| 223 | your Berkeley DB API is configured to throw exceptions. |
| 224 | Otherwise, <code class="literal">DB_LOCK_DEADLOCK</code> is returned. |
| 225 | </p> |
| 226 | </div> |
| 227 | <div class="sect3" lang="en" xml:lang="en"> |
| 228 | <div class="titlepage"> |
| 229 | <div> |
| 230 | <div> |
| 231 | <h4 class="title"><a id="idp6709344"></a><span>DbLockNotGrantedException or </span>DB_LOCK_NOTGRANTED</h4> |
| 232 | </div> |
| 233 | </div> |
| 234 | </div> |
| 235 | <p> |
| 236 | A Berkeley DB Concurrent Data Store database environment configured |
| 237 | for lock timeouts was unable to grant a lock in the allowed time. |
| 238 | </p> |
| 239 | <p> |
| 240 | You attempted to open a database handle that is configured |
| 241 | for no waiting exclusive locking, but the exclusive lock could not be |
| 242 | immediately obtained. See |
| 243 | <a class="xref" href="dbset_lk_exclusive.html" title="Db::set_lk_exclusive()">Db::set_lk_exclusive()</a> |
| 244 | for more information. |
| 245 | </p> |
| 246 | <p> |
| 247 | <a class="xref" href="dblocknotgranted.html" title="DbLockNotGrantedException">DbLockNotGrantedException</a> is thrown if |
| 248 | your Berkeley DB API is configured to throw exceptions. |
| 249 | Otherwise, <code class="literal">DB_LOCK_NOTGRANTED</code> is returned. |
| 250 | </p> |
| 251 | </div> |
| 252 | <div class="sect3" lang="en" xml:lang="en"> |
| 253 | <div class="titlepage"> |
| 254 | <div> |
| 255 | <div> |
| 256 | <h4 class="title"><a id="idp6692944"></a>EINVAL</h4> |
| 257 | </div> |
| 258 | </div> |
| 259 | </div> |
| 260 | <p> |
| 261 | If the method was called before <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> |
| 262 | was called; or if an invalid flag value or parameter was specified. |
| 263 | </p> |
| 264 | </div> |
| 265 | <div class="sect3" lang="en" xml:lang="en"> |
| 266 | <div class="titlepage"> |
| 267 | <div> |
| 268 | <div> |
| 269 | <h4 class="title"><a id="idp6678568"></a>ENOENT</h4> |
| 270 | </div> |
| 271 | </div> |
| 272 | </div> |
| 273 | <p> |
| 274 | The file or directory does not exist. |
| 275 | </p> |
| 276 | </div> |
| 277 | </div> |
| 278 | <div class="sect2" lang="en" xml:lang="en"> |
| 279 | <div class="titlepage"> |
| 280 | <div> |
| 281 | <div> |
| 282 | <h3 class="title"><a id="idp6721464"></a>Class</h3> |
| 283 | </div> |
| 284 | </div> |
| 285 | </div> |
| 286 | <p> |
| 287 | <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> |
| 288 | </p> |
| 289 | </div> |
| 290 | <div class="sect2" lang="en" xml:lang="en"> |
| 291 | <div class="titlepage"> |
| 292 | <div> |
| 293 | <div> |
| 294 | <h3 class="title"><a id="idp6709880"></a>See Also</h3> |
| 295 | </div> |
| 296 | </div> |
| 297 | </div> |
| 298 | <p> |
| 299 | <a class="xref" href="env.html#envlist" title="Database Environments and Related Methods">Database Environments and Related Methods</a> |
| 300 | </p> |
| 301 | </div> |
| 302 | </div> |
| 303 | <div class="navfooter"> |
| 304 | <hr /> |
| 305 | <table width="100%" summary="Navigation footer"> |
| 306 | <tr> |
| 307 | <td width="40%" align="left"><a accesskey="p" href="envdbremove.html">Prev</a> </td> |
| 308 | <td width="20%" align="center"> |
| 309 | <a accesskey="u" href="env.html">Up</a> |
| 310 | </td> |
| 311 | <td width="40%" align="right"> <a accesskey="n" href="enverr.html">Next</a></td> |
| 312 | </tr> |
| 313 | <tr> |
| 314 | <td width="40%" align="left" valign="top">DbEnv::dbremove() </td> |
| 315 | <td width="20%" align="center"> |
| 316 | <a accesskey="h" href="index.html">Home</a> |
| 317 | </td> |
| 318 | <td width="40%" align="right" valign="top"> DbEnv::err()</td> |
| 319 | </tr> |
| 320 | </table> |
| 321 | </div> |
| 322 | </body> |
| 323 | </html> |