| 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::rename()</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="db.html" title="Chapter 2. The Db Handle" /> |
| 11 | <link rel="prev" href="dbremove.html" title="Db::remove()" /> |
| 12 | <link rel="next" href="dbset_alloc.html" title="Db::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">Db::rename()</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="dbremove.html">Prev</a> </td> |
| 25 | <th width="60%" align="center">Chapter 2. |
| 26 | The Db Handle |
| 27 | </th> |
| 28 | <td width="20%" align="right"> <a accesskey="n" href="dbset_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="dbrename"></a>Db::rename()</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <pre class="programlisting">#include <db_cxx.h> |
| 42 | |
| 43 | int |
| 44 | Db::rename(const char *file, |
| 45 | const char *database, const char *newname, u_int32_t flags);</pre> |
| 46 | <p> |
| 47 | The <code class="methodname">Db::rename()</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 | incidentally renaming all of the databases it contained. |
| 51 | </p> |
| 52 | <p> |
| 53 | Applications should not rename databases that are currently in use. |
| 54 | If an underlying file is being renamed and logging is currently |
| 55 | enabled in the database environment, no database in the file may be |
| 56 | open when the <code class="methodname">Db::rename()</code> method is called. In particular, some |
| 57 | architectures do not permit renaming files with open handles. On |
| 58 | these architectures, attempts to rename databases that are currently |
| 59 | in use by any thread of control in the system may fail. |
| 60 | </p> |
| 61 | <p> |
| 62 | The <code class="methodname">Db::rename()</code> method should not be called if the rename is |
| 63 | intended to be transactionally safe; the |
| 64 | <a class="xref" href="envdbrename.html" title="DbEnv::dbrename()">DbEnv::dbrename()</a> method |
| 65 | should be used instead. |
| 66 | </p> |
| 67 | <p> |
| 68 | The <code class="methodname">Db::rename()</code> method may not be called after calling the |
| 69 | <a class="xref" href="dbopen.html" title="Db::open()">Db::open()</a> method on any |
| 70 | <a class="link" href="db.html" title="Chapter 2. The Db Handle">Db</a> handle. If the |
| 71 | <a class="xref" href="dbopen.html" title="Db::open()">Db::open()</a> method has already |
| 72 | been called on a <a class="link" href="db.html" title="Chapter 2. The Db Handle">Db</a> |
| 73 | handle, close the existing handle and create a new one before calling |
| 74 | <code class="methodname">Db::rename()</code>. |
| 75 | </p> |
| 76 | <p> |
| 77 | The <a class="link" href="db.html" title="Chapter 2. The Db Handle">Db</a> handle may not be |
| 78 | accessed again after <code class="methodname">Db::rename()</code> is called, regardless of its |
| 79 | return. |
| 80 | </p> |
| 81 | <p> |
| 82 | The <code class="methodname">Db::rename()</code> <span> |
| 83 | |
| 84 | <span> |
| 85 | method either returns a non-zero error value or throws an |
| 86 | exception that encapsulates a non-zero error value on |
| 87 | failure, and returns 0 on success. |
| 88 | </span> |
| 89 | </span> |
| 90 | </p> |
| 91 | <div class="sect2" lang="en" xml:lang="en"> |
| 92 | <div class="titlepage"> |
| 93 | <div> |
| 94 | <div> |
| 95 | <h3 class="title"><a id="idm1906688"></a>Parameters</h3> |
| 96 | </div> |
| 97 | </div> |
| 98 | </div> |
| 99 | <div class="sect3" lang="en" xml:lang="en"> |
| 100 | <div class="titlepage"> |
| 101 | <div> |
| 102 | <div> |
| 103 | <h4 class="title"><a id="idm1448512"></a>file</h4> |
| 104 | </div> |
| 105 | </div> |
| 106 | </div> |
| 107 | <p> |
| 108 | The <span class="bold"><strong>file</strong></span> parameter is the physical |
| 109 | file which contains the database(s) to be renamed. |
| 110 | </p> |
| 111 | <p> |
| 112 | When using a Unicode build on Windows (the default), the |
| 113 | <span class="bold"><strong>file</strong></span> argument will |
| 114 | be interpreted as a UTF-8 string, which is equivalent to ASCII for Latin |
| 115 | characters. |
| 116 | </p> |
| 117 | </div> |
| 118 | <div class="sect3" lang="en" xml:lang="en"> |
| 119 | <div class="titlepage"> |
| 120 | <div> |
| 121 | <div> |
| 122 | <h4 class="title"><a id="idm1271648"></a>database</h4> |
| 123 | </div> |
| 124 | </div> |
| 125 | </div> |
| 126 | <p> |
| 127 | The <span class="bold"><strong>database</strong></span> parameter is the |
| 128 | database to be renamed. |
| 129 | </p> |
| 130 | </div> |
| 131 | <div class="sect3" lang="en" xml:lang="en"> |
| 132 | <div class="titlepage"> |
| 133 | <div> |
| 134 | <div> |
| 135 | <h4 class="title"><a id="idm716560"></a>newname</h4> |
| 136 | </div> |
| 137 | </div> |
| 138 | </div> |
| 139 | <p> |
| 140 | The <span class="bold"><strong>newname</strong></span> parameter is the new name |
| 141 | of the database or file. |
| 142 | </p> |
| 143 | </div> |
| 144 | <div class="sect3" lang="en" xml:lang="en"> |
| 145 | <div class="titlepage"> |
| 146 | <div> |
| 147 | <div> |
| 148 | <h4 class="title"><a id="idm1748248"></a>flags</h4> |
| 149 | </div> |
| 150 | </div> |
| 151 | </div> |
| 152 | <p> |
| 153 | The <span class="bold"><strong>flags</strong></span> parameter is currently unused, and must |
| 154 | be set to 0. |
| 155 | </p> |
| 156 | </div> |
| 157 | </div> |
| 158 | <div class="sect2" lang="en" xml:lang="en"> |
| 159 | <div class="titlepage"> |
| 160 | <div> |
| 161 | <div> |
| 162 | <h3 class="title"><a id="idm2140008"></a>Environment Variables</h3> |
| 163 | </div> |
| 164 | </div> |
| 165 | </div> |
| 166 | <p> |
| 167 | If the database was opened within a database environment, the |
| 168 | environment variable <code class="literal">DB_HOME</code> may be used as the path of the |
| 169 | database environment home. |
| 170 | </p> |
| 171 | <p> |
| 172 | <code class="methodname">Db::rename()</code> is affected by any database directory specified using the |
| 173 | <a class="xref" href="envset_data_dir.html" title="DbEnv::set_data_dir()">DbEnv::set_data_dir()</a> |
| 174 | method, or by setting the "set_data_dir" string |
| 175 | in the environment's <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file. |
| 176 | </p> |
| 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="idm1877000"></a>Errors</h3> |
| 183 | </div> |
| 184 | </div> |
| 185 | </div> |
| 186 | <p> |
| 187 | The <code class="methodname">Db::rename()</code> <span> |
| 188 | |
| 189 | <span> |
| 190 | method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a> |
| 191 | exception, encapsulating one of the following non-zero errors, or return one |
| 192 | of the following non-zero errors: |
| 193 | </span> |
| 194 | </span> |
| 195 | </p> |
| 196 | <div class="sect3" lang="en" xml:lang="en"> |
| 197 | <div class="titlepage"> |
| 198 | <div> |
| 199 | <div> |
| 200 | <h4 class="title"><a id="idm2134664"></a>EINVAL</h4> |
| 201 | </div> |
| 202 | </div> |
| 203 | </div> |
| 204 | <p> |
| 205 | If the method was called after <a class="xref" href="dbopen.html" title="Db::open()">Db::open()</a> |
| 206 | was called; or if an invalid flag value or parameter was specified. |
| 207 | </p> |
| 208 | </div> |
| 209 | <div class="sect3" lang="en" xml:lang="en"> |
| 210 | <div class="titlepage"> |
| 211 | <div> |
| 212 | <div> |
| 213 | <h4 class="title"><a id="idm962264"></a>ENOENT</h4> |
| 214 | </div> |
| 215 | </div> |
| 216 | </div> |
| 217 | <p> |
| 218 | The file or directory does not exist. |
| 219 | </p> |
| 220 | </div> |
| 221 | </div> |
| 222 | <div class="sect2" lang="en" xml:lang="en"> |
| 223 | <div class="titlepage"> |
| 224 | <div> |
| 225 | <div> |
| 226 | <h3 class="title"><a id="idm900792"></a>Class</h3> |
| 227 | </div> |
| 228 | </div> |
| 229 | </div> |
| 230 | <p> |
| 231 | <a class="link" href="db.html" title="Chapter 2. The Db Handle">Db</a> |
| 232 | </p> |
| 233 | </div> |
| 234 | <div class="sect2" lang="en" xml:lang="en"> |
| 235 | <div class="titlepage"> |
| 236 | <div> |
| 237 | <div> |
| 238 | <h3 class="title"><a id="idm1926792"></a>See Also</h3> |
| 239 | </div> |
| 240 | </div> |
| 241 | </div> |
| 242 | <p> |
| 243 | <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a> |
| 244 | </p> |
| 245 | </div> |
| 246 | </div> |
| 247 | <div class="navfooter"> |
| 248 | <hr /> |
| 249 | <table width="100%" summary="Navigation footer"> |
| 250 | <tr> |
| 251 | <td width="40%" align="left"><a accesskey="p" href="dbremove.html">Prev</a> </td> |
| 252 | <td width="20%" align="center"> |
| 253 | <a accesskey="u" href="db.html">Up</a> |
| 254 | </td> |
| 255 | <td width="40%" align="right"> <a accesskey="n" href="dbset_alloc.html">Next</a></td> |
| 256 | </tr> |
| 257 | <tr> |
| 258 | <td width="40%" align="left" valign="top">Db::remove() </td> |
| 259 | <td width="20%" align="center"> |
| 260 | <a accesskey="h" href="index.html">Home</a> |
| 261 | </td> |
| 262 | <td width="40%" align="right" valign="top"> Db::set_alloc()</td> |
| 263 | </tr> |
| 264 | </table> |
| 265 | </div> |
| 266 | </body> |
| 267 | </html> |