]> git.sur5r.net Git - openldap/commitdiff
Fix approx matching when there is an equality index but no approx index.
authorKurt Zeilenga <kurt@openldap.org>
Fri, 9 Apr 2004 21:30:55 +0000 (21:30 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Fri, 9 Apr 2004 21:30:55 +0000 (21:30 +0000)
Add better approx test

servers/slapd/back-bdb/attr.c
servers/slapd/back-bdb/index.c
servers/slapd/back-ldbm/attr.c
servers/slapd/back-ldbm/index.c
servers/slapd/filterentry.c
servers/slapd/matchedValues.c
tests/data/search.out.master
tests/scripts/test003-search
tests/scripts/test009-referral

index 5540aef86d1ca5cd89c961d5be9f869da5f14b97..dd545d260211ac78e26550f9c95865f085683a00 100644 (file)
@@ -156,12 +156,9 @@ bdb_attr_index_config(
                }
 
                if( IS_SLAP_INDEX( mask, SLAP_INDEX_APPROX ) && !(
-                       ad->ad_type->sat_approx
+                       ad->ad_type->sat_approx
                                && ad->ad_type->sat_approx->smr_indexer
-                               && ad->ad_type->sat_approx->smr_filter )
-                       && ( ad->ad_type->sat_equality
-                               && ad->ad_type->sat_equality->smr_indexer
-                               && ad->ad_type->sat_equality->smr_filter ) ) )
+                               && ad->ad_type->sat_approx->smr_filter ) )
                {
                        fprintf( stderr, "%s: line %d: "
                                "approx index of attribute \"%s\" disallowed\n",
index f2d807eb52a8df8b56e48dea3bd585c28b5d4feb..e1f09f6fdc9becf71b4a457e5fba1e38dea59e6c 100644 (file)
@@ -121,9 +121,14 @@ int bdb_index_param(
                break;
 
        case LDAP_FILTER_APPROX:
-               if( IS_SLAP_INDEX( mask, SLAP_INDEX_APPROX ) ) {
-                       goto done;
+               if ( desc->ad_type->sat_approx ) {
+                       if( IS_SLAP_INDEX( mask, SLAP_INDEX_APPROX ) ) {
+                               goto done;
+                       }
+                       break;
                }
+
+               /* Use EQUALITY rule and index for approximate match */
                /* fall thru */
 
        case LDAP_FILTER_EQUALITY:
index 1ce058b966f84eba84c8157d6f1dcb583514c0cb..bb49d279c210b555c4a697c2e73432858b38806e 100644 (file)
@@ -156,12 +156,9 @@ attr_index_config(
                }
 
                if( IS_SLAP_INDEX( mask, SLAP_INDEX_APPROX ) && !(
-                       ad->ad_type->sat_approx
+                       ad->ad_type->sat_approx
                                && ad->ad_type->sat_approx->smr_indexer
-                               && ad->ad_type->sat_approx->smr_filter )
-                       && ( ad->ad_type->sat_equality
-                               && ad->ad_type->sat_equality->smr_indexer
-                               && ad->ad_type->sat_equality->smr_filter ) ) )
+                               && ad->ad_type->sat_approx->smr_filter ) )
                {
                        fprintf( stderr, "%s: line %d: "
                                "approx index of attribute \"%s\" disallowed\n",
index 13956bbc1ede3fe7517f9830805cbbb420c0b802..90911d36ad659610e6ef45dc274b7c61afc8625f 100644 (file)
@@ -115,9 +115,14 @@ int index_param(
                break;
 
        case LDAP_FILTER_APPROX:
-               if( IS_SLAP_INDEX( mask, SLAP_INDEX_APPROX ) ) {
-                       goto done;
+               if ( desc->ad_type->sat_approx ) {
+                       if( IS_SLAP_INDEX( mask, SLAP_INDEX_APPROX ) ) {
+                               goto done;
+                       }
+                       break;
                }
+
+               /* Use EQUALITY rule and index for approximate match */
                /* fall thru */
 
        case LDAP_FILTER_EQUALITY:
index 86a2db459dfcb135928fb68383a85d16df8713ae..681c66c5c156407aaf983d9996eb404d9ab20d63 100644 (file)
@@ -437,8 +437,7 @@ test_ava_filter(
                        continue;
                }
 
-               for ( bv = a->a_nvals; bv->bv_val != NULL; bv++ )
-               {
+               for ( bv = a->a_nvals; bv->bv_val != NULL; bv++ ) {
                        int ret;
                        int rc;
                        const char *text;
index ef7b39638d06defa1b4aca7908e24a34cd5edece..b8a8e61c45d0f2ce62b6fc0fde8746f011e2dd4b 100644 (file)
@@ -206,8 +206,8 @@ test_ava_vrFilter(
                case LDAP_FILTER_APPROX:
                        mr = a->a_desc->ad_type->sat_approx;
                        if( mr != NULL ) break;
+                       /* use EQUALITY matching rule if no APPROX rule */
 
-               /* use EQUALITY matching rule if no APPROX rule */
                case LDAP_FILTER_EQUALITY:
                        mr = a->a_desc->ad_type->sat_equality;
                        break;
@@ -221,10 +221,7 @@ test_ava_vrFilter(
                        mr = NULL;
                }
 
-               if( mr == NULL ) {
-                       continue;
-
-               }
+               if( mr == NULL ) continue;
 
                bv = a->a_nvals;
                for ( j=0; bv->bv_val != NULL; bv++, j++ ) {
index 6545de94a0d13aa4fe8e0cef6d60997dd703ac83..79ab08ab85939568dc3846f85e792131fcc69f39 100644 (file)
@@ -39,6 +39,20 @@ pager: +1 313 555 4474
 facsimiletelephonenumber: +1 313 555 2177
 telephonenumber: +1 313 555 0355
 
+dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,o=Universit
+ y of Michigan,c=US
+cn: Barbara Jensen
+cn: Babs Jensen
+sn:: IEplbnNlbiA=
+title: Mythical Manager, Research Systems
+
+dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,o=University 
+ of Michigan,c=US
+cn: Bjorn Jensen
+cn: Biiff Jensen
+sn: Jensen
+title: Director, Embedded Systems
+
 dn: cn=All Staff,ou=Groups,o=University of Michigan,c=US
 member: cn=Manager,o=University of Michigan,c=US
 member: cn=Barbara Jensen,ou=Information Technology Division,ou=People,o=Unive
index f473680b31615cf8898e74aed2fd877d21bab104..4adf693f0a516fc696b127dc0be53655de477bdd 100755 (executable)
@@ -75,6 +75,16 @@ if test $RC != 0 ; then
        exit $RC
 fi
 
+echo "Testing approximate searching..."
+$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
+       '(sn~=jENSEN)' name >> $SEARCHOUT 2>&1
+RC=$?
+if test $RC != 0 ; then
+       echo "ldapsearch failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+fi
+
 echo "Testing OR searching..."
 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
        '(|(givenname=Xx*yY*Z)(cn=)(undef=*)(objectclass=groupofnames)(sn~=jones)(member=cn=Manager,o=University of Michigan,c=US)(uniqueMember=cn=Manager,o=University of Michigan,c=US))' >> $SEARCHOUT 2>&1
index d20edc21d2c2d8d0dfbb8bfebab9e333bac107fe..00a352393518bb7e05c205e39420410229fe5fd3 100755 (executable)
@@ -92,6 +92,16 @@ if test $RC != 0 ; then
        exit $RC
 fi
 
+echo "Testing approximate searching..."
+$LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
+       '(sn=jENSEN)' name >> $SEARCHOUT 2>&1
+RC=$?
+if test $RC != 0 ; then
+       echo "ldapsearch failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+fi
+
 echo "Testing OR searching..."
 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
        '(|(objectclass=groupofnames)(objectClass=groupofuniquenames)(sn=jones))' >> $SEARCHOUT 2>&1