X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fback-bdb%2Fkey.c;h=69d81b770a80bfb18284bc866537144187393329;hb=550dc4aaeee2b9f2ed25b451d950bd5e7088652d;hp=a6b490f101cac5f2d2dcdc9f9e50987a9020face;hpb=43167d0fa65ea3c81368b6ce85fee48a7c703055;p=openldap
diff --git a/servers/slapd/back-bdb/key.c b/servers/slapd/back-bdb/key.c
index a6b490f101..69d81b770a 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-2002 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* This work is part of OpenLDAP Software .
+ *
+ * Copyright 2000-2011 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"
@@ -23,43 +32,29 @@ bdb_key_read(
DB *db,
DB_TXN *txn,
struct berval *k,
- ID *ids
+ ID *ids,
+ DBC **saved_cursor,
+ int get_flag
)
{
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
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_ERR,
- "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_DETAIL1,
- "bdb_key_read: %ld candidates\n", (long) BDB_IDL_N(ids) ));
-#else
Debug( LDAP_DEBUG_TRACE, "<= bdb_index_read %ld candidates\n",
(long) BDB_IDL_N(ids), 0, 0 );
-#endif
}
return rc;
@@ -79,14 +74,8 @@ bdb_key_change(
int rc;
DBT key;
-#ifdef NEW_LOGGING
- LDAP_LOG(( "index", LDAP_LEVEL_DETAIL1,
- "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 );
bv2DBT(k,&key);
@@ -95,19 +84,21 @@ bdb_key_change(
if (op == SLAP_INDEX_ADD_OP) {
/* Add values */
- rc = bdb_idl_insert_key( be, db, txn, &key, id );
+#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 );
+ if ( rc == DB_NOTFOUND ) rc = 0;
}
-#ifdef NEW_LOGGING
- LDAP_LOG(( "index", LDAP_LEVEL_RESULTS,
- "key_change: return %d\n", rc ));
-#else
Debug( LDAP_DEBUG_TRACE, "<= key_change %d\n", rc, 0, 0 );
-#endif
return rc;
}