}
if ( rc == -1 ) {
- /* TimesTen : Don't run the query */
goto impossible;
}
* 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;
&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;
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,",
"ldap_entries.dn LIKE ?" );
}
-#if 0
- backsql_strfcat( &bsi->join_where, "b",
- &bi->subtree_cond );
-#endif
break;
default:
* 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;
}
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
"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;
}