From 96e003883208e701b8ad2f8b764f66f8facc8cda Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Fri, 5 Oct 2001 01:19:58 +0000 Subject: [PATCH] Initial idl fetch code, undef BDB_INDEX for now, other cleanup --- servers/slapd/back-bdb/back-bdb.h | 2 +- servers/slapd/back-bdb/config.c | 2 +- servers/slapd/back-bdb/delete.c | 2 +- servers/slapd/back-bdb/extended.c | 5 ++-- servers/slapd/back-bdb/filterindex.c | 34 ++++++++++++------------ servers/slapd/back-bdb/idl.c | 24 +++++++++++++++++ servers/slapd/back-bdb/key.c | 39 +++++++++++++++++----------- servers/slapd/back-bdb/proto-bdb.h | 7 +++++ 8 files changed, 78 insertions(+), 37 deletions(-) diff --git a/servers/slapd/back-bdb/back-bdb.h b/servers/slapd/back-bdb/back-bdb.h index b3fd31f383..d3191f5209 100644 --- a/servers/slapd/back-bdb/back-bdb.h +++ b/servers/slapd/back-bdb/back-bdb.h @@ -15,7 +15,7 @@ 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 diff --git a/servers/slapd/back-bdb/config.c b/servers/slapd/back-bdb/config.c index f9a66fcc63..c22a847239 100644 --- a/servers/slapd/back-bdb/config.c +++ b/servers/slapd/back-bdb/config.c @@ -1,4 +1,4 @@ -/* config.c - ldbm backend configuration file routine */ +/* config.c - bdb backend configuration file routine */ /* $OpenLDAP$ */ /* * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved. diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index 8ad2557473..de0028a0be 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -1,4 +1,4 @@ -/* delete.c - ldbm backend delete routine */ +/* delete.c - bdb backend delete routine */ /* $OpenLDAP$ */ /* * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved. diff --git a/servers/slapd/back-bdb/extended.c b/servers/slapd/back-bdb/extended.c index 04b96f823a..83ab00ccc4 100644 --- a/servers/slapd/back-bdb/extended.c +++ b/servers/slapd/back-bdb/extended.c @@ -1,4 +1,4 @@ -/* extended.c - ldbm backend extended routines */ +/* extended.c - bdb backend extended routines */ /* $OpenLDAP$ */ /* * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved. @@ -49,4 +49,5 @@ bdb_extended( *text = "not supported within naming context"; return LDAP_OPERATIONS_ERROR; -} \ No newline at end of file +} + diff --git a/servers/slapd/back-bdb/filterindex.c b/servers/slapd/back-bdb/filterindex.c index 3e7427834b..73490efa07 100644 --- a/servers/slapd/back-bdb/filterindex.c +++ b/servers/slapd/back-bdb/filterindex.c @@ -310,15 +310,15 @@ equality_candidates( if( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, - "<= bdb_equality_candidates: (%s%s) MR filter failed (%d)\n", - "", "", rc ); + "<= bdb_equality_candidates: MR filter failed (%d)\n", + rc, 0, 0 ); return 0; } if( keys == NULL ) { Debug( LDAP_DEBUG_TRACE, - "<= bdb_equality_candidates: no keys (%s%s)\n", - "", "", 0 ); + "<= bdb_equality_candidates: no keys\n", + 0, 0, 0 ); return 0; } @@ -417,22 +417,22 @@ approx_candidates( if( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, - "<= approx_candidates: (%s%s) MR filter failed (%d)\n", - dbname, LDBM_SUFFIX, rc ); + "<= approx_candidates: (%s) MR filter failed (%d)\n", + dbname, rc, 0 ); return idl; } if( keys == NULL ) { Debug( LDAP_DEBUG_TRACE, - "<= approx_candidates: no keys (%s%s)\n", - dbname, LDBM_SUFFIX, 0 ); + "<= approx_candidates: no keys (%s)\n", + dbname, 0, 0 ); return idl; } if ( db == NULL ) { Debug( LDAP_DEBUG_ANY, - "<= approx_candidates db open failed (%s%s)\n", - dbname, LDBM_SUFFIX, 0 ); + "<= approx_candidates db open failed (%s)\n", + dbname, 0, 0 ); return idl; } @@ -537,24 +537,24 @@ substring_candidates( if( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, - "<= substrings_candidates: (%s%s) MR filter failed (%d)\n", - dbname, LDBM_SUFFIX, rc ); + "<= substrings_candidates: (%s) MR filter failed (%d)\n", + dbname, rc, 0 ); return idl; } if( keys == NULL ) { Debug( LDAP_DEBUG_TRACE, - "<= substrings_candidates: (0x%04lx) no keys (%s%s)\n", - mask, dbname, LDBM_SUFFIX ); + "<= substrings_candidates: (0x%04lx) no keys (%s)\n", + mask, dbname, 0 ); return idl; } - db = ldbm_cache_open( be, dbname, LDBM_SUFFIX, LDBM_READER ); + rc = bdb_db_cache( be, dbname, &db ); if ( db == NULL ) { Debug( LDAP_DEBUG_ANY, - "<= substrings_candidates db open failed (%s%s)\n", - dbname, LDBM_SUFFIX, 0 ); + "<= substrings_candidates db open failed (%s)\n", + dbname, 0, 0 ); return idl; } diff --git a/servers/slapd/back-bdb/idl.c b/servers/slapd/back-bdb/idl.c index 71666bc862..0463bc5ba9 100644 --- a/servers/slapd/back-bdb/idl.c +++ b/servers/slapd/back-bdb/idl.c @@ -211,6 +211,30 @@ static int idl_delete( ID *ids, ID id ) return 0; } +int +bdb_idl_fetch_key( + BackendDB *be, + DB *db, + DB_TXN *tid, + DBT *key, + ID *ids ) +{ + int rc; + DBT data; + + assert( ids != NULL ); + + DBTzero( &data ); + data.data = ids; + data.ulen = BDB_IDL_SIZE * sizeof( ID ); + data.flags = DB_DBT_USERMEM; + + /* fetch it */ + rc = db->get( db, tid, key, &data, 0 ); + + return rc; +} + int bdb_idl_insert_key( BackendDB *be, diff --git a/servers/slapd/back-bdb/key.c b/servers/slapd/back-bdb/key.c index 95109daa08..f5b877e5a2 100644 --- a/servers/slapd/back-bdb/key.c +++ b/servers/slapd/back-bdb/key.c @@ -23,36 +23,45 @@ bdb_key_read( DB *db, DB_TXN *txn, struct berval *k, - ID **idout + ID *ids ) { - Datum key; - ID_BLOCK *idl; + DBT key; #ifdef NEW_LOGGING LDAP_LOG(( "index", LDAP_LEVEL_ENTRY, - "key_read: enter\n" )); + "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; + DBzero( &key ); + key.data = k->bv_val; + key.size = k->bv_len; - rc = bdb_idl_fetch_key( be, db, key, idl ); + rc = bdb_idl_fetch_key( be, db, txn, key, ids ); + if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "index", LDAP_LEVEL_ENTRY, - "key_read: %ld candidates\n", - idl ? ID_BLOCK_NIDS(idl) : 0 )); + LDAP_LOG(( "index", LDAP_LEVEL_ENTRY, + "bdb_key_read: failed (%d)\n", + rc )); #else - Debug( LDAP_DEBUG_TRACE, "<= index_read %ld candidates\n", - idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 ); + 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 + } - *idout = idl; - return LDAP_SUCCESS; + return rc; } #endif diff --git a/servers/slapd/back-bdb/proto-bdb.h b/servers/slapd/back-bdb/proto-bdb.h index 06c1922533..7e641bf9d5 100644 --- a/servers/slapd/back-bdb/proto-bdb.h +++ b/servers/slapd/back-bdb/proto-bdb.h @@ -142,6 +142,13 @@ int bdb_id2entry( */ unsigned bdb_idl_search( ID *ids, ID id ); +int bdb_idl_fetch_key( + BackendDB *be, + DB *db, + DB_TXN *txn, + DBT *key, + ID *ids ); + int bdb_idl_insert_key( BackendDB *be, DB *db, -- 2.39.5