+
+ if ( si->concat_func == NULL ) {
+ Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): "
+ "concat func not specified (use \"concat_pattern\" "
+ "directive in slapd.conf)\n", 0, 0, 0 );
+
+ if ( backsql_split_pattern( backsql_def_concat_func,
+ &si->concat_func, 2 ) ) {
+ Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): "
+ "unable to parse pattern '%s'",
+ backsql_def_concat_func, 0, 0 );
+ return 1;
+ }
+ }
+
+ /*
+ * Prepare cast string as required
+ */
+ if ( si->upper_func.bv_val ) {
+ char buf[1024];
+
+ if ( BACKSQL_UPPER_NEEDS_CAST( si ) ) {
+ snprintf( buf, sizeof( buf ),
+ "%s(cast (" /* ? as varchar(%d))) */ ,
+ si->upper_func.bv_val );
+ ber_str2bv( buf, 0, 1, &si->upper_func_open );
+
+ snprintf( buf, sizeof( buf ),
+ /* (cast(? */ " as varchar(%d)))",
+ BACKSQL_MAX_DN_LEN );
+ ber_str2bv( buf, 0, 1, &si->upper_func_close );
+
+ } else {
+ snprintf( buf, sizeof( buf ), "%s(" /* ?) */ ,
+ si->upper_func.bv_val );
+ ber_str2bv( buf, 0, 1, &si->upper_func_open );
+
+ ber_str2bv( /* (? */ ")", 0, 1, &si->upper_func_close );
+ }
+ }
+
+ /* normalize filter values only if necessary */
+ si->bi_caseIgnoreMatch = mr_find( "caseIgnoreMatch" );
+