1#ifndef _DB_H
2#define _DB_H
3/* This code generated by make_db_h. Copyright (c) 2006, 2015, Percona and/or its affiliates. */
4#ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved."
5#include <sys/types.h>
6/*stdio is needed for the FILE* in db->verify*/
7#include <stdio.h>
8/*stdbool is needed for the bool in db_env_enable_engine_status*/
9#include <stdbool.h>
10#include <stdint.h>
11#if defined(__cplusplus) || defined(__cilkplusplus)
12extern "C" {
13#endif
14#define DB_VERSION_MAJOR 4
15#define DB_VERSION_MINOR 6
16/* As of r40364 (post PerconaFT 5.2.7), the patch version number is 100+ the BDB header patch version number.*/
17#define DB_VERSION_PATCH 119
18#define DB_VERSION_STRING "Percona: PerconaFT 4.6.119"
19#define DB_GID_SIZE 128
20typedef struct toku_xa_xid_s { /* This struct is intended to be binary compatible with the XID in the XA architecture. See source:/import/opengroup.org/C193.pdf */
21 long formatID; /* format identifier */
22 long gtrid_length; /* value from 1 through 64 */
23 long bqual_length; /* value from 1 through 64 */
24 char data[DB_GID_SIZE];
25} TOKU_XA_XID;
26#ifndef TOKU_OFF_T_DEFINED
27#define TOKU_OFF_T_DEFINED
28typedef int64_t toku_off_t;
29#endif
30typedef struct __toku_db_env DB_ENV;
31typedef struct __toku_db_key_range DB_KEY_RANGE;
32typedef struct __toku_db_lsn DB_LSN;
33typedef struct __toku_db DB;
34typedef struct __toku_db_txn DB_TXN;
35typedef struct __toku_db_txn_active DB_TXN_ACTIVE;
36typedef struct __toku_db_txn_stat DB_TXN_STAT;
37typedef struct __toku_dbc DBC;
38typedef struct __toku_dbt DBT;
39typedef struct __toku_db_preplist { DB_TXN *txn; uint8_t gid[DB_GID_SIZE]; } DB_PREPLIST;
40typedef uint32_t db_recno_t;
41typedef int(*YDB_CALLBACK_FUNCTION)(DBT const*, DBT const*, void*);
42struct simple_dbt {
43 uint32_t len;
44 void *data;
45};
46typedef struct __toku_db_btree_stat64 {
47 uint64_t bt_nkeys; /* how many unique keys (guaranteed only to be an estimate, even when flattened) */
48 uint64_t bt_ndata; /* how many key-value pairs (an estimate, but exact when flattened) */
49 uint64_t bt_dsize; /* how big are the keys+values (not counting the lengths) (an estimate, unless flattened) */
50 uint64_t bt_fsize; /* how big is the underlying file */
51 uint64_t bt_create_time_sec; /* Creation time, in seconds */
52 uint64_t bt_modify_time_sec; /* Time of last serialization, in seconds */
53 uint64_t bt_verify_time_sec; /* Time of last verification, in seconds */
54} DB_BTREE_STAT64;
55typedef enum toku_compression_method {
56 TOKU_NO_COMPRESSION = 0,
57 TOKU_SNAPPY_METHOD = 7,
58 TOKU_ZLIB_METHOD = 8,
59 TOKU_QUICKLZ_METHOD = 9,
60 TOKU_LZMA_METHOD = 10,
61 TOKU_ZLIB_WITHOUT_CHECKSUM_METHOD = 11,
62 TOKU_DEFAULT_COMPRESSION_METHOD = 1,
63 TOKU_FAST_COMPRESSION_METHOD = 2,
64 TOKU_SMALL_COMPRESSION_METHOD = 3,
65} TOKU_COMPRESSION_METHOD;
66typedef struct __toku_loader DB_LOADER;
67struct __toku_loader_internal;
68struct __toku_loader {
69 struct __toku_loader_internal *i;
70 int (*set_error_callback)(DB_LOADER *loader, void (*error_cb)(DB *db, int i, int err, DBT *key, DBT *val, void *error_extra), void *error_extra); /* set the error callback */
71 int (*set_poll_function)(DB_LOADER *loader, int (*poll_func)(void *extra, float progress), void *poll_extra); /* set the polling function */
72 int (*put)(DB_LOADER *loader, DBT *key, DBT* val); /* give a row to the loader */
73 int (*close)(DB_LOADER *loader); /* finish loading, free memory */
74 int (*abort)(DB_LOADER *loader); /* abort loading, free memory */
75};
76typedef struct __toku_indexer DB_INDEXER;
77struct __toku_indexer_internal;
78struct __toku_indexer {
79 struct __toku_indexer_internal *i;
80 int (*set_error_callback)(DB_INDEXER *indexer, void (*error_cb)(DB *db, int i, int err, DBT *key, DBT *val, void *error_extra), void *error_extra); /* set the error callback */
81 int (*set_poll_function)(DB_INDEXER *indexer, int (*poll_func)(void *extra, float progress), void *poll_extra); /* set the polling function */
82 int (*build)(DB_INDEXER *indexer); /* build the indexes */
83 int (*close)(DB_INDEXER *indexer); /* finish indexing, free memory */
84 int (*abort)(DB_INDEXER *indexer); /* abort indexing, free memory */
85};
86typedef enum {
87 FS_GREEN = 0, // green zone (we have lots of space)
88 FS_YELLOW = 1, // yellow zone (issue warning but allow operations)
89 FS_RED = 2, // red zone (prevent insert operations)
90 FS_BLOCKED = 3 // For reporting engine status, completely blocked
91} fs_redzone_state;
92// engine status info
93// engine status is passed to handlerton as an array of TOKU_ENGINE_STATUS_ROW_S[]
94typedef enum {
95 FS_STATE = 0, // interpret as file system state (redzone) enum
96 UINT64, // interpret as uint64_t
97 CHARSTR, // interpret as char *
98 UNIXTIME, // interpret as time_t
99 TOKUTIME, // interpret as tokutime_t
100 PARCOUNT, // interpret as PARTITIONED_COUNTER
101 DOUBLE // interpret as double
102} toku_engine_status_display_type;
103typedef enum {
104 TOKU_ENGINE_STATUS = (1ULL<<0), // Include when asking for engine status
105 TOKU_GLOBAL_STATUS = (1ULL<<1), // Include when asking for information_schema.global_status
106} toku_engine_status_include_type;
107typedef struct __toku_engine_status_row {
108 const char * keyname; // info schema key, should not change across revisions without good reason
109 const char * columnname; // column for mysql, e.g. information_schema.global_status. TOKUDB_ will automatically be prefixed.
110 const char * legend; // the text that will appear at user interface
111 toku_engine_status_display_type type; // how to interpret the value
112 toku_engine_status_include_type include; // which kinds of callers should get read this row?
113 union {
114 double dnum;
115 uint64_t num;
116 const char * str;
117 char datebuf[26];
118 struct partitioned_counter *parcount;
119 } value;
120} * TOKU_ENGINE_STATUS_ROW, TOKU_ENGINE_STATUS_ROW_S;
121typedef enum {
122 DB_BTREE=1,
123 DB_UNKNOWN=5
124} DBTYPE;
125#define DB_VERB_DEADLOCK 1
126#define DB_VERB_RECOVERY 8
127#define DB_VERB_REPLICATION 32
128#define DB_VERB_WAITSFOR 64
129#define DB_ARCH_ABS 1
130#define DB_ARCH_LOG 4
131#define DB_CREATE 1
132#define DB_CXX_NO_EXCEPTIONS 1
133#define DB_EXCL 16384
134#define DB_PRIVATE 8388608
135#define DB_RDONLY 32
136#define DB_RECOVER 64
137#define DB_RUNRECOVERY -30975
138#define DB_THREAD 128
139#define DB_TXN_NOSYNC 512
140#define DB_BLACKHOLE 524288
141#define DB_LOCK_DEFAULT 1
142#define DB_LOCK_OLDEST 7
143#define DB_LOCK_RANDOM 8
144#define DB_KEYFIRST 13
145#define DB_KEYLAST 14
146#define DB_NOOVERWRITE 20
147#define DB_NODUPDATA 19
148#define DB_NOOVERWRITE_NO_ERROR 1
149#define DB_OPFLAGS_MASK 255
150#define DB_AUTO_COMMIT 33554432
151#define DB_INIT_LOCK 131072
152#define DB_INIT_LOG 262144
153#define DB_INIT_MPOOL 524288
154#define DB_INIT_TXN 2097152
155#define DB_KEYEXIST -30996
156#define DB_LOCK_DEADLOCK -30995
157#define DB_LOCK_NOTGRANTED -30994
158#define DB_NOTFOUND -30989
159#define DB_SECONDARY_BAD -30974
160#define DB_DONOTINDEX -30998
161#define DB_BUFFER_SMALL -30999
162#define DB_BADFORMAT -30500
163#define DB_DELETE_ANY 65536
164#define DB_FIRST 7
165#define DB_LAST 15
166#define DB_CURRENT 6
167#define DB_NEXT 16
168#define DB_PREV 23
169#define DB_SET 26
170#define DB_SET_RANGE 27
171#define DB_CURRENT_BINDING 253
172#define DB_SET_RANGE_REVERSE 252
173#define DB_RMW 1073741824
174#define DB_LOCKING_READ 0x80000000
175#define DB_IS_RESETTING_OP 0x01000000
176#define DB_PRELOCKED 0x00800000
177#define DB_PRELOCKED_WRITE 0x00400000
178#define DB_IS_HOT_INDEX 0x00100000
179#define DBC_DISABLE_PREFETCHING 0x20000000
180#define DB_UPDATE_CMP_DESCRIPTOR 0x40000000
181#define TOKUFT_DIRTY_SHUTDOWN 80000000
182#define DB_DBT_APPMALLOC 1
183#define DB_DBT_DUPOK 2
184#define DB_DBT_MALLOC 8
185#define DB_DBT_MULTIPLE 16
186#define DB_DBT_REALLOC 64
187#define DB_DBT_USERMEM 256
188#define DB_LOG_AUTOREMOVE 524288
189#define DB_TXN_WRITE_NOSYNC 4096
190#define DB_TXN_NOWAIT 1024
191#define DB_TXN_SYNC 16384
192#define DB_TXN_SNAPSHOT 268435456
193#define DB_READ_UNCOMMITTED 134217728
194#define DB_READ_COMMITTED 67108864
195#define DB_INHERIT_ISOLATION 1
196#define DB_SERIALIZABLE 2
197#define DB_TXN_READ_ONLY 4
198#define DB_READ_COMMITTED_ALWAYS 8
199/* PerconaFT specific error codes */
200#define TOKUDB_OUT_OF_LOCKS -100000
201#define TOKUDB_SUCCEEDED_EARLY -100001
202#define TOKUDB_FOUND_BUT_REJECTED -100002
203#define TOKUDB_USER_CALLBACK_ERROR -100003
204#define TOKUDB_DICTIONARY_TOO_OLD -100004
205#define TOKUDB_DICTIONARY_TOO_NEW -100005
206#define TOKUDB_DICTIONARY_NO_HEADER -100006
207#define TOKUDB_CANCELED -100007
208#define TOKUDB_NO_DATA -100008
209#define TOKUDB_ACCEPT -100009
210#define TOKUDB_MVCC_DICTIONARY_TOO_NEW -100010
211#define TOKUDB_UPGRADE_FAILURE -100011
212#define TOKUDB_TRY_AGAIN -100012
213#define TOKUDB_NEEDS_REPAIR -100013
214#define TOKUDB_CURSOR_CONTINUE -100014
215#define TOKUDB_BAD_CHECKSUM -100015
216#define TOKUDB_HUGE_PAGES_ENABLED -100016
217#define TOKUDB_OUT_OF_RANGE -100017
218#define TOKUDB_INTERRUPTED -100018
219/* LOADER flags */
220#define LOADER_DISALLOW_PUTS 1
221#define LOADER_COMPRESS_INTERMEDIATES 2
222typedef struct {
223 uint32_t capacity;
224 uint32_t size;
225 DBT *dbts;
226} DBT_ARRAY;
227
228typedef int (*generate_row_for_put_func)(DB *dest_db, DB *src_db, DBT_ARRAY * dest_keys, DBT_ARRAY *dest_vals, const DBT *src_key, const DBT *src_val);
229typedef int (*generate_row_for_del_func)(DB *dest_db, DB *src_db, DBT_ARRAY * dest_keys, const DBT *src_key, const DBT *src_val);
230DBT_ARRAY * toku_dbt_array_init(DBT_ARRAY *dbts, uint32_t size) __attribute__((__visibility__("default")));
231void toku_dbt_array_destroy(DBT_ARRAY *dbts) __attribute__((__visibility__("default")));
232void toku_dbt_array_destroy_shallow(DBT_ARRAY *dbts) __attribute__((__visibility__("default")));
233void toku_dbt_array_resize(DBT_ARRAY *dbts, uint32_t size) __attribute__((__visibility__("default")));
234typedef void (*lock_timeout_callback)(DB *db, uint64_t requesting_txnid, const DBT *left_key, const DBT *right_key, uint64_t blocking_txnid);
235typedef void (*lock_wait_callback)(void *arg, uint64_t requesting_txnid, uint64_t blocking_txnid);
236typedef int (*iterate_row_locks_callback)(DB **db, DBT *left_key, DBT *right_key, void *extra);
237typedef int (*iterate_transactions_callback)(DB_TXN *dbtxn, iterate_row_locks_callback cb, void *locks_extra, void *extra);
238typedef int (*iterate_requests_callback)(DB *db, uint64_t requesting_txnid, const DBT *left_key, const DBT *right_key, uint64_t blocking_txnid, uint64_t start_time, void *extra);
239struct __toku_db_env {
240 struct __toku_db_env_internal *i;
241#define db_env_struct_i(x) ((x)->i)
242 int (*checkpointing_set_period) (DB_ENV*, uint32_t) /* Change the delay between automatic checkpoints. 0 means disabled. */;
243 int (*checkpointing_get_period) (DB_ENV*, uint32_t*) /* Retrieve the delay between automatic checkpoints. 0 means disabled. */;
244 int (*cleaner_set_period) (DB_ENV*, uint32_t) /* Change the delay between automatic cleaner attempts. 0 means disabled. */;
245 int (*cleaner_get_period) (DB_ENV*, uint32_t*) /* Retrieve the delay between automatic cleaner attempts. 0 means disabled. */;
246 int (*cleaner_set_iterations) (DB_ENV*, uint32_t) /* Change the number of attempts on each cleaner invocation. 0 means disabled. */;
247 int (*cleaner_get_iterations) (DB_ENV*, uint32_t*) /* Retrieve the number of attempts on each cleaner invocation. 0 means disabled. */;
248 int (*evictor_set_enable_partial_eviction) (DB_ENV*, bool) /* Enables or disabled partial eviction of nodes from cachetable. */;
249 int (*evictor_get_enable_partial_eviction) (DB_ENV*, bool*) /* Retrieve the status of partial eviction of nodes from cachetable. */;
250 int (*checkpointing_postpone) (DB_ENV*) /* Use for 'rename table' or any other operation that must be disjoint from a checkpoint */;
251 int (*checkpointing_resume) (DB_ENV*) /* Alert tokuft that 'postpone' is no longer necessary */;
252 int (*checkpointing_begin_atomic_operation) (DB_ENV*) /* Begin a set of operations (that must be atomic as far as checkpoints are concerned). i.e. inserting into every index in one table */;
253 int (*checkpointing_end_atomic_operation) (DB_ENV*) /* End a set of operations (that must be atomic as far as checkpoints are concerned). */;
254 int (*set_default_bt_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (key) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */;
255 int (*get_engine_status_num_rows) (DB_ENV*, uint64_t*) /* return number of rows in engine status */;
256 int (*get_engine_status) (DB_ENV*, TOKU_ENGINE_STATUS_ROW, uint64_t, uint64_t*, fs_redzone_state*, uint64_t*, char*, int, toku_engine_status_include_type) /* Fill in status struct and redzone state, possibly env panic string */;
257 int (*get_engine_status_text) (DB_ENV*, char*, int) /* Fill in status text */;
258 int (*crash) (DB_ENV*, const char*/*expr_as_string*/,const char */*fun*/,const char*/*file*/,int/*line*/, int/*errno*/);
259 int (*get_iname) (DB_ENV* env, DBT* dname_dbt, DBT* iname_dbt) /* FOR TEST ONLY: lookup existing iname */;
260 int (*create_loader) (DB_ENV *env, DB_TXN *txn, DB_LOADER **blp, DB *src_db, int N, DB *dbs[/*N*/], uint32_t db_flags[/*N*/], uint32_t dbt_flags[/*N*/], uint32_t loader_flags);
261 int (*create_indexer) (DB_ENV *env, DB_TXN *txn, DB_INDEXER **idxrp, DB *src_db, int N, DB *dbs[/*N*/], uint32_t db_flags[/*N*/], uint32_t indexer_flags);
262 int (*put_multiple) (DB_ENV *env, DB *src_db, DB_TXN *txn,
263 const DBT *src_key, const DBT *src_val,
264 uint32_t num_dbs, DB **db_array, DBT_ARRAY *keys, DBT_ARRAY *vals, uint32_t *flags_array) /* insert into multiple DBs */;
265 int (*set_generate_row_callback_for_put) (DB_ENV *env, generate_row_for_put_func generate_row_for_put);
266 int (*del_multiple) (DB_ENV *env, DB *src_db, DB_TXN *txn,
267 const DBT *src_key, const DBT *src_val,
268 uint32_t num_dbs, DB **db_array, DBT_ARRAY *keys, uint32_t *flags_array) /* delete from multiple DBs */;
269 int (*set_generate_row_callback_for_del) (DB_ENV *env, generate_row_for_del_func generate_row_for_del);
270 int (*update_multiple) (DB_ENV *env, DB *src_db, DB_TXN *txn,
271 DBT *old_src_key, DBT *old_src_data,
272 DBT *new_src_key, DBT *new_src_data,
273 uint32_t num_dbs, DB **db_array, uint32_t *flags_array,
274 uint32_t num_keys, DBT_ARRAY *keys,
275 uint32_t num_vals, DBT_ARRAY *vals) /* update multiple DBs */;
276 int (*get_redzone) (DB_ENV *env, int *redzone) /* get the redzone limit */;
277 int (*set_redzone) (DB_ENV *env, int redzone) /* set the redzone limit in percent of total space */;
278 int (*set_lk_max_memory) (DB_ENV *env, uint64_t max);
279 int (*get_lk_max_memory) (DB_ENV *env, uint64_t *max);
280 void (*set_update) (DB_ENV *env, int (*update_function)(DB *, const DBT *key, const DBT *old_val, const DBT *extra, void (*set_val)(const DBT *new_val, void *set_extra), void *set_extra));
281 int (*set_lock_timeout) (DB_ENV *env, uint64_t default_lock_wait_time_msec, uint64_t (*get_lock_wait_time_cb)(uint64_t default_lock_wait_time));
282 int (*get_lock_timeout) (DB_ENV *env, uint64_t *lock_wait_time_msec);
283 int (*set_lock_timeout_callback) (DB_ENV *env, lock_timeout_callback callback);
284 int (*set_lock_wait_callback) (DB_ENV *env, lock_wait_callback callback);
285 int (*txn_xa_recover) (DB_ENV*, TOKU_XA_XID list[/*count*/], long count, /*out*/ long *retp, uint32_t flags);
286 int (*get_txn_from_xid) (DB_ENV*, /*in*/ TOKU_XA_XID *, /*out*/ DB_TXN **);
287 DB* (*get_db_for_directory) (DB_ENV*);
288 int (*get_cursor_for_directory) (DB_ENV*, /*in*/ DB_TXN *, /*out*/ DBC **);
289 int (*get_cursor_for_persistent_environment)(DB_ENV*, /*in*/ DB_TXN *, /*out*/ DBC **);
290 void (*change_fsync_log_period) (DB_ENV*, uint32_t);
291 int (*iterate_live_transactions) (DB_ENV *env, iterate_transactions_callback callback, void *extra);
292 int (*iterate_pending_lock_requests) (DB_ENV *env, iterate_requests_callback callback, void *extra);
293 void (*set_loader_memory_size)(DB_ENV *env, uint64_t (*get_loader_memory_size_callback)(void));
294 uint64_t (*get_loader_memory_size)(DB_ENV *env);
295 void (*set_killed_callback)(DB_ENV *env, uint64_t default_killed_time_msec, uint64_t (*get_killed_time_callback)(uint64_t default_killed_time_msec), int (*killed_callback)(void));
296 void (*do_backtrace) (DB_ENV *env);
297 int (*set_client_pool_threads)(DB_ENV *, uint32_t);
298 int (*set_cachetable_pool_threads)(DB_ENV *, uint32_t);
299 int (*set_checkpoint_pool_threads)(DB_ENV *, uint32_t);
300 void (*set_check_thp)(DB_ENV *, bool new_val);
301 bool (*get_check_thp)(DB_ENV *);
302 bool (*set_dir_per_db)(DB_ENV *, bool new_val);
303 bool (*get_dir_per_db)(DB_ENV *);
304 const char *(*get_data_dir)(DB_ENV *env);
305 int (*dirtool_attach)(DB_ENV *, DB_TXN *, const char *, const char *);
306 int (*dirtool_detach)(DB_ENV *, DB_TXN *, const char *);
307 int (*dirtool_move)(DB_ENV *, DB_TXN *, const char *, const char *);
308 void (*kill_waiter)(DB_ENV *, void *extra);
309 void *app_private;
310 void *api1_internal;
311 int (*close) (DB_ENV *, uint32_t);
312 int (*dbremove) (DB_ENV *, DB_TXN *, const char *, const char *, uint32_t);
313 int (*dbrename) (DB_ENV *, DB_TXN *, const char *, const char *, const char *, uint32_t);
314 void (*err) (const DB_ENV *, int, const char *, ...) __attribute__ (( format (printf, 3, 4) ));
315 int (*get_cachesize) (DB_ENV *, uint32_t *, uint32_t *, int *);
316 int (*get_flags) (DB_ENV *, uint32_t *);
317 int (*get_lg_max) (DB_ENV *, uint32_t*);
318 int (*log_archive) (DB_ENV *, char **[], uint32_t);
319 int (*log_flush) (DB_ENV *, const DB_LSN *);
320 int (*open) (DB_ENV *, const char *, uint32_t, int);
321 int (*set_cachesize) (DB_ENV *, uint32_t, uint32_t, int);
322 int (*set_data_dir) (DB_ENV *, const char *);
323 void (*set_errcall) (DB_ENV *, void (*)(const DB_ENV *, const char *, const char *));
324 void (*set_errfile) (DB_ENV *, FILE*);
325 void (*set_errpfx) (DB_ENV *, const char *);
326 int (*set_flags) (DB_ENV *, uint32_t, int);
327 int (*set_lg_bsize) (DB_ENV *, uint32_t);
328 int (*set_lg_dir) (DB_ENV *, const char *);
329 int (*set_lg_max) (DB_ENV *, uint32_t);
330 int (*set_lk_detect) (DB_ENV *, uint32_t);
331 int (*set_tmp_dir) (DB_ENV *, const char *);
332 int (*set_verbose) (DB_ENV *, uint32_t, int);
333 int (*txn_begin) (DB_ENV *, DB_TXN *, DB_TXN **, uint32_t);
334 int (*txn_checkpoint) (DB_ENV *, uint32_t, uint32_t, uint32_t);
335 int (*txn_recover) (DB_ENV *, DB_PREPLIST preplist[/*count*/], long count, /*out*/ long *retp, uint32_t flags);
336 int (*txn_stat) (DB_ENV *, DB_TXN_STAT **, uint32_t);
337};
338struct __toku_db_key_range {
339 double less;
340 double equal;
341 double greater;
342};
343struct __toku_db_lsn {
344 uint32_t file;
345 uint32_t offset;
346};
347struct __toku_dbt {
348 void*data;
349 uint32_t size;
350 uint32_t ulen;
351 uint32_t flags;
352};
353typedef struct __toku_descriptor {
354 DBT dbt;
355} *DESCRIPTOR, DESCRIPTOR_S;
356//One header is included in 'data'
357//One header is included in 'additional for checkpoint'
358typedef struct __toku_db_fragmentation {
359 uint64_t file_size_bytes; //Total file size in bytes
360 uint64_t data_bytes; //Compressed User Data in bytes
361 uint64_t data_blocks; //Number of blocks of compressed User Data
362 uint64_t checkpoint_bytes_additional; //Additional bytes used for checkpoint system
363 uint64_t checkpoint_blocks_additional; //Additional blocks used for checkpoint system
364 uint64_t unused_bytes; //Unused space in file
365 uint64_t unused_blocks; //Number of contiguous regions of unused space
366 uint64_t largest_unused_block; //Size of largest contiguous unused space
367} *TOKU_DB_FRAGMENTATION, TOKU_DB_FRAGMENTATION_S;
368struct __toku_db {
369 struct __toku_db_internal *i;
370#define db_struct_i(x) ((x)->i)
371 int (*key_range64)(DB*, DB_TXN *, DBT *, uint64_t *less, uint64_t *equal, uint64_t *greater, int *is_exact);
372 int (*get_key_after_bytes)(DB *, DB_TXN *, const DBT *, uint64_t, void (*callback)(const DBT *, uint64_t, void *), void *, uint32_t); /* given start_key and skip_len, find largest end_key such that the elements in [start_key,end_key) sum to <= skip_len bytes */;
373 int (*keys_range64)(DB*, DB_TXN *, DBT *keyleft, DBT *keyright, uint64_t *less, uint64_t *left, uint64_t *between, uint64_t *right, uint64_t *greater, bool *middle_3_exact);
374 int (*stat64)(DB *, DB_TXN *, DB_BTREE_STAT64 *);
375 int (*pre_acquire_table_lock)(DB*, DB_TXN*);
376 int (*pre_acquire_fileops_lock)(DB*, DB_TXN*);
377 const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/;
378 const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/;
379 void (*get_max_row_size) (DB*, uint32_t *max_key_size, uint32_t *max_row_size);
380 DESCRIPTOR descriptor /* saved row/dictionary descriptor for aiding in comparisons */;
381 DESCRIPTOR cmp_descriptor /* saved row/dictionary descriptor for aiding in comparisons */;
382 int (*change_descriptor) (DB*, DB_TXN*, const DBT* descriptor, uint32_t) /* change row/dictionary descriptor for a db. Available only while db is open */;
383 int (*getf_set)(DB*, DB_TXN*, uint32_t, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_set without a persistent cursor) */;
384 int (*optimize)(DB*) /* Run garbage collecion and promote all transactions older than oldest. Amortized (happens during flattening) */;
385 int (*hot_optimize)(DB*, DBT*, DBT*, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra, uint64_t* loops_run);
386 int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION);
387 int (*change_pagesize)(DB*,uint32_t);
388 int (*change_readpagesize)(DB*,uint32_t);
389 int (*get_readpagesize)(DB*,uint32_t*);
390 int (*set_readpagesize)(DB*,uint32_t);
391 int (*change_compression_method)(DB*,TOKU_COMPRESSION_METHOD);
392 int (*get_compression_method)(DB*,TOKU_COMPRESSION_METHOD*);
393 int (*set_compression_method)(DB*,TOKU_COMPRESSION_METHOD);
394 int (*change_fanout)(DB *db, uint32_t fanout);
395 int (*get_fanout)(DB *db, uint32_t *fanout);
396 int (*set_fanout)(DB *db, uint32_t fanout);
397 int (*set_memcmp_magic)(DB *db, uint8_t magic);
398 int (*set_indexer)(DB*, DB_INDEXER*);
399 void (*get_indexer)(DB*, DB_INDEXER**);
400 int (*verify_with_progress)(DB *, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra, int verbose, int keep_going);
401 int (*update)(DB *, DB_TXN*, const DBT *key, const DBT *extra, uint32_t flags);
402 int (*update_broadcast)(DB *, DB_TXN*, const DBT *extra, uint32_t flags);
403 int (*get_fractal_tree_info64)(DB*,uint64_t*,uint64_t*,uint64_t*,uint64_t*);
404 int (*iterate_fractal_tree_block_map)(DB*,int(*)(uint64_t,int64_t,int64_t,int64_t,int64_t,void*),void*);
405 const char *(*get_dname)(DB *db);
406 int (*get_last_key)(DB *db, YDB_CALLBACK_FUNCTION func, void* extra);
407 int (*recount_rows)(DB* db, int (*progress_callback)(uint64_t count, uint64_t deleted, void* progress_extra), void* progress_extra);
408 void *app_private;
409 DB_ENV *dbenv;
410 void *api_internal;
411 int (*close) (DB*, uint32_t);
412 int (*cursor) (DB *, DB_TXN *, DBC **, uint32_t);
413 int (*del) (DB *, DB_TXN *, DBT *, uint32_t);
414 int (*fd) (DB *, int *);
415 int (*get) (DB *, DB_TXN *, DBT *, DBT *, uint32_t);
416 int (*get_flags) (DB *, uint32_t *);
417 int (*get_pagesize) (DB *, uint32_t *);
418 int (*key_range) (DB *, DB_TXN *, DBT *, DB_KEY_RANGE *, uint32_t);
419 int (*open) (DB *, DB_TXN *, const char *, const char *, DBTYPE, uint32_t, int);
420 int (*put) (DB *, DB_TXN *, DBT *, DBT *, uint32_t);
421 void (*set_errfile) (DB *, FILE*);
422 int (*set_flags) (DB *, uint32_t);
423 int (*set_pagesize) (DB *, uint32_t);
424 int (*stat) (DB *, void *, uint32_t);
425 int (*verify) (DB *, const char *, const char *, FILE *, uint32_t);
426};
427struct __toku_db_txn_active {
428 uint32_t txnid;
429 DB_LSN lsn;
430};
431typedef struct __toku_txn_progress {
432 uint64_t entries_total;
433 uint64_t entries_processed;
434 uint8_t is_commit;
435 uint8_t stalled_on_checkpoint;
436} *TOKU_TXN_PROGRESS, TOKU_TXN_PROGRESS_S;
437typedef void(*TXN_PROGRESS_POLL_FUNCTION)(TOKU_TXN_PROGRESS, void*);
438struct txn_stat {
439 uint64_t rollback_raw_count;
440 uint64_t rollback_num_entries;
441};
442struct __toku_db_txn {
443 int (*txn_stat)(DB_TXN *, struct txn_stat **);
444 int (*commit_with_progress)(DB_TXN*, uint32_t, TXN_PROGRESS_POLL_FUNCTION, void*);
445 int (*abort_with_progress)(DB_TXN*, TXN_PROGRESS_POLL_FUNCTION, void*);
446 int (*xa_prepare) (DB_TXN*, TOKU_XA_XID *, uint32_t flags);
447 uint64_t (*id64) (DB_TXN*);
448 void (*set_client_id)(DB_TXN *, uint64_t client_id, void *client_extra);
449 void (*get_client_id)(DB_TXN *, uint64_t *client_id, void **client_extra);
450 bool (*is_prepared)(DB_TXN *);
451 DB_TXN *(*get_child)(DB_TXN *);
452 uint64_t (*get_start_time)(DB_TXN *);
453 DB_ENV *mgrp /* In PerconaFT, mgrp is a DB_ENV, not a DB_TXNMGR */;
454 DB_TXN *parent;
455 void *api_internal;
456 int (*abort) (DB_TXN *);
457 int (*commit) (DB_TXN*, uint32_t);
458 int (*discard) (DB_TXN*, uint32_t);
459 uint32_t (*id) (DB_TXN *);
460 int (*prepare) (DB_TXN*, uint8_t gid[DB_GID_SIZE], uint32_t flags);
461};
462struct __toku_db_txn_stat {
463 uint32_t st_nactive;
464 DB_TXN_ACTIVE *st_txnarray;
465};
466struct __toku_dbc {
467 int (*c_getf_first)(DBC *, uint32_t, YDB_CALLBACK_FUNCTION, void *);
468 int (*c_getf_last)(DBC *, uint32_t, YDB_CALLBACK_FUNCTION, void *);
469 int (*c_getf_next)(DBC *, uint32_t, YDB_CALLBACK_FUNCTION, void *);
470 int (*c_getf_prev)(DBC *, uint32_t, YDB_CALLBACK_FUNCTION, void *);
471 int (*c_getf_current)(DBC *, uint32_t, YDB_CALLBACK_FUNCTION, void *);
472 int (*c_getf_set)(DBC *, uint32_t, DBT *, YDB_CALLBACK_FUNCTION, void *);
473 int (*c_getf_set_range)(DBC *, uint32_t, DBT *, YDB_CALLBACK_FUNCTION, void *);
474 int (*c_getf_set_range_reverse)(DBC *, uint32_t, DBT *, YDB_CALLBACK_FUNCTION, void *);
475 int (*c_getf_set_range_with_bound)(DBC *, uint32_t, DBT *k, DBT *k_bound, YDB_CALLBACK_FUNCTION, void *);
476 int (*c_set_bounds)(DBC*, const DBT*, const DBT*, bool pre_acquire, int out_of_range_error);
477 void (*c_set_check_interrupt_callback)(DBC*, bool (*)(void*, uint64_t deleted_rows), void *);
478 void (*c_remove_restriction)(DBC*);
479 void (*c_set_txn)(DBC*, DB_TXN*);
480 char _internal[512];
481 DB *dbp;
482 int (*c_close) (DBC *);
483 int (*c_get) (DBC *, DBT *, DBT *, uint32_t);
484};
485int db_env_create(DB_ENV **, uint32_t) __attribute__((__visibility__("default")));
486int db_create(DB **, DB_ENV *, uint32_t) __attribute__((__visibility__("default")));
487const char *db_strerror(int) __attribute__((__visibility__("default")));
488const char *db_version(int*,int *,int *) __attribute__((__visibility__("default")));
489int log_compare (const DB_LSN*, const DB_LSN *) __attribute__((__visibility__("default")));
490int toku_set_trace_file (const char *fname) __attribute__((__visibility__("default")));
491int toku_close_trace_file (void) __attribute__((__visibility__("default")));
492void db_env_set_direct_io (bool direct_io_on) __attribute__((__visibility__("default")));
493void db_env_set_compress_buffers_before_eviction (bool compress_buffers) __attribute__((__visibility__("default")));
494void db_env_set_func_fsync (int (*)(int)) __attribute__((__visibility__("default")));
495void db_env_set_func_free (void (*)(void*)) __attribute__((__visibility__("default")));
496void db_env_set_func_malloc (void *(*)(size_t)) __attribute__((__visibility__("default")));
497void db_env_set_func_realloc (void *(*)(void*, size_t)) __attribute__((__visibility__("default")));
498void db_env_set_func_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default")));
499void db_env_set_func_full_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default")));
500void db_env_set_func_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default")));
501void db_env_set_func_full_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default")));
502void db_env_set_func_fdopen (FILE* (*)(int, const char *)) __attribute__((__visibility__("default")));
503void db_env_set_func_fopen (FILE* (*)(const char *, const char *)) __attribute__((__visibility__("default")));
504void db_env_set_func_open (int (*)(const char *, int, int)) __attribute__((__visibility__("default")));
505void db_env_set_func_fclose (int (*)(FILE*)) __attribute__((__visibility__("default")));
506void db_env_set_func_pread (ssize_t (*)(int, void *, size_t, off_t)) __attribute__((__visibility__("default")));
507void db_env_set_func_loader_fwrite (size_t (*fwrite_fun)(const void*,size_t,size_t,FILE*)) __attribute__((__visibility__("default")));
508void db_env_set_checkpoint_callback (void (*)(void*), void*) __attribute__((__visibility__("default")));
509void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default")));
510void db_env_set_recover_callback (void (*)(void*), void*) __attribute__((__visibility__("default")));
511void db_env_set_recover_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default")));
512void db_env_set_loader_size_factor (uint32_t) __attribute__((__visibility__("default")));
513void db_env_set_mvcc_garbage_collection_verification(uint32_t) __attribute__((__visibility__("default")));
514void db_env_enable_engine_status(bool) __attribute__((__visibility__("default")));
515void db_env_set_flusher_thread_callback (void (*)(int, void*), void*) __attribute__((__visibility__("default")));
516void db_env_set_num_bucket_mutexes(uint32_t) __attribute__((__visibility__("default")));
517int db_env_set_toku_product_name(const char*) __attribute__((__visibility__("default")));
518void db_env_try_gdb_stack_trace(const char *gdb_path) __attribute__((__visibility__("default")));
519#if defined(__cplusplus) || defined(__cilkplusplus)
520}
521#endif
522#endif
523