| 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>Miscellaneous Differences</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="Getting Started with the Oracle Berkeley DB SQL APIs" /> |
| 10 | <link rel="up" href="dbsqlbasics.html" title="Chapter 1. Berkeley DB SQL: The Absolute Basics" /> |
| 11 | <link rel="prev" href="addedpragmas.html" title="Added PRAGMAs" /> |
| 12 | <link rel="next" href="bdb-concepts.html" title="Berkeley DB Concepts" /> |
| 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">Miscellaneous Differences</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="addedpragmas.html">Prev</a> </td> |
| 25 | <th width="60%" align="center">Chapter 1. Berkeley DB SQL: The Absolute Basics</th> |
| 26 | <td width="20%" align="right"> <a accesskey="n" href="bdb-concepts.html">Next</a></td> |
| 27 | </tr> |
| 28 | </table> |
| 29 | <hr /> |
| 30 | </div> |
| 31 | <div class="sect1" lang="en" xml:lang="en"> |
| 32 | <div class="titlepage"> |
| 33 | <div> |
| 34 | <div> |
| 35 | <h2 class="title" style="clear: both"><a id="miscdiff"></a>Miscellaneous Differences</h2> |
| 36 | </div> |
| 37 | </div> |
| 38 | </div> |
| 39 | <p> |
| 40 | The following miscellaneous differences also exist between |
| 41 | the BDB SQL interface and SQLite: |
| 42 | </p> |
| 43 | <div class="itemizedlist"> |
| 44 | <ul type="disc"> |
| 45 | <li> |
| 46 | <p> |
| 47 | The BDB SQL interface does not support the <code class="literal">IMMEDIATE</code> keyword |
| 48 | (<code class="literal">BEGIN IMMEDIATE</code> behaves just like <code class="literal">BEGIN</code>). |
| 49 | </p> |
| 50 | </li> |
| 51 | <li> |
| 52 | <p> |
| 53 | When an exclusive transaction is active, it will |
| 54 | block any new transactions from beginning (they |
| 55 | will be blocked during their first operation until |
| 56 | the exclusive transactions commits or aborts). |
| 57 | Non-exclusive transactions that are active when the |
| 58 | exclusive transaction begins will not be able to |
| 59 | execute any more operations without being blocked |
| 60 | until the exclusive transactions finishes. |
| 61 | </p> |
| 62 | </li> |
| 63 | <li> |
| 64 | <p> |
| 65 | Enabling MVCC mostly disables exclusive |
| 66 | transactions. Exclusive transactions can still be |
| 67 | used, but they will run concurrently with regular |
| 68 | transactions, even ones that write to the database. |
| 69 | The only advantage of exclusive transactions in |
| 70 | this case is that two exclusive transactions will |
| 71 | be forced to run in serial, and that if an |
| 72 | exclusive transaction and non-exclusive transaction |
| 73 | experience deadlock, then the non-exclusive |
| 74 | transaction will always be the transaction forced |
| 75 | to release its locks. |
| 76 | </p> |
| 77 | <p> |
| 78 | For more information on MVCC and snapshot |
| 79 | isolation, see |
| 80 | <a class="xref" href="mvcc.html" title="Using Multiversion Concurrency Control">Using Multiversion Concurrency Control</a> |
| 81 | </p> |
| 82 | </li> |
| 83 | <li> |
| 84 | <p> |
| 85 | There are differences in how the two products work |
| 86 | in a concurrent application that will cause the |
| 87 | BDB SQL interface to deadlock where SQLite would result in a |
| 88 | different error. This is because the products use |
| 89 | different locking paradigms. See |
| 90 | <a class="xref" href="lockingnotes.html" title="Chapter 2. Locking Notes">Locking Notes</a> |
| 91 | for more information. |
| 92 | </p> |
| 93 | </li> |
| 94 | <li> |
| 95 | <p> |
| 96 | The BDB SQL does not call the busy callback when a |
| 97 | session attempts to operate the same database page |
| 98 | that another session has locked. It blocks |
| 99 | instead. This means that the functions |
| 100 | <code class="literal">sqlite3_busy_handler</code> and |
| 101 | <code class="literal">sqlite3_busy_timeout</code> are not |
| 102 | effective in BDB SQL. |
| 103 | </p> |
| 104 | </li> |
| 105 | <li> |
| 106 | <p> |
| 107 | The BDB SQL does not support two phase commit across databases. |
| 108 | Attaching to multiple databases can lead to inconsistency |
| 109 | after recovery and undetected deadlocks when |
| 110 | accessing multiple databases from concurrent transactions |
| 111 | in different order. Hence, applications must ensure that |
| 112 | they access databases in the same order in any transaction |
| 113 | that spans multiple databases. Else, a deadlock can |
| 114 | occur that causes threads to block, and the deadlock will |
| 115 | not be detected by Berkeley DB. |
| 116 | </p> |
| 117 | </li> |
| 118 | <li> |
| 119 | <p> |
| 120 | In BDB SQL, when two sessions accessing the same database |
| 121 | perform conflicting operations on the same page, one session |
| 122 | will be blocked until the conflicting operations are resolved. |
| 123 | For example, |
| 124 | </p> |
| 125 | <p><span class="bold"><strong>Session 1:</strong></span> |
| 126 | </p> |
| 127 | <pre class="programlisting">dbsql> insert into a values (4); |
| 128 | dbsql> begin; |
| 129 | dbsql> insert into a values (5); </pre> |
| 130 | <p> |
| 131 | <span class="bold"><strong>Session 2:</strong></span> |
| 132 | </p> |
| 133 | <pre class="programlisting">dbsql> select * from a; |
| 134 | </pre> |
| 135 | <p> |
| 136 | What happens here is that Session 2 is blocked until Session 1 commits the transaction. |
| 137 | </p> |
| 138 | <p><span class="bold"><strong>Session 1:</strong></span> |
| 139 | </p> |
| 140 | <pre class="programlisting">dbsql> commit; |
| 141 | </pre> |
| 142 | <p> |
| 143 | <span class="bold"><strong>Session 2:</strong></span> |
| 144 | </p> |
| 145 | <pre class="programlisting">dbsql> select * from a; |
| 146 | 4 |
| 147 | 5 |
| 148 | </pre> |
| 149 | <p> |
| 150 | Under such situations in SQLite, operations poll |
| 151 | instead of blocking, and a callback is used to |
| 152 | determine whether to continue polling. |
| 153 | </p> |
| 154 | </li> |
| 155 | <li> |
| 156 | <p> |
| 157 | By default, you always only have a single database |
| 158 | file when you use BDB SQL interface SQL, just as you do |
| 159 | when you use SQLite. However, you can configure |
| 160 | BDB SQL interface at compile time to create one BDB SQL interface |
| 161 | database file for each SQL table that you |
| 162 | create. How to perform this configuration is |
| 163 | described in the <em class="citetitle">Berkeley DB Installation and Build Guide</em>. |
| 164 | </p> |
| 165 | </li> |
| 166 | </ul> |
| 167 | </div> |
| 168 | </div> |
| 169 | <div class="navfooter"> |
| 170 | <hr /> |
| 171 | <table width="100%" summary="Navigation footer"> |
| 172 | <tr> |
| 173 | <td width="40%" align="left"><a accesskey="p" href="addedpragmas.html">Prev</a> </td> |
| 174 | <td width="20%" align="center"> |
| 175 | <a accesskey="u" href="dbsqlbasics.html">Up</a> |
| 176 | </td> |
| 177 | <td width="40%" align="right"> <a accesskey="n" href="bdb-concepts.html">Next</a></td> |
| 178 | </tr> |
| 179 | <tr> |
| 180 | <td width="40%" align="left" valign="top">Added PRAGMAs </td> |
| 181 | <td width="20%" align="center"> |
| 182 | <a accesskey="h" href="index.html">Home</a> |
| 183 | </td> |
| 184 | <td width="40%" align="right" valign="top"> Berkeley DB Concepts</td> |
| 185 | </tr> |
| 186 | </table> |
| 187 | </div> |
| 188 | </body> |
| 189 | </html> |