| 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->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 DB_ENV Handle" /> |
| 11 | <link rel="prev" href="envdbremove.html" title="DB_ENV->dbremove()" /> |
| 12 | <link rel="next" href="enverr.html" title="DB_ENV->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">DB_ENV->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 DB_ENV 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>DB_ENV->dbrename()</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <pre class="programlisting">#include <db.h> |
| 42 | |
| 43 | int |
| 44 | DB_ENV->dbrename(DB_ENV *dbenv, DB_TXN *txnid, const char *file, |
| 45 | const char *database, const char *newname, u_int32_t flags); </pre> |
| 46 | <p> |
| 47 | The <code class="methodname">DB_ENV->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">DB_ENV->dbrename()</code> method is called. |
| 58 | </p> |
| 59 | <p> |
| 60 | The <code class="methodname">DB_ENV->dbrename()</code> <span> |
| 61 | <span> |
| 62 | method returns a non-zero error value on failure and 0 on success. |
| 63 | </span> |
| 64 | |
| 65 | </span> |
| 66 | </p> |
| 67 | <p> |
| 68 | <code class="methodname">DB_ENV->dbrename()</code> is affected by any database directory specified using the |
| 69 | <a class="xref" href="envset_data_dir.html" title="DB_ENV->set_data_dir()">DB_ENV->set_data_dir()</a> |
| 70 | method, or by setting the <code class="literal">set_data_dir</code> string in the environment's |
| 71 | <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file. |
| 72 | </p> |
| 73 | <div class="sect2" lang="en" xml:lang="en"> |
| 74 | <div class="titlepage"> |
| 75 | <div> |
| 76 | <div> |
| 77 | <h3 class="title"><a id="idp51365152"></a>Parameters</h3> |
| 78 | </div> |
| 79 | </div> |
| 80 | </div> |
| 81 | <div class="sect3" lang="en" xml:lang="en"> |
| 82 | <div class="titlepage"> |
| 83 | <div> |
| 84 | <div> |
| 85 | <h4 class="title"><a id="idp51365344"></a>txnid</h4> |
| 86 | </div> |
| 87 | </div> |
| 88 | </div> |
| 89 | <p> |
| 90 | If the operation is part of an application-specified transaction, the |
| 91 | <span class="bold"><strong>txnid</strong></span> parameter is a transaction |
| 92 | handle returned from <a class="xref" href="txnbegin.html" title="DB_ENV->txn_begin()">DB_ENV->txn_begin()</a>; if the |
| 93 | operation is part of a Berkeley DB Concurrent Data Store group, the |
| 94 | <span class="bold"><strong>txnid</strong></span> parameter is a handle returned |
| 95 | from <a class="xref" href="envcdsgroup_begin.html" title="DB_ENV->cdsgroup_begin()">DB_ENV->cdsgroup_begin()</a>; |
| 96 | otherwise NULL. If no transaction handle is specified, but the |
| 97 | <code class="literal">DB_AUTO_COMMIT</code> flag is specified to either this method or the |
| 98 | environment handle, the operation will be implicitly |
| 99 | transaction protected. |
| 100 | </p> |
| 101 | </div> |
| 102 | <div class="sect3" lang="en" xml:lang="en"> |
| 103 | <div class="titlepage"> |
| 104 | <div> |
| 105 | <div> |
| 106 | <h4 class="title"><a id="idp51366400"></a>file</h4> |
| 107 | </div> |
| 108 | </div> |
| 109 | </div> |
| 110 | <p> |
| 111 | The <span class="bold"><strong>file</strong></span> parameter is the physical |
| 112 | file which contains the database(s) to be renamed. |
| 113 | </p> |
| 114 | <p> |
| 115 | When using a Unicode build on Windows (the default), the |
| 116 | <span class="bold"><strong>file</strong></span> argument will |
| 117 | be interpreted as a UTF-8 string, which is equivalent to ASCII for Latin |
| 118 | characters. |
| 119 | </p> |
| 120 | </div> |
| 121 | <div class="sect3" lang="en" xml:lang="en"> |
| 122 | <div class="titlepage"> |
| 123 | <div> |
| 124 | <div> |
| 125 | <h4 class="title"><a id="idp51327920"></a>database</h4> |
| 126 | </div> |
| 127 | </div> |
| 128 | </div> |
| 129 | <p> |
| 130 | The <span class="bold"><strong>database</strong></span> parameter is the |
| 131 | database to be renamed. |
| 132 | </p> |
| 133 | </div> |
| 134 | <div class="sect3" lang="en" xml:lang="en"> |
| 135 | <div class="titlepage"> |
| 136 | <div> |
| 137 | <div> |
| 138 | <h4 class="title"><a id="idp51361128"></a>newname</h4> |
| 139 | </div> |
| 140 | </div> |
| 141 | </div> |
| 142 | <p> |
| 143 | The <span class="bold"><strong>newname</strong></span> parameter is the new name |
| 144 | of the database or file. |
| 145 | </p> |
| 146 | </div> |
| 147 | <div class="sect3" lang="en" xml:lang="en"> |
| 148 | <div class="titlepage"> |
| 149 | <div> |
| 150 | <div> |
| 151 | <h4 class="title"><a id="idp51362672"></a>flags</h4> |
| 152 | </div> |
| 153 | </div> |
| 154 | </div> |
| 155 | <p> |
| 156 | The <span class="bold"><strong>flags</strong></span> parameter |
| 157 | must be set to 0 or the following value: |
| 158 | </p> |
| 159 | <div class="itemizedlist"> |
| 160 | <ul type="disc"> |
| 161 | <li> |
| 162 | <p> |
| 163 | <code class="literal">DB_AUTO_COMMIT</code> |
| 164 | </p> |
| 165 | <p> |
| 166 | Enclose the <code class="methodname">DB_ENV->dbrename()</code> |
| 167 | call within a transaction. If the call |
| 168 | succeeds, changes made by the operation will be recoverable. If the |
| 169 | call fails, the operation will have made no changes. |
| 170 | </p> |
| 171 | </li> |
| 172 | </ul> |
| 173 | </div> |
| 174 | </div> |
| 175 | </div> |
| 176 | <div class="sect2" lang="en" xml:lang="en"> |
| 177 | <div class="titlepage"> |
| 178 | <div> |
| 179 | <div> |
| 180 | <h3 class="title"><a id="idp51374216"></a>Environment Variables</h3> |
| 181 | </div> |
| 182 | </div> |
| 183 | </div> |
| 184 | <p> |
| 185 | The environment variable <code class="literal">DB_HOME</code> may be used as the path of |
| 186 | the database environment home. |
| 187 | </p> |
| 188 | </div> |
| 189 | <div class="sect2" lang="en" xml:lang="en"> |
| 190 | <div class="titlepage"> |
| 191 | <div> |
| 192 | <div> |
| 193 | <h3 class="title"><a id="idp51363752"></a>Errors</h3> |
| 194 | </div> |
| 195 | </div> |
| 196 | </div> |
| 197 | <p> |
| 198 | The <code class="methodname">DB_ENV->dbrename()</code> <span> |
| 199 | <span> |
| 200 | method may fail and return one of the following non-zero errors: |
| 201 | </span> |
| 202 | |
| 203 | </span> |
| 204 | </p> |
| 205 | <div class="sect3" lang="en" xml:lang="en"> |
| 206 | <div class="titlepage"> |
| 207 | <div> |
| 208 | <div> |
| 209 | <h4 class="title"><a id="idp51379864"></a>DB_LOCK_DEADLOCK</h4> |
| 210 | </div> |
| 211 | </div> |
| 212 | </div> |
| 213 | <p> |
| 214 | A transactional database environment operation was selected to resolve |
| 215 | a deadlock. |
| 216 | </p> |
| 217 | </div> |
| 218 | <div class="sect3" lang="en" xml:lang="en"> |
| 219 | <div class="titlepage"> |
| 220 | <div> |
| 221 | <div> |
| 222 | <h4 class="title"><a id="idp51378240"></a>DB_LOCK_NOTGRANTED</h4> |
| 223 | </div> |
| 224 | </div> |
| 225 | </div> |
| 226 | <p> |
| 227 | A Berkeley DB Concurrent Data Store database environment configured |
| 228 | for lock timeouts was unable to grant a lock in the allowed time. |
| 229 | </p> |
| 230 | <p> |
| 231 | You attempted to open a database handle that is configured |
| 232 | for no waiting exclusive locking, but the exclusive lock could not be |
| 233 | immediately obtained. See |
| 234 | <a class="xref" href="dbset_lk_exclusive.html" title="DB->set_lk_exclusive()">DB->set_lk_exclusive()</a> |
| 235 | for more information. |
| 236 | </p> |
| 237 | </div> |
| 238 | <div class="sect3" lang="en" xml:lang="en"> |
| 239 | <div class="titlepage"> |
| 240 | <div> |
| 241 | <div> |
| 242 | <h4 class="title"><a id="idp51381072"></a>EINVAL</h4> |
| 243 | </div> |
| 244 | </div> |
| 245 | </div> |
| 246 | <p> |
| 247 | If the method was called before <a class="xref" href="envopen.html" title="DB_ENV->open()">DB_ENV->open()</a> |
| 248 | was called; or if an invalid flag value or parameter was specified. |
| 249 | </p> |
| 250 | </div> |
| 251 | <div class="sect3" lang="en" xml:lang="en"> |
| 252 | <div class="titlepage"> |
| 253 | <div> |
| 254 | <div> |
| 255 | <h4 class="title"><a id="idp51382152"></a>ENOENT</h4> |
| 256 | </div> |
| 257 | </div> |
| 258 | </div> |
| 259 | <p> |
| 260 | The file or directory does not exist. |
| 261 | </p> |
| 262 | </div> |
| 263 | </div> |
| 264 | <div class="sect2" lang="en" xml:lang="en"> |
| 265 | <div class="titlepage"> |
| 266 | <div> |
| 267 | <div> |
| 268 | <h3 class="title"><a id="idp51377704"></a>Class</h3> |
| 269 | </div> |
| 270 | </div> |
| 271 | </div> |
| 272 | <p> |
| 273 | <a class="link" href="env.html" title="Chapter 5. The DB_ENV Handle">DB_ENV</a> |
| 274 | </p> |
| 275 | </div> |
| 276 | <div class="sect2" lang="en" xml:lang="en"> |
| 277 | <div class="titlepage"> |
| 278 | <div> |
| 279 | <div> |
| 280 | <h3 class="title"><a id="idp51383232"></a>See Also</h3> |
| 281 | </div> |
| 282 | </div> |
| 283 | </div> |
| 284 | <p> |
| 285 | <a class="xref" href="env.html#envlist" title="Database Environments and Related Methods">Database Environments and Related Methods</a> |
| 286 | </p> |
| 287 | </div> |
| 288 | </div> |
| 289 | <div class="navfooter"> |
| 290 | <hr /> |
| 291 | <table width="100%" summary="Navigation footer"> |
| 292 | <tr> |
| 293 | <td width="40%" align="left"><a accesskey="p" href="envdbremove.html">Prev</a> </td> |
| 294 | <td width="20%" align="center"> |
| 295 | <a accesskey="u" href="env.html">Up</a> |
| 296 | </td> |
| 297 | <td width="40%" align="right"> <a accesskey="n" href="enverr.html">Next</a></td> |
| 298 | </tr> |
| 299 | <tr> |
| 300 | <td width="40%" align="left" valign="top">DB_ENV->dbremove() </td> |
| 301 | <td width="20%" align="center"> |
| 302 | <a accesskey="h" href="index.html">Home</a> |
| 303 | </td> |
| 304 | <td width="40%" align="right" valign="top"> DB_ENV->err()</td> |
| 305 | </tr> |
| 306 | </table> |
| 307 | </div> |
| 308 | </body> |
| 309 | </html> |