1 /* init.c - initialize bdb backend */
4 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
11 #include <ac/string.h>
15 int bdb_next_id( BackendDB *be, DB_TXN *tid, ID *out )
17 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
19 ldap_pvt_thread_mutex_lock( &bdb->bi_lastid_mutex );
20 *out = ++bdb->bi_lastid;
21 ldap_pvt_thread_mutex_unlock( &bdb->bi_lastid_mutex );
26 int bdb_last_id( BackendDB *be, DB_TXN *tid )
28 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
35 key.flags = DB_DBT_USERMEM;
36 key.data = (char *) &id;
37 key.ulen = sizeof( id );
40 data.flags = DB_DBT_USERMEM | DB_DBT_PARTIAL;
42 /* Get a read cursor */
43 rc = bdb->bi_id2entry->bdi_db->cursor( bdb->bi_id2entry->bdi_db,
47 rc = cursor->c_get(cursor, &key, &data, DB_LAST);
48 cursor->c_close(cursor);
61 LDAP_LOG ( INDEX, ERR, "bdb_last_id: get failed: %s (%d)\n",
62 db_strerror(rc), rc, 0 );
64 Debug( LDAP_DEBUG_ANY,
65 "=> bdb_last_id: get failed: %s (%d)\n",
66 db_strerror(rc), rc, 0 );