]> git.sur5r.net Git - openldap/commitdiff
Add presense indexing
authorKurt Zeilenga <kurt@openldap.org>
Tue, 6 Jun 2000 19:32:15 +0000 (19:32 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Tue, 6 Jun 2000 19:32:15 +0000 (19:32 +0000)
servers/slapd/back-ldbm/filterindex.c

index 57a760659a1ab1aa74b0a1d608a2027d932f9a94..238c3ae36fa0980d913ab88614cc304ba9f32603 100644 (file)
@@ -136,11 +136,58 @@ presence_candidates(
 )
 {
        ID_BLOCK        *idl;
+#ifdef SLAPD_SCHEMA_NOT_COMPAT
+       DBCache *db;
+       int rc;
+       char *dbname;
+       slap_index mask;
+       struct berval *prefix;
+#endif
 
        Debug( LDAP_DEBUG_TRACE, "=> presence_candidates\n", 0, 0, 0 );
 
 #ifdef SLAPD_SCHEMA_NOT_COMPAT
        idl = idl_allids( be );
+
+       rc = index_param( be, desc, LDAP_FILTER_PRESENT,
+               &dbname, &mask, &prefix );
+
+       if( rc != LDAP_SUCCESS ) {
+               return idl;
+       }
+
+       if( dbname == NULL ) {
+               /* not indexed */
+               return idl;
+       }
+
+       db = ldbm_cache_open( be, dbname, LDBM_SUFFIX, LDBM_READER );
+       
+       if ( db == NULL ) {
+               Debug( LDAP_DEBUG_ANY,
+                   "<= presense_candidates db open failed (%s%s)\n",
+                       dbname, LDBM_SUFFIX, 0 );
+               return idl;
+       }
+
+       if( prefix != NULL ) {
+               idl_free( idl );
+               idl = NULL;
+
+               rc = key_read( be, db, prefix, &idl );
+
+               if( rc != LDAP_SUCCESS ) {
+                       Debug( LDAP_DEBUG_TRACE, "<= presense_candidates key read failed (%d)\n",
+                           rc, 0, 0 );
+
+               } else if( idl == NULL ) {
+                       Debug( LDAP_DEBUG_TRACE, "<= presense_candidates NULL\n",
+                           0, 0, 0 );
+               }
+       }
+
+       ldbm_cache_close( be, db );
+
 #else
        idl = index_read( be, desc, SLAP_INDEX_PRESENT, NULL );
 #endif
@@ -220,12 +267,6 @@ equality_candidates(
                return idl;
        }
 
-       if( rc != LDAP_SUCCESS ) {
-               Debug( LDAP_DEBUG_TRACE, "<= equality_candidates open failed (%d)\n",
-                   rc, 0, 0 );
-               return idl;
-       }
-
        for ( i= 0; keys[i] != NULL; i++ ) {
                ID_BLOCK *save;
                ID_BLOCK *tmp;
@@ -347,12 +388,6 @@ approx_candidates(
                return idl;
        }
 
-       if( rc != LDAP_SUCCESS ) {
-               Debug( LDAP_DEBUG_TRACE, "<= approx_candidates open failed (%d)\n",
-                   rc, 0, 0 );
-               return idl;
-       }
-
        for ( i= 0; keys[i] != NULL; i++ ) {
                ID_BLOCK *save;
                ID_BLOCK *tmp;