]> git.sur5r.net Git - openldap/commitdiff
ITS#8146 fix mdb_filter_candidates for unindexed attr
authorHoward Chu <hyc@openldap.org>
Mon, 18 May 2015 16:55:04 +0000 (17:55 +0100)
committerHoward Chu <hyc@openldap.org>
Mon, 18 May 2015 16:55:04 +0000 (17:55 +0100)
Change result of MDB_IDL_ALL() to use the last entryID in the DB
instead of NOID.

servers/slapd/back-mdb/filterindex.c

index 137f02c2a6da43183ce921a6a791f347e34fc1da..a0fd41b07b343a88666d70fd68c25625c8219877 100644 (file)
@@ -211,6 +211,31 @@ mdb_filter_candidates(
                /* Must not return NULL, otherwise extended filters break */
                MDB_IDL_ALL( ids );
        }
+       if ( MDB_IDL_IS_RANGE( ids ) && ids[2] == NOID ) {
+               struct mdb_info *mdb = (struct mdb_info *) op->o_bd->be_private;
+               ID last;
+
+               if ( mdb->mi_nextid ) {
+                       last = mdb->mi_nextid - 1;
+               } else {
+                       MDB_cursor *mc;
+                       MDB_val key;
+
+                       last = 0;
+                       rc = mdb_cursor_open( rtxn, mdb->mi_id2entry, &mc );
+                       if ( !rc ) {
+                               rc = mdb_cursor_get( mc, &key, NULL, MDB_LAST );
+                               if ( !rc )
+                                       memcpy( &last, key.mv_data, sizeof( last ));
+                               mdb_cursor_close( mc );
+                       }
+               }
+               if ( last ) {
+                       ids[2] = last;
+               } else {
+                       MDB_IDL_ZERO( ids );
+               }
+       }
 
 out:
        Debug( LDAP_DEBUG_FILTER,