]> git.sur5r.net Git - openldap/commitdiff
improve ID logging when arbitrary key is set (almost blind fix; compiles in both...
authorPierangelo Masarati <ando@openldap.org>
Sat, 7 Aug 2010 22:30:53 +0000 (22:30 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sat, 7 Aug 2010 22:30:53 +0000 (22:30 +0000)
servers/slapd/back-sql/add.c
servers/slapd/back-sql/back-sql.h
servers/slapd/back-sql/entry-id.c
servers/slapd/back-sql/modify.c
servers/slapd/back-sql/modrdn.c
servers/slapd/back-sql/search.c

index f4dda1e9ce8f51b48af91b58edd1ca5116e5344a..0bc7fb5d716d7aeb80bd55331cf900cbf07dc691 100644 (file)
@@ -190,17 +190,12 @@ backsql_modify_delete_all_values(
                                rs->sr_err = LDAP_OTHER;
                                goto done;
                        }
-#ifdef BACKSQL_ARBITRARY_KEY
-                       Debug( LDAP_DEBUG_TRACE,
-                               "   backsql_modify_delete_all_values() "
-                               "arg(%d)=%s\n",
-                               pno + 1 + po, e_id->eid_keyval.bv_val, 0 );
-#else /* ! BACKSQL_ARBITRARY_KEY */
+
                        Debug( LDAP_DEBUG_TRACE,
                                "   backsql_modify_delete_all_values() "
-                               "arg(%d)=%lu\n",
-                               pno + 1 + po, e_id->eid_keyval, 0 );
-#endif /* ! BACKSQL_ARBITRARY_KEY */
+                               "arg(%d)=" BACKSQL_IDFMT "\n",
+                               pno + 1 + po,
+                               BACKSQL_IDARG(e_id->eid_keyval), 0 );
 
                        /*
                         * check for syntax needed here 
@@ -477,17 +472,12 @@ add_only:;
                                        rs->sr_err = LDAP_OTHER;
                                        goto done;
                                }
-#ifdef BACKSQL_ARBITRARY_KEY
-                               Debug( LDAP_DEBUG_TRACE,
-                                       "   backsql_modify_internal(): "
-                                       "arg(%d)=\"%s\"\n", 
-                                       pno + 1 + po, e_id->eid_keyval.bv_val, 0 );
-#else /* ! BACKSQL_ARBITRARY_KEY */
+
                                Debug( LDAP_DEBUG_TRACE,
                                        "   backsql_modify_internal(): "
-                                       "arg(%d)=\"%lu\"\n", 
-                                       pno + 1 + po, e_id->eid_keyval, 0 );
-#endif /* ! BACKSQL_ARBITRARY_KEY */
+                                       "arg(%d)=" BACKSQL_IDFMT "\n", 
+                                       pno + 1 + po,
+                                       BACKSQL_IDARG(e_id->eid_keyval), 0 );
 
                                /*
                                 * check for syntax needed here
@@ -640,17 +630,12 @@ add_only:;
                                        rs->sr_err = LDAP_OTHER;
                                        goto done;
                                }
-#ifdef BACKSQL_ARBITRARY_KEY
-                               Debug( LDAP_DEBUG_TRACE,
-                                       "   backsql_modify_internal(): "
-                                       "arg(%d)=\"%s\"\n", 
-                                       pno + 1 + po, e_id->eid_keyval.bv_val, 0 );
-#else /* ! BACKSQL_ARBITRARY_KEY */
+
                                Debug( LDAP_DEBUG_TRACE,
                                        "   backsql_modify_internal(): "
-                                       "arg(%d)=\"%lu\"\n", 
-                                       pno + 1 + po, e_id->eid_keyval, 0 );
-#endif /* ! BACKSQL_ARBITRARY_KEY */
+                                       "arg(%d)=" BACKSQL_IDFMT "\n", 
+                                       pno + 1 + po,
+                                       BACKSQL_IDARG(e_id->eid_keyval), 0 );
 
                                /*
                                 * check for syntax needed here 
@@ -1399,17 +1384,17 @@ backsql_add( Operation *op, SlapReply *rs )
                goto done;
        }
 
-       Debug( LDAP_DEBUG_TRACE, "   backsql_add(): executing \"%s\" for dn \"%s\"\n",
-                       bi->sql_insentry_stmt, op->ora_e->e_name.bv_val, 0 );
-#ifdef BACKSQL_ARBITRARY_KEY
-       Debug( LDAP_DEBUG_TRACE, "                  for oc_map_id=%ld, "
-                       "p_id=%s, keyval=%ld\n",
-                       oc->bom_id, bsi.bsi_base_id.eid_id.bv_val, new_keyval );
-#else /* ! BACKSQL_ARBITRARY_KEY */
-       Debug( LDAP_DEBUG_TRACE, "                  for oc_map_id=%ld, "
-                       "p_id=%ld, keyval=%ld\n",
-                       oc->bom_id, bsi.bsi_base_id.eid_id, new_keyval );
-#endif /* ! BACKSQL_ARBITRARY_KEY */
+       if ( LogTest( LDAP_DEBUG_TRACE ) ) {
+               char buf[ SLAP_TEXT_BUFLEN ];
+
+               snprintf( buf, sizeof(buf),
+                       "executing \"%s\" for dn=\"%s\"  oc_map_id=%ld p_id=" BACKSQL_IDFMT " keyval=%ld",
+                       bi->sql_insentry_stmt, op->ora_e->e_name.bv_val,
+                       oc->bom_id, BACKSQL_IDARG(bsi.bsi_base_id.eid_id),
+                       new_keyval );
+               Debug( LDAP_DEBUG_TRACE, "   backsql_add(): %s\n", buf, 0, 0 );
+       }
+
        rc = SQLExecute( sth );
        if ( rc != SQL_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, "   backsql_add(\"%s\"): "
index caee42f95ad0dba1247870ad1d623878029d2f8f..4be0931c1bebd9a279bf1416cc8dca45e2f5fdcd 100644 (file)
@@ -596,5 +596,13 @@ typedef struct backsql_info {
          || (ct) == SQL_VARBINARY \
          || (ct) == SQL_LONGVARBINARY)
 
+#ifdef BACKSQL_ARBITRARY_KEY
+#define BACKSQL_IDFMT "%s"
+#define BACKSQL_IDARG(arg) ((arg).bv_val)
+#else /* ! BACKSQL_ARBITRARY_KEY */
+#define BACKSQL_IDFMT "%lu"
+#define BACKSQL_IDARG(arg) (arg)
+#endif /* ! BACKSQL_ARBITRARY_KEY */
+
 #endif /* __BACKSQL_H__ */
 
index 18e5c9309c0457b87f61f4b3e159808ea027f44c..417a8a23a2a6b6362ad2fe54f12559b146bbdf51 100644 (file)
@@ -532,17 +532,10 @@ backsql_get_attr_vals( void *v_at, void *v_bsi )
        assert( at != NULL );
        assert( bsi != NULL );
 
-#ifdef BACKSQL_ARBITRARY_KEY
-       Debug( LDAP_DEBUG_TRACE, "==>backsql_get_attr_vals(): "
-               "oc=\"%s\" attr=\"%s\" keyval=%s\n",
-               BACKSQL_OC_NAME( bsi->bsi_oc ), at->bam_ad->ad_cname.bv_val, 
-               bsi->bsi_c_eid->eid_keyval.bv_val );
-#else /* ! BACKSQL_ARBITRARY_KEY */
        Debug( LDAP_DEBUG_TRACE, "==>backsql_get_attr_vals(): "
-               "oc=\"%s\" attr=\"%s\" keyval=%ld\n",
+               "oc=\"%s\" attr=\"%s\" keyval=" BACKSQL_IDFMT "\n",
                BACKSQL_OC_NAME( bsi->bsi_oc ), at->bam_ad->ad_cname.bv_val, 
-               bsi->bsi_c_eid->eid_keyval );
-#endif /* ! BACKSQL_ARBITRARY_KEY */
+               BACKSQL_IDARG(bsi->bsi_c_eid->eid_keyval) );
 
 #ifdef BACKSQL_PRETTY_VALIDATE
        validate = at->bam_true_ad->ad_type->sat_syntax->ssyn_validate;
@@ -694,15 +687,9 @@ backsql_get_attr_vals( void *v_at, void *v_bsi )
        }
 
 #ifdef BACKSQL_TRACE
-#ifdef BACKSQL_ARBITRARY_KEY
        Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_vals(): "
-               "query=\"%s\" keyval=%s\n", at->bam_query,
-               bsi->bsi_c_eid->eid_keyval.bv_val, 0 );
-#else /* !BACKSQL_ARBITRARY_KEY */
-       Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_vals(): "
-               "query=\"%s\" keyval=%d\n", at->bam_query,
-               bsi->bsi_c_eid->eid_keyval, 0 );
-#endif /* ! BACKSQL_ARBITRARY_KEY */
+               "query=\"%s\" keyval=" BACKSQL_IDFMT "\n", at->bam_query,
+               BACKSQL_IDARG(bsi->bsi_c_eid->eid_keyval), 0 );
 #endif /* BACKSQL_TRACE */
 
        rc = SQLExecute( sth );
index 323c7c53f62b77713d088746243811a81d98b6c7..d1c40fb95fbb40c402149cc68315f8cf10c9f77f 100644 (file)
@@ -102,16 +102,10 @@ backsql_modify( Operation *op, SlapReply *rs )
                goto done;
        }
 
-#ifdef BACKSQL_ARBITRARY_KEY
        Debug( LDAP_DEBUG_TRACE, "   backsql_modify(): "
-               "modifying entry \"%s\" (id=%s)\n", 
+               "modifying entry \"%s\" (id=" BACKSQL_IDFMT ")\n", 
                bsi.bsi_base_id.eid_dn.bv_val,
-               bsi.bsi_base_id.eid_id.bv_val, 0 );
-#else /* ! BACKSQL_ARBITRARY_KEY */
-       Debug( LDAP_DEBUG_TRACE, "   backsql_modify(): "
-               "modifying entry \"%s\" (id=%ld)\n", 
-               bsi.bsi_base_id.eid_dn.bv_val, bsi.bsi_base_id.eid_id, 0 );
-#endif /* ! BACKSQL_ARBITRARY_KEY */
+               BACKSQL_IDARG(bsi.bsi_base_id.eid_id), 0 );
 
        if ( get_assert( op ) &&
                        ( test_filter( op, &m, get_assertion( op ) )
index 22f8d4790cd9cfc97645b11c997f13ae0397cc7c..79ee5f8820c9d5716a81eb313a66f2a0c59555d5 100644 (file)
@@ -107,13 +107,9 @@ backsql_modrdn( Operation *op, SlapReply *rs )
                goto done;
        }
 
-#ifdef BACKSQL_ARBITRARY_KEY
-       Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): entry id=%s\n",
-               e_id.eid_id.bv_val, 0, 0 );
-#else /* ! BACKSQL_ARBITRARY_KEY */
-       Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): entry id=%ld\n",
-               e_id.eid_id, 0, 0 );
-#endif /* ! BACKSQL_ARBITRARY_KEY */
+       Debug( LDAP_DEBUG_TRACE,
+               "   backsql_modrdn(): entry id=" BACKSQL_IDFMT "\n",
+               BACKSQL_IDARG(e_id.eid_id), 0, 0 );
 
        if ( get_assert( op ) &&
                        ( test_filter( op, &r, get_assertion( op ) )
@@ -171,15 +167,9 @@ backsql_modrdn( Operation *op, SlapReply *rs )
                        slap_anlist_all_attributes,
                        BACKSQL_ISF_GET_ENTRY );
 
-#ifdef BACKSQL_ARBITRARY_KEY
-       Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): "
-               "old parent entry id is %s\n",
-               bsi.bsi_base_id.eid_id.bv_val, 0, 0 );
-#else /* ! BACKSQL_ARBITRARY_KEY */
-       Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): "
-               "old parent entry id is %ld\n",
-               bsi.bsi_base_id.eid_id, 0, 0 );
-#endif /* ! BACKSQL_ARBITRARY_KEY */
+       Debug( LDAP_DEBUG_TRACE,
+               "   backsql_modrdn(): old parent entry id is " BACKSQL_IDFMT "\n",
+               BACKSQL_IDARG(bsi.bsi_base_id.eid_id), 0, 0 );
 
        if ( rs->sr_err != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_modrdn(): "
@@ -234,15 +224,9 @@ backsql_modrdn( Operation *op, SlapReply *rs )
 
                n_id = bsi.bsi_base_id;
 
-#ifdef BACKSQL_ARBITRARY_KEY
-               Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): "
-                       "new parent entry id=%s\n",
-                       n_id.eid_id.bv_val, 0, 0 );
-#else /* ! BACKSQL_ARBITRARY_KEY */
-               Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): "
-                       "new parent entry id=%ld\n",
-                       n_id.eid_id, 0, 0 );
-#endif /* ! BACKSQL_ARBITRARY_KEY */
+               Debug( LDAP_DEBUG_TRACE,
+                       "   backsql_modrdn(): new parent entry id=" BACKSQL_IDFMT "\n",
+                       BACKSQL_IDARG(n_id.eid_id), 0, 0 );
 
                if ( !access_allowed( op, &n, slap_schema.si_ad_children, 
                                        NULL, ACL_WADD, NULL ) ) {
index 1531de57767d9fdbb416eed9c6b145e49e073bf6..21adfed7ee0a3f48316b219961cecd6584f8904b 100644 (file)
@@ -1883,13 +1883,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 ) {
@@ -1963,16 +1958,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 +2236,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=%ld, keyval=" BACKSQL_IDFMT "\n",
+                       BACKSQL_IDARG(eid->eid_id),
+                       eid->eid_oc_id,
+                       BACKSQL_IDARG(eid->eid_keyval) );
 
                /* check scope */
                switch ( op->ors_scope ) {