1 /* index.c - routines for dealing with attribute indexes */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2000-2008 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>
43 Debug( LDAP_DEBUG_TRACE, "=> key_read\n", 0, 0, 0 );
48 key.flags = DB_DBT_USERMEM;
50 rc = bdb_idl_fetch_key( be, db, locker, &key, ids, saved_cursor, get_flag );
52 if( rc != LDAP_SUCCESS ) {
53 Debug( LDAP_DEBUG_TRACE, "<= bdb_index_read: failed (%d)\n",
56 Debug( LDAP_DEBUG_TRACE, "<= bdb_index_read %ld candidates\n",
57 (long) BDB_IDL_N(ids), 0, 0 );
63 /* Add or remove stuff from index files */
77 Debug( LDAP_DEBUG_TRACE, "=> key_change(%s,%lx)\n",
78 op == SLAP_INDEX_ADD_OP ? "ADD":"DELETE", (long) id, 0 );
83 key.flags = DB_DBT_USERMEM;
85 if (op == SLAP_INDEX_ADD_OP) {
88 #ifdef BDB_TOOL_IDL_CACHING
89 if ( slapMode & SLAP_TOOL_QUICK )
90 rc = bdb_tool_idl_add( be, db, txn, &key, id );
93 rc = bdb_idl_insert_key( be, db, txn, &key, id );
94 if ( rc == DB_KEYEXIST ) rc = 0;
97 rc = bdb_idl_delete_key( be, db, txn, &key, id );
98 if ( rc == DB_NOTFOUND ) rc = 0;
101 Debug( LDAP_DEBUG_TRACE, "<= key_change %d\n", rc, 0, 0 );