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 ) ) {
" 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 );
" 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 );
" 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 ) ) {
" 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 );
" 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 );
" 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 );
"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 ) ) {
" 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";
" 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 );
" 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 );
" 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 );
" 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 ) ) {
" 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";
" 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 );
" 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 );
" 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 );
" 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 ) ) {
" 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 );
" 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 );
" 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 );
" 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 );
" 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 );
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";
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";
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";
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";
}
}
- 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";
" 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 );
" 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 );
" 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 );
" 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 );
}
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",
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 !!!
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 ) {
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;
}
}
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;
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;
#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
/*
* 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;
* 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
#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 ) \
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 ) {
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 ) {
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 ) {
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 ) {
"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 ) {
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"
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 ) {
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 ) {
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 ) {
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 ) {
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 ) {
}
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,
}
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" ) ) {
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 ) {
}
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,
}
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 ) {
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 ) {
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 ) {
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 ) {
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 ) {
}
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,
}
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 ) {
}
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,
}
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 ) {
}
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,
}
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",
" 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";
" 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 );
" 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 );
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";
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";
"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 );
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";
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";
"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 );
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";
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";
"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 );
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";
}
/* 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;
}
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;
}
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;
}
/* 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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
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;
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 );
/*
* 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
*/
};
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 );
"(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 {
&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 {
"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(): "
"(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",
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",
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",
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",
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",
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);
/*
* 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;
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 );
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";
"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 );
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";
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";
" 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 );
" 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 );
" 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 );
" 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 );
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";
}
struct backsql_attr_schema_info {
- backsql_info *bas_si;
+ backsql_info *bas_bi;
SQLHDBC bas_dbh;
SQLHSTMT bas_sth;
unsigned long *bas_oc_id;
" \"%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 );
" \"%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;
}
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,
/* ( */ ')' );
int
-backsql_load_schema_map( backsql_info *si, SQLHDBC dbh )
+backsql_load_schema_map( backsql_info *bi, SQLHDBC dbh )
{
SQLHSTMT sth;
RETCODE rc;
/*
* 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;
}
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;
}
: 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 ] );
*/
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 );
/* 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;
}
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 );
}
backsql_oc_map_rec *
-backsql_oc2oc( backsql_info *si, ObjectClass *oc )
+backsql_oc2oc( backsql_info *bi, ObjectClass *oc )
{
backsql_oc_map_rec tmp, *res;
#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(): "
}
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;
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(): "
}
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;
#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
}
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;
}
/* 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;
/* 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;
/* 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;
&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,
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 {
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 {
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 {
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;
}
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;
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;
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;
( 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
"SQL_CONCUR_ROWVER) failed:\n",
0, 0, 0 );
backsql_PrintErrors( SQL_NULL_HENV, dbh, *sth, rc );
+ SQLFreeStmt( *sth, SQL_DROP );
+ return rc;
}
}
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;
}
}
}
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 );
}
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 );
}
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 ];
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;
}
* 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 );
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;
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
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;
* 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 "
}
}
- 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;