Debian Codegraph @

docs/api_reference/C/dbjoin.html

raw symbols SCIP
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-&gt;join()</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="dbget_type.html" title="DB-&gt;get_type()" />
12 <link rel="next" href="dbkey_range.html" title="DB-&gt;key_range()" />
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-&gt;join()</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="dbget_type.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="dbkey_range.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="dbjoin"></a>DB-&gt;join()</h2>
38 </div>
39 </div>
40 </div>
41 <pre class="programlisting">#include &lt;db.h&gt;
42
43 int
44 DB-&gt;join(DB *primary,
45 DBC **curslist, DBC **dbcp, u_int32_t flags); </pre>
46 <p>
47 The <code class="methodname">DB-&gt;join()</code> method creates a specialized join cursor for use in
48 performing equality or natural joins on secondary indices. For
49 information on how to organize your data to use this functionality,
50 see <a href="../../programmer_reference/am_cursor.html#am_join" class="olink">Equality join</a>.
51 </p>
52 <p>
53 The <code class="methodname">DB-&gt;join()</code> method is called using the
54 <a class="link" href="db.html" title="Chapter 2.  The DB Handle">DB</a> handle of the primary
55 database.
56 </p>
57 <p>
58 The join cursor supports only the <a class="xref" href="dbcget.html" title="DBcursor-&gt;get()">DBcursor-&gt;get()</a> and
59 <a class="xref" href="dbcclose.html" title="DBcursor-&gt;close()">DBcursor-&gt;close()</a> cursor functions:
60 </p>
61 <div class="itemizedlist">
62 <ul type="disc">
63 <li>
64 <p>
65 <span class="bold"><strong> <a class="xref" href="dbcget.html" title="DBcursor-&gt;get()">DBcursor-&gt;get()</a> </strong></span>
66 </p>
67 <p>
68 Iterates over the values associated with the keys to which each item
69 in <span class="bold"><strong>curslist</strong></span> was initialized. Any
70 data value that appears in all items specified by the <span class="bold"><strong>curslist</strong></span> parameter is then used as a key into
71 the <span class="bold"><strong>primary</strong></span>, and the key/data pair
72 found in the <span class="bold"><strong>primary</strong></span> is returned. The
73 <span class="bold"><strong>flags</strong></span> parameter must be set to 0 or
74 the following value:
75
76 </p>
77 <div class="itemizedlist">
78 <ul type="circle">
79 <li>
80 <p>
81 <span class="bold"><strong><code class="literal">DB_JOIN_ITEM</code></strong></span>
82 </p>
83 <p>
84 Do not use the data value found in all the cursors as a lookup key for
85 the <span class="bold"><strong>primary</strong></span>, but simply return it in
86 the key parameter instead. The data parameter is left unchanged.
87 </p>
88 </li>
89 </ul>
90 </div>
91 <p>
92 In addition, the following flag may be set by bitwise inclusively
93 <span class="bold"><strong>OR</strong></span>'ing it into the <span class="bold"><strong>flags</strong></span> parameter:
94 </p>
95 <div class="itemizedlist">
96 <ul type="circle">
97 <li>
98 <p>
99 <span class="bold"><strong> <code class="literal">DB_READ_UNCOMMITTED</code></strong></span>
100 </p>
101 <p>
102 Configure a transactional join operation to have degree 1 isolation,
103 reading modified but not yet committed data. Silently ignored if the
104 <a class="link" href="dbopen.html#dbopen_DB_READ_UNCOMMITTED">DB_READ_UNCOMMITTED</a>
105 flag was not specified when the underlying database was opened.
106 </p>
107 </li>
108 <li>
109 <p>
110 <span class="bold"><strong><code class="literal">DB_RMW</code></strong></span>
111 </p>
112 <p>
113 Acquire write locks instead of read locks when doing the read, if
114 locking is configured. Setting this flag can eliminate deadlock
115 during a read-modify-write cycle by acquiring the write lock during
116 the read part of the cycle so that another thread of control acquiring
117 a read lock for the same item, in its own read-modify-write cycle,
118 will not result in deadlock.
119 </p>
120 </li>
121 </ul>
122 </div>
123 </li>
124 <li>
125 <p>
126 <span class="bold"><strong> <a class="xref" href="dbcclose.html" title="DBcursor-&gt;close()">DBcursor-&gt;close()</a> </strong></span>
127 </p>
128 <p>
129 Close the returned cursor and release all resources. (Closing the
130 cursors in <span class="bold"><strong>curslist</strong></span> is the
131 responsibility of the caller.)
132 </p>
133 </li>
134 </ul>
135 </div>
136 <p>
137 The <code class="methodname">DB-&gt;join()</code> <span>
138 <span>
139 method returns a non-zero error value on failure and 0 on success.
140 </span>
141
142 </span>
143 </p>
144 <div class="sect2" lang="en" xml:lang="en">
145 <div class="titlepage">
146 <div>
147 <div>
148 <h3 class="title"><a id="idp49849416"></a>Parameters</h3>
149 </div>
150 </div>
151 </div>
152 <div class="sect3" lang="en" xml:lang="en">
153 <div class="titlepage">
154 <div>
155 <div>
156 <h4 class="title"><a id="idp49850064"></a>curslist</h4>
157 </div>
158 </div>
159 </div>
160 <p>
161 The <span class="bold"><strong>curslist</strong></span> parameter contains a
162 NULL terminated array of cursors. Each cursor must have been
163 initialized to refer to the key on which the underlying database
164 should be joined. Typically, this initialization is done by a
165 <a class="xref" href="dbcget.html" title="DBcursor-&gt;get()">DBcursor-&gt;get()</a> call with the
166 <a class="link" href="dbcget.html#dbcget_DB_SET">DB_SET</a> flag
167 specified. Once the cursors have been passed as part of a <span class="bold"><strong>curslist</strong></span>, they should not be accessed or
168 modified until the newly created join cursor has been closed, or else
169 inconsistent results may be returned.
170 </p>
171 <p>
172 Joined values are retrieved by doing a sequential iteration over the
173 first cursor in the <span class="bold"><strong>curslist</strong></span>
174 parameter, and a nested iteration over each secondary cursor in the
175 order they are specified in the <span class="bold"><strong>curslist</strong></span> parameter. This requires database
176 traversals to search for the current datum in all the cursors after
177 the first. For this reason, the best join performance normally
178 results from sorting the cursors from the one that refers to the least
179 number of data items to the one that refers to the most. By default,
180 <code class="methodname">DB-&gt;join()</code> does this sort on behalf of its caller.
181 </p>
182 <p>
183 For the returned join cursor to be used in a transaction-protected
184 manner, the cursors listed in <span class="bold"><strong>curslist</strong></span> must have been created within the
185 context of the same transaction.
186 </p>
187 </div>
188 <div class="sect3" lang="en" xml:lang="en">
189 <div class="titlepage">
190 <div>
191 <div>
192 <h4 class="title"><a id="idp49840136"></a>dbcp</h4>
193 </div>
194 </div>
195 </div>
196 <p>
197 The newly created join cursor is returned in the memory location to
198 which <span class="bold"><strong>dbcp</strong></span> refers.
199 </p>
200 </div>
201 <div class="sect3" lang="en" xml:lang="en">
202 <div class="titlepage">
203 <div>
204 <div>
205 <h4 class="title"><a id="idp49842064"></a>flags</h4>
206 </div>
207 </div>
208 </div>
209 <p>
210 The <span class="bold"><strong>flags</strong></span> parameter must be set to 0
211 or the following value:
212 </p>
213 <div class="itemizedlist">
214 <ul type="disc">
215 <li>
216 <p><a id="join_DB_JOIN_NOSORT"></a>
217 <code class="literal">DB_JOIN_NOSORT</code>
218 </p>
219 <p>
220 Do not sort the cursors based on the number of data items to which
221 they refer. If the data are structured so that cursors with many data
222 items also share many common elements, higher performance will result
223 from listing those cursors before cursors with fewer data items; that
224 is, a sort order other than the default. The DB_JOIN_NOSORT flag
225 permits applications to perform join optimization prior to calling the
226 <code class="methodname">DB-&gt;join()</code> method.
227 </p>
228 </li>
229 </ul>
230 </div>
231 </div>
232 </div>
233 <div class="sect2" lang="en" xml:lang="en">
234 <div class="titlepage">
235 <div>
236 <div>
237 <h3 class="title"><a id="idp49852344"></a>Errors</h3>
238 </div>
239 </div>
240 </div>
241 <p>
242 The <code class="methodname">DB-&gt;join()</code> <span>
243 <span>
244 method may fail and return one of the following non-zero errors:
245 </span>
246
247 </span>
248 </p>
249 <div class="sect3" lang="en" xml:lang="en">
250 <div class="titlepage">
251 <div>
252 <div>
253 <h4 class="title"><a id="idp49833928"></a> DB_REP_HANDLE_DEAD</h4>
254 </div>
255 </div>
256 </div>
257 <p>
258 When a client synchronizes with the master, it is possible for committed
259 transactions to be rolled back. This invalidates all the database and cursor
260 handles opened in the replication environment. Once this occurs, an attempt to use
261 such a handle will
262
263 return <code class="literal">DB_REP_HANDLE_DEAD</code>.
264 The application will need to discard the handle and open a new one in order to
265 continue processing.
266 </p>
267 </div>
268 <div class="sect3" lang="en" xml:lang="en">
269 <div class="titlepage">
270 <div>
271 <div>
272 <h4 class="title"><a id="idp49864088"></a>DB_REP_LOCKOUT</h4>
273 </div>
274 </div>
275 </div>
276 <p>
277 The operation was blocked by client/master synchronization.
278 </p>
279 </div>
280 <div class="sect3" lang="en" xml:lang="en">
281 <div class="titlepage">
282 <div>
283 <div>
284 <h4 class="title"><a id="idp49845568"></a>DB_SECONDARY_BAD</h4>
285 </div>
286 </div>
287 </div>
288 <p>
289 A secondary index references a nonexistent primary key.
290 </p>
291 </div>
292 <div class="sect3" lang="en" xml:lang="en">
293 <div class="titlepage">
294 <div>
295 <div>
296 <h4 class="title"><a id="idp49834328"></a>EINVAL</h4>
297 </div>
298 </div>
299 </div>
300 <p>
301 If cursor methods other than <a class="xref" href="dbcget.html" title="DBcursor-&gt;get()">DBcursor-&gt;get()</a>
302 or <a class="xref" href="dbcclose.html" title="DBcursor-&gt;close()">DBcursor-&gt;close()</a> were called;
303 or if an invalid flag value or parameter was specified.
304 </p>
305 </div>
306 </div>
307 <div class="sect2" lang="en" xml:lang="en">
308 <div class="titlepage">
309 <div>
310 <div>
311 <h3 class="title"><a id="idp49865416"></a>Class</h3>
312 </div>
313 </div>
314 </div>
315 <p>
316 <a class="link" href="db.html" title="Chapter 2.  The DB Handle">DB</a>
317 </p>
318 </div>
319 <div class="sect2" lang="en" xml:lang="en">
320 <div class="titlepage">
321 <div>
322 <div>
323 <h3 class="title"><a id="idp49841496"></a>See Also</h3>
324 </div>
325 </div>
326 </div>
327 <p>
328 <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a>
329 </p>
330 </div>
331 </div>
332 <div class="navfooter">
333 <hr />
334 <table width="100%" summary="Navigation footer">
335 <tr>
336 <td width="40%" align="left"><a accesskey="p" href="dbget_type.html">Prev</a> </td>
337 <td width="20%" align="center">
338 <a accesskey="u" href="db.html">Up</a>
339 </td>
340 <td width="40%" align="right"> <a accesskey="n" href="dbkey_range.html">Next</a></td>
341 </tr>
342 <tr>
343 <td width="40%" align="left" valign="top">DB-&gt;get_type() </td>
344 <td width="20%" align="center">
345 <a accesskey="h" href="index.html">Home</a>
346 </td>
347 <td width="40%" align="right" valign="top"> DB-&gt;key_range()</td>
348 </tr>
349 </table>
350 </div>
351 </body>
352 </html>