diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-10-11 04:34:15 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:39:39 -0500 |
commit | a3b33d6fa811dd1277e51e17ba4a4c3954457397 (patch) | |
tree | a1140aab33d7787ff7e916071eea2c515bfaa12e /source4/lib/ldb | |
parent | d2376d70b280a0642ecac23cfc526b76819d6bb1 (diff) | |
download | samba-a3b33d6fa811dd1277e51e17ba4a4c3954457397.tar.gz samba-a3b33d6fa811dd1277e51e17ba4a4c3954457397.tar.bz2 samba-a3b33d6fa811dd1277e51e17ba4a4c3954457397.zip |
r10889: make searches for dn's less of a special case, and much faster when
part of more complex expressions
(This used to be commit 40d304140b4cf22559d6b55c8cbaf1b984baf62f)
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r-- | source4/lib/ldb/ldb_tdb/ldb_index.c | 7 | ||||
-rw-r--r-- | source4/lib/ldb/ldb_tdb/ldb_search.c | 15 |
2 files changed, 7 insertions, 15 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c index c2a4fb1ea8..7c920dd78b 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_index.c +++ b/source4/lib/ldb/ldb_tdb/ldb_index.c @@ -319,6 +319,13 @@ static int ltdb_index_dn_leaf(struct ldb_module *module, 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); } diff --git a/source4/lib/ldb/ldb_tdb/ldb_search.c b/source4/lib/ldb/ldb_tdb/ldb_search.c index eb89753007..74046475e0 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_search.c +++ b/source4/lib/ldb/ldb_tdb/ldb_search.c @@ -501,21 +501,6 @@ int ltdb_search_bytree(struct ldb_module *module, const struct ldb_dn *base, 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; } |