diff options
author | Andrew Bartlett <abartlet@samba.org> | 2018-05-29 10:04:29 +1200 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2018-06-26 09:19:16 +0200 |
commit | b8df3cd999c2dd56f77d90fcdc264decc233834e (patch) | |
tree | 089dcb9f02ecec4aa9ef9bc6caaed353825d9205 /lib | |
parent | 703ca1a427a468f763538f1371c388d25745b2dd (diff) | |
download | samba-b8df3cd999c2dd56f77d90fcdc264decc233834e.tar.gz |
ldb: One-level search was incorrectly falling back to full DB scan
When no search filter is specified, the code falls back to using
'(|(objectClass=*)(distinguishedName=*)'. ltdb_index_dn() then failed
because matching against '*' is not indexed. The error return then
caused the code to fallback to a full-scan of the DB, which could have a
considerable performance hit.
Instead, we want to continue on and do the ltdb_index_filter() over the
indexed results that were returned.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13448
Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
(cherry picked from commit 88ae60ed186c9c479722ad62d65a07d0c2e71469)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ldb/ldb_tdb/ldb_index.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/ldb/ldb_tdb/ldb_index.c b/lib/ldb/ldb_tdb/ldb_index.c index 3a1aa23aa7e..251f6295f54 100644 --- a/lib/ldb/ldb_tdb/ldb_index.c +++ b/lib/ldb/ldb_tdb/ldb_index.c @@ -1799,20 +1799,21 @@ int ltdb_search_indexed(struct ltdb_context *ac, uint32_t *match_count) } /* * Here we load the index for the tree. + * + * We only care if this is successful, if the + * index can't trim the result list down then + * the ONELEVEL index is still good enough. */ ret = ltdb_index_dn(ac->module, ltdb, ac->tree, idx_one_tree_list); - if (ret != LDB_SUCCESS) { - talloc_free(idx_one_tree_list); - talloc_free(dn_list); - return ret; - } - - if (!list_intersect(ldb, ltdb, - dn_list, idx_one_tree_list)) { - talloc_free(idx_one_tree_list); - talloc_free(dn_list); - return LDB_ERR_OPERATIONS_ERROR; + if (ret == LDB_SUCCESS) { + if (!list_intersect(ldb, ltdb, + dn_list, + idx_one_tree_list)) { + talloc_free(idx_one_tree_list); + talloc_free(dn_list); + return LDB_ERR_OPERATIONS_ERROR; + } } } break; |