summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/modules
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-10-06 05:24:46 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:39:26 -0500
commit5fd031c97daaa1bf09a7ad80550753acd434075f (patch)
tree8221ef256c17f138b11d22d9da26ae95db5618c4 /source4/lib/ldb/modules
parent92da5aa6b8d5141b22d781442583c9f3ad94d3af (diff)
downloadsamba-5fd031c97daaa1bf09a7ad80550753acd434075f.tar.gz
samba-5fd031c97daaa1bf09a7ad80550753acd434075f.tar.bz2
samba-5fd031c97daaa1bf09a7ad80550753acd434075f.zip
r10753: don't require every ldb module to implement both a search_bytree() and
a search() function, instead each module now only implements the bytree method, and the expression based search is handled generically by the modules code. This makes for more consistency and less code duplication. fixed the tdb backend to handle BASE searches much more efficiently. They now always only lookup one record, regardless of the search expression (This used to be commit 7e44f9153c5578624e2fca04cdc0a00af0fd9eb4)
Diffstat (limited to 'source4/lib/ldb/modules')
-rw-r--r--source4/lib/ldb/modules/ldb_map.c37
-rw-r--r--source4/lib/ldb/modules/rdn_name.c13
-rw-r--r--source4/lib/ldb/modules/schema.c8
-rw-r--r--source4/lib/ldb/modules/skel.c7
-rw-r--r--source4/lib/ldb/modules/timestamps.c9
5 files changed, 13 insertions, 61 deletions
diff --git a/source4/lib/ldb/modules/ldb_map.c b/source4/lib/ldb/modules/ldb_map.c
index 1133991ac4..1da1ef661a 100644
--- a/source4/lib/ldb/modules/ldb_map.c
+++ b/source4/lib/ldb/modules/ldb_map.c
@@ -744,9 +744,9 @@ static int map_delete(struct ldb_module *module, const struct ldb_dn *dn)
}
/* search fallback database */
-static int map_search_bytree_fb(struct ldb_module *module, const struct ldb_dn *base,
- enum ldb_scope scope, struct ldb_parse_tree *tree,
- const char * const *attrs, struct ldb_message ***res)
+static int map_search_fb(struct ldb_module *module, const struct ldb_dn *base,
+ enum ldb_scope scope, struct ldb_parse_tree *tree,
+ const char * const *attrs, struct ldb_message ***res)
{
int ret;
struct ldb_parse_tree t_and, t_not, t_present, *childs[2];
@@ -771,7 +771,7 @@ static int map_search_bytree_fb(struct ldb_module *module, const struct ldb_dn *
}
/* Search in the database against which we are mapping */
-static int map_search_bytree_mp(struct ldb_module *module, const struct ldb_dn *base,
+static int map_search_mp(struct ldb_module *module, const struct ldb_dn *base,
enum ldb_scope scope, struct ldb_parse_tree *tree,
const char * const *attrs, struct ldb_message ***res)
{
@@ -869,14 +869,14 @@ static int map_search_bytree_mp(struct ldb_module *module, const struct ldb_dn *
search for matching records using a ldb_parse_tree
*/
static int map_search_bytree(struct ldb_module *module, const struct ldb_dn *base,
- enum ldb_scope scope, struct ldb_parse_tree *tree,
- const char * const *attrs, struct ldb_message ***res)
+ enum ldb_scope scope, struct ldb_parse_tree *tree,
+ const char * const *attrs, struct ldb_message ***res)
{
struct ldb_message **fbres, **mpres = NULL;
int i;
int ret_fb, ret_mp;
- ret_fb = map_search_bytree_fb(module, base, scope, tree, attrs, &fbres);
+ ret_fb = map_search_fb(module, base, scope, tree, attrs, &fbres);
if (ret_fb == -1)
return -1;
@@ -886,7 +886,7 @@ static int map_search_bytree(struct ldb_module *module, const struct ldb_dn *bas
return ret_fb;
}
- ret_mp = map_search_bytree_mp(module, base, scope, tree, attrs, &mpres);
+ ret_mp = map_search_mp(module, base, scope, tree, attrs, &mpres);
if (ret_mp == -1) {
return -1;
}
@@ -901,26 +901,6 @@ static int map_search_bytree(struct ldb_module *module, const struct ldb_dn *bas
return ret_fb + ret_mp;
}
-/*
- search for matching records
-*/
-static int map_search(struct ldb_module *module, const struct ldb_dn *base,
- enum ldb_scope scope, const char *expression,
- const char * const *attrs, struct ldb_message ***res)
-{
- struct ldb_parse_tree *tree;
- int ret;
-
- tree = ldb_parse_tree(NULL, expression);
- if (tree == NULL) {
- ldb_set_errstring(module, talloc_strdup(module, "expression parse failed"));
- return -1;
- }
-
- ret = map_search_bytree(module, base, scope, tree, attrs, res);
- talloc_free(tree);
- return ret;
-}
static int msg_contains_objectclass(const struct ldb_message *msg, const char *name)
{
@@ -1270,7 +1250,6 @@ static int map_del_trans(struct ldb_module *module)
static const struct ldb_module_ops map_ops = {
.name = "map",
- .search = map_search,
.search_bytree = map_search_bytree,
.add_record = map_add,
.modify_record = map_modify,
diff --git a/source4/lib/ldb/modules/rdn_name.c b/source4/lib/ldb/modules/rdn_name.c
index 3e3fbd544f..0275952780 100644
--- a/source4/lib/ldb/modules/rdn_name.c
+++ b/source4/lib/ldb/modules/rdn_name.c
@@ -37,17 +37,9 @@
#include "ldb/include/ldb_private.h"
#include <time.h>
-static int rdn_name_search(struct ldb_module *module, const struct ldb_dn *base,
- enum ldb_scope scope, const char *expression,
- const char * const *attrs, struct ldb_message ***res)
-{
- ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_name_search\n");
- return ldb_next_search(module, base, scope, expression, attrs, res);
-}
-
static int rdn_name_search_bytree(struct ldb_module *module, const struct ldb_dn *base,
- enum ldb_scope scope, struct ldb_parse_tree *tree,
- const char * const *attrs, struct ldb_message ***res)
+ enum ldb_scope scope, struct ldb_parse_tree *tree,
+ const char * const *attrs, struct ldb_message ***res)
{
ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_name_search\n");
return ldb_next_search_bytree(module, base, scope, tree, attrs, res);
@@ -241,7 +233,6 @@ static int rdn_name_destructor(void *module_ctx)
static const struct ldb_module_ops rdn_name_ops = {
.name = "rdn_name",
- .search = rdn_name_search,
.search_bytree = rdn_name_search_bytree,
.add_record = rdn_name_add_record,
.modify_record = rdn_name_modify_record,
diff --git a/source4/lib/ldb/modules/schema.c b/source4/lib/ldb/modules/schema.c
index e882f72bd4..7c1753b215 100644
--- a/source4/lib/ldb/modules/schema.c
+++ b/source4/lib/ldb/modules/schema.c
@@ -283,13 +283,6 @@ static int get_attr_list_recursive(struct ldb_module *module, struct schema_stru
}
/* search */
-static int schema_search(struct ldb_module *module, const struct ldb_dn *base,
- enum ldb_scope scope, const char *expression,
- const char * const *attrs, struct ldb_message ***res)
-{
- return ldb_next_search(module, base, scope, expression, attrs, res);
-}
-
static int schema_search_bytree(struct ldb_module *module, const struct ldb_dn *base,
enum ldb_scope scope, struct ldb_parse_tree *tree,
const char * const *attrs, struct ldb_message ***res)
@@ -537,7 +530,6 @@ static int schema_destructor(void *module_ctx)
static const struct ldb_module_ops schema_ops = {
.name = "schema",
- .search = schema_search,
.search_bytree = schema_search_bytree,
.add_record = schema_add_record,
.modify_record = schema_modify_record,
diff --git a/source4/lib/ldb/modules/skel.c b/source4/lib/ldb/modules/skel.c
index 5d14a27a7b..f882a840e1 100644
--- a/source4/lib/ldb/modules/skel.c
+++ b/source4/lib/ldb/modules/skel.c
@@ -43,10 +43,10 @@ struct private_data {
/* search */
static int skel_search(struct ldb_module *module, const struct ldb_dn *base,
- enum ldb_scope scope, const char *expression,
+ enum ldb_scope scope, struct ldb_parse_tree *tree,
const char * const *attrs, struct ldb_message ***res)
{
- return ldb_next_search(module, base, scope, expression, attrs, res);
+ return ldb_next_search(module, base, scope, tree, attrs, res);
}
/* add_record */
@@ -102,8 +102,7 @@ static int skel_destructor(void *module_ctx)
static const struct ldb_module_ops skel_ops = {
.name = "skel",
- .search = skel_search,
- .search_bytree = skel_search_bytree,
+ .search_bytree = skel_search_bytree,
.add_record = skel_add_record,
.modify_record = skel_modify_record,
.delete_record = skel_delete_record,
diff --git a/source4/lib/ldb/modules/timestamps.c b/source4/lib/ldb/modules/timestamps.c
index 01e5c2c37c..5a1e54486a 100644
--- a/source4/lib/ldb/modules/timestamps.c
+++ b/source4/lib/ldb/modules/timestamps.c
@@ -37,14 +37,6 @@
#include "ldb/include/ldb_private.h"
#include <time.h>
-static int timestamps_search(struct ldb_module *module, const struct ldb_dn *base,
- enum ldb_scope scope, const char *expression,
- const char * const *attrs, struct ldb_message ***res)
-{
- ldb_debug(module->ldb, LDB_DEBUG_TRACE, "timestamps_search\n");
- return ldb_next_search(module, base, scope, expression, attrs, res);
-}
-
static int timestamps_search_bytree(struct ldb_module *module, const struct ldb_dn *base,
enum ldb_scope scope, struct ldb_parse_tree *tree,
const char * const *attrs, struct ldb_message ***res)
@@ -238,7 +230,6 @@ static int timestamps_destructor(void *module_ctx)
static const struct ldb_module_ops timestamps_ops = {
.name = "timestamps",
- .search = timestamps_search,
.search_bytree = timestamps_search_bytree,
.add_record = timestamps_add_record,
.modify_record = timestamps_modify_record,