BDB_INDEX code does no harm (but no good yet, not used by filters yet).

This commit is contained in:
Kurt Zeilenga 2001-10-05 20:12:16 +00:00
parent 492eb4b65b
commit 78adfde54e
9 changed files with 34 additions and 42 deletions

View File

@ -238,7 +238,6 @@ retry: rc = txn_abort( ltid );
goto return_results;
}
#ifdef BDB_INDEX
/* attribute indexes */
if ( bdb_index_entry_add( be, ltid, e, e->e_attrs ) != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "bdb_add: index_entry_add failed\n",
@ -253,7 +252,6 @@ retry: rc = txn_abort( ltid );
text = "index generation failed";
goto return_results;
}
#endif
rc = txn_commit( ltid, 0 );
ltid = NULL;

View File

@ -15,8 +15,6 @@
#include "slap.h"
#include "back-bdb.h"
#if BDB_CONFIG_INDICES
/* for the cache of attribute information (which are indexed, etc.) */
typedef struct bdb_attrinfo {
#ifdef SLAPD_USE_AD
@ -258,4 +256,3 @@ bdb_attr_index_destroy( Avlnode *tree )
avl_free( tree, ainfo_free );
}
#endif

View File

@ -15,10 +15,7 @@
LDAP_BEGIN_DECL
/* #define BDB_INDEX 1 */
/* #define BDB_REINDEX 1 */
/* #define BDB_FILTER_INDICES 1 */
#define BDB_CONFIG_INDICES 1
/* #define SLAPD_USE_AD 1 */
#define DN_BASE_PREFIX SLAP_INDEX_EQUALITY_PREFIX
@ -67,6 +64,10 @@ struct bdb_info {
int bi_ndatabases;
struct bdb_db_info **bi_databases;
ldap_pvt_thread_mutex_t bi_database_mutex;
slap_mask_t bi_defaultmask;
Avlnode *bi_attrs;
int bi_txn_cp;
u_int32_t bi_txn_cp_min;
@ -78,11 +79,6 @@ struct bdb_info {
ldap_pvt_thread_t bi_lock_detect_tid;
#endif
#if BDB_CONFIG_INDICES
slap_mask_t bi_defaultmask;
Avlnode *bi_attrs;
#endif
ID bi_lastid;
};

View File

@ -32,14 +32,26 @@ bdb_db_cache(
*dbout = NULL;
for( i=BDB_NDB; bdb->bi_databases[i]->bdi_name; i++ ) {
for( i=BDB_NDB; bdb->bi_databases[i]; i++ ) {
if( !strcmp( bdb->bi_databases[i]->bdi_name, name) ) {
*dbout = bdb->bi_databases[i]->bdi_db;
return 0;
}
}
ldap_pvt_thread_mutex_lock( &bdb->bi_database_mutex );
/* check again! may have been added by another thread */
for( i=BDB_NDB; bdb->bi_databases[i]; i++ ) {
if( !strcmp( bdb->bi_databases[i]->bdi_name, name) ) {
*dbout = bdb->bi_databases[i]->bdi_db;
ldap_pvt_thread_mutex_unlock( &bdb->bi_database_mutex );
return 0;
}
}
if( i >= BDB_INDICES ) {
ldap_pvt_thread_mutex_unlock( &bdb->bi_database_mutex );
return -1;
}
@ -52,6 +64,7 @@ bdb_db_cache(
Debug( LDAP_DEBUG_ANY,
"bdb_db_cache: db_create(%s) failed: %s (%d)\n",
bdb->bi_dbenv_home, db_strerror(rc), rc );
ldap_pvt_thread_mutex_unlock( &bdb->bi_database_mutex );
return rc;
}
@ -69,12 +82,15 @@ bdb_db_cache(
Debug( LDAP_DEBUG_ANY,
"bdb_db_cache: db_open(%s) failed: %s (%d)\n",
name, db_strerror(rc), rc );
ldap_pvt_thread_mutex_unlock( &bdb->bi_database_mutex );
return rc;
}
bdb->bi_databases[i+1] = NULL;
bdb->bi_databases[i] = db;
*dbout = db->bdi_db;
ldap_pvt_thread_mutex_unlock( &bdb->bi_database_mutex );
return 0;
}

View File

@ -15,8 +15,6 @@
#include "slap.h"
#include "back-bdb.h"
#ifdef BDB_INDEX
static slap_mask_t index_mask(
Backend *be,
AttributeDescription *desc,
@ -399,5 +397,3 @@ bdb_index_entry(
return LDAP_SUCCESS;
}
#endif

View File

@ -71,6 +71,8 @@ bdb_db_init( BackendDB *be )
bdb->bi_lock_detect = DB_LOCK_NORUN;
#endif
ldap_pvt_thread_mutex_init( &bdb->bi_database_mutex );
be->be_private = bdb;
return 0;
}
@ -373,11 +375,7 @@ bdb_initialize(
bi->bi_tool_entry_next = bdb_tool_entry_next;
bi->bi_tool_entry_get = bdb_tool_entry_get;
bi->bi_tool_entry_put = bdb_tool_entry_put;
#if BDB_REINDEX
bi->bi_tool_entry_reindex = bdb_tool_entry_reindex;
#else
bi->bi_tool_entry_reindex = 0;
#endif
bi->bi_tool_sync = 0;
bi->bi_connection_init = 0;

View File

@ -14,8 +14,8 @@
#include "slap.h"
#include "back-bdb.h"
#include "idl.h"
#ifdef BDB_FILTER_INDICES
/* read a key */
int
bdb_key_read(
@ -26,7 +26,8 @@ bdb_key_read(
ID *ids
)
{
DBT key;
int rc;
DBT key;
#ifdef NEW_LOGGING
LDAP_LOG(( "index", LDAP_LEVEL_ENTRY,
@ -35,10 +36,10 @@ bdb_key_read(
Debug( LDAP_DEBUG_TRACE, "=> key_read\n", 0, 0, 0 );
#endif
DBzero( &key );
DBTzero( &key );
bv2DBT(k,&key);
rc = bdb_idl_fetch_key( be, db, txn, key, ids );
rc = bdb_idl_fetch_key( be, db, txn, &key, ids );
if( rc != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
@ -52,19 +53,16 @@ bdb_key_read(
} else {
#ifdef NEW_LOGGING
LDAP_LOG(( "index", LDAP_LEVEL_ENTRY,
"bdb_key_read: %ld candidates\n",
idl ? ID_BLOCK_NIDS(idl) : 0 ));
"bdb_key_read: %ld candidates\n", BDB_IDL_N(ids) );
#else
Debug( LDAP_DEBUG_TRACE, "<= bdb_index_read %ld candidates\n",
idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
BDB_IDL_N(ids), 0, 0 );
#endif
}
return rc;
}
#endif
#ifdef BDB_INDEX
/* Add or remove stuff from index files */
int
bdb_key_change(
@ -109,4 +107,3 @@ bdb_key_change(
return rc;
}
#endif

View File

@ -127,14 +127,13 @@ int bdb_modify_internal(
return rc;
}
#ifdef BDB_INDEX
/* delete indices for old attributes */
rc = bdb_index_entry_del( be, tid, e, save_attrs);
if ( rc != LDAP_SUCCESS ) {
attrs_free( e->e_attrs );
e->e_attrs = save_attrs;
Debug( LDAP_DEBUG_ANY, "entry index delete failed: %s\n",
*text, 0, 0 );
Debug( LDAP_DEBUG_ANY, "entry index delete failed!\n",
0, 0, 0 );
return rc;
}
@ -143,11 +142,10 @@ int bdb_modify_internal(
if ( rc != LDAP_SUCCESS ) {
attrs_free( e->e_attrs );
e->e_attrs = save_attrs;
Debug( LDAP_DEBUG_ANY, "entry index add failed: %s\n",
*text, 0, 0 );
Debug( LDAP_DEBUG_ANY, "entry index add failed!\n",
0, 0, 0 );
return rc;
}
#endif
attrs_free( save_attrs );
return rc;

View File

@ -156,7 +156,6 @@ ID bdb_tool_entry_put(
goto done;
}
#ifdef BDB_INDEX
rc = bdb_index_entry_add( be, tid, e, e->e_attrs );
if( rc != 0 ) {
Debug( LDAP_DEBUG_ANY,
@ -164,7 +163,6 @@ ID bdb_tool_entry_put(
db_strerror(rc), rc, 0 );
goto done;
}
#endif
done:
if( rc == 0 ) {
@ -187,7 +185,6 @@ done:
return e->e_id;
}
#if BDB_REINDEX
int bdb_tool_entry_reindex(
BackendDB *be,
ID id )
@ -250,4 +247,3 @@ done:
entry_free( e );
return rc;
}
#endif