~ubuntu-branches/ubuntu/edgy/rpm/edgy

« back to all changes in this revision

Viewing changes to db/docs/api_c/db_put.html

  • Committer: Bazaar Package Importer
  • Author(s): Joey Hess
  • Date: 2002-01-22 20:56:57 UTC
  • Revision ID: james.westby@ubuntu.com-20020122205657-l74j50mr9z8ofcl5
Tags: upstream-4.0.3
ImportĀ upstreamĀ versionĀ 4.0.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!--$Id: db_put.so,v 10.37 2001/04/02 00:36:35 bostic Exp $-->
 
2
<!--Copyright 1997-2001 by Sleepycat Software, Inc.-->
 
3
<!--All rights reserved.-->
 
4
<html>
 
5
<head>
 
6
<title>Berkeley DB: DB-&gt;put</title>
 
7
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
 
8
<meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++">
 
9
</head>
 
10
<body bgcolor=white>
 
11
<a name="2"><!--meow--></a>
 
12
<table width="100%"><tr valign=top>
 
13
<td>
 
14
<h1>DB-&gt;put</h1>
 
15
</td>
 
16
<td align=right>
 
17
<a href="../api_c/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a>
 
18
</td></tr></table>
 
19
<hr size=1 noshade>
 
20
<tt>
 
21
<h3><pre>
 
22
#include &lt;db.h&gt;
 
23
<p>
 
24
int
 
25
DB-&gt;put(DB *db,
 
26
    DB_TXN *txnid, DBT *key, DBT *data, u_int32_t flags);
 
27
</pre></h3>
 
28
<h1>Description</h1>
 
29
<p>The DB-&gt;put function stores key/data pairs in the database.  The default
 
30
behavior of the DB-&gt;put function is to enter the new key/data
 
31
pair, replacing any previously existing key if duplicates are disallowed,
 
32
or adding a duplicate data item if duplicates are allowed.  If the database
 
33
supports duplicates, the DB-&gt;put function adds the new data value at the
 
34
end of the duplicate set.  If the database supports sorted duplicates,
 
35
the new data value is inserted at the correct sorted location.
 
36
<p>If the operation is to be transaction-protected, the <b>txnid</b>
 
37
parameter is a transaction handle returned from <a href="../api_c/txn_begin.html">txn_begin</a>;
 
38
otherwise, NULL.
 
39
<p>The <b>flags</b> value must be set to 0 or
 
40
one of the following values:
 
41
<p><dl compact>
 
42
<p><dt><a name="DB_APPEND">DB_APPEND</a><dd>Append the key/data pair to the end of the database.  For the
 
43
DB_APPEND flag to be specified, the underlying database must be
 
44
a Queue or Recno database.  The record number allocated to the record is
 
45
returned in the specified <b>key</b>.
 
46
<p>There is a minor behavioral difference between the Recno and Queue access
 
47
methods for the DB_APPEND flag.  If a transaction enclosing a
 
48
DB-&gt;put operation with the DB_APPEND flag aborts, the
 
49
record number may be decremented (and later reallocated by a subsequent
 
50
DB_APPEND operation) by the Recno access method, but will not be
 
51
decremented or reallocated by the Queue access method.
 
52
<p><dt><a name="DB_NODUPDATA">DB_NODUPDATA</a><dd>In the case of the Btree and Hash access methods, enter the new key/data
 
53
pair only if it does not already appear in the database.  If the
 
54
key/data pair already appears in the database, <a href="../api_c/dbc_put.html#DB_KEYEXIST">DB_KEYEXIST</a> is
 
55
returned.  The DB_NODUPDATA flag may only be specified if the
 
56
underlying database has been configured to support sorted duplicates.
 
57
<p>The DB_NODUPDATA flag may not be specified to the Queue or Recno
 
58
access methods.
 
59
<p><dt><a name="DB_NOOVERWRITE">DB_NOOVERWRITE</a><dd>Enter the new key/data pair only if the key does not already appear in
 
60
the database.  If the key already appears in the database,
 
61
<a href="../api_c/dbc_put.html#DB_KEYEXIST">DB_KEYEXIST</a> is returned.  Even if the database allows duplicates,
 
62
a call to DB-&gt;put with the DB_NOOVERWRITE flag set will
 
63
fail if the key already exists in the database.
 
64
</dl>
 
65
<p>Otherwise, the DB-&gt;put function returns a non-zero error value on failure and 0 on success.
 
66
<h1>Errors</h1>
 
67
<p>The DB-&gt;put function may fail and return a non-zero error for the following conditions:
 
68
<p><dl compact>
 
69
<p><dt>DB_LOCK_DEADLOCK<dd>The operation was selected to resolve a deadlock.
 
70
</dl>
 
71
<p><dl compact>
 
72
<p><dt>EACCES<dd>An attempt was made to modify a read-only database.
 
73
</dl>
 
74
<p><dl compact>
 
75
<p><dt>EINVAL<dd>An invalid flag value or parameter was specified.
 
76
<p>A record number of 0 was specified.
 
77
<p>An attempt was made to add a record to a fixed-length database that was too
 
78
large to fit.
 
79
<p>An attempt was made to do a partial put.
 
80
<p>An attempt was made to add a record to a secondary index.
 
81
</dl>
 
82
<p><dl compact>
 
83
<p><dt>ENOSPC<dd>A btree exceeded the maximum btree depth (255).
 
84
</dl>
 
85
<p>The DB-&gt;put function may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions.
 
86
If a catastrophic error has occurred, the DB-&gt;put function may fail and return
 
87
<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail
 
88
in the same way.
 
89
<h1>See Also</h1>
 
90
<a href="../api_c/db_create.html">db_create</a>,
 
91
<a href="../api_c/db_associate.html">DB-&gt;associate</a>,
 
92
<a href="../api_c/db_close.html">DB-&gt;close</a>,
 
93
<a href="../api_c/db_cursor.html">DB-&gt;cursor</a>,
 
94
<a href="../api_c/db_del.html">DB-&gt;del</a>,
 
95
<a href="../api_c/db_err.html">DB-&gt;err</a>, <a href="../api_c/db_err.html">DB-&gt;errx</a>
 
96
<a href="../api_c/db_fd.html">DB-&gt;fd</a>,
 
97
<a href="../api_c/db_get.html">DB-&gt;get</a>,
 
98
<a href="../api_c/db_get.html">DB-&gt;pget</a>,
 
99
<a href="../api_c/db_get_byteswapped.html">DB-&gt;get_byteswapped</a>,
 
100
<a href="../api_c/db_get_type.html">DB-&gt;get_type</a>,
 
101
<a href="../api_c/db_join.html">DB-&gt;join</a>,
 
102
<a href="../api_c/db_key_range.html">DB-&gt;key_range</a>,
 
103
<a href="../api_c/db_open.html">DB-&gt;open</a>,
 
104
<a href="../api_c/db_put.html">DB-&gt;put</a>,
 
105
<a href="../api_c/db_remove.html">DB-&gt;remove</a>,
 
106
<a href="../api_c/db_rename.html">DB-&gt;rename</a>,
 
107
<a href="../api_c/db_set_alloc.html">DB-&gt;set_alloc</a>,
 
108
<a href="../api_c/db_set_append_recno.html">DB-&gt;set_append_recno</a>,
 
109
<a href="../api_c/db_set_bt_compare.html">DB-&gt;set_bt_compare</a>,
 
110
<a href="../api_c/db_set_bt_minkey.html">DB-&gt;set_bt_minkey</a>,
 
111
<a href="../api_c/db_set_bt_prefix.html">DB-&gt;set_bt_prefix</a>,
 
112
<a href="../api_c/db_set_cachesize.html">DB-&gt;set_cachesize</a>,
 
113
<a href="../api_c/db_set_dup_compare.html">DB-&gt;set_dup_compare</a>,
 
114
<a href="../api_c/db_set_errcall.html">DB-&gt;set_errcall</a>,
 
115
<a href="../api_c/db_set_errfile.html">DB-&gt;set_errfile</a>,
 
116
<a href="../api_c/db_set_errpfx.html">DB-&gt;set_errpfx</a>,
 
117
<a href="../api_c/db_set_feedback.html">DB-&gt;set_feedback</a>,
 
118
<a href="../api_c/db_set_flags.html">DB-&gt;set_flags</a>,
 
119
<a href="../api_c/db_set_h_ffactor.html">DB-&gt;set_h_ffactor</a>,
 
120
<a href="../api_c/db_set_h_hash.html">DB-&gt;set_h_hash</a>,
 
121
<a href="../api_c/db_set_h_nelem.html">DB-&gt;set_h_nelem</a>,
 
122
<a href="../api_c/db_set_lorder.html">DB-&gt;set_lorder</a>,
 
123
<a href="../api_c/db_set_pagesize.html">DB-&gt;set_pagesize</a>,
 
124
<a href="../api_c/db_set_paniccall.html">DB-&gt;set_paniccall</a>,
 
125
<a href="../api_c/db_set_q_extentsize.html">DB-&gt;set_q_extentsize</a>,
 
126
<a href="../api_c/db_set_re_delim.html">DB-&gt;set_re_delim</a>,
 
127
<a href="../api_c/db_set_re_len.html">DB-&gt;set_re_len</a>,
 
128
<a href="../api_c/db_set_re_pad.html">DB-&gt;set_re_pad</a>,
 
129
<a href="../api_c/db_set_re_source.html">DB-&gt;set_re_source</a>,
 
130
<a href="../api_c/db_stat.html">DB-&gt;stat</a>,
 
131
<a href="../api_c/db_sync.html">DB-&gt;sync</a>,
 
132
<a href="../api_c/db_truncate.html">DB-&gt;truncate</a>,
 
133
<a href="../api_c/db_upgrade.html">DB-&gt;upgrade</a>,
 
134
and
 
135
<a href="../api_c/db_verify.html">DB-&gt;verify</a>.
 
136
</tt>
 
137
<table width="100%"><tr><td><br></td><td align=right>
 
138
<a href="../api_c/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a>
 
139
</td></tr></table>
 
140
<p><font size=1><a href="http://www.sleepycat.com">Copyright Sleepycat Software</a></font>
 
141
</body>
 
142
</html>