X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fback-bdb%2Fkey.c;h=20f59088a3848c06e4470d3534ae95d39d84c7d3;hb=6e9c21cff8fc740dc6ed21c6f64d9a8899a33401;hp=e892b0102cd021b7a25b3a25c7a8014b80c89e78;hpb=78adfde54e0aa46efbfadb926135f0e93bca951a;p=openldap diff --git a/servers/slapd/back-bdb/key.c b/servers/slapd/back-bdb/key.c index e892b0102c..20f59088a3 100644 --- a/servers/slapd/back-bdb/key.c +++ b/servers/slapd/back-bdb/key.c @@ -1,7 +1,7 @@ /* index.c - routines for dealing with attribute indexes */ /* $OpenLDAP$ */ /* - * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved. + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file */ @@ -19,10 +19,10 @@ /* read a key */ int bdb_key_read( - Backend *be, + Backend *be, DB *db, DB_TXN *txn, - struct berval *k, + struct berval *k, ID *ids ) { @@ -30,33 +30,32 @@ bdb_key_read( DBT key; #ifdef NEW_LOGGING - LDAP_LOG(( "index", LDAP_LEVEL_ENTRY, - "key_read: enter\n" )); + LDAP_LOG( INDEX, ENTRY, "key_read: enter\n", 0, 0, 0 ); #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 ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "index", LDAP_LEVEL_ENTRY, - "bdb_key_read: failed (%d)\n", - rc )); + LDAP_LOG( INDEX, ERR, "bdb_key_read: failed (%d)\n", rc, 0, 0 ); #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", BDB_IDL_N(ids) ); + LDAP_LOG( INDEX, DETAIL1, + "bdb_key_read: %ld candidates\n", (long)BDB_IDL_N(ids), 0, 0); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_index_read %ld candidates\n", - BDB_IDL_N(ids), 0, 0 ); + (long) BDB_IDL_N(ids), 0, 0 ); #endif } @@ -66,21 +65,20 @@ bdb_key_read( /* 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 )); + LDAP_LOG( INDEX, ENTRY, "key_change: %s ID %lx\n", + op == SLAP_INDEX_ADD_OP ? "Add" : "Delete", (long) id, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> key_change(%s,%lx)\n", op == SLAP_INDEX_ADD_OP ? "ADD":"DELETE", (long) id, 0 ); @@ -88,19 +86,21 @@ bdb_key_change( DBTzero( &key ); 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 */ + 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 )); + LDAP_LOG( INDEX, RESULTS, "key_change: return %d\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= key_change %d\n", rc, 0, 0 ); #endif