X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fback-bdb%2Fkey.c;h=c6440ebfc3a56c47952eb368ad5dc7c019cc3015;hb=d3aae2dc427d1fd1bef8d236cde39524cbc35396;hp=f5b877e5a21ee6d9ca5a85d2bbf03e30bcf6de54;hpb=96e003883208e701b8ad2f8b764f66f8facc8cda;p=openldap
diff --git a/servers/slapd/back-bdb/key.c b/servers/slapd/back-bdb/key.c
index f5b877e5a2..c6440ebfc3 100644
--- a/servers/slapd/back-bdb/key.c
+++ b/servers/slapd/back-bdb/key.c
@@ -1,8 +1,17 @@
/* index.c - routines for dealing with attribute indexes */
/* $OpenLDAP$ */
-/*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* This work is part of OpenLDAP Software .
+ *
+ * Copyright 2000-2009 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * .
*/
#include "portable.h"
@@ -14,101 +23,82 @@
#include "slap.h"
#include "back-bdb.h"
+#include "idl.h"
-#ifdef BDB_FILTER_INDICES
/* read a key */
int
bdb_key_read(
- Backend *be,
+ Backend *be,
DB *db,
DB_TXN *txn,
- struct berval *k,
- ID *ids
+ struct berval *k,
+ ID *ids,
+ DBC **saved_cursor,
+ int get_flag
)
{
- DBT key;
+ int rc;
+ DBT key;
-#ifdef NEW_LOGGING
- LDAP_LOG(( "index", LDAP_LEVEL_ENTRY,
- "key_read: enter\n" ));
-#else
Debug( LDAP_DEBUG_TRACE, "=> key_read\n", 0, 0, 0 );
-#endif
- DBzero( &key );
- key.data = k->bv_val;
- key.size = k->bv_len;
+ DBTzero( &key );
+ bv2DBT(k,&key);
+ key.ulen = key.size;
+ key.flags = DB_DBT_USERMEM;
- rc = bdb_idl_fetch_key( be, db, txn, key, ids );
+ rc = bdb_idl_fetch_key( be, db, txn, &key, ids, saved_cursor, get_flag );
if( rc != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
- LDAP_LOG(( "index", LDAP_LEVEL_ENTRY,
- "bdb_key_read: failed (%d)\n",
- rc ));
-#else
Debug( LDAP_DEBUG_TRACE, "<= bdb_index_read: failed (%d)\n",
rc, 0, 0 );
-#endif
} else {
-#ifdef NEW_LOGGING
- LDAP_LOG(( "index", LDAP_LEVEL_ENTRY,
- "bdb_key_read: %ld candidates\n",
- idl ? ID_BLOCK_NIDS(idl) : 0 ));
-#else
Debug( LDAP_DEBUG_TRACE, "<= bdb_index_read %ld candidates\n",
- idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
-#endif
+ (long) BDB_IDL_N(ids), 0, 0 );
}
return rc;
}
-#endif
-#ifdef BDB_INDEX
/* Add or remove stuff from index files */
int
bdb_key_change(
- Backend *be,
- DB *db,
+ Backend *be,
+ DB *db,
DB_TXN *txn,
- struct berval *k,
- ID id,
- int op
+ struct berval *k,
+ ID id,
+ int op
)
{
int rc;
DBT key;
-#ifdef NEW_LOGGING
- LDAP_LOG(( "index", LDAP_LEVEL_ENTRY,
- "key_change: %s ID %lx\n",
- op == SLAP_INDEX_ADD_OP ? "Add" : "Delete", (long)id ));
-#else
Debug( LDAP_DEBUG_TRACE, "=> key_change(%s,%lx)\n",
op == SLAP_INDEX_ADD_OP ? "ADD":"DELETE", (long) id, 0 );
-#endif
DBTzero( &key );
- key.data = k->bv_val;
- key.size = k->bv_len;
+ bv2DBT(k,&key);
+ key.ulen = key.size;
+ key.flags = DB_DBT_USERMEM;
if (op == SLAP_INDEX_ADD_OP) {
- /* Add values */
- rc = bdb_idl_insert_key( be, db, txn, &key, id );
+ /* Add values */
+#ifdef BDB_TOOL_IDL_CACHING
+ if ( slapMode & SLAP_TOOL_QUICK )
+ rc = bdb_tool_idl_add( be, db, txn, &key, id );
+ else
+#endif
+ rc = bdb_idl_insert_key( be, db, txn, &key, id );
+ if ( rc == DB_KEYEXIST ) rc = 0;
} else {
- /* Delete values */
- rc = bdb_idl_delete_key( be, db, txn, &key, id );
+ /* Delete values */
+ rc = bdb_idl_delete_key( be, db, txn, &key, id );
+ if ( rc == DB_NOTFOUND ) rc = 0;
}
-#ifdef NEW_LOGGING
- LDAP_LOG(( "index", LDAP_LEVEL_ENTRY,
- "key_change: return %d\n", rc ));
-#else
Debug( LDAP_DEBUG_TRACE, "<= key_change %d\n", rc, 0, 0 );
-#endif
return rc;
}
-#endif