1 /* index.c - routines for dealing with attribute indexes */
4 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 #include <ac/string.h>
13 #include <ac/socket.h>
33 LDAP_LOG( INDEX, ENTRY, "key_read: enter\n", 0, 0, 0 );
35 Debug( LDAP_DEBUG_TRACE, "=> key_read\n", 0, 0, 0 );
41 key.flags = DB_DBT_USERMEM;
43 rc = bdb_idl_fetch_key( be, db, txn, &key, ids );
45 if( rc != LDAP_SUCCESS ) {
47 LDAP_LOG( INDEX, ERR, "bdb_key_read: failed (%d)\n", rc, 0, 0 );
49 Debug( LDAP_DEBUG_TRACE, "<= bdb_index_read: failed (%d)\n",
54 LDAP_LOG( INDEX, DETAIL1,
55 "bdb_key_read: %ld candidates\n", (long)BDB_IDL_N(ids), 0, 0);
57 Debug( LDAP_DEBUG_TRACE, "<= bdb_index_read %ld candidates\n",
58 (long) BDB_IDL_N(ids), 0, 0 );
65 /* Add or remove stuff from index files */
80 LDAP_LOG( INDEX, ENTRY, "key_change: %s ID %lx\n",
81 op == SLAP_INDEX_ADD_OP ? "Add" : "Delete", (long) id, 0 );
83 Debug( LDAP_DEBUG_TRACE, "=> key_change(%s,%lx)\n",
84 op == SLAP_INDEX_ADD_OP ? "ADD":"DELETE", (long) id, 0 );
90 key.flags = DB_DBT_USERMEM;
92 if (op == SLAP_INDEX_ADD_OP) {
94 rc = bdb_idl_insert_key( be, db, txn, &key, id );
95 if ( rc == DB_KEYEXIST ) rc = 0;
98 rc = bdb_idl_delete_key( be, db, txn, &key, id );
99 if ( rc == DB_NOTFOUND ) rc = 0;
103 LDAP_LOG( INDEX, RESULTS, "key_change: return %d\n", rc, 0, 0 );
105 Debug( LDAP_DEBUG_TRACE, "<= key_change %d\n", rc, 0, 0 );