back-bdb.h 1.97 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

Kurt Zeilenga's avatar
Kurt Zeilenga committed
18
/* #define BDB_FILTER_INDICES 1 */
19
/* #define SLAPD_USE_AD 1 */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
20

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

25
26
27
28
29
30
#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
31
#define DEFAULT_MODE		0600
Kurt Zeilenga's avatar
Kurt Zeilenga committed
32

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

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

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

43
#define BDB_SUFFIX		".bdb"
44
45
46
#define BDB_NEXTID		0
#define BDB_DN2ID		1
#define BDB_ID2ENTRY	2
47
48
49
#define BDB_NDB			3

#define BDB_INDICES		128
50
51

struct bdb_db_info {
52
	char		*bdi_name;
53
54
55
56
57
58
	DB			*bdi_db;
};

struct bdb_info {
	DB_ENV		*bi_dbenv;

59
60
	/* DB_ENV parameters */
	/* The DB_ENV can be tuned via DB_CONFIG */
61
62
63
64
65
	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
66
	struct bdb_db_info **bi_databases;
67
68
69
70
	ldap_pvt_thread_mutex_t	bi_database_mutex;

	slap_mask_t	bi_defaultmask;
	Avlnode		*bi_attrs;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
71
72
73
74

	int			bi_txn_cp;
	u_int32_t	bi_txn_cp_min;
	u_int32_t	bi_txn_cp_kbyte;
75
76
77
78
79
80

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

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

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

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

Kurt Zeilenga's avatar
Kurt Zeilenga committed
95
96
LDAP_END_DECL

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

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