]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-sql/search.c
remove dnNormalize2
[openldap] / servers / slapd / back-sql / search.c
index f1cc0ada09a14f7a0729b4962b110d9a295c7603..9305d45aadc047ea132a3a3585123b410e328381 100644 (file)
@@ -369,7 +369,6 @@ backsql_process_filter( backsql_srch_info *bsi, Filter *f )
        }
 
        if ( rc == -1 ) {
-               /* TimesTen : Don't run the query */
                goto impossible;
        }
  
@@ -400,15 +399,19 @@ backsql_process_filter( backsql_srch_info *bsi, Filter *f )
                 * Note however that hasSubordinates is boolean, 
                 * so a more appropriate filter would be 
                 * '(hasSubordinates=FALSE)'
+                *
+                * A more robust search for hasSubordinates
+                * would * require joining the ldap_entries table
+                * selecting if there are descendants of the
+                * candidate.
                 */
                backsql_strfcat( &bsi->flt_where, "l",
                                (ber_len_t)sizeof( "1=1" ) - 1, "1=1" );
                if ( ad == slap_schema.si_ad_hasSubordinates ) {
                        /*
-                        * We use this flag since we need to parse
-                        * the filter anyway; we should have used
-                        * the frontend API function
-                        * filter_has_subordinates()
+                        * instruct candidate selection algorithm
+                        * and attribute list to try to detect
+                        * if an entry has subordinates
                         */
                        bsi->bsi_flags |= BSQL_SF_FILTER_HASSUBORDINATE;
 
@@ -448,20 +451,6 @@ backsql_process_filter( backsql_srch_info *bsi, Filter *f )
                                &at->join_where );
        }
 
-#if 0
-       /*
-        * FIXME: this is not required any more; however, note that
-        * attribute name syntax might collide with SQL legal aliases
-        */
-       if ( at != &oc_attr ) {
-               backsql_strfcat( &bsi->sel, "cblb",
-                               ',',
-                               &at->sel_expr,
-                               (ber_len_t)sizeof( " AS " ) - 1, " AS ", 
-                               &at->name );
-       }
-#endif
-
        switch ( f->f_choice ) {
        case LDAP_FILTER_EQUALITY:
                filter_value = &f->f_av_value;
@@ -691,19 +680,6 @@ backsql_srch_query( backsql_srch_info *bsi, struct berval *query )
        bsi->flt_where.bb_val.bv_len = 0;
        bsi->flt_where.bb_len = 0;
 
-#if 0
-       /*
-        * FIXME: this query has been split in case a string cast function
-        * is defined; more sophisticated (pattern based) function should
-        * be used
-        */
-       backsql_strcat( &bsi->sel,
-                       "SELECT DISTINCT ldap_entries.id,", 
-                       bsi->oc->keytbl.bv_val, ".", bsi->oc->keycol.bv_val,
-                       ",'", bsi->oc->name.bv_val, "' AS objectClass",
-                       ",ldap_entries.dn AS dn", NULL );
-#endif
-
        backsql_strfcat( &bsi->sel, "lbcbc",
                        (ber_len_t)sizeof( "SELECT DISTINCT ldap_entries.id," ) - 1,
                                "SELECT DISTINCT ldap_entries.id,", 
@@ -781,10 +757,6 @@ backsql_srch_query( backsql_srch_info *bsi, struct berval *query )
                                                "ldap_entries.dn LIKE ?" );
                }
 
-#if 0
-               backsql_strfcat( &bsi->join_where, "b",
-                               &bi->subtree_cond );
-#endif
                break;
 
        default:
@@ -809,8 +781,6 @@ backsql_srch_query( backsql_srch_info *bsi, struct berval *query )
                 * Indicates that there's no possible way the filter matches
                 * anything.  No need to issue the query
                 */
-               Debug( LDAP_DEBUG_TRACE,
-                       "<==backsql_srch_query() returns NULL\n", 0, 0, 0 );
                free( query->bv_val );
                query->bv_val = NULL;
        }
@@ -828,9 +798,10 @@ backsql_srch_query( backsql_srch_info *bsi, struct berval *query )
        bsi->flt_where.bb_val.bv_len = 0;
        bsi->flt_where.bb_len = 0;
        
-       Debug( LDAP_DEBUG_TRACE, "<==backsql_srch_query()\n", 0, 0, 0 );
+       Debug( LDAP_DEBUG_TRACE, "<==backsql_srch_query() returns %s\n",
+               query->bv_val ? query->bv_val : "NULL", 0, 0 );
        
-       return ( query->bv_val == NULL ? 1 : 0 );
+       return ( rc <= 0 ? 1 : 0 );
 }
 
 static int
@@ -860,16 +831,29 @@ backsql_oc_get_candidates( void *v_oc, void *v_bsi )
                        "unchecked limit has been overcome\n", 0, 0, 0 );
                /* should never get here */
                assert( 0 );
-               bsi->status = LDAP_OTHER;
+               bsi->status = LDAP_ADMINLIMIT_EXCEEDED;
                return BACKSQL_STOP;
        }
        
        bsi->oc = oc;
-       if ( backsql_srch_query( bsi, &query ) ) {
+       res = backsql_srch_query( bsi, &query );
+       if ( res ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): "
-                       "could not construct query for objectclass\n",
-                       0, 0, 0 );
-               bsi->status = LDAP_OTHER;
+                       "error while constructing query for objectclass '%s'\n",
+                       oc->oc->soc_cname.bv_val, 0, 0 );
+               /*
+                * FIXME: need to separate errors from legally
+                * impossible filters
+                */
+               bsi->status = LDAP_SUCCESS;
+               return BACKSQL_CONTINUE;
+       }
+
+       if ( query.bv_val == NULL ) {
+               Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): "
+                       "could not construct query for objectclass '%s'\n",
+                       oc->oc->soc_cname.bv_val, 0, 0 );
+               bsi->status = LDAP_SUCCESS;
                return BACKSQL_CONTINUE;
        }