1 /* index.c - routines for dealing with attribute indexes */
4 * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 #include <ac/string.h>
13 #include <ac/socket.h>
16 #include "back-ldbm.h"
31 LDAP_LOG(( "index", LDAP_LEVEL_ENTRY,
32 "key_read: enter\n" ));
34 Debug( LDAP_DEBUG_TRACE, "=> key_read\n", 0, 0, 0 );
38 ldbm_datum_init( key );
40 key.dsize = k->bv_len;
42 idl = idl_fetch( be, db, key );
45 LDAP_LOG(( "index", LDAP_LEVEL_ENTRY,
46 "key_read: %ld candidates\n",
47 idl ? ID_BLOCK_NIDS(idl) : 0 ));
49 Debug( LDAP_DEBUG_TRACE, "<= index_read %ld candidates\n",
50 idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
58 /* Add or remove stuff from index files */
72 LDAP_LOG(( "index", LDAP_LEVEL_ENTRY,
73 "key_change: %s ID %lx\n",
74 op == SLAP_INDEX_ADD_OP ? "Add" : "Delete", (long)id ));
76 Debug( LDAP_DEBUG_TRACE, "=> key_change(%s,%lx)\n",
77 op == SLAP_INDEX_ADD_OP ? "ADD":"DELETE", (long) id, 0 );
81 ldbm_datum_init( key );
83 key.dsize = k->bv_len;
85 ldap_pvt_thread_mutex_lock( &db->dbc_write_mutex );
86 if (op == SLAP_INDEX_ADD_OP) {
88 rc = idl_insert_key( be, db, key, id );
92 rc = idl_delete_key( be, db, key, id );
94 ldap_pvt_thread_mutex_unlock( &db->dbc_write_mutex );
98 LDAP_LOG(( "index", LDAP_LEVEL_ENTRY,
99 "key_change: return %d\n", rc ));
101 Debug( LDAP_DEBUG_TRACE, "<= key_change %d\n", rc, 0, 0 );
105 ldap_pvt_thread_yield();