| 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_create</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="db_copy.html" title="db_copy" /> |
| 12 | <link rel="next" href="dbdel.html" title="DB->del()" /> |
| 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_create</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="db_copy.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="dbdel.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="dbcreate"></a>db_create</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <pre class="programlisting">#include <db.h> |
| 42 | |
| 43 | int db_create(DB **dbp, DB_ENV *dbenv, u_int32_t flags); </pre> |
| 44 | <p> |
| 45 | The <code class="function">db_create()</code> function creates a <a class="link" href="db.html" title="Chapter 2. The DB Handle">DB</a> |
| 46 | structure that is the handle for a Berkeley DB database. This function allocates memory for the |
| 47 | structure, returning a pointer to the structure in the memory to which |
| 48 | <span class="bold"><strong>dbp</strong></span> refers. To release the allocated memory and |
| 49 | discard the handle, call the <a class="xref" href="dbclose.html" title="DB->close()">DB->close()</a>, |
| 50 | <a class="xref" href="dbremove.html" title="DB->remove()">DB->remove()</a>, |
| 51 | <a class="xref" href="dbrename.html" title="DB->rename()">DB->rename()</a>, or |
| 52 | <a class="xref" href="dbverify.html" title="DB->verify()">DB->verify()</a> methods. |
| 53 | </p> |
| 54 | <p> |
| 55 | DB handles are free-threaded if the |
| 56 | <a class="link" href="envopen.html#envopen_DB_THREAD">DB_THREAD</a> flag is specified to |
| 57 | the <a class="xref" href="dbopen.html" title="DB->open()">DB->open()</a> method when the database is opened or |
| 58 | if the database environment in which the database is opened is free-threaded. The handle |
| 59 | should not be closed while any other handle that refers to the database is in use; for |
| 60 | example, database handles must not be closed while cursor handles into the database remain |
| 61 | open, or transactions that include operations on the database have not yet been committed |
| 62 | or aborted. Once the <a class="xref" href="dbclose.html" title="DB->close()">DB->close()</a>, |
| 63 | <a class="xref" href="dbremove.html" title="DB->remove()">DB->remove()</a>, |
| 64 | <a class="xref" href="dbrename.html" title="DB->rename()">DB->rename()</a>, or |
| 65 | <a class="xref" href="dbverify.html" title="DB->verify()">DB->verify()</a> |
| 66 | methods are called, the handle may not be accessed again, regardless of the method's return. |
| 67 | </p> |
| 68 | <p> |
| 69 | The DB handle contains a special field, <code class="literal">app_private</code>, |
| 70 | which is declared as type <code class="literal">void *</code>. This field is provided for the use |
| 71 | of the application program. It is initialized to NULL and is not further used by |
| 72 | Berkeley DB in any way. |
| 73 | </p> |
| 74 | <p> |
| 75 | The <code class="literal">db_create</code> function returns a non-zero error value on failure |
| 76 | and 0 on success. |
| 77 | </p> |
| 78 | <div class="sect2" lang="en" xml:lang="en"> |
| 79 | <div class="titlepage"> |
| 80 | <div> |
| 81 | <div> |
| 82 | <h3 class="title"><a id="idp49437224"></a>Parameters</h3> |
| 83 | </div> |
| 84 | </div> |
| 85 | </div> |
| 86 | <div class="sect3" lang="en" xml:lang="en"> |
| 87 | <div class="titlepage"> |
| 88 | <div> |
| 89 | <div> |
| 90 | <h4 class="title"><a id="idp49437448"></a>dbp</h4> |
| 91 | </div> |
| 92 | </div> |
| 93 | </div> |
| 94 | <p> |
| 95 | The <span class="bold"><strong>dbp</strong></span> parameter references the |
| 96 | memory into which the returned structure pointer is stored. |
| 97 | </p> |
| 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="idp49432784"></a>dbenv</h4> |
| 104 | </div> |
| 105 | </div> |
| 106 | </div> |
| 107 | <p> |
| 108 | <span>If the <span class="bold"><strong>dbenv</strong></span> parameter is NULL,</span> |
| 109 | |
| 110 | the database is standalone; that is, it is not part of any Berkeley DB |
| 111 | environment. |
| 112 | </p> |
| 113 | <p> |
| 114 | <span> |
| 115 | If the <span class="bold"><strong>dbenv</strong></span> parameter is not NULL, |
| 116 | </span> |
| 117 | |
| 118 | the database is created within the specified Berkeley DB environment. |
| 119 | The database access methods automatically make calls to the other |
| 120 | subsystems in Berkeley DB, based on the enclosing environment. For |
| 121 | example, if the environment has been configured to use locking, the |
| 122 | access methods will automatically acquire the correct locks when |
| 123 | reading and writing pages of the database. |
| 124 | </p> |
| 125 | </div> |
| 126 | <div class="sect3" lang="en" xml:lang="en"> |
| 127 | <div class="titlepage"> |
| 128 | <div> |
| 129 | <div> |
| 130 | <h4 class="title"><a id="idp49445520"></a>flags</h4> |
| 131 | </div> |
| 132 | </div> |
| 133 | </div> |
| 134 | <p> |
| 135 | The <span class="bold"><strong>flags</strong></span> parameter must be set to 0 or the following value: |
| 136 | </p> |
| 137 | <div class="itemizedlist"> |
| 138 | <ul type="disc"> |
| 139 | <li> |
| 140 | <p><a id="dbcreate_DB_XA_CREATE"></a> |
| 141 | <code class="literal">DB_XA_CREATE</code> |
| 142 | </p> |
| 143 | <p> |
| 144 | Instead of creating a standalone database, create a database intended |
| 145 | to be accessed via applications running under an X/Open conformant |
| 146 | Transaction Manager. The database will be opened in the environment |
| 147 | specified by the OPENINFO parameter of the GROUPS section of the |
| 148 | ubbconfig file. See the <a href="../../programmer_reference/xa_xa_intro.html" class="olink">XA Introduction</a> section in the Berkeley DB Reference Guide for |
| 149 | more information. |
| 150 | </p> |
| 151 | </li> |
| 152 | </ul> |
| 153 | </div> |
| 154 | </div> |
| 155 | </div> |
| 156 | <div class="sect2" lang="en" xml:lang="en"> |
| 157 | <div class="titlepage"> |
| 158 | <div> |
| 159 | <div> |
| 160 | <h3 class="title"><a id="idp49400640"></a>Errors</h3> |
| 161 | </div> |
| 162 | </div> |
| 163 | </div> |
| 164 | <p> |
| 165 | The <code class="function">db_create()</code> function may fail and return one of the following non-zero |
| 166 | errors: |
| 167 | </p> |
| 168 | <div class="sect3" lang="en" xml:lang="en"> |
| 169 | <div class="titlepage"> |
| 170 | <div> |
| 171 | <div> |
| 172 | <h4 class="title"><a id="idp49413856"></a>EINVAL</h4> |
| 173 | </div> |
| 174 | </div> |
| 175 | </div> |
| 176 | <p> |
| 177 | An invalid flag value or parameter was specified. |
| 178 | </p> |
| 179 | </div> |
| 180 | </div> |
| 181 | <div class="sect2" lang="en" xml:lang="en"> |
| 182 | <div class="titlepage"> |
| 183 | <div> |
| 184 | <div> |
| 185 | <h3 class="title"><a id="idp49433104"></a>Class</h3> |
| 186 | </div> |
| 187 | </div> |
| 188 | </div> |
| 189 | <p> |
| 190 | <a class="link" href="db.html" title="Chapter 2. The DB Handle">DB</a> |
| 191 | </p> |
| 192 | </div> |
| 193 | <div class="sect2" lang="en" xml:lang="en"> |
| 194 | <div class="titlepage"> |
| 195 | <div> |
| 196 | <div> |
| 197 | <h3 class="title"><a id="idp49256424"></a>See Also</h3> |
| 198 | </div> |
| 199 | </div> |
| 200 | </div> |
| 201 | <p> |
| 202 | <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a> |
| 203 | </p> |
| 204 | </div> |
| 205 | </div> |
| 206 | <div class="navfooter"> |
| 207 | <hr /> |
| 208 | <table width="100%" summary="Navigation footer"> |
| 209 | <tr> |
| 210 | <td width="40%" align="left"><a accesskey="p" href="db_copy.html">Prev</a> </td> |
| 211 | <td width="20%" align="center"> |
| 212 | <a accesskey="u" href="db.html">Up</a> |
| 213 | </td> |
| 214 | <td width="40%" align="right"> <a accesskey="n" href="dbdel.html">Next</a></td> |
| 215 | </tr> |
| 216 | <tr> |
| 217 | <td width="40%" align="left" valign="top">db_copy </td> |
| 218 | <td width="20%" align="center"> |
| 219 | <a accesskey="h" href="index.html">Home</a> |
| 220 | </td> |
| 221 | <td width="40%" align="right" valign="top"> DB->del()</td> |
| 222 | </tr> |
| 223 | </table> |
| 224 | </div> |
| 225 | </body> |
| 226 | </html> |