/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2000-2005 The OpenLDAP Foundation.
+ * Copyright 2000-2006 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
# define SLAP_BDB_ALLOW_DIRTY_READ
#endif
-#define bdb_cf_gen BDB_SYMBOL(cf_gen)
+#define bdb_cf_gen BDB_SYMBOL(cf_gen)
#define bdb_cf_cleanup BDB_SYMBOL(cf_cleanup)
#define bdb_checkpoint BDB_SYMBOL(checkpoint)
#define bdb_online_index BDB_SYMBOL(online_index)
"olcDbNoSync $ olcDbDirtyRead $ olcDbIDLcacheSize $ "
"olcDbIndex $ olcDbLinearIndex $ olcDbLockDetect $ "
"olcDbMode $ olcDbSearchStack $ olcDbShmKey $ "
- " olcDbCacheFree ) )",
+ "olcDbCacheFree ) )",
Cft_Database, bdbcfg },
{ NULL, 0, NULL }
};
ID id, nid;
EntryInfo *ei;
int rc, getnext = 1;
+ int i;
connection_fake_init( &conn, op, ctx );
getnext = 1;
}
+ for ( i = 0; i < bdb->bi_nattrs; i++ ) {
+ if ( bdb->bi_attrs[ i ]->ai_indexmask & BDB_INDEX_DELETING
+ || bdb->bi_attrs[ i ]->ai_newmask == 0 )
+ {
+ continue;
+ }
+ bdb->bi_attrs[ i ]->ai_indexmask = bdb->bi_attrs[ i ]->ai_newmask;
+ bdb->bi_attrs[ i ]->ai_newmask = 0;
+ }
+
ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
ldap_pvt_runqueue_stoptask( &slapd_rq, rtask );
bdb->bi_index_task = NULL;
}
static int
-bdb_cf_gen(ConfigArgs *c)
+bdb_cf_gen( ConfigArgs *c )
{
struct bdb_info *bdb = c->be->be_private;
int rc;
rc = 0;
switch( c->type ) {
case BDB_CHKPT:
- if (bdb->bi_txn_cp ) {
+ if ( bdb->bi_txn_cp ) {
char buf[64];
struct berval bv;
bv.bv_len = sprintf( buf, "%d %d", bdb->bi_txn_cp_kbyte,
break;
case BDB_CONFIG:
- if (( slapMode&SLAP_SERVER_MODE ) && !( bdb->bi_flags&BDB_IS_OPEN )
- && !bdb->bi_db_config ) {
+ if ( ( slapMode & SLAP_SERVER_MODE )
+ && !( bdb->bi_flags & BDB_IS_OPEN )
+ && !bdb->bi_db_config )
+ {
char buf[SLAP_TEXT_BUFLEN];
FILE *f = fopen( bdb->bi_db_config_path, "r" );
struct berval bv;
if ( bdb->bi_txn_cp_task ) {
struct re_s *re = bdb->bi_txn_cp_task;
bdb->bi_txn_cp_task = NULL;
- if ( ldap_pvt_runqueue_isrunning( &slapd_rq, re ))
+ if ( ldap_pvt_runqueue_isrunning( &slapd_rq, re ) )
ldap_pvt_runqueue_stoptask( &slapd_rq, re );
ldap_pvt_runqueue_remove( &slapd_rq, re );
}
case BDB_NOSYNC:
bdb->bi_dbenv->set_flags( bdb->bi_dbenv, DB_TXN_NOSYNC, 0 );
break;
- case BDB_INDEX: {
- AttributeDescription *ad = NULL;
- struct berval bv, def = BER_BVC("default");
- char *ptr;
- const char *text;
- for (ptr = c->line; !isspace( *ptr ); ptr++);
- bv.bv_val = c->line;
- bv.bv_len = ptr - bv.bv_val;
- if ( bvmatch( &bv, &def )) {
- bdb->bi_defaultmask = 0;
+ case BDB_INDEX:
+ if ( c->valx == -1 ) {
+ int i;
+
+ /* delete all (FIXME) */
+ for ( i = 0; i < bdb->bi_nattrs; i++ ) {
+ bdb->bi_attrs[i]->ai_indexmask |= BDB_INDEX_DELETING;
+ }
+ bdb->bi_flags |= BDB_DEL_INDEX;
+ c->cleanup = bdb_cf_cleanup;
+
} else {
- slap_bv2ad( &bv, &ad, &text );
- if ( ad ) {
- AttrInfo *ai = bdb_attr_mask( bdb, ad );
- ai->ai_indexmask |= BDB_INDEX_DELETING;
- bdb->bi_flags |= BDB_DEL_INDEX;
- c->cleanup = bdb_cf_cleanup;
+ struct berval bv, def = BER_BVC("default");
+ char *ptr;
+
+ for (ptr = c->line; !isspace( (unsigned char) *ptr ); ptr++);
+
+ bv.bv_val = c->line;
+ bv.bv_len = ptr - bv.bv_val;
+ if ( bvmatch( &bv, &def )) {
+ bdb->bi_defaultmask = 0;
+
+ } else {
+ int i;
+ char **attrs;
+ char sep;
+
+ sep = bv.bv_val[ bv.bv_len ];
+ bv.bv_val[ bv.bv_len ] = '\0';
+ attrs = ldap_str2charray( bv.bv_val, "," );
+
+ for ( i = 0; attrs[ i ]; i++ ) {
+ AttributeDescription *ad = NULL;
+ const char *text;
+ AttrInfo *ai;
+
+ slap_str2ad( attrs[ i ], &ad, &text );
+ /* if we got here... */
+ assert( ad != NULL );
+
+ ai = bdb_attr_mask( bdb, ad );
+ /* if we got here... */
+ assert( ai != NULL );
+
+ ai->ai_indexmask |= BDB_INDEX_DELETING;
+ bdb->bi_flags |= BDB_DEL_INDEX;
+ c->cleanup = bdb_cf_cleanup;
+ }
+
+ bv.bv_val[ bv.bv_len ] = sep;
+ ldap_charray_free( attrs );
}
}
- }
break;
}
return rc;
if ( c->op == SLAP_CONFIG_ADD ) {
ptr += STRLENOF("dbconfig");
- while (!isspace(*ptr)) ptr++;
- while (isspace(*ptr)) ptr++;
+ while (!isspace((unsigned char)*ptr)) ptr++;
+ while (isspace((unsigned char)*ptr)) ptr++;
}
if ( bdb->bi_flags & BDB_IS_OPEN ) {