From ce63e21f00b9e6cf13da31d77c0e89650d4dd105 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Wed, 19 Jul 2000 02:24:08 +0000 Subject: [PATCH] New slapindex framework (no meat) --- servers/slapd/back-ldbm/external.h | 6 +--- servers/slapd/back-ldbm/init.c | 2 +- servers/slapd/back-ldbm/tools.c | 43 ++----------------------- servers/slapd/slap.h | 9 ++---- servers/slapd/tools/slapcommon.c | 6 ++-- servers/slapd/tools/slapindex.c | 50 ++++++------------------------ 6 files changed, 18 insertions(+), 98 deletions(-) diff --git a/servers/slapd/back-ldbm/external.h b/servers/slapd/back-ldbm/external.h index 1ea9d56561..2bdac2f069 100644 --- a/servers/slapd/back-ldbm/external.h +++ b/servers/slapd/back-ldbm/external.h @@ -96,11 +96,7 @@ extern ID ldbm_tool_entry_next LDAP_P(( BackendDB *be )); extern Entry* ldbm_tool_entry_get LDAP_P(( BackendDB *be, ID id )); extern ID ldbm_tool_entry_put LDAP_P(( BackendDB *be, Entry *e )); -extern int ldbm_tool_index_attr LDAP_P(( BackendDB *be, - AttributeDescription* desc )); -extern int ldbm_tool_index_change LDAP_P(( BackendDB *be, - AttributeDescription* desc, - struct berval **bv, ID id, int op )); +extern int ldbm_tool_entry_reindex LDAP_P(( BackendDB *be, ID id )); extern int ldbm_tool_sync LDAP_P(( BackendDB *be )); extern int ldbm_back_referrals LDAP_P(( BackendDB *bd, diff --git a/servers/slapd/back-ldbm/init.c b/servers/slapd/back-ldbm/init.c index d81105ae8c..dc4b5b81de 100644 --- a/servers/slapd/back-ldbm/init.c +++ b/servers/slapd/back-ldbm/init.c @@ -79,7 +79,7 @@ ldbm_back_initialize( bi->bi_tool_entry_next = ldbm_tool_entry_next; bi->bi_tool_entry_get = ldbm_tool_entry_get; bi->bi_tool_entry_put = ldbm_tool_entry_put; - bi->bi_tool_index_attr = ldbm_tool_index_attr; + bi->bi_tool_entry_reindex = ldbm_tool_entry_reindex; bi->bi_tool_sync = ldbm_tool_sync; bi->bi_connection_init = 0; diff --git a/servers/slapd/back-ldbm/tools.c b/servers/slapd/back-ldbm/tools.c index 1715465e69..d83d70360a 100644 --- a/servers/slapd/back-ldbm/tools.c +++ b/servers/slapd/back-ldbm/tools.c @@ -192,48 +192,11 @@ ID ldbm_tool_entry_put( return e->e_id; } -int ldbm_tool_index_attr( +int ldbm_tool_entry_reindex( BackendDB *be, - AttributeDescription *desc -) + ID id ) { - static DBCache *db = NULL; - slap_index indexmask; - char *at_cname; - - assert( slapMode & SLAP_TOOL_MODE ); - - at_cname = desc->ad_cname->bv_val; - - assert( desc != NULL ); - attr_mask( be->be_private, at_cname, &indexmask ); - - if ( (db = ldbm_cache_open( be, at_cname, LDBM_SUFFIX, LDBM_NEWDB )) - == NULL ) - { - Debug( LDAP_DEBUG_ANY, - "<= index_attr NULL (could not open %s%s)\n", at_cname, - LDBM_SUFFIX, 0 ); - return 0; - } - - ldbm_cache_close( be, db ); - - return indexmask != 0; -} - -int ldbm_tool_index_change( - BackendDB *be, - AttributeDescription *desc, - struct berval **bv, - ID id, - int op ) -{ - assert( slapMode & SLAP_TOOL_MODE ); - - index_values( be, desc, bv, id, op ); - - return 0; + return LDAP_OTHER; } int ldbm_tool_sync( BackendDB *be ) diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index f4f7b6374d..2e9fbb0375 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -787,10 +787,9 @@ struct slap_backend_db { #define be_entry_close bd_info->bi_tool_entry_close #define be_entry_first bd_info->bi_tool_entry_first #define be_entry_next bd_info->bi_tool_entry_next +#define be_entry_reindex bd_info->bi_tool_entry_reindex #define be_entry_get bd_info->bi_tool_entry_get #define be_entry_put bd_info->bi_tool_entry_put -#define be_index_attr bd_info->bi_tool_index_attr -#define be_index_change bd_info->bi_tool_index_change #define be_sync bd_info->bi_tool_sync #endif @@ -960,11 +959,7 @@ struct slap_backend_info { ID (*bi_tool_entry_next) LDAP_P(( BackendDB *be )); Entry* (*bi_tool_entry_get) LDAP_P(( BackendDB *be, ID id )); ID (*bi_tool_entry_put) LDAP_P(( BackendDB *be, Entry *e )); - int (*bi_tool_index_attr) LDAP_P(( BackendDB *be, - AttributeDescription *desc )); - int (*bi_tool_index_change) LDAP_P(( BackendDB *be, - AttributeDescription *desc, - struct berval **bv, ID id, int op )); + int (*bi_tool_entry_reindex) LDAP_P(( BackendDB *be, ID id )); int (*bi_tool_sync) LDAP_P(( BackendDB *be )); #define SLAP_INDEX_ADD_OP 0x0001 diff --git a/servers/slapd/tools/slapcommon.c b/servers/slapd/tools/slapcommon.c index 45ba63a2d8..954635a801 100644 --- a/servers/slapd/tools/slapcommon.c +++ b/servers/slapd/tools/slapcommon.c @@ -54,7 +54,7 @@ usage( int tool ) break; case SLAPINDEX: - options = "\tattributetype\n"; + options = "\n"; break; } @@ -161,9 +161,7 @@ slap_tool_init( } } - if ( ( argc != optind + (tool == SLAPINDEX ? 1 : 0) ) - || (dbnum >= 0 && base != NULL ) ) - { + if ( ( argc != optind ) || (dbnum >= 0 && base != NULL ) ) { usage( tool ); } diff --git a/servers/slapd/tools/slapindex.c b/servers/slapd/tools/slapindex.c index efee55d7e8..87ab02d84f 100644 --- a/servers/slapd/tools/slapindex.c +++ b/servers/slapd/tools/slapindex.c @@ -31,9 +31,7 @@ main( int argc, char **argv ) !be->be_entry_close && !be->be_entry_first && !be->be_entry_next && - !be->be_entry_get && - !be->be_index_attr && - !be->be_index_change ) + !be->be_entry_reindex ) { fprintf( stderr, "%s: database doesn't support necessary operations.\n", progname ); @@ -50,12 +48,6 @@ main( int argc, char **argv ) exit( EXIT_FAILURE ); } - if ( !be->be_index_attr( be, desc ) ) { - fprintf( stderr, "attribute type \"%s\": no indices to generate\n", - type ); - exit( EXIT_FAILURE ); - } - if( be->be_entry_open( be, 0 ) != 0 ) { fprintf( stderr, "%s: could not open database.\n", progname ); @@ -66,43 +58,19 @@ main( int argc, char **argv ) id != NOID; id = be->be_entry_next( be ) ) { - Entry* e = be->be_entry_get( be, id ); - - if ( e == NULL ) { - fprintf( stderr, - "entry id=%08lx: no data\n", (long) id ); - rc = EXIT_FAILURE; - if( continuemode ) continue; - break; - } + int rtn; if( verbose ) { - printf("indexing id=%08lx dn=\"%s\"\n", - id, e->e_dn ); + printf("indexing id=%08lx\n", (long) id ); } - { - Attribute *attr; - - for( attr = attrs_find( e->e_attrs, desc ); - attr != NULL; - attr = attrs_find( attr->a_next, desc ) ) - { - - if ( be->be_index_change( be, - desc, attr->a_vals, id, SLAP_INDEX_ADD_OP ) ) - { - rc = EXIT_FAILURE; - - if( !continuemode ) { - entry_free( e ); - goto done; - } - } - } - } + rtn = be->be_entry_reindex( be, id ); - entry_free( e ); + if( rtn != LDAP_SUCCESS ) { + rc = EXIT_FAILURE; + if( continuemode ) continue; + break; + } } done: -- 2.39.5