1 | /* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
2 | // vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: |
3 | #ident "$Id$" |
4 | /*====== |
5 | This file is part of PerconaFT. |
6 | |
7 | |
8 | Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. |
9 | |
10 | PerconaFT is free software: you can redistribute it and/or modify |
11 | it under the terms of the GNU General Public License, version 2, |
12 | as published by the Free Software Foundation. |
13 | |
14 | PerconaFT is distributed in the hope that it will be useful, |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | GNU General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU General Public License |
20 | along with PerconaFT. If not, see <http://www.gnu.org/licenses/>. |
21 | |
22 | ---------------------------------------- |
23 | |
24 | PerconaFT is free software: you can redistribute it and/or modify |
25 | it under the terms of the GNU Affero General Public License, version 3, |
26 | as published by the Free Software Foundation. |
27 | |
28 | PerconaFT is distributed in the hope that it will be useful, |
29 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
30 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
31 | GNU Affero General Public License for more details. |
32 | |
33 | You should have received a copy of the GNU Affero General Public License |
34 | along with PerconaFT. If not, see <http://www.gnu.org/licenses/>. |
35 | ======= */ |
36 | |
37 | #ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." |
38 | |
39 | /* Make a db.h that will be link-time compatible with Sleepycat's Berkeley DB. */ |
40 | |
41 | |
42 | #include <stdio.h> |
43 | #include <stdlib.h> |
44 | // Don't include toku_assert.h. Just use assert.h |
45 | #include <assert.h> |
46 | #include <string.h> |
47 | #include <sys/types.h> |
48 | |
49 | #define VISIBLE "__attribute__((__visibility__(\"default\")))" |
50 | |
51 | #define FIELD_LIMIT 100 |
52 | struct fieldinfo { |
53 | const char *decl_format_string; |
54 | const char *name; |
55 | size_t offset; |
56 | } fields[FIELD_LIMIT]; |
57 | static int field_counter=0; |
58 | |
59 | static int compare_fields (const void *av, const void *bv) { |
60 | const struct fieldinfo *a = (const struct fieldinfo *) av; |
61 | const struct fieldinfo *b = (const struct fieldinfo *) bv; |
62 | if (a->offset< b->offset) return -1; |
63 | if (a->offset==b->offset) return 0; |
64 | return +1; |
65 | } |
66 | |
67 | #define STRUCT_SETUP(typ, fname, fstring) ({ \ |
68 | assert(field_counter<FIELD_LIMIT); \ |
69 | fields[field_counter].decl_format_string = fstring; \ |
70 | fields[field_counter].name = #fname; \ |
71 | fields[field_counter].offset = __builtin_offsetof(typ, fname); \ |
72 | field_counter++; }) |
73 | |
74 | static void sort_and_dump_fields (const char *structname, bool has_internal, const char *[]) { |
75 | int i; |
76 | qsort(fields, field_counter, sizeof(fields[0]), compare_fields); |
77 | printf("struct __toku_%s {\n" , structname); |
78 | if (has_internal) { |
79 | printf(" struct __toku_%s_internal *i;\n" , structname); |
80 | printf("#define %s_struct_i(x) ((x)->i)\n" , structname); |
81 | } |
82 | if (extra_decls) { |
83 | while (*extra_decls) { |
84 | printf(" %s;\n" , *extra_decls); |
85 | extra_decls++; |
86 | } |
87 | } |
88 | for (i=0; i<field_counter; i++) { |
89 | printf(" " ); |
90 | printf(fields[i].decl_format_string, fields[i].name); |
91 | printf(";\n" ); |
92 | } |
93 | printf("};\n" ); |
94 | } |
95 | |
96 | #include "db-4.6.19.h" |
97 | |
98 | static void print_dbtype(void) { |
99 | /* DBTYPE is mentioned by db_open.html */ |
100 | printf("typedef enum {\n" ); |
101 | printf(" DB_BTREE=%d,\n" , DB_BTREE); |
102 | printf(" DB_UNKNOWN=%d\n" , DB_UNKNOWN); |
103 | printf("} DBTYPE;\n" ); |
104 | } |
105 | |
106 | |
107 | #define dodefine(name) printf("#define %s %d\n", #name, name) |
108 | #define dodefine_track(flags, name) ({ assert((flags & name) != name); \ |
109 | flags |= (name); \ |
110 | printf("#define %s %d\n", #name, name); }) |
111 | #define dodefine_from_track(flags, name) ({\ |
112 | uint32_t which; \ |
113 | uint32_t bit; \ |
114 | for (which = 0; which < 32; which++) { \ |
115 | bit = 1U << which; \ |
116 | if (!(flags & bit)) break; \ |
117 | } \ |
118 | assert(which < 32); \ |
119 | printf("#define %s %u\n", #name, bit); \ |
120 | flags |= bit; \ |
121 | }) |
122 | |
123 | #define dodefine_track_enum(flags, name) ({ assert(name>=0 && name<256); \ |
124 | assert(!(flags[name])); \ |
125 | flags[name] = 1; \ |
126 | printf("#define %s %d\n", #name, (int)(name)); }) |
127 | #define dodefine_from_track_enum(flags, name) ({\ |
128 | uint32_t which; \ |
129 | /* don't use 0 */ \ |
130 | for (which = 1; which < 256; which++) { \ |
131 | if (!(flags[which])) break; \ |
132 | } \ |
133 | assert(which < 256); \ |
134 | flags[which] = 1; \ |
135 | printf("#define %s %u\n", #name, which); \ |
136 | }) |
137 | |
138 | enum { |
139 | TOKUDB_OUT_OF_LOCKS = -100000, |
140 | TOKUDB_SUCCEEDED_EARLY = -100001, |
141 | TOKUDB_FOUND_BUT_REJECTED = -100002, |
142 | TOKUDB_USER_CALLBACK_ERROR = -100003, |
143 | TOKUDB_DICTIONARY_TOO_OLD = -100004, |
144 | TOKUDB_DICTIONARY_TOO_NEW = -100005, |
145 | = -100006, |
146 | TOKUDB_CANCELED = -100007, |
147 | TOKUDB_NO_DATA = -100008, |
148 | TOKUDB_ACCEPT = -100009, |
149 | TOKUDB_MVCC_DICTIONARY_TOO_NEW = -100010, |
150 | TOKUDB_UPGRADE_FAILURE = -100011, |
151 | TOKUDB_TRY_AGAIN = -100012, |
152 | TOKUDB_NEEDS_REPAIR = -100013, |
153 | TOKUDB_CURSOR_CONTINUE = -100014, |
154 | TOKUDB_BAD_CHECKSUM = -100015, |
155 | TOKUDB_HUGE_PAGES_ENABLED = -100016, |
156 | TOKUDB_OUT_OF_RANGE = -100017, |
157 | TOKUDB_INTERRUPTED = -100018, |
158 | DONTUSE_I_JUST_PUT_THIS_HERE_SO_I_COULD_HAVE_A_COMMA_AFTER_EACH_ITEM |
159 | }; |
160 | |
161 | static void print_defines (void) { |
162 | dodefine(DB_VERB_DEADLOCK); |
163 | dodefine(DB_VERB_RECOVERY); |
164 | dodefine(DB_VERB_REPLICATION); |
165 | dodefine(DB_VERB_WAITSFOR); |
166 | |
167 | dodefine(DB_ARCH_ABS); |
168 | dodefine(DB_ARCH_LOG); |
169 | |
170 | dodefine(DB_CREATE); |
171 | dodefine(DB_CXX_NO_EXCEPTIONS); |
172 | dodefine(DB_EXCL); |
173 | dodefine(DB_PRIVATE); |
174 | dodefine(DB_RDONLY); |
175 | dodefine(DB_RECOVER); |
176 | dodefine(DB_RUNRECOVERY); |
177 | dodefine(DB_THREAD); |
178 | dodefine(DB_TXN_NOSYNC); |
179 | |
180 | /* according to BDB 4.6.19, this is the next unused flag in the set of |
181 | * common flags plus private flags for DB->open */ |
182 | #define DB_BLACKHOLE 0x0080000 |
183 | dodefine(DB_BLACKHOLE); |
184 | #undef DB_BLACKHOLE |
185 | |
186 | dodefine(DB_LOCK_DEFAULT); |
187 | dodefine(DB_LOCK_OLDEST); |
188 | dodefine(DB_LOCK_RANDOM); |
189 | |
190 | //dodefine(DB_DUP); No longer supported #2862 |
191 | //dodefine(DB_DUPSORT); No longer supported #2862 |
192 | |
193 | dodefine(DB_KEYFIRST); |
194 | dodefine(DB_KEYLAST); |
195 | { |
196 | static uint8_t insert_flags[256]; |
197 | dodefine_track_enum(insert_flags, DB_NOOVERWRITE); |
198 | dodefine_track_enum(insert_flags, DB_NODUPDATA); |
199 | dodefine_from_track_enum(insert_flags, DB_NOOVERWRITE_NO_ERROR); |
200 | } |
201 | dodefine(DB_OPFLAGS_MASK); |
202 | |
203 | dodefine(DB_AUTO_COMMIT); |
204 | |
205 | dodefine(DB_INIT_LOCK); |
206 | dodefine(DB_INIT_LOG); |
207 | dodefine(DB_INIT_MPOOL); |
208 | dodefine(DB_INIT_TXN); |
209 | |
210 | //dodefine(DB_KEYEMPTY); /// KEYEMPTY is no longer used. We just use DB_NOTFOUND |
211 | dodefine(DB_KEYEXIST); |
212 | dodefine(DB_LOCK_DEADLOCK); |
213 | dodefine(DB_LOCK_NOTGRANTED); |
214 | dodefine(DB_NOTFOUND); |
215 | dodefine(DB_SECONDARY_BAD); |
216 | dodefine(DB_DONOTINDEX); |
217 | #ifdef DB_BUFFER_SMALL |
218 | dodefine(DB_BUFFER_SMALL); |
219 | #endif |
220 | printf("#define DB_BADFORMAT -30500\n" ); // private tokudb |
221 | printf("#define DB_DELETE_ANY %d\n" , 1<<16); // private tokudb |
222 | |
223 | dodefine(DB_FIRST); |
224 | dodefine(DB_LAST); |
225 | dodefine(DB_CURRENT); |
226 | dodefine(DB_NEXT); |
227 | dodefine(DB_PREV); |
228 | dodefine(DB_SET); |
229 | dodefine(DB_SET_RANGE); |
230 | printf("#define DB_CURRENT_BINDING 253\n" ); // private tokudb |
231 | printf("#define DB_SET_RANGE_REVERSE 252\n" ); // private tokudb |
232 | //printf("#define DB_GET_BOTH_RANGE_REVERSE 251\n"); // private tokudb. No longer supported #2862. |
233 | dodefine(DB_RMW); |
234 | |
235 | printf("#define DB_LOCKING_READ 0x80000000\n" ); |
236 | printf("#define DB_IS_RESETTING_OP 0x01000000\n" ); // private tokudb |
237 | printf("#define DB_PRELOCKED 0x00800000\n" ); // private tokudb |
238 | printf("#define DB_PRELOCKED_WRITE 0x00400000\n" ); // private tokudb |
239 | //printf("#define DB_PRELOCKED_FILE_READ 0x00200000\n"); // private tokudb. No longer supported in #4472 |
240 | printf("#define DB_IS_HOT_INDEX 0x00100000\n" ); // private tokudb |
241 | printf("#define DBC_DISABLE_PREFETCHING 0x20000000\n" ); // private tokudb |
242 | printf("#define DB_UPDATE_CMP_DESCRIPTOR 0x40000000\n" ); // private tokudb |
243 | printf("#define TOKUFT_DIRTY_SHUTDOWN %x\n" , 1<<31); |
244 | |
245 | { |
246 | //dbt flags |
247 | uint32_t dbt_flags = 0; |
248 | dodefine_track(dbt_flags, DB_DBT_APPMALLOC); |
249 | dodefine_track(dbt_flags, DB_DBT_DUPOK); |
250 | dodefine_track(dbt_flags, DB_DBT_MALLOC); |
251 | #ifdef DB_DBT_MULTIPLE |
252 | dodefine_track(dbt_flags, DB_DBT_MULTIPLE); |
253 | #endif |
254 | dodefine_track(dbt_flags, DB_DBT_REALLOC); |
255 | dodefine_track(dbt_flags, DB_DBT_USERMEM); |
256 | } |
257 | |
258 | // flags for the env->set_flags function |
259 | #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3 |
260 | dodefine(DB_LOG_AUTOREMOVE); |
261 | #endif |
262 | |
263 | { |
264 | //Txn begin/commit flags |
265 | uint32_t txn_flags = 0; |
266 | dodefine_track(txn_flags, DB_TXN_WRITE_NOSYNC); |
267 | dodefine_track(txn_flags, DB_TXN_NOWAIT); |
268 | dodefine_track(txn_flags, DB_TXN_SYNC); |
269 | #ifdef DB_TXN_SNAPSHOT |
270 | dodefine_track(txn_flags, DB_TXN_SNAPSHOT); |
271 | #endif |
272 | #ifdef DB_READ_UNCOMMITTED |
273 | dodefine_track(txn_flags, DB_READ_UNCOMMITTED); |
274 | #endif |
275 | #ifdef DB_READ_COMMITTED |
276 | dodefine_track(txn_flags, DB_READ_COMMITTED); |
277 | #endif |
278 | //Add them if they didn't exist |
279 | #ifndef DB_TXN_SNAPSHOT |
280 | dodefine_from_track(txn_flags, DB_TXN_SNAPSHOT); |
281 | #endif |
282 | #ifndef DB_READ_UNCOMMITTED |
283 | dodefine_from_track(txn_flags, DB_READ_UNCOMMITTED); |
284 | #endif |
285 | #ifndef DB_READ_COMMITTED |
286 | dodefine_from_track(txn_flags, DB_READ_COMMITTED); |
287 | #endif |
288 | dodefine_from_track(txn_flags, DB_INHERIT_ISOLATION); |
289 | dodefine_from_track(txn_flags, DB_SERIALIZABLE); |
290 | dodefine_from_track(txn_flags, DB_TXN_READ_ONLY); |
291 | dodefine_from_track(txn_flags, DB_READ_COMMITTED_ALWAYS); |
292 | } |
293 | |
294 | /* PerconaFT specific error codes*/ |
295 | printf("/* PerconaFT specific error codes */\n" ); |
296 | dodefine(TOKUDB_OUT_OF_LOCKS); |
297 | dodefine(TOKUDB_SUCCEEDED_EARLY); |
298 | dodefine(TOKUDB_FOUND_BUT_REJECTED); |
299 | dodefine(TOKUDB_USER_CALLBACK_ERROR); |
300 | dodefine(TOKUDB_DICTIONARY_TOO_OLD); |
301 | dodefine(TOKUDB_DICTIONARY_TOO_NEW); |
302 | dodefine(TOKUDB_DICTIONARY_NO_HEADER); |
303 | dodefine(TOKUDB_CANCELED); |
304 | dodefine(TOKUDB_NO_DATA); |
305 | dodefine(TOKUDB_ACCEPT); |
306 | dodefine(TOKUDB_MVCC_DICTIONARY_TOO_NEW); |
307 | dodefine(TOKUDB_UPGRADE_FAILURE); |
308 | dodefine(TOKUDB_TRY_AGAIN); |
309 | dodefine(TOKUDB_NEEDS_REPAIR); |
310 | dodefine(TOKUDB_CURSOR_CONTINUE); |
311 | dodefine(TOKUDB_BAD_CHECKSUM); |
312 | dodefine(TOKUDB_HUGE_PAGES_ENABLED); |
313 | dodefine(TOKUDB_OUT_OF_RANGE); |
314 | dodefine(TOKUDB_INTERRUPTED); |
315 | |
316 | /* LOADER flags */ |
317 | printf("/* LOADER flags */\n" ); |
318 | { |
319 | uint32_t loader_flags = 0; |
320 | dodefine_from_track(loader_flags, LOADER_DISALLOW_PUTS); // Loader is only used for side effects. |
321 | dodefine_from_track(loader_flags, LOADER_COMPRESS_INTERMEDIATES); |
322 | } |
323 | } |
324 | |
325 | static void print_db_env_struct (void) { |
326 | field_counter=0; |
327 | STRUCT_SETUP(DB_ENV, api1_internal, "void *%s" ); /* Used for C++ hacking. */ |
328 | STRUCT_SETUP(DB_ENV, app_private, "void *%s" ); |
329 | STRUCT_SETUP(DB_ENV, close, "int (*%s) (DB_ENV *, uint32_t)" ); |
330 | STRUCT_SETUP(DB_ENV, err, "void (*%s) (const DB_ENV *, int, const char *, ...) __attribute__ (( format (printf, 3, 4) ))" ); |
331 | #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3 |
332 | STRUCT_SETUP(DB_ENV, get_cachesize, "int (*%s) (DB_ENV *, uint32_t *, uint32_t *, int *)" ); |
333 | STRUCT_SETUP(DB_ENV, get_flags, "int (*%s) (DB_ENV *, uint32_t *)" ); |
334 | STRUCT_SETUP(DB_ENV, get_lg_max, "int (*%s) (DB_ENV *, uint32_t*)" ); |
335 | #endif |
336 | STRUCT_SETUP(DB_ENV, log_archive, "int (*%s) (DB_ENV *, char **[], uint32_t)" ); |
337 | STRUCT_SETUP(DB_ENV, log_flush, "int (*%s) (DB_ENV *, const DB_LSN *)" ); |
338 | STRUCT_SETUP(DB_ENV, open, "int (*%s) (DB_ENV *, const char *, uint32_t, int)" ); |
339 | STRUCT_SETUP(DB_ENV, set_cachesize, "int (*%s) (DB_ENV *, uint32_t, uint32_t, int)" ); |
340 | STRUCT_SETUP(DB_ENV, set_data_dir, "int (*%s) (DB_ENV *, const char *)" ); |
341 | #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 1 |
342 | STRUCT_SETUP(DB_ENV, set_errcall, "void (*%s) (DB_ENV *, void (*)(const char *, char *))" ); |
343 | #endif |
344 | #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3 |
345 | STRUCT_SETUP(DB_ENV, set_errcall, "void (*%s) (DB_ENV *, void (*)(const DB_ENV *, const char *, const char *))" ); |
346 | #endif |
347 | STRUCT_SETUP(DB_ENV, set_errfile, "void (*%s) (DB_ENV *, FILE*)" ); |
348 | STRUCT_SETUP(DB_ENV, set_errpfx, "void (*%s) (DB_ENV *, const char *)" ); |
349 | STRUCT_SETUP(DB_ENV, set_flags, "int (*%s) (DB_ENV *, uint32_t, int)" ); |
350 | STRUCT_SETUP(DB_ENV, set_lg_bsize, "int (*%s) (DB_ENV *, uint32_t)" ); |
351 | STRUCT_SETUP(DB_ENV, set_lg_dir, "int (*%s) (DB_ENV *, const char *)" ); |
352 | STRUCT_SETUP(DB_ENV, set_lg_max, "int (*%s) (DB_ENV *, uint32_t)" ); |
353 | STRUCT_SETUP(DB_ENV, set_lk_detect, "int (*%s) (DB_ENV *, uint32_t)" ); |
354 | #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR <= 4 |
355 | STRUCT_SETUP(DB_ENV, set_lk_max, "int (*%s) (DB_ENV *, uint32_t)" ); |
356 | #endif |
357 | //STRUCT_SETUP(DB_ENV, set_noticecall, "void (*%s) (DB_ENV *, void (*)(DB_ENV *, db_notices))"); |
358 | STRUCT_SETUP(DB_ENV, set_tmp_dir, "int (*%s) (DB_ENV *, const char *)" ); |
359 | STRUCT_SETUP(DB_ENV, set_verbose, "int (*%s) (DB_ENV *, uint32_t, int)" ); |
360 | STRUCT_SETUP(DB_ENV, txn_checkpoint, "int (*%s) (DB_ENV *, uint32_t, uint32_t, uint32_t)" ); |
361 | STRUCT_SETUP(DB_ENV, txn_stat, "int (*%s) (DB_ENV *, DB_TXN_STAT **, uint32_t)" ); |
362 | STRUCT_SETUP(DB_ENV, txn_begin, "int (*%s) (DB_ENV *, DB_TXN *, DB_TXN **, uint32_t)" ); |
363 | STRUCT_SETUP(DB_ENV, txn_recover, "int (*%s) (DB_ENV *, DB_PREPLIST preplist[/*count*/], long count, /*out*/ long *retp, uint32_t flags)" ); |
364 | STRUCT_SETUP(DB_ENV, dbremove, "int (*%s) (DB_ENV *, DB_TXN *, const char *, const char *, uint32_t)" ); |
365 | STRUCT_SETUP(DB_ENV, dbrename, "int (*%s) (DB_ENV *, DB_TXN *, const char *, const char *, const char *, uint32_t)" ); |
366 | |
367 | const char *[]={ |
368 | "int (*checkpointing_set_period) (DB_ENV*, uint32_t) /* Change the delay between automatic checkpoints. 0 means disabled. */" , |
369 | "int (*checkpointing_get_period) (DB_ENV*, uint32_t*) /* Retrieve the delay between automatic checkpoints. 0 means disabled. */" , |
370 | "int (*cleaner_set_period) (DB_ENV*, uint32_t) /* Change the delay between automatic cleaner attempts. 0 means disabled. */" , |
371 | "int (*cleaner_get_period) (DB_ENV*, uint32_t*) /* Retrieve the delay between automatic cleaner attempts. 0 means disabled. */" , |
372 | "int (*cleaner_set_iterations) (DB_ENV*, uint32_t) /* Change the number of attempts on each cleaner invocation. 0 means disabled. */" , |
373 | "int (*cleaner_get_iterations) (DB_ENV*, uint32_t*) /* Retrieve the number of attempts on each cleaner invocation. 0 means disabled. */" , |
374 | "int (*evictor_set_enable_partial_eviction) (DB_ENV*, bool) /* Enables or disabled partial eviction of nodes from cachetable. */" , |
375 | "int (*evictor_get_enable_partial_eviction) (DB_ENV*, bool*) /* Retrieve the status of partial eviction of nodes from cachetable. */" , |
376 | "int (*checkpointing_postpone) (DB_ENV*) /* Use for 'rename table' or any other operation that must be disjoint from a checkpoint */" , |
377 | "int (*checkpointing_resume) (DB_ENV*) /* Alert tokuft that 'postpone' is no longer necessary */" , |
378 | "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 */" , |
379 | "int (*checkpointing_end_atomic_operation) (DB_ENV*) /* End a set of operations (that must be atomic as far as checkpoints are concerned). */" , |
380 | "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. */" , |
381 | "int (*get_engine_status_num_rows) (DB_ENV*, uint64_t*) /* return number of rows in engine status */" , |
382 | "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 */" , |
383 | "int (*get_engine_status_text) (DB_ENV*, char*, int) /* Fill in status text */" , |
384 | "int (*crash) (DB_ENV*, const char*/*expr_as_string*/,const char */*fun*/,const char*/*file*/,int/*line*/, int/*errno*/)" , |
385 | "int (*get_iname) (DB_ENV* env, DBT* dname_dbt, DBT* iname_dbt) /* FOR TEST ONLY: lookup existing iname */" , |
386 | "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)" , |
387 | "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)" , |
388 | "int (*put_multiple) (DB_ENV *env, DB *src_db, DB_TXN *txn,\n" |
389 | " const DBT *src_key, const DBT *src_val,\n" |
390 | " uint32_t num_dbs, DB **db_array, DBT_ARRAY *keys, DBT_ARRAY *vals, uint32_t *flags_array) /* insert into multiple DBs */" , |
391 | "int (*set_generate_row_callback_for_put) (DB_ENV *env, generate_row_for_put_func generate_row_for_put)" , |
392 | "int (*del_multiple) (DB_ENV *env, DB *src_db, DB_TXN *txn,\n" |
393 | " const DBT *src_key, const DBT *src_val,\n" |
394 | " uint32_t num_dbs, DB **db_array, DBT_ARRAY *keys, uint32_t *flags_array) /* delete from multiple DBs */" , |
395 | "int (*set_generate_row_callback_for_del) (DB_ENV *env, generate_row_for_del_func generate_row_for_del)" , |
396 | "int (*update_multiple) (DB_ENV *env, DB *src_db, DB_TXN *txn,\n" |
397 | " DBT *old_src_key, DBT *old_src_data,\n" |
398 | " DBT *new_src_key, DBT *new_src_data,\n" |
399 | " uint32_t num_dbs, DB **db_array, uint32_t *flags_array,\n" |
400 | " uint32_t num_keys, DBT_ARRAY *keys,\n" |
401 | " uint32_t num_vals, DBT_ARRAY *vals) /* update multiple DBs */" , |
402 | "int (*get_redzone) (DB_ENV *env, int *redzone) /* get the redzone limit */" , |
403 | "int (*set_redzone) (DB_ENV *env, int redzone) /* set the redzone limit in percent of total space */" , |
404 | "int (*set_lk_max_memory) (DB_ENV *env, uint64_t max)" , |
405 | "int (*get_lk_max_memory) (DB_ENV *env, uint64_t *max)" , |
406 | "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))" , |
407 | "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))" , |
408 | "int (*get_lock_timeout) (DB_ENV *env, uint64_t *lock_wait_time_msec)" , |
409 | "int (*set_lock_timeout_callback) (DB_ENV *env, lock_timeout_callback callback)" , |
410 | "int (*set_lock_wait_callback) (DB_ENV *env, lock_wait_callback callback)" , |
411 | "int (*txn_xa_recover) (DB_ENV*, TOKU_XA_XID list[/*count*/], long count, /*out*/ long *retp, uint32_t flags)" , |
412 | "int (*get_txn_from_xid) (DB_ENV*, /*in*/ TOKU_XA_XID *, /*out*/ DB_TXN **)" , |
413 | "DB* (*get_db_for_directory) (DB_ENV*)" , |
414 | "int (*get_cursor_for_directory) (DB_ENV*, /*in*/ DB_TXN *, /*out*/ DBC **)" , |
415 | "int (*get_cursor_for_persistent_environment)(DB_ENV*, /*in*/ DB_TXN *, /*out*/ DBC **)" , |
416 | "void (*change_fsync_log_period) (DB_ENV*, uint32_t)" , |
417 | "int (*iterate_live_transactions) (DB_ENV *env, iterate_transactions_callback callback, void *extra)" , |
418 | "int (*iterate_pending_lock_requests) (DB_ENV *env, iterate_requests_callback callback, void *extra)" , |
419 | "void (*set_loader_memory_size)(DB_ENV *env, uint64_t (*get_loader_memory_size_callback)(void))" , |
420 | "uint64_t (*get_loader_memory_size)(DB_ENV *env)" , |
421 | "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))" , |
422 | "void (*do_backtrace) (DB_ENV *env)" , |
423 | "int (*set_client_pool_threads)(DB_ENV *, uint32_t)" , |
424 | "int (*set_cachetable_pool_threads)(DB_ENV *, uint32_t)" , |
425 | "int (*set_checkpoint_pool_threads)(DB_ENV *, uint32_t)" , |
426 | "void (*set_check_thp)(DB_ENV *, bool new_val)" , |
427 | "bool (*get_check_thp)(DB_ENV *)" , |
428 | "bool (*set_dir_per_db)(DB_ENV *, bool new_val)" , |
429 | "bool (*get_dir_per_db)(DB_ENV *)" , |
430 | "const char *(*get_data_dir)(DB_ENV *env)" , |
431 | "int (*dirtool_attach)(DB_ENV *, DB_TXN *, const char *, const char *)" , |
432 | "int (*dirtool_detach)(DB_ENV *, DB_TXN *, const char *)" , |
433 | "int (*dirtool_move)(DB_ENV *, DB_TXN *, const char *, const char *)" , |
434 | "void (*kill_waiter)(DB_ENV *, void *extra)" , |
435 | NULL}; |
436 | |
437 | sort_and_dump_fields("db_env" , true, extra); |
438 | } |
439 | |
440 | static void print_db_key_range_struct (void) { |
441 | field_counter=0; |
442 | STRUCT_SETUP(DB_KEY_RANGE, less, "double %s" ); |
443 | STRUCT_SETUP(DB_KEY_RANGE, equal, "double %s" ); |
444 | STRUCT_SETUP(DB_KEY_RANGE, greater, "double %s" ); |
445 | sort_and_dump_fields("db_key_range" , false, NULL); |
446 | } |
447 | |
448 | static void print_db_lsn_struct(void) { |
449 | field_counter = 0; |
450 | // FT-692 |
451 | STRUCT_SETUP(DB_LSN, file, "uint32_t %s" ); |
452 | STRUCT_SETUP(DB_LSN, offset, "uint32_t %s" ); |
453 | sort_and_dump_fields("db_lsn" , false, NULL); |
454 | } |
455 | |
456 | static void print_dbt_struct(void) { |
457 | field_counter=0; |
458 | #if 0 && DB_VERSION_MAJOR==4 && DB_VERSION_MINOR==1 |
459 | STRUCT_SETUP(DBT, app_private, "void*%s" ); |
460 | #endif |
461 | STRUCT_SETUP(DBT, data, "void*%s" ); |
462 | STRUCT_SETUP(DBT, flags, "uint32_t %s" ); |
463 | STRUCT_SETUP(DBT, size, "uint32_t %s" ); |
464 | STRUCT_SETUP(DBT, ulen, "uint32_t %s" ); |
465 | sort_and_dump_fields("dbt" , false, NULL); |
466 | } |
467 | |
468 | static void print_db_struct (void) { |
469 | /* Do these in alphabetical order. */ |
470 | field_counter=0; |
471 | STRUCT_SETUP(DB, api_internal, "void *%s" ); /* Used for C++ hacking. */ |
472 | STRUCT_SETUP(DB, app_private, "void *%s" ); |
473 | STRUCT_SETUP(DB, close, "int (*%s) (DB*, uint32_t)" ); |
474 | STRUCT_SETUP(DB, cursor, "int (*%s) (DB *, DB_TXN *, DBC **, uint32_t)" ); |
475 | STRUCT_SETUP(DB, dbenv, "DB_ENV *%s" ); |
476 | STRUCT_SETUP(DB, del, "int (*%s) (DB *, DB_TXN *, DBT *, uint32_t)" ); |
477 | STRUCT_SETUP(DB, fd, "int (*%s) (DB *, int *)" ); |
478 | STRUCT_SETUP(DB, get, "int (*%s) (DB *, DB_TXN *, DBT *, DBT *, uint32_t)" ); |
479 | #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3 |
480 | STRUCT_SETUP(DB, get_flags, "int (*%s) (DB *, uint32_t *)" ); |
481 | STRUCT_SETUP(DB, get_pagesize, "int (*%s) (DB *, uint32_t *)" ); |
482 | #endif |
483 | STRUCT_SETUP(DB, key_range, "int (*%s) (DB *, DB_TXN *, DBT *, DB_KEY_RANGE *, uint32_t)" ); |
484 | STRUCT_SETUP(DB, open, "int (*%s) (DB *, DB_TXN *, const char *, const char *, DBTYPE, uint32_t, int)" ); |
485 | STRUCT_SETUP(DB, put, "int (*%s) (DB *, DB_TXN *, DBT *, DBT *, uint32_t)" ); |
486 | STRUCT_SETUP(DB, set_errfile, "void (*%s) (DB *, FILE*)" ); |
487 | STRUCT_SETUP(DB, set_flags, "int (*%s) (DB *, uint32_t)" ); |
488 | STRUCT_SETUP(DB, set_pagesize, "int (*%s) (DB *, uint32_t)" ); |
489 | STRUCT_SETUP(DB, stat, "int (*%s) (DB *, void *, uint32_t)" ); |
490 | STRUCT_SETUP(DB, verify, "int (*%s) (DB *, const char *, const char *, FILE *, uint32_t)" ); |
491 | const char *[]={ |
492 | "int (*key_range64)(DB*, DB_TXN *, DBT *, uint64_t *less, uint64_t *equal, uint64_t *greater, int *is_exact)" , |
493 | "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 */" , |
494 | "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)" , |
495 | "int (*stat64)(DB *, DB_TXN *, DB_BTREE_STAT64 *)" , |
496 | "int (*pre_acquire_table_lock)(DB*, DB_TXN*)" , |
497 | "int (*pre_acquire_fileops_lock)(DB*, DB_TXN*)" , |
498 | "const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/" , |
499 | "const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/" , |
500 | "void (*get_max_row_size) (DB*, uint32_t *max_key_size, uint32_t *max_row_size)" , |
501 | "DESCRIPTOR descriptor /* saved row/dictionary descriptor for aiding in comparisons */" , |
502 | "DESCRIPTOR cmp_descriptor /* saved row/dictionary descriptor for aiding in comparisons */" , |
503 | "int (*change_descriptor) (DB*, DB_TXN*, const DBT* descriptor, uint32_t) /* change row/dictionary descriptor for a db. Available only while db is open */" , |
504 | "int (*getf_set)(DB*, DB_TXN*, uint32_t, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_set without a persistent cursor) */" , |
505 | "int (*optimize)(DB*) /* Run garbage collecion and promote all transactions older than oldest. Amortized (happens during flattening) */" , |
506 | "int (*hot_optimize)(DB*, DBT*, DBT*, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra, uint64_t* loops_run)" , |
507 | "int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION)" , |
508 | "int (*change_pagesize)(DB*,uint32_t)" , |
509 | "int (*change_readpagesize)(DB*,uint32_t)" , |
510 | "int (*get_readpagesize)(DB*,uint32_t*)" , |
511 | "int (*set_readpagesize)(DB*,uint32_t)" , |
512 | "int (*change_compression_method)(DB*,TOKU_COMPRESSION_METHOD)" , |
513 | "int (*get_compression_method)(DB*,TOKU_COMPRESSION_METHOD*)" , |
514 | "int (*set_compression_method)(DB*,TOKU_COMPRESSION_METHOD)" , |
515 | "int (*change_fanout)(DB *db, uint32_t fanout)" , |
516 | "int (*get_fanout)(DB *db, uint32_t *fanout)" , |
517 | "int (*set_fanout)(DB *db, uint32_t fanout)" , |
518 | "int (*set_memcmp_magic)(DB *db, uint8_t magic)" , |
519 | "int (*set_indexer)(DB*, DB_INDEXER*)" , |
520 | "void (*get_indexer)(DB*, DB_INDEXER**)" , |
521 | "int (*verify_with_progress)(DB *, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra, int verbose, int keep_going)" , |
522 | "int (*update)(DB *, DB_TXN*, const DBT *key, const DBT *extra, uint32_t flags)" , |
523 | "int (*update_broadcast)(DB *, DB_TXN*, const DBT *extra, uint32_t flags)" , |
524 | "int (*get_fractal_tree_info64)(DB*,uint64_t*,uint64_t*,uint64_t*,uint64_t*)" , |
525 | "int (*iterate_fractal_tree_block_map)(DB*,int(*)(uint64_t,int64_t,int64_t,int64_t,int64_t,void*),void*)" , |
526 | "const char *(*get_dname)(DB *db)" , |
527 | "int (*get_last_key)(DB *db, YDB_CALLBACK_FUNCTION func, void* extra)" , |
528 | "int (*recount_rows)(DB* db, int (*progress_callback)(uint64_t count, uint64_t deleted, void* progress_extra), void* progress_extra)" , |
529 | NULL}; |
530 | sort_and_dump_fields("db" , true, extra); |
531 | } |
532 | |
533 | static void print_db_txn_active_struct (void) { |
534 | field_counter=0; |
535 | STRUCT_SETUP(DB_TXN_ACTIVE, lsn, "DB_LSN %s" ); |
536 | STRUCT_SETUP(DB_TXN_ACTIVE, txnid, "uint32_t %s" ); |
537 | sort_and_dump_fields("db_txn_active" , false, NULL); |
538 | } |
539 | |
540 | static void print_db_txn_struct (void) { |
541 | field_counter=0; |
542 | STRUCT_SETUP(DB_TXN, abort, "int (*%s) (DB_TXN *)" ); |
543 | STRUCT_SETUP(DB_TXN, api_internal,"void *%s" ); |
544 | STRUCT_SETUP(DB_TXN, commit, "int (*%s) (DB_TXN*, uint32_t)" ); |
545 | STRUCT_SETUP(DB_TXN, prepare, "int (*%s) (DB_TXN*, uint8_t gid[DB_GID_SIZE], uint32_t flags)" ); |
546 | STRUCT_SETUP(DB_TXN, discard, "int (*%s) (DB_TXN*, uint32_t)" ); |
547 | STRUCT_SETUP(DB_TXN, id, "uint32_t (*%s) (DB_TXN *)" ); |
548 | STRUCT_SETUP(DB_TXN, mgrp, "DB_ENV *%s /* In PerconaFT, mgrp is a DB_ENV, not a DB_TXNMGR */" ); |
549 | STRUCT_SETUP(DB_TXN, parent, "DB_TXN *%s" ); |
550 | const char *[] = { |
551 | "int (*txn_stat)(DB_TXN *, struct txn_stat **)" , |
552 | "int (*commit_with_progress)(DB_TXN*, uint32_t, TXN_PROGRESS_POLL_FUNCTION, void*)" , |
553 | "int (*abort_with_progress)(DB_TXN*, TXN_PROGRESS_POLL_FUNCTION, void*)" , |
554 | "int (*xa_prepare) (DB_TXN*, TOKU_XA_XID *, uint32_t flags)" , |
555 | "uint64_t (*id64) (DB_TXN*)" , |
556 | "void (*set_client_id)(DB_TXN *, uint64_t client_id, void *client_extra)" , |
557 | "void (*get_client_id)(DB_TXN *, uint64_t *client_id, void **client_extra)" , |
558 | "bool (*is_prepared)(DB_TXN *)" , |
559 | "DB_TXN *(*get_child)(DB_TXN *)" , |
560 | "uint64_t (*get_start_time)(DB_TXN *)" , |
561 | NULL}; |
562 | sort_and_dump_fields("db_txn" , false, extra); |
563 | } |
564 | |
565 | static void print_db_txn_stat_struct (void) { |
566 | field_counter=0; |
567 | STRUCT_SETUP(DB_TXN_STAT, st_nactive, "uint32_t %s" ); |
568 | STRUCT_SETUP(DB_TXN_STAT, st_txnarray, "DB_TXN_ACTIVE *%s" ); |
569 | sort_and_dump_fields("db_txn_stat" , false, NULL); |
570 | } |
571 | |
572 | static void print_dbc_struct (void) { |
573 | field_counter=0; |
574 | STRUCT_SETUP(DBC, c_close, "int (*%s) (DBC *)" ); |
575 | //STRUCT_SETUP(DBC, c_del, "int (*%s) (DBC *, uint32_t)"); // c_del was removed. See #4576. |
576 | STRUCT_SETUP(DBC, c_get, "int (*%s) (DBC *, DBT *, DBT *, uint32_t)" ); |
577 | STRUCT_SETUP(DBC, dbp, "DB *%s" ); |
578 | const char *[]={ |
579 | "int (*c_getf_first)(DBC *, uint32_t, YDB_CALLBACK_FUNCTION, void *)" , |
580 | "int (*c_getf_last)(DBC *, uint32_t, YDB_CALLBACK_FUNCTION, void *)" , |
581 | "int (*c_getf_next)(DBC *, uint32_t, YDB_CALLBACK_FUNCTION, void *)" , |
582 | "int (*c_getf_prev)(DBC *, uint32_t, YDB_CALLBACK_FUNCTION, void *)" , |
583 | "int (*c_getf_current)(DBC *, uint32_t, YDB_CALLBACK_FUNCTION, void *)" , |
584 | "int (*c_getf_set)(DBC *, uint32_t, DBT *, YDB_CALLBACK_FUNCTION, void *)" , |
585 | "int (*c_getf_set_range)(DBC *, uint32_t, DBT *, YDB_CALLBACK_FUNCTION, void *)" , |
586 | "int (*c_getf_set_range_reverse)(DBC *, uint32_t, DBT *, YDB_CALLBACK_FUNCTION, void *)" , |
587 | "int (*c_getf_set_range_with_bound)(DBC *, uint32_t, DBT *k, DBT *k_bound, YDB_CALLBACK_FUNCTION, void *)" , |
588 | "int (*c_set_bounds)(DBC*, const DBT*, const DBT*, bool pre_acquire, int out_of_range_error)" , |
589 | "void (*c_set_check_interrupt_callback)(DBC*, bool (*)(void*, uint64_t deleted_rows), void *)" , |
590 | "void (*c_remove_restriction)(DBC*)" , |
591 | "void (*c_set_txn)(DBC*, DB_TXN*)" , |
592 | "char _internal[512]" , |
593 | NULL}; |
594 | sort_and_dump_fields("dbc" , false, extra); |
595 | } |
596 | |
597 | |
598 | int main (int argc, char *const argv[] __attribute__((__unused__))) { |
599 | assert(argc==1); |
600 | |
601 | printf("#ifndef _DB_H\n" ); |
602 | printf("#define _DB_H\n" ); |
603 | printf("/* This code generated by make_db_h. Copyright (c) 2006, 2015, Percona and/or its affiliates. */\n" ); |
604 | printf("#ident \"Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.\"\n" ); |
605 | printf("#include <sys/types.h>\n" ); |
606 | printf("/*stdio is needed for the FILE* in db->verify*/\n" ); |
607 | printf("#include <stdio.h>\n" ); |
608 | printf("/*stdbool is needed for the bool in db_env_enable_engine_status*/\n" ); |
609 | printf("#include <stdbool.h>\n" ); |
610 | printf("#include <stdint.h>\n" ); |
611 | //printf("#include <inttypes.h>\n"); |
612 | printf("#if defined(__cplusplus) || defined(__cilkplusplus)\nextern \"C\" {\n#endif\n" ); |
613 | |
614 | printf("#define DB_VERSION_MAJOR %d\n" , DB_VERSION_MAJOR); |
615 | printf("#define DB_VERSION_MINOR %d\n" , DB_VERSION_MINOR); |
616 | printf("/* As of r40364 (post PerconaFT 5.2.7), the patch version number is 100+ the BDB header patch version number.*/\n" ); |
617 | printf("#define DB_VERSION_PATCH %d\n" , 100+DB_VERSION_PATCH); |
618 | printf("#define DB_VERSION_STRING \"Percona: PerconaFT %d.%d.%d\"\n" , DB_VERSION_MAJOR, DB_VERSION_MINOR, 100+DB_VERSION_PATCH); |
619 | |
620 | #ifndef DB_GID_SIZE |
621 | #define DB_GID_SIZE DB_XIDDATASIZE |
622 | #endif |
623 | dodefine(DB_GID_SIZE); |
624 | |
625 | printf("typedef 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 */\n" |
626 | " long formatID; /* format identifier */\n" |
627 | " long gtrid_length; /* value from 1 through 64 */\n" |
628 | " long bqual_length; /* value from 1 through 64 */\n" |
629 | " char data[DB_GID_SIZE];\n" |
630 | "} TOKU_XA_XID;\n" ); |
631 | |
632 | printf("#ifndef TOKU_OFF_T_DEFINED\n" |
633 | "#define TOKU_OFF_T_DEFINED\n" |
634 | "typedef int64_t toku_off_t;\n" |
635 | "#endif\n" ); |
636 | |
637 | printf("typedef struct __toku_db_env DB_ENV;\n" ); |
638 | printf("typedef struct __toku_db_key_range DB_KEY_RANGE;\n" ); |
639 | printf("typedef struct __toku_db_lsn DB_LSN;\n" ); |
640 | printf("typedef struct __toku_db DB;\n" ); |
641 | printf("typedef struct __toku_db_txn DB_TXN;\n" ); |
642 | printf("typedef struct __toku_db_txn_active DB_TXN_ACTIVE;\n" ); |
643 | printf("typedef struct __toku_db_txn_stat DB_TXN_STAT;\n" ); |
644 | printf("typedef struct __toku_dbc DBC;\n" ); |
645 | printf("typedef struct __toku_dbt DBT;\n" ); |
646 | printf("typedef struct __toku_db_preplist { DB_TXN *txn; uint8_t gid[DB_GID_SIZE]; } DB_PREPLIST;\n" ); |
647 | printf("typedef uint32_t db_recno_t;\n" ); |
648 | printf("typedef int(*YDB_CALLBACK_FUNCTION)(DBT const*, DBT const*, void*);\n" ); |
649 | |
650 | printf("struct simple_dbt {\n" ); |
651 | printf(" uint32_t len;\n" ); |
652 | printf(" void *data;\n" ); |
653 | printf("};\n" ); |
654 | |
655 | //stat64 |
656 | printf("typedef struct __toku_db_btree_stat64 {\n" ); |
657 | printf(" uint64_t bt_nkeys; /* how many unique keys (guaranteed only to be an estimate, even when flattened) */\n" ); |
658 | printf(" uint64_t bt_ndata; /* how many key-value pairs (an estimate, but exact when flattened) */\n" ); |
659 | printf(" uint64_t bt_dsize; /* how big are the keys+values (not counting the lengths) (an estimate, unless flattened) */\n" ); |
660 | printf(" uint64_t bt_fsize; /* how big is the underlying file */\n" ); |
661 | // 4018 |
662 | printf(" uint64_t bt_create_time_sec; /* Creation time, in seconds */\n" ); |
663 | printf(" uint64_t bt_modify_time_sec; /* Time of last serialization, in seconds */\n" ); |
664 | printf(" uint64_t bt_verify_time_sec; /* Time of last verification, in seconds */\n" ); |
665 | printf("} DB_BTREE_STAT64;\n" ); |
666 | |
667 | // compression methods |
668 | printf("typedef enum toku_compression_method {\n" ); |
669 | printf(" TOKU_NO_COMPRESSION = 0,\n" ); // "identity" compression |
670 | printf(" TOKU_SNAPPY_METHOD = 7,\n" ); // google snappy |
671 | printf(" TOKU_ZLIB_METHOD = 8,\n" ); // RFC 1950 says use 8 for zlib. It reserves 15 to allow more bytes. |
672 | printf(" TOKU_QUICKLZ_METHOD = 9,\n" ); // We use 9 for QUICKLZ (the QLZ compression level is stored int he high-order nibble). I couldn't find any standard for any other numbers, so I just use 9. -Bradley |
673 | printf(" TOKU_LZMA_METHOD = 10,\n" ); // We use 10 for LZMA. (Note the compression level is stored in the high-order nibble). |
674 | printf(" TOKU_ZLIB_WITHOUT_CHECKSUM_METHOD = 11,\n" ); // We wrap a zlib without checksumming compression technique in our own checksummed metadata. |
675 | printf(" TOKU_DEFAULT_COMPRESSION_METHOD = 1,\n" ); // default is actually quicklz |
676 | printf(" TOKU_FAST_COMPRESSION_METHOD = 2,\n" ); // friendlier names |
677 | printf(" TOKU_SMALL_COMPRESSION_METHOD = 3,\n" ); |
678 | printf("} TOKU_COMPRESSION_METHOD;\n" ); |
679 | |
680 | //bulk loader |
681 | printf("typedef struct __toku_loader DB_LOADER;\n" ); |
682 | printf("struct __toku_loader_internal;\n" ); |
683 | printf("struct __toku_loader {\n" ); |
684 | printf(" struct __toku_loader_internal *i;\n" ); |
685 | printf(" 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 */\n" ); |
686 | printf(" int (*set_poll_function)(DB_LOADER *loader, int (*poll_func)(void *extra, float progress), void *poll_extra); /* set the polling function */\n" ); |
687 | printf(" int (*put)(DB_LOADER *loader, DBT *key, DBT* val); /* give a row to the loader */\n" ); |
688 | printf(" int (*close)(DB_LOADER *loader); /* finish loading, free memory */\n" ); |
689 | printf(" int (*abort)(DB_LOADER *loader); /* abort loading, free memory */\n" ); |
690 | printf("};\n" ); |
691 | |
692 | //indexer |
693 | printf("typedef struct __toku_indexer DB_INDEXER;\n" ); |
694 | printf("struct __toku_indexer_internal;\n" ); |
695 | printf("struct __toku_indexer {\n" ); |
696 | printf(" struct __toku_indexer_internal *i;\n" ); |
697 | printf(" 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 */\n" ); |
698 | printf(" int (*set_poll_function)(DB_INDEXER *indexer, int (*poll_func)(void *extra, float progress), void *poll_extra); /* set the polling function */\n" ); |
699 | printf(" int (*build)(DB_INDEXER *indexer); /* build the indexes */\n" ); |
700 | printf(" int (*close)(DB_INDEXER *indexer); /* finish indexing, free memory */\n" ); |
701 | printf(" int (*abort)(DB_INDEXER *indexer); /* abort indexing, free memory */\n" ); |
702 | printf("};\n" ); |
703 | |
704 | // Filesystem redzone state |
705 | printf("typedef enum { \n" ); |
706 | printf(" FS_GREEN = 0, // green zone (we have lots of space) \n" ); |
707 | printf(" FS_YELLOW = 1, // yellow zone (issue warning but allow operations) \n" ); |
708 | printf(" FS_RED = 2, // red zone (prevent insert operations) \n" ); |
709 | printf(" FS_BLOCKED = 3 // For reporting engine status, completely blocked \n" ); |
710 | printf("} fs_redzone_state;\n" ); |
711 | |
712 | printf("// engine status info\n" ); |
713 | printf("// engine status is passed to handlerton as an array of TOKU_ENGINE_STATUS_ROW_S[]\n" ); |
714 | |
715 | printf("typedef enum {\n" ); |
716 | printf(" FS_STATE = 0, // interpret as file system state (redzone) enum \n" ); |
717 | printf(" UINT64, // interpret as uint64_t \n" ); |
718 | printf(" CHARSTR, // interpret as char * \n" ); |
719 | printf(" UNIXTIME, // interpret as time_t \n" ); |
720 | printf(" TOKUTIME, // interpret as tokutime_t \n" ); |
721 | printf(" PARCOUNT, // interpret as PARTITIONED_COUNTER\n" ); |
722 | printf(" DOUBLE // interpret as double\n" ); |
723 | printf("} toku_engine_status_display_type; \n" ); |
724 | |
725 | printf("typedef enum {\n" ); |
726 | printf(" TOKU_ENGINE_STATUS = (1ULL<<0), // Include when asking for engine status\n" ); |
727 | printf(" TOKU_GLOBAL_STATUS = (1ULL<<1), // Include when asking for information_schema.global_status\n" ); |
728 | printf("} toku_engine_status_include_type; \n" ); |
729 | |
730 | printf("typedef struct __toku_engine_status_row {\n" ); |
731 | printf(" const char * keyname; // info schema key, should not change across revisions without good reason \n" ); |
732 | printf(" const char * columnname; // column for mysql, e.g. information_schema.global_status. TOKUDB_ will automatically be prefixed.\n" ); |
733 | printf(" const char * legend; // the text that will appear at user interface \n" ); |
734 | printf(" toku_engine_status_display_type type; // how to interpret the value \n" ); |
735 | printf(" toku_engine_status_include_type include; // which kinds of callers should get read this row?\n" ); |
736 | printf(" union { \n" ); |
737 | printf(" double dnum; \n" ); |
738 | printf(" uint64_t num; \n" ); |
739 | printf(" const char * str; \n" ); |
740 | printf(" char datebuf[26]; \n" ); |
741 | printf(" struct partitioned_counter *parcount;\n" ); |
742 | printf(" } value; \n" ); |
743 | printf("} * TOKU_ENGINE_STATUS_ROW, TOKU_ENGINE_STATUS_ROW_S; \n" ); |
744 | |
745 | print_dbtype(); |
746 | print_defines(); |
747 | |
748 | printf("typedef struct {\n" ); |
749 | printf(" uint32_t capacity;\n" ); |
750 | printf(" uint32_t size;\n" ); |
751 | printf(" DBT *dbts;\n" ); |
752 | printf("} DBT_ARRAY;\n\n" ); |
753 | printf("typedef 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);\n" ); |
754 | printf("typedef int (*generate_row_for_del_func)(DB *dest_db, DB *src_db, DBT_ARRAY * dest_keys, const DBT *src_key, const DBT *src_val);\n" ); |
755 | printf("DBT_ARRAY * toku_dbt_array_init(DBT_ARRAY *dbts, uint32_t size) %s;\n" , VISIBLE); |
756 | printf("void toku_dbt_array_destroy(DBT_ARRAY *dbts) %s;\n" , VISIBLE); |
757 | printf("void toku_dbt_array_destroy_shallow(DBT_ARRAY *dbts) %s;\n" , VISIBLE); |
758 | printf("void toku_dbt_array_resize(DBT_ARRAY *dbts, uint32_t size) %s;\n" , VISIBLE); |
759 | |
760 | printf("typedef void (*lock_timeout_callback)(DB *db, uint64_t requesting_txnid, const DBT *left_key, const DBT *right_key, uint64_t blocking_txnid);\n" ); |
761 | printf("typedef void (*lock_wait_callback)(void *arg, uint64_t requesting_txnid, uint64_t blocking_txnid);\n" ); |
762 | printf("typedef int (*iterate_row_locks_callback)(DB **db, DBT *left_key, DBT *right_key, void *extra);\n" ); |
763 | printf("typedef int (*iterate_transactions_callback)(DB_TXN *dbtxn, iterate_row_locks_callback cb, void *locks_extra, void *extra);\n" ); |
764 | printf("typedef 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);\n" ); |
765 | print_db_env_struct(); |
766 | print_db_key_range_struct(); |
767 | print_db_lsn_struct(); |
768 | print_dbt_struct(); |
769 | |
770 | printf("typedef struct __toku_descriptor {\n" ); |
771 | printf(" DBT dbt;\n" ); |
772 | printf("} *DESCRIPTOR, DESCRIPTOR_S;\n" ); |
773 | |
774 | //file fragmentation info |
775 | //a block is just a contiguous region in a file. |
776 | printf("//One header is included in 'data'\n" ); |
777 | printf("//One header is included in 'additional for checkpoint'\n" ); |
778 | printf("typedef struct __toku_db_fragmentation {\n" ); |
779 | printf(" uint64_t file_size_bytes; //Total file size in bytes\n" ); |
780 | printf(" uint64_t data_bytes; //Compressed User Data in bytes\n" ); |
781 | printf(" uint64_t data_blocks; //Number of blocks of compressed User Data\n" ); |
782 | printf(" uint64_t checkpoint_bytes_additional; //Additional bytes used for checkpoint system\n" ); |
783 | printf(" uint64_t checkpoint_blocks_additional; //Additional blocks used for checkpoint system \n" ); |
784 | printf(" uint64_t unused_bytes; //Unused space in file\n" ); |
785 | printf(" uint64_t unused_blocks; //Number of contiguous regions of unused space\n" ); |
786 | printf(" uint64_t largest_unused_block; //Size of largest contiguous unused space\n" ); |
787 | printf("} *TOKU_DB_FRAGMENTATION, TOKU_DB_FRAGMENTATION_S;\n" ); |
788 | |
789 | print_db_struct(); |
790 | |
791 | print_db_txn_active_struct(); |
792 | |
793 | printf("typedef struct __toku_txn_progress {\n" ); |
794 | printf(" uint64_t entries_total;\n" ); |
795 | printf(" uint64_t entries_processed;\n" ); |
796 | printf(" uint8_t is_commit;\n" ); |
797 | printf(" uint8_t stalled_on_checkpoint;\n" ); |
798 | printf("} *TOKU_TXN_PROGRESS, TOKU_TXN_PROGRESS_S;\n" ); |
799 | printf("typedef void(*TXN_PROGRESS_POLL_FUNCTION)(TOKU_TXN_PROGRESS, void*);\n" ); |
800 | printf("struct txn_stat {\n uint64_t rollback_raw_count;\n uint64_t rollback_num_entries;\n};\n" ); |
801 | |
802 | print_db_txn_struct(); |
803 | print_db_txn_stat_struct(); |
804 | print_dbc_struct(); |
805 | |
806 | printf("int db_env_create(DB_ENV **, uint32_t) %s;\n" , VISIBLE); |
807 | printf("int db_create(DB **, DB_ENV *, uint32_t) %s;\n" , VISIBLE); |
808 | printf("const char *db_strerror(int) %s;\n" , VISIBLE); |
809 | printf("const char *db_version(int*,int *,int *) %s;\n" , VISIBLE); |
810 | printf("int log_compare (const DB_LSN*, const DB_LSN *) %s;\n" , VISIBLE); |
811 | printf("int toku_set_trace_file (const char *fname) %s;\n" , VISIBLE); |
812 | printf("int toku_close_trace_file (void) %s;\n" , VISIBLE); |
813 | printf("void db_env_set_direct_io (bool direct_io_on) %s;\n" , VISIBLE); |
814 | printf("void db_env_set_compress_buffers_before_eviction (bool compress_buffers) %s;\n" , VISIBLE); |
815 | printf("void db_env_set_func_fsync (int (*)(int)) %s;\n" , VISIBLE); |
816 | printf("void db_env_set_func_free (void (*)(void*)) %s;\n" , VISIBLE); |
817 | printf("void db_env_set_func_malloc (void *(*)(size_t)) %s;\n" , VISIBLE); |
818 | printf("void db_env_set_func_realloc (void *(*)(void*, size_t)) %s;\n" , VISIBLE); |
819 | printf("void db_env_set_func_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) %s;\n" , VISIBLE); |
820 | printf("void db_env_set_func_full_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) %s;\n" , VISIBLE); |
821 | printf("void db_env_set_func_write (ssize_t (*)(int, const void *, size_t)) %s;\n" , VISIBLE); |
822 | printf("void db_env_set_func_full_write (ssize_t (*)(int, const void *, size_t)) %s;\n" , VISIBLE); |
823 | printf("void db_env_set_func_fdopen (FILE* (*)(int, const char *)) %s;\n" , VISIBLE); |
824 | printf("void db_env_set_func_fopen (FILE* (*)(const char *, const char *)) %s;\n" , VISIBLE); |
825 | printf("void db_env_set_func_open (int (*)(const char *, int, int)) %s;\n" , VISIBLE); |
826 | printf("void db_env_set_func_fclose (int (*)(FILE*)) %s;\n" , VISIBLE); |
827 | printf("void db_env_set_func_pread (ssize_t (*)(int, void *, size_t, off_t)) %s;\n" , VISIBLE); |
828 | printf("void db_env_set_func_loader_fwrite (size_t (*fwrite_fun)(const void*,size_t,size_t,FILE*)) %s;\n" , VISIBLE); |
829 | printf("void db_env_set_checkpoint_callback (void (*)(void*), void*) %s;\n" , VISIBLE); |
830 | printf("void db_env_set_checkpoint_callback2 (void (*)(void*), void*) %s;\n" , VISIBLE); |
831 | printf("void db_env_set_recover_callback (void (*)(void*), void*) %s;\n" , VISIBLE); |
832 | printf("void db_env_set_recover_callback2 (void (*)(void*), void*) %s;\n" , VISIBLE); |
833 | printf("void db_env_set_loader_size_factor (uint32_t) %s;\n" , VISIBLE); |
834 | printf("void db_env_set_mvcc_garbage_collection_verification(uint32_t) %s;\n" , VISIBLE); |
835 | printf("void db_env_enable_engine_status(bool) %s;\n" , VISIBLE); |
836 | printf("void db_env_set_flusher_thread_callback (void (*)(int, void*), void*) %s;\n" , VISIBLE); |
837 | printf("void db_env_set_num_bucket_mutexes(uint32_t) %s;\n" , VISIBLE); |
838 | printf("int db_env_set_toku_product_name(const char*) %s;\n" , VISIBLE); |
839 | printf("void db_env_try_gdb_stack_trace(const char *gdb_path) %s;\n" , VISIBLE); |
840 | |
841 | printf("#if defined(__cplusplus) || defined(__cilkplusplus)\n}\n#endif\n" ); |
842 | printf("#endif\n" ); |
843 | |
844 | return 0; |
845 | } |
846 | |