2009-02-24 01:35:49 +03:00
# include "ldb_includes.h"
2004-11-16 12:00:52 +03:00
# include "tdb.h"
2009-01-30 02:39:30 +03:00
# include "ldb_module.h"
2004-03-31 10:45:39 +04:00
/* this private structure is used by the ltdb backend in the
ldb_context */
struct ltdb_private {
TDB_CONTEXT * tdb ;
unsigned int connect_flags ;
2004-05-01 13:45:56 +04:00
2006-09-21 10:44:12 +04:00
unsigned long long sequence_number ;
2004-05-01 13:45:56 +04:00
2006-10-19 01:45:46 +04:00
/* the low level tdb seqnum - used to avoid loading BASEINFO when
possible */
int tdb_seqnum ;
2005-01-02 10:49:29 +03:00
struct ltdb_cache {
struct ldb_message * indexlist ;
struct ldb_message * attributes ;
2009-10-21 15:21:26 +04:00
bool one_level_indexes ;
bool attribute_indexes ;
2004-05-01 13:45:56 +04:00
struct {
char * name ;
int flags ;
} last_attribute ;
2005-01-02 10:49:29 +03:00
} * cache ;
2007-10-18 04:03:21 +04:00
int in_transaction ;
2007-11-15 03:53:44 +03:00
bool check_base ;
2008-12-16 10:45:28 +03:00
struct ltdb_idxptr * idxptr ;
2009-03-31 08:07:54 +04:00
bool prepared_commit ;
2009-12-09 06:37:26 +03:00
int read_lock_count ;
2004-03-31 10:45:39 +04:00
} ;
2006-03-03 20:44:03 +03:00
/*
the async local context
holds also internal search state during a full db search
*/
2009-03-10 01:04:38 +03:00
struct ltdb_req_spy {
struct ltdb_context * ctx ;
} ;
2006-07-22 20:56:33 +04:00
struct ltdb_context {
2006-03-03 20:44:03 +03:00
struct ldb_module * module ;
2008-09-12 02:34:11 +04:00
struct ldb_request * req ;
2009-03-10 01:04:38 +03:00
bool request_terminated ;
struct ltdb_req_spy * spy ;
2006-03-03 20:44:03 +03:00
/* search stuff */
2006-08-22 22:09:49 +04:00
const struct ldb_parse_tree * tree ;
2006-11-22 03:59:34 +03:00
struct ldb_dn * base ;
2006-03-03 20:44:03 +03:00
enum ldb_scope scope ;
const char * const * attrs ;
2008-12-29 22:24:57 +03:00
struct tevent_timer * timeout_event ;
2006-03-03 20:44:03 +03:00
} ;
2004-05-01 13:45:56 +04:00
/* special record types */
# define LTDB_INDEX "@INDEX"
# define LTDB_INDEXLIST "@INDEXLIST"
# define LTDB_IDX "@IDX"
2009-10-21 15:21:26 +04:00
# define LTDB_IDXVERSION "@IDXVERSION"
2004-05-01 13:45:56 +04:00
# define LTDB_IDXATTR "@IDXATTR"
2006-12-11 18:49:39 +03:00
# define LTDB_IDXONE "@IDXONE"
2004-05-01 13:45:56 +04:00
# define LTDB_BASEINFO "@BASEINFO"
2007-11-15 03:53:44 +03:00
# define LTDB_OPTIONS "@OPTIONS"
2004-05-01 13:45:56 +04:00
# define LTDB_ATTRIBUTES "@ATTRIBUTES"
/* special attribute types */
# define LTDB_SEQUENCE_NUMBER "sequenceNumber"
2007-11-15 03:53:44 +03:00
# define LTDB_CHECK_BASE "checkBaseOnSearch"
2006-09-21 10:44:12 +04:00
# define LTDB_MOD_TIMESTAMP "whenChanged"
2004-05-01 13:45:56 +04:00
# define LTDB_OBJECTCLASS "objectClass"
2004-11-16 12:00:52 +03:00
/* The following definitions come from lib/ldb/ldb_tdb/ldb_cache.c */
2005-01-02 10:49:29 +03:00
int ltdb_cache_reload ( struct ldb_module * module ) ;
2004-11-16 12:00:52 +03:00
int ltdb_cache_load ( struct ldb_module * module ) ;
int ltdb_increase_sequence_number ( struct ldb_module * module ) ;
2005-05-18 01:43:47 +04:00
int ltdb_check_at_attributes_values ( const struct ldb_val * value ) ;
2004-11-16 12:00:52 +03:00
/* The following definitions come from lib/ldb/ldb_tdb/ldb_index.c */
struct ldb_parse_tree ;
2009-09-15 21:00:24 +04:00
int ltdb_search_indexed ( struct ltdb_context * ctx , uint32_t * ) ;
2009-10-21 15:21:26 +04:00
int ltdb_index_add_new ( struct ldb_module * module , const struct ldb_message * msg ) ;
int ltdb_index_delete ( struct ldb_module * module , const struct ldb_message * msg ) ;
2009-11-18 12:44:56 +03:00
int ltdb_index_del_element ( struct ldb_module * module , struct ldb_dn * dn ,
struct ldb_message_element * el ) ;
2009-10-21 15:21:26 +04:00
int ltdb_index_add_element ( struct ldb_module * module , struct ldb_dn * dn ,
struct ldb_message_element * el ) ;
2009-11-18 12:44:56 +03:00
int ltdb_index_del_value ( struct ldb_module * module , struct ldb_dn * dn ,
2009-11-06 20:35:17 +03:00
struct ldb_message_element * el , unsigned int v_idx ) ;
2004-11-16 12:00:52 +03:00
int ltdb_reindex ( struct ldb_module * module ) ;
2008-12-16 10:45:28 +03:00
int ltdb_index_transaction_start ( struct ldb_module * module ) ;
int ltdb_index_transaction_commit ( struct ldb_module * module ) ;
int ltdb_index_transaction_cancel ( struct ldb_module * module ) ;
2004-11-16 12:00:52 +03:00
/* The following definitions come from lib/ldb/ldb_tdb/ldb_pack.c */
int ltdb_pack_data ( struct ldb_module * module ,
const struct ldb_message * message ,
struct TDB_DATA * data ) ;
void ltdb_unpack_data_free ( struct ldb_module * module ,
struct ldb_message * message ) ;
int ltdb_unpack_data ( struct ldb_module * module ,
const struct TDB_DATA * data ,
struct ldb_message * message ) ;
/* The following definitions come from lib/ldb/ldb_tdb/ldb_search.c */
int ltdb_has_wildcard ( struct ldb_module * module , const char * attr_name ,
const struct ldb_val * val ) ;
void ltdb_search_dn1_free ( struct ldb_module * module , struct ldb_message * msg ) ;
2006-11-22 03:59:34 +03:00
int ltdb_search_dn1 ( struct ldb_module * module , struct ldb_dn * dn , struct ldb_message * msg ) ;
2006-01-31 14:16:43 +03:00
int ltdb_add_attr_results ( struct ldb_module * module ,
TALLOC_CTX * mem_ctx ,
struct ldb_message * msg ,
2004-11-16 12:00:52 +03:00
const char * const attrs [ ] ,
2005-11-08 03:11:45 +03:00
unsigned int * count ,
2004-11-16 12:00:52 +03:00
struct ldb_message * * * res ) ;
2006-03-03 20:44:03 +03:00
int ltdb_filter_attrs ( struct ldb_message * msg , const char * const * attrs ) ;
2008-09-12 02:34:11 +04:00
int ltdb_search ( struct ltdb_context * ctx ) ;
2004-11-16 12:00:52 +03:00
/* The following definitions come from lib/ldb/ldb_tdb/ldb_tdb.c */
2008-10-15 22:03:20 +04:00
int ltdb_lock_read ( struct ldb_module * module ) ;
int ltdb_unlock_read ( struct ldb_module * module ) ;
2006-11-22 03:59:34 +03:00
struct TDB_DATA ltdb_key ( struct ldb_module * module , struct ldb_dn * dn ) ;
2004-11-16 12:00:52 +03:00
int ltdb_store ( struct ldb_module * module , const struct ldb_message * msg , int flgs ) ;
2009-12-19 12:55:11 +03:00
int ltdb_modify_internal ( struct ldb_module * module , const struct ldb_message * msg , struct ldb_request * req ) ;
2009-10-22 04:06:33 +04:00
int ltdb_delete_noindex ( struct ldb_module * module , struct ldb_dn * dn ) ;
int ltdb_err_map ( enum TDB_ERROR tdb_code ) ;
2004-11-16 12:00:52 +03:00
2005-07-20 04:59:38 +04:00
struct tdb_context * ltdb_wrap_open ( TALLOC_CTX * mem_ctx ,
const char * path , int hash_size , int tdb_flags ,
2006-07-03 10:40:56 +04:00
int open_flags , mode_t mode ,
struct ldb_context * ldb ) ;