1 /* $NetBSD: back-wt.h,v 1.3 2025/09/05 21:16:31 christos Exp $ */ 2 3 /* OpenLDAP WiredTiger backend */ 4 /* $OpenLDAP$ */ 5 /* This work is part of OpenLDAP Software <http://www.openldap.org/>. 6 * 7 * Copyright 2002-2024 The OpenLDAP Foundation. 8 * All rights reserved. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted only as authorized by the OpenLDAP 12 * Public License. 13 * 14 * A copy of this license is available in the file LICENSE in the 15 * top-level directory of the distribution or, alternatively, at 16 * <http://www.OpenLDAP.org/license.html>. 17 */ 18 /* ACKNOWLEDGEMENTS: 19 * This work was developed by HAMANO Tsukasa <hamano (at) osstech.co.jp> 20 * based on back-bdb for inclusion in OpenLDAP Software. 21 * WiredTiger is a product of MongoDB Inc. 22 */ 23 24 #ifndef _BACK_WT_H_ 25 #define _BACK_WT_H_ 26 27 #include <portable.h> 28 29 #include <ac/errno.h> 30 #include <sys/stat.h> 31 32 #include "slap.h" 33 #include "wiredtiger.h" 34 35 /* The default search IDL stack cache depth */ 36 #define DEFAULT_SEARCH_STACK_DEPTH 16 37 38 #define WT_CONFIG_MAX 2048 39 40 struct wt_info { 41 WT_CONNECTION *wi_conn; 42 WT_CONNECTION *wi_cache; 43 char *wi_home; 44 char *wi_config; 45 ID wi_lastid; 46 47 slap_mask_t wi_defaultmask; 48 int wi_nattrs; 49 struct wt_attrinfo **wi_attrs; 50 void *wi_search_stack; 51 int wi_search_stack_depth; 52 53 struct re_s *wi_index_task; 54 55 int wi_flags; 56 #define WT_IS_OPEN 0x01 57 #define WT_OPEN_INDEX 0x02 58 #define WT_DEL_INDEX 0x08 59 #define WT_RE_OPEN 0x10 60 #define WT_NEED_UPGRADE 0x20 61 #define WT_USE_IDLCACHE 0x40 62 }; 63 64 #define WT_TABLE_ID2ENTRY "table:id2entry" 65 #define WT_TABLE_DN2ID "table:dn2id" 66 67 #define WT_INDEX_DN "index:id2entry:dn" 68 #define WT_INDEX_NDN "index:dn2id:ndn" 69 #define WT_INDEX_PID "index:dn2id:pid" 70 /* Currently, revdn is primary key, the revdn index is obsolete. */ 71 #define WT_INDEX_REVDN "index:dn2id:revdn" 72 73 /* table for cache */ 74 #define WT_TABLE_IDLCACHE "table:idlcache" 75 76 #define ITEMzero(item) (memset((item), 0, sizeof(WT_ITEM))) 77 #define ITEM2bv(item,bv) ((bv)->bv_val = (item)->data, \ 78 (bv)->bv_len = (item)->size) 79 #define bv2ITEM(bv,item) ((item)->data = (bv)->bv_val, \ 80 (item)->size = (bv)->bv_len ) 81 82 #define WT_INDEX_CACHE_SIZE 1024 83 84 typedef struct { 85 WT_SESSION *session; 86 int is_begin_transaction; 87 WT_CURSOR *dn2id; 88 WT_CURSOR *dn2id_w; 89 WT_CURSOR *dn2id_ndn; 90 WT_CURSOR *dn2entry; 91 WT_CURSOR *id2entry; 92 WT_CURSOR *id2entry_add; 93 WT_CURSOR *id2entry_update; 94 WT_SESSION *idlcache_session; 95 WT_CURSOR *index_pid; 96 } wt_ctx; 97 98 /* for the cache of attribute information (which are indexed, etc.) */ 99 typedef struct wt_attrinfo { 100 AttributeDescription *ai_desc; /* attribute description cn;lang-en */ 101 slap_mask_t ai_indexmask; /* how the attr is indexed */ 102 slap_mask_t ai_newmask; /* new settings to replace old mask */ 103 #ifdef LDAP_COMP_MATCH 104 ComponentReference* ai_cr; /*component indexing*/ 105 #endif 106 } AttrInfo; 107 108 /* These flags must not clash with SLAP_INDEX flags or ops in slap.h! */ 109 #define WT_INDEX_DELETING 0x8000U /* index is being modified */ 110 #define WT_INDEX_UPDATE_OP 0x03 /* performing an index update */ 111 112 #include "proto-wt.h" 113 114 #endif /* _BACK_WT_H_ */ 115 116 /* 117 * Local variables: 118 * indent-tabs-mode: t 119 * tab-width: 4 120 * c-basic-offset: 4 121 * End: 122 */ 123