1 /* index.c - routines for dealing with attribute indexes */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2005 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>
25 #include "back-ldbm.h"
39 Debug( LDAP_DEBUG_TRACE, "=> key_read\n", 0, 0, 0 );
42 ldbm_datum_init( key );
44 key.dsize = k->bv_len;
46 idl = idl_fetch( be, db, key );
48 Debug( LDAP_DEBUG_TRACE, "<= index_read %ld candidates\n",
49 idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
56 /* Add or remove stuff from index files */
69 Debug( LDAP_DEBUG_TRACE, "=> key_change(%s,%lx)\n",
70 op == SLAP_INDEX_ADD_OP ? "ADD":"DELETE", (long) id, 0 );
73 ldbm_datum_init( key );
75 key.dsize = k->bv_len;
77 ldap_pvt_thread_mutex_lock( &db->dbc_write_mutex );
78 if (op == SLAP_INDEX_ADD_OP) {
80 rc = idl_insert_key( be, db, key, id );
84 rc = idl_delete_key( be, db, key, id );
86 ldap_pvt_thread_mutex_unlock( &db->dbc_write_mutex );
89 Debug( LDAP_DEBUG_TRACE, "<= key_change %d\n", rc, 0, 0 );
92 ldap_pvt_thread_yield();