X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fback-mdb%2Ffilterindex.c;h=b71f0d39d3a460836750a6444cc3ad9b3af9c169;hb=59e9ff6243465640956b58ad1756a3ede53eca7c;hp=4be30170bf79fe0869ea638715066c2c0dab6bc2;hpb=0b03c51e79e714b8f8c8d6811f942f52c52b2383;p=openldap diff --git a/servers/slapd/back-mdb/filterindex.c b/servers/slapd/back-mdb/filterindex.c index 4be30170bf..b71f0d39d3 100644 --- a/servers/slapd/back-mdb/filterindex.c +++ b/servers/slapd/back-mdb/filterindex.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 2000-2013 The OpenLDAP Foundation. + * Copyright 2000-2018 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -211,6 +211,31 @@ mdb_filter_candidates( /* Must not return NULL, otherwise extended filters break */ MDB_IDL_ALL( ids ); } + if ( ids[2] == NOID && MDB_IDL_IS_RANGE( ids )) { + struct mdb_info *mdb = (struct mdb_info *) op->o_bd->be_private; + ID last; + + if ( mdb->mi_nextid ) { + last = mdb->mi_nextid; + } 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,