Author: tridge
Date: 2005-10-11 04:34:15 +0000 (Tue, 11 Oct 2005)
New Revision: 10889

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=10889

Log:

make searches for dn's less of a special case, and much faster when
part of more complex expressions

Modified:
   branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_index.c
   branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_search.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_index.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_index.c       2005-10-11 
04:28:46 UTC (rev 10888)
+++ branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_index.c       2005-10-11 
04:34:15 UTC (rev 10889)
@@ -319,6 +319,13 @@
        if (ldb_attr_cmp(tree->u.equality.attr, LTDB_OBJECTCLASS) == 0) {
                return ltdb_index_dn_objectclass(module, tree, index_list, 
list);
        }
+       if (ldb_attr_cmp(tree->u.equality.attr, "distinguishedName") == 0 ||
+           ldb_attr_cmp(tree->u.equality.attr, "dn") == 0) {
+               char *dn = talloc_strdup(list, (char 
*)tree->u.equality.value.data);
+               list->count = 1;
+               list->dn = &dn;
+               return 1;
+       }
        return ltdb_index_dn_simple(module, tree, index_list, list);
 }
 

Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_search.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_search.c      2005-10-11 
04:28:46 UTC (rev 10888)
+++ branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_search.c      2005-10-11 
04:34:15 UTC (rev 10889)
@@ -501,21 +501,6 @@
        if ((base == NULL || base->comp_num == 0) &&
            (scope == LDB_SCOPE_BASE || scope == LDB_SCOPE_ONELEVEL)) return -1;
 
-       /* it is important that we handle dn queries this way, and not
-          via a full db search, otherwise ldb is horribly slow */
-       if (tree->operation == LDB_OP_EQUALITY &&
-           (ldb_attr_cmp(tree->u.equality.attr, "dn") == 0 ||
-            ldb_attr_cmp(tree->u.equality.attr, "distinguishedName") == 0)) {
-               struct ldb_dn *dn;
-               dn = ldb_dn_explode(module->ldb, tree->u.equality.value.data);
-               if (dn == NULL) {
-                       return LDB_ERR_INVALID_DN_SYNTAX;
-               }
-               ret = ltdb_search_dn(module, dn, attrs, res);
-               talloc_free(dn);
-               return ret;
-       }
-
        if (ltdb_lock_read(module) != 0) {
                return -1;
        }

Reply via email to