| 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->exists()</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="dberr.html" title="DB->err()" /> |
| 12 | <link rel="next" href="dbfd.html" title="DB->fd()" /> |
| 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->exists()</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="dberr.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="dbfd.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="dbexists"></a>DB->exists()</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <pre class="programlisting">#include <db.h> |
| 42 | |
| 43 | int |
| 44 | DB->exists(DB *db, DB_TXN *txnid, DBT *key, u_int32_t flags); </pre> |
| 45 | <p> |
| 46 | The <code class="methodname">DB->exists()</code> method returns whether the specified key appears in the |
| 47 | database. |
| 48 | </p> |
| 49 | <p> |
| 50 | The <code class="methodname">DB->exists()</code> method will return <a href="../../programmer_reference/program_errorret.html#program_errorret.DB_NOTFOUND" class="olink">DB_NOTFOUND</a> if the specified key |
| 51 | is not in the database. The <code class="methodname">DB->exists()</code> method will return |
| 52 | <a href="../../programmer_reference/program_errorret.html#program_errorret.DB_KEYEMPTY" class="olink">DB_KEYEMPTY</a> if the database |
| 53 | is a Queue or Recno database and the specified key exists, but was never explicitly created |
| 54 | by the application or was later deleted. |
| 55 | </p> |
| 56 | <div class="sect2" lang="en" xml:lang="en"> |
| 57 | <div class="titlepage"> |
| 58 | <div> |
| 59 | <div> |
| 60 | <h3 class="title"><a id="idp49495176"></a>Parameters</h3> |
| 61 | </div> |
| 62 | </div> |
| 63 | </div> |
| 64 | <div class="sect3" lang="en" xml:lang="en"> |
| 65 | <div class="titlepage"> |
| 66 | <div> |
| 67 | <div> |
| 68 | <h4 class="title"><a id="idp49458352"></a>txnid</h4> |
| 69 | </div> |
| 70 | </div> |
| 71 | </div> |
| 72 | <p> |
| 73 | If the operation is part of an application-specified transaction, the <span class="bold"><strong>txnid</strong></span> parameter is a transaction handle returned from |
| 74 | <a class="xref" href="txnbegin.html" title="DB_ENV->txn_begin()">DB_ENV->txn_begin()</a>; if the operation is part of a |
| 75 | Berkeley DB Concurrent Data Store group, the <span class="bold"><strong>txnid</strong></span> |
| 76 | parameter is a handle returned from |
| 77 | <a class="xref" href="envcdsgroup_begin.html" title="DB_ENV->cdsgroup_begin()">DB_ENV->cdsgroup_begin()</a>; otherwise NULL. |
| 78 | If no transaction handle is specified, but the |
| 79 | operation occurs in a transactional database, the operation will be |
| 80 | implicitly transaction protected. |
| 81 | </p> |
| 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="idp49498992"></a>key</h4> |
| 88 | </div> |
| 89 | </div> |
| 90 | </div> |
| 91 | <p> |
| 92 | The key <a class="link" href="dbt.html" title="Chapter 4. The DBT Handle">DBT</a> operated on. |
| 93 | </p> |
| 94 | </div> |
| 95 | <div class="sect3" lang="en" xml:lang="en"> |
| 96 | <div class="titlepage"> |
| 97 | <div> |
| 98 | <div> |
| 99 | <h4 class="title"><a id="idp49504368"></a>flags</h4> |
| 100 | </div> |
| 101 | </div> |
| 102 | </div> |
| 103 | <p> |
| 104 | The <span class="bold"><strong>flags</strong></span> parameter must be set to zero or |
| 105 | by bitwise inclusively <span class="bold"><strong>OR</strong></span>'ing together one |
| 106 | or more of the following values: |
| 107 | </p> |
| 108 | <div class="itemizedlist"> |
| 109 | <ul type="disc"> |
| 110 | <li> |
| 111 | <p><a id="exists_DB_READ_COMMITTED"></a> |
| 112 | <code class="literal">DB_READ_COMMITTED</code> |
| 113 | </p> |
| 114 | <p> |
| 115 | Configure a transactional read operation to have degree 2 isolation |
| 116 | (the read is not repeatable). |
| 117 | </p> |
| 118 | </li> |
| 119 | <li> |
| 120 | <p><a id="exists_DB_READ_UNCOMMITTED"></a> |
| 121 | <code class="literal">DB_READ_UNCOMMITTED</code> |
| 122 | </p> |
| 123 | <p> |
| 124 | Configure a transactional read operation to have degree 1 isolation, |
| 125 | reading modified but not yet committed data. Silently ignored if the |
| 126 | <a class="link" href="dbopen.html#dbopen_DB_READ_UNCOMMITTED">DB_READ_UNCOMMITTED</a> |
| 127 | flag was not specified when the underlying database was opened. |
| 128 | </p> |
| 129 | </li> |
| 130 | <li> |
| 131 | <p><a id="exists_DB_RMW"></a> |
| 132 | <code class="literal">DB_RMW</code> |
| 133 | </p> |
| 134 | <p> |
| 135 | Acquire write locks instead of read locks when doing the read, if locking is |
| 136 | configured. Setting this flag can eliminate deadlock during a read-modify-write |
| 137 | cycle by acquiring the write lock during the read part of the cycle so that |
| 138 | another thread of control acquiring a read lock for the same item, in its own |
| 139 | read-modify-write cycle, will not result in deadlock. |
| 140 | </p> |
| 141 | <p> |
| 142 | Because the <code class="methodname">DB->exists()</code> method will not hold locks |
| 143 | across Berkeley DB calls in non-transactional operations, the |
| 144 | <a class="link" href="dbcget.html#dbcget_DB_RMW">DB_RMW</a> flag to the |
| 145 | <code class="methodname">DB->exists()</code> call is meaningful only in the presence |
| 146 | of transactions. |
| 147 | </p> |
| 148 | </li> |
| 149 | </ul> |
| 150 | </div> |
| 151 | </div> |
| 152 | </div> |
| 153 | <div class="sect2" lang="en" xml:lang="en"> |
| 154 | <div class="titlepage"> |
| 155 | <div> |
| 156 | <div> |
| 157 | <h3 class="title"><a id="idp49517264"></a>Class</h3> |
| 158 | </div> |
| 159 | </div> |
| 160 | </div> |
| 161 | <p> |
| 162 | <a class="link" href="db.html" title="Chapter 2. The DB Handle">DB</a> |
| 163 | </p> |
| 164 | </div> |
| 165 | <div class="sect2" lang="en" xml:lang="en"> |
| 166 | <div class="titlepage"> |
| 167 | <div> |
| 168 | <div> |
| 169 | <h3 class="title"><a id="idp49511992"></a>See Also</h3> |
| 170 | </div> |
| 171 | </div> |
| 172 | </div> |
| 173 | <p> |
| 174 | <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a> |
| 175 | </p> |
| 176 | </div> |
| 177 | </div> |
| 178 | <div class="navfooter"> |
| 179 | <hr /> |
| 180 | <table width="100%" summary="Navigation footer"> |
| 181 | <tr> |
| 182 | <td width="40%" align="left"><a accesskey="p" href="dberr.html">Prev</a> </td> |
| 183 | <td width="20%" align="center"> |
| 184 | <a accesskey="u" href="db.html">Up</a> |
| 185 | </td> |
| 186 | <td width="40%" align="right"> <a accesskey="n" href="dbfd.html">Next</a></td> |
| 187 | </tr> |
| 188 | <tr> |
| 189 | <td width="40%" align="left" valign="top">DB->err() </td> |
| 190 | <td width="20%" align="center"> |
| 191 | <a accesskey="h" href="index.html">Home</a> |
| 192 | </td> |
| 193 | <td width="40%" align="right" valign="top"> DB->fd()</td> |
| 194 | </tr> |
| 195 | </table> |
| 196 | </div> |
| 197 | </body> |
| 198 | </html> |