1 /* index.c - routines for dealing with attribute indexes */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2003 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"
40 LDAP_LOG( INDEX, ENTRY, "key_read: enter\n", 0, 0, 0 );
42 Debug( LDAP_DEBUG_TRACE, "=> key_read\n", 0, 0, 0 );
46 ldbm_datum_init( key );
48 key.dsize = k->bv_len;
50 idl = idl_fetch( be, db, key );
53 LDAP_LOG( INDEX, ENTRY,
54 "key_read: %ld candidates\n", idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
56 Debug( LDAP_DEBUG_TRACE, "<= index_read %ld candidates\n",
57 idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
65 /* Add or remove stuff from index files */
79 LDAP_LOG( INDEX, ENTRY, "key_change: %s ID %lx\n",
80 op == SLAP_INDEX_ADD_OP ? "Add" : "Delete", (long)id, 0 );
82 Debug( LDAP_DEBUG_TRACE, "=> key_change(%s,%lx)\n",
83 op == SLAP_INDEX_ADD_OP ? "ADD":"DELETE", (long) id, 0 );
87 ldbm_datum_init( key );
89 key.dsize = k->bv_len;
91 ldap_pvt_thread_mutex_lock( &db->dbc_write_mutex );
92 if (op == SLAP_INDEX_ADD_OP) {
94 rc = idl_insert_key( be, db, key, id );
98 rc = idl_delete_key( be, db, key, id );
100 ldap_pvt_thread_mutex_unlock( &db->dbc_write_mutex );
104 LDAP_LOG( INDEX, ENTRY, "key_change: return %d\n", rc, 0, 0 );
106 Debug( LDAP_DEBUG_TRACE, "<= key_change %d\n", rc, 0, 0 );
110 ldap_pvt_thread_yield();