]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-sql/search.c
Happy New Year!
[openldap] / servers / slapd / back-sql / search.c
index 1531de57767d9fdbb416eed9c6b145e49e073bf6..cadd0366dcf6819c3b2cff8a382f533e3bffad91 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2010 The OpenLDAP Foundation.
+ * Copyright 1999-2012 The OpenLDAP Foundation.
  * Portions Copyright 1999 Dmitry Kovalev.
  * Portions Copyright 2002 Pierangelo Masarati.
  * Portions Copyright 2004 Mark Adamson.
@@ -928,7 +928,7 @@ backsql_process_filter( backsql_srch_info *bsi, Filter *f )
 #ifdef BACKSQL_SYNCPROV
        } else if ( ad == slap_schema.si_ad_entryCSN ) {
                /*
-                * support for syncrepl as producer...
+                * support for syncrepl as provider...
                 */
 #if 0
                if ( !bsi->bsi_op->o_sync ) {
@@ -1746,9 +1746,10 @@ backsql_oc_get_candidates( void *v_oc, void *v_bsi )
                return BACKSQL_AVL_CONTINUE;
        }
        
-       Debug( LDAP_DEBUG_TRACE, "id: '%ld'\n", bsi->bsi_oc->bom_id, 0, 0 );
+       Debug( LDAP_DEBUG_TRACE, "id: '" BACKSQL_IDNUMFMT "'\n",
+               bsi->bsi_oc->bom_id, 0, 0 );
 
-       rc = backsql_BindParamInt( sth, 1, SQL_PARAM_INPUT,
+       rc = backsql_BindParamNumID( sth, 1, SQL_PARAM_INPUT,
                        &bsi->bsi_oc->bom_id );
        if ( rc != SQL_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): "
@@ -1883,13 +1884,8 @@ backsql_oc_get_candidates( void *v_oc, void *v_bsi )
        case LDAP_SCOPE_ONELEVEL:
                assert( !BER_BVISNULL( &bsi->bsi_base_id.eid_ndn ) );
 
-#ifdef BACKSQL_ARBITRARY_KEY
-               Debug( LDAP_DEBUG_TRACE, "(one)id: \"%s\"\n",
-                               bsi->bsi_base_id.eid_id.bv_val, 0, 0 );
-#else /* ! BACKSQL_ARBITRARY_KEY */
-               Debug( LDAP_DEBUG_TRACE, "(one)id: '%lu'\n",
-                               bsi->bsi_base_id.eid_id, 0, 0 );
-#endif /* ! BACKSQL_ARBITRARY_KEY */
+               Debug( LDAP_DEBUG_TRACE, "(one)id=" BACKSQL_IDFMT "\n",
+                       BACKSQL_IDARG(bsi->bsi_base_id.eid_id), 0, 0 );
                rc = backsql_BindParamID( sth, 2, SQL_PARAM_INPUT,
                                &bsi->bsi_base_id.eid_id );
                if ( rc != SQL_SUCCESS ) {
@@ -1945,10 +1941,10 @@ backsql_oc_get_candidates( void *v_oc, void *v_bsi )
                ber_str2bv_x( row.cols[ 1 ], 0, 1, &c_id->eid_keyval,
                                op->o_tmpmemctx );
 #else /* ! BACKSQL_ARBITRARY_KEY */
-               if ( lutil_atoulx( &c_id->eid_id, row.cols[ 0 ], 0 ) != 0 ) {
+               if ( BACKSQL_STR2ID( &c_id->eid_id, row.cols[ 0 ], 0 ) != 0 ) {
                        goto cleanup;
                }
-               if ( lutil_atoulx( &c_id->eid_keyval, row.cols[ 1 ], 0 ) != 0 ) {
+               if ( BACKSQL_STR2ID( &c_id->eid_keyval, row.cols[ 1 ], 0 ) != 0 ) {
                        goto cleanup;
                }
 #endif /* ! BACKSQL_ARBITRARY_KEY */
@@ -1963,16 +1959,11 @@ backsql_oc_get_candidates( void *v_oc, void *v_bsi )
                *bsi->bsi_id_listtail = c_id;
                bsi->bsi_id_listtail = &c_id->eid_next;
 
-#ifdef BACKSQL_ARBITRARY_KEY
                Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): "
-                       "added entry id=%s, keyval=%s dn=\"%s\"\n",
-                       c_id->eid_id.bv_val, c_id->eid_keyval.bv_val,
+                       "added entry id=" BACKSQL_IDFMT " keyval=" BACKSQL_IDFMT " dn=\"%s\"\n",
+                       BACKSQL_IDARG(c_id->eid_id),
+                       BACKSQL_IDARG(c_id->eid_keyval),
                        row.cols[ 3 ] );
-#else /* ! BACKSQL_ARBITRARY_KEY */
-               Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): "
-                       "added entry id=%ld, keyval=%ld dn=\"%s\"\n",
-                       c_id->eid_id, c_id->eid_keyval, row.cols[ 3 ] );
-#endif /* ! BACKSQL_ARBITRARY_KEY */
 
                /* count candidates, for unchecked limit */
                bsi->bsi_n_candidates--;
@@ -2246,16 +2237,11 @@ backsql_search( Operation *op, SlapReply *rs )
                        goto send_results;
                }
 
-#ifdef BACKSQL_ARBITRARY_KEY
                Debug(LDAP_DEBUG_TRACE, "backsql_search(): loading data "
-                       "for entry id=%s, oc_id=%ld, keyval=%s\n",
-                       eid->eid_id.bv_val, eid->eid_oc_id,
-                       eid->eid_keyval.bv_val );
-#else /* ! BACKSQL_ARBITRARY_KEY */
-               Debug(LDAP_DEBUG_TRACE, "backsql_search(): loading data "
-                       "for entry id=%ld, oc_id=%ld, keyval=%ld\n",
-                       eid->eid_id, eid->eid_oc_id, eid->eid_keyval );
-#endif /* ! BACKSQL_ARBITRARY_KEY */
+                       "for entry id=" BACKSQL_IDFMT " oc_id=" BACKSQL_IDNUMFMT ", keyval=" BACKSQL_IDFMT "\n",
+                       BACKSQL_IDARG(eid->eid_id),
+                       eid->eid_oc_id,
+                       BACKSQL_IDARG(eid->eid_keyval) );
 
                /* check scope */
                switch ( op->ors_scope ) {
@@ -2527,7 +2513,7 @@ send_results:;
 #ifdef BACKSQL_SYNCPROV
        if ( op->o_sync ) {
                Operation       op2 = *op;
-               SlapReply       rs2 = { 0 };
+               SlapReply       rs2 = { REP_RESULT };
                Entry           *e = entry_alloc();
                slap_callback   cb = { 0 };