From 0e96868e8ed1d80dfa9e8f8856875385e5a28487 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Wed, 14 Sep 2011 09:54:58 -0700 Subject: [PATCH] Fix onelevel search from last commit --- servers/slapd/back-mdb/dn2id.c | 22 +++++++++++----------- tests/scripts/test003-search | 8 ++++++-- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/servers/slapd/back-mdb/dn2id.c b/servers/slapd/back-mdb/dn2id.c index 837e81fcc6..2550b69592 100644 --- a/servers/slapd/back-mdb/dn2id.c +++ b/servers/slapd/back-mdb/dn2id.c @@ -727,7 +727,7 @@ mdb_idscopes( ID id; ID2 id2; char *ptr; - int rc; + int rc = 0; unsigned int x; unsigned int nrlen, rlen; diskNode *d; @@ -741,15 +741,7 @@ mdb_idscopes( id = isc->id; while (id) { - x = mdb_id2l_search( isc->scopes, id ); - if ( x <= isc->scopes[0].mid && isc->scopes[x].mid == id ) { - if ( !isc->scopes[x].mval.mv_data ) { - isc->nscope = x; - return MDB_SUCCESS; - } - data = isc->scopes[x].mval; - rc = 1; - } else { + if ( !rc ) { key.mv_data = &id; rc = mdb_cursor_get( isc->mc, &key, &data, MDB_SET ); if ( rc ) @@ -766,7 +758,6 @@ mdb_idscopes( isc->rdns[isc->numrdns].bv_val = d->nrdn+nrlen+1; isc->numrdns++; - if (!rc && id != isc->id) { id2.mid = id; id2.mval = data; @@ -775,6 +766,15 @@ mdb_idscopes( ptr = data.mv_data; ptr += data.mv_size - sizeof(ID); memcpy( &id, ptr, sizeof(ID) ); + x = mdb_id2l_search( isc->scopes, id ); + if ( x <= isc->scopes[0].mid && isc->scopes[x].mid == id ) { + if ( !isc->scopes[x].mval.mv_data ) { + isc->nscope = x; + return MDB_SUCCESS; + } + data = isc->scopes[x].mval; + rc = 1; + } if ( op->ors_scope == LDAP_SCOPE_ONELEVEL ) break; } diff --git a/tests/scripts/test003-search b/tests/scripts/test003-search index 86514daae9..8480419943 100755 --- a/tests/scripts/test003-search +++ b/tests/scripts/test003-search @@ -65,9 +65,8 @@ if test $RC != 0 ; then exit $RC fi -cat /dev/null > $SEARCHOUT - echo "Testing exact searching..." +echo "# Testing exact searching..." > $SEARCHOUT $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \ '(sn=jENSEN)' >> $SEARCHOUT 2>&1 RC=$? @@ -78,6 +77,7 @@ if test $RC != 0 ; then fi echo "Testing approximate searching..." +echo "# Testing approximate searching..." >> $SEARCHOUT $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \ '(sn~=jENSEN)' name >> $SEARCHOUT 2>&1 RC=$? @@ -88,6 +88,7 @@ if test $RC != 0 ; then fi echo "Testing OR searching..." +echo "# Testing OR searching..." >> $SEARCHOUT $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \ '(|(givenname=Xx*yY*Z)(cn=)(undef=*)(objectclass=groupofnames)(sn=jones)(member=cn=Manager,dc=example,dc=com)(uniqueMember=cn=Manager,dc=example,dc=com))' >> $SEARCHOUT 2>&1 RC=$? @@ -98,6 +99,7 @@ if test $RC != 0 ; then fi echo "Testing AND matching and ends-with searching..." +echo "# Testing AND matching and ends-with searching..." >> $SEARCHOUT $LDAPSEARCH -S "" -b "ou=groups,$BASEDN" -s one -h $LOCALHOST -p $PORT1 \ '(&(objectclass=groupofnames)(cn=A*)(member=cn=Mark Elliot,ou=Alumni Association,ou=People,dc=example,dc=com))' >> $SEARCHOUT 2>&1 RC=$? @@ -108,6 +110,7 @@ if test $RC != 0 ; then fi echo "Testing NOT searching..." +echo "# Testing NOT searching..." >> $SEARCHOUT $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \ '(!(objectclass=pilotPerson))' >> $SEARCHOUT 2>&1 RC=$? @@ -118,6 +121,7 @@ if test $RC != 0 ; then fi echo "Testing objectClass/attributeType inheritance ..." +echo "# Testing objectClass/attributeType inheritance ..." >> $SEARCHOUT $LDAPSEARCH -M -a never -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \ '(&(objectClass=inetorgperson)(userid=uham))' \ "2.5.4.0" "userid" >> $SEARCHOUT 2>&1 -- 2.39.5