Author: nkinder
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv13436
Modified Files:
ldbm_search.c
Log Message:
Resolves: 288521
Summary: Presence filter using attribute subtype returns incorrect search results.
Index: ldbm_search.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ldbm_search.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ldbm_search.c 17 Sep 2007 19:18:31 -0000 1.10
+++ ldbm_search.c 27 Sep 2007 21:33:37 -0000 1.11
@@ -943,10 +943,12 @@
IDList *idl
)
{
+ int rc = 0;
+
/* Is the ID list ALLIDS ? */
if ( ALLIDS(idl)) {
/* If so, then can't optimize */
- return 0;
+ return rc;
}
/* Is this a base scope search? */
@@ -956,11 +958,40 @@
* the entrydn index in producing our 1 candidate, and that means
* we have not used the filter to produce the candidate list.
*/
- return 0;
+ return rc;
}
-
+
/* Grok the filter and tell me if it has only equality components in it */
- return grok_filter(f);
+ rc = grok_filter(f);
+
+ /* If we haven't determined that we can't skip the filter test already,
+ * do one last check for attribute subtypes. We don't need to worry
+ * about any complex filters here since grok_filter() will have already
+ * assumed that we can't skip the filter test in those cases. */
+ if (rc != 0) {
+ char *type = NULL;
+ char *basetype = NULL;
+
+ /* We don't need to free type since that's taken
+ * care of when the filter is free'd later. We
+ * do need to free basetype when we are done. */
+ slapi_filter_get_attribute_type(f, &type);
+ basetype = slapi_attr_basetype(type, NULL, 0);
+
+ /* Is the filter using an attribute subtype? */
+ if (strcasecmp(type, basetype) != 0) {
+ /* If so, we can't optimize since attribute subtypes
+ * are simply indexed under their basetype attribute.
+ * The basetype index has no knowledge of the subtype
+ * itself. In the future, we should add support for
+ * indexing the subtypes so we can optimize this type
+ * of search. */
+ rc = 0;
+ }
+ slapi_ch_free_string(&basetype);
+ }
+
+ return rc;
}
Show replies by thread