*I#Berkeley DB: DB->put[P

DB->put





#include <db.h>

intDB->put(DB *db,9 DB_TXN *txnid, DBT *key, DBT *data, u_int32_t flags);





Description



;The DB->put function stores key/data pairs in the database.

KIf the database supports duplicates, the DB->put function adds the new dataGvalue at the end of the duplicate set. If the database supports sortedJduplicates, the new data value is inserted at the correct sorted location.

;If the file is being accessed under transaction protection,<the txnid parameter is a transaction ID returned fromItxn_begin, otherwise, NULL.

CThe flags parameter must be set to 0 or one of the followingvalues:

H

DB_APPEND
Append the key/data pair to the end of the database.>For DB_APPEND to be specified, the underlying database must beof type DB_RECNO.FThe record number allocated to the record is returned in the specified key.\

DB_NOOVERWRITE
Enter the new key/data pair only if the key does not already appearin the database.


<The default behavior of the DB->put function is to enter theFnew key/data pair, replacing any previously existing key if duplicatesFare disallowed, or to add a duplicate entry if duplicates are allowed.<Even if the designated database allows duplicates, a call to=DB->put with the DB_NOOVERWRITE flag set will fail if the keyalready exists in the database.

The DB->putDfunction returns the value of errno on failure, 0 on success,Eand DB_KEYEXIST if the DB_NOOVERWRITE flag was set and the keyalready exists in the file.



Errors

PIf a fatal error occurs in Berkeley DB, the DB->put function may fail and returnFDB_RUNRECOVERY, at which point all subsequent database calls will alsoreturn DB_RUNRECOVERY.

The DB->put)function may fail and return errnoKfor any of the errors specified for the following Berkeley DB and C library functions:4DB->cursor,DBcursor->c_close(3),7DBcursor->c_get,DBcursor->c_put(3),__account_page(3),dbenv->db_paniccall(3), fflush(3), fprintf(3),free(3),func(3),6lock_get,3lock_put,6lock_vec,1log_put, malloc(3), memcpy(3), memmove(3),9memp_fget,9memp_fput,9memp_fset, memset(3), realloc(3), strerror(3), vfprintf(3),and vsnprintf(3).

In addition, the DB->put)function may fail and return errnofor the following conditions:

D

EACCES
An attempt was made to modify a read-only database.


(

EAGAIN
A lock was unavailable.


B

EINVAL
An invalid flag value or parameter was specified.

#A record number of 0 was specified.

CAn attempt was made to add a record to a fixed-length database thatwas too large to fit.

(An attempt was made to do a partial put.



@

ENOSPC
A btree exceeded the maximum btree depth (255).




See Also

8db_appexit,8db_appinit,8db_version,2DB->close,4DB->cursor,.DB->del,,DB->fd,.DB->get,0DB->join,/db_open,DB->put,0DB->stat,0DB->sync,;DBcursor->c_close,7DBcursor->c_del,6DBcursor->c_getand7DBcursor->c_put.
ÿÿ