back-bdb.h 1.93 KB
Newer Older
1
/* back-bdb.h - bdb back-end header file */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
2
3
/* $OpenLDAP$ */
/*
4
 * Copyright 2000-2001 The OpenLDAP Foundation, All Rights Reserved.
Kurt Zeilenga's avatar
Kurt Zeilenga committed
5
6
7
8
9
10
11
12
13
 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 */

#ifndef _BACK_BDB_H_
#define _BACK_BDB_H_

#include <portable.h>
#include <db.h>

14
15
#include "slap.h"

Kurt Zeilenga's avatar
Kurt Zeilenga committed
16
17
LDAP_BEGIN_DECL

18
#define BDB_FILTER_INDICES 1
Kurt Zeilenga's avatar
Kurt Zeilenga committed
19

Kurt Zeilenga's avatar
Kurt Zeilenga committed
20
21
22
23
#define DN_BASE_PREFIX		SLAP_INDEX_EQUALITY_PREFIX
#define DN_ONE_PREFIX	 	'%'
#define DN_SUBTREE_PREFIX 	'@'

24
25
26
27
28
29
#define DBTzero(t)			(memset((t), 0, sizeof(DBT)))
#define DBT2bv(t,bv)		((bv)->bv_val = (t)->data, \
								(bv)->bv_len = (t)->size)
#define bv2DBT(bv,t)		((t)->data = (bv)->bv_val, \
								(t)->size = (bv)->bv_len )

Kurt Zeilenga's avatar
Kurt Zeilenga committed
30
#define DEFAULT_MODE		0600
Kurt Zeilenga's avatar
Kurt Zeilenga committed
31

Kurt Zeilenga's avatar
Kurt Zeilenga committed
32
33
#define BDB_TXN_RETRIES	16

34
#define BDB_DBENV_HOME	LDAP_RUNDIR LDAP_DIRSEP "openldap-bdb"
Kurt Zeilenga's avatar
Kurt Zeilenga committed
35

36
#ifdef BDB_SUBDIRS
37
38
39
#define BDB_TMP_SUBDIR	LDAP_DIRSEP "tmp"
#define BDB_LG_SUBDIR	LDAP_DIRSEP "log"
#define BDB_DATA_SUBDIR	LDAP_DIRSEP "data"
40
#endif
Kurt Zeilenga's avatar
Kurt Zeilenga committed
41

42
#define BDB_SUFFIX		".bdb"
43
44
45
#define BDB_ID2ENTRY	0
#define BDB_DN2ID		1
#define BDB_NDB			2
46
47

#define BDB_INDICES		128
48
49

struct bdb_db_info {
50
	char		*bdi_name;
51
52
53
54
55
56
	DB			*bdi_db;
};

struct bdb_info {
	DB_ENV		*bi_dbenv;

57
58
	/* DB_ENV parameters */
	/* The DB_ENV can be tuned via DB_CONFIG */
59
60
61
62
63
	char		*bi_dbenv_home;
	u_int32_t	bi_dbenv_xflags; /* extra flags */
	int			bi_dbenv_mode;

	int			bi_ndatabases;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
64
	struct bdb_db_info **bi_databases;
65
66
67
68
	ldap_pvt_thread_mutex_t	bi_database_mutex;

	slap_mask_t	bi_defaultmask;
	Avlnode		*bi_attrs;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
69

70
	int		bi_txn;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
71
72
73
	int			bi_txn_cp;
	u_int32_t	bi_txn_cp_min;
	u_int32_t	bi_txn_cp_kbyte;
74
75
76
77
78
79

#ifndef NO_THREADS
	int			bi_lock_detect;
	int			bi_lock_detect_seconds;
	ldap_pvt_thread_t	bi_lock_detect_tid;
#endif
80
81

	ID			bi_lastid;
82
	ldap_pvt_thread_mutex_t	bi_lastid_mutex;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
83
};
84

85
#define bi_id2entry	bi_databases[BDB_ID2ENTRY]
Kurt Zeilenga's avatar
Kurt Zeilenga committed
86
#define bi_dn2id	bi_databases[BDB_DN2ID]
Kurt Zeilenga's avatar
Kurt Zeilenga committed
87

88
89
90
91
92
93
struct bdb_op_info {
	BackendDB*	boi_bdb;
	DB_TXN*		boi_txn;
	int			boi_err;
};

Kurt Zeilenga's avatar
Kurt Zeilenga committed
94
95
LDAP_END_DECL

Kurt Zeilenga's avatar
Kurt Zeilenga committed
96
97
#include "proto-bdb.h"

Kurt Zeilenga's avatar
Kurt Zeilenga committed
98
#endif /* _BACK_BDB_H_ */