mirror of
https://github.com/MariaDB/server.git
synced 2025-11-09 11:41:36 +03:00
75 lines
5.0 KiB
HTML
75 lines
5.0 KiB
HTML
<!--$Id: convert.so,v 11.6 2000/03/18 21:43:19 bostic Exp $-->
|
|
<!--Copyright 1997, 1998, 1999, 2000 by Sleepycat Software, Inc.-->
|
|
<!--All rights reserved.-->
|
|
<html>
|
|
<head>
|
|
<title>Berkeley DB Reference Guide: Release 2.0: converting applications</title>
|
|
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
|
|
<meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++">
|
|
</head>
|
|
<body bgcolor=white>
|
|
<table><tr valign=top>
|
|
<td><h3><dl><dt>Berkeley DB Reference Guide:<dd>Upgrading Berkeley DB Applications</dl></h3></td>
|
|
<td width="1%"><a href="../../ref/upgrade.2.0/system.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../ref/toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/upgrade.2.0/disk.html"><img src="../../images/next.gif" alt="Next"></a>
|
|
</td></tr></table>
|
|
<p>
|
|
<h1 align=center>Release 2.0: converting applications</h1>
|
|
<p>Mapping the Berkeley DB 1.85 functionality into Berkeley DB version 2 is almost always
|
|
simple. The manual page <a href="../../api_c/db_open.html">DB->open</a> replaces the Berkeley DB 1.85 manual
|
|
pages <b>dbopen</b>(3), <b>btree</b>(3), <b>hash</b>(3) and
|
|
<b>recno</b>(3). You should be able to convert each 1.85 function
|
|
call into a Berkeley DB version 2 function call using just the <a href="../../api_c/db_open.html">DB->open</a>
|
|
documentation.
|
|
<p>Some guidelines and things to watch out for:
|
|
<p><ol>
|
|
<p><li>Most access method functions have exactly the same semantics as in Berkeley DB
|
|
1.85, although the arguments to the functions have changed in some cases.
|
|
To get your code to compile, the most common change is to add the
|
|
transaction ID as an argument (NULL, since Berkeley DB 1.85 did not support
|
|
transactions.)
|
|
<p><li>You must always initialize DBT structures to zero before using them with
|
|
any Berkeley DB version 2 function. (They do not normally have to be
|
|
reinitialized each time, only when they are first allocated. Do this by
|
|
declaring the DBT structure external or static, or by calling the C
|
|
library routine <b>bzero</b>(3) or <b>memset</b>(3).)
|
|
<p><li>The error returns are completely different in the two versions. In Berkeley DB
|
|
1.85, < 0 meant an error, and > 0 meant a minor Berkeley DB exception.
|
|
In Berkeley DB 2.0, > 0 means an error (the Berkeley DB version 2 functions
|
|
return <b>errno</b> on error) and < 0 means a Berkeley DB exception.
|
|
See <a href="../../ref/program/errorret.html">Error Returns to Applications</a>
|
|
for more information.
|
|
<p><li>The Berkeley DB 1.85 DB->seq function has been replaced by cursors in Berkeley DB
|
|
version 2. The semantics are approximately the same, but cursors require
|
|
the creation of an extra object (the DBC object), which is then used to
|
|
access the database.
|
|
<p>Specifically, the partial key match and range search functionality of the
|
|
R_CURSOR flag in DB->seq has been replaced by the
|
|
<a href="../../api_c/dbc_get.html#DB_SET_RANGE">DB_SET_RANGE</a> flag in <a href="../../api_c/dbc_get.html">DBcursor->c_get</a>.
|
|
<p><li>In version 2 of the Berkeley DB library, additions or deletions into Recno
|
|
(fixed and variable-length record) databases no longer automatically
|
|
logically renumber all records after the add/delete point, by default.
|
|
The default behavior is that deleting records does not cause subsequent
|
|
records to be renumbered, and it is an error to attempt to add new records
|
|
between records already in the database. Applications wanting the
|
|
historic Recno access method semantics should call the
|
|
<a href="../../api_c/db_set_flags.html">DB->set_flags</a> function with the <a href="../../api_c/db_set_flags.html#DB_RENUMBER">DB_RENUMBER</a> flag.
|
|
<p><li>Opening a database in Berkeley DB version 2 is a much heavier-weight operation
|
|
than it was in Berkeley DB 1.85. Therefore, if your historic applications were
|
|
written to open a database, perform a single operation, and close the
|
|
database, you may observe performance degradation. In most cases, this
|
|
is due to the expense of creating the environment upon each open. While
|
|
we encourage restructuring your application to avoid repeated opens and
|
|
closes, you can probably recover most of the lost performance by simply
|
|
using a persistent environment across invocations.
|
|
</ol>
|
|
<p>While simply converting Berkeley DB 1.85 function calls to Berkeley DB version 2
|
|
function calls will work, we recommend that you eventually reconsider your
|
|
application's interface to the Berkeley DB database library in light of the
|
|
additional functionality supplied by Berkeley DB version 2, as it is likely to
|
|
result in enhanced application performance.
|
|
<table><tr><td><br></td><td width="1%"><a href="../../ref/upgrade.2.0/system.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../ref/toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/upgrade.2.0/disk.html"><img src="../../images/next.gif" alt="Next"></a>
|
|
</td></tr></table>
|
|
<p><font size=1><a href="http://www.sleepycat.com">Copyright Sleepycat Software</a></font>
|
|
</body>
|
|
</html>
|