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>
16 #include "back-ldbm.h"
31 LDAP_LOG( INDEX, ENTRY, "key_read: enter\n", 0, 0, 0 );
33 Debug( LDAP_DEBUG_TRACE, "=> key_read\n", 0, 0, 0 );
37 ldbm_datum_init( key );
39 key.dsize = k->bv_len;
41 idl = idl_fetch( be, db, key );
44 LDAP_LOG( INDEX, ENTRY,
45 "key_read: %ld candidates\n", idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
47 Debug( LDAP_DEBUG_TRACE, "<= index_read %ld candidates\n",
48 idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
56 /* Add or remove stuff from index files */
70 LDAP_LOG( INDEX, ENTRY, "key_change: %s ID %lx\n",
71 op == SLAP_INDEX_ADD_OP ? "Add" : "Delete", (long)id, 0 );
73 Debug( LDAP_DEBUG_TRACE, "=> key_change(%s,%lx)\n",
74 op == SLAP_INDEX_ADD_OP ? "ADD":"DELETE", (long) id, 0 );
78 ldbm_datum_init( key );
80 key.dsize = k->bv_len;
82 ldap_pvt_thread_mutex_lock( &db->dbc_write_mutex );
83 if (op == SLAP_INDEX_ADD_OP) {
85 rc = idl_insert_key( be, db, key, id );
89 rc = idl_delete_key( be, db, key, id );
91 ldap_pvt_thread_mutex_unlock( &db->dbc_write_mutex );
95 LDAP_LOG( INDEX, ENTRY, "key_change: return %d\n", rc, 0, 0 );
97 Debug( LDAP_DEBUG_TRACE, "<= key_change %d\n", rc, 0, 0 );
101 ldap_pvt_thread_yield();