SRCS = init.c tools.c config.c \
add.c bind.c compare.c delete.c modify.c modrdn.c search.c \
extended.c passwd.c referral.c \
- attr.c index.c \
+ attr.c index.c key.c dbcache.c \
dn2entry.c dn2id.c error.c id2entry.c idl.c nextid.c
OBJS = init.lo tools.lo config.lo \
add.lo bind.lo compare.lo delete.lo modify.lo modrdn.lo search.lo \
extended.lo passwd.lo referral.lo \
- attr.lo index.lo \
+ attr.lo index.lo key.lo dbcache.lo \
dn2entry.lo dn2id.lo error.lo id2entry.lo idl.lo nextid.lo
LDAP_INCDIR= ../../../include
#endif
}
-#if 0
void
bdb_attr_mask(
struct bdb_info *bdb,
*indexmask = a != NULL ? a->ai_indexmask : 0;
}
-#endif
int
bdb_attr_index_config(
-/* back-bdb.h - ldap ldbm back-end header file */
+/* back-bdb.h - bdb back-end header file */
/* $OpenLDAP$ */
/*
- * Copyright 2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 2000-2001 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
LDAP_BEGIN_DECL
-/* #define BDB_INDEX 1 */
+#define BDB_INDEX 1
/* #define BDB_REINDEX 1 */
/* #define BDB_FILTER_INDICES 1 */
#define BDB_CONFIG_INDICES 1
--- /dev/null
+/* dbcache.c - manage cache of open databases */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-2001 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/errno.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+#include <sys/stat.h>
+
+#include "slap.h"
+#include "back-bdb.h"
+
+int
+bdb_db_cache(
+ Backend *be,
+ const char *name,
+ DB *db )
+{
+ return -1;
+}
ID_BLOCK *save;
ID_BLOCK *tmp;
- rc = key_read( be, db, keys[i], &tmp );
+ rc = bdb_key_read( be, db, keys[i], tmp );
if( rc != LDAP_SUCCESS ) {
idl_free( idl );
ID_BLOCK *save;
ID_BLOCK *tmp;
- rc = key_read( be, db, keys[i], &tmp );
+ rc = bdb_key_read( be, db, keys[i], &tmp );
if( rc != LDAP_SUCCESS ) {
idl_free( idl );
return( idl );
}
-#endif
\ No newline at end of file
+#endif
/* we do not support indexing of binary attributes */
if( slap_ad_is_binary( desc ) ) return 0;
- attr_mask( be->be_private, desc->ad_cname->bv_val, &mask );
+ bdb_attr_mask( be->be_private, desc->ad_cname->bv_val, &mask );
if( mask ) {
*atname = desc->ad_cname->bv_val;
if( slap_ad_is_lang( desc ) ) {
/* has language tag */
- attr_mask( be->be_private, desc->ad_type->sat_cname, &mask );
+ bdb_attr_mask( be->be_private, desc->ad_type->sat_cname, &mask );
if( mask & SLAP_INDEX_AUTO_LANG ) {
*atname = desc->ad_cname->bv_val;
/* see if supertype defined mask for its subtypes */
for( at = desc->ad_type; at != NULL ; at = at->sat_sup ) {
- attr_mask( be->be_private, at->sat_cname, &mask );
+ bdb_attr_mask( be->be_private, at->sat_cname, &mask );
if( mask & SLAP_INDEX_AUTO_SUBTYPES ) {
*atname = desc->ad_type->sat_cname;
dbnamep, &tmpmask );
}
- attr_mask( be->be_private, type->sat_cname, &mask );
+ bdb_attr_mask( be->be_private, type->sat_cname, &mask );
if( mask ) {
*dbnamep = type->sat_cname;
sprintf( lname, "%s;%s", type->sat_cname, lang );
- attr_mask( be->be_private, lname, &tmpmask );
+ bdb_attr_mask( be->be_private, lname, &tmpmask );
if( tmpmask ) {
dbname = lname;
--- /dev/null
+/* index.c - routines for dealing with attribute indexes */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
+#include "slap.h"
+#include "back-bdb.h"
+
+#ifdef BDB_FILTER_INDICES
+/* read a key */
+int
+bdb_key_read(
+ Backend *be,
+ DB *db,
+ DB_TXN *txn,
+ struct berval *k,
+ ID **idout
+)
+{
+ Datum key;
+ ID_BLOCK *idl;
+
+#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
+
+ ldbm_datum_init( key );
+ key.dptr = k->bv_val;
+ key.dsize = k->bv_len;
+
+ rc = bdb_idl_fetch_key( be, db, key, idl );
+
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "index", LDAP_LEVEL_ENTRY,
+ "key_read: %ld candidates\n",
+ idl ? ID_BLOCK_NIDS(idl) : 0 ));
+#else
+ Debug( LDAP_DEBUG_TRACE, "<= index_read %ld candidates\n",
+ idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
+#endif
+
+ *idout = idl;
+ return LDAP_SUCCESS;
+}
+#endif
+
+#ifdef BDB_INDEX
+/* Add or remove stuff from index files */
+int
+bdb_key_change(
+ Backend *be,
+ DB *db,
+ DB_TXN *txn,
+ 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;
+
+ if (op == SLAP_INDEX_ADD_OP) {
+ /* Add values */
+ rc = bdb_idl_insert_key( be, db, txn, &key, id );
+
+ } else {
+ /* Delete values */
+ rc = bdb_idl_delete_key( be, db, txn, &key, id );
+ }
+
+#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
void bdb_attr_index_destroy LDAP_P(( Avlnode *tree ));
+/*
+ * dbcache.c
+ */
+int
+bdb_db_cache(
+ Backend *be,
+ const char *name,
+ DB *db );
+
/*
* dn2entry.c
*/
bdb_key_read(
Backend *be,
DB *db,
+ DB_TXN *txn,
struct berval *k,
ID *ids );
+
+extern int
+bdb_key_change(
+ Backend *be,
+ DB *db,
+ DB_TXN *txn,
+ struct berval *k,
+ ID id,
+ int op );
/*
* nextid.c