+/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 1999-2005 The OpenLDAP Foundation.
+ * Copyright 1999-2011 The OpenLDAP Foundation.
* Portions Copyright 1999 Dmitry Kovalev.
* Portions Copyright 2002 Pierangelo Mararati.
* All rights reserved.
/*
* api.c
*/
-int backsql_api_config( backsql_info *si, const char *name );
+int backsql_api_config( backsql_info *bi, const char *name,
+ int argc, char *argv[] );
+int backsql_api_destroy( backsql_info *bi );
int backsql_api_register( backsql_api *ba );
int backsql_api_dn2odbc( Operation *op, SlapReply *rs, struct berval *dn );
int backsql_api_odbc2dn( Operation *op, SlapReply *rs, struct berval *dn );
#endif /* BACKSQL_ARBITRARY_KEY */
/* stores in *id the ID in table ldap_entries corresponding to DN, if any */
-int backsql_dn2id( Operation *op, SlapReply *rs, backsql_entryID *id,
- SQLHDBC dbh, struct berval *dn, int muck );
+extern int
+backsql_dn2id( Operation *op, SlapReply *rs, SQLHDBC dbh,
+ struct berval *ndn, backsql_entryID *id,
+ int matched, int muck );
/* stores in *nchildren the count of children for an entry */
-int backsql_count_children( backsql_info *bi, SQLHDBC dbh,
+extern int
+backsql_count_children( Operation *op, SQLHDBC dbh,
struct berval *dn, unsigned long *nchildren );
/* returns LDAP_COMPARE_TRUE/LDAP_COMPARE_FALSE if the entry corresponding
* to DN has/has not children */
-int backsql_has_children( backsql_info *bi, SQLHDBC dbh, struct berval *dn );
+extern int
+backsql_has_children( Operation *op, SQLHDBC dbh, struct berval *dn );
-/* frees *id and returns next in list */
-backsql_entryID *backsql_free_entryID( backsql_entryID *id, int freeit );
+/* free *id and return next in list */
+extern backsql_entryID *
+backsql_free_entryID( backsql_entryID *id, int freeit, void *ctx );
-/* turns an ID into an entry */
-int backsql_id2entry( backsql_srch_info *bsi, backsql_entryID *id );
+/* turn an ID into an entry */
+extern int
+backsql_id2entry( backsql_srch_info *bsi, backsql_entryID *id );
+
+/* duplicate an entryID */
+extern backsql_entryID *
+backsql_entryID_dup( backsql_entryID *eid, void *ctx );
/*
* operational.c
* search.c
*/
-/* the function must collect the entry associated to nbase */
-#define BACKSQL_ISF_GET_ID 0x1U
int backsql_init_search( backsql_srch_info *bsi,
- struct berval *nbase, int scope, int slimit, int tlimit,
+ struct berval *nbase, int scope,
time_t stoptime, Filter *filter, SQLHDBC dbh,
Operation *op, SlapReply *rs, AttributeName *attrs,
unsigned flags );
+void backsql_entry_clean( Operation *op, Entry *e );
+
/*
* sql-wrap.h
*/
-RETCODE backsql_Prepare( SQLHDBC dbh, SQLHSTMT *sth, char* query, int timeout );
+RETCODE backsql_Prepare( SQLHDBC dbh, SQLHSTMT *sth, const char* query, int timeout );
#define backsql_BindParamStr( sth, par_ind, io, str, maxlen ) \
SQLBindParameter( (sth), (SQLUSMALLINT)(par_ind), \
(io), SQL_C_CHAR, SQL_VARCHAR, \
- (SQLUINTEGER)(maxlen), 0, (SQLPOINTER)(str), \
- (SQLUINTEGER)(maxlen), NULL )
+ (SQLULEN)(maxlen), 0, (SQLPOINTER)(str), \
+ (SQLLEN)(maxlen), NULL )
#define backsql_BindParamBerVal( sth, par_ind, io, bv ) \
SQLBindParameter( (sth), (SQLUSMALLINT)(par_ind), \
(io), SQL_C_CHAR, SQL_VARCHAR, \
- (SQLUINTEGER)(bv)->bv_len, 0, \
+ (SQLULEN)(bv)->bv_len, 0, \
(SQLPOINTER)(bv)->bv_val, \
- (SQLUINTEGER)(bv)->bv_len, NULL )
+ (SQLLEN)(bv)->bv_len, NULL )
#define backsql_BindParamInt( sth, par_ind, io, val ) \
SQLBindParameter( (sth), (SQLUSMALLINT)(par_ind), \
(io), SQL_C_ULONG, SQL_INTEGER, \
- 0, 0, (SQLPOINTER)(val), 0, (SQLINTEGER*)NULL )
+ 0, 0, (SQLPOINTER)(val), 0, (SQLLEN*)NULL )
+
+#define backsql_BindParamNumID( sth, par_ind, io, val ) \
+ SQLBindParameter( (sth), (SQLUSMALLINT)(par_ind), \
+ (io), BACKSQL_C_NUMID, SQL_INTEGER, \
+ 0, 0, (SQLPOINTER)(val), 0, (SQLLEN*)NULL )
#ifdef BACKSQL_ARBITRARY_KEY
#define backsql_BindParamID( sth, par_ind, io, id ) \
backsql_BindParamBerVal( (sth), (par_ind), (io), (id) )
#else /* ! BACKSQL_ARBITRARY_KEY */
#define backsql_BindParamID( sth, par_ind, io, id ) \
- backsql_BindParamInt( (sth), (par_ind), (io), (id) )
+ backsql_BindParamNumID( (sth), (par_ind), (io), (id) )
#endif /* ! BACKSQL_ARBITRARY_KEY */
+RETCODE backsql_BindRowAsStrings_x( SQLHSTMT sth, BACKSQL_ROW_NTS *row, void *ctx );
+
RETCODE backsql_BindRowAsStrings( SQLHSTMT sth, BACKSQL_ROW_NTS *row );
+RETCODE backsql_FreeRow_x( BACKSQL_ROW_NTS *row, void *ctx );
+
RETCODE backsql_FreeRow( BACKSQL_ROW_NTS *row );
void backsql_PrintErrors( SQLHENV henv, SQLHDBC hdbc, SQLHSTMT sth, int rc );
+int backsql_conn_destroy( backsql_info *bi );
+
int backsql_init_db_env( backsql_info *si );
int backsql_free_db_env( backsql_info *si );
-int backsql_get_db_conn( Operation *op, SQLHDBC *dbh );
+int backsql_get_db_conn( Operation *op, SQLHDBC *dbh );
-int backsql_free_db_conn( Operation *op );
+int backsql_free_db_conn( Operation *op, SQLHDBC dbh );
/*
* util.c
*/
-extern char
+extern const char
backsql_def_oc_query[],
backsql_def_needs_select_oc_query[],
backsql_def_at_query[],
- backsql_def_delentry_query[],
- backsql_def_insentry_query[],
- backsql_def_delobjclasses_query[],
- backsql_def_delreferrals_query[],
+ backsql_def_delentry_stmt[],
+ backsql_def_renentry_stmt[],
+ backsql_def_insentry_stmt[],
+ backsql_def_delobjclasses_stmt[],
backsql_def_subtree_cond[],
backsql_def_upper_subtree_cond[],
backsql_id_query[],
- backsql_def_concat_func[];
-extern char
+ backsql_def_concat_func[],
backsql_check_dn_ru_query[];
-struct berbuf * backsql_strcat( struct berbuf *dest, ... );
-struct berbuf * backsql_strfcat( struct berbuf *dest, const char *fmt, ... );
+struct berbuf * backsql_strcat_x( struct berbuf *dest, void *memctx, ... );
+struct berbuf * backsql_strfcat_x( struct berbuf *dest, void *memctx, const char *fmt, ... );
-int backsql_entry_addattr( Entry *e, struct berval *at_name,
+int backsql_entry_addattr( Entry *e, AttributeDescription *ad,
struct berval *at_val, void *memctx );
-int backsql_merge_from_clause( struct berbuf *dest_from,
+int backsql_merge_from_clause( backsql_info *bi, struct berbuf *dest_from,
struct berval *src_from );
int backsql_split_pattern( const char *pattern, BerVarray *split_pattern,
extern BI_operational backsql_operational;
extern BI_entry_get_rw backsql_entry_get;
+extern BI_entry_release_rw backsql_entry_release;
extern BI_connection_destroy backsql_connection_destroy;