]> git.sur5r.net Git - openldap/commitdiff
Added some delete handlers
authorHoward Chu <hyc@openldap.org>
Thu, 21 Apr 2005 12:45:25 +0000 (12:45 +0000)
committerHoward Chu <hyc@openldap.org>
Thu, 21 Apr 2005 12:45:25 +0000 (12:45 +0000)
servers/slapd/back-bdb/attr.c
servers/slapd/back-bdb/config.c
servers/slapd/back-bdb/proto-bdb.h

index 50182015cce4b6d854d3b11089b3ce8f0d43c505..42b2bc3c26f9303925cdd01584419aa5de9eac86 100644 (file)
@@ -330,9 +330,26 @@ bdb_attr_index_unparse( struct bdb_info *bdb, BerVarray *bva )
        avl_apply( bdb->bi_attrs, bdb_attr_index_unparser, bva, -1, AVL_INORDER );
 }
 
+static void
+bdb_attrinfo_free( AttrInfo *ai )
+{
+#ifdef LDAP_COMP_MATCH
+       free( ai->ai_cr );
+#endif
+       free( ai );
+}
+
 void
 bdb_attr_index_destroy( Avlnode *tree )
 {
-       avl_free( tree, free );
+       avl_free( tree, bdb_attrinfo_free );
 }
 
+void bdb_attr_index_free( struct bdb_info *bdb, AttributeDescription *ad )
+{
+       AttrInfo *ai;
+
+       ai = avl_delete( &bdb->bi_attrs, ad, ainfo_type_cmp );
+       if ( ai )
+               bdb_attrinfo_free( ai );
+}
index e5658dd4b83adfcb50140c2c6cf360be8a8838f0..87c2e884fb2edbb36256a7284bf23e0d53d32763 100644 (file)
@@ -221,7 +221,50 @@ bdb_cf_gen(ConfigArgs *c)
                        break;
                }
                return rc;
+       } else if ( c->op == LDAP_MOD_DELETE ) {
+               rc = 0;
+               switch( c->type ) {
+               /* single-valued no-ops */
+               case BDB_LOCKD:
+               case BDB_SSTACK:
+                       break;
+
+               case BDB_CHKPT:
+                       /* FIXME: should stop the checkpoint task too */
+                       bdb->bi_txn_cp = 0;
+                       break;
+               case BDB_CONFIG:
+                       rc = 1;
+                       /* FIXME: delete values or the whole file? */
+                       break;
+               case BDB_DIRECTORY:
+                       rc = 1;
+                       /* FIXME: what does this mean? */
+                       break;
+               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 ( ber_bvmatch( &bv, &defbv )) {
+                               bdb->bi_defaultmask = 0;
+                       } else {
+                               slap_bv2ad( &bv, &ad, &text );
+                               if ( ad )
+                                       bdb_attr_index_free( bdb, ad );
+                       }
+                       }
+                       break;
+               }
+               return rc;
        }
+
        switch( c->type ) {
        case BDB_CHKPT:
                bdb->bi_txn_cp = 1;
@@ -282,6 +325,10 @@ bdb_cf_gen(ConfigArgs *c)
                        bdb->bi_dbenv_xflags |= DB_TXN_NOSYNC;
                else
                        bdb->bi_dbenv_xflags &= ~DB_TXN_NOSYNC;
+               if ( bdb->bi_db_is_open ) {
+                       bdb->bi_dbenv->set_flags( bdb->bi_dbenv, DB_TXN_NOSYNC,
+                               c->value_int );
+               }
                break;
 
        case BDB_INDEX:
@@ -289,6 +336,9 @@ bdb_cf_gen(ConfigArgs *c)
                        c->argc - 1, &c->argv[1] );
 
                if( rc != LDAP_SUCCESS ) return 1;
+               /* FIXME: must run slapindex on the new attributes */
+               if ( bdb->bi_db_is_open ) {
+               }
                break;
 
        case BDB_LOCKD:
index 31d289c260261cc91abf1cb5db33ac345b44fde7..99716d2079afb28ee4cea3c493d79abdcc9f64a5 100644 (file)
@@ -33,6 +33,7 @@ LDAP_BEGIN_DECL
 #define bdb_attr_mask                          BDB_SYMBOL(attr_mask)
 #define bdb_attr_index_config          BDB_SYMBOL(attr_index_config)
 #define bdb_attr_index_destroy         BDB_SYMBOL(attr_index_destroy)
+#define bdb_attr_index_free                    BDB_SYMBOL(attr_index_free)
 #define bdb_attr_index_unparse         BDB_SYMBOL(attr_index_unparse)
 
 #ifdef LDAP_COMP_MATCH
@@ -57,6 +58,8 @@ int bdb_attr_index_config LDAP_P(( struct bdb_info *bdb,
 
 void bdb_attr_index_unparse LDAP_P(( struct bdb_info *bdb, BerVarray *bva ));
 void bdb_attr_index_destroy LDAP_P(( Avlnode *tree ));
+void bdb_attr_index_free LDAP_P(( struct bdb_info *bdb,
+       AttributeDescription *ad ));
 
 /*
  * config.c