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