• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src/router/db-4.8.30/docs/programmer_reference/
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>Cursor stability</title>
7    <link rel="stylesheet" href="gettingStarted.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 Programmer's Reference Guide" />
10    <link rel="up" href="am_misc.html" title="Chapter 4.  Access Method Wrapup" />
11    <link rel="prev" href="am_misc_error.html" title="Error support" />
12    <link rel="next" href="am_misc_dbsizes.html" title="Database limits" />
13  </head>
14  <body>
15    <div class="navheader">
16      <table width="100%" summary="Navigation header">
17        <tr>
18          <th colspan="3" align="center">Cursor stability</th>
19        </tr>
20        <tr>
21          <td width="20%" align="left"><a accesskey="p" href="am_misc_error.html">Prev</a> </td>
22          <th width="60%" align="center">Chapter 4. 
23		Access Method Wrapup
24        </th>
25          <td width="20%" align="right"> <a accesskey="n" href="am_misc_dbsizes.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="am_misc_stability"></a>Cursor stability</h2>
35          </div>
36        </div>
37      </div>
38      <p>In the absence of locking, no guarantees are made about the stability
39of cursors in different threads of control.  However, the Btree, Queue
40and Recno access methods guarantee that cursor operations, interspersed
41with any other operation in the same thread of control will always
42return keys in order and will return each non-deleted key/data pair
43exactly once.  Because the Hash access method uses a dynamic hashing
44algorithm, it cannot guarantee any form of stability in the presence of
45inserts and deletes unless transactional locking is performed.</p>
46      <p>If locking was specified when the Berkeley DB environment was opened, but
47transactions are not in effect, the access methods provide repeatable
48reads with respect to the cursor.  That is, a <a href="../api_reference/C/dbcget.html#dbcget_DB_CURRENT" class="olink">DB_CURRENT</a> call
49on the cursor is guaranteed to return the same record as was returned
50on the last call to the cursor.</p>
51      <p>In the presence of transactions, the Btree, Hash and Recno access
52methods provide degree 3 isolation (serializable transactions).  The
53Queue access method provides degree 3 isolation with the exception that
54it permits phantom records to appear between calls.  That is, deleted
55records are not locked, therefore another transaction may replace a
56deleted record between two calls to retrieve it.  The record would not
57appear in the first call but would be seen by the second call.  For
58readers not enclosed in transactions, all access method calls provide
59degree 2 isolation, that is, reads are not repeatable.  A transaction
60may be declared to run with degree 2 isolation by specifying the
61<a href="../api_reference/C/dbcget.html#dbcget_DB_READ_COMMITTED" class="olink">DB_READ_COMMITTED</a> flag.  Finally, Berkeley DB provides degree 1 isolation
62when the <a href="../api_reference/C/dbopen.html#dbopen_DB_READ_UNCOMMITTED" class="olink">DB_READ_UNCOMMITTED</a> flag is specified; that is, reads
63may see data modified in transactions which have not yet committed.</p>
64      <p>For all access methods, a cursor scan of the database performed within
65the context of a transaction is guaranteed to return each key/data pair
66once and only once, except in the following case.  If, while performing
67a cursor scan using the Hash access method, the transaction performing
68the scan inserts a new pair into the database, it is possible that
69duplicate key/data pairs will be returned.</p>
70    </div>
71    <div class="navfooter">
72      <hr />
73      <table width="100%" summary="Navigation footer">
74        <tr>
75          <td width="40%" align="left"><a accesskey="p" href="am_misc_error.html">Prev</a> </td>
76          <td width="20%" align="center">
77            <a accesskey="u" href="am_misc.html">Up</a>
78          </td>
79          <td width="40%" align="right"> <a accesskey="n" href="am_misc_dbsizes.html">Next</a></td>
80        </tr>
81        <tr>
82          <td width="40%" align="left" valign="top">Error support </td>
83          <td width="20%" align="center">
84            <a accesskey="h" href="index.html">Home</a>
85          </td>
86          <td width="40%" align="right" valign="top"> Database limits</td>
87        </tr>
88      </table>
89    </div>
90  </body>
91</html>
92