]> git.sur5r.net Git - openldap/commitdiff
Disallow multiple suffixes by default. Otherwise subtree index optimization
authorHoward Chu <hyc@openldap.org>
Thu, 30 Jan 2003 22:00:16 +0000 (22:00 +0000)
committerHoward Chu <hyc@openldap.org>
Thu, 30 Jan 2003 22:00:16 +0000 (22:00 +0000)
breaks. #define BDB_MULTIPLE_SUFFIXES if you want multiple suffix support.
If you use it, subtree indexing will slow down by factor of 2.

servers/slapd/back-bdb/dn2id.c
servers/slapd/back-bdb/init.c

index d164600c3a57fdf8ab414efa1467d9215bdb1f83..99f8888dc9eb0aaa771ff6a372b32856d7300f12 100644 (file)
@@ -67,22 +67,27 @@ bdb_dn2id_add(
                goto done;
        }
 
+#ifndef BDB_MULTIPLE_SUFFIXES
        if( !be_issuffix( be, &ptr )) {
+#endif
                buf[0] = DN_SUBTREE_PREFIX;
-               rc = bdb_idl_insert_key( be, db, txn, &key, e->e_id );
+               rc = db->put( db, txn, &key, &data, DB_NOOVERWRITE );
                if( rc != 0 ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG ( INDEX, ERR, 
-                               "=> bdb_dn2id_add: subtree (%s) insert failed: %d\n",
+                               "=> bdb_dn2id_add: subtree (%s) put failed: %d\n",
                                ptr.bv_val, rc, 0 );
 #else
                        Debug( LDAP_DEBUG_ANY,
-                       "=> bdb_dn2id_add: subtree (%s) insert failed: %d\n",
+                       "=> bdb_dn2id_add: subtree (%s) put failed: %d\n",
                        ptr.bv_val, rc, 0 );
 #endif
                        goto done;
                }
                
+#ifdef BDB_MULTIPLE_SUFFIXES
+       if( !be_issuffix( be, &ptr )) {
+#endif
                dnParent( &ptr, &pdn );
        
                key.size = pdn.bv_len + 2;
@@ -105,9 +110,13 @@ bdb_dn2id_add(
 #endif
                        goto done;
                }
+#ifndef BDB_MULTIPLE_SUFFIXES
        }
 
        while( !be_issuffix( be, &ptr )) {
+#else
+       for (;;) {
+#endif
                ptr.bv_val[-1] = DN_SUBTREE_PREFIX;
 
                rc = bdb_idl_insert_key( be, db, txn, &key, e->e_id );
@@ -124,6 +133,9 @@ bdb_dn2id_add(
 #endif
                        break;
                }
+#ifdef BDB_MULTIPLE_SUFFIXES
+               if( be_issuffix( be, &ptr )) break;
+#endif
                dnParent( &ptr, &pdn );
 
                key.size = pdn.bv_len + 2;
@@ -131,6 +143,9 @@ bdb_dn2id_add(
                key.data = pdn.bv_val - 1;
                ptr = pdn;
        }
+#ifdef BDB_MULTIPLE_SUFFIXES
+       }
+#endif
 
 done:
        ch_free( buf );
@@ -189,7 +204,9 @@ bdb_dn2id_delete(
                goto done;
        }
 
+#ifndef BDB_MULTIPLE_SUFFIXES
        if( !be_issuffix( be, &ptr )) {
+#endif
                buf[0] = DN_SUBTREE_PREFIX;
                rc = db->del( db, txn, &key, 0 );
                if( rc != 0 ) {
@@ -205,6 +222,9 @@ bdb_dn2id_delete(
                        goto done;
                }
 
+#ifdef BDB_MULTIPLE_SUFFIXES
+       if( !be_issuffix( be, &ptr )) {
+#endif
                dnParent( &ptr, &pdn );
 
                key.size = pdn.bv_len + 2;
@@ -227,9 +247,13 @@ bdb_dn2id_delete(
 #endif
                        goto done;
                }
+#ifndef BDB_MULTIPLE_SUFFIXES
        }
 
        while( !be_issuffix( be, &ptr )) {
+#else
+       for (;;) {
+#endif
                ptr.bv_val[-1] = DN_SUBTREE_PREFIX;
 
                rc = bdb_idl_delete_key( be, db, txn, &key, e->e_id );
@@ -245,6 +269,9 @@ bdb_dn2id_delete(
 #endif
                        goto done;
                }
+#ifdef BDB_MULTIPLE_SUFFIXES
+               if( be_issuffix( be, &ptr )) break;
+#endif
                dnParent( &ptr, &pdn );
 
                key.size = pdn.bv_len + 2;
@@ -252,6 +279,9 @@ bdb_dn2id_delete(
                key.data = pdn.bv_val - 1;
                ptr = pdn;
        }
+#ifdef BDB_MULTIPLE_SUFFIXES
+       }
+#endif
 
 done:
        ch_free( buf );
@@ -525,11 +555,13 @@ bdb_dn2idl(
        Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2idl( \"%s\" )\n", dn->bv_val, 0, 0 );
 #endif
 
+#ifndef        BDB_MULTIPLE_SUFFIXES
        if (prefix == DN_SUBTREE_PREFIX && be_issuffix(be, dn))
        {
                BDB_IDL_ALL(bdb, ids);
                return 0;
        }
+#endif
 
        DBTzero( &key );
        key.size = dn->bv_len + 2;
index 5c619263e2b93ad410c9a9c4228460996d6fd1a4..0ad31a1782fe68c1f27c3b460626535235626efd 100644 (file)
@@ -157,6 +157,18 @@ bdb_db_open( BackendDB *be )
                be->be_suffix[0].bv_val, 0, 0 );
 #endif
 
+#ifndef BDB_MULTIPLE_SUFFIXES
+       if ( be->be_suffix[1].bv_val ) {
+#ifdef NEW_LOGGING
+       LDAP_LOG( BACK_BDB, ARGS, 
+               "bdb_db_open: only one suffix allowed\n", 0, 0, 0 );
+#else
+       Debug( LDAP_DEBUG_ARGS,
+               "bdb_db_open: only one suffix allowed\n", 0, 0, 0 );
+#endif
+               return -1;
+       }
+#endif
        /* we should check existance of dbenv_home and db_directory */
 
        rc = db_env_create( &bdb->bi_dbenv, 0 );