Skip to content
Snippets Groups Projects
Commit ce63e21f authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

New slapindex framework (no meat)

parent 46ca9103
No related branches found
No related tags found
No related merge requests found
......@@ -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,
......
......@@ -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;
......
......@@ -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 )
......
......@@ -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
......
......@@ -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 );
}
......
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment