db.h 124 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187
  1. /*
  2. * See the file LICENSE for redistribution information.
  3. *
  4. * Copyright (c) 1996, 2015 Oracle and/or its affiliates. All rights reserved.
  5. *
  6. * $Id$
  7. *
  8. * db.h include file layout:
  9. * General.
  10. * Database Environment.
  11. * Locking subsystem.
  12. * Logging subsystem.
  13. * Shared buffer cache (mpool) subsystem.
  14. * Transaction subsystem.
  15. * Access methods.
  16. * Access method cursors.
  17. * Dbm/Ndbm, Hsearch historic interfaces.
  18. */
  19. #ifndef _DB_H_
  20. #define _DB_H_
  21. #ifndef __NO_SYSTEM_INCLUDES
  22. #include <sys/types.h>
  23. #include <inttypes.h>
  24. #include <stdint.h>
  25. #include <stddef.h>
  26. #include <stdio.h>
  27. #include <unistd.h>
  28. #include <pthread.h>
  29. #endif
  30. #if defined(__cplusplus)
  31. extern "C" {
  32. #endif
  33. #undef __P
  34. #define __P(protos) protos
  35. /*
  36. * Berkeley DB version information.
  37. */
  38. #define DB_VERSION_FAMILY 12
  39. #define DB_VERSION_RELEASE 1
  40. #define DB_VERSION_MAJOR 6
  41. #define DB_VERSION_MINOR 0
  42. #define DB_VERSION_PATCH 35
  43. #define DB_VERSION_STRING "Berkeley DB 6.0.35: (February 26, 2015)"
  44. #define DB_VERSION_FULL_STRING "Berkeley DB 12c Release 1, library version 12.1.6.0.35: (February 26, 2015)"
  45. /*
  46. * !!!
  47. * Berkeley DB uses specifically sized types. If they're not provided by
  48. * the system, typedef them here.
  49. *
  50. * We protect them against multiple inclusion using __BIT_TYPES_DEFINED__,
  51. * as does BIND and Kerberos, since we don't know for sure what #include
  52. * files the user is using.
  53. *
  54. * !!!
  55. * We also provide the standard u_int, u_long etc., if they're not provided
  56. * by the system.
  57. */
  58. #ifndef __BIT_TYPES_DEFINED__
  59. #define __BIT_TYPES_DEFINED__
  60. #endif
  61. /*
  62. * Missing ANSI types.
  63. *
  64. * uintmax_t --
  65. * Largest unsigned type, used to align structures in memory. We don't store
  66. * floating point types in structures, so integral types should be sufficient
  67. * (and we don't have to worry about systems that store floats in other than
  68. * power-of-2 numbers of bytes). Additionally this fixes compilers that rewrite
  69. * structure assignments and ANSI C memcpy calls to be in-line instructions
  70. * that happen to require alignment.
  71. *
  72. * uintptr_t --
  73. * Unsigned type that's the same size as a pointer. There are places where
  74. * DB modifies pointers by discarding the bottom bits to guarantee alignment.
  75. * We can't use uintmax_t, it may be larger than the pointer, and compilers
  76. * get upset about that. So far we haven't run on any machine where there's
  77. * no unsigned type the same size as a pointer -- here's hoping.
  78. */
  79. typedef int db_off_t;
  80. #ifdef HAVE_MIXED_SIZE_ADDRESSING
  81. typedef u_int32_t db_size_t;
  82. #else
  83. typedef size_t db_size_t;
  84. #endif
  85. #ifdef HAVE_MIXED_SIZE_ADDRESSING
  86. typedef int32_t db_ssize_t;
  87. #else
  88. typedef ssize_t db_ssize_t;
  89. #endif
  90. /*
  91. * Sequences are only available on machines with 64-bit integral types.
  92. */
  93. typedef long long db_seq_t;
  94. /* Thread and process identification. */
  95. typedef pthread_t db_threadid_t;
  96. /* Basic types that are exported or quasi-exported. */
  97. typedef u_int32_t db_pgno_t; /* Page number type. */
  98. typedef u_int16_t db_indx_t; /* Page offset type. */
  99. #define DB_MAX_PAGES 0xffffffff /* >= # of pages in a file */
  100. typedef u_int32_t db_recno_t; /* Record number type. */
  101. #define DB_MAX_RECORDS 0xffffffff /* >= # of records in a tree */
  102. typedef u_int32_t db_timeout_t; /* Type of a timeout. */
  103. /*
  104. * Region offsets are the difference between a pointer in a region and the
  105. * region's base address. With private environments, both addresses are the
  106. * result of calling malloc, and we can't assume anything about what malloc
  107. * will return, so region offsets have to be able to hold differences between
  108. * arbitrary pointers.
  109. */
  110. typedef db_size_t roff_t;
  111. /*
  112. * Forward structure declarations, so we can declare pointers and
  113. * applications can get type checking.
  114. */
  115. struct __channel; typedef struct __channel CHANNEL;
  116. struct __db; typedef struct __db DB;
  117. struct __db_bt_stat; typedef struct __db_bt_stat DB_BTREE_STAT;
  118. struct __db_channel; typedef struct __db_channel DB_CHANNEL;
  119. struct __db_cipher; typedef struct __db_cipher DB_CIPHER;
  120. struct __db_compact; typedef struct __db_compact DB_COMPACT;
  121. struct __db_dbt; typedef struct __db_dbt DBT;
  122. struct __db_distab; typedef struct __db_distab DB_DISTAB;
  123. struct __db_env; typedef struct __db_env DB_ENV;
  124. struct __db_h_stat; typedef struct __db_h_stat DB_HASH_STAT;
  125. struct __db_heap_rid; typedef struct __db_heap_rid DB_HEAP_RID;
  126. struct __db_heap_stat; typedef struct __db_heap_stat DB_HEAP_STAT;
  127. struct __db_ilock; typedef struct __db_ilock DB_LOCK_ILOCK;
  128. struct __db_lock_hstat; typedef struct __db_lock_hstat DB_LOCK_HSTAT;
  129. struct __db_lock_pstat; typedef struct __db_lock_pstat DB_LOCK_PSTAT;
  130. struct __db_lock_stat; typedef struct __db_lock_stat DB_LOCK_STAT;
  131. struct __db_lock_u; typedef struct __db_lock_u DB_LOCK;
  132. struct __db_locker; typedef struct __db_locker DB_LOCKER;
  133. struct __db_lockreq; typedef struct __db_lockreq DB_LOCKREQ;
  134. struct __db_locktab; typedef struct __db_locktab DB_LOCKTAB;
  135. struct __db_log; typedef struct __db_log DB_LOG;
  136. struct __db_log_cursor; typedef struct __db_log_cursor DB_LOGC;
  137. struct __db_log_stat; typedef struct __db_log_stat DB_LOG_STAT;
  138. struct __db_lsn; typedef struct __db_lsn DB_LSN;
  139. struct __db_mpool; typedef struct __db_mpool DB_MPOOL;
  140. struct __db_mpool_fstat;typedef struct __db_mpool_fstat DB_MPOOL_FSTAT;
  141. struct __db_mpool_stat; typedef struct __db_mpool_stat DB_MPOOL_STAT;
  142. struct __db_mpoolfile; typedef struct __db_mpoolfile DB_MPOOLFILE;
  143. struct __db_mutex_stat; typedef struct __db_mutex_stat DB_MUTEX_STAT;
  144. struct __db_mutex_t; typedef struct __db_mutex_t DB_MUTEX;
  145. struct __db_mutexmgr; typedef struct __db_mutexmgr DB_MUTEXMGR;
  146. struct __db_preplist; typedef struct __db_preplist DB_PREPLIST;
  147. struct __db_qam_stat; typedef struct __db_qam_stat DB_QUEUE_STAT;
  148. struct __db_rep; typedef struct __db_rep DB_REP;
  149. struct __db_rep_stat; typedef struct __db_rep_stat DB_REP_STAT;
  150. struct __db_repmgr_conn_err;
  151. typedef struct __db_repmgr_conn_err DB_REPMGR_CONN_ERR;
  152. struct __db_repmgr_site;typedef struct __db_repmgr_site DB_REPMGR_SITE;
  153. struct __db_repmgr_stat;typedef struct __db_repmgr_stat DB_REPMGR_STAT;
  154. struct __db_seq_record; typedef struct __db_seq_record DB_SEQ_RECORD;
  155. struct __db_seq_stat; typedef struct __db_seq_stat DB_SEQUENCE_STAT;
  156. struct __db_stream; typedef struct __db_stream DB_STREAM;
  157. struct __db_site; typedef struct __db_site DB_SITE;
  158. struct __db_sequence; typedef struct __db_sequence DB_SEQUENCE;
  159. struct __db_thread_info;typedef struct __db_thread_info DB_THREAD_INFO;
  160. struct __db_txn; typedef struct __db_txn DB_TXN;
  161. struct __db_txn_active; typedef struct __db_txn_active DB_TXN_ACTIVE;
  162. struct __db_txn_stat; typedef struct __db_txn_stat DB_TXN_STAT;
  163. struct __db_txn_token; typedef struct __db_txn_token DB_TXN_TOKEN;
  164. struct __db_txnmgr; typedef struct __db_txnmgr DB_TXNMGR;
  165. struct __dbc; typedef struct __dbc DBC;
  166. struct __dbc_internal; typedef struct __dbc_internal DBC_INTERNAL;
  167. struct __env; typedef struct __env ENV;
  168. struct __fh_t; typedef struct __fh_t DB_FH;
  169. struct __fname; typedef struct __fname FNAME;
  170. struct __key_range; typedef struct __key_range DB_KEY_RANGE;
  171. struct __mpoolfile; typedef struct __mpoolfile MPOOLFILE;
  172. struct __db_logvrfy_config;
  173. typedef struct __db_logvrfy_config DB_LOG_VERIFY_CONFIG;
  174. /*
  175. * The Berkeley DB API flags are automatically-generated -- the following flag
  176. * names are no longer used, but remain for compatibility reasons.
  177. */
  178. #define DB_DEGREE_2 DB_READ_COMMITTED
  179. #define DB_DIRTY_READ DB_READ_UNCOMMITTED
  180. #define DB_JOINENV 0x0
  181. /* Key/data structure -- a Data-Base Thang. */
  182. struct __db_dbt {
  183. void *data; /* Key/data */
  184. u_int32_t size; /* key/data length */
  185. u_int32_t ulen; /* RO: length of user buffer. */
  186. u_int32_t dlen; /* RO: get/put record length. */
  187. u_int32_t doff; /* RO: get/put record offset. */
  188. void *app_data;
  189. #define DB_DBT_APPMALLOC 0x0001 /* Callback allocated memory. */
  190. #define DB_DBT_BULK 0x0002 /* Internal: Insert if duplicate. */
  191. #define DB_DBT_DUPOK 0x0004 /* Internal: Insert if duplicate. */
  192. #define DB_DBT_ISSET 0x0008 /* Lower level calls set value. */
  193. #define DB_DBT_MALLOC 0x0010 /* Return in malloc'd memory. */
  194. #define DB_DBT_MULTIPLE 0x0020 /* References multiple records. */
  195. #define DB_DBT_PARTIAL 0x0040 /* Partial put/get. */
  196. #define DB_DBT_REALLOC 0x0080 /* Return in realloc'd memory. */
  197. #define DB_DBT_READONLY 0x0100 /* Readonly, don't update. */
  198. #define DB_DBT_STREAMING 0x0200 /* Internal: DBT is being streamed. */
  199. #define DB_DBT_USERCOPY 0x0400 /* Use the user-supplied callback. */
  200. #define DB_DBT_USERMEM 0x0800 /* Return in user's memory. */
  201. #define DB_DBT_BLOB 0x1000 /* Data item is a blob. */
  202. #define DB_DBT_BLOB_REC 0x2000 /* Internal: Blob database record. */
  203. u_int32_t flags;
  204. };
  205. /*******************************************************
  206. * Mutexes.
  207. *******************************************************/
  208. /*
  209. * When mixed size addressing is supported mutexes need to be the same size
  210. * independent of the process address size is.
  211. */
  212. #ifdef HAVE_MIXED_SIZE_ADDRESSING
  213. typedef db_size_t db_mutex_t;
  214. #else
  215. typedef uintptr_t db_mutex_t;
  216. #endif
  217. struct __db_mutex_stat { /* SHARED */
  218. /* The following fields are maintained in the region's copy. */
  219. u_int32_t st_mutex_align; /* Mutex alignment */
  220. u_int32_t st_mutex_tas_spins; /* Mutex test-and-set spins */
  221. u_int32_t st_mutex_init; /* Initial mutex count */
  222. u_int32_t st_mutex_cnt; /* Mutex count */
  223. u_int32_t st_mutex_max; /* Mutex max */
  224. u_int32_t st_mutex_free; /* Available mutexes */
  225. u_int32_t st_mutex_inuse; /* Mutexes in use */
  226. u_int32_t st_mutex_inuse_max; /* Maximum mutexes ever in use */
  227. /* The following fields are filled-in from other places. */
  228. #ifndef __TEST_DB_NO_STATISTICS
  229. uintmax_t st_region_wait; /* Region lock granted after wait. */
  230. uintmax_t st_region_nowait; /* Region lock granted without wait. */
  231. roff_t st_regsize; /* Region size. */
  232. roff_t st_regmax; /* Region max. */
  233. #endif
  234. };
  235. /* This is the length of the buffer passed to DB_ENV->thread_id_string() */
  236. #define DB_THREADID_STRLEN 128
  237. /*******************************************************
  238. * Locking.
  239. *******************************************************/
  240. #define DB_LOCKVERSION 1
  241. #define DB_FILE_ID_LEN 20 /* Unique file ID length. */
  242. /*
  243. * Deadlock detector modes; used in the DB_ENV structure to configure the
  244. * locking subsystem.
  245. */
  246. #define DB_LOCK_NORUN 0
  247. #define DB_LOCK_DEFAULT 1 /* Default policy. */
  248. #define DB_LOCK_EXPIRE 2 /* Only expire locks, no detection. */
  249. #define DB_LOCK_MAXLOCKS 3 /* Select locker with max locks. */
  250. #define DB_LOCK_MAXWRITE 4 /* Select locker with max writelocks. */
  251. #define DB_LOCK_MINLOCKS 5 /* Select locker with min locks. */
  252. #define DB_LOCK_MINWRITE 6 /* Select locker with min writelocks. */
  253. #define DB_LOCK_OLDEST 7 /* Select oldest locker. */
  254. #define DB_LOCK_RANDOM 8 /* Select random locker. */
  255. #define DB_LOCK_YOUNGEST 9 /* Select youngest locker. */
  256. /*
  257. * Simple R/W lock modes and for multi-granularity intention locking.
  258. *
  259. * !!!
  260. * These values are NOT random, as they are used as an index into the lock
  261. * conflicts arrays, i.e., DB_LOCK_IWRITE must be == 3, and DB_LOCK_IREAD
  262. * must be == 4.
  263. */
  264. typedef enum {
  265. DB_LOCK_NG=0, /* Not granted. */
  266. DB_LOCK_READ=1, /* Shared/read. */
  267. DB_LOCK_WRITE=2, /* Exclusive/write. */
  268. DB_LOCK_WAIT=3, /* Wait for event */
  269. DB_LOCK_IWRITE=4, /* Intent exclusive/write. */
  270. DB_LOCK_IREAD=5, /* Intent to share/read. */
  271. DB_LOCK_IWR=6, /* Intent to read and write. */
  272. DB_LOCK_READ_UNCOMMITTED=7, /* Degree 1 isolation. */
  273. DB_LOCK_WWRITE=8 /* Was Written. */
  274. } db_lockmode_t;
  275. /*
  276. * Request types.
  277. */
  278. typedef enum {
  279. DB_LOCK_DUMP=0, /* Display held locks. */
  280. DB_LOCK_GET=1, /* Get the lock. */
  281. DB_LOCK_GET_TIMEOUT=2, /* Get lock with a timeout. */
  282. DB_LOCK_INHERIT=3, /* Pass locks to parent. */
  283. DB_LOCK_PUT=4, /* Release the lock. */
  284. DB_LOCK_PUT_ALL=5, /* Release locker's locks. */
  285. DB_LOCK_PUT_OBJ=6, /* Release locker's locks on obj. */
  286. DB_LOCK_PUT_READ=7, /* Release locker's read locks. */
  287. DB_LOCK_TIMEOUT=8, /* Force a txn to timeout. */
  288. DB_LOCK_TRADE=9, /* Trade locker ids on a lock. */
  289. DB_LOCK_UPGRADE_WRITE=10 /* Upgrade writes for dirty reads. */
  290. } db_lockop_t;
  291. /*
  292. * Status of a lock.
  293. */
  294. typedef enum {
  295. DB_LSTAT_ABORTED=1, /* Lock belongs to an aborted txn. */
  296. DB_LSTAT_EXPIRED=2, /* Lock has expired. */
  297. DB_LSTAT_FREE=3, /* Lock is unallocated. */
  298. DB_LSTAT_HELD=4, /* Lock is currently held. */
  299. DB_LSTAT_PENDING=5, /* Lock was waiting and has been
  300. * promoted; waiting for the owner
  301. * to run and upgrade it to held. */
  302. DB_LSTAT_WAITING=6 /* Lock is on the wait queue. */
  303. }db_status_t;
  304. /* Lock statistics structure. */
  305. struct __db_lock_stat { /* SHARED */
  306. u_int32_t st_id; /* Last allocated locker ID. */
  307. u_int32_t st_cur_maxid; /* Current maximum unused ID. */
  308. u_int32_t st_initlocks; /* Initial number of locks in table. */
  309. u_int32_t st_initlockers; /* Initial num of lockers in table. */
  310. u_int32_t st_initobjects; /* Initial num of objects in table. */
  311. u_int32_t st_locks; /* Current number of locks in table. */
  312. u_int32_t st_lockers; /* Current num of lockers in table. */
  313. u_int32_t st_objects; /* Current num of objects in table. */
  314. u_int32_t st_maxlocks; /* Maximum number of locks in table. */
  315. u_int32_t st_maxlockers; /* Maximum num of lockers in table. */
  316. u_int32_t st_maxobjects; /* Maximum num of objects in table. */
  317. u_int32_t st_partitions; /* number of partitions. */
  318. u_int32_t st_tablesize; /* Size of object hash table. */
  319. int32_t st_nmodes; /* Number of lock modes. */
  320. u_int32_t st_nlockers; /* Current number of lockers. */
  321. #ifndef __TEST_DB_NO_STATISTICS
  322. u_int32_t st_nlocks; /* Current number of locks. */
  323. u_int32_t st_maxnlocks; /* Maximum number of locks so far. */
  324. u_int32_t st_maxhlocks; /* Maximum number of locks in any bucket. */
  325. uintmax_t st_locksteals; /* Number of lock steals so far. */
  326. uintmax_t st_maxlsteals; /* Maximum number steals in any partition. */
  327. u_int32_t st_maxnlockers; /* Maximum number of lockers so far. */
  328. u_int32_t st_nobjects; /* Current number of objects. */
  329. u_int32_t st_maxnobjects; /* Maximum number of objects so far. */
  330. u_int32_t st_maxhobjects; /* Maximum number of objectsin any bucket. */
  331. uintmax_t st_objectsteals; /* Number of objects steals so far. */
  332. uintmax_t st_maxosteals; /* Maximum number of steals in any partition. */
  333. uintmax_t st_nrequests; /* Number of lock gets. */
  334. uintmax_t st_nreleases; /* Number of lock puts. */
  335. uintmax_t st_nupgrade; /* Number of lock upgrades. */
  336. uintmax_t st_ndowngrade; /* Number of lock downgrades. */
  337. uintmax_t st_lock_wait; /* Lock conflicts w/ subsequent wait */
  338. uintmax_t st_lock_nowait; /* Lock conflicts w/o subsequent wait */
  339. uintmax_t st_ndeadlocks; /* Number of lock deadlocks. */
  340. db_timeout_t st_locktimeout; /* Lock timeout. */
  341. uintmax_t st_nlocktimeouts; /* Number of lock timeouts. */
  342. db_timeout_t st_txntimeout; /* Transaction timeout. */
  343. uintmax_t st_ntxntimeouts; /* Number of transaction timeouts. */
  344. uintmax_t st_part_wait; /* Partition lock granted after wait. */
  345. uintmax_t st_part_nowait; /* Partition lock granted without wait. */
  346. uintmax_t st_part_max_wait; /* Max partition lock granted after wait. */
  347. uintmax_t st_part_max_nowait; /* Max partition lock granted without wait. */
  348. uintmax_t st_objs_wait; /* Object lock granted after wait. */
  349. uintmax_t st_objs_nowait; /* Object lock granted without wait. */
  350. uintmax_t st_lockers_wait; /* Locker lock granted after wait. */
  351. uintmax_t st_lockers_nowait; /* Locker lock granted without wait. */
  352. uintmax_t st_region_wait; /* Region lock granted after wait. */
  353. uintmax_t st_region_nowait; /* Region lock granted without wait. */
  354. uintmax_t st_nlockers_hit; /* Lockers found in thread info. */
  355. uintmax_t st_nlockers_reused; /* Lockers reallocated from thread info. */
  356. u_int32_t st_hash_len; /* Max length of bucket. */
  357. roff_t st_regsize; /* Region size. */
  358. #endif
  359. };
  360. struct __db_lock_hstat { /* SHARED */
  361. uintmax_t st_nrequests; /* Number of lock gets. */
  362. uintmax_t st_nreleases; /* Number of lock puts. */
  363. uintmax_t st_nupgrade; /* Number of lock upgrades. */
  364. uintmax_t st_ndowngrade; /* Number of lock downgrades. */
  365. u_int32_t st_nlocks; /* Current number of locks. */
  366. u_int32_t st_maxnlocks; /* Maximum number of locks so far. */
  367. u_int32_t st_nobjects; /* Current number of objects. */
  368. u_int32_t st_maxnobjects; /* Maximum number of objects so far. */
  369. uintmax_t st_lock_wait; /* Lock conflicts w/ subsequent wait */
  370. uintmax_t st_lock_nowait; /* Lock conflicts w/o subsequent wait */
  371. uintmax_t st_nlocktimeouts; /* Number of lock timeouts. */
  372. uintmax_t st_ntxntimeouts; /* Number of transaction timeouts. */
  373. u_int32_t st_hash_len; /* Max length of bucket. */
  374. };
  375. struct __db_lock_pstat { /* SHARED */
  376. u_int32_t st_nlocks; /* Current number of locks. */
  377. u_int32_t st_maxnlocks; /* Maximum number of locks so far. */
  378. u_int32_t st_nobjects; /* Current number of objects. */
  379. u_int32_t st_maxnobjects; /* Maximum number of objects so far. */
  380. uintmax_t st_locksteals; /* Number of lock steals so far. */
  381. uintmax_t st_objectsteals; /* Number of objects steals so far. */
  382. };
  383. /*
  384. * DB_LOCK_ILOCK --
  385. * Internal DB access method lock.
  386. */
  387. struct __db_ilock { /* SHARED */
  388. db_pgno_t pgno; /* Page being locked. */
  389. u_int8_t fileid[DB_FILE_ID_LEN];/* File id. */
  390. #define DB_HANDLE_LOCK 1
  391. #define DB_RECORD_LOCK 2
  392. #define DB_PAGE_LOCK 3
  393. #define DB_DATABASE_LOCK 4
  394. u_int32_t type; /* Type of lock. */
  395. };
  396. /*
  397. * DB_LOCK --
  398. * The structure is allocated by the caller and filled in during a
  399. * lock_get request (or a lock_vec/DB_LOCK_GET).
  400. */
  401. struct __db_lock_u { /* SHARED */
  402. roff_t off; /* Offset of the lock in the region */
  403. u_int32_t ndx; /* Index of the object referenced by
  404. * this lock; used for locking. */
  405. u_int32_t gen; /* Generation number of this lock. */
  406. db_lockmode_t mode; /* mode of this lock. */
  407. };
  408. /* Lock request structure. */
  409. struct __db_lockreq {
  410. db_lockop_t op; /* Operation. */
  411. db_lockmode_t mode; /* Requested mode. */
  412. db_timeout_t timeout; /* Time to expire lock. */
  413. DBT *obj; /* Object being locked. */
  414. DB_LOCK lock; /* Lock returned. */
  415. };
  416. /*******************************************************
  417. * Logging.
  418. *******************************************************/
  419. #define DB_LOGVERSION 21 /* Current log version. */
  420. #define DB_LOGVERSION_LATCHING 15 /* Log version using latching: db-4.8 */
  421. #define DB_LOGCHKSUM 12 /* Check sum headers: db-4.5 */
  422. #define DB_LOGOLDVER 8 /* Oldest version supported: db-4.2 */
  423. #define DB_LOGMAGIC 0x040988
  424. /*
  425. * A DB_LSN has two parts, a fileid which identifies a specific file, and an
  426. * offset within that file. The fileid is an unsigned 4-byte quantity that
  427. * uniquely identifies a file within the log directory -- currently a simple
  428. * counter inside the log. The offset is also an unsigned 4-byte value. The
  429. * log manager guarantees the offset is never more than 4 bytes by switching
  430. * to a new log file before the maximum length imposed by an unsigned 4-byte
  431. * offset is reached.
  432. */
  433. struct __db_lsn { /* SHARED */
  434. u_int32_t file; /* File ID. */
  435. u_int32_t offset; /* File offset. */
  436. };
  437. /*
  438. * Application-specified log record types start at DB_user_BEGIN, and must not
  439. * equal or exceed DB_debug_FLAG.
  440. *
  441. * DB_debug_FLAG is the high-bit of the u_int32_t that specifies a log record
  442. * type. If the flag is set, it's a log record that was logged for debugging
  443. * purposes only, even if it reflects a database change -- the change was part
  444. * of a non-durable transaction.
  445. */
  446. #define DB_user_BEGIN 10000
  447. #define DB_debug_FLAG 0x80000000
  448. /*
  449. * DB_LOGC --
  450. * Log cursor.
  451. */
  452. struct __db_log_cursor {
  453. ENV *env; /* Environment */
  454. DB_FH *fhp; /* File handle. */
  455. DB_LSN lsn; /* Cursor: LSN */
  456. u_int32_t len; /* Cursor: record length */
  457. u_int32_t prev; /* Cursor: previous record's offset */
  458. DBT dbt; /* Return DBT. */
  459. DB_LSN p_lsn; /* Persist LSN. */
  460. u_int32_t p_version; /* Persist version. */
  461. u_int8_t *bp; /* Allocated read buffer. */
  462. u_int32_t bp_size; /* Read buffer length in bytes. */
  463. u_int32_t bp_rlen; /* Read buffer valid data length. */
  464. DB_LSN bp_lsn; /* Read buffer first byte LSN. */
  465. u_int32_t bp_maxrec; /* Max record length in the log file. */
  466. /* DB_LOGC PUBLIC HANDLE LIST BEGIN */
  467. int (*close) __P((DB_LOGC *, u_int32_t));
  468. int (*get) __P((DB_LOGC *, DB_LSN *, DBT *, u_int32_t));
  469. int (*version) __P((DB_LOGC *, u_int32_t *, u_int32_t));
  470. /* DB_LOGC PUBLIC HANDLE LIST END */
  471. #define DB_LOG_DISK 0x01 /* Log record came from disk. */
  472. #define DB_LOG_LOCKED 0x02 /* Log region already locked */
  473. #define DB_LOG_SILENT_ERR 0x04 /* Turn-off error messages. */
  474. u_int32_t flags;
  475. };
  476. /* Log statistics structure. */
  477. struct __db_log_stat { /* SHARED */
  478. u_int32_t st_magic; /* Log file magic number. */
  479. u_int32_t st_version; /* Log file version number. */
  480. int32_t st_mode; /* Log file permissions mode. */
  481. u_int32_t st_lg_bsize; /* Log buffer size. */
  482. u_int32_t st_lg_size; /* Log file size. */
  483. u_int32_t st_wc_bytes; /* Bytes to log since checkpoint. */
  484. u_int32_t st_wc_mbytes; /* Megabytes to log since checkpoint. */
  485. u_int32_t st_fileid_init; /* Initial allocation for fileids. */
  486. #ifndef __TEST_DB_NO_STATISTICS
  487. u_int32_t st_nfileid; /* Current number of fileids. */
  488. u_int32_t st_maxnfileid; /* Maximum number of fileids used. */
  489. uintmax_t st_record; /* Records entered into the log. */
  490. u_int32_t st_w_bytes; /* Bytes to log. */
  491. u_int32_t st_w_mbytes; /* Megabytes to log. */
  492. uintmax_t st_wcount; /* Total I/O writes to the log. */
  493. uintmax_t st_wcount_fill; /* Overflow writes to the log. */
  494. uintmax_t st_rcount; /* Total I/O reads from the log. */
  495. uintmax_t st_scount; /* Total syncs to the log. */
  496. uintmax_t st_region_wait; /* Region lock granted after wait. */
  497. uintmax_t st_region_nowait; /* Region lock granted without wait. */
  498. u_int32_t st_cur_file; /* Current log file number. */
  499. u_int32_t st_cur_offset; /* Current log file offset. */
  500. u_int32_t st_disk_file; /* Known on disk log file number. */
  501. u_int32_t st_disk_offset; /* Known on disk log file offset. */
  502. u_int32_t st_maxcommitperflush; /* Max number of commits in a flush. */
  503. u_int32_t st_mincommitperflush; /* Min number of commits in a flush. */
  504. roff_t st_regsize; /* Region size. */
  505. #endif
  506. };
  507. /*
  508. * We need to record the first log record of a transaction. For user
  509. * defined logging this macro returns the place to put that information,
  510. * if it is need in rlsnp, otherwise it leaves it unchanged. We also
  511. * need to track the last record of the transaction, this returns the
  512. * place to put that info.
  513. */
  514. #define DB_SET_TXN_LSNP(txn, blsnp, llsnp) \
  515. ((txn)->set_txn_lsnp(txn, blsnp, llsnp))
  516. /*
  517. * Definition of the structure which specifies marshalling of log records.
  518. */
  519. typedef enum {
  520. LOGREC_Done,
  521. LOGREC_ARG,
  522. LOGREC_HDR,
  523. LOGREC_DATA,
  524. LOGREC_DB,
  525. LOGREC_DBOP,
  526. LOGREC_DBT,
  527. LOGREC_LOCKS,
  528. LOGREC_OP,
  529. LOGREC_PGDBT,
  530. LOGREC_PGDDBT,
  531. LOGREC_PGLIST,
  532. LOGREC_POINTER,
  533. LOGREC_TIME,
  534. LOGREC_LONGARG
  535. } log_rec_type_t;
  536. typedef const struct __log_rec_spec {
  537. log_rec_type_t type;
  538. u_int32_t offset;
  539. const char *name;
  540. const char fmt[4];
  541. } DB_LOG_RECSPEC;
  542. /*
  543. * Size of a DBT in a log record.
  544. */
  545. #define LOG_DBT_SIZE(dbt) \
  546. (sizeof(u_int32_t) + ((dbt) == NULL ? 0 : (dbt)->size))
  547. /*******************************************************
  548. * Shared buffer cache (mpool).
  549. *******************************************************/
  550. /* Priority values for DB_MPOOLFILE->{put,set_priority}. */
  551. typedef enum {
  552. DB_PRIORITY_UNCHANGED=0,
  553. DB_PRIORITY_VERY_LOW=1,
  554. DB_PRIORITY_LOW=2,
  555. DB_PRIORITY_DEFAULT=3,
  556. DB_PRIORITY_HIGH=4,
  557. DB_PRIORITY_VERY_HIGH=5
  558. } DB_CACHE_PRIORITY;
  559. /* Per-process DB_MPOOLFILE information. */
  560. struct __db_mpoolfile {
  561. DB_FH *fhp; /* Underlying file handle. */
  562. /*
  563. * !!!
  564. * The ref, pinref and q fields are protected by the region lock.
  565. */
  566. u_int32_t ref; /* Reference count. */
  567. u_int32_t pinref; /* Pinned block reference count. */
  568. /*
  569. * !!!
  570. * Explicit representations of structures from queue.h.
  571. * TAILQ_ENTRY(__db_mpoolfile) q;
  572. */
  573. struct {
  574. struct __db_mpoolfile *tqe_next;
  575. struct __db_mpoolfile **tqe_prev;
  576. } q; /* Linked list of DB_MPOOLFILE's. */
  577. /*
  578. * !!!
  579. * The rest of the fields (with the exception of the MP_FLUSH flag)
  580. * are not thread-protected, even when they may be modified at any
  581. * time by the application. The reason is the DB_MPOOLFILE handle
  582. * is single-threaded from the viewpoint of the application, and so
  583. * the only fields needing to be thread-protected are those accessed
  584. * by checkpoint or sync threads when using DB_MPOOLFILE structures
  585. * to flush buffers from the cache.
  586. */
  587. ENV *env; /* Environment */
  588. MPOOLFILE *mfp; /* Underlying MPOOLFILE. */
  589. u_int32_t clear_len; /* Cleared length on created pages. */
  590. u_int8_t /* Unique file ID. */
  591. fileid[DB_FILE_ID_LEN];
  592. int ftype; /* File type. */
  593. int32_t lsn_offset; /* LSN offset in page. */
  594. u_int32_t gbytes, bytes; /* Maximum file size. */
  595. DBT *pgcookie; /* Byte-string passed to pgin/pgout. */
  596. int32_t priority; /* Cache priority. */
  597. void *addr; /* Address of mmap'd region. */
  598. size_t len; /* Length of mmap'd region. */
  599. u_int32_t config_flags; /* Flags to DB_MPOOLFILE->set_flags. */
  600. /* DB_MPOOLFILE PUBLIC HANDLE LIST BEGIN */
  601. int (*close) __P((DB_MPOOLFILE *, u_int32_t));
  602. int (*get)
  603. __P((DB_MPOOLFILE *, db_pgno_t *, DB_TXN *, u_int32_t, void *));
  604. int (*get_clear_len) __P((DB_MPOOLFILE *, u_int32_t *));
  605. int (*get_fileid) __P((DB_MPOOLFILE *, u_int8_t *));
  606. int (*get_flags) __P((DB_MPOOLFILE *, u_int32_t *));
  607. int (*get_ftype) __P((DB_MPOOLFILE *, int *));
  608. int (*get_last_pgno) __P((DB_MPOOLFILE *, db_pgno_t *));
  609. int (*get_lsn_offset) __P((DB_MPOOLFILE *, int32_t *));
  610. int (*get_maxsize) __P((DB_MPOOLFILE *, u_int32_t *, u_int32_t *));
  611. int (*get_pgcookie) __P((DB_MPOOLFILE *, DBT *));
  612. int (*get_priority) __P((DB_MPOOLFILE *, DB_CACHE_PRIORITY *));
  613. int (*open) __P((DB_MPOOLFILE *, const char *, u_int32_t, int, size_t));
  614. int (*put) __P((DB_MPOOLFILE *, void *, DB_CACHE_PRIORITY, u_int32_t));
  615. int (*set_clear_len) __P((DB_MPOOLFILE *, u_int32_t));
  616. int (*set_fileid) __P((DB_MPOOLFILE *, u_int8_t *));
  617. int (*set_flags) __P((DB_MPOOLFILE *, u_int32_t, int));
  618. int (*set_ftype) __P((DB_MPOOLFILE *, int));
  619. int (*set_lsn_offset) __P((DB_MPOOLFILE *, int32_t));
  620. int (*set_maxsize) __P((DB_MPOOLFILE *, u_int32_t, u_int32_t));
  621. int (*set_pgcookie) __P((DB_MPOOLFILE *, DBT *));
  622. int (*set_priority) __P((DB_MPOOLFILE *, DB_CACHE_PRIORITY));
  623. int (*sync) __P((DB_MPOOLFILE *));
  624. /* DB_MPOOLFILE PUBLIC HANDLE LIST END */
  625. /*
  626. * MP_FILEID_SET, MP_OPEN_CALLED and MP_READONLY do not need to be
  627. * thread protected because they are initialized before the file is
  628. * linked onto the per-process lists, and never modified.
  629. *
  630. * MP_FLUSH is thread protected because it is potentially read/set by
  631. * multiple threads of control.
  632. */
  633. #define MP_FILEID_SET 0x001 /* Application supplied a file ID. */
  634. #define MP_FLUSH 0x002 /* Was used to flush a buffer. */
  635. #define MP_FOR_FLUSH 0x004 /* Was opened to flush a buffer. */
  636. #define MP_MULTIVERSION 0x008 /* Opened for multiversion access. */
  637. #define MP_OPEN_CALLED 0x010 /* File opened. */
  638. #define MP_READONLY 0x020 /* File is readonly. */
  639. #define MP_DUMMY 0x040 /* File is dummy for __memp_fput. */
  640. u_int32_t flags;
  641. };
  642. /* Mpool statistics structure. */
  643. struct __db_mpool_stat { /* SHARED */
  644. u_int32_t st_gbytes; /* Total cache size: GB. */
  645. u_int32_t st_bytes; /* Total cache size: B. */
  646. u_int32_t st_ncache; /* Number of cache regions. */
  647. u_int32_t st_max_ncache; /* Maximum number of regions. */
  648. db_size_t st_mmapsize; /* Maximum file size for mmap. */
  649. int32_t st_maxopenfd; /* Maximum number of open fd's. */
  650. int32_t st_maxwrite; /* Maximum buffers to write. */
  651. db_timeout_t st_maxwrite_sleep; /* Sleep after writing max buffers. */
  652. u_int32_t st_pages; /* Total number of pages. */
  653. #ifndef __TEST_DB_NO_STATISTICS
  654. u_int32_t st_map; /* Pages from mapped files. */
  655. uintmax_t st_cache_hit; /* Pages found in the cache. */
  656. uintmax_t st_cache_miss; /* Pages not found in the cache. */
  657. uintmax_t st_page_create; /* Pages created in the cache. */
  658. uintmax_t st_page_in; /* Pages read in. */
  659. uintmax_t st_page_out; /* Pages written out. */
  660. uintmax_t st_ro_evict; /* Clean pages forced from the cache. */
  661. uintmax_t st_rw_evict; /* Dirty pages forced from the cache. */
  662. uintmax_t st_page_trickle; /* Pages written by memp_trickle. */
  663. u_int32_t st_page_clean; /* Clean pages. */
  664. u_int32_t st_page_dirty; /* Dirty pages. */
  665. u_int32_t st_hash_buckets; /* Number of hash buckets. */
  666. u_int32_t st_hash_mutexes; /* Number of hash bucket mutexes. */
  667. u_int32_t st_pagesize; /* Assumed page size. */
  668. u_int32_t st_hash_searches; /* Total hash chain searches. */
  669. u_int32_t st_hash_longest; /* Longest hash chain searched. */
  670. uintmax_t st_hash_examined; /* Total hash entries searched. */
  671. uintmax_t st_hash_nowait; /* Hash lock granted with nowait. */
  672. uintmax_t st_hash_wait; /* Hash lock granted after wait. */
  673. uintmax_t st_hash_max_nowait; /* Max hash lock granted with nowait. */
  674. uintmax_t st_hash_max_wait; /* Max hash lock granted after wait. */
  675. uintmax_t st_region_nowait; /* Region lock granted with nowait. */
  676. uintmax_t st_region_wait; /* Region lock granted after wait. */
  677. uintmax_t st_mvcc_frozen; /* Buffers frozen. */
  678. uintmax_t st_mvcc_thawed; /* Buffers thawed. */
  679. uintmax_t st_mvcc_freed; /* Frozen buffers freed. */
  680. uintmax_t st_mvcc_reused; /* Outdated invisible buffers reused. */
  681. uintmax_t st_alloc; /* Number of page allocations. */
  682. uintmax_t st_alloc_buckets; /* Buckets checked during allocation. */
  683. uintmax_t st_alloc_max_buckets;/* Max checked during allocation. */
  684. uintmax_t st_alloc_pages; /* Pages checked during allocation. */
  685. uintmax_t st_alloc_max_pages; /* Max checked during allocation. */
  686. uintmax_t st_io_wait; /* Thread waited on buffer I/O. */
  687. uintmax_t st_sync_interrupted; /* Number of times sync interrupted. */
  688. u_int32_t st_oddfsize_detect; /* Odd file size detected. */
  689. u_int32_t st_oddfsize_resolve; /* Odd file size resolved. */
  690. roff_t st_regsize; /* Region size. */
  691. roff_t st_regmax; /* Region max. */
  692. #endif
  693. };
  694. /*
  695. * Mpool file statistics structure.
  696. * The first fields in this structure must mirror the __db_mpool_fstat_int
  697. * structure, since content is mem copied between the two.
  698. */
  699. struct __db_mpool_fstat {
  700. u_int32_t st_pagesize; /* Page size. */
  701. #ifndef __TEST_DB_NO_STATISTICS
  702. u_int32_t st_map; /* Pages from mapped files. */
  703. uintmax_t st_cache_hit; /* Pages found in the cache. */
  704. uintmax_t st_cache_miss; /* Pages not found in the cache. */
  705. uintmax_t st_page_create; /* Pages created in the cache. */
  706. uintmax_t st_page_in; /* Pages read in. */
  707. uintmax_t st_page_out; /* Pages written out. */
  708. uintmax_t st_backup_spins; /* Number of spins during a copy. */
  709. #endif
  710. char *file_name; /* File name. */
  711. };
  712. /*******************************************************
  713. * Transactions and recovery.
  714. *******************************************************/
  715. #define DB_TXNVERSION 1
  716. typedef enum {
  717. DB_TXN_ABORT=0, /* Public. */
  718. DB_TXN_APPLY=1, /* Public. */
  719. DB_TXN_BACKWARD_ROLL=3, /* Public. */
  720. DB_TXN_FORWARD_ROLL=4, /* Public. */
  721. DB_TXN_OPENFILES=5, /* Internal. */
  722. DB_TXN_POPENFILES=6, /* Internal. */
  723. DB_TXN_PRINT=7, /* Public. */
  724. DB_TXN_LOG_VERIFY=8 /* Internal. */
  725. } db_recops;
  726. /*
  727. * BACKWARD_ALLOC is used during the forward pass to pick up any aborted
  728. * allocations for files that were created during the forward pass.
  729. * The main difference between _ALLOC and _ROLL is that the entry for
  730. * the file not exist during the rollforward pass.
  731. */
  732. #define DB_UNDO(op) ((op) == DB_TXN_ABORT || (op) == DB_TXN_BACKWARD_ROLL)
  733. #define DB_REDO(op) ((op) == DB_TXN_FORWARD_ROLL || (op) == DB_TXN_APPLY)
  734. struct __db_txn {
  735. DB_TXNMGR *mgrp; /* Pointer to transaction manager. */
  736. DB_TXN *parent; /* Pointer to transaction's parent. */
  737. DB_THREAD_INFO *thread_info; /* Pointer to thread information. */
  738. u_int32_t txnid; /* Unique transaction id. */
  739. char *name; /* Transaction name. */
  740. DB_LOCKER *locker; /* Locker for this txn. */
  741. void *td; /* Detail structure within region. */
  742. db_timeout_t lock_timeout; /* Timeout for locks for this txn. */
  743. void *txn_list; /* Undo information for parent. */
  744. /*
  745. * !!!
  746. * Explicit representations of structures from queue.h.
  747. * TAILQ_ENTRY(__db_txn) links;
  748. */
  749. struct {
  750. struct __db_txn *tqe_next;
  751. struct __db_txn **tqe_prev;
  752. } links; /* Links transactions off manager. */
  753. /*
  754. * !!!
  755. * Explicit representations of structures from shqueue.h.
  756. * SH_TAILQ_ENTRY xa_links;
  757. * These links link together transactions that are active in
  758. * the same thread of control.
  759. */
  760. struct {
  761. db_ssize_t stqe_next;
  762. db_ssize_t stqe_prev;
  763. } xa_links; /* Links XA transactions. */
  764. /*
  765. * !!!
  766. * Explicit representations of structures from queue.h.
  767. * TAILQ_HEAD(__kids, __db_txn) kids;
  768. */
  769. struct __kids {
  770. struct __db_txn *tqh_first;
  771. struct __db_txn **tqh_last;
  772. } kids;
  773. /*
  774. * !!!
  775. * Explicit representations of structures from queue.h.
  776. * TAILQ_HEAD(__events, __txn_event) events;
  777. */
  778. struct {
  779. struct __txn_event *tqh_first;
  780. struct __txn_event **tqh_last;
  781. } events; /* Links deferred events. */
  782. /*
  783. * !!!
  784. * Explicit representations of structures from queue.h.
  785. * STAILQ_HEAD(__logrec, __txn_logrec) logs;
  786. */
  787. struct {
  788. struct __txn_logrec *stqh_first;
  789. struct __txn_logrec **stqh_last;
  790. } logs; /* Links in memory log records. */
  791. /*
  792. * !!!
  793. * Explicit representations of structures from queue.h.
  794. * TAILQ_ENTRY(__db_txn) klinks;
  795. */
  796. struct {
  797. struct __db_txn *tqe_next;
  798. struct __db_txn **tqe_prev;
  799. } klinks; /* Links of children in parent. */
  800. /*
  801. * !!!
  802. * Explicit representations of structures from queue.h.
  803. * TAILQ_HEAD(__my_cursors, __dbc) my_cursors;
  804. */
  805. struct __my_cursors {
  806. struct __dbc *tqh_first;
  807. struct __dbc **tqh_last;
  808. } my_cursors;
  809. /*
  810. * !!!
  811. * Explicit representations of structures from queue.h.
  812. * TAILQ_HEAD(__femfs, MPOOLFILE) femfs;
  813. *
  814. * These are DBs involved in file extension in this transaction.
  815. */
  816. struct __femfs {
  817. DB *tqh_first;
  818. DB **tqh_last;
  819. } femfs;
  820. DB_TXN_TOKEN *token_buffer; /* User's commit token buffer. */
  821. void *api_internal; /* C++ API private. */
  822. void *xml_internal; /* XML API private. */
  823. u_int32_t cursors; /* Number of cursors open for txn */
  824. /* DB_TXN PUBLIC HANDLE LIST BEGIN */
  825. int (*abort) __P((DB_TXN *));
  826. int (*commit) __P((DB_TXN *, u_int32_t));
  827. int (*discard) __P((DB_TXN *, u_int32_t));
  828. int (*get_name) __P((DB_TXN *, const char **));
  829. int (*get_priority) __P((DB_TXN *, u_int32_t *));
  830. u_int32_t (*id) __P((DB_TXN *));
  831. int (*prepare) __P((DB_TXN *, u_int8_t *));
  832. int (*set_commit_token) __P((DB_TXN *, DB_TXN_TOKEN *));
  833. int (*set_name) __P((DB_TXN *, const char *));
  834. int (*set_priority) __P((DB_TXN *, u_int32_t));
  835. int (*set_timeout) __P((DB_TXN *, db_timeout_t, u_int32_t));
  836. /* DB_TXN PUBLIC HANDLE LIST END */
  837. /* DB_TXN PRIVATE HANDLE LIST BEGIN */
  838. void (*set_txn_lsnp) __P((DB_TXN *txn, DB_LSN **, DB_LSN **));
  839. /* DB_TXN PRIVATE HANDLE LIST END */
  840. #define TXN_XA_THREAD_NOTA 0
  841. #define TXN_XA_THREAD_ASSOCIATED 1
  842. #define TXN_XA_THREAD_SUSPENDED 2
  843. #define TXN_XA_THREAD_UNASSOCIATED 3
  844. u_int32_t xa_thr_status;
  845. #define TXN_CHILDCOMMIT 0x00001 /* Txn has committed. */
  846. #define TXN_COMPENSATE 0x00002 /* Compensating transaction. */
  847. #define TXN_DEADLOCK 0x00004 /* Txn has deadlocked. */
  848. #define TXN_FAMILY 0x00008 /* Cursors/children are independent. */
  849. #define TXN_IGNORE_LEASE 0x00010 /* Skip lease check at commit time. */
  850. #define TXN_INFAMILY 0x00020 /* Part of a transaction family. */
  851. #define TXN_LOCKTIMEOUT 0x00040 /* Txn has a lock timeout. */
  852. #define TXN_MALLOC 0x00080 /* Structure allocated by TXN system. */
  853. #define TXN_NOSYNC 0x00100 /* Do not sync on prepare and commit. */
  854. #define TXN_NOWAIT 0x00200 /* Do not wait on locks. */
  855. #define TXN_PRIVATE 0x00400 /* Txn owned by cursor. */
  856. #define TXN_READONLY 0x00800 /* CDS group handle. */
  857. #define TXN_READ_COMMITTED 0x01000 /* Txn has degree 2 isolation. */
  858. #define TXN_READ_UNCOMMITTED 0x02000 /* Txn has degree 1 isolation. */
  859. #define TXN_RESTORED 0x04000 /* Txn has been restored. */
  860. #define TXN_SNAPSHOT 0x08000 /* Snapshot Isolation. */
  861. #define TXN_SYNC 0x10000 /* Write and sync on prepare/commit. */
  862. #define TXN_WRITE_NOSYNC 0x20000 /* Write only on prepare/commit. */
  863. #define TXN_BULK 0x40000 /* Enable bulk loading optimization. */
  864. u_int32_t flags;
  865. };
  866. #define TXN_SYNC_FLAGS (TXN_SYNC | TXN_NOSYNC | TXN_WRITE_NOSYNC)
  867. /*
  868. * Structure used for two phase commit interface.
  869. * We set the size of our global transaction id (gid) to be 128 in order
  870. * to match that defined by the XA X/Open standard.
  871. */
  872. #define DB_GID_SIZE 128
  873. struct __db_preplist {
  874. DB_TXN *txn;
  875. u_int8_t gid[DB_GID_SIZE];
  876. };
  877. /* Transaction statistics structure. */
  878. struct __db_txn_active {
  879. u_int32_t txnid; /* Transaction ID */
  880. u_int32_t parentid; /* Transaction ID of parent */
  881. pid_t pid; /* Process owning txn ID */
  882. db_threadid_t tid; /* Thread owning txn ID */
  883. DB_LSN lsn; /* LSN when transaction began */
  884. DB_LSN read_lsn; /* Read LSN for MVCC */
  885. u_int32_t mvcc_ref; /* MVCC reference count */
  886. u_int32_t priority; /* Deadlock resolution priority */
  887. #define TXN_ABORTED 1
  888. #define TXN_COMMITTED 2
  889. #define TXN_NEED_ABORT 3
  890. #define TXN_PREPARED 4
  891. #define TXN_RUNNING 5
  892. u_int32_t status; /* Status of the transaction */
  893. #define TXN_XA_ACTIVE 1
  894. #define TXN_XA_DEADLOCKED 2
  895. #define TXN_XA_IDLE 3
  896. #define TXN_XA_PREPARED 4
  897. #define TXN_XA_ROLLEDBACK 5
  898. u_int32_t xa_status; /* XA status */
  899. u_int8_t gid[DB_GID_SIZE]; /* Global transaction ID */
  900. char name[51]; /* 50 bytes of name, nul termination */
  901. };
  902. struct __db_txn_stat {
  903. u_int32_t st_nrestores; /* number of restored transactions
  904. after recovery. */
  905. #ifndef __TEST_DB_NO_STATISTICS
  906. DB_LSN st_last_ckp; /* lsn of the last checkpoint */
  907. time_t st_time_ckp; /* time of last checkpoint */
  908. u_int32_t st_last_txnid; /* last transaction id given out */
  909. u_int32_t st_inittxns; /* inital txns allocated */
  910. u_int32_t st_maxtxns; /* maximum txns possible */
  911. uintmax_t st_naborts; /* number of aborted transactions */
  912. uintmax_t st_nbegins; /* number of begun transactions */
  913. uintmax_t st_ncommits; /* number of committed transactions */
  914. u_int32_t st_nactive; /* number of active transactions */
  915. u_int32_t st_nsnapshot; /* number of snapshot transactions */
  916. u_int32_t st_maxnactive; /* maximum active transactions */
  917. u_int32_t st_maxnsnapshot; /* maximum snapshot transactions */
  918. uintmax_t st_region_wait; /* Region lock granted after wait. */
  919. uintmax_t st_region_nowait; /* Region lock granted without wait. */
  920. roff_t st_regsize; /* Region size. */
  921. DB_TXN_ACTIVE *st_txnarray; /* array of active transactions */
  922. #endif
  923. };
  924. #define DB_TXN_TOKEN_SIZE 20
  925. struct __db_txn_token {
  926. u_int8_t buf[DB_TXN_TOKEN_SIZE];
  927. };
  928. /*******************************************************
  929. * Replication.
  930. *******************************************************/
  931. /* Special, out-of-band environment IDs. */
  932. #define DB_EID_BROADCAST -1
  933. #define DB_EID_INVALID -2
  934. #define DB_EID_MASTER -3
  935. #define DB_REP_DEFAULT_PRIORITY 100
  936. /* Acknowledgement policies; 0 reserved as OOB. */
  937. #define DB_REPMGR_ACKS_ALL 1
  938. #define DB_REPMGR_ACKS_ALL_AVAILABLE 2
  939. #define DB_REPMGR_ACKS_ALL_PEERS 3
  940. #define DB_REPMGR_ACKS_NONE 4
  941. #define DB_REPMGR_ACKS_ONE 5
  942. #define DB_REPMGR_ACKS_ONE_PEER 6
  943. #define DB_REPMGR_ACKS_QUORUM 7
  944. /* Replication timeout configuration values. */
  945. #define DB_REP_ACK_TIMEOUT 1 /* RepMgr acknowledgements. */
  946. #define DB_REP_CHECKPOINT_DELAY 2 /* Master checkpoint delay. */
  947. #define DB_REP_CONNECTION_RETRY 3 /* RepMgr connections. */
  948. #define DB_REP_ELECTION_RETRY 4 /* RepMgr elect retries. */
  949. #define DB_REP_ELECTION_TIMEOUT 5 /* Rep normal elections. */
  950. #define DB_REP_FULL_ELECTION_TIMEOUT 6 /* Rep full elections. */
  951. #define DB_REP_HEARTBEAT_MONITOR 7 /* RepMgr client HB monitor. */
  952. #define DB_REP_HEARTBEAT_SEND 8 /* RepMgr master send freq. */
  953. #define DB_REP_LEASE_TIMEOUT 9 /* Master leases. */
  954. /*
  955. * Event notification types. (Tcl testing interface currently assumes there are
  956. * no more than 32 of these.)
  957. */
  958. #define DB_EVENT_PANIC 0
  959. #define DB_EVENT_REG_ALIVE 1
  960. #define DB_EVENT_REG_PANIC 2
  961. #define DB_EVENT_REP_AUTOTAKEOVER_FAILED 3
  962. #define DB_EVENT_REP_CLIENT 4
  963. #define DB_EVENT_REP_CONNECT_BROKEN 5
  964. #define DB_EVENT_REP_CONNECT_ESTD 6
  965. #define DB_EVENT_REP_CONNECT_TRY_FAILED 7
  966. #define DB_EVENT_REP_DUPMASTER 8
  967. #define DB_EVENT_REP_ELECTED 9
  968. #define DB_EVENT_REP_ELECTION_FAILED 10
  969. #define DB_EVENT_REP_INIT_DONE 11
  970. #define DB_EVENT_REP_JOIN_FAILURE 12
  971. #define DB_EVENT_REP_LOCAL_SITE_REMOVED 13
  972. #define DB_EVENT_REP_MASTER 14
  973. #define DB_EVENT_REP_MASTER_FAILURE 15
  974. #define DB_EVENT_REP_NEWMASTER 16
  975. #define DB_EVENT_REP_PERM_FAILED 17
  976. #define DB_EVENT_REP_SITE_ADDED 18
  977. #define DB_EVENT_REP_SITE_REMOVED 19
  978. #define DB_EVENT_REP_STARTUPDONE 20
  979. #define DB_EVENT_REP_WOULD_ROLLBACK 21 /* Undocumented; C API only. */
  980. #define DB_EVENT_WRITE_FAILED 22
  981. #define DB_EVENT_NO_SUCH_EVENT 0xffffffff /* OOB sentinel value */
  982. /* Replication Manager site status. */
  983. struct __db_repmgr_site {
  984. int eid;
  985. char *host;
  986. u_int port;
  987. #define DB_REPMGR_CONNECTED 1
  988. #define DB_REPMGR_DISCONNECTED 2
  989. u_int32_t status;
  990. #define DB_REPMGR_ISPEER 0x01
  991. #define DB_REPMGR_ISVIEW 0x02
  992. u_int32_t flags;
  993. };
  994. /* Replication statistics. */
  995. struct __db_rep_stat { /* SHARED */
  996. /* !!!
  997. * Many replication statistics fields cannot be protected by a mutex
  998. * without an unacceptable performance penalty, since most message
  999. * processing is done without the need to hold a region-wide lock.
  1000. * Fields whose comments end with a '+' may be updated without holding
  1001. * the replication or log mutexes (as appropriate), and thus may be
  1002. * off somewhat (or, on unreasonable architectures under unlucky
  1003. * circumstances, garbaged).
  1004. */
  1005. u_int32_t st_startup_complete; /* Site completed client sync-up. */
  1006. u_int32_t st_view; /* Site is a view. */
  1007. #ifndef __TEST_DB_NO_STATISTICS
  1008. uintmax_t st_log_queued; /* Log records currently queued.+ */
  1009. u_int32_t st_status; /* Current replication status. */
  1010. DB_LSN st_next_lsn; /* Next LSN to use or expect. */
  1011. DB_LSN st_waiting_lsn; /* LSN we're awaiting, if any. */
  1012. DB_LSN st_max_perm_lsn; /* Maximum permanent LSN. */
  1013. db_pgno_t st_next_pg; /* Next pg we expect. */
  1014. db_pgno_t st_waiting_pg; /* pg we're awaiting, if any. */
  1015. u_int32_t st_dupmasters; /* # of times a duplicate master
  1016. condition was detected.+ */
  1017. db_ssize_t st_env_id; /* Current environment ID. */
  1018. u_int32_t st_env_priority; /* Current environment priority. */
  1019. uintmax_t st_bulk_fills; /* Bulk buffer fills. */
  1020. uintmax_t st_bulk_overflows; /* Bulk buffer overflows. */
  1021. uintmax_t st_bulk_records; /* Bulk records stored. */
  1022. uintmax_t st_bulk_transfers; /* Transfers of bulk buffers. */
  1023. uintmax_t st_client_rerequests;/* Number of forced rerequests. */
  1024. uintmax_t st_client_svc_req; /* Number of client service requests
  1025. received by this client. */
  1026. uintmax_t st_client_svc_miss; /* Number of client service requests
  1027. missing on this client. */
  1028. u_int32_t st_gen; /* Current generation number. */
  1029. u_int32_t st_egen; /* Current election gen number. */
  1030. uintmax_t st_lease_chk; /* Lease validity checks. */
  1031. uintmax_t st_lease_chk_misses; /* Lease checks invalid. */
  1032. uintmax_t st_lease_chk_refresh; /* Lease refresh attempts. */
  1033. uintmax_t st_lease_sends; /* Lease messages sent live. */
  1034. uintmax_t st_log_duplicated; /* Log records received multiply.+ */
  1035. uintmax_t st_log_queued_max; /* Max. log records queued at once.+ */
  1036. uintmax_t st_log_queued_total; /* Total # of log recs. ever queued.+ */
  1037. uintmax_t st_log_records; /* Log records received and put.+ */
  1038. uintmax_t st_log_requested; /* Log recs. missed and requested.+ */
  1039. db_ssize_t st_master; /* Env. ID of the current master. */
  1040. uintmax_t st_master_changes; /* # of times we've switched masters. */
  1041. uintmax_t st_msgs_badgen; /* Messages with a bad generation #.+ */
  1042. uintmax_t st_msgs_processed; /* Messages received and processed.+ */
  1043. uintmax_t st_msgs_recover; /* Messages ignored because this site
  1044. was a client in recovery.+ */
  1045. uintmax_t st_msgs_send_failures;/* # of failed message sends.+ */
  1046. uintmax_t st_msgs_sent; /* # of successful message sends.+ */
  1047. uintmax_t st_newsites; /* # of NEWSITE msgs. received.+ */
  1048. u_int32_t st_nsites; /* Current number of sites we will
  1049. assume during elections. */
  1050. uintmax_t st_nthrottles; /* # of times we were throttled. */
  1051. uintmax_t st_outdated; /* # of times we detected and returned
  1052. an OUTDATED condition.+ */
  1053. uintmax_t st_pg_duplicated; /* Pages received multiply.+ */
  1054. uintmax_t st_pg_records; /* Pages received and stored.+ */
  1055. uintmax_t st_pg_requested; /* Pages missed and requested.+ */
  1056. uintmax_t st_txns_applied; /* # of transactions applied.+ */
  1057. uintmax_t st_startsync_delayed;/* # of STARTSYNC msgs delayed.+ */
  1058. /* Elections generally. */
  1059. uintmax_t st_elections; /* # of elections held.+ */
  1060. uintmax_t st_elections_won; /* # of elections won by this site.+ */
  1061. /* Statistics about an in-progress election. */
  1062. db_ssize_t st_election_cur_winner; /* Current front-runner. */
  1063. u_int32_t st_election_gen; /* Election generation number. */
  1064. u_int32_t st_election_datagen; /* Election data generation number. */
  1065. DB_LSN st_election_lsn; /* Max. LSN of current winner. */
  1066. u_int32_t st_election_nsites; /* # of "registered voters". */
  1067. u_int32_t st_election_nvotes; /* # of "registered voters" needed. */
  1068. u_int32_t st_election_priority; /* Current election priority. */
  1069. int32_t st_election_status; /* Current election status. */
  1070. u_int32_t st_election_tiebreaker;/* Election tiebreaker value. */
  1071. u_int32_t st_election_votes; /* Votes received in this round. */
  1072. u_int32_t st_election_sec; /* Last election time seconds. */
  1073. u_int32_t st_election_usec; /* Last election time useconds. */
  1074. u_int32_t st_max_lease_sec; /* Maximum lease timestamp seconds. */
  1075. u_int32_t st_max_lease_usec; /* Maximum lease timestamp useconds. */
  1076. /* Undocumented statistics only used by the test system. */
  1077. #ifdef CONFIG_TEST
  1078. u_int32_t st_filefail_cleanups; /* # of FILE_FAIL cleanups done. */
  1079. uintmax_t st_log_futuredup; /* Future log records that are dups. */
  1080. #endif
  1081. #endif
  1082. };
  1083. /* Replication Manager statistics. */
  1084. struct __db_repmgr_stat { /* SHARED */
  1085. uintmax_t st_perm_failed; /* # of insufficiently ack'ed msgs. */
  1086. uintmax_t st_msgs_queued; /* # msgs queued for network delay. */
  1087. uintmax_t st_msgs_dropped; /* # msgs discarded due to excessive
  1088. queue length. */
  1089. uintmax_t st_connection_drop; /* Existing connections dropped. */
  1090. uintmax_t st_connect_fail; /* Failed new connection attempts. */
  1091. u_int32_t st_elect_threads; /* # of active election threads. */
  1092. u_int32_t st_max_elect_threads; /* Max concurrent e-threads ever. */
  1093. u_int32_t st_site_participants; /* # of repgroup participant sites. */
  1094. u_int32_t st_site_total; /* # of repgroup total sites. */
  1095. u_int32_t st_site_views; /* # of repgroup view sites. */
  1096. uintmax_t st_takeovers; /* # of automatic listener takeovers. */
  1097. u_int32_t st_incoming_queue_size; /* Undoc: # msgs currently queued. */
  1098. };
  1099. /* Replication Manager connection error. */
  1100. struct __db_repmgr_conn_err {
  1101. int eid; /* Replication Environment ID. */
  1102. int error; /* System networking error code. */
  1103. };
  1104. /*******************************************************
  1105. * Sequences.
  1106. *******************************************************/
  1107. /*
  1108. * The storage record for a sequence.
  1109. */
  1110. struct __db_seq_record {
  1111. u_int32_t seq_version; /* Version size/number. */
  1112. u_int32_t flags; /* DB_SEQ_XXX Flags. */
  1113. db_seq_t seq_value; /* Current value. */
  1114. db_seq_t seq_max; /* Max permitted. */
  1115. db_seq_t seq_min; /* Min permitted. */
  1116. };
  1117. /*
  1118. * Handle for a sequence object.
  1119. */
  1120. struct __db_sequence {
  1121. DB *seq_dbp; /* DB handle for this sequence. */
  1122. db_mutex_t mtx_seq; /* Mutex if sequence is threaded. */
  1123. DB_SEQ_RECORD *seq_rp; /* Pointer to current data. */
  1124. DB_SEQ_RECORD seq_record; /* Data from DB_SEQUENCE. */
  1125. u_int32_t seq_cache_size; /* Number of values cached. */
  1126. db_seq_t seq_last_value; /* Last value cached. */
  1127. db_seq_t seq_prev_value; /* Last value returned. */
  1128. DBT seq_key; /* DBT pointing to sequence key. */
  1129. DBT seq_data; /* DBT pointing to seq_record. */
  1130. /* API-private structure: used by C++ and Java. */
  1131. void *api_internal;
  1132. /* DB_SEQUENCE PUBLIC HANDLE LIST BEGIN */
  1133. int (*close) __P((DB_SEQUENCE *, u_int32_t));
  1134. int (*get) __P((DB_SEQUENCE *,
  1135. DB_TXN *, u_int32_t, db_seq_t *, u_int32_t));
  1136. int (*get_cachesize) __P((DB_SEQUENCE *, u_int32_t *));
  1137. int (*get_db) __P((DB_SEQUENCE *, DB **));
  1138. int (*get_flags) __P((DB_SEQUENCE *, u_int32_t *));
  1139. int (*get_key) __P((DB_SEQUENCE *, DBT *));
  1140. int (*get_range) __P((DB_SEQUENCE *,
  1141. db_seq_t *, db_seq_t *));
  1142. int (*initial_value) __P((DB_SEQUENCE *, db_seq_t));
  1143. int (*open) __P((DB_SEQUENCE *,
  1144. DB_TXN *, DBT *, u_int32_t));
  1145. int (*remove) __P((DB_SEQUENCE *, DB_TXN *, u_int32_t));
  1146. int (*set_cachesize) __P((DB_SEQUENCE *, u_int32_t));
  1147. int (*set_flags) __P((DB_SEQUENCE *, u_int32_t));
  1148. int (*set_range) __P((DB_SEQUENCE *, db_seq_t, db_seq_t));
  1149. int (*stat) __P((DB_SEQUENCE *,
  1150. DB_SEQUENCE_STAT **, u_int32_t));
  1151. int (*stat_print) __P((DB_SEQUENCE *, u_int32_t));
  1152. /* DB_SEQUENCE PUBLIC HANDLE LIST END */
  1153. };
  1154. struct __db_seq_stat { /* SHARED */
  1155. uintmax_t st_wait; /* Sequence lock granted w/o wait. */
  1156. uintmax_t st_nowait; /* Sequence lock granted after wait. */
  1157. db_seq_t st_current; /* Current value in db. */
  1158. db_seq_t st_value; /* Current cached value. */
  1159. db_seq_t st_last_value; /* Last cached value. */
  1160. db_seq_t st_min; /* Minimum value. */
  1161. db_seq_t st_max; /* Maximum value. */
  1162. u_int32_t st_cache_size; /* Cache size. */
  1163. u_int32_t st_flags; /* Flag value. */
  1164. };
  1165. /*******************************************************
  1166. * Access methods.
  1167. *******************************************************/
  1168. /*
  1169. * Any new methods need to retain the original numbering. The type
  1170. * is written in a log record so must be maintained.
  1171. */
  1172. typedef enum {
  1173. DB_BTREE=1,
  1174. DB_HASH=2,
  1175. DB_HEAP=6,
  1176. DB_RECNO=3,
  1177. DB_QUEUE=4,
  1178. DB_UNKNOWN=5 /* Figure it out on open. */
  1179. } DBTYPE;
  1180. #define DB_RENAMEMAGIC 0x030800 /* File has been renamed. */
  1181. #define DB_BTREEVERSION 10 /* Current btree version. */
  1182. #define DB_BTREEOLDVER 8 /* Oldest btree version supported. */
  1183. #define DB_BTREEMAGIC 0x053162
  1184. #define DB_HASHVERSION 10 /* Current hash version. */
  1185. #define DB_HASHOLDVER 7 /* Oldest hash version supported. */
  1186. #define DB_HASHMAGIC 0x061561
  1187. #define DB_HEAPVERSION 2 /* Current heap version. */
  1188. #define DB_HEAPOLDVER 1 /* Oldest heap version supported. */
  1189. #define DB_HEAPMAGIC 0x074582
  1190. #define DB_QAMVERSION 4 /* Current queue version. */
  1191. #define DB_QAMOLDVER 3 /* Oldest queue version supported. */
  1192. #define DB_QAMMAGIC 0x042253
  1193. #define DB_SEQUENCE_VERSION 2 /* Current sequence version. */
  1194. #define DB_SEQUENCE_OLDVER 1 /* Oldest sequence version supported. */
  1195. /*
  1196. * DB access method and cursor operation values. Each value is an operation
  1197. * code to which additional bit flags are added.
  1198. */
  1199. #define DB_AFTER 1 /* Dbc.put */
  1200. #define DB_APPEND 2 /* Db.put */
  1201. #define DB_BEFORE 3 /* Dbc.put */
  1202. #define DB_CONSUME 4 /* Db.get */
  1203. #define DB_CONSUME_WAIT 5 /* Db.get */
  1204. #define DB_CURRENT 6 /* Dbc.get, Dbc.put, DbLogc.get */
  1205. #define DB_FIRST 7 /* Dbc.get, DbLogc->get */
  1206. #define DB_GET_BOTH 8 /* Db.get, Dbc.get */
  1207. #define DB_GET_BOTHC 9 /* Dbc.get (internal) */
  1208. #define DB_GET_BOTH_RANGE 10 /* Db.get, Dbc.get */
  1209. #define DB_GET_RECNO 11 /* Dbc.get */
  1210. #define DB_JOIN_ITEM 12 /* Dbc.get; don't do primary lookup */
  1211. #define DB_KEYFIRST 13 /* Dbc.put */
  1212. #define DB_KEYLAST 14 /* Dbc.put */
  1213. #define DB_LAST 15 /* Dbc.get, DbLogc->get */
  1214. #define DB_NEXT 16 /* Dbc.get, DbLogc->get */
  1215. #define DB_NEXT_DUP 17 /* Dbc.get */
  1216. #define DB_NEXT_NODUP 18 /* Dbc.get */
  1217. #define DB_NODUPDATA 19 /* Db.put, Dbc.put */
  1218. #define DB_NOOVERWRITE 20 /* Db.put */
  1219. #define DB_OVERWRITE_DUP 21 /* Dbc.put, Db.put; no DB_KEYEXIST */
  1220. #define DB_POSITION 22 /* Dbc.dup */
  1221. #define DB_PREV 23 /* Dbc.get, DbLogc->get */
  1222. #define DB_PREV_DUP 24 /* Dbc.get */
  1223. #define DB_PREV_NODUP 25 /* Dbc.get */
  1224. #define DB_SET 26 /* Dbc.get, DbLogc->get */
  1225. #define DB_SET_RANGE 27 /* Dbc.get */
  1226. #define DB_SET_RECNO 28 /* Db.get, Dbc.get */
  1227. #define DB_UPDATE_SECONDARY 29 /* Dbc.get, Dbc.del (internal) */
  1228. #define DB_SET_LTE 30 /* Dbc.get (internal) */
  1229. #define DB_GET_BOTH_LTE 31 /* Dbc.get (internal) */
  1230. /* This has to change when the max opcode hits 255. */
  1231. #define DB_OPFLAGS_MASK 0x000000ff /* Mask for operations flags. */
  1232. /*
  1233. * DB (user visible) error return codes.
  1234. *
  1235. * !!!
  1236. * We don't want our error returns to conflict with other packages where
  1237. * possible, so pick a base error value that's hopefully not common. We
  1238. * document that we own the error name space from -30,800 to -30,999.
  1239. */
  1240. /* DB (public) error return codes. */
  1241. #define DB_BUFFER_SMALL (-30999)/* User memory too small for return. */
  1242. #define DB_DONOTINDEX (-30998)/* "Null" return from 2ndary callbk. */
  1243. #define DB_FOREIGN_CONFLICT (-30997)/* A foreign db constraint triggered. */
  1244. #define DB_HEAP_FULL (-30996)/* No free space in a heap file. */
  1245. #define DB_KEYEMPTY (-30995)/* Key/data deleted or never created. */
  1246. #define DB_KEYEXIST (-30994)/* The key/data pair already exists. */
  1247. #define DB_LOCK_DEADLOCK (-30993)/* Deadlock. */
  1248. #define DB_LOCK_NOTGRANTED (-30992)/* Lock unavailable. */
  1249. #define DB_LOG_BUFFER_FULL (-30991)/* In-memory log buffer full. */
  1250. #define DB_LOG_VERIFY_BAD (-30990)/* Log verification failed. */
  1251. #define DB_NOSERVER (-30989)/* Server panic return. */
  1252. #define DB_NOTFOUND (-30988)/* Key/data pair not found (EOF). */
  1253. #define DB_OLD_VERSION (-30987)/* Out-of-date version. */
  1254. #define DB_PAGE_NOTFOUND (-30986)/* Requested page not found. */
  1255. #define DB_REP_DUPMASTER (-30985)/* There are two masters. */
  1256. #define DB_REP_HANDLE_DEAD (-30984)/* Rolled back a commit. */
  1257. #define DB_REP_HOLDELECTION (-30983)/* Time to hold an election. */
  1258. #define DB_REP_IGNORE (-30982)/* This msg should be ignored.*/
  1259. #define DB_REP_ISPERM (-30981)/* Cached not written perm written.*/
  1260. #define DB_REP_JOIN_FAILURE (-30980)/* Unable to join replication group. */
  1261. #define DB_REP_LEASE_EXPIRED (-30979)/* Master lease has expired. */
  1262. #define DB_REP_LOCKOUT (-30978)/* API/Replication lockout now. */
  1263. #define DB_REP_NEWSITE (-30977)/* New site entered system. */
  1264. #define DB_REP_NOTPERM (-30976)/* Permanent log record not written. */
  1265. #define DB_REP_UNAVAIL (-30975)/* Site cannot currently be reached. */
  1266. #define DB_REP_WOULDROLLBACK (-30974)/* UNDOC: rollback inhibited by app. */
  1267. #define DB_RUNRECOVERY (-30973)/* Panic return. */
  1268. #define DB_SECONDARY_BAD (-30972)/* Secondary index corrupt. */
  1269. #define DB_TIMEOUT (-30971)/* Timed out on read consistency. */
  1270. #define DB_VERIFY_BAD (-30970)/* Verify failed; bad format. */
  1271. #define DB_VERSION_MISMATCH (-30969)/* Environment version mismatch. */
  1272. /* DB (private) error return codes. */
  1273. #define DB_ALREADY_ABORTED (-30899)
  1274. #define DB_CHKSUM_FAIL (-30898)/* Checksum failed. */
  1275. #define DB_DELETED (-30897)/* Recovery file marked deleted. */
  1276. #define DB_EVENT_NOT_HANDLED (-30896)/* Forward event to application. */
  1277. #define DB_NEEDSPLIT (-30895)/* Page needs to be split. */
  1278. #define DB_NOINTMP (-30886)/* Sequences not supported in temporary
  1279. or in-memory databases. */
  1280. #define DB_REP_BULKOVF (-30894)/* Rep bulk buffer overflow. */
  1281. #define DB_REP_LOGREADY (-30893)/* Rep log ready for recovery. */
  1282. #define DB_REP_NEWMASTER (-30892)/* We have learned of a new master. */
  1283. #define DB_REP_PAGEDONE (-30891)/* This page was already done. */
  1284. #define DB_SURPRISE_KID (-30890)/* Child commit where parent
  1285. didn't know it was a parent. */
  1286. #define DB_SWAPBYTES (-30889)/* Database needs byte swapping. */
  1287. #define DB_TXN_CKP (-30888)/* Encountered ckp record in log. */
  1288. #define DB_VERIFY_FATAL (-30887)/* DB->verify cannot proceed. */
  1289. /* Database handle. */
  1290. struct __db {
  1291. /*******************************************************
  1292. * Public: owned by the application.
  1293. *******************************************************/
  1294. u_int32_t pgsize; /* Database logical page size. */
  1295. DB_CACHE_PRIORITY priority; /* Database priority in cache. */
  1296. /* Callbacks. */
  1297. int (*db_append_recno) __P((DB *, DBT *, db_recno_t));
  1298. void (*db_feedback) __P((DB *, int, int));
  1299. int (*dup_compare) __P((DB *, const DBT *, const DBT *, size_t *));
  1300. void *app_private; /* Application-private handle. */
  1301. /*******************************************************
  1302. * Private: owned by DB.
  1303. *******************************************************/
  1304. DB_ENV *dbenv; /* Backing public environment. */
  1305. ENV *env; /* Backing private environment. */
  1306. DBTYPE type; /* DB access method type. */
  1307. DB_MPOOLFILE *mpf; /* Backing buffer pool. */
  1308. db_mutex_t mutex; /* Synchronization for free threading */
  1309. char *fname, *dname; /* File/database passed to DB->open. */
  1310. const char *dirname; /* Directory of DB file. */
  1311. u_int32_t open_flags; /* Flags passed to DB->open. */
  1312. u_int8_t fileid[DB_FILE_ID_LEN];/* File's unique ID for locking. */
  1313. u_int32_t adj_fileid; /* File's unique ID for curs. adj. */
  1314. u_int32_t blob_threshold; /* Blob threshold record size. */
  1315. #define DB_LOGFILEID_INVALID -1
  1316. FNAME *log_filename; /* File's naming info for logging. */
  1317. db_pgno_t meta_pgno; /* Meta page number */
  1318. DB_LOCKER *locker; /* Locker for handle locking. */
  1319. DB_LOCKER *cur_locker; /* Current handle lock holder. */
  1320. DB_TXN *cur_txn; /* Opening transaction. */
  1321. DB_LOCKER *associate_locker; /* Locker for DB->associate call. */
  1322. DB_LOCK handle_lock; /* Lock held on this handle. */
  1323. time_t timestamp; /* Handle timestamp for replication. */
  1324. u_int32_t fid_gen; /* Rep generation number for fids. */
  1325. /*
  1326. * Returned data memory for DB->get() and friends.
  1327. */
  1328. DBT my_rskey; /* Secondary key. */
  1329. DBT my_rkey; /* [Primary] key. */
  1330. DBT my_rdata; /* Data. */
  1331. /*
  1332. * !!!
  1333. * Some applications use DB but implement their own locking outside of
  1334. * DB. If they're using fcntl(2) locking on the underlying database
  1335. * file, and we open and close a file descriptor for that file, we will
  1336. * discard their locks. The DB_FCNTL_LOCKING flag to DB->open is an
  1337. * undocumented interface to support this usage which leaves any file
  1338. * descriptors we open until DB->close. This will only work with the
  1339. * DB->open interface and simple caches, e.g., creating a transaction
  1340. * thread may open/close file descriptors this flag doesn't protect.
  1341. * Locking with fcntl(2) on a file that you don't own is a very, very
  1342. * unsafe thing to do. 'Nuff said.
  1343. */
  1344. DB_FH *saved_open_fhp; /* Saved file handle. */
  1345. /*
  1346. * Linked list of DBP's, linked from the ENV, used to keep track
  1347. * of all open db handles for cursor adjustment.
  1348. *
  1349. * !!!
  1350. * Explicit representations of structures from queue.h.
  1351. * TAILQ_ENTRY(__db) dblistlinks;
  1352. */
  1353. struct {
  1354. struct __db *tqe_next;
  1355. struct __db **tqe_prev;
  1356. } dblistlinks;
  1357. /*
  1358. * Cursor queues.
  1359. *
  1360. * !!!
  1361. * Explicit representations of structures from queue.h.
  1362. * TAILQ_HEAD(__cq_fq, __dbc) free_queue;
  1363. * TAILQ_HEAD(__cq_aq, __dbc) active_queue;
  1364. * TAILQ_HEAD(__cq_jq, __dbc) join_queue;
  1365. */
  1366. struct __cq_fq {
  1367. struct __dbc *tqh_first;
  1368. struct __dbc **tqh_last;
  1369. } free_queue;
  1370. struct __cq_aq {
  1371. struct __dbc *tqh_first;
  1372. struct __dbc **tqh_last;
  1373. } active_queue;
  1374. struct __cq_jq {
  1375. struct __dbc *tqh_first;
  1376. struct __dbc **tqh_last;
  1377. } join_queue;
  1378. /*
  1379. * Secondary index support.
  1380. *
  1381. * Linked list of secondary indices -- set in the primary.
  1382. *
  1383. * !!!
  1384. * Explicit representations of structures from queue.h.
  1385. * LIST_HEAD(s_secondaries, __db);
  1386. */
  1387. struct {
  1388. struct __db *lh_first;
  1389. } s_secondaries;
  1390. /*
  1391. * List entries for secondaries, and reference count of how many
  1392. * threads are updating this secondary (see Dbc.put).
  1393. *
  1394. * !!!
  1395. * Note that these are synchronized by the primary's mutex, but
  1396. * filled in in the secondaries.
  1397. *
  1398. * !!!
  1399. * Explicit representations of structures from queue.h.
  1400. * LIST_ENTRY(__db) s_links;
  1401. */
  1402. struct {
  1403. struct __db *le_next;
  1404. struct __db **le_prev;
  1405. } s_links;
  1406. u_int32_t s_refcnt;
  1407. /* Secondary callback and free functions -- set in the secondary. */
  1408. int (*s_callback) __P((DB *, const DBT *, const DBT *, DBT *));
  1409. /* Reference to primary -- set in the secondary. */
  1410. DB *s_primary;
  1411. #define DB_ASSOC_IMMUTABLE_KEY 0x00000001 /* Secondary key is immutable. */
  1412. #define DB_ASSOC_CREATE 0x00000002 /* Secondary db populated on open. */
  1413. /* Flags passed to associate -- set in the secondary. */
  1414. u_int32_t s_assoc_flags;
  1415. /*
  1416. * Foreign key support.
  1417. *
  1418. * Linked list of primary dbs -- set in the foreign db
  1419. *
  1420. * !!!
  1421. * Explicit representations of structures from queue.h.
  1422. * LIST_HEAD(f_primaries, __db);
  1423. */
  1424. struct {
  1425. struct __db_foreign_info *lh_first;
  1426. } f_primaries;
  1427. /*
  1428. * !!!
  1429. * Explicit representations of structures from queue.h.
  1430. * TAILQ_ENTRY(__db) felink;
  1431. *
  1432. * Links in a list of DBs involved in file extension
  1433. * during a transaction. These are to be used only while the
  1434. * metadata is locked.
  1435. */
  1436. struct {
  1437. struct __db *tqe_next;
  1438. struct __db **tqe_prev;
  1439. } felink;
  1440. /* Reference to foreign -- set in the secondary. */
  1441. DB *s_foreign;
  1442. DB *blob_meta_db; /* Databases holding blob metadata. */
  1443. DB_SEQUENCE *blob_seq; /* Sequence of blob ids. */
  1444. char *blob_sub_dir; /* Subdirectory for blob files */
  1445. db_seq_t blob_file_id; /* Id of the file blob directory. */
  1446. db_seq_t blob_sdb_id; /* Id of the subdb blob directory. */
  1447. /* API-private structure: used by DB 1.85, C++, Java, Perl and Tcl */
  1448. void *api_internal;
  1449. /* Subsystem-private structure. */
  1450. void *bt_internal; /* Btree/Recno access method. */
  1451. void *h_internal; /* Hash access method. */
  1452. void *heap_internal; /* Heap access method. */
  1453. void *p_internal; /* Partition informaiton. */
  1454. void *q_internal; /* Queue access method. */
  1455. /* DB PUBLIC HANDLE LIST BEGIN */
  1456. int (*associate) __P((DB *, DB_TXN *, DB *,
  1457. int (*)(DB *, const DBT *, const DBT *, DBT *), u_int32_t));
  1458. int (*associate_foreign) __P((DB *, DB *,
  1459. int (*)(DB *, const DBT *, DBT *, const DBT *, int *),
  1460. u_int32_t));
  1461. int (*close) __P((DB *, u_int32_t));
  1462. int (*compact) __P((DB *,
  1463. DB_TXN *, DBT *, DBT *, DB_COMPACT *, u_int32_t, DBT *));
  1464. int (*cursor) __P((DB *, DB_TXN *, DBC **, u_int32_t));
  1465. int (*del) __P((DB *, DB_TXN *, DBT *, u_int32_t));
  1466. void (*err) __P((DB *, int, const char *, ...));
  1467. void (*errx) __P((DB *, const char *, ...));
  1468. int (*exists) __P((DB *, DB_TXN *, DBT *, u_int32_t));
  1469. int (*fd) __P((DB *, int *));
  1470. int (*get) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
  1471. int (*get_alloc) __P((DB *, void *(**)(size_t),
  1472. void *(**)(void *, size_t), void (**)(void *)));
  1473. int (*get_append_recno) __P((DB *, int (**)(DB *, DBT *, db_recno_t)));
  1474. int (*get_assoc_flags) __P((DB *, u_int32_t *));
  1475. int (*get_blob_dir) __P((DB *, const char **));
  1476. int (*get_blob_sub_dir) __P((DB *, const char **));
  1477. int (*get_blob_threshold) __P((DB *, u_int32_t *));
  1478. int (*get_bt_compare)
  1479. __P((DB *, int (**)(DB *, const DBT *, const DBT *, size_t *)));
  1480. int (*get_bt_compress) __P((DB *,
  1481. int (**)(DB *,
  1482. const DBT *, const DBT *, const DBT *, const DBT *, DBT *),
  1483. int (**)(DB *, const DBT *, const DBT *, DBT *, DBT *, DBT *)));
  1484. int (*get_bt_minkey) __P((DB *, u_int32_t *));
  1485. int (*get_bt_prefix)
  1486. __P((DB *, size_t (**)(DB *, const DBT *, const DBT *)));
  1487. int (*get_byteswapped) __P((DB *, int *));
  1488. int (*get_cachesize) __P((DB *, u_int32_t *, u_int32_t *, int *));
  1489. int (*get_create_dir) __P((DB *, const char **));
  1490. int (*get_dbname) __P((DB *, const char **, const char **));
  1491. int (*get_dup_compare)
  1492. __P((DB *, int (**)(DB *, const DBT *, const DBT *, size_t *)));
  1493. int (*get_encrypt_flags) __P((DB *, u_int32_t *));
  1494. DB_ENV *(*get_env) __P((DB *));
  1495. void (*get_errcall) __P((DB *,
  1496. void (**)(const DB_ENV *, const char *, const char *)));
  1497. void (*get_errfile) __P((DB *, FILE **));
  1498. void (*get_errpfx) __P((DB *, const char **));
  1499. int (*get_feedback) __P((DB *, void (**)(DB *, int, int)));
  1500. int (*get_flags) __P((DB *, u_int32_t *));
  1501. int (*get_h_compare)
  1502. __P((DB *, int (**)(DB *, const DBT *, const DBT *, size_t *)));
  1503. int (*get_h_ffactor) __P((DB *, u_int32_t *));
  1504. int (*get_h_hash)
  1505. __P((DB *, u_int32_t (**)(DB *, const void *, u_int32_t)));
  1506. int (*get_h_nelem) __P((DB *, u_int32_t *));
  1507. int (*get_heapsize) __P((DB *, u_int32_t *, u_int32_t *));
  1508. int (*get_heap_regionsize) __P((DB *, u_int32_t *));
  1509. int (*get_lk_exclusive) __P((DB *, int *, int *));
  1510. int (*get_lorder) __P((DB *, int *));
  1511. DB_MPOOLFILE *(*get_mpf) __P((DB *));
  1512. void (*get_msgcall) __P((DB *,
  1513. void (**)(const DB_ENV *, const char *)));
  1514. void (*get_msgfile) __P((DB *, FILE **));
  1515. int (*get_multiple) __P((DB *));
  1516. int (*get_open_flags) __P((DB *, u_int32_t *));
  1517. int (*get_pagesize) __P((DB *, u_int32_t *));
  1518. int (*get_partition_callback) __P((DB *,
  1519. u_int32_t *, u_int32_t (**)(DB *, DBT *key)));
  1520. int (*get_partition_dirs) __P((DB *, const char ***));
  1521. int (*get_partition_keys) __P((DB *, u_int32_t *, DBT **));
  1522. int (*get_priority) __P((DB *, DB_CACHE_PRIORITY *));
  1523. int (*get_q_extentsize) __P((DB *, u_int32_t *));
  1524. int (*get_re_delim) __P((DB *, int *));
  1525. int (*get_re_len) __P((DB *, u_int32_t *));
  1526. int (*get_re_pad) __P((DB *, int *));
  1527. int (*get_re_source) __P((DB *, const char **));
  1528. int (*get_transactional) __P((DB *));
  1529. int (*get_type) __P((DB *, DBTYPE *));
  1530. int (*join) __P((DB *, DBC **, DBC **, u_int32_t));
  1531. int (*key_range)
  1532. __P((DB *, DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t));
  1533. int (*open) __P((DB *,
  1534. DB_TXN *, const char *, const char *, DBTYPE, u_int32_t, int));
  1535. int (*pget) __P((DB *, DB_TXN *, DBT *, DBT *, DBT *, u_int32_t));
  1536. int (*put) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
  1537. int (*remove) __P((DB *, const char *, const char *, u_int32_t));
  1538. int (*rename) __P((DB *,
  1539. const char *, const char *, const char *, u_int32_t));
  1540. int (*set_alloc) __P((DB *, void *(*)(size_t),
  1541. void *(*)(void *, size_t), void (*)(void *)));
  1542. int (*set_append_recno) __P((DB *, int (*)(DB *, DBT *, db_recno_t)));
  1543. int (*set_blob_dir) __P((DB *, const char *));
  1544. int (*set_blob_threshold) __P((DB *, u_int32_t, u_int32_t));
  1545. int (*set_bt_compare)
  1546. __P((DB *, int (*)(DB *, const DBT *, const DBT *, size_t *)));
  1547. int (*set_bt_compress) __P((DB *,
  1548. int (*)(DB *, const DBT *, const DBT *, const DBT *, const DBT *, DBT *),
  1549. int (*)(DB *, const DBT *, const DBT *, DBT *, DBT *, DBT *)));
  1550. int (*set_bt_minkey) __P((DB *, u_int32_t));
  1551. int (*set_bt_prefix)
  1552. __P((DB *, size_t (*)(DB *, const DBT *, const DBT *)));
  1553. int (*set_cachesize) __P((DB *, u_int32_t, u_int32_t, int));
  1554. int (*set_create_dir) __P((DB *, const char *));
  1555. int (*set_dup_compare)
  1556. __P((DB *, int (*)(DB *, const DBT *, const DBT *, size_t *)));
  1557. int (*set_encrypt) __P((DB *, const char *, u_int32_t));
  1558. void (*set_errcall) __P((DB *,
  1559. void (*)(const DB_ENV *, const char *, const char *)));
  1560. void (*set_errfile) __P((DB *, FILE *));
  1561. void (*set_errpfx) __P((DB *, const char *));
  1562. int (*set_feedback) __P((DB *, void (*)(DB *, int, int)));
  1563. int (*set_flags) __P((DB *, u_int32_t));
  1564. int (*set_h_compare)
  1565. __P((DB *, int (*)(DB *, const DBT *, const DBT *, size_t *)));
  1566. int (*set_h_ffactor) __P((DB *, u_int32_t));
  1567. int (*set_h_hash)
  1568. __P((DB *, u_int32_t (*)(DB *, const void *, u_int32_t)));
  1569. int (*set_h_nelem) __P((DB *, u_int32_t));
  1570. int (*set_heapsize) __P((DB *, u_int32_t, u_int32_t, u_int32_t));
  1571. int (*set_heap_regionsize) __P((DB *, u_int32_t));
  1572. int (*set_lk_exclusive) __P((DB *, int));
  1573. int (*set_lorder) __P((DB *, int));
  1574. void (*set_msgcall) __P((DB *, void (*)(const DB_ENV *, const char *)));
  1575. void (*set_msgfile) __P((DB *, FILE *));
  1576. int (*set_pagesize) __P((DB *, u_int32_t));
  1577. int (*set_paniccall) __P((DB *, void (*)(DB_ENV *, int)));
  1578. int (*set_partition) __P((DB *,
  1579. u_int32_t, DBT *, u_int32_t (*)(DB *, DBT *key)));
  1580. int (*set_partition_dirs) __P((DB *, const char **));
  1581. int (*set_priority) __P((DB *, DB_CACHE_PRIORITY));
  1582. int (*set_q_extentsize) __P((DB *, u_int32_t));
  1583. int (*set_re_delim) __P((DB *, int));
  1584. int (*set_re_len) __P((DB *, u_int32_t));
  1585. int (*set_re_pad) __P((DB *, int));
  1586. int (*set_re_source) __P((DB *, const char *));
  1587. int (*sort_multiple) __P((DB *, DBT *, DBT *, u_int32_t));
  1588. int (*stat) __P((DB *, DB_TXN *, void *, u_int32_t));
  1589. int (*stat_print) __P((DB *, u_int32_t));
  1590. int (*sync) __P((DB *, u_int32_t));
  1591. int (*truncate) __P((DB *, DB_TXN *, u_int32_t *, u_int32_t));
  1592. int (*upgrade) __P((DB *, const char *, u_int32_t));
  1593. int (*verify)
  1594. __P((DB *, const char *, const char *, FILE *, u_int32_t));
  1595. /* DB PUBLIC HANDLE LIST END */
  1596. /* DB PRIVATE HANDLE LIST BEGIN */
  1597. int (*dump) __P((DB *, const char *,
  1598. int (*)(void *, const void *), void *, int, int));
  1599. int (*db_am_remove) __P((DB *, DB_THREAD_INFO *,
  1600. DB_TXN *, const char *, const char *, u_int32_t));
  1601. int (*db_am_rename) __P((DB *, DB_THREAD_INFO *,
  1602. DB_TXN *, const char *, const char *, const char *));
  1603. /* DB PRIVATE HANDLE LIST END */
  1604. /*
  1605. * Never called; these are a place to save function pointers
  1606. * so that we can undo an associate.
  1607. */
  1608. int (*stored_get) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
  1609. int (*stored_close) __P((DB *, u_int32_t));
  1610. /* Alternative handle close function, used by C++ API. */
  1611. int (*alt_close) __P((DB *, u_int32_t));
  1612. #define DB_OK_BTREE 0x01
  1613. #define DB_OK_HASH 0x02
  1614. #define DB_OK_HEAP 0x04
  1615. #define DB_OK_QUEUE 0x08
  1616. #define DB_OK_RECNO 0x10
  1617. u_int32_t am_ok; /* Legal AM choices. */
  1618. /*
  1619. * This field really ought to be an AM_FLAG, but we have
  1620. * have run out of bits. If/when we decide to split up
  1621. * the flags, we can incorporate it.
  1622. */
  1623. int preserve_fid; /* Do not free fileid on close. */
  1624. #define DB_AM_CHKSUM 0x00000001 /* Checksumming */
  1625. #define DB_AM_COMPENSATE 0x00000002 /* Created by compensating txn */
  1626. #define DB_AM_COMPRESS 0x00000004 /* Compressed BTree */
  1627. #define DB_AM_CREATED 0x00000008 /* Database was created upon open */
  1628. #define DB_AM_CREATED_MSTR 0x00000010 /* Encompassing file was created */
  1629. #define DB_AM_DBM_ERROR 0x00000020 /* Error in DBM/NDBM database */
  1630. #define DB_AM_DELIMITER 0x00000040 /* Variable length delimiter set */
  1631. #define DB_AM_DISCARD 0x00000080 /* Discard any cached pages */
  1632. #define DB_AM_DUP 0x00000100 /* DB_DUP */
  1633. #define DB_AM_DUPSORT 0x00000200 /* DB_DUPSORT */
  1634. #define DB_AM_ENCRYPT 0x00000400 /* Encryption */
  1635. #define DB_AM_FIXEDLEN 0x00000800 /* Fixed-length records */
  1636. #define DB_AM_INMEM 0x00001000 /* In-memory; no sync on close */
  1637. #define DB_AM_INORDER 0x00002000 /* DB_INORDER */
  1638. #define DB_AM_IN_RENAME 0x00004000 /* File is being renamed */
  1639. #define DB_AM_NOT_DURABLE 0x00008000 /* Do not log changes */
  1640. #define DB_AM_OPEN_CALLED 0x00010000 /* DB->open called */
  1641. #define DB_AM_PAD 0x00020000 /* Fixed-length record pad */
  1642. #define DB_AM_PARTDB 0x00040000 /* Handle for a database partition */
  1643. #define DB_AM_PGDEF 0x00080000 /* Page size was defaulted */
  1644. #define DB_AM_RDONLY 0x00100000 /* Database is readonly */
  1645. #define DB_AM_READ_UNCOMMITTED 0x00200000 /* Support degree 1 isolation */
  1646. #define DB_AM_RECNUM 0x00400000 /* DB_RECNUM */
  1647. #define DB_AM_RECOVER 0x00800000 /* DB opened by recovery routine */
  1648. #define DB_AM_RENUMBER 0x01000000 /* DB_RENUMBER */
  1649. #define DB_AM_REVSPLITOFF 0x02000000 /* DB_REVSPLITOFF */
  1650. #define DB_AM_SECONDARY 0x04000000 /* Database is a secondary index */
  1651. #define DB_AM_SNAPSHOT 0x08000000 /* DB_SNAPSHOT */
  1652. #define DB_AM_SUBDB 0x10000000 /* Subdatabases supported */
  1653. #define DB_AM_SWAP 0x20000000 /* Pages need to be byte-swapped */
  1654. #define DB_AM_TXN 0x40000000 /* Opened in a transaction */
  1655. #define DB_AM_VERIFYING 0x80000000 /* DB handle is in the verifier */
  1656. u_int32_t orig_flags; /* Flags at open, for refresh */
  1657. u_int32_t flags;
  1658. #define DB2_AM_EXCL 0x00000001 /* Exclusively lock the handle */
  1659. #define DB2_AM_INTEXCL 0x00000002 /* Internal exclusive lock. */
  1660. #define DB2_AM_NOWAIT 0x00000004 /* Do not wait for handle lock */
  1661. u_int32_t orig_flags2; /* Second flags word; for refresh */
  1662. u_int32_t flags2; /* Second flags word */
  1663. };
  1664. /*
  1665. * Stream interface for blob files.
  1666. */
  1667. struct __db_stream {
  1668. DBC *dbc; /* Cursor pointing to the db blob record. */
  1669. DB_FH *fhp;
  1670. /* DB_STREAM PUBLIC HANDLE LIST BEGIN */
  1671. int (*close) __P((DB_STREAM *, u_int32_t));
  1672. int (*read) __P((DB_STREAM *, DBT *, db_off_t, u_int32_t, u_int32_t));
  1673. int (*size) __P((DB_STREAM *, db_off_t *, u_int32_t));
  1674. int (*write) __P((DB_STREAM *, DBT *, db_off_t, u_int32_t));
  1675. /* DB_STREAM PUBLIC HANDLE LIST END */
  1676. u_int32_t flags;
  1677. #define DB_STREAM_READ 0x00000001 /* Stream is read only. */
  1678. #define DB_STREAM_WRITE 0x00000002 /* Stream is writeable. */
  1679. #define DB_STREAM_SYNC_WRITE 0x00000004 /* Sync file on each write. */
  1680. db_seq_t blob_id;
  1681. db_off_t file_size;
  1682. };
  1683. /*
  1684. * Macros for bulk operations. These are only intended for the C API.
  1685. * For C++, use DbMultiple*Iterator or DbMultiple*Builder.
  1686. *
  1687. * Bulk operations store multiple entries into a single DBT structure. The
  1688. * following macros assist with creating and reading these Multiple DBTs.
  1689. *
  1690. * The basic layout for single data items is:
  1691. *
  1692. * -------------------------------------------------------------------------
  1693. * | data1 | ... | dataN | ..... |-1 | dNLen | dNOff | ... | d1Len | d1Off |
  1694. * -------------------------------------------------------------------------
  1695. *
  1696. * For the DB_MULTIPLE_KEY* macros, the items are in key/data pairs, so data1
  1697. * would be a key, and data2 its corresponding value (N is always even).
  1698. *
  1699. * For the DB_MULTIPLE_RECNO* macros, the record number is stored along with
  1700. * the len/off pair in the "header" section, and the list is zero terminated
  1701. * (since -1 is a valid record number):
  1702. *
  1703. * --------------------------------------------------------------------------
  1704. * | d1 |..| dN |..| 0 | dNLen | dNOff | recnoN |..| d1Len | d1Off | recno1 |
  1705. * --------------------------------------------------------------------------
  1706. */
  1707. #define DB_MULTIPLE_INIT(pointer, dbt) \
  1708. (pointer = (u_int8_t *)(dbt)->data + \
  1709. (dbt)->ulen - sizeof(u_int32_t))
  1710. #define DB_MULTIPLE_NEXT(pointer, dbt, retdata, retdlen) \
  1711. do { \
  1712. u_int32_t *__p = (u_int32_t *)(pointer); \
  1713. if (*__p == (u_int32_t)-1) { \
  1714. retdata = NULL; \
  1715. pointer = NULL; \
  1716. break; \
  1717. } \
  1718. retdata = (u_int8_t *)(dbt)->data + *__p--; \
  1719. retdlen = *__p--; \
  1720. pointer = __p; \
  1721. if (retdlen == 0 && retdata == (u_int8_t *)(dbt)->data) \
  1722. retdata = NULL; \
  1723. } while (0)
  1724. #define DB_MULTIPLE_KEY_NEXT(pointer, dbt, retkey, retklen, retdata, retdlen) \
  1725. do { \
  1726. u_int32_t *__p = (u_int32_t *)(pointer); \
  1727. if (*__p == (u_int32_t)-1) { \
  1728. retdata = NULL; \
  1729. retkey = NULL; \
  1730. pointer = NULL; \
  1731. break; \
  1732. } \
  1733. retkey = (u_int8_t *)(dbt)->data + *__p--; \
  1734. retklen = *__p--; \
  1735. retdata = (u_int8_t *)(dbt)->data + *__p--; \
  1736. retdlen = *__p--; \
  1737. pointer = __p; \
  1738. } while (0)
  1739. #define DB_MULTIPLE_RECNO_NEXT(pointer, dbt, recno, retdata, retdlen) \
  1740. do { \
  1741. u_int32_t *__p = (u_int32_t *)(pointer); \
  1742. if (*__p == (u_int32_t)0) { \
  1743. recno = 0; \
  1744. retdata = NULL; \
  1745. pointer = NULL; \
  1746. break; \
  1747. } \
  1748. recno = *__p--; \
  1749. retdata = (u_int8_t *)(dbt)->data + *__p--; \
  1750. retdlen = *__p--; \
  1751. pointer = __p; \
  1752. } while (0)
  1753. #define DB_MULTIPLE_WRITE_INIT(pointer, dbt) \
  1754. do { \
  1755. (dbt)->flags |= DB_DBT_BULK; \
  1756. pointer = (u_int8_t *)(dbt)->data + \
  1757. (dbt)->ulen - sizeof(u_int32_t); \
  1758. *(u_int32_t *)(pointer) = (u_int32_t)-1; \
  1759. } while (0)
  1760. #define DB_MULTIPLE_RESERVE_NEXT(pointer, dbt, writedata, writedlen) \
  1761. do { \
  1762. u_int32_t *__p = (u_int32_t *)(pointer); \
  1763. u_int32_t __off = ((pointer) == (u_int8_t *)(dbt)->data +\
  1764. (dbt)->ulen - sizeof(u_int32_t)) ? 0 : __p[1] + __p[2];\
  1765. if ((u_int8_t *)(dbt)->data + __off + (writedlen) > \
  1766. (u_int8_t *)(__p - 2)) \
  1767. writedata = NULL; \
  1768. else { \
  1769. writedata = (u_int8_t *)(dbt)->data + __off; \
  1770. __p[0] = __off; \
  1771. __p[-1] = (u_int32_t)(writedlen); \
  1772. __p[-2] = (u_int32_t)-1; \
  1773. pointer = __p - 2; \
  1774. } \
  1775. } while (0)
  1776. #define DB_MULTIPLE_WRITE_NEXT(pointer, dbt, writedata, writedlen) \
  1777. do { \
  1778. void *__destd; \
  1779. DB_MULTIPLE_RESERVE_NEXT((pointer), (dbt), \
  1780. __destd, (writedlen)); \
  1781. if (__destd == NULL) \
  1782. pointer = NULL; \
  1783. else \
  1784. memcpy(__destd, (writedata), (writedlen)); \
  1785. } while (0)
  1786. #define DB_MULTIPLE_KEY_RESERVE_NEXT(pointer, dbt, writekey, writeklen, writedata, writedlen) \
  1787. do { \
  1788. u_int32_t *__p = (u_int32_t *)(pointer); \
  1789. u_int32_t __off = ((pointer) == (u_int8_t *)(dbt)->data +\
  1790. (dbt)->ulen - sizeof(u_int32_t)) ? 0 : __p[1] + __p[2];\
  1791. if ((u_int8_t *)(dbt)->data + __off + (writeklen) + \
  1792. (writedlen) > (u_int8_t *)(__p - 4)) { \
  1793. writekey = NULL; \
  1794. writedata = NULL; \
  1795. } else { \
  1796. writekey = (u_int8_t *)(dbt)->data + __off; \
  1797. __p[0] = __off; \
  1798. __p[-1] = (u_int32_t)(writeklen); \
  1799. __p -= 2; \
  1800. __off += (u_int32_t)(writeklen); \
  1801. writedata = (u_int8_t *)(dbt)->data + __off; \
  1802. __p[0] = __off; \
  1803. __p[-1] = (u_int32_t)(writedlen); \
  1804. __p[-2] = (u_int32_t)-1; \
  1805. pointer = __p - 2; \
  1806. } \
  1807. } while (0)
  1808. #define DB_MULTIPLE_KEY_WRITE_NEXT(pointer, dbt, writekey, writeklen, writedata, writedlen) \
  1809. do { \
  1810. void *__destk, *__destd; \
  1811. DB_MULTIPLE_KEY_RESERVE_NEXT((pointer), (dbt), \
  1812. __destk, (writeklen), __destd, (writedlen)); \
  1813. if (__destk == NULL) \
  1814. pointer = NULL; \
  1815. else { \
  1816. memcpy(__destk, (writekey), (writeklen)); \
  1817. if (__destd != NULL) \
  1818. memcpy(__destd, (writedata), (writedlen));\
  1819. } \
  1820. } while (0)
  1821. #define DB_MULTIPLE_RECNO_WRITE_INIT(pointer, dbt) \
  1822. do { \
  1823. (dbt)->flags |= DB_DBT_BULK; \
  1824. pointer = (u_int8_t *)(dbt)->data + \
  1825. (dbt)->ulen - sizeof(u_int32_t); \
  1826. *(u_int32_t *)(pointer) = 0; \
  1827. } while (0)
  1828. #define DB_MULTIPLE_RECNO_RESERVE_NEXT(pointer, dbt, recno, writedata, writedlen) \
  1829. do { \
  1830. u_int32_t *__p = (u_int32_t *)(pointer); \
  1831. u_int32_t __off = ((pointer) == (u_int8_t *)(dbt)->data +\
  1832. (dbt)->ulen - sizeof(u_int32_t)) ? 0 : __p[1] + __p[2]; \
  1833. if (((u_int8_t *)(dbt)->data + __off) + (writedlen) > \
  1834. (u_int8_t *)(__p - 3)) \
  1835. writedata = NULL; \
  1836. else { \
  1837. writedata = (u_int8_t *)(dbt)->data + __off; \
  1838. __p[0] = (u_int32_t)(recno); \
  1839. __p[-1] = __off; \
  1840. __p[-2] = (u_int32_t)(writedlen); \
  1841. __p[-3] = 0; \
  1842. pointer = __p - 3; \
  1843. } \
  1844. } while (0)
  1845. #define DB_MULTIPLE_RECNO_WRITE_NEXT(pointer, dbt, recno, writedata, writedlen)\
  1846. do { \
  1847. void *__destd; \
  1848. DB_MULTIPLE_RECNO_RESERVE_NEXT((pointer), (dbt), \
  1849. (recno), __destd, (writedlen)); \
  1850. if (__destd == NULL) \
  1851. pointer = NULL; \
  1852. else if ((writedlen) != 0) \
  1853. memcpy(__destd, (writedata), (writedlen)); \
  1854. } while (0)
  1855. struct __db_heap_rid {
  1856. db_pgno_t pgno; /* Page number. */
  1857. db_indx_t indx; /* Index in the offset table. */
  1858. };
  1859. #define DB_HEAP_RID_SZ (sizeof(db_pgno_t) + sizeof(db_indx_t))
  1860. /*******************************************************
  1861. * Access method cursors.
  1862. *******************************************************/
  1863. struct __dbc {
  1864. DB *dbp; /* Backing database */
  1865. DB_ENV *dbenv; /* Backing environment */
  1866. ENV *env; /* Backing environment */
  1867. DB_THREAD_INFO *thread_info; /* Thread that owns this cursor. */
  1868. DB_TXN *txn; /* Associated transaction. */
  1869. DB_CACHE_PRIORITY priority; /* Priority in cache. */
  1870. /*
  1871. * Active/free cursor queues.
  1872. *
  1873. * !!!
  1874. * Explicit representations of structures from queue.h.
  1875. * TAILQ_ENTRY(__dbc) links;
  1876. */
  1877. struct {
  1878. DBC *tqe_next;
  1879. DBC **tqe_prev;
  1880. } links;
  1881. /*
  1882. * Cursor queue of the owning transaction.
  1883. *
  1884. * !!!
  1885. * Explicit representations of structures from queue.h.
  1886. * TAILQ_ENTRY(__dbc) txn_cursors;
  1887. */
  1888. struct {
  1889. DBC *tqe_next; /* next element */
  1890. DBC **tqe_prev; /* address of previous next element */
  1891. } txn_cursors;
  1892. /*
  1893. * The DBT *'s below are used by the cursor routines to return
  1894. * data to the user when DBT flags indicate that DB should manage
  1895. * the returned memory. They point at a DBT containing the buffer
  1896. * and length that will be used, and "belonging" to the handle that
  1897. * should "own" this memory. This may be a "my_*" field of this
  1898. * cursor--the default--or it may be the corresponding field of
  1899. * another cursor, a DB handle, a join cursor, etc. In general, it
  1900. * will be whatever handle the user originally used for the current
  1901. * DB interface call.
  1902. */
  1903. DBT *rskey; /* Returned secondary key. */
  1904. DBT *rkey; /* Returned [primary] key. */
  1905. DBT *rdata; /* Returned data. */
  1906. DBT my_rskey; /* Space for returned secondary key. */
  1907. DBT my_rkey; /* Space for returned [primary] key. */
  1908. DBT my_rdata; /* Space for returned data. */
  1909. DB_LOCKER *lref; /* Reference to default locker. */
  1910. DB_LOCKER *locker; /* Locker for this operation. */
  1911. DBT lock_dbt; /* DBT referencing lock. */
  1912. DB_LOCK_ILOCK lock; /* Object to be locked. */
  1913. DB_LOCK mylock; /* CDB lock held on this cursor. */
  1914. DBTYPE dbtype; /* Cursor type. */
  1915. DBC_INTERNAL *internal; /* Access method private. */
  1916. /* DBC PUBLIC HANDLE LIST BEGIN */
  1917. int (*close) __P((DBC *));
  1918. int (*cmp) __P((DBC *, DBC *, int *, u_int32_t));
  1919. int (*count) __P((DBC *, db_recno_t *, u_int32_t));
  1920. int (*db_stream) __P((DBC *, DB_STREAM **, u_int32_t));
  1921. int (*del) __P((DBC *, u_int32_t));
  1922. int (*dup) __P((DBC *, DBC **, u_int32_t));
  1923. int (*get) __P((DBC *, DBT *, DBT *, u_int32_t));
  1924. int (*get_priority) __P((DBC *, DB_CACHE_PRIORITY *));
  1925. int (*pget) __P((DBC *, DBT *, DBT *, DBT *, u_int32_t));
  1926. int (*put) __P((DBC *, DBT *, DBT *, u_int32_t));
  1927. int (*set_priority) __P((DBC *, DB_CACHE_PRIORITY));
  1928. /* DBC PUBLIC HANDLE LIST END */
  1929. /* The following are the method names deprecated in the 4.6 release. */
  1930. int (*c_close) __P((DBC *));
  1931. int (*c_count) __P((DBC *, db_recno_t *, u_int32_t));
  1932. int (*c_del) __P((DBC *, u_int32_t));
  1933. int (*c_dup) __P((DBC *, DBC **, u_int32_t));
  1934. int (*c_get) __P((DBC *, DBT *, DBT *, u_int32_t));
  1935. int (*c_pget) __P((DBC *, DBT *, DBT *, DBT *, u_int32_t));
  1936. int (*c_put) __P((DBC *, DBT *, DBT *, u_int32_t));
  1937. /* DBC PRIVATE HANDLE LIST BEGIN */
  1938. int (*am_bulk) __P((DBC *, DBT *, u_int32_t));
  1939. int (*am_close) __P((DBC *, db_pgno_t, int *));
  1940. int (*am_del) __P((DBC *, u_int32_t));
  1941. int (*am_destroy) __P((DBC *));
  1942. int (*am_get) __P((DBC *, DBT *, DBT *, u_int32_t, db_pgno_t *));
  1943. int (*am_put) __P((DBC *, DBT *, DBT *, u_int32_t, db_pgno_t *));
  1944. int (*am_writelock) __P((DBC *));
  1945. /* DBC PRIVATE HANDLE LIST END */
  1946. /*
  1947. * DBC_DONTLOCK and DBC_RECOVER are used during recovery and transaction
  1948. * abort. If a transaction is being aborted or recovered then DBC_RECOVER
  1949. * will be set and locking and logging will be disabled on this cursor. If
  1950. * we are performing a compensating transaction (e.g. free page processing)
  1951. * then DB_DONTLOCK will be set to inhibit locking, but logging will still
  1952. * be required. DB_DONTLOCK is also used if the whole database is locked.
  1953. */
  1954. #define DBC_ACTIVE 0x00001 /* Cursor in use. */
  1955. #define DBC_BULK 0x00002 /* Bulk update cursor. */
  1956. #define DBC_DONTLOCK 0x00004 /* Don't lock on this cursor. */
  1957. #define DBC_DOWNREV 0x00008 /* Down rev replication master. */
  1958. #define DBC_DUPLICATE 0x00010 /* Create a duplicate cursor. */
  1959. #define DBC_ERROR 0x00020 /* Error in this request. */
  1960. #define DBC_FAMILY 0x00040 /* Part of a locker family. */
  1961. #define DBC_FROM_DB_GET 0x00080 /* Called from the DB->get() method. */
  1962. #define DBC_MULTIPLE 0x00100 /* Return Multiple data. */
  1963. #define DBC_MULTIPLE_KEY 0x00200 /* Return Multiple keys and data. */
  1964. #define DBC_OPD 0x00400 /* Cursor references off-page dups. */
  1965. #define DBC_OWN_LID 0x00800 /* Free lock id on destroy. */
  1966. #define DBC_PARTITIONED 0x01000 /* Cursor for a partitioned db. */
  1967. #define DBC_READ_COMMITTED 0x02000 /* Cursor has degree 2 isolation. */
  1968. #define DBC_READ_UNCOMMITTED 0x04000 /* Cursor has degree 1 isolation. */
  1969. #define DBC_RECOVER 0x08000 /* Recovery cursor; don't log/lock. */
  1970. #define DBC_RMW 0x10000 /* Acquire write flag in read op. */
  1971. #define DBC_TRANSIENT 0x20000 /* Cursor is transient. */
  1972. #define DBC_WAS_READ_COMMITTED 0x40000 /* Cursor holds a read commited lock. */
  1973. #define DBC_WRITECURSOR 0x80000 /* Cursor may be used to write (CDB). */
  1974. #define DBC_WRITER 0x100000 /* Cursor immediately writing (CDB). */
  1975. u_int32_t flags;
  1976. };
  1977. /* Key range statistics structure */
  1978. struct __key_range {
  1979. double less;
  1980. double equal;
  1981. double greater;
  1982. };
  1983. /* Btree/Recno statistics structure. */
  1984. struct __db_bt_stat { /* SHARED */
  1985. u_int32_t bt_magic; /* Magic number. */
  1986. u_int32_t bt_version; /* Version number. */
  1987. u_int32_t bt_metaflags; /* Metadata flags. */
  1988. u_int32_t bt_nkeys; /* Number of unique keys. */
  1989. u_int32_t bt_ndata; /* Number of data items. */
  1990. u_int32_t bt_pagecnt; /* Page count. */
  1991. u_int32_t bt_pagesize; /* Page size. */
  1992. u_int32_t bt_minkey; /* Minkey value. */
  1993. u_int32_t bt_nblobs; /* Number of blobs. */
  1994. u_int32_t bt_re_len; /* Fixed-length record length. */
  1995. u_int32_t bt_re_pad; /* Fixed-length record pad. */
  1996. u_int32_t bt_levels; /* Tree levels. */
  1997. u_int32_t bt_int_pg; /* Internal pages. */
  1998. u_int32_t bt_leaf_pg; /* Leaf pages. */
  1999. u_int32_t bt_dup_pg; /* Duplicate pages. */
  2000. u_int32_t bt_over_pg; /* Overflow pages. */
  2001. u_int32_t bt_empty_pg; /* Empty pages. */
  2002. u_int32_t bt_free; /* Pages on the free list. */
  2003. uintmax_t bt_int_pgfree; /* Bytes free in internal pages. */
  2004. uintmax_t bt_leaf_pgfree; /* Bytes free in leaf pages. */
  2005. uintmax_t bt_dup_pgfree; /* Bytes free in duplicate pages. */
  2006. uintmax_t bt_over_pgfree; /* Bytes free in overflow pages. */
  2007. };
  2008. struct __db_compact {
  2009. /* Input Parameters. */
  2010. u_int32_t compact_fillpercent; /* Desired fillfactor: 1-100 */
  2011. db_timeout_t compact_timeout; /* Lock timeout. */
  2012. u_int32_t compact_pages; /* Max pages to process. */
  2013. /* Output Stats. */
  2014. u_int32_t compact_empty_buckets; /* Empty hash buckets found. */
  2015. u_int32_t compact_pages_free; /* Number of pages freed. */
  2016. u_int32_t compact_pages_examine; /* Number of pages examine. */
  2017. u_int32_t compact_levels; /* Number of levels removed. */
  2018. u_int32_t compact_deadlock; /* Number of deadlocks. */
  2019. db_pgno_t compact_pages_truncated; /* Pages truncated to OS. */
  2020. /* Internal. */
  2021. db_pgno_t compact_truncate; /* Exchange pages above here. */
  2022. };
  2023. /* Hash statistics structure. */
  2024. struct __db_h_stat { /* SHARED */
  2025. u_int32_t hash_magic; /* Magic number. */
  2026. u_int32_t hash_version; /* Version number. */
  2027. u_int32_t hash_metaflags; /* Metadata flags. */
  2028. u_int32_t hash_nkeys; /* Number of unique keys. */
  2029. u_int32_t hash_ndata; /* Number of data items. */
  2030. u_int32_t hash_nblobs; /* Number of blobs. */
  2031. u_int32_t hash_pagecnt; /* Page count. */
  2032. u_int32_t hash_pagesize; /* Page size. */
  2033. u_int32_t hash_ffactor; /* Fill factor specified at create. */
  2034. u_int32_t hash_buckets; /* Number of hash buckets. */
  2035. u_int32_t hash_free; /* Pages on the free list. */
  2036. uintmax_t hash_bfree; /* Bytes free on bucket pages. */
  2037. u_int32_t hash_bigpages; /* Number of big key/data pages. */
  2038. uintmax_t hash_big_bfree; /* Bytes free on big item pages. */
  2039. u_int32_t hash_overflows; /* Number of overflow pages. */
  2040. uintmax_t hash_ovfl_free; /* Bytes free on ovfl pages. */
  2041. u_int32_t hash_dup; /* Number of dup pages. */
  2042. uintmax_t hash_dup_free; /* Bytes free on duplicate pages. */
  2043. };
  2044. /* Heap statistics structure. */
  2045. struct __db_heap_stat { /* SHARED */
  2046. u_int32_t heap_magic; /* Magic number. */
  2047. u_int32_t heap_version; /* Version number. */
  2048. u_int32_t heap_metaflags; /* Metadata flags. */
  2049. u_int32_t heap_nblobs; /* Number of blobs. */
  2050. u_int32_t heap_nrecs; /* Number of records. */
  2051. u_int32_t heap_pagecnt; /* Page count. */
  2052. u_int32_t heap_pagesize; /* Page size. */
  2053. u_int32_t heap_nregions; /* Number of regions. */
  2054. u_int32_t heap_regionsize; /* Number of pages in a region. */
  2055. };
  2056. /* Queue statistics structure. */
  2057. struct __db_qam_stat { /* SHARED */
  2058. u_int32_t qs_magic; /* Magic number. */
  2059. u_int32_t qs_version; /* Version number. */
  2060. u_int32_t qs_metaflags; /* Metadata flags. */
  2061. u_int32_t qs_nkeys; /* Number of unique keys. */
  2062. u_int32_t qs_ndata; /* Number of data items. */
  2063. u_int32_t qs_pagesize; /* Page size. */
  2064. u_int32_t qs_extentsize; /* Pages per extent. */
  2065. u_int32_t qs_pages; /* Data pages. */
  2066. u_int32_t qs_re_len; /* Fixed-length record length. */
  2067. u_int32_t qs_re_pad; /* Fixed-length record pad. */
  2068. u_int32_t qs_pgfree; /* Bytes free in data pages. */
  2069. u_int32_t qs_first_recno; /* First not deleted record. */
  2070. u_int32_t qs_cur_recno; /* Next available record number. */
  2071. };
  2072. /*******************************************************
  2073. * Environment.
  2074. *******************************************************/
  2075. #define DB_REGION_MAGIC 0x120897 /* Environment magic number. */
  2076. /*
  2077. * Database environment structure.
  2078. *
  2079. * This is the public database environment handle. The private environment
  2080. * handle is the ENV structure. The user owns this structure, the library
  2081. * owns the ENV structure. The reason there are two structures is because
  2082. * the user's configuration outlives any particular DB_ENV->open call, and
  2083. * separate structures allows us to easily discard internal information without
  2084. * discarding the user's configuration.
  2085. *
  2086. * Fields in the DB_ENV structure should normally be set only by application
  2087. * DB_ENV handle methods.
  2088. */
  2089. /*
  2090. * Memory configuration types.
  2091. */
  2092. typedef enum {
  2093. DB_MEM_LOCK=1,
  2094. DB_MEM_LOCKOBJECT=2,
  2095. DB_MEM_LOCKER=3,
  2096. DB_MEM_LOGID=4,
  2097. DB_MEM_TRANSACTION=5,
  2098. DB_MEM_THREAD=6
  2099. } DB_MEM_CONFIG;
  2100. /*
  2101. * Backup configuration types.
  2102. */
  2103. typedef enum {
  2104. DB_BACKUP_READ_COUNT=1,
  2105. DB_BACKUP_READ_SLEEP=2,
  2106. DB_BACKUP_SIZE=3,
  2107. DB_BACKUP_WRITE_DIRECT=4
  2108. } DB_BACKUP_CONFIG;
  2109. struct __db_env {
  2110. ENV *env; /* Linked ENV structure */
  2111. /*
  2112. * The DB_ENV structure can be used concurrently, so field access is
  2113. * protected.
  2114. */
  2115. db_mutex_t mtx_db_env; /* DB_ENV structure mutex */
  2116. /* Error message callback */
  2117. void (*db_errcall) __P((const DB_ENV *, const char *, const char *));
  2118. FILE *db_errfile; /* Error message file stream */
  2119. const char *db_errpfx; /* Error message prefix */
  2120. /* Other message callback */
  2121. void (*db_msgcall) __P((const DB_ENV *, const char *));
  2122. FILE *db_msgfile; /* Other message file stream */
  2123. /* Other application callback functions */
  2124. int (*app_dispatch) __P((DB_ENV *, DBT *, DB_LSN *, db_recops));
  2125. void (*db_event_func) __P((DB_ENV *, u_int32_t, void *));
  2126. void (*db_feedback) __P((DB_ENV *, int, int));
  2127. void (*db_free) __P((void *));
  2128. void (*db_paniccall) __P((DB_ENV *, int));
  2129. void *(*db_malloc) __P((size_t));
  2130. void *(*db_realloc) __P((void *, size_t));
  2131. int (*is_alive) __P((DB_ENV *, pid_t, db_threadid_t, u_int32_t));
  2132. void (*thread_id) __P((DB_ENV *, pid_t *, db_threadid_t *));
  2133. char *(*thread_id_string) __P((DB_ENV *, pid_t, db_threadid_t, char *));
  2134. /* Application specified paths */
  2135. char *db_blob_dir; /* Blob file directory */
  2136. char *db_log_dir; /* Database log file directory */
  2137. char *db_md_dir; /* Persistent metadata directory */
  2138. char *db_tmp_dir; /* Database tmp file directory */
  2139. char *db_create_dir; /* Create directory for data files */
  2140. char **db_data_dir; /* Database data file directories */
  2141. int data_cnt; /* Database data file slots */
  2142. int data_next; /* Next database data file slot */
  2143. char *intermediate_dir_mode; /* Intermediate directory perms */
  2144. long shm_key; /* shmget key */
  2145. char *passwd; /* Cryptography support */
  2146. size_t passwd_len;
  2147. /* Private handle references */
  2148. void *app_private; /* Application-private handle */
  2149. void *api1_internal; /* C++, Perl API private */
  2150. void *api2_internal; /* Java API private */
  2151. u_int32_t verbose; /* DB_VERB_XXX flags */
  2152. u_int32_t blob_threshold; /* Blob threshold record size */
  2153. /* Mutex configuration */
  2154. u_int32_t mutex_align; /* Mutex alignment */
  2155. u_int32_t mutex_cnt; /* Number of mutexes to configure */
  2156. u_int32_t mutex_inc; /* Number of mutexes to add */
  2157. u_int32_t mutex_max; /* Max number of mutexes */
  2158. u_int32_t mutex_tas_spins;/* Test-and-set spin count */
  2159. /* Locking configuration */
  2160. u_int8_t *lk_conflicts; /* Two dimensional conflict matrix */
  2161. int lk_modes; /* Number of lock modes in table */
  2162. u_int32_t lk_detect; /* Deadlock detect on all conflicts */
  2163. u_int32_t lk_max; /* Maximum number of locks */
  2164. u_int32_t lk_max_lockers;/* Maximum number of lockers */
  2165. u_int32_t lk_max_objects;/* Maximum number of locked objects */
  2166. u_int32_t lk_init; /* Initial number of locks */
  2167. u_int32_t lk_init_lockers;/* Initial number of lockers */
  2168. u_int32_t lk_init_objects;/* Initial number of locked objects */
  2169. u_int32_t lk_partitions ;/* Number of object partitions */
  2170. db_timeout_t lk_timeout; /* Lock timeout period */
  2171. /* Used during initialization */
  2172. u_int32_t locker_t_size; /* Locker hash table size. */
  2173. u_int32_t object_t_size; /* Object hash table size. */
  2174. /* Logging configuration */
  2175. u_int32_t lg_bsize; /* Buffer size */
  2176. u_int32_t lg_fileid_init; /* Initial allocation for fname structs */
  2177. int lg_filemode; /* Log file permission mode */
  2178. u_int32_t lg_regionmax; /* Region size */
  2179. u_int32_t lg_size; /* Log file size */
  2180. u_int32_t lg_flags; /* Log configuration */
  2181. /* Memory pool configuration */
  2182. u_int32_t mp_gbytes; /* Cache size: GB */
  2183. u_int32_t mp_bytes; /* Cache size: bytes */
  2184. u_int32_t mp_max_gbytes; /* Maximum cache size: GB */
  2185. u_int32_t mp_max_bytes; /* Maximum cache size: bytes */
  2186. size_t mp_mmapsize; /* Maximum file size for mmap */
  2187. int mp_maxopenfd; /* Maximum open file descriptors */
  2188. int mp_maxwrite; /* Maximum buffers to write */
  2189. u_int mp_ncache; /* Initial number of cache regions */
  2190. u_int32_t mp_pagesize; /* Average page size */
  2191. u_int32_t mp_tablesize; /* Approximate hash table size */
  2192. u_int32_t mp_mtxcount; /* Number of mutexs */
  2193. /* Sleep after writing max buffers */
  2194. db_timeout_t mp_maxwrite_sleep;
  2195. /* Transaction configuration */
  2196. u_int32_t tx_init; /* Initial number of transactions */
  2197. u_int32_t tx_max; /* Maximum number of transactions */
  2198. time_t tx_timestamp; /* Recover to specific timestamp */
  2199. db_timeout_t tx_timeout; /* Timeout for transactions */
  2200. /* Thread tracking configuration */
  2201. u_int32_t thr_init; /* Thread count */
  2202. u_int32_t thr_max; /* Thread max */
  2203. roff_t memory_max; /* Maximum region memory */
  2204. /*
  2205. * The following fields are not strictly user-owned, but they outlive
  2206. * the ENV structure, and so are stored here.
  2207. */
  2208. DB_FH *registry; /* DB_REGISTER file handle */
  2209. u_int32_t registry_off; /*
  2210. * Offset of our slot. We can't use
  2211. * off_t because its size depends on
  2212. * build settings.
  2213. */
  2214. db_timeout_t envreg_timeout; /* DB_REGISTER wait timeout */
  2215. #define DB_ENV_AUTO_COMMIT 0x00000001 /* DB_AUTO_COMMIT */
  2216. #define DB_ENV_CDB_ALLDB 0x00000002 /* CDB environment wide locking */
  2217. #define DB_ENV_FAILCHK 0x00000004 /* Failchk is running */
  2218. #define DB_ENV_DIRECT_DB 0x00000008 /* DB_DIRECT_DB set */
  2219. #define DB_ENV_DSYNC_DB 0x00000010 /* DB_DSYNC_DB set */
  2220. #define DB_ENV_DATABASE_LOCKING 0x00000020 /* Try database-level locking */
  2221. #define DB_ENV_MULTIVERSION 0x00000040 /* DB_MULTIVERSION set */
  2222. #define DB_ENV_NOLOCKING 0x00000080 /* DB_NOLOCKING set */
  2223. #define DB_ENV_NOMMAP 0x00000100 /* DB_NOMMAP set */
  2224. #define DB_ENV_NOPANIC 0x00000200 /* Okay if panic set */
  2225. #define DB_ENV_OVERWRITE 0x00000400 /* DB_OVERWRITE set */
  2226. #define DB_ENV_REGION_INIT 0x00000800 /* DB_REGION_INIT set */
  2227. #define DB_ENV_TIME_NOTGRANTED 0x00001000 /* DB_TIME_NOTGRANTED set */
  2228. #define DB_ENV_TXN_NOSYNC 0x00002000 /* DB_TXN_NOSYNC set */
  2229. #define DB_ENV_TXN_NOWAIT 0x00004000 /* DB_TXN_NOWAIT set */
  2230. #define DB_ENV_TXN_SNAPSHOT 0x00008000 /* DB_TXN_SNAPSHOT set */
  2231. #define DB_ENV_TXN_WRITE_NOSYNC 0x00010000 /* DB_TXN_WRITE_NOSYNC set */
  2232. #define DB_ENV_YIELDCPU 0x00020000 /* DB_YIELDCPU set */
  2233. #define DB_ENV_HOTBACKUP 0x00040000 /* DB_HOTBACKUP_IN_PROGRESS set */
  2234. #define DB_ENV_NOFLUSH 0x00080000 /* DB_NOFLUSH set */
  2235. u_int32_t flags;
  2236. /* DB_ENV PUBLIC HANDLE LIST BEGIN */
  2237. int (*add_data_dir) __P((DB_ENV *, const char *));
  2238. int (*backup) __P((DB_ENV *, const char *, u_int32_t));
  2239. int (*cdsgroup_begin) __P((DB_ENV *, DB_TXN **));
  2240. int (*close) __P((DB_ENV *, u_int32_t));
  2241. int (*dbbackup) __P((DB_ENV *, const char *, const char *, u_int32_t));
  2242. int (*dbremove) __P((DB_ENV *,
  2243. DB_TXN *, const char *, const char *, u_int32_t));
  2244. int (*dbrename) __P((DB_ENV *,
  2245. DB_TXN *, const char *, const char *, const char *, u_int32_t));
  2246. void (*err) __P((const DB_ENV *, int, const char *, ...));
  2247. void (*errx) __P((const DB_ENV *, const char *, ...));
  2248. int (*failchk) __P((DB_ENV *, u_int32_t));
  2249. int (*fileid_reset) __P((DB_ENV *, const char *, u_int32_t));
  2250. int (*get_alloc) __P((DB_ENV *, void *(**)(size_t),
  2251. void *(**)(void *, size_t), void (**)(void *)));
  2252. int (*get_app_dispatch)
  2253. __P((DB_ENV *, int (**)(DB_ENV *, DBT *, DB_LSN *, db_recops)));
  2254. int (*get_blob_dir) __P((DB_ENV *, const char **));
  2255. int (*get_blob_threshold) __P((DB_ENV*, u_int32_t *));
  2256. int (*get_cache_max) __P((DB_ENV *, u_int32_t *, u_int32_t *));
  2257. int (*get_cachesize) __P((DB_ENV *, u_int32_t *, u_int32_t *, int *));
  2258. int (*get_create_dir) __P((DB_ENV *, const char **));
  2259. int (*get_data_dirs) __P((DB_ENV *, const char ***));
  2260. int (*get_data_len) __P((DB_ENV *, u_int32_t *));
  2261. int (*get_backup_callbacks) __P((DB_ENV *,
  2262. int (**)(DB_ENV *, const char *, const char *, void **),
  2263. int (**)(DB_ENV *, u_int32_t, u_int32_t, u_int32_t, u_int8_t *, void *),
  2264. int (**)(DB_ENV *, const char *, void *)));
  2265. int (*get_backup_config) __P((DB_ENV *, DB_BACKUP_CONFIG, u_int32_t *));
  2266. int (*get_encrypt_flags) __P((DB_ENV *, u_int32_t *));
  2267. void (*get_errcall) __P((DB_ENV *,
  2268. void (**)(const DB_ENV *, const char *, const char *)));
  2269. void (*get_errfile) __P((DB_ENV *, FILE **));
  2270. void (*get_errpfx) __P((DB_ENV *, const char **));
  2271. int (*get_flags) __P((DB_ENV *, u_int32_t *));
  2272. int (*get_feedback) __P((DB_ENV *, void (**)(DB_ENV *, int, int)));
  2273. int (*get_home) __P((DB_ENV *, const char **));
  2274. int (*get_intermediate_dir_mode) __P((DB_ENV *, const char **));
  2275. int (*get_isalive) __P((DB_ENV *,
  2276. int (**)(DB_ENV *, pid_t, db_threadid_t, u_int32_t)));
  2277. int (*get_lg_bsize) __P((DB_ENV *, u_int32_t *));
  2278. int (*get_lg_dir) __P((DB_ENV *, const char **));
  2279. int (*get_lg_filemode) __P((DB_ENV *, int *));
  2280. int (*get_lg_max) __P((DB_ENV *, u_int32_t *));
  2281. int (*get_lg_regionmax) __P((DB_ENV *, u_int32_t *));
  2282. int (*get_lk_conflicts) __P((DB_ENV *, const u_int8_t **, int *));
  2283. int (*get_lk_detect) __P((DB_ENV *, u_int32_t *));
  2284. int (*get_lk_max_lockers) __P((DB_ENV *, u_int32_t *));
  2285. int (*get_lk_max_locks) __P((DB_ENV *, u_int32_t *));
  2286. int (*get_lk_max_objects) __P((DB_ENV *, u_int32_t *));
  2287. int (*get_lk_partitions) __P((DB_ENV *, u_int32_t *));
  2288. int (*get_lk_priority) __P((DB_ENV *, u_int32_t, u_int32_t *));
  2289. int (*get_lk_tablesize) __P((DB_ENV *, u_int32_t *));
  2290. int (*get_memory_init) __P((DB_ENV *, DB_MEM_CONFIG, u_int32_t *));
  2291. int (*get_memory_max) __P((DB_ENV *, u_int32_t *, u_int32_t *));
  2292. int (*get_metadata_dir) __P((DB_ENV *, const char **));
  2293. int (*get_mp_max_openfd) __P((DB_ENV *, int *));
  2294. int (*get_mp_max_write) __P((DB_ENV *, int *, db_timeout_t *));
  2295. int (*get_mp_mmapsize) __P((DB_ENV *, size_t *));
  2296. int (*get_mp_mtxcount) __P((DB_ENV *, u_int32_t *));
  2297. int (*get_mp_pagesize) __P((DB_ENV *, u_int32_t *));
  2298. int (*get_mp_tablesize) __P((DB_ENV *, u_int32_t *));
  2299. void (*get_msgcall)
  2300. __P((DB_ENV *, void (**)(const DB_ENV *, const char *)));
  2301. void (*get_msgfile) __P((DB_ENV *, FILE **));
  2302. int (*get_open_flags) __P((DB_ENV *, u_int32_t *));
  2303. int (*get_shm_key) __P((DB_ENV *, long *));
  2304. int (*get_thread_count) __P((DB_ENV *, u_int32_t *));
  2305. int (*get_thread_id_fn)
  2306. __P((DB_ENV *, void (**)(DB_ENV *, pid_t *, db_threadid_t *)));
  2307. int (*get_thread_id_string_fn) __P((DB_ENV *,
  2308. char *(**)(DB_ENV *, pid_t, db_threadid_t, char *)));
  2309. int (*get_timeout) __P((DB_ENV *, db_timeout_t *, u_int32_t));
  2310. int (*get_tmp_dir) __P((DB_ENV *, const char **));
  2311. int (*get_tx_max) __P((DB_ENV *, u_int32_t *));
  2312. int (*get_tx_timestamp) __P((DB_ENV *, time_t *));
  2313. int (*get_verbose) __P((DB_ENV *, u_int32_t, int *));
  2314. int (*is_bigendian) __P((void));
  2315. int (*lock_detect) __P((DB_ENV *, u_int32_t, u_int32_t, int *));
  2316. int (*lock_get) __P((DB_ENV *,
  2317. u_int32_t, u_int32_t, DBT *, db_lockmode_t, DB_LOCK *));
  2318. int (*lock_id) __P((DB_ENV *, u_int32_t *));
  2319. int (*lock_id_free) __P((DB_ENV *, u_int32_t));
  2320. int (*lock_put) __P((DB_ENV *, DB_LOCK *));
  2321. int (*lock_stat) __P((DB_ENV *, DB_LOCK_STAT **, u_int32_t));
  2322. int (*lock_stat_print) __P((DB_ENV *, u_int32_t));
  2323. int (*lock_vec) __P((DB_ENV *,
  2324. u_int32_t, u_int32_t, DB_LOCKREQ *, int, DB_LOCKREQ **));
  2325. int (*log_archive) __P((DB_ENV *, char **[], u_int32_t));
  2326. int (*log_cursor) __P((DB_ENV *, DB_LOGC **, u_int32_t));
  2327. int (*log_file) __P((DB_ENV *, const DB_LSN *, char *, size_t));
  2328. int (*log_flush) __P((DB_ENV *, const DB_LSN *));
  2329. int (*log_get_config) __P((DB_ENV *, u_int32_t, int *));
  2330. int (*log_printf) __P((DB_ENV *, DB_TXN *, const char *, ...));
  2331. int (*log_put) __P((DB_ENV *, DB_LSN *, const DBT *, u_int32_t));
  2332. int (*log_put_record) __P((DB_ENV *, DB *, DB_TXN *, DB_LSN *,
  2333. u_int32_t, u_int32_t, u_int32_t, u_int32_t,
  2334. DB_LOG_RECSPEC *, ...));
  2335. int (*log_read_record) __P((DB_ENV *, DB **,
  2336. void *, void *, DB_LOG_RECSPEC *, u_int32_t, void **));
  2337. int (*log_set_config) __P((DB_ENV *, u_int32_t, int));
  2338. int (*log_stat) __P((DB_ENV *, DB_LOG_STAT **, u_int32_t));
  2339. int (*log_stat_print) __P((DB_ENV *, u_int32_t));
  2340. int (*log_verify) __P((DB_ENV *, const DB_LOG_VERIFY_CONFIG *));
  2341. int (*lsn_reset) __P((DB_ENV *, const char *, u_int32_t));
  2342. int (*memp_fcreate) __P((DB_ENV *, DB_MPOOLFILE **, u_int32_t));
  2343. int (*memp_register) __P((DB_ENV *, int, int (*)(DB_ENV *, db_pgno_t,
  2344. void *, DBT *), int (*)(DB_ENV *, db_pgno_t, void *, DBT *)));
  2345. int (*memp_stat) __P((DB_ENV *,
  2346. DB_MPOOL_STAT **, DB_MPOOL_FSTAT ***, u_int32_t));
  2347. int (*memp_stat_print) __P((DB_ENV *, u_int32_t));
  2348. int (*memp_sync) __P((DB_ENV *, DB_LSN *));
  2349. int (*memp_trickle) __P((DB_ENV *, int, int *));
  2350. int (*mutex_alloc) __P((DB_ENV *, u_int32_t, db_mutex_t *));
  2351. int (*mutex_free) __P((DB_ENV *, db_mutex_t));
  2352. int (*mutex_get_align) __P((DB_ENV *, u_int32_t *));
  2353. int (*mutex_get_increment) __P((DB_ENV *, u_int32_t *));
  2354. int (*mutex_get_init) __P((DB_ENV *, u_int32_t *));
  2355. int (*mutex_get_max) __P((DB_ENV *, u_int32_t *));
  2356. int (*mutex_get_tas_spins) __P((DB_ENV *, u_int32_t *));
  2357. int (*mutex_lock) __P((DB_ENV *, db_mutex_t));
  2358. int (*mutex_set_align) __P((DB_ENV *, u_int32_t));
  2359. int (*mutex_set_increment) __P((DB_ENV *, u_int32_t));
  2360. int (*mutex_set_init) __P((DB_ENV *, u_int32_t));
  2361. int (*mutex_set_max) __P((DB_ENV *, u_int32_t));
  2362. int (*mutex_set_tas_spins) __P((DB_ENV *, u_int32_t));
  2363. int (*mutex_stat) __P((DB_ENV *, DB_MUTEX_STAT **, u_int32_t));
  2364. int (*mutex_stat_print) __P((DB_ENV *, u_int32_t));
  2365. int (*mutex_unlock) __P((DB_ENV *, db_mutex_t));
  2366. int (*open) __P((DB_ENV *, const char *, u_int32_t, int));
  2367. int (*remove) __P((DB_ENV *, const char *, u_int32_t));
  2368. int (*rep_elect) __P((DB_ENV *, u_int32_t, u_int32_t, u_int32_t));
  2369. int (*rep_flush) __P((DB_ENV *));
  2370. int (*rep_get_clockskew) __P((DB_ENV *, u_int32_t *, u_int32_t *));
  2371. int (*rep_get_config) __P((DB_ENV *, u_int32_t, int *));
  2372. int (*rep_get_limit) __P((DB_ENV *, u_int32_t *, u_int32_t *));
  2373. int (*rep_get_nsites) __P((DB_ENV *, u_int32_t *));
  2374. int (*rep_get_priority) __P((DB_ENV *, u_int32_t *));
  2375. int (*rep_get_request) __P((DB_ENV *, u_int32_t *, u_int32_t *));
  2376. int (*rep_get_timeout) __P((DB_ENV *, int, u_int32_t *));
  2377. int (*rep_process_message)
  2378. __P((DB_ENV *, DBT *, DBT *, int, DB_LSN *));
  2379. int (*rep_set_clockskew) __P((DB_ENV *, u_int32_t, u_int32_t));
  2380. int (*rep_set_config) __P((DB_ENV *, u_int32_t, int));
  2381. int (*rep_set_limit) __P((DB_ENV *, u_int32_t, u_int32_t));
  2382. int (*rep_set_nsites) __P((DB_ENV *, u_int32_t));
  2383. int (*rep_set_priority) __P((DB_ENV *, u_int32_t));
  2384. int (*rep_set_request) __P((DB_ENV *, u_int32_t, u_int32_t));
  2385. int (*rep_set_timeout) __P((DB_ENV *, int, db_timeout_t));
  2386. int (*rep_set_transport) __P((DB_ENV *, int, int (*)(DB_ENV *,
  2387. const DBT *, const DBT *, const DB_LSN *, int, u_int32_t)));
  2388. int (*rep_set_view) __P((DB_ENV *, int (*)(DB_ENV *,
  2389. const char *, int *, u_int32_t)));
  2390. int (*rep_start) __P((DB_ENV *, DBT *, u_int32_t));
  2391. int (*rep_stat) __P((DB_ENV *, DB_REP_STAT **, u_int32_t));
  2392. int (*rep_stat_print) __P((DB_ENV *, u_int32_t));
  2393. int (*rep_sync) __P((DB_ENV *, u_int32_t));
  2394. int (*repmgr_channel) __P((DB_ENV *, int, DB_CHANNEL **, u_int32_t));
  2395. int (*repmgr_get_ack_policy) __P((DB_ENV *, int *));
  2396. int (*repmgr_get_incoming_queue_max)
  2397. __P((DB_ENV *, u_int32_t *, u_int32_t *));
  2398. int (*repmgr_local_site) __P((DB_ENV *, DB_SITE **));
  2399. int (*repmgr_msg_dispatch) __P((DB_ENV *,
  2400. void (*)(DB_ENV *, DB_CHANNEL *, DBT *, u_int32_t, u_int32_t),
  2401. u_int32_t));
  2402. int (*repmgr_set_ack_policy) __P((DB_ENV *, int));
  2403. int (*repmgr_set_incoming_queue_max)
  2404. __P((DB_ENV *, u_int32_t, u_int32_t));
  2405. int (*repmgr_site)
  2406. __P((DB_ENV *, const char *, u_int, DB_SITE**, u_int32_t));
  2407. int (*repmgr_site_by_eid) __P((DB_ENV *, int, DB_SITE**));
  2408. int (*repmgr_site_list) __P((DB_ENV *, u_int *, DB_REPMGR_SITE **));
  2409. int (*repmgr_start) __P((DB_ENV *, int, u_int32_t));
  2410. int (*repmgr_stat) __P((DB_ENV *, DB_REPMGR_STAT **, u_int32_t));
  2411. int (*repmgr_stat_print) __P((DB_ENV *, u_int32_t));
  2412. int (*set_alloc) __P((DB_ENV *, void *(*)(size_t),
  2413. void *(*)(void *, size_t), void (*)(void *)));
  2414. int (*set_app_dispatch)
  2415. __P((DB_ENV *, int (*)(DB_ENV *, DBT *, DB_LSN *, db_recops)));
  2416. int (*set_blob_dir) __P((DB_ENV *, const char *));
  2417. int (*set_blob_threshold) __P((DB_ENV *, u_int32_t, u_int32_t));
  2418. int (*set_cache_max) __P((DB_ENV *, u_int32_t, u_int32_t));
  2419. int (*set_cachesize) __P((DB_ENV *, u_int32_t, u_int32_t, int));
  2420. int (*set_create_dir) __P((DB_ENV *, const char *));
  2421. int (*set_data_dir) __P((DB_ENV *, const char *));
  2422. int (*set_data_len) __P((DB_ENV *, u_int32_t));
  2423. int (*set_backup_callbacks) __P((DB_ENV *,
  2424. int (*)(DB_ENV *, const char *, const char *, void **),
  2425. int (*)(DB_ENV *, u_int32_t,
  2426. u_int32_t, u_int32_t, u_int8_t *, void *),
  2427. int (*)(DB_ENV *, const char *, void *)));
  2428. int (*set_backup_config) __P((DB_ENV *, DB_BACKUP_CONFIG, u_int32_t));
  2429. int (*set_encrypt) __P((DB_ENV *, const char *, u_int32_t));
  2430. void (*set_errcall) __P((DB_ENV *,
  2431. void (*)(const DB_ENV *, const char *, const char *)));
  2432. void (*set_errfile) __P((DB_ENV *, FILE *));
  2433. void (*set_errpfx) __P((DB_ENV *, const char *));
  2434. int (*set_event_notify)
  2435. __P((DB_ENV *, void (*)(DB_ENV *, u_int32_t, void *)));
  2436. int (*set_feedback) __P((DB_ENV *, void (*)(DB_ENV *, int, int)));
  2437. int (*set_flags) __P((DB_ENV *, u_int32_t, int));
  2438. int (*set_intermediate_dir_mode) __P((DB_ENV *, const char *));
  2439. int (*set_isalive) __P((DB_ENV *,
  2440. int (*)(DB_ENV *, pid_t, db_threadid_t, u_int32_t)));
  2441. int (*set_lg_bsize) __P((DB_ENV *, u_int32_t));
  2442. int (*set_lg_dir) __P((DB_ENV *, const char *));
  2443. int (*set_lg_filemode) __P((DB_ENV *, int));
  2444. int (*set_lg_max) __P((DB_ENV *, u_int32_t));
  2445. int (*set_lg_regionmax) __P((DB_ENV *, u_int32_t));
  2446. int (*set_lk_conflicts) __P((DB_ENV *, u_int8_t *, int));
  2447. int (*set_lk_detect) __P((DB_ENV *, u_int32_t));
  2448. int (*set_lk_max_lockers) __P((DB_ENV *, u_int32_t));
  2449. int (*set_lk_max_locks) __P((DB_ENV *, u_int32_t));
  2450. int (*set_lk_max_objects) __P((DB_ENV *, u_int32_t));
  2451. int (*set_lk_partitions) __P((DB_ENV *, u_int32_t));
  2452. int (*set_lk_priority) __P((DB_ENV *, u_int32_t, u_int32_t));
  2453. int (*set_lk_tablesize) __P((DB_ENV *, u_int32_t));
  2454. int (*set_memory_init) __P((DB_ENV *, DB_MEM_CONFIG, u_int32_t));
  2455. int (*set_memory_max) __P((DB_ENV *, u_int32_t, u_int32_t));
  2456. int (*set_metadata_dir) __P((DB_ENV *, const char *));
  2457. int (*set_mp_max_openfd) __P((DB_ENV *, int));
  2458. int (*set_mp_max_write) __P((DB_ENV *, int, db_timeout_t));
  2459. int (*set_mp_mmapsize) __P((DB_ENV *, size_t));
  2460. int (*set_mp_mtxcount) __P((DB_ENV *, u_int32_t));
  2461. int (*set_mp_pagesize) __P((DB_ENV *, u_int32_t));
  2462. int (*set_mp_tablesize) __P((DB_ENV *, u_int32_t));
  2463. void (*set_msgcall)
  2464. __P((DB_ENV *, void (*)(const DB_ENV *, const char *)));
  2465. void (*set_msgfile) __P((DB_ENV *, FILE *));
  2466. int (*set_paniccall) __P((DB_ENV *, void (*)(DB_ENV *, int)));
  2467. int (*set_shm_key) __P((DB_ENV *, long));
  2468. int (*set_thread_count) __P((DB_ENV *, u_int32_t));
  2469. int (*set_thread_id)
  2470. __P((DB_ENV *, void (*)(DB_ENV *, pid_t *, db_threadid_t *)));
  2471. int (*set_thread_id_string) __P((DB_ENV *,
  2472. char *(*)(DB_ENV *, pid_t, db_threadid_t, char *)));
  2473. int (*set_timeout) __P((DB_ENV *, db_timeout_t, u_int32_t));
  2474. int (*set_tmp_dir) __P((DB_ENV *, const char *));
  2475. int (*set_tx_max) __P((DB_ENV *, u_int32_t));
  2476. int (*set_tx_timestamp) __P((DB_ENV *, time_t *));
  2477. int (*set_verbose) __P((DB_ENV *, u_int32_t, int));
  2478. int (*txn_applied) __P((DB_ENV *,
  2479. DB_TXN_TOKEN *, db_timeout_t, u_int32_t));
  2480. int (*stat_print) __P((DB_ENV *, u_int32_t));
  2481. int (*txn_begin) __P((DB_ENV *, DB_TXN *, DB_TXN **, u_int32_t));
  2482. int (*txn_checkpoint) __P((DB_ENV *, u_int32_t, u_int32_t, u_int32_t));
  2483. int (*txn_recover) __P((DB_ENV *,
  2484. DB_PREPLIST *, long, long *, u_int32_t));
  2485. int (*txn_stat) __P((DB_ENV *, DB_TXN_STAT **, u_int32_t));
  2486. int (*txn_stat_print) __P((DB_ENV *, u_int32_t));
  2487. /* DB_ENV PUBLIC HANDLE LIST END */
  2488. /* DB_ENV PRIVATE HANDLE LIST BEGIN */
  2489. int (*prdbt) __P((DBT *, int, const char *, void *,
  2490. int (*)(void *, const void *), int, int, int));
  2491. /* DB_ENV PRIVATE HANDLE LIST END */
  2492. };
  2493. /*
  2494. * Dispatch structure for recovery, log verification and print routines. Since
  2495. * internal and external routines take different arguments (ENV versus DB_ENV),
  2496. * we need something more elaborate than a single pointer and size.
  2497. */
  2498. struct __db_distab {
  2499. int (**int_dispatch) __P((ENV *, DBT *, DB_LSN *, db_recops, void *));
  2500. size_t int_size;
  2501. int (**ext_dispatch) __P((DB_ENV *, DBT *, DB_LSN *, db_recops));
  2502. size_t ext_size;
  2503. };
  2504. /*
  2505. * Log verification configuration structure.
  2506. */
  2507. struct __db_logvrfy_config {
  2508. int continue_after_fail, verbose;
  2509. u_int32_t cachesize;
  2510. const char *temp_envhome;
  2511. const char *dbfile, *dbname;
  2512. DB_LSN start_lsn, end_lsn;
  2513. time_t start_time, end_time;
  2514. };
  2515. struct __db_channel {
  2516. CHANNEL *channel; /* Pointer to internal state details. */
  2517. int eid; /* Env. ID passed in constructor. */
  2518. db_timeout_t timeout;
  2519. /* DB_CHANNEL PUBLIC HANDLE LIST BEGIN */
  2520. int (*close) __P((DB_CHANNEL *, u_int32_t));
  2521. int (*send_msg) __P((DB_CHANNEL *, DBT *, u_int32_t, u_int32_t));
  2522. int (*send_request) __P((DB_CHANNEL *,
  2523. DBT *, u_int32_t, DBT *, db_timeout_t, u_int32_t));
  2524. int (*set_timeout) __P((DB_CHANNEL *, db_timeout_t));
  2525. /* DB_CHANNEL PUBLIC HANDLE LIST END */
  2526. };
  2527. struct __db_site {
  2528. ENV *env;
  2529. int eid;
  2530. const char *host;
  2531. u_int port;
  2532. u_int32_t flags;
  2533. /* DB_SITE PUBLIC HANDLE LIST BEGIN */
  2534. int (*get_address) __P((DB_SITE *, const char **, u_int *));
  2535. int (*get_config) __P((DB_SITE *, u_int32_t, u_int32_t *));
  2536. int (*get_eid) __P((DB_SITE *, int *));
  2537. int (*set_config) __P((DB_SITE *, u_int32_t, u_int32_t));
  2538. int (*remove) __P((DB_SITE *));
  2539. int (*close) __P((DB_SITE *));
  2540. /* DB_SITE PUBLIC HANDLE LIST END */
  2541. };
  2542. #if DB_DBM_HSEARCH != 0
  2543. /*******************************************************
  2544. * Dbm/Ndbm historic interfaces.
  2545. *******************************************************/
  2546. typedef struct __db DBM;
  2547. #define DBM_INSERT 0 /* Flags to dbm_store(). */
  2548. #define DBM_REPLACE 1
  2549. /*
  2550. * The DB support for ndbm(3) always appends this suffix to the
  2551. * file name to avoid overwriting the user's original database.
  2552. */
  2553. #define DBM_SUFFIX ".db"
  2554. #if defined(_XPG4_2)
  2555. typedef struct {
  2556. char *dptr;
  2557. size_t dsize;
  2558. } datum;
  2559. #else
  2560. typedef struct {
  2561. char *dptr;
  2562. int dsize;
  2563. } datum;
  2564. #endif
  2565. /*
  2566. * Translate NDBM calls into DB calls so that DB doesn't step on the
  2567. * application's name space.
  2568. */
  2569. #define dbm_clearerr(a) __db_ndbm_clearerr(a)
  2570. #define dbm_close(a) __db_ndbm_close(a)
  2571. #define dbm_delete(a, b) __db_ndbm_delete(a, b)
  2572. #define dbm_dirfno(a) __db_ndbm_dirfno(a)
  2573. #define dbm_error(a) __db_ndbm_error(a)
  2574. #define dbm_fetch(a, b) __db_ndbm_fetch(a, b)
  2575. #define dbm_firstkey(a) __db_ndbm_firstkey(a)
  2576. #define dbm_nextkey(a) __db_ndbm_nextkey(a)
  2577. #define dbm_open(a, b, c) __db_ndbm_open(a, b, c)
  2578. #define dbm_pagfno(a) __db_ndbm_pagfno(a)
  2579. #define dbm_rdonly(a) __db_ndbm_rdonly(a)
  2580. #define dbm_store(a, b, c, d) \
  2581. __db_ndbm_store(a, b, c, d)
  2582. /*
  2583. * Translate DBM calls into DB calls so that DB doesn't step on the
  2584. * application's name space.
  2585. *
  2586. * The global variables dbrdonly, dirf and pagf were not retained when 4BSD
  2587. * replaced the dbm interface with ndbm, and are not supported here.
  2588. */
  2589. #define dbminit(a) __db_dbm_init(a)
  2590. #define dbmclose __db_dbm_close
  2591. #if !defined(__cplusplus)
  2592. #define delete(a) __db_dbm_delete(a)
  2593. #endif
  2594. #define fetch(a) __db_dbm_fetch(a)
  2595. #define firstkey __db_dbm_firstkey
  2596. #define nextkey(a) __db_dbm_nextkey(a)
  2597. #define store(a, b) __db_dbm_store(a, b)
  2598. /*******************************************************
  2599. * Hsearch historic interface.
  2600. *******************************************************/
  2601. typedef enum {
  2602. FIND, ENTER
  2603. } ACTION;
  2604. typedef struct entry {
  2605. char *key;
  2606. char *data;
  2607. } ENTRY;
  2608. #define hcreate(a) __db_hcreate(a)
  2609. #define hdestroy __db_hdestroy
  2610. #define hsearch(a, b) __db_hsearch(a, b)
  2611. #endif /* DB_DBM_HSEARCH */
  2612. #if defined(__cplusplus)
  2613. }
  2614. #endif
  2615. #endif /* !_DB_H_ */
  2616. /* DO NOT EDIT: automatically built by dist/s_apiflags. */
  2617. #define DB_AGGRESSIVE 0x00000001
  2618. #define DB_ARCH_ABS 0x00000001
  2619. #define DB_ARCH_DATA 0x00000002
  2620. #define DB_ARCH_LOG 0x00000004
  2621. #define DB_ARCH_REMOVE 0x00000008
  2622. #define DB_AUTO_COMMIT 0x00000100
  2623. #define DB_BACKUP_CLEAN 0x00000002
  2624. #define DB_BACKUP_FILES 0x00000008
  2625. #define DB_BACKUP_NO_LOGS 0x00000010
  2626. #define DB_BACKUP_SINGLE_DIR 0x00000020
  2627. #define DB_BACKUP_UPDATE 0x00000040
  2628. #define DB_BOOTSTRAP_HELPER 0x00000001
  2629. #define DB_CDB_ALLDB 0x00000040
  2630. #define DB_CHKSUM 0x00000008
  2631. #define DB_CKP_INTERNAL 0x00000002
  2632. #define DB_CREATE 0x00000001
  2633. #define DB_CURSOR_BULK 0x00000001
  2634. #define DB_CURSOR_TRANSIENT 0x00000008
  2635. #define DB_CXX_NO_EXCEPTIONS 0x00000002
  2636. #define DB_DATABASE_LOCKING 0x00000080
  2637. #define DB_DIRECT 0x00000020
  2638. #define DB_DIRECT_DB 0x00000200
  2639. #define DB_DSYNC_DB 0x00000400
  2640. #define DB_DUP 0x00000010
  2641. #define DB_DUPSORT 0x00000002
  2642. #define DB_DURABLE_UNKNOWN 0x00000040
  2643. #define DB_ENCRYPT 0x00000001
  2644. #define DB_ENCRYPT_AES 0x00000001
  2645. #define DB_EXCL 0x00000004
  2646. #define DB_EXTENT 0x00000100
  2647. #define DB_FAILCHK 0x00000010
  2648. #define DB_FAILCHK_ISALIVE 0x00000040
  2649. #define DB_FAST_STAT 0x00000001
  2650. #define DB_FCNTL_LOCKING 0x00000800
  2651. #define DB_FLUSH 0x00000002
  2652. #define DB_FORCE 0x00000001
  2653. #define DB_FORCESYNC 0x00000001
  2654. #define DB_FOREIGN_ABORT 0x00000001
  2655. #define DB_FOREIGN_CASCADE 0x00000002
  2656. #define DB_FOREIGN_NULLIFY 0x00000004
  2657. #define DB_FREELIST_ONLY 0x00000001
  2658. #define DB_FREE_SPACE 0x00000002
  2659. #define DB_GROUP_CREATOR 0x00000002
  2660. #define DB_HOTBACKUP_IN_PROGRESS 0x00000800
  2661. #define DB_IGNORE_LEASE 0x00001000
  2662. #define DB_IMMUTABLE_KEY 0x00000002
  2663. #define DB_INIT_CDB 0x00000080
  2664. #define DB_INIT_LOCK 0x00000100
  2665. #define DB_INIT_LOG 0x00000200
  2666. #define DB_INIT_MPOOL 0x00000400
  2667. #define DB_INIT_MUTEX 0x00000800
  2668. #define DB_INIT_REP 0x00001000
  2669. #define DB_INIT_TXN 0x00002000
  2670. #define DB_INORDER 0x00000020
  2671. #define DB_INTERNAL_BLOB_DB 0x00001000
  2672. #define DB_INTERNAL_PERSISTENT_DB 0x00002000
  2673. #define DB_INTERNAL_TEMPORARY_DB 0x00004000
  2674. #define DB_JOIN_NOSORT 0x00000001
  2675. #define DB_LEGACY 0x00000004
  2676. #define DB_LOCAL_SITE 0x00000008
  2677. #define DB_LOCKDOWN 0x00004000
  2678. #define DB_LOCK_CHECK 0x00000001
  2679. #define DB_LOCK_IGNORE_REC 0x00000002
  2680. #define DB_LOCK_NOWAIT 0x00000004
  2681. #define DB_LOCK_RECORD 0x00000008
  2682. #define DB_LOCK_SET_TIMEOUT 0x00000010
  2683. #define DB_LOCK_SWITCH 0x00000020
  2684. #define DB_LOCK_UPGRADE 0x00000040
  2685. #define DB_LOG_AUTO_REMOVE 0x00000001
  2686. #define DB_LOG_BLOB 0x00000002
  2687. #define DB_LOG_CHKPNT 0x00000001
  2688. #define DB_LOG_COMMIT 0x00000004
  2689. #define DB_LOG_DIRECT 0x00000004
  2690. #define DB_LOG_DSYNC 0x00000008
  2691. #define DB_LOG_IN_MEMORY 0x00000010
  2692. #define DB_LOG_NOCOPY 0x00000008
  2693. #define DB_LOG_NOT_DURABLE 0x00000010
  2694. #define DB_LOG_NO_DATA 0x00000002
  2695. #define DB_LOG_VERIFY_CAF 0x00000001
  2696. #define DB_LOG_VERIFY_DBFILE 0x00000002
  2697. #define DB_LOG_VERIFY_ERR 0x00000004
  2698. #define DB_LOG_VERIFY_FORWARD 0x00000008
  2699. #define DB_LOG_VERIFY_INTERR 0x00000010
  2700. #define DB_LOG_VERIFY_PARTIAL 0x00000020
  2701. #define DB_LOG_VERIFY_VERBOSE 0x00000040
  2702. #define DB_LOG_VERIFY_WARNING 0x00000080
  2703. #define DB_LOG_WRNOSYNC 0x00000020
  2704. #define DB_LOG_ZERO 0x00000020
  2705. #define DB_MPOOL_CREATE 0x00000001
  2706. #define DB_MPOOL_DIRTY 0x00000002
  2707. #define DB_MPOOL_DISCARD 0x00000001
  2708. #define DB_MPOOL_EDIT 0x00000004
  2709. #define DB_MPOOL_FREE 0x00000008
  2710. #define DB_MPOOL_LAST 0x00000010
  2711. #define DB_MPOOL_NEW 0x00000020
  2712. #define DB_MPOOL_NOFILE 0x00000001
  2713. #define DB_MPOOL_NOLOCK 0x00000004
  2714. #define DB_MPOOL_TRY 0x00000040
  2715. #define DB_MPOOL_UNLINK 0x00000002
  2716. #define DB_MULTIPLE 0x00000800
  2717. #define DB_MULTIPLE_KEY 0x00004000
  2718. #define DB_MULTIVERSION 0x00000008
  2719. #define DB_MUTEX_ALLOCATED 0x00000001
  2720. #define DB_MUTEX_LOCKED 0x00000002
  2721. #define DB_MUTEX_LOGICAL_LOCK 0x00000004
  2722. #define DB_MUTEX_PROCESS_ONLY 0x00000008
  2723. #define DB_MUTEX_SELF_BLOCK 0x00000010
  2724. #define DB_MUTEX_SHARED 0x00000020
  2725. #define DB_NOERROR 0x00008000
  2726. #define DB_NOFLUSH 0x00001000
  2727. #define DB_NOLOCKING 0x00002000
  2728. #define DB_NOMMAP 0x00000010
  2729. #define DB_NOORDERCHK 0x00000002
  2730. #define DB_NOPANIC 0x00004000
  2731. #define DB_NOSYNC 0x00000001
  2732. #define DB_NO_AUTO_COMMIT 0x00010000
  2733. #define DB_NO_CHECKPOINT 0x00008000
  2734. #define DB_ODDFILESIZE 0x00000080
  2735. #define DB_ORDERCHKONLY 0x00000004
  2736. #define DB_OVERWRITE 0x00008000
  2737. #define DB_PANIC_ENVIRONMENT 0x00010000
  2738. #define DB_PRINTABLE 0x00000008
  2739. #define DB_PRIVATE 0x00010000
  2740. #define DB_PR_PAGE 0x00000010
  2741. #define DB_PR_RECOVERYTEST 0x00000020
  2742. #define DB_RDONLY 0x00000400
  2743. #define DB_RDWRMASTER 0x00020000
  2744. #define DB_READ_COMMITTED 0x00000400
  2745. #define DB_READ_UNCOMMITTED 0x00000200
  2746. #define DB_RECNUM 0x00000040
  2747. #define DB_RECOVER 0x00000002
  2748. #define DB_RECOVER_FATAL 0x00020000
  2749. #define DB_REGION_INIT 0x00020000
  2750. #define DB_REGISTER 0x00040000
  2751. #define DB_RENUMBER 0x00000080
  2752. #define DB_REPMGR_CONF_2SITE_STRICT 0x00000001
  2753. #define DB_REPMGR_CONF_ELECTIONS 0x00000002
  2754. #define DB_REPMGR_NEED_RESPONSE 0x00000001
  2755. #define DB_REPMGR_PEER 0x00000010
  2756. #define DB_REP_ANYWHERE 0x00000001
  2757. #define DB_REP_CLIENT 0x00000001
  2758. #define DB_REP_CONF_AUTOINIT 0x00000004
  2759. #define DB_REP_CONF_AUTOROLLBACK 0x00000008
  2760. #define DB_REP_CONF_BULK 0x00000010
  2761. #define DB_REP_CONF_DELAYCLIENT 0x00000020
  2762. #define DB_REP_CONF_INMEM 0x00000040
  2763. #define DB_REP_CONF_LEASE 0x00000080
  2764. #define DB_REP_CONF_NOWAIT 0x00000100
  2765. #define DB_REP_ELECTION 0x00000004
  2766. #define DB_REP_MASTER 0x00000002
  2767. #define DB_REP_NOBUFFER 0x00000002
  2768. #define DB_REP_PERMANENT 0x00000004
  2769. #define DB_REP_REREQUEST 0x00000008
  2770. #define DB_REVSPLITOFF 0x00000100
  2771. #define DB_RMW 0x00002000
  2772. #define DB_SALVAGE 0x00000040
  2773. #define DB_SA_SKIPFIRSTKEY 0x00000080
  2774. #define DB_SA_UNKNOWNKEY 0x00000100
  2775. #define DB_SEQ_DEC 0x00000001
  2776. #define DB_SEQ_INC 0x00000002
  2777. #define DB_SEQ_RANGE_SET 0x00000004
  2778. #define DB_SEQ_WRAP 0x00000008
  2779. #define DB_SEQ_WRAPPED 0x00000010
  2780. #define DB_SET_LOCK_TIMEOUT 0x00000001
  2781. #define DB_SET_REG_TIMEOUT 0x00000004
  2782. #define DB_SET_TXN_NOW 0x00000008
  2783. #define DB_SET_TXN_TIMEOUT 0x00000002
  2784. #define DB_SHALLOW_DUP 0x00000100
  2785. #define DB_SNAPSHOT 0x00000200
  2786. #define DB_STAT_ALL 0x00000004
  2787. #define DB_STAT_ALLOC 0x00000008
  2788. #define DB_STAT_CLEAR 0x00000001
  2789. #define DB_STAT_LOCK_CONF 0x00000010
  2790. #define DB_STAT_LOCK_LOCKERS 0x00000020
  2791. #define DB_STAT_LOCK_OBJECTS 0x00000040
  2792. #define DB_STAT_LOCK_PARAMS 0x00000080
  2793. #define DB_STAT_MEMP_HASH 0x00000010
  2794. #define DB_STAT_MEMP_NOERROR 0x00000020
  2795. #define DB_STAT_SUBSYSTEM 0x00000002
  2796. #define DB_STAT_SUMMARY 0x00000010
  2797. #define DB_ST_DUPOK 0x00000200
  2798. #define DB_ST_DUPSET 0x00000400
  2799. #define DB_ST_DUPSORT 0x00000800
  2800. #define DB_ST_IS_RECNO 0x00001000
  2801. #define DB_ST_OVFL_LEAF 0x00002000
  2802. #define DB_ST_RECNUM 0x00004000
  2803. #define DB_ST_RELEN 0x00008000
  2804. #define DB_ST_TOPLEVEL 0x00010000
  2805. #define DB_SYSTEM_MEM 0x00080000
  2806. #define DB_THREAD 0x00000020
  2807. #define DB_TIME_NOTGRANTED 0x00040000
  2808. #define DB_TRUNCATE 0x00040000
  2809. #define DB_TXN_BULK 0x00000010
  2810. #define DB_TXN_FAMILY 0x00000040
  2811. #define DB_TXN_NOSYNC 0x00000001
  2812. #define DB_TXN_NOT_DURABLE 0x00000004
  2813. #define DB_TXN_NOWAIT 0x00000002
  2814. #define DB_TXN_SNAPSHOT 0x00000004
  2815. #define DB_TXN_SYNC 0x00000008
  2816. #define DB_TXN_WAIT 0x00000080
  2817. #define DB_TXN_WRITE_NOSYNC 0x00000020
  2818. #define DB_UNREF 0x00020000
  2819. #define DB_UPGRADE 0x00000001
  2820. #define DB_USE_ENVIRON 0x00000004
  2821. #define DB_USE_ENVIRON_ROOT 0x00000008
  2822. #define DB_VERB_BACKUP 0x00000001
  2823. #define DB_VERB_DEADLOCK 0x00000002
  2824. #define DB_VERB_FILEOPS 0x00000004
  2825. #define DB_VERB_FILEOPS_ALL 0x00000008
  2826. #define DB_VERB_MVCC 0x00000010
  2827. #define DB_VERB_RECOVERY 0x00000020
  2828. #define DB_VERB_REGISTER 0x00000040
  2829. #define DB_VERB_REPLICATION 0x00000080
  2830. #define DB_VERB_REPMGR_CONNFAIL 0x00000100
  2831. #define DB_VERB_REPMGR_MISC 0x00000200
  2832. #define DB_VERB_REP_ELECT 0x00000400
  2833. #define DB_VERB_REP_LEASE 0x00000800
  2834. #define DB_VERB_REP_MISC 0x00001000
  2835. #define DB_VERB_REP_MSGS 0x00002000
  2836. #define DB_VERB_REP_SYNC 0x00004000
  2837. #define DB_VERB_REP_SYSTEM 0x00008000
  2838. #define DB_VERB_REP_TEST 0x00010000
  2839. #define DB_VERB_WAITSFOR 0x00020000
  2840. #define DB_VERIFY 0x00000002
  2841. #define DB_VERIFY_PARTITION 0x00040000
  2842. #define DB_WRITECURSOR 0x00000010
  2843. #define DB_WRITELOCK 0x00000020
  2844. #define DB_WRITEOPEN 0x00080000
  2845. #define DB_XA_CREATE 0x00000001
  2846. #define DB_YIELDCPU 0x00080000
  2847. /* DO NOT EDIT: automatically built by dist/s_include. */
  2848. #ifndef _DB_EXT_PROT_IN_
  2849. #define _DB_EXT_PROT_IN_
  2850. #if defined(__cplusplus)
  2851. extern "C" {
  2852. #endif
  2853. int db_copy __P((DB_ENV *, const char *, const char *, const char *));
  2854. int db_create __P((DB **, DB_ENV *, u_int32_t));
  2855. char *db_strerror __P((int));
  2856. int db_env_set_func_assert __P((void (*)(const char *, const char *, int)));
  2857. int db_env_set_func_close __P((int (*)(int)));
  2858. int db_env_set_func_dirfree __P((void (*)(char **, int)));
  2859. int db_env_set_func_dirlist __P((int (*)(const char *, char ***, int *)));
  2860. int db_env_set_func_exists __P((int (*)(const char *, int *)));
  2861. int db_env_set_func_free __P((void (*)(void *)));
  2862. int db_env_set_func_fsync __P((int (*)(int)));
  2863. int db_env_set_func_ftruncate __P((int (*)(int, off_t)));
  2864. int db_env_set_func_ioinfo __P((int (*)(const char *, int, u_int32_t *, u_int32_t *, u_int32_t *)));
  2865. int db_env_set_func_malloc __P((void *(*)(size_t)));
  2866. int db_env_set_func_file_map __P((int (*)(DB_ENV *, char *, size_t, int, void **), int (*)(DB_ENV *, void *)));
  2867. int db_env_set_func_region_map __P((int (*)(DB_ENV *, char *, size_t, int *, void **), int (*)(DB_ENV *, void *)));
  2868. int db_env_set_func_pread __P((ssize_t (*)(int, void *, size_t, off_t)));
  2869. int db_env_set_func_pwrite __P((ssize_t (*)(int, const void *, size_t, off_t)));
  2870. int db_env_set_func_open __P((int (*)(const char *, int, ...)));
  2871. int db_env_set_func_read __P((ssize_t (*)(int, void *, size_t)));
  2872. int db_env_set_func_realloc __P((void *(*)(void *, size_t)));
  2873. int db_env_set_func_rename __P((int (*)(const char *, const char *)));
  2874. int db_env_set_func_seek __P((int (*)(int, off_t, int)));
  2875. int db_env_set_func_unlink __P((int (*)(const char *)));
  2876. int db_env_set_func_write __P((ssize_t (*)(int, const void *, size_t)));
  2877. int db_env_set_func_yield __P((int (*)(u_long, u_long)));
  2878. int db_env_create __P((DB_ENV **, u_int32_t));
  2879. char *db_version __P((int *, int *, int *));
  2880. char *db_full_version __P((int *, int *, int *, int *, int *));
  2881. int log_compare __P((const DB_LSN *, const DB_LSN *));
  2882. #if defined(DB_WIN32) && !defined(DB_WINCE)
  2883. int db_env_set_win_security __P((SECURITY_ATTRIBUTES *sa));
  2884. #endif
  2885. int db_sequence_create __P((DB_SEQUENCE **, DB *, u_int32_t));
  2886. #if DB_DBM_HSEARCH != 0
  2887. int __db_ndbm_clearerr __P((DBM *));
  2888. void __db_ndbm_close __P((DBM *));
  2889. int __db_ndbm_delete __P((DBM *, datum));
  2890. int __db_ndbm_dirfno __P((DBM *));
  2891. int __db_ndbm_error __P((DBM *));
  2892. datum __db_ndbm_fetch __P((DBM *, datum));
  2893. datum __db_ndbm_firstkey __P((DBM *));
  2894. datum __db_ndbm_nextkey __P((DBM *));
  2895. DBM *__db_ndbm_open __P((const char *, int, int));
  2896. int __db_ndbm_pagfno __P((DBM *));
  2897. int __db_ndbm_rdonly __P((DBM *));
  2898. int __db_ndbm_store __P((DBM *, datum, datum, int));
  2899. int __db_dbm_close __P((void));
  2900. int __db_dbm_delete __P((datum));
  2901. datum __db_dbm_fetch __P((datum));
  2902. datum __db_dbm_firstkey __P((void));
  2903. int __db_dbm_init __P((char *));
  2904. datum __db_dbm_nextkey __P((datum));
  2905. int __db_dbm_store __P((datum, datum));
  2906. #endif
  2907. #if DB_DBM_HSEARCH != 0
  2908. int __db_hcreate __P((size_t));
  2909. ENTRY *__db_hsearch __P((ENTRY, ACTION));
  2910. void __db_hdestroy __P((void));
  2911. #endif
  2912. #if defined(__cplusplus)
  2913. }
  2914. #endif
  2915. #endif /* !_DB_EXT_PROT_IN_ */