From: Pierangelo Masarati Date: Sat, 7 Aug 2010 22:30:53 +0000 (+0000) Subject: improve ID logging when arbitrary key is set (almost blind fix; compiles in both... X-Git-Tag: MIGRATION_CVS2GIT~530 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=41fe685d357d3d81e82523d3f735a53931f370f0;p=openldap improve ID logging when arbitrary key is set (almost blind fix; compiles in both cases) --- diff --git a/servers/slapd/back-sql/add.c b/servers/slapd/back-sql/add.c index f4dda1e9ce..0bc7fb5d71 100644 --- a/servers/slapd/back-sql/add.c +++ b/servers/slapd/back-sql/add.c @@ -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\"): " diff --git a/servers/slapd/back-sql/back-sql.h b/servers/slapd/back-sql/back-sql.h index caee42f95a..4be0931c1b 100644 --- a/servers/slapd/back-sql/back-sql.h +++ b/servers/slapd/back-sql/back-sql.h @@ -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__ */ diff --git a/servers/slapd/back-sql/entry-id.c b/servers/slapd/back-sql/entry-id.c index 18e5c9309c..417a8a23a2 100644 --- a/servers/slapd/back-sql/entry-id.c +++ b/servers/slapd/back-sql/entry-id.c @@ -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 ); diff --git a/servers/slapd/back-sql/modify.c b/servers/slapd/back-sql/modify.c index 323c7c53f6..d1c40fb95f 100644 --- a/servers/slapd/back-sql/modify.c +++ b/servers/slapd/back-sql/modify.c @@ -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 ) ) diff --git a/servers/slapd/back-sql/modrdn.c b/servers/slapd/back-sql/modrdn.c index 22f8d4790c..79ee5f8820 100644 --- a/servers/slapd/back-sql/modrdn.c +++ b/servers/slapd/back-sql/modrdn.c @@ -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 ) ) { diff --git a/servers/slapd/back-sql/search.c b/servers/slapd/back-sql/search.c index 1531de5776..21adfed7ee 100644 --- a/servers/slapd/back-sql/search.c +++ b/servers/slapd/back-sql/search.c @@ -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 ) {