1 /* index.c - routines for dealing with attribute indexes */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2000-2004 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
21 #include <ac/string.h>
22 #include <ac/socket.h>
42 LDAP_LOG( INDEX, ENTRY, "key_read: enter\n", 0, 0, 0 );
44 Debug( LDAP_DEBUG_TRACE, "=> key_read\n", 0, 0, 0 );
50 key.flags = DB_DBT_USERMEM;
52 rc = bdb_idl_fetch_key( be, db, txn, &key, ids );
54 if( rc != LDAP_SUCCESS ) {
56 LDAP_LOG( INDEX, ERR, "bdb_key_read: failed (%d)\n", rc, 0, 0 );
58 Debug( LDAP_DEBUG_TRACE, "<= bdb_index_read: failed (%d)\n",
63 LDAP_LOG( INDEX, DETAIL1,
64 "bdb_key_read: %ld candidates\n", (long)BDB_IDL_N(ids), 0, 0);
66 Debug( LDAP_DEBUG_TRACE, "<= bdb_index_read %ld candidates\n",
67 (long) BDB_IDL_N(ids), 0, 0 );
74 /* Add or remove stuff from index files */
89 LDAP_LOG( INDEX, ENTRY, "key_change: %s ID %lx\n",
90 op == SLAP_INDEX_ADD_OP ? "Add" : "Delete", (long) id, 0 );
92 Debug( LDAP_DEBUG_TRACE, "=> key_change(%s,%lx)\n",
93 op == SLAP_INDEX_ADD_OP ? "ADD":"DELETE", (long) id, 0 );
99 key.flags = DB_DBT_USERMEM;
101 if (op == SLAP_INDEX_ADD_OP) {
103 rc = bdb_idl_insert_key( be, db, txn, &key, id );
104 if ( rc == DB_KEYEXIST ) rc = 0;
107 rc = bdb_idl_delete_key( be, db, txn, &key, id );
108 if ( rc == DB_NOTFOUND ) rc = 0;
112 LDAP_LOG( INDEX, RESULTS, "key_change: return %d\n", rc, 0, 0 );
114 Debug( LDAP_DEBUG_TRACE, "<= key_change %d\n", rc, 0, 0 );