From fa8ee16d38e885d83118f70577d8362ed6c582ae Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Sat, 2 Oct 2004 12:05:42 +0000 Subject: [PATCH] cleanup naming; minor fixes --- servers/slapd/back-sql/add.c | 68 +++++----- servers/slapd/back-sql/api.c | 16 +-- servers/slapd/back-sql/back-sql.h | 110 +++++++++------- servers/slapd/back-sql/config.c | 98 +++++++-------- servers/slapd/back-sql/delete.c | 32 ++--- servers/slapd/back-sql/entry-id.c | 36 +++--- servers/slapd/back-sql/init.c | 186 ++++++++++++++-------------- servers/slapd/back-sql/modrdn.c | 22 ++-- servers/slapd/back-sql/schema-map.c | 71 +++++------ servers/slapd/back-sql/search.c | 30 ++--- servers/slapd/back-sql/sql-wrap.c | 62 +++++----- 11 files changed, 375 insertions(+), 356 deletions(-) diff --git a/servers/slapd/back-sql/add.c b/servers/slapd/back-sql/add.c index 4074f37bd9..8bb4c727e9 100644 --- a/servers/slapd/back-sql/add.c +++ b/servers/slapd/back-sql/add.c @@ -62,7 +62,7 @@ backsql_modify_delete_all_values( Debug( LDAP_DEBUG_TRACE, " backsql_modify_delete_all_values(): " "error preparing query\n", 0, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, asth, rc ); if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) { @@ -78,7 +78,7 @@ backsql_modify_delete_all_values( " backsql_modify_delete_all_values(): " "error binding key value parameter\n", 0, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, asth, rc ); SQLFreeStmt( asth, SQL_DROP ); @@ -96,7 +96,7 @@ backsql_modify_delete_all_values( " backsql_modify_delete_all_values(): " "error executing attribute query\n", 0, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, asth, rc ); SQLFreeStmt( asth, SQL_DROP ); @@ -129,7 +129,7 @@ backsql_modify_delete_all_values( " backsql_modify_delete_all_values(): " "error preparing query %s\n", at->bam_delete_proc, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) { @@ -149,7 +149,7 @@ backsql_modify_delete_all_values( " backsql_modify_delete_all_values(): " "error binding output parameter for %s[%d]\n", at->bam_ad->ad_cname.bv_val, i, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); @@ -172,7 +172,7 @@ backsql_modify_delete_all_values( " backsql_modify_delete_all_values(): " "error binding keyval parameter for %s[%d]\n", at->bam_ad->ad_cname.bv_val, i, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); @@ -207,7 +207,7 @@ backsql_modify_delete_all_values( " backsql_modify_delete_all_values(): " "error binding value parameter for %s[%d]\n", at->bam_ad->ad_cname.bv_val, i, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); @@ -231,7 +231,7 @@ backsql_modify_delete_all_values( "delete_proc " "execution failed\n", 0, 0, 0 ); - backsql_PrintErrors( bi->db_env, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) { @@ -414,7 +414,7 @@ add_only:; " backsql_modify_internal(): " "error preparing add query\n", 0, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, sth, rc ); + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); rs->sr_err = LDAP_OTHER; rs->sr_text = "SQL-backend error"; @@ -430,7 +430,7 @@ add_only:; " backsql_modify_internal(): " "error binding output parameter for %s[%d]\n", at->bam_ad->ad_cname.bv_val, i, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); @@ -450,7 +450,7 @@ add_only:; " backsql_modify_internal(): " "error binding keyval parameter for %s[%d]\n", at->bam_ad->ad_cname.bv_val, i, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); @@ -481,7 +481,7 @@ add_only:; " backsql_modify_internal(): " "error binding value parameter for %s[%d]\n", at->bam_ad->ad_cname.bv_val, i, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); @@ -501,7 +501,7 @@ add_only:; " backsql_modify_internal(): " "add_proc execution failed\n", 0, 0, 0 ); - backsql_PrintErrors( bi->db_env, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) { @@ -557,7 +557,7 @@ add_only:; " backsql_modify_internal(): " "error preparing delete query\n", 0, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, sth, rc ); + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); rs->sr_err = LDAP_OTHER; rs->sr_text = "SQL-backend error"; @@ -573,7 +573,7 @@ add_only:; " backsql_modify_internal(): " "error binding output parameter for %s[%d]\n", at->bam_ad->ad_cname.bv_val, i, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); @@ -593,7 +593,7 @@ add_only:; " backsql_modify_internal(): " "error binding keyval parameter for %s[%d]\n", at->bam_ad->ad_cname.bv_val, i, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); @@ -624,7 +624,7 @@ add_only:; " backsql_modify_internal(): " "error binding value parameter for %s[%d]\n", at->bam_ad->ad_cname.bv_val, i, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); @@ -645,7 +645,7 @@ add_only:; " backsql_modify_internal(): " "delete_proc execution " "failed\n", 0, 0, 0 ); - backsql_PrintErrors( bi->db_env, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) { @@ -777,7 +777,7 @@ backsql_add_attr( " backsql_add_attr(): " "error binding output parameter for %s[%d]\n", at_rec->bam_ad->ad_cname.bv_val, i, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); @@ -802,7 +802,7 @@ backsql_add_attr( " backsql_add_attr(): " "error binding keyval parameter for %s[%d]\n", at_rec->bam_ad->ad_cname.bv_val, i, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); @@ -827,7 +827,7 @@ backsql_add_attr( " backsql_add_attr(): " "error binding value parameter for %s[%d]\n", at_rec->bam_ad->ad_cname.bv_val, i, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); @@ -853,7 +853,7 @@ backsql_add_attr( " backsql_add_attr(\"%s\"): " "add_proc execution failed\n", op->oq_add.rs_e->e_name.bv_val, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, sth, rc ); + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) { SQLFreeStmt( sth, SQL_DROP ); @@ -1110,7 +1110,7 @@ backsql_add( Operation *op, SlapReply *rs ) " backsql_add_attr(): " "error binding keyval parameter for objectClass %s\n", oc->bom_oc->soc_cname.bv_val, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); @@ -1127,7 +1127,7 @@ backsql_add( Operation *op, SlapReply *rs ) Debug( LDAP_DEBUG_TRACE, " backsql_add(\"%s\"): " "create_proc execution failed\n", op->oq_add.rs_e->e_name.bv_val, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, sth, rc); + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc); SQLFreeStmt( sth, SQL_DROP ); rs->sr_err = LDAP_OTHER; rs->sr_text = "SQL-backend error"; @@ -1168,7 +1168,7 @@ backsql_add( Operation *op, SlapReply *rs ) Debug( LDAP_DEBUG_TRACE, " backsql_add(\"%s\"): " "create_proc result evaluation failed\n", op->oq_add.rs_e->e_name.bv_val, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, sth, rc); + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc); SQLFreeStmt( sth, SQL_DROP ); rs->sr_err = LDAP_OTHER; rs->sr_text = "SQL-backend error"; @@ -1178,7 +1178,7 @@ backsql_add( Operation *op, SlapReply *rs ) Debug( LDAP_DEBUG_TRACE, " backsql_add(\"%s\"): " "create_proc result is bogus (ncols=%d)\n", op->oq_add.rs_e->e_name.bv_val, ncols, 0 ); - backsql_PrintErrors( bi->db_env, dbh, sth, rc); + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc); SQLFreeStmt( sth, SQL_DROP ); rs->sr_err = LDAP_OTHER; rs->sr_text = "SQL-backend error"; @@ -1214,7 +1214,7 @@ backsql_add( Operation *op, SlapReply *rs ) Debug( LDAP_DEBUG_TRACE, " backsql_add(\"%s\"): " "create_proc result is empty?\n", op->oq_add.rs_e->e_name.bv_val, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, sth, rc); + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc); SQLFreeStmt( sth, SQL_DROP ); rs->sr_err = LDAP_OTHER; rs->sr_text = "SQL-backend error"; @@ -1255,7 +1255,7 @@ backsql_add( Operation *op, SlapReply *rs ) } } - rc = backsql_Prepare( dbh, &sth, bi->insentry_query, 0 ); + rc = backsql_Prepare( dbh, &sth, bi->sql_insentry_query, 0 ); if ( rc != SQL_SUCCESS ) { rs->sr_err = LDAP_OTHER; rs->sr_text = "SQL-backend error"; @@ -1268,7 +1268,7 @@ backsql_add( Operation *op, SlapReply *rs ) " backsql_add_attr(): " "error binding DN parameter for objectClass %s\n", oc->bom_oc->soc_cname.bv_val, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); @@ -1283,7 +1283,7 @@ backsql_add( Operation *op, SlapReply *rs ) " backsql_add_attr(): " "error binding objectClass ID parameter for objectClass %s\n", oc->bom_oc->soc_cname.bv_val, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); @@ -1298,7 +1298,7 @@ backsql_add( Operation *op, SlapReply *rs ) " backsql_add_attr(): " "error binding parent ID parameter for objectClass %s\n", oc->bom_oc->soc_cname.bv_val, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); @@ -1313,7 +1313,7 @@ backsql_add( Operation *op, SlapReply *rs ) " backsql_add_attr(): " "error binding entry ID parameter for objectClass %s\n", oc->bom_oc->soc_cname.bv_val, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); @@ -1323,7 +1323,7 @@ backsql_add( Operation *op, SlapReply *rs ) } Debug( LDAP_DEBUG_TRACE, " backsql_add(): executing \"%s\" for dn \"%s\"\n", - bi->insentry_query, op->oq_add.rs_e->e_name.bv_val, 0 ); + bi->sql_insentry_query, op->oq_add.rs_e->e_name.bv_val, 0 ); #ifdef BACKSQL_ARBITRARY_KEY Debug( LDAP_DEBUG_TRACE, " for oc_map_id=%ld, " "parent_id=%s, keyval=%ld\n", @@ -1338,7 +1338,7 @@ backsql_add( Operation *op, SlapReply *rs ) Debug( LDAP_DEBUG_TRACE, " backsql_add(\"%s\"): " "could not insert ldap_entries record\n", op->oq_add.rs_e->e_name.bv_val, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, sth, rc ); + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); /* * execute delete_proc to delete data added !!! diff --git a/servers/slapd/back-sql/api.c b/servers/slapd/back-sql/api.c index 715e22b63b..3119ceb950 100644 --- a/servers/slapd/back-sql/api.c +++ b/servers/slapd/back-sql/api.c @@ -31,11 +31,11 @@ static backsql_api *backsqlapi; int -backsql_api_config( backsql_info *si, const char *name ) +backsql_api_config( backsql_info *bi, const char *name ) { backsql_api *ba; - assert( si ); + assert( bi ); assert( name ); for ( ba = backsqlapi; ba; ba = ba->ba_next ) { @@ -44,8 +44,8 @@ backsql_api_config( backsql_info *si, const char *name ) ba2 = ch_malloc( sizeof( backsql_api ) ); *ba2 = *ba; - ba2->ba_next = si->si_api; - si->si_api = ba2; + ba2->ba_next = bi->sql_api; + bi->sql_api = ba2; return 0; } } @@ -81,12 +81,12 @@ backsql_api_register( backsql_api *ba ) int backsql_api_dn2odbc( Operation *op, SlapReply *rs, struct berval *dn ) { - backsql_info *si = (backsql_info *)op->o_bd->be_private; + backsql_info *bi = (backsql_info *)op->o_bd->be_private; backsql_api *ba; int rc; struct berval bv; - ba = si->si_api; + ba = bi->sql_api; if ( ba == NULL ) { return 0; @@ -112,12 +112,12 @@ backsql_api_dn2odbc( Operation *op, SlapReply *rs, struct berval *dn ) int backsql_api_odbc2dn( Operation *op, SlapReply *rs, struct berval *dn ) { - backsql_info *si = (backsql_info *)op->o_bd->be_private; + backsql_info *bi = (backsql_info *)op->o_bd->be_private; backsql_api *ba; int rc; struct berval bv; - ba = si->si_api; + ba = bi->sql_api; if ( ba == NULL ) { return 0; diff --git a/servers/slapd/back-sql/back-sql.h b/servers/slapd/back-sql/back-sql.h index db901cbbb5..4e3803c9e4 100644 --- a/servers/slapd/back-sql/back-sql.h +++ b/servers/slapd/back-sql/back-sql.h @@ -77,13 +77,10 @@ #include "external.h" #include "sql-types.h" -/* - * PostgreSQL 7.0 doesn't work without :( - */ -#define BACKSQL_REALLOC_STMT - /* * Better use the standard length of 8192 (as of slap.h)? + * + * NOTE: must be consistent with definition in ldap_entries table */ /* #define BACKSQL_MAX_DN_LEN SLAP_LDAPDN_MAXLEN */ #define BACKSQL_MAX_DN_LEN 255 @@ -96,23 +93,37 @@ /* * define to enable varchars as unique keys in user tables + * + * by default integers are used (and recommended) + * for performances. Integers are used anyway in back-sql + * related tables. */ #undef BACKSQL_ARBITRARY_KEY /* * define to the appropriate aliasing string + * + * some RDBMSes tolerate (or require) that " AS " is not used + * when aliasing tables/columns */ #define BACKSQL_ALIASING "AS " /* #define BACKSQL_ALIASING "" */ /* * define to the appropriate quoting char + * + * some RDBMSes tolerate/require that the aliases be enclosed + * in quotes. This is especially true for those that do not + * allow keywords used as aliases. */ /* #define BACKSQL_ALIASING_QUOTE '"' */ /* #define BACKSQL_ALIASING_QUOTE '\'' */ /* * API + * + * a simple mechanism to allow DN mucking between the LDAP + * and the stored string representation. */ typedef struct backsql_api { char *ba_name; @@ -286,35 +297,39 @@ typedef struct backsql_srch_info { * Backend private data structure */ typedef struct { - char *dbhost; - int dbport; - char *dbuser; - char *dbpasswd; - char *dbname; + char *sql_dbhost; + int sql_dbport; + char *sql_dbuser; + char *sql_dbpasswd; + char *sql_dbname; + /* * SQL condition for subtree searches differs in syntax: * "LIKE CONCAT('%',?)" or "LIKE '%'+?" or "LIKE '%'||?" - * or smth else + * or smtg else */ - struct berval subtree_cond; - struct berval children_cond; - char *oc_query, *at_query; - char *insentry_query, - *delentry_query, - *delobjclasses_query, - *delreferrals_query; - char *id_query; - char *has_children_query; - - MatchingRule *bi_caseIgnoreMatch; - MatchingRule *bi_telephoneNumberMatch; - - struct berval upper_func; - struct berval upper_func_open; - struct berval upper_func_close; - BerVarray concat_func; - - unsigned int bsql_flags; + struct berval sql_subtree_cond; + struct berval sql_children_cond; + char *sql_oc_query, + *sql_at_query; + char *sql_insentry_query, + *sql_delentry_query, + *sql_delobjclasses_query, + *sql_delreferrals_query; + char *sql_id_query; + char *sql_has_children_query; + + MatchingRule *sql_caseIgnoreMatch; + MatchingRule *sql_telephoneNumberMatch; + + struct berval sql_upper_func; + struct berval sql_upper_func_open; + struct berval sql_upper_func_close; + BerVarray sql_concat_func; + + struct berval sql_strcast_func; + + unsigned int sql_flags; #define BSQLF_SCHEMA_LOADED 0x0001 #define BSQLF_UPPER_NEEDS_CAST 0x0002 #define BSQLF_CREATE_NEEDS_SELECT 0x0004 @@ -325,33 +340,32 @@ typedef struct { #define BSQLF_ALLOW_ORPHANS 0x0080 #define BACKSQL_SCHEMA_LOADED(si) \ - ((si)->bsql_flags & BSQLF_SCHEMA_LOADED) + ((si)->sql_flags & BSQLF_SCHEMA_LOADED) #define BACKSQL_UPPER_NEEDS_CAST(si) \ - ((si)->bsql_flags & BSQLF_UPPER_NEEDS_CAST) + ((si)->sql_flags & BSQLF_UPPER_NEEDS_CAST) #define BACKSQL_CREATE_NEEDS_SELECT(si) \ - ((si)->bsql_flags & BSQLF_CREATE_NEEDS_SELECT) + ((si)->sql_flags & BSQLF_CREATE_NEEDS_SELECT) #define BACKSQL_FAIL_IF_NO_MAPPING(si) \ - ((si)->bsql_flags & BSQLF_FAIL_IF_NO_MAPPING) + ((si)->sql_flags & BSQLF_FAIL_IF_NO_MAPPING) #define BACKSQL_HAS_LDAPINFO_DN_RU(si) \ - ((si)->bsql_flags & BSQLF_HAS_LDAPINFO_DN_RU) + ((si)->sql_flags & BSQLF_HAS_LDAPINFO_DN_RU) #define BACKSQL_DONTCHECK_LDAPINFO_DN_RU(si) \ - ((si)->bsql_flags & BSQLF_DONTCHECK_LDAPINFO_DN_RU) + ((si)->sql_flags & BSQLF_DONTCHECK_LDAPINFO_DN_RU) #define BACKSQL_USE_REVERSE_DN(si) \ - ((si)->bsql_flags & BSQLF_USE_REVERSE_DN) + ((si)->sql_flags & BSQLF_USE_REVERSE_DN) #define BACKSQL_CANUPPERCASE(si) \ - ((si)->upper_func.bv_val) + (!BER_BVISNULL( &(si)->sql_upper_func )) #define BACKSQL_ALLOW_ORPHANS(si) \ - ((si)->bsql_flags & BSQLF_ALLOW_ORPHANS) + ((si)->sql_flags & BSQLF_ALLOW_ORPHANS) - struct berval strcast_func; - Avlnode *db_conns; - Avlnode *oc_by_oc; - Avlnode *oc_by_id; - ldap_pvt_thread_mutex_t dbconn_mutex; - ldap_pvt_thread_mutex_t schema_mutex; - SQLHENV db_env; - - backsql_api *si_api; + Avlnode *sql_db_conns; + Avlnode *sql_oc_by_oc; + Avlnode *sql_oc_by_id; + ldap_pvt_thread_mutex_t sql_dbconn_mutex; + ldap_pvt_thread_mutex_t sql_schema_mutex; + SQLHENV sql_db_env; + + backsql_api *sql_api; } backsql_info; #define BACKSQL_SUCCESS( rc ) \ diff --git a/servers/slapd/back-sql/config.c b/servers/slapd/back-sql/config.c index fe62525cf6..6fe8a91207 100644 --- a/servers/slapd/back-sql/config.c +++ b/servers/slapd/back-sql/config.c @@ -37,10 +37,10 @@ backsql_db_config( int argc, char **argv ) { - backsql_info *si = (backsql_info *)be->be_private; + backsql_info *bi = (backsql_info *)be->be_private; Debug( LDAP_DEBUG_TRACE, "==>backsql_db_config()\n", 0, 0, 0 ); - assert( si ); + assert( bi ); if ( !strcasecmp( argv[ 0 ], "dbhost" ) ) { if ( argc < 2 ) { @@ -50,10 +50,10 @@ backsql_db_config( fname, lineno, 0 ); return 1; } - si->dbhost = ch_strdup( argv[ 1 ] ); + bi->sql_dbhost = ch_strdup( argv[ 1 ] ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): hostname=%s\n", - si->dbhost, 0, 0 ); + bi->sql_dbhost, 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "dbuser" ) ) { if ( argc < 2 ) { @@ -63,9 +63,9 @@ backsql_db_config( fname, lineno, 0 ); return 1; } - si->dbuser = ch_strdup( argv[ 1 ] ); + bi->sql_dbuser = ch_strdup( argv[ 1 ] ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): dbuser=%s\n", - si->dbuser, 0, 0 ); + bi->sql_dbuser, 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "dbpasswd" ) ) { if ( argc < 2 ) { @@ -75,9 +75,9 @@ backsql_db_config( fname, lineno, 0 ); return 1; } - si->dbpasswd = ch_strdup( argv[ 1 ] ); + bi->sql_dbpasswd = ch_strdup( argv[ 1 ] ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " - "dbpasswd=%s\n", /* si->dbpasswd */ "xxxx", 0, 0 ); + "dbpasswd=%s\n", /* bi->sql_dbpasswd */ "xxxx", 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "dbname" ) ) { if ( argc < 2 ) { @@ -87,9 +87,9 @@ backsql_db_config( "directive\n", fname, lineno, 0 ); return 1; } - si->dbname = ch_strdup( argv[ 1 ] ); + bi->sql_dbname = ch_strdup( argv[ 1 ] ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): dbname=%s\n", - si->dbname, 0, 0 ); + bi->sql_dbname, 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "concat_pattern" ) ) { if ( argc < 2 ) { @@ -100,7 +100,7 @@ backsql_db_config( fname, lineno, 0 ); return 1; } - if ( backsql_split_pattern( argv[ 1 ], &si->concat_func, 2 ) ) { + if ( backsql_split_pattern( argv[ 1 ], &bi->sql_concat_func, 2 ) ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "unable to parse pattern \"%s\"\n" @@ -120,9 +120,9 @@ backsql_db_config( fname, lineno, 0 ); return 1; } - ber_str2bv( argv[ 1 ], 0, 1, &si->subtree_cond ); + ber_str2bv( argv[ 1 ], 0, 1, &bi->sql_subtree_cond ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " - "subtree_cond=%s\n", si->subtree_cond.bv_val, 0, 0 ); + "subtree_cond=%s\n", bi->sql_subtree_cond.bv_val, 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "children_cond" ) ) { if ( argc < 2 ) { @@ -133,9 +133,9 @@ backsql_db_config( fname, lineno, 0 ); return 1; } - ber_str2bv( argv[ 1 ], 0, 1, &si->children_cond ); + ber_str2bv( argv[ 1 ], 0, 1, &bi->sql_children_cond ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " - "subtree_cond=%s\n", si->children_cond.bv_val, 0, 0 ); + "subtree_cond=%s\n", bi->sql_children_cond.bv_val, 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "oc_query" ) ) { if ( argc < 2 ) { @@ -146,9 +146,9 @@ backsql_db_config( fname, lineno, 0 ); return 1; } - si->oc_query = ch_strdup( argv[ 1 ] ); + bi->sql_oc_query = ch_strdup( argv[ 1 ] ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " - "oc_query=%s\n", si->oc_query, 0, 0 ); + "oc_query=%s\n", bi->sql_oc_query, 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "at_query" ) ) { if ( argc < 2 ) { @@ -159,9 +159,9 @@ backsql_db_config( fname, lineno, 0 ); return 1; } - si->at_query = ch_strdup( argv[ 1 ] ); + bi->sql_at_query = ch_strdup( argv[ 1 ] ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " - "at_query=%s\n", si->at_query, 0, 0 ); + "at_query=%s\n", bi->sql_at_query, 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "insentry_query" ) ) { if ( argc < 2 ) { @@ -172,9 +172,9 @@ backsql_db_config( fname, lineno, 0 ); return 1; } - si->insentry_query = ch_strdup( argv[ 1 ] ); + bi->sql_insentry_query = ch_strdup( argv[ 1 ] ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " - "insentry_query=%s\n", si->insentry_query, 0, 0 ); + "insentry_query=%s\n", bi->sql_insentry_query, 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "create_needs_select" ) ) { if ( argc < 2 ) { @@ -187,10 +187,10 @@ backsql_db_config( } if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) { - si->bsql_flags |= BSQLF_CREATE_NEEDS_SELECT; + bi->sql_flags |= BSQLF_CREATE_NEEDS_SELECT; } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) { - si->bsql_flags &= ~BSQLF_CREATE_NEEDS_SELECT; + bi->sql_flags &= ~BSQLF_CREATE_NEEDS_SELECT; } else { Debug( LDAP_DEBUG_TRACE, @@ -203,7 +203,7 @@ backsql_db_config( } Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " "create_needs_select =%s\n", - BACKSQL_CREATE_NEEDS_SELECT( si ) ? "yes" : "no", + BACKSQL_CREATE_NEEDS_SELECT( bi ) ? "yes" : "no", 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "upper_func" ) ) { @@ -215,9 +215,9 @@ backsql_db_config( fname, lineno, 0 ); return 1; } - ber_str2bv( argv[ 1 ], 0, 1, &si->upper_func ); + ber_str2bv( argv[ 1 ], 0, 1, &bi->sql_upper_func ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " - "upper_func=%s\n", si->upper_func.bv_val, 0, 0 ); + "upper_func=%s\n", bi->sql_upper_func.bv_val, 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "upper_needs_cast" ) ) { if ( argc < 2 ) { @@ -230,10 +230,10 @@ backsql_db_config( } if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) { - si->bsql_flags |= BSQLF_UPPER_NEEDS_CAST; + bi->sql_flags |= BSQLF_UPPER_NEEDS_CAST; } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) { - si->bsql_flags &= ~BSQLF_UPPER_NEEDS_CAST; + bi->sql_flags &= ~BSQLF_UPPER_NEEDS_CAST; } else { Debug( LDAP_DEBUG_TRACE, @@ -246,7 +246,7 @@ backsql_db_config( } Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " "upper_needs_cast =%s\n", - BACKSQL_UPPER_NEEDS_CAST( si ) ? "yes" : "no", 0, 0 ); + BACKSQL_UPPER_NEEDS_CAST( bi ) ? "yes" : "no", 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "strcast_func" ) ) { if ( argc < 2 ) { @@ -257,9 +257,9 @@ backsql_db_config( fname, lineno, 0 ); return 1; } - ber_str2bv( argv[ 1 ], 0, 1, &si->strcast_func ); + ber_str2bv( argv[ 1 ], 0, 1, &bi->sql_strcast_func ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " - "strcast_func=%s\n", si->strcast_func.bv_val, 0, 0 ); + "strcast_func=%s\n", bi->sql_strcast_func.bv_val, 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "delentry_query" ) ) { if ( argc < 2 ) { @@ -270,9 +270,9 @@ backsql_db_config( fname, lineno, 0 ); return 1; } - si->delentry_query = ch_strdup( argv[ 1 ] ); + bi->sql_delentry_query = ch_strdup( argv[ 1 ] ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " - "delentry_query=%s\n", si->delentry_query, 0, 0 ); + "delentry_query=%s\n", bi->sql_delentry_query, 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "delobjclasses_query" ) ) { if ( argc < 2 ) { @@ -283,9 +283,9 @@ backsql_db_config( fname, lineno, 0 ); return 1; } - si->delobjclasses_query = ch_strdup( argv[ 1 ] ); + bi->sql_delobjclasses_query = ch_strdup( argv[ 1 ] ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " - "delobjclasses_query=%s\n", si->delobjclasses_query, 0, 0 ); + "delobjclasses_query=%s\n", bi->sql_delobjclasses_query, 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "delreferrals_query" ) ) { if ( argc < 2 ) { @@ -296,9 +296,9 @@ backsql_db_config( fname, lineno, 0 ); return 1; } - si->delreferrals_query = ch_strdup( argv[ 1 ] ); + bi->sql_delreferrals_query = ch_strdup( argv[ 1 ] ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " - "delreferrals_query=%s\n", si->delreferrals_query, 0, 0 ); + "delreferrals_query=%s\n", bi->sql_delreferrals_query, 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "has_ldapinfo_dn_ru") ) { if ( argc < 2 ) { @@ -311,12 +311,12 @@ backsql_db_config( } if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) { - si->bsql_flags |= BSQLF_HAS_LDAPINFO_DN_RU; - si->bsql_flags |= BSQLF_DONTCHECK_LDAPINFO_DN_RU; + bi->sql_flags |= BSQLF_HAS_LDAPINFO_DN_RU; + bi->sql_flags |= BSQLF_DONTCHECK_LDAPINFO_DN_RU; } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) { - si->bsql_flags &= ~BSQLF_HAS_LDAPINFO_DN_RU; - si->bsql_flags |= BSQLF_DONTCHECK_LDAPINFO_DN_RU; + bi->sql_flags &= ~BSQLF_HAS_LDAPINFO_DN_RU; + bi->sql_flags |= BSQLF_DONTCHECK_LDAPINFO_DN_RU; } else { Debug( LDAP_DEBUG_TRACE, @@ -329,7 +329,7 @@ backsql_db_config( } Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " "has_ldapinfo_dn_ru=%s\n", - BACKSQL_HAS_LDAPINFO_DN_RU( si ) ? "yes" : "no", 0, 0 ); + BACKSQL_HAS_LDAPINFO_DN_RU( bi ) ? "yes" : "no", 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "fail_if_no_mapping") ) { if ( argc < 2 ) { @@ -342,10 +342,10 @@ backsql_db_config( } if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) { - si->bsql_flags |= BSQLF_FAIL_IF_NO_MAPPING; + bi->sql_flags |= BSQLF_FAIL_IF_NO_MAPPING; } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) { - si->bsql_flags &= ~BSQLF_FAIL_IF_NO_MAPPING; + bi->sql_flags &= ~BSQLF_FAIL_IF_NO_MAPPING; } else { Debug( LDAP_DEBUG_TRACE, @@ -358,7 +358,7 @@ backsql_db_config( } Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " "fail_if_no_mapping=%s\n", - BACKSQL_FAIL_IF_NO_MAPPING( si ) ? "yes" : "no", 0, 0 ); + BACKSQL_FAIL_IF_NO_MAPPING( bi ) ? "yes" : "no", 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "allow_orphans") ) { if ( argc < 2 ) { @@ -371,10 +371,10 @@ backsql_db_config( } if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) { - si->bsql_flags |= BSQLF_ALLOW_ORPHANS; + bi->sql_flags |= BSQLF_ALLOW_ORPHANS; } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) { - si->bsql_flags &= ~BSQLF_ALLOW_ORPHANS; + bi->sql_flags &= ~BSQLF_ALLOW_ORPHANS; } else { Debug( LDAP_DEBUG_TRACE, @@ -387,10 +387,10 @@ backsql_db_config( } Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " "allow_orphans=%s\n", - BACKSQL_ALLOW_ORPHANS( si ) ? "yes" : "no", 0, 0 ); + BACKSQL_ALLOW_ORPHANS( bi ) ? "yes" : "no", 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "sqllayer") ) { - if ( backsql_api_config( si, argv[ 1 ] ) ) { + if ( backsql_api_config( bi, argv[ 1 ] ) ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "unable to load sqllayer \"%s\"\n", diff --git a/servers/slapd/back-sql/delete.c b/servers/slapd/back-sql/delete.c index f0f5b58b5f..5cf9b6456e 100644 --- a/servers/slapd/back-sql/delete.c +++ b/servers/slapd/back-sql/delete.c @@ -175,7 +175,7 @@ backsql_delete( Operation *op, SlapReply *rs ) " backsql_delete(): " "error preparing delete query\n", 0, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, sth, rc ); + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); rs->sr_err = LDAP_OTHER; rs->sr_text = "SQL-backend error"; @@ -190,7 +190,7 @@ backsql_delete( Operation *op, SlapReply *rs ) " backsql_delete(): " "error binding output parameter for objectClass %s\n", oc->bom_oc->soc_cname.bv_val, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); @@ -209,7 +209,7 @@ backsql_delete( Operation *op, SlapReply *rs ) " backsql_delete(): " "error binding keyval parameter for objectClass %s\n", oc->bom_oc->soc_cname.bv_val, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); @@ -222,7 +222,7 @@ backsql_delete( Operation *op, SlapReply *rs ) if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, " backsql_delete(): " "delete_proc execution failed\n", 0, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, sth, rc ); + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); rs->sr_err = LDAP_OTHER; rs->sr_text = "SQL-backend error"; @@ -231,13 +231,13 @@ backsql_delete( Operation *op, SlapReply *rs ) SQLFreeStmt( sth, SQL_DROP ); /* delete "auxiliary" objectClasses, if any... */ - rc = backsql_Prepare( dbh, &sth, bi->delobjclasses_query, 0 ); + rc = backsql_Prepare( dbh, &sth, bi->sql_delobjclasses_query, 0 ); if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, " backsql_delete(): " "error preparing ldap_entry_objclasses delete query\n", 0, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, sth, rc ); + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); rs->sr_err = LDAP_OTHER; rs->sr_text = "SQL-backend error"; @@ -251,7 +251,7 @@ backsql_delete( Operation *op, SlapReply *rs ) "error binding auxiliary objectClasses " "entry ID parameter for objectClass %s\n", oc->bom_oc->soc_cname.bv_val, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); @@ -272,7 +272,7 @@ backsql_delete( Operation *op, SlapReply *rs ) Debug( LDAP_DEBUG_TRACE, " backsql_delete(): " "failed to delete record from ldap_entry_objclasses\n", 0, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, sth, rc ); + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); rs->sr_err = LDAP_OTHER; rs->sr_text = "SQL-backend error"; @@ -281,13 +281,13 @@ backsql_delete( Operation *op, SlapReply *rs ) SQLFreeStmt( sth, SQL_DROP ); /* delete referrals, if any... */ - rc = backsql_Prepare( dbh, &sth, bi->delreferrals_query, 0 ); + rc = backsql_Prepare( dbh, &sth, bi->sql_delreferrals_query, 0 ); if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, " backsql_delete(): " "error preparing ldap_referrals delete query\n", 0, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, sth, rc ); + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); rs->sr_err = LDAP_OTHER; rs->sr_text = "SQL-backend error"; @@ -301,7 +301,7 @@ backsql_delete( Operation *op, SlapReply *rs ) "error binding referrals entry ID parameter " "for objectClass %s\n", oc->bom_oc->soc_cname.bv_val, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); @@ -322,7 +322,7 @@ backsql_delete( Operation *op, SlapReply *rs ) Debug( LDAP_DEBUG_TRACE, " backsql_delete(): " "failed to delete record from ldap_referrals\n", 0, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, sth, rc ); + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); rs->sr_err = LDAP_OTHER; rs->sr_text = "SQL-backend error"; @@ -331,13 +331,13 @@ backsql_delete( Operation *op, SlapReply *rs ) SQLFreeStmt( sth, SQL_DROP ); /* delete entry... */ - rc = backsql_Prepare( dbh, &sth, bi->delentry_query, 0 ); + rc = backsql_Prepare( dbh, &sth, bi->sql_delentry_query, 0 ); if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, " backsql_delete(): " "error preparing ldap_entries delete query\n", 0, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, sth, rc ); + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); rs->sr_err = LDAP_OTHER; rs->sr_text = "SQL-backend error"; @@ -351,7 +351,7 @@ backsql_delete( Operation *op, SlapReply *rs ) "error binding entry ID parameter " "for objectClass %s\n", oc->bom_oc->soc_cname.bv_val, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); @@ -365,7 +365,7 @@ backsql_delete( Operation *op, SlapReply *rs ) Debug( LDAP_DEBUG_TRACE, " backsql_delete(): " "failed to delete record from ldap_entries\n", 0, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, sth, rc ); + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); rs->sr_err = LDAP_OTHER; rs->sr_text = "SQL-backend error"; diff --git a/servers/slapd/back-sql/entry-id.c b/servers/slapd/back-sql/entry-id.c index b53384a9aa..35108c34cb 100644 --- a/servers/slapd/back-sql/entry-id.c +++ b/servers/slapd/back-sql/entry-id.c @@ -95,14 +95,14 @@ backsql_dn2id( } /* begin TimesTen */ - Debug(LDAP_DEBUG_TRACE, "id_query \"%s\"\n", bi->id_query, 0, 0); - assert( bi->id_query ); - rc = backsql_Prepare( dbh, &sth, bi->id_query, 0 ); + Debug(LDAP_DEBUG_TRACE, "id_query \"%s\"\n", bi->sql_id_query, 0, 0); + assert( bi->sql_id_query ); + rc = backsql_Prepare( dbh, &sth, bi->sql_id_query, 0 ); if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "backsql_dn2id(): error preparing SQL:\n%s", - bi->id_query, 0, 0); - backsql_PrintErrors( SQL_NULL_HENV, dbh, sth, rc ); + bi->sql_id_query, 0, 0); + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); return LDAP_OTHER; } @@ -143,7 +143,7 @@ backsql_dn2id( Debug( LDAP_DEBUG_TRACE, "backsql_dn2id(): " "error binding dn=\"%s\" parameter:\n", toBind.bv_val, 0, 0 ); - backsql_PrintErrors( SQL_NULL_HENV, dbh, sth, rc ); + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); return LDAP_OTHER; } @@ -152,8 +152,8 @@ backsql_dn2id( if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "backsql_dn2id(): " "error executing query (\"%s\", \"%s\"):\n", - bi->id_query, toBind.bv_val, 0 ); - backsql_PrintErrors( SQL_NULL_HENV, dbh, sth, rc ); + bi->sql_id_query, toBind.bv_val, 0 ); + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); return LDAP_OTHER; } @@ -215,14 +215,14 @@ backsql_count_children( /* begin TimesTen */ Debug(LDAP_DEBUG_TRACE, "children id query \"%s\"\n", - bi->has_children_query, 0, 0); - assert( bi->has_children_query ); - rc = backsql_Prepare( dbh, &sth, bi->has_children_query, 0 ); + bi->sql_has_children_query, 0, 0); + assert( bi->sql_has_children_query ); + rc = backsql_Prepare( dbh, &sth, bi->sql_has_children_query, 0 ); if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "backsql_count_children(): error preparing SQL:\n%s", - bi->has_children_query, 0, 0); - backsql_PrintErrors( SQL_NULL_HENV, dbh, sth, rc ); + bi->sql_has_children_query, 0, 0); + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); return LDAP_OTHER; } @@ -233,7 +233,7 @@ backsql_count_children( Debug( LDAP_DEBUG_TRACE, "backsql_count_children(): " "error binding dn=\"%s\" parameter:\n", dn->bv_val, 0, 0 ); - backsql_PrintErrors( SQL_NULL_HENV, dbh, sth, rc ); + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); return LDAP_OTHER; } @@ -242,8 +242,8 @@ backsql_count_children( if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "backsql_count_children(): " "error executing query (\"%s\", \"%s\"):\n", - bi->has_children_query, dn->bv_val, 0 ); - backsql_PrintErrors( SQL_NULL_HENV, dbh, sth, rc ); + bi->sql_has_children_query, dn->bv_val, 0 ); + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); return LDAP_OTHER; } @@ -323,7 +323,7 @@ backsql_get_attr_vals( void *v_at, void *v_bsi ) if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_values(): " "error preparing query: %s\n", at->bam_query, 0, 0 ); - backsql_PrintErrors( bi->db_env, bsi->bsi_dbh, sth, rc ); + backsql_PrintErrors( bi->sql_db_env, bsi->bsi_dbh, sth, rc ); return 1; } @@ -352,7 +352,7 @@ backsql_get_attr_vals( void *v_at, void *v_bsi ) Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_values(): " "error executing attribute query \"%s\"\n", at->bam_query, 0, 0 ); - backsql_PrintErrors( bi->db_env, bsi->bsi_dbh, sth, rc ); + backsql_PrintErrors( bi->sql_db_env, bsi->bsi_dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); return 1; } diff --git a/servers/slapd/back-sql/init.c b/servers/slapd/back-sql/init.c index 24d6d201f6..45669f7236 100644 --- a/servers/slapd/back-sql/init.c +++ b/servers/slapd/back-sql/init.c @@ -113,16 +113,16 @@ int backsql_db_init( BackendDB *bd ) { - backsql_info *si; + backsql_info *bi; Debug( LDAP_DEBUG_TRACE, "==>backsql_db_init()\n", 0, 0, 0 ); - si = (backsql_info *)ch_calloc( 1, sizeof( backsql_info ) ); - memset( si, '\0', sizeof( backsql_info ) ); - ldap_pvt_thread_mutex_init( &si->dbconn_mutex ); - ldap_pvt_thread_mutex_init( &si->schema_mutex ); - backsql_init_db_env( si ); + bi = (backsql_info *)ch_calloc( 1, sizeof( backsql_info ) ); + memset( bi, '\0', sizeof( backsql_info ) ); + ldap_pvt_thread_mutex_init( &bi->sql_dbconn_mutex ); + ldap_pvt_thread_mutex_init( &bi->sql_schema_mutex ); + backsql_init_db_env( bi ); - bd->be_private = si; + bd->be_private = bi; Debug( LDAP_DEBUG_TRACE, "<==backsql_db_init()\n", 0, 0, 0 ); return 0; } @@ -131,39 +131,39 @@ int backsql_db_destroy( BackendDB *bd ) { - backsql_info *si = (backsql_info*)bd->be_private; + backsql_info *bi = (backsql_info*)bd->be_private; Debug( LDAP_DEBUG_TRACE, "==>backsql_db_destroy()\n", 0, 0, 0 ); - ldap_pvt_thread_mutex_lock( &si->dbconn_mutex ); - backsql_free_db_env( si ); - ldap_pvt_thread_mutex_unlock( &si->dbconn_mutex ); - ldap_pvt_thread_mutex_destroy( &si->dbconn_mutex ); - ldap_pvt_thread_mutex_lock( &si->schema_mutex ); - backsql_destroy_schema_map( si ); - ldap_pvt_thread_mutex_unlock( &si->schema_mutex ); - ldap_pvt_thread_mutex_destroy( &si->schema_mutex ); - free( si->dbname ); - free( si->dbuser ); - if ( si->dbpasswd ) { - free( si->dbpasswd ); + ldap_pvt_thread_mutex_lock( &bi->sql_dbconn_mutex ); + backsql_free_db_env( bi ); + ldap_pvt_thread_mutex_unlock( &bi->sql_dbconn_mutex ); + ldap_pvt_thread_mutex_destroy( &bi->sql_dbconn_mutex ); + ldap_pvt_thread_mutex_lock( &bi->sql_schema_mutex ); + backsql_destroy_schema_map( bi ); + ldap_pvt_thread_mutex_unlock( &bi->sql_schema_mutex ); + ldap_pvt_thread_mutex_destroy( &bi->sql_schema_mutex ); + free( bi->sql_dbname ); + free( bi->sql_dbuser ); + if ( bi->sql_dbpasswd ) { + free( bi->sql_dbpasswd ); } - if ( si->dbhost ) { - free( si->dbhost ); + if ( bi->sql_dbhost ) { + free( bi->sql_dbhost ); } - if ( si->upper_func.bv_val ) { - free( si->upper_func.bv_val ); - free( si->upper_func_open.bv_val ); - free( si->upper_func_close.bv_val ); + if ( bi->sql_upper_func.bv_val ) { + free( bi->sql_upper_func.bv_val ); + free( bi->sql_upper_func_open.bv_val ); + free( bi->sql_upper_func_close.bv_val ); } - free( si->subtree_cond.bv_val ); - free( si->oc_query ); - free( si->at_query ); - free( si->insentry_query ); - free( si->delentry_query ); - free( si->delobjclasses_query ); - free( si->delreferrals_query ); - free( si ); + free( bi->sql_subtree_cond.bv_val ); + free( bi->sql_oc_query ); + free( bi->sql_at_query ); + free( bi->sql_insentry_query ); + free( bi->sql_delentry_query ); + free( bi->sql_delobjclasses_query ); + free( bi->sql_delreferrals_query ); + free( bi ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_destroy()\n", 0, 0, 0 ); return 0; @@ -173,7 +173,7 @@ int backsql_db_open( BackendDB *bd ) { - backsql_info *si = (backsql_info*)bd->be_private; + backsql_info *bi = (backsql_info*)bd->be_private; SQLHDBC dbh; ber_len_t idq_len; struct berbuf bb = BB_NULL; @@ -182,20 +182,20 @@ backsql_db_open( Debug( LDAP_DEBUG_TRACE, "==>backsql_db_open(): " "testing RDBMS connection\n", 0, 0, 0 ); - if ( si->dbname == NULL ) { + if ( bi->sql_dbname == NULL ) { Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): " "datasource name not specified " "(use \"dbname\" directive in slapd.conf)\n", 0, 0, 0 ); return 1; } - if ( si->concat_func == NULL ) { + if ( bi->sql_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 ) ) { + &bi->sql_concat_func, 2 ) ) { Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): " "unable to parse pattern \"%s\"", backsql_def_concat_func, 0, 0 ); @@ -206,44 +206,44 @@ backsql_db_open( /* * Prepare cast string as required */ - if ( si->upper_func.bv_val ) { + if ( bi->sql_upper_func.bv_val ) { char buf[1024]; - if ( BACKSQL_UPPER_NEEDS_CAST( si ) ) { + if ( BACKSQL_UPPER_NEEDS_CAST( bi ) ) { snprintf( buf, sizeof( buf ), "%s(cast (" /* ? as varchar(%d))) */ , - si->upper_func.bv_val ); - ber_str2bv( buf, 0, 1, &si->upper_func_open ); + bi->sql_upper_func.bv_val ); + ber_str2bv( buf, 0, 1, &bi->sql_upper_func_open ); snprintf( buf, sizeof( buf ), /* (cast(? */ " as varchar(%d)))", BACKSQL_MAX_DN_LEN ); - ber_str2bv( buf, 0, 1, &si->upper_func_close ); + ber_str2bv( buf, 0, 1, &bi->sql_upper_func_close ); } else { snprintf( buf, sizeof( buf ), "%s(" /* ?) */ , - si->upper_func.bv_val ); - ber_str2bv( buf, 0, 1, &si->upper_func_open ); + bi->sql_upper_func.bv_val ); + ber_str2bv( buf, 0, 1, &bi->sql_upper_func_open ); - ber_str2bv( /* (? */ ")", 0, 1, &si->upper_func_close ); + ber_str2bv( /* (? */ ")", 0, 1, &bi->sql_upper_func_close ); } } /* normalize filter values only if necessary */ - si->bi_caseIgnoreMatch = mr_find( "caseIgnoreMatch" ); - assert( si->bi_caseIgnoreMatch ); + bi->sql_caseIgnoreMatch = mr_find( "caseIgnoreMatch" ); + assert( bi->sql_caseIgnoreMatch ); - si->bi_telephoneNumberMatch = mr_find( "telephoneNumberMatch" ); - assert( si->bi_telephoneNumberMatch ); + bi->sql_telephoneNumberMatch = mr_find( "telephoneNumberMatch" ); + assert( bi->sql_telephoneNumberMatch ); - if ( si->dbuser == NULL ) { + if ( bi->sql_dbuser == NULL ) { Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): " "user name not specified " "(use \"dbuser\" directive in slapd.conf)\n", 0, 0, 0 ); return 1; } - if ( si->subtree_cond.bv_val == NULL ) { + if ( bi->sql_subtree_cond.bv_val == NULL ) { /* * Prepare concat function for subtree search condition */ @@ -255,7 +255,7 @@ backsql_db_open( }; struct berbuf bb = BB_NULL; - if ( backsql_prepare_pattern( si->concat_func, values, + if ( backsql_prepare_pattern( bi->sql_concat_func, values, &concat ) ) { Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): " "unable to prepare CONCAT pattern", 0, 0, 0 ); @@ -267,19 +267,19 @@ backsql_db_open( "(use \"subtree_cond\" directive in slapd.conf)\n", 0, 0, 0); - if ( si->upper_func.bv_val ) { + if ( bi->sql_upper_func.bv_val ) { /* * UPPER(ldap_entries.dn) LIKE UPPER(CONCAT('%',?)) */ backsql_strfcat( &bb, "blbbb", - &si->upper_func, + &bi->sql_upper_func, (ber_len_t)STRLENOF( "(ldap_entries.dn) LIKE " ), "(ldap_entries.dn) LIKE ", - &si->upper_func_open, + &bi->sql_upper_func_open, &concat, - &si->upper_func_close ); + &bi->sql_upper_func_close ); } else { @@ -293,27 +293,27 @@ backsql_db_open( &concat ); } - si->subtree_cond = bb.bb_val; + bi->sql_subtree_cond = bb.bb_val; Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): " "setting \"%s\" as default\n", - si->subtree_cond.bv_val, 0, 0 ); + bi->sql_subtree_cond.bv_val, 0, 0 ); } - if ( si->children_cond.bv_val == NULL ) { + if ( bi->sql_children_cond.bv_val == NULL ) { struct berbuf bb = BB_NULL; - if ( si->upper_func.bv_val ) { + if ( bi->sql_upper_func.bv_val ) { /* * UPPER(ldap_entries.dn) LIKE UPPER(CONCAT('%,',?)) */ backsql_strfcat( &bb, "blbl", - &si->upper_func, + &bi->sql_upper_func, (ber_len_t)STRLENOF( "(ldap_entries.dn)=" ), "(ldap_entries.dn)=", - &si->upper_func, + &bi->sql_upper_func, (ber_len_t)STRLENOF( "(?)" ), "(?)" ); } else { @@ -327,20 +327,20 @@ backsql_db_open( "ldap_entries.dn=?"); } - si->children_cond = bb.bb_val; + bi->sql_children_cond = bb.bb_val; Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): " "setting \"%s\" as default\n", - si->children_cond.bv_val, 0, 0 ); + bi->sql_children_cond.bv_val, 0, 0 ); } - if ( si->oc_query == NULL ) { - if ( BACKSQL_CREATE_NEEDS_SELECT( si ) ) { - si->oc_query = + if ( bi->sql_oc_query == NULL ) { + if ( BACKSQL_CREATE_NEEDS_SELECT( bi ) ) { + bi->sql_oc_query = ch_strdup( backsql_def_needs_select_oc_query ); } else { - si->oc_query = ch_strdup( backsql_def_oc_query ); + bi->sql_oc_query = ch_strdup( backsql_def_oc_query ); } Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): " @@ -348,10 +348,10 @@ backsql_db_open( "(use \"oc_query\" directive in slapd.conf)\n", 0, 0, 0 ); Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): " - "setting \"%s\" by default\n", si->oc_query, 0, 0 ); + "setting \"%s\" by default\n", bi->sql_oc_query, 0, 0 ); } - if ( si->at_query == NULL ) { + if ( bi->sql_at_query == NULL ) { Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): " "attribute mapping SQL statement not specified " "(use \"at_query\" directive in slapd.conf)\n", @@ -359,10 +359,10 @@ backsql_db_open( Debug(LDAP_DEBUG_TRACE, "backsql_db_open(): " "setting \"%s\" by default\n", backsql_def_at_query, 0, 0 ); - si->at_query = ch_strdup( backsql_def_at_query ); + bi->sql_at_query = ch_strdup( backsql_def_at_query ); } - if ( si->insentry_query == NULL ) { + if ( bi->sql_insentry_query == NULL ) { Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): " "entry insertion SQL statement not specified " "(use \"insentry_query\" directive in slapd.conf)\n", @@ -370,10 +370,10 @@ backsql_db_open( Debug(LDAP_DEBUG_TRACE, "backsql_db_open(): " "setting \"%s\" by default\n", backsql_def_insentry_query, 0, 0 ); - si->insentry_query = ch_strdup( backsql_def_insentry_query ); + bi->sql_insentry_query = ch_strdup( backsql_def_insentry_query ); } - if ( si->delentry_query == NULL ) { + if ( bi->sql_delentry_query == NULL ) { Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): " "entry deletion SQL statement not specified " "(use \"delentry_query\" directive in slapd.conf)\n", @@ -381,10 +381,10 @@ backsql_db_open( Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): " "setting \"%s\" by default\n", backsql_def_delentry_query, 0, 0 ); - si->delentry_query = ch_strdup( backsql_def_delentry_query ); + bi->sql_delentry_query = ch_strdup( backsql_def_delentry_query ); } - if ( si->delobjclasses_query == NULL ) { + if ( bi->sql_delobjclasses_query == NULL ) { Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): " "objclasses deletion SQL statement not specified " "(use \"delobjclasses_query\" directive in slapd.conf)\n", @@ -392,10 +392,10 @@ backsql_db_open( Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): " "setting \"%s\" by default\n", backsql_def_delobjclasses_query, 0, 0 ); - si->delobjclasses_query = ch_strdup( backsql_def_delobjclasses_query ); + bi->sql_delobjclasses_query = ch_strdup( backsql_def_delobjclasses_query ); } - if ( si->delreferrals_query == NULL ) { + if ( bi->sql_delreferrals_query == NULL ) { Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): " "referrals deletion SQL statement not specified " "(use \"delreferrals_query\" directive in slapd.conf)\n", @@ -403,7 +403,7 @@ backsql_db_open( Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): " "setting \"%s\" by default\n", backsql_def_delreferrals_query, 0, 0 ); - si->delreferrals_query = ch_strdup( backsql_def_delreferrals_query ); + bi->sql_delreferrals_query = ch_strdup( backsql_def_delreferrals_query ); } otmp.o_connid = (unsigned long)(-1); @@ -417,39 +417,39 @@ backsql_db_open( /* * Prepare ID selection query */ - si->id_query = NULL; + bi->sql_id_query = NULL; idq_len = 0; - if ( si->upper_func.bv_val == NULL ) { + if ( bi->sql_upper_func.bv_val == NULL ) { backsql_strcat( &bb, backsql_id_query, "dn=?", NULL ); } else { - if ( BACKSQL_HAS_LDAPINFO_DN_RU( si ) ) { + if ( BACKSQL_HAS_LDAPINFO_DN_RU( bi ) ) { backsql_strcat( &bb, backsql_id_query, "dn_ru=?", NULL ); } else { - if ( BACKSQL_USE_REVERSE_DN( si ) ) { + if ( BACKSQL_USE_REVERSE_DN( bi ) ) { backsql_strfcat( &bb, "sbl", backsql_id_query, - &si->upper_func, + &bi->sql_upper_func, (ber_len_t)STRLENOF( "(dn)=?" ), "(dn)=?" ); } else { backsql_strfcat( &bb, "sblbcb", backsql_id_query, - &si->upper_func, + &bi->sql_upper_func, (ber_len_t)STRLENOF( "(dn)=" ), "(dn)=", - &si->upper_func_open, + &bi->sql_upper_func_open, '?', - &si->upper_func_close ); + &bi->sql_upper_func_close ); } } } - si->id_query = bb.bb_val.bv_val; + bi->sql_id_query = bb.bb_val.bv_val; /* * Prepare children ID selection query */ - si->has_children_query = NULL; + bi->sql_has_children_query = NULL; bb.bb_val.bv_val = NULL; bb.bb_val.bv_len = 0; @@ -457,11 +457,11 @@ backsql_db_open( backsql_strfcat( &bb, "sb", "SELECT COUNT(distinct subordinates.id) FROM ldap_entries,ldap_entries subordinates WHERE subordinates.parent=ldap_entries.id AND ", - &si->children_cond ); - si->has_children_query = bb.bb_val.bv_val; + &bi->sql_children_cond ); + bi->sql_has_children_query = bb.bb_val.bv_val; backsql_free_db_conn( &otmp ); - if ( !BACKSQL_SCHEMA_LOADED( si ) ) { + if ( !BACKSQL_SCHEMA_LOADED( bi ) ) { Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): " "test failed, schema map not loaded - exiting\n", 0, 0, 0 ); diff --git a/servers/slapd/back-sql/modrdn.c b/servers/slapd/back-sql/modrdn.c index 624ea7b950..5cade96a3c 100644 --- a/servers/slapd/back-sql/modrdn.c +++ b/servers/slapd/back-sql/modrdn.c @@ -233,12 +233,12 @@ backsql_modrdn( Operation *op, SlapReply *rs ) Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): " "executing delentry_query\n", 0, 0, 0 ); - rc = backsql_Prepare( dbh, &sth, bi->delentry_query, 0 ); + rc = backsql_Prepare( dbh, &sth, bi->sql_delentry_query, 0 ); if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): " "error preparing delentry_query\n", 0, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); rs->sr_text = "SQL-backend error"; @@ -253,7 +253,7 @@ backsql_modrdn( Operation *op, SlapReply *rs ) "error binding entry ID parameter " "for objectClass %s\n", oc->bom_oc->soc_cname.bv_val, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); @@ -267,7 +267,7 @@ backsql_modrdn( Operation *op, SlapReply *rs ) Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): " "failed to delete record from ldap_entries\n", 0, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, sth, rc ); + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); rs->sr_err = LDAP_OTHER; rs->sr_text = "SQL-backend error"; @@ -280,12 +280,12 @@ backsql_modrdn( Operation *op, SlapReply *rs ) Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): " "executing insentry_query\n", 0, 0, 0 ); - rc = backsql_Prepare( dbh, &sth, bi->insentry_query, 0 ); + rc = backsql_Prepare( dbh, &sth, bi->sql_insentry_query, 0 ); if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): " "error preparing insentry_query\n", 0, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); rs->sr_text = "SQL-backend error"; @@ -299,7 +299,7 @@ backsql_modrdn( Operation *op, SlapReply *rs ) " backsql_add_attr(): " "error binding DN parameter for objectClass %s\n", oc->bom_oc->soc_cname.bv_val, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); @@ -314,7 +314,7 @@ backsql_modrdn( Operation *op, SlapReply *rs ) " backsql_add_attr(): " "error binding objectClass ID parameter for objectClass %s\n", oc->bom_oc->soc_cname.bv_val, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); @@ -329,7 +329,7 @@ backsql_modrdn( Operation *op, SlapReply *rs ) " backsql_add_attr(): " "error binding parent ID parameter for objectClass %s\n", oc->bom_oc->soc_cname.bv_val, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); @@ -344,7 +344,7 @@ backsql_modrdn( Operation *op, SlapReply *rs ) " backsql_add_attr(): " "error binding entry ID parameter for objectClass %s\n", oc->bom_oc->soc_cname.bv_val, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); @@ -357,7 +357,7 @@ backsql_modrdn( Operation *op, SlapReply *rs ) if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): " "could not insert ldap_entries record\n", 0, 0, 0 ); - backsql_PrintErrors( bi->db_env, dbh, sth, rc ); + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); rs->sr_err = LDAP_OTHER; rs->sr_text = "SQL-backend error"; diff --git a/servers/slapd/back-sql/schema-map.c b/servers/slapd/back-sql/schema-map.c index fd524e721f..a0325b37f7 100644 --- a/servers/slapd/back-sql/schema-map.c +++ b/servers/slapd/back-sql/schema-map.c @@ -340,7 +340,7 @@ backsql_add_sysmaps( backsql_oc_map_rec *oc_map ) } struct backsql_attr_schema_info { - backsql_info *bas_si; + backsql_info *bas_bi; SQLHDBC bas_dbh; SQLHSTMT bas_sth; unsigned long *bas_oc_id; @@ -364,7 +364,7 @@ backsql_oc_get_attr_mapping( void *v_oc, void *v_bas ) " \"%s\"\n" " for objectClass \"%s\"\n" " with param oc_id=\"%lu\"\n", - bas->bas_si->at_query, + bas->bas_bi->sql_at_query, BACKSQL_OC_NAME( oc_map ), *bas->bas_oc_id ); @@ -375,10 +375,11 @@ backsql_oc_get_attr_mapping( void *v_oc, void *v_bas ) " \"%s\"\n" " for objectClass \"%s\"\n" " with param oc_id=\"%lu\"\n", - bas->bas_si->at_query, + bas->bas_bi->sql_at_query, BACKSQL_OC_NAME( oc_map ), *bas->bas_oc_id ); - backsql_PrintErrors( SQL_NULL_HENV, bas->bas_dbh, bas->bas_sth, rc ); + backsql_PrintErrors( bas->bas_bi->sql_db_env, + bas->bas_dbh, bas->bas_sth, rc ); bas->bas_rc = LDAP_OTHER; return BACKSQL_AVL_STOP; } @@ -463,13 +464,13 @@ backsql_oc_get_attr_mapping( void *v_oc, void *v_bas ) oc_map->bom_oc->soc_cname.bv_val, 0 ); } - if ( !BER_BVISNULL( &bas->bas_si->upper_func ) && + if ( !BER_BVISNULL( &bas->bas_bi->sql_upper_func ) && BER_BVISNULL( &at_map->bam_sel_expr_u ) ) { struct berbuf bb = BB_NULL; backsql_strfcat( &bb, "bcbc", - &bas->bas_si->upper_func, + &bas->bas_bi->sql_upper_func, '(' /* ) */ , &at_map->bam_sel_expr, /* ( */ ')' ); @@ -490,7 +491,7 @@ backsql_oc_get_attr_mapping( void *v_oc, void *v_bas ) int -backsql_load_schema_map( backsql_info *si, SQLHDBC dbh ) +backsql_load_schema_map( backsql_info *bi, SQLHDBC dbh ) { SQLHSTMT sth; RETCODE rc; @@ -504,31 +505,31 @@ backsql_load_schema_map( backsql_info *si, SQLHDBC dbh ) /* * TimesTen : See if the ldap_entries.dn_ru field exists in the schema */ - if ( !BACKSQL_DONTCHECK_LDAPINFO_DN_RU( si ) ) { + if ( !BACKSQL_DONTCHECK_LDAPINFO_DN_RU( bi ) ) { rc = backsql_Prepare( dbh, &sth, backsql_check_dn_ru_query, 0 ); if ( rc == SQL_SUCCESS ) { /* Yes, the field exists */ - si->bsql_flags |= BSQLF_HAS_LDAPINFO_DN_RU; + bi->sql_flags |= BSQLF_HAS_LDAPINFO_DN_RU; Debug( LDAP_DEBUG_TRACE, "ldapinfo.dn_ru field exists " "in the schema\n", 0, 0, 0 ); } else { /* No such field exists */ - si->bsql_flags &= ~BSQLF_HAS_LDAPINFO_DN_RU; + bi->sql_flags &= ~BSQLF_HAS_LDAPINFO_DN_RU; } SQLFreeStmt( sth, SQL_DROP ); } Debug( LDAP_DEBUG_TRACE, "backsql_load_schema_map(): oc_query \"%s\"\n", - si->oc_query, 0, 0 ); + bi->sql_oc_query, 0, 0 ); - rc = backsql_Prepare( dbh, &sth, si->oc_query, 0 ); + rc = backsql_Prepare( dbh, &sth, bi->sql_oc_query, 0 ); if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "backsql_load_schema_map(): " "error preparing oc_query: \"%s\"\n", - si->oc_query, 0, 0 ); - backsql_PrintErrors( si->db_env, dbh, sth, rc ); + bi->sql_oc_query, 0, 0 ); + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); return LDAP_OTHER; } @@ -536,7 +537,7 @@ backsql_load_schema_map( backsql_info *si, SQLHDBC dbh ) if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "backsql_load_schema_map(): " "error executing oc_query: \n", 0, 0, 0 ); - backsql_PrintErrors( si->db_env, dbh, sth, rc ); + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); return LDAP_OTHER; } @@ -564,7 +565,7 @@ backsql_load_schema_map( backsql_info *si, SQLHDBC dbh ) : ch_strdup( oc_row.cols[ 4 ] ); colnum = 5; - if ( BACKSQL_CREATE_NEEDS_SELECT( si ) ) { + if ( BACKSQL_CREATE_NEEDS_SELECT( bi ) ) { colnum = 6; oc_map->bom_create_keyval = ( oc_row.value_len[ 5 ] < 0 ) ? NULL : ch_strdup( oc_row.cols[ 5 ] ); @@ -580,13 +581,13 @@ backsql_load_schema_map( backsql_info *si, SQLHDBC dbh ) */ oc_map->bom_attrs = NULL; - if ( avl_insert( &si->oc_by_oc, oc_map, backsql_cmp_oc, avl_dup_error ) == -1 ) { + if ( avl_insert( &bi->sql_oc_by_oc, oc_map, backsql_cmp_oc, avl_dup_error ) == -1 ) { Debug( LDAP_DEBUG_TRACE, "backsql_load_schema_map(): " "duplicate objectClass \"%s\" in objectClass map\n", oc_map->bom_oc->soc_cname.bv_val, 0, 0 ); return LDAP_OTHER; } - if ( avl_insert( &si->oc_by_id, oc_map, backsql_cmp_oc_id, avl_dup_error ) == -1 ) { + if ( avl_insert( &bi->sql_oc_by_id, oc_map, backsql_cmp_oc_id, avl_dup_error ) == -1 ) { Debug( LDAP_DEBUG_TRACE, "backsql_load_schema_map(): " "duplicate objectClass \"%s\" in objectClass by ID map\n", oc_map->bom_oc->soc_cname.bv_val, 0, 0 ); @@ -620,14 +621,14 @@ backsql_load_schema_map( backsql_info *si, SQLHDBC dbh ) /* prepare for attribute fetching */ Debug( LDAP_DEBUG_TRACE, "backsql_load_schema_map(): at_query \"%s\"\n", - si->at_query, 0, 0 ); + bi->sql_at_query, 0, 0 ); - rc = backsql_Prepare( dbh, &sth, si->at_query, 0 ); + rc = backsql_Prepare( dbh, &sth, bi->sql_at_query, 0 ); if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "backsql_load_schema_map(): " "error preparing at_query: \"%s\"\n", - si->at_query, 0, 0 ); - backsql_PrintErrors( si->db_env, dbh, sth, rc ); + bi->sql_at_query, 0, 0 ); + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); return LDAP_OTHER; } @@ -635,23 +636,23 @@ backsql_load_schema_map( backsql_info *si, SQLHDBC dbh ) if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "backsql_load_schema_map(): " "error binding param \"oc_id\" for at_query\n", 0, 0, 0 ); - backsql_PrintErrors( si->db_env, dbh, sth, rc ); + backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); return LDAP_OTHER; } - bas.bas_si = si; + bas.bas_bi = bi; bas.bas_dbh = dbh; bas.bas_sth = sth; bas.bas_oc_id = &oc_id; bas.bas_rc = LDAP_SUCCESS; - (void)avl_apply( si->oc_by_oc, backsql_oc_get_attr_mapping, + (void)avl_apply( bi->sql_oc_by_oc, backsql_oc_get_attr_mapping, &bas, BACKSQL_AVL_STOP, AVL_INORDER ); SQLFreeStmt( sth, SQL_DROP ); - si->bsql_flags |= BSQLF_SCHEMA_LOADED; + bi->sql_flags |= BSQLF_SCHEMA_LOADED; Debug( LDAP_DEBUG_TRACE, "<==backsql_load_schema_map()\n", 0, 0, 0 ); @@ -659,7 +660,7 @@ backsql_load_schema_map( backsql_info *si, SQLHDBC dbh ) } backsql_oc_map_rec * -backsql_oc2oc( backsql_info *si, ObjectClass *oc ) +backsql_oc2oc( backsql_info *bi, ObjectClass *oc ) { backsql_oc_map_rec tmp, *res; @@ -670,7 +671,7 @@ backsql_oc2oc( backsql_info *si, ObjectClass *oc ) #endif /* BACKSQL_TRACE */ tmp.bom_oc = oc; - res = (backsql_oc_map_rec *)avl_find( si->oc_by_oc, &tmp, backsql_cmp_oc ); + res = (backsql_oc_map_rec *)avl_find( bi->sql_oc_by_oc, &tmp, backsql_cmp_oc ); #ifdef BACKSQL_TRACE if ( res != NULL ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_oc2oc(): " @@ -686,7 +687,7 @@ backsql_oc2oc( backsql_info *si, ObjectClass *oc ) } backsql_oc_map_rec * -backsql_name2oc( backsql_info *si, struct berval *oc_name ) +backsql_name2oc( backsql_info *bi, struct berval *oc_name ) { backsql_oc_map_rec tmp, *res; @@ -701,7 +702,7 @@ backsql_name2oc( backsql_info *si, struct berval *oc_name ) return NULL; } - res = (backsql_oc_map_rec *)avl_find( si->oc_by_oc, &tmp, backsql_cmp_oc ); + res = (backsql_oc_map_rec *)avl_find( bi->sql_oc_by_oc, &tmp, backsql_cmp_oc ); #ifdef BACKSQL_TRACE if ( res != NULL ) { Debug( LDAP_DEBUG_TRACE, "<==oc_with_name(): " @@ -717,7 +718,7 @@ backsql_name2oc( backsql_info *si, struct berval *oc_name ) } backsql_oc_map_rec * -backsql_id2oc( backsql_info *si, unsigned long id ) +backsql_id2oc( backsql_info *bi, unsigned long id ) { backsql_oc_map_rec tmp, *res; @@ -727,7 +728,7 @@ backsql_id2oc( backsql_info *si, unsigned long id ) #endif /* BACKSQL_TRACE */ tmp.bom_id = id; - res = (backsql_oc_map_rec *)avl_find( si->oc_by_id, &tmp, + res = (backsql_oc_map_rec *)avl_find( bi->sql_oc_by_id, &tmp, backsql_cmp_oc_id ); #ifdef BACKSQL_TRACE @@ -918,11 +919,11 @@ backsql_free_oc( void *v_oc ) } int -backsql_destroy_schema_map( backsql_info *si ) +backsql_destroy_schema_map( backsql_info *bi ) { Debug( LDAP_DEBUG_TRACE, "==>destroy_schema_map()\n", 0, 0, 0 ); - avl_free( si->oc_by_oc, 0 ); - avl_free( si->oc_by_id, backsql_free_oc ); + avl_free( bi->sql_oc_by_oc, 0 ); + avl_free( bi->sql_oc_by_id, backsql_free_oc ); Debug( LDAP_DEBUG_TRACE, "<==destroy_schema_map()\n", 0, 0, 0 ); return 0; } diff --git a/servers/slapd/back-sql/search.c b/servers/slapd/back-sql/search.c index c3c96746e0..f87da1db5c 100644 --- a/servers/slapd/back-sql/search.c +++ b/servers/slapd/back-sql/search.c @@ -252,14 +252,14 @@ backsql_process_sub_filter( backsql_srch_info *bsi, Filter *f, /* always uppercase strings by now */ #ifdef BACKSQL_UPPERCASE_FILTER if ( SLAP_MR_ASSOCIATED( f->f_sub_desc->ad_type->sat_substr, - bi->bi_caseIgnoreMatch ) ) + bi->sql_caseIgnoreMatch ) ) #endif /* BACKSQL_UPPERCASE_FILTER */ { casefold = 1; } if ( SLAP_MR_ASSOCIATED( f->f_sub_desc->ad_type->sat_substr, - bi->bi_telephoneNumberMatch ) ) + bi->sql_telephoneNumberMatch ) ) { struct berval bv; @@ -853,14 +853,14 @@ equality_match:; /* always uppercase strings by now */ #ifdef BACKSQL_UPPERCASE_FILTER if ( SLAP_MR_ASSOCIATED( matching_rule, - bi->bi_caseIgnoreMatch ) ) + bi->sql_caseIgnoreMatch ) ) #endif /* BACKSQL_UPPERCASE_FILTER */ { casefold = 1; } if ( SLAP_MR_ASSOCIATED( matching_rule, - bi->bi_telephoneNumberMatch ) ) + bi->sql_telephoneNumberMatch ) ) { struct berval bv; ber_len_t i; @@ -924,7 +924,7 @@ equality_match:; /* always uppercase strings by now */ #ifdef BACKSQL_UPPERCASE_FILTER if ( SLAP_MR_ASSOCIATED( at->bam_ad->ad_type->sat_ordering, - bi->bi_caseIgnoreMatch ) ) + bi->sql_caseIgnoreMatch ) ) #endif /* BACKSQL_UPPERCASE_FILTER */ { casefold = 1; @@ -1031,9 +1031,9 @@ backsql_srch_query( backsql_srch_info *bsi, struct berval *query ) &bsi->bsi_oc->bom_keycol, ',' ); - if ( !BER_BVISNULL( &bi->strcast_func ) ) { + if ( !BER_BVISNULL( &bi->sql_strcast_func ) ) { backsql_strfcat( &bsi->bsi_sel, "blbl", - &bi->strcast_func, + &bi->sql_strcast_func, (ber_len_t)STRLENOF( "('" /* ') */ ), "('" /* ') */ , &bsi->bsi_oc->bom_oc->soc_cname, @@ -1078,7 +1078,7 @@ backsql_srch_query( backsql_srch_info *bsi, struct berval *query ) case LDAP_SCOPE_BASE: if ( BACKSQL_CANUPPERCASE( bi ) ) { backsql_strfcat( &bsi->bsi_join_where, "bl", - &bi->upper_func, + &bi->sql_upper_func, (ber_len_t)STRLENOF( "(ldap_entries.dn)=?" ), "(ldap_entries.dn)=?" ); } else { @@ -1091,7 +1091,7 @@ backsql_srch_query( backsql_srch_info *bsi, struct berval *query ) case BACKSQL_SCOPE_BASE_LIKE: if ( BACKSQL_CANUPPERCASE( bi ) ) { backsql_strfcat( &bsi->bsi_join_where, "bl", - &bi->upper_func, + &bi->sql_upper_func, (ber_len_t)STRLENOF( "(ldap_entries.dn) LIKE ?" ), "(ldap_entries.dn) LIKE ?" ); } else { @@ -1110,7 +1110,7 @@ backsql_srch_query( backsql_srch_info *bsi, struct berval *query ) case LDAP_SCOPE_SUBTREE: if ( BACKSQL_CANUPPERCASE( bi ) ) { backsql_strfcat( &bsi->bsi_join_where, "bl", - &bi->upper_func, + &bi->sql_upper_func, (ber_len_t)STRLENOF( "(ldap_entries.dn) LIKE ?" ), "(ldap_entries.dn) LIKE ?" ); } else { @@ -1246,7 +1246,7 @@ backsql_oc_get_candidates( void *v_oc, void *v_bsi ) if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): " "error preparing query\n", 0, 0, 0 ); - backsql_PrintErrors( bi->db_env, bsi->bsi_dbh, sth, rc ); + backsql_PrintErrors( bi->sql_db_env, bsi->bsi_dbh, sth, rc ); bsi->bsi_status = LDAP_OTHER; return BACKSQL_AVL_CONTINUE; } @@ -1291,7 +1291,7 @@ backsql_oc_get_candidates( void *v_oc, void *v_bsi ) if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): " "error binding base_dn parameter\n", 0, 0, 0 ); - backsql_PrintErrors( bi->db_env, bsi->bsi_dbh, + backsql_PrintErrors( bi->sql_db_env, bsi->bsi_dbh, sth, rc ); bsi->bsi_status = LDAP_OTHER; return BACKSQL_AVL_CONTINUE; @@ -1351,7 +1351,7 @@ backsql_oc_get_candidates( void *v_oc, void *v_bsi ) Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): " "error binding base_dn parameter (2)\n", 0, 0, 0 ); - backsql_PrintErrors( bi->db_env, bsi->bsi_dbh, + backsql_PrintErrors( bi->sql_db_env, bsi->bsi_dbh, sth, rc ); bsi->bsi_status = LDAP_OTHER; return BACKSQL_AVL_CONTINUE; @@ -1384,7 +1384,7 @@ backsql_oc_get_candidates( void *v_oc, void *v_bsi ) if ( !BACKSQL_SUCCESS( rc ) ) { Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): " "error executing query\n", 0, 0, 0 ); - backsql_PrintErrors( bi->db_env, bsi->bsi_dbh, sth, rc ); + backsql_PrintErrors( bi->sql_db_env, bsi->bsi_dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); bsi->bsi_status = LDAP_OTHER; return BACKSQL_AVL_CONTINUE; @@ -1535,7 +1535,7 @@ backsql_search( Operation *op, SlapReply *rs ) ( op->ors_limit == NULL /* isroot == FALSE */ ? -2 : ( op->ors_limit->lms_s_unchecked == -1 ? -2 : ( op->ors_limit->lms_s_unchecked ) ) ); - avl_apply( bi->oc_by_oc, backsql_oc_get_candidates, + avl_apply( bi->sql_oc_by_oc, backsql_oc_get_candidates, &srch_info, BACKSQL_AVL_STOP, AVL_INORDER ); if ( op->ors_limit != NULL /* isroot == TRUE */ && op->ors_limit->lms_s_unchecked != -1 diff --git a/servers/slapd/back-sql/sql-wrap.c b/servers/slapd/back-sql/sql-wrap.c index f6337fe31e..a7a30384e6 100644 --- a/servers/slapd/back-sql/sql-wrap.c +++ b/servers/slapd/back-sql/sql-wrap.c @@ -98,6 +98,8 @@ backsql_Prepare( SQLHDBC dbh, SQLHSTMT *sth, char *query, int timeout ) "SQL_CONCUR_ROWVER) failed:\n", 0, 0, 0 ); backsql_PrintErrors( SQL_NULL_HENV, dbh, *sth, rc ); + SQLFreeStmt( *sth, SQL_DROP ); + return rc; } } @@ -108,6 +110,8 @@ backsql_Prepare( SQLHDBC dbh, SQLHSTMT *sth, char *query, int timeout ) rc = SQLSetStmtOption( *sth, SQL_QUERY_TIMEOUT, timeout ); if ( rc != SQL_SUCCESS ) { backsql_PrintErrors( SQL_NULL_HENV, dbh, *sth, rc ); + SQLFreeStmt( *sth, SQL_DROP ); + return rc; } } @@ -267,13 +271,13 @@ backsql_close_db_conn( backsql_db_conn *conn ) } int -backsql_init_db_env( backsql_info *si ) +backsql_init_db_env( backsql_info *bi ) { RETCODE rc; int ret = SQL_SUCCESS; Debug( LDAP_DEBUG_TRACE, "==>backsql_init_db_env()\n", 0, 0, 0 ); - rc = SQLAllocEnv( &si->db_env ); + rc = SQLAllocEnv( &bi->sql_db_env ); if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "init_db_env: SQLAllocEnv failed:\n", 0, 0, 0 ); @@ -286,7 +290,7 @@ backsql_init_db_env( backsql_info *si ) } int -backsql_free_db_env( backsql_info *si ) +backsql_free_db_env( backsql_info *bi ) { Debug( LDAP_DEBUG_TRACE, "==>backsql_free_db_env()\n", 0, 0, 0 ); @@ -305,7 +309,7 @@ backsql_free_db_env( backsql_info *si ) } static int -backsql_open_db_conn( backsql_info *si, unsigned long ldap_cid, backsql_db_conn **pdbc ) +backsql_open_db_conn( backsql_info *bi, unsigned long ldap_cid, backsql_db_conn **pdbc ) { /* TimesTen */ char DBMSName[ 32 ]; @@ -318,26 +322,26 @@ backsql_open_db_conn( backsql_info *si, unsigned long ldap_cid, backsql_db_conn Debug( LDAP_DEBUG_TRACE, "==>backsql_open_db_conn()\n", 0, 0, 0 ); dbc = (backsql_db_conn *)ch_calloc( 1, sizeof( backsql_db_conn ) ); dbc->ldap_cid = ldap_cid; - rc = SQLAllocConnect( si->db_env, &dbc->dbh ); + rc = SQLAllocConnect( bi->sql_db_env, &dbc->dbh ); if ( !BACKSQL_SUCCESS( rc ) ) { Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn: " "SQLAllocConnect() failed:\n", 0, 0, 0 ); - backsql_PrintErrors( si->db_env, SQL_NULL_HDBC, + backsql_PrintErrors( bi->sql_db_env, SQL_NULL_HDBC, SQL_NULL_HENV, rc ); return LDAP_UNAVAILABLE; } rc = SQLConnect( dbc->dbh, - (SQLCHAR*)si->dbname, SQL_NTS, - (SQLCHAR*)si->dbuser, SQL_NTS, - (SQLCHAR*)si->dbpasswd, SQL_NTS ); + (SQLCHAR*)bi->sql_dbname, SQL_NTS, + (SQLCHAR*)bi->sql_dbuser, SQL_NTS, + (SQLCHAR*)bi->sql_dbpasswd, SQL_NTS ); if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn: " "SQLConnect() to database \"%s\" as user \"%s\" " - "%s:\n", si->dbname, si->dbuser, + "%s:\n", bi->sql_dbname, bi->sql_dbuser, rc == SQL_SUCCESS_WITH_INFO ? "succeeded with info" : "failed" ); - backsql_PrintErrors( si->db_env, dbc->dbh, SQL_NULL_HENV, rc ); + backsql_PrintErrors( bi->sql_db_env, dbc->dbh, SQL_NULL_HENV, rc ); if ( rc != SQL_SUCCESS_WITH_INFO ) { return LDAP_UNAVAILABLE; } @@ -354,7 +358,7 @@ backsql_open_db_conn( backsql_info *si, unsigned long ldap_cid, backsql_db_conn * remember that fact for later use. */ /* Assume until proven otherwise */ - si->bsql_flags &= ~BSQLF_USE_REVERSE_DN; + bi->sql_flags &= ~BSQLF_USE_REVERSE_DN; DBMSName[ 0 ] = '\0'; rc = SQLGetInfo( dbc->dbh, SQL_DBMS_NAME, (PTR)&DBMSName, sizeof( DBMSName ), NULL ); @@ -363,25 +367,25 @@ backsql_open_db_conn( backsql_info *si, unsigned long ldap_cid, backsql_db_conn strcmp( DBMSName, "Front-Tier" ) == 0 ) { Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn: " "TimesTen database!\n", 0, 0, 0 ); - si->bsql_flags |= BSQLF_USE_REVERSE_DN; + bi->sql_flags |= BSQLF_USE_REVERSE_DN; } } else { Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn: " "SQLGetInfo() failed:\n", 0, 0, 0 ); - backsql_PrintErrors( si->db_env, dbc->dbh, SQL_NULL_HENV, rc ); + backsql_PrintErrors( bi->sql_db_env, dbc->dbh, SQL_NULL_HENV, rc ); return rc; } /* end TimesTen */ Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn(): " "connected, adding to tree\n", 0, 0, 0 ); - ldap_pvt_thread_mutex_lock( &si->dbconn_mutex ); - if ( avl_insert( &si->db_conns, dbc, backsql_cmp_connid, avl_dup_error ) ) { + ldap_pvt_thread_mutex_lock( &bi->sql_dbconn_mutex ); + if ( avl_insert( &bi->sql_db_conns, dbc, backsql_cmp_connid, avl_dup_error ) ) { Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn: " "duplicate connection ID\n", 0, 0, 0 ); return LDAP_OTHER; } - ldap_pvt_thread_mutex_unlock( &si->dbconn_mutex ); + ldap_pvt_thread_mutex_unlock( &bi->sql_dbconn_mutex ); Debug( LDAP_DEBUG_TRACE, "<==backsql_open_db_conn()\n", 0, 0, 0 ); *pdbc = dbc; @@ -392,15 +396,15 @@ backsql_open_db_conn( backsql_info *si, unsigned long ldap_cid, backsql_db_conn int backsql_free_db_conn( Operation *op ) { - backsql_info *si = (backsql_info *)op->o_bd->be_private; + backsql_info *bi = (backsql_info *)op->o_bd->be_private; backsql_db_conn tmp = { 0 }, *conn; Debug( LDAP_DEBUG_TRACE, "==>backsql_free_db_conn()\n", 0, 0, 0 ); tmp.ldap_cid = op->o_connid; - ldap_pvt_thread_mutex_lock( &si->dbconn_mutex ); - conn = avl_delete( &si->db_conns, &tmp, backsql_cmp_connid ); - ldap_pvt_thread_mutex_unlock( &si->dbconn_mutex ); + ldap_pvt_thread_mutex_lock( &bi->sql_dbconn_mutex ); + conn = avl_delete( &bi->sql_db_conns, &tmp, backsql_cmp_connid ); + ldap_pvt_thread_mutex_unlock( &bi->sql_dbconn_mutex ); /* * we have one thread per connection, as I understand -- so we can @@ -418,7 +422,7 @@ backsql_free_db_conn( Operation *op ) int backsql_get_db_conn( Operation *op, SQLHDBC *dbh ) { - backsql_info *si = (backsql_info *)op->o_bd->be_private; + backsql_info *bi = (backsql_info *)op->o_bd->be_private; backsql_db_conn *dbc, tmp = { 0 }; int rc = LDAP_SUCCESS; @@ -434,9 +438,9 @@ backsql_get_db_conn( Operation *op, SQLHDBC *dbh ) * we have one thread per connection, as I understand -- * so we do not need locking here */ - dbc = avl_find( si->db_conns, &tmp, backsql_cmp_connid ); + dbc = avl_find( bi->sql_db_conns, &tmp, backsql_cmp_connid ); if ( !dbc ) { - rc = backsql_open_db_conn( si, op->o_connid, &dbc ); + rc = backsql_open_db_conn( bi, op->o_connid, &dbc ); if ( rc != LDAP_SUCCESS) { Debug( LDAP_DEBUG_TRACE, "backsql_get_db_conn(): " "could not get connection handle " @@ -445,18 +449,18 @@ backsql_get_db_conn( Operation *op, SQLHDBC *dbh ) } } - ldap_pvt_thread_mutex_lock( &si->schema_mutex ); - if ( !BACKSQL_SCHEMA_LOADED( si ) ) { + ldap_pvt_thread_mutex_lock( &bi->sql_schema_mutex ); + if ( !BACKSQL_SCHEMA_LOADED( bi ) ) { Debug( LDAP_DEBUG_TRACE, "backsql_get_db_conn(): " "first call -- reading schema map\n", 0, 0, 0 ); - rc = backsql_load_schema_map( si, dbc->dbh ); + rc = backsql_load_schema_map( bi, dbc->dbh ); if ( rc != LDAP_SUCCESS ) { - ldap_pvt_thread_mutex_unlock( &si->schema_mutex ); + ldap_pvt_thread_mutex_unlock( &bi->sql_schema_mutex ); backsql_free_db_conn( op ); return rc; } } - ldap_pvt_thread_mutex_unlock( &si->schema_mutex ); + ldap_pvt_thread_mutex_unlock( &bi->sql_schema_mutex ); *dbh = dbc->dbh; -- 2.39.5