Commit 1a48d758 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul Committed by Yoni Fogel

Merge in the 1390 fixes, and delete 1390. Fixes #1390.

{{{
svn merge -r10820:HEAD https://svn.tokutek.com/tokudb/toku/tokudb.1390
}}}


git-svn-id: file:///svn/toku/tokudb@11192 c7de825b-a66e-492c-adef-691d508d4ae1
parent 7ebad62d
......@@ -19,7 +19,7 @@ CFLAGS = -Wall -W -Werror -g $(OPTFLAGS)
runs: runs_mysql runs_installed
samples: sample_offsets_4_6 sample_offsets_4_5 sample_offsets_4_4 sample_offsets_4_3 sample_offsets_4_1
hs: db.h_4_6 db.h_4_5 db.h_4_4 db.h_4_3 db.h_4_1
hs: db.h_4_6 db.h_4_5 db.h_4_4 db.h_4_3 db.h_4_1 tdb.h
# the mysql versions use the header in the mysql distribution.
runs_mysql: ./sample_offsets_mysql
./sample_offsets_mysql
......@@ -30,7 +30,7 @@ sample_offsets_mysql: sample_offsets.c
$(CC) $(CFLAGS) $(CPPFLAGS) $< -o $@
make_db_h_4_1.o: make_db_h.c sample_offsets_32_4_1.h sample_offsets_64_4_1.h
$(CC) $(CFLAGS) -I. -I$(BDBDIR)/db-4.1.25/build_unix $< -c -o $@ -DUSE_MAJOR=4 -DUSE_MINOR=1
$(CC) $(CFLAGS) -I. -I$(BDBDIR)/db-4.1.25/build_unix $< -c -o $@ -DUSE_MAJOR=4 -DUSE_MINOR=1 -DTDB_NATIVE=0
db.h_4_1: make_db_h_4_1
./make_db_h_4_1 > $@
sample_offsets_4_1: sample_offsets.c
......@@ -38,7 +38,7 @@ sample_offsets_4_1: sample_offsets.c
./sample_offsets_4_1
make_db_h_4_3.o: make_db_h.c sample_offsets_32_4_3.h sample_offsets_64_4_3.h
$(CC) $(CFLAGS) -I. -I$(BDBDIR)/db-4.3.29/build_unix $< -c -o $@ -DUSE_MAJOR=4 -DUSE_MINOR=3
$(CC) $(CFLAGS) -I. -I$(BDBDIR)/db-4.3.29/build_unix $< -c -o $@ -DUSE_MAJOR=4 -DUSE_MINOR=3 -DTDB_NATIVE=0
db.h_4_3: make_db_h_4_3
./make_db_h_4_3 > $@
sample_offsets_4_3: sample_offsets.c
......@@ -46,7 +46,7 @@ sample_offsets_4_3: sample_offsets.c
./sample_offsets_4_3
make_db_h_4_4.o: make_db_h.c sample_offsets_32_4_4.h sample_offsets_64_4_4.h
$(CC) $(CFLAGS) -I. -I$(BDBDIR)/db-4.4.20/build_unix $< -c -o $@ -DUSE_MAJOR=4 -DUSE_MINOR=4
$(CC) $(CFLAGS) -I. -I$(BDBDIR)/db-4.4.20/build_unix $< -c -o $@ -DUSE_MAJOR=4 -DUSE_MINOR=4 -DTDB_NATIVE=0
db.h_4_4: make_db_h_4_4
./make_db_h_4_4 > $@
sample_offsets_4_4: sample_offsets.c
......@@ -54,7 +54,7 @@ sample_offsets_4_4: sample_offsets.c
./sample_offsets_4_4
make_db_h_4_5.o: make_db_h.c sample_offsets_32_4_5.h sample_offsets_64_4_5.h
$(CC) $(CFLAGS) -I. -I$(BDBDIR)/db-4.5.20/build_unix $< -c -o $@ -DUSE_MAJOR=4 -DUSE_MINOR=5
$(CC) $(CFLAGS) -I. -I$(BDBDIR)/db-4.5.20/build_unix $< -c -o $@ -DUSE_MAJOR=4 -DUSE_MINOR=5 -DTDB_NATIVE=0
db.h_4_5: make_db_h_4_5
./make_db_h_4_5 > $@
sample_offsets_4_5: sample_offsets.c
......@@ -62,19 +62,24 @@ sample_offsets_4_5: sample_offsets.c
./sample_offsets_4_5
make_db_h_4_6.o: make_db_h.c sample_offsets_32_4_6.h sample_offsets_64_4_6.h
$(CC) $(CFLAGS) -I. -I$(BDBDIR)/db-4.6.19/build_unix $< -c -o $@ -DUSE_MAJOR=4 -DUSE_MINOR=6
$(CC) $(CFLAGS) -I. -I$(BDBDIR)/db-4.6.19/build_unix $< -c -o $@ -DUSE_MAJOR=4 -DUSE_MINOR=6 -DTDB_NATIVE=0
db.h_4_6: make_db_h_4_6
./make_db_h_4_6 > $@
sample_offsets_4_6: sample_offsets.c
$(CC) $(CFLAGS) -I. -I$(BDBDIR)/db-4.6.19/build_unix $< -o $@
./sample_offsets_4_6
make_tdb_h.o: make_db_h.c
$(CC) $(CFLAGS) -I. -I$(BDBDIR)/db-4.6.19/build_unix $< -c -o $@ -DUSE_MAJOR=4 -DUSE_MINOR=6 -DTDB_NATIVE=1
tdb.h: make_tdb_h
./make_tdb_h > $@
sample_offsets:
sample_offsets_local: ./db.h
sample_offsets_local: sample_offsets.c
$(CC) $(CFLAGS) -I. -DLOCAL $< -o $@
hfiles: db.h_4_1 db.h_4_3 db.h_4_4 db.h_4_5 db.h_4_6
hfiles: db.h_4_1 db.h_4_3 db.h_4_4 db.h_4_5 db.h_4_6 tdb.h
check32: sample_offsets_local
./sample_offsets_local
......@@ -82,7 +87,9 @@ check32: sample_offsets_local
clean:
rm -f sample_offsets_mysql sample_offsets sample_offsets_?_? *.o make_db_h_?_?
install: db.h_$(BDB)
install: tdb.h
cp tdb.h ../include/db.h
install_bdb_compatible: db.h_$(BDB)
cp db.h_$(BDB) ../include/db.h
# Note: To make the compile work, you must cd to the ../../berkeleydb/db-4.1.25/build_unix
......
......@@ -9,6 +9,7 @@
extern "C" {
#endif
#define TOKUDB 1
#define TOKUDB_NATIVE_H 0
#define DB_VERSION_MAJOR 4
#define DB_VERSION_MINOR 1
#define DB_VERSION_PATCH 25
......@@ -34,6 +35,7 @@ typedef u_int32_t db_recno_t;
typedef int(*YDB_CALLBACK_FUNCTION)(DBT const*, DBT const*, void*);
typedef int(*YDB_HEAVISIDE_CALLBACK_FUNCTION)(DBT const *key, DBT const *value, void *extra_f, int r_h);
typedef int(*YDB_HEAVISIDE_FUNCTION)(const DBT *key, const DBT *value, void *extra_h);
#include <tdb-internal.h>
typedef struct __toku_db_btree_stat64 {
u_int64_t bt_nkeys; /* how many unique keys (guaranteed only to be an estimate, even when flattened) */
u_int64_t bt_ndata; /* how many key-value pairs (an estimate, but exact when flattened) */
......@@ -122,6 +124,7 @@ typedef enum {
#endif
struct __toku_db_env {
struct __toku_db_env_internal *i;
#define db_env_struct_i(x) ((x)->i)
int (*checkpointing_postpone) (DB_ENV*) /* Use for 'rename table' or any other operation that must be disjoint from a checkpoint */;
int (*checkpointing_resume) (DB_ENV*) /* Alert tokudb 'postpone' is no longer necessary */;
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 */;
......@@ -192,6 +195,7 @@ struct __toku_dbt {
};
struct __toku_db {
struct __toku_db_internal *i;
#define db_struct_i(x) ((x)->i)
int (*key_range64)(DB*, DB_TXN *, DBT *, u_int64_t *less, u_int64_t *equal, u_int64_t *greater, int *is_exact);
int (*stat64)(DB *, DB_TXN *, DB_BTREE_STAT64 *);
int (*pre_acquire_read_lock)(DB*, DB_TXN*, const DBT*, const DBT*, const DBT*, const DBT*);
......@@ -249,6 +253,7 @@ struct __toku_db_txn {
DB_ENV *mgrp /*In TokuDB, mgrp is a DB_ENV not a DB_TXNMGR*/; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */
DB_TXN *parent; /* 32-bit offset=4 size=4, 64=bit offset=8 size=8 */
struct __toku_db_txn_internal *i;
#define db_txn_struct_i(x) ((x)->i)
int (*txn_stat)(DB_TXN *, struct txn_stat **);
void* __toku_dummy0[7];
char __toku_dummy1[24];
......@@ -272,6 +277,7 @@ struct __toku_db_txn_stat {
struct __toku_dbc {
DB *dbp; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */
struct __toku_dbc_internal *i;
#define dbc_struct_i(x) ((x)->i)
int (*c_getf_first)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *);
int (*c_getf_last)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *);
int (*c_getf_next)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *);
......
......@@ -9,6 +9,7 @@
extern "C" {
#endif
#define TOKUDB 1
#define TOKUDB_NATIVE_H 0
#define DB_VERSION_MAJOR 4
#define DB_VERSION_MINOR 3
#define DB_VERSION_PATCH 29
......@@ -34,6 +35,7 @@ typedef u_int32_t db_recno_t;
typedef int(*YDB_CALLBACK_FUNCTION)(DBT const*, DBT const*, void*);
typedef int(*YDB_HEAVISIDE_CALLBACK_FUNCTION)(DBT const *key, DBT const *value, void *extra_f, int r_h);
typedef int(*YDB_HEAVISIDE_FUNCTION)(const DBT *key, const DBT *value, void *extra_h);
#include <tdb-internal.h>
typedef struct __toku_db_btree_stat64 {
u_int64_t bt_nkeys; /* how many unique keys (guaranteed only to be an estimate, even when flattened) */
u_int64_t bt_ndata; /* how many key-value pairs (an estimate, but exact when flattened) */
......@@ -124,6 +126,7 @@ typedef enum {
#endif
struct __toku_db_env {
struct __toku_db_env_internal *i;
#define db_env_struct_i(x) ((x)->i)
int (*checkpointing_postpone) (DB_ENV*) /* Use for 'rename table' or any other operation that must be disjoint from a checkpoint */;
int (*checkpointing_resume) (DB_ENV*) /* Alert tokudb 'postpone' is no longer necessary */;
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 */;
......@@ -202,6 +205,7 @@ struct __toku_dbt {
};
struct __toku_db {
struct __toku_db_internal *i;
#define db_struct_i(x) ((x)->i)
int (*key_range64)(DB*, DB_TXN *, DBT *, u_int64_t *less, u_int64_t *equal, u_int64_t *greater, int *is_exact);
int (*stat64)(DB *, DB_TXN *, DB_BTREE_STAT64 *);
int (*pre_acquire_read_lock)(DB*, DB_TXN*, const DBT*, const DBT*, const DBT*, const DBT*);
......@@ -265,6 +269,7 @@ struct __toku_db_txn {
DB_ENV *mgrp /*In TokuDB, mgrp is a DB_ENV not a DB_TXNMGR*/; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */
DB_TXN *parent; /* 32-bit offset=4 size=4, 64=bit offset=8 size=8 */
struct __toku_db_txn_internal *i;
#define db_txn_struct_i(x) ((x)->i)
int (*txn_stat)(DB_TXN *, struct txn_stat **);
void* __toku_dummy0[12];
char __toku_dummy1[24];
......@@ -288,6 +293,7 @@ struct __toku_db_txn_stat {
struct __toku_dbc {
DB *dbp; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */
struct __toku_dbc_internal *i;
#define dbc_struct_i(x) ((x)->i)
int (*c_getf_first)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *);
int (*c_getf_last)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *);
int (*c_getf_next)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *);
......
......@@ -9,6 +9,7 @@
extern "C" {
#endif
#define TOKUDB 1
#define TOKUDB_NATIVE_H 0
#define DB_VERSION_MAJOR 4
#define DB_VERSION_MINOR 4
#define DB_VERSION_PATCH 20
......@@ -34,6 +35,7 @@ typedef u_int32_t db_recno_t;
typedef int(*YDB_CALLBACK_FUNCTION)(DBT const*, DBT const*, void*);
typedef int(*YDB_HEAVISIDE_CALLBACK_FUNCTION)(DBT const *key, DBT const *value, void *extra_f, int r_h);
typedef int(*YDB_HEAVISIDE_FUNCTION)(const DBT *key, const DBT *value, void *extra_h);
#include <tdb-internal.h>
typedef struct __toku_db_btree_stat64 {
u_int64_t bt_nkeys; /* how many unique keys (guaranteed only to be an estimate, even when flattened) */
u_int64_t bt_ndata; /* how many key-value pairs (an estimate, but exact when flattened) */
......@@ -125,6 +127,7 @@ typedef enum {
#endif
struct __toku_db_env {
struct __toku_db_env_internal *i;
#define db_env_struct_i(x) ((x)->i)
int (*checkpointing_postpone) (DB_ENV*) /* Use for 'rename table' or any other operation that must be disjoint from a checkpoint */;
int (*checkpointing_resume) (DB_ENV*) /* Alert tokudb 'postpone' is no longer necessary */;
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 */;
......@@ -205,6 +208,7 @@ struct __toku_dbt {
};
struct __toku_db {
struct __toku_db_internal *i;
#define db_struct_i(x) ((x)->i)
int (*key_range64)(DB*, DB_TXN *, DBT *, u_int64_t *less, u_int64_t *equal, u_int64_t *greater, int *is_exact);
int (*stat64)(DB *, DB_TXN *, DB_BTREE_STAT64 *);
int (*pre_acquire_read_lock)(DB*, DB_TXN*, const DBT*, const DBT*, const DBT*, const DBT*);
......@@ -272,6 +276,7 @@ struct __toku_db_txn {
DB_ENV *mgrp /*In TokuDB, mgrp is a DB_ENV not a DB_TXNMGR*/; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */
DB_TXN *parent; /* 32-bit offset=4 size=4, 64=bit offset=8 size=8 */
struct __toku_db_txn_internal *i;
#define db_txn_struct_i(x) ((x)->i)
int (*txn_stat)(DB_TXN *, struct txn_stat **);
void* __toku_dummy0[15];
char __toku_dummy1[8];
......@@ -295,6 +300,7 @@ struct __toku_db_txn_stat {
struct __toku_dbc {
DB *dbp; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */
struct __toku_dbc_internal *i;
#define dbc_struct_i(x) ((x)->i)
int (*c_getf_first)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *);
int (*c_getf_last)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *);
int (*c_getf_next)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *);
......
......@@ -9,6 +9,7 @@
extern "C" {
#endif
#define TOKUDB 1
#define TOKUDB_NATIVE_H 0
#define DB_VERSION_MAJOR 4
#define DB_VERSION_MINOR 5
#define DB_VERSION_PATCH 20
......@@ -34,6 +35,7 @@ typedef u_int32_t db_recno_t;
typedef int(*YDB_CALLBACK_FUNCTION)(DBT const*, DBT const*, void*);
typedef int(*YDB_HEAVISIDE_CALLBACK_FUNCTION)(DBT const *key, DBT const *value, void *extra_f, int r_h);
typedef int(*YDB_HEAVISIDE_FUNCTION)(const DBT *key, const DBT *value, void *extra_h);
#include <tdb-internal.h>
typedef struct __toku_db_btree_stat64 {
u_int64_t bt_nkeys; /* how many unique keys (guaranteed only to be an estimate, even when flattened) */
u_int64_t bt_ndata; /* how many key-value pairs (an estimate, but exact when flattened) */
......@@ -125,6 +127,7 @@ typedef enum {
#endif
struct __toku_db_env {
struct __toku_db_env_internal *i;
#define db_env_struct_i(x) ((x)->i)
int (*checkpointing_postpone) (DB_ENV*) /* Use for 'rename table' or any other operation that must be disjoint from a checkpoint */;
int (*checkpointing_resume) (DB_ENV*) /* Alert tokudb 'postpone' is no longer necessary */;
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 */;
......@@ -205,6 +208,7 @@ struct __toku_dbt {
};
struct __toku_db {
struct __toku_db_internal *i;
#define db_struct_i(x) ((x)->i)
int (*key_range64)(DB*, DB_TXN *, DBT *, u_int64_t *less, u_int64_t *equal, u_int64_t *greater, int *is_exact);
int (*stat64)(DB *, DB_TXN *, DB_BTREE_STAT64 *);
int (*pre_acquire_read_lock)(DB*, DB_TXN*, const DBT*, const DBT*, const DBT*, const DBT*);
......@@ -272,6 +276,7 @@ struct __toku_db_txn {
DB_ENV *mgrp /*In TokuDB, mgrp is a DB_ENV not a DB_TXNMGR*/; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */
DB_TXN *parent; /* 32-bit offset=4 size=4, 64=bit offset=8 size=8 */
struct __toku_db_txn_internal *i;
#define db_txn_struct_i(x) ((x)->i)
int (*txn_stat)(DB_TXN *, struct txn_stat **);
void* __toku_dummy0[15];
char __toku_dummy1[8];
......@@ -295,6 +300,7 @@ struct __toku_db_txn_stat {
struct __toku_dbc {
DB *dbp; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */
struct __toku_dbc_internal *i;
#define dbc_struct_i(x) ((x)->i)
int (*c_getf_first)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *);
int (*c_getf_last)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *);
int (*c_getf_next)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *);
......
......@@ -9,6 +9,7 @@
extern "C" {
#endif
#define TOKUDB 1
#define TOKUDB_NATIVE_H 0
#define DB_VERSION_MAJOR 4
#define DB_VERSION_MINOR 6
#define DB_VERSION_PATCH 19
......@@ -34,6 +35,7 @@ typedef u_int32_t db_recno_t;
typedef int(*YDB_CALLBACK_FUNCTION)(DBT const*, DBT const*, void*);
typedef int(*YDB_HEAVISIDE_CALLBACK_FUNCTION)(DBT const *key, DBT const *value, void *extra_f, int r_h);
typedef int(*YDB_HEAVISIDE_FUNCTION)(const DBT *key, const DBT *value, void *extra_h);
#include <tdb-internal.h>
typedef struct __toku_db_btree_stat64 {
u_int64_t bt_nkeys; /* how many unique keys (guaranteed only to be an estimate, even when flattened) */
u_int64_t bt_ndata; /* how many key-value pairs (an estimate, but exact when flattened) */
......@@ -127,6 +129,7 @@ typedef enum {
#endif
struct __toku_db_env {
struct __toku_db_env_internal *i;
#define db_env_struct_i(x) ((x)->i)
int (*checkpointing_postpone) (DB_ENV*) /* Use for 'rename table' or any other operation that must be disjoint from a checkpoint */;
int (*checkpointing_resume) (DB_ENV*) /* Alert tokudb 'postpone' is no longer necessary */;
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 */;
......@@ -208,6 +211,7 @@ struct __toku_dbt {
};
struct __toku_db {
struct __toku_db_internal *i;
#define db_struct_i(x) ((x)->i)
int (*key_range64)(DB*, DB_TXN *, DBT *, u_int64_t *less, u_int64_t *equal, u_int64_t *greater, int *is_exact);
int (*stat64)(DB *, DB_TXN *, DB_BTREE_STAT64 *);
char __toku_dummy0[8];
......@@ -276,6 +280,7 @@ struct __toku_db_txn {
DB_ENV *mgrp /*In TokuDB, mgrp is a DB_ENV not a DB_TXNMGR*/; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */
DB_TXN *parent; /* 32-bit offset=4 size=4, 64=bit offset=8 size=8 */
struct __toku_db_txn_internal *i;
#define db_txn_struct_i(x) ((x)->i)
int (*txn_stat)(DB_TXN *, struct txn_stat **);
void* __toku_dummy0[16];
char __toku_dummy1[8];
......@@ -300,6 +305,7 @@ struct __toku_db_txn_stat {
struct __toku_dbc {
DB *dbp; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */
struct __toku_dbc_internal *i;
#define dbc_struct_i(x) ((x)->i)
int (*c_getf_first)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *);
int (*c_getf_last)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *);
int (*c_getf_next)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *);
......
......@@ -192,7 +192,15 @@ void print_struct (const char *structname, int need_internal, struct fieldinfo *
unsigned int diff = diff64-diff32;
unsigned int n_dummys = diff/4;
if (need_internal && !did_toku_internal) {
printf(" struct __toku_%s_internal *i;\n", structname);
if (TDB_NATIVE &&
(strcmp(structname, "dbc")==0 ||
strcmp(structname, "db_txn")==0)) {
printf(" struct __toku_%s_internal ii;\n", structname);
printf("#define %s_struct_i(x) (&(x)->ii)\n", structname);
} else {
printf(" struct __toku_%s_internal *i;\n", structname);
printf("#define %s_struct_i(x) ((x)->i)\n", structname);
}
n_dummys--;
did_toku_internal=1;
}
......@@ -202,7 +210,9 @@ void print_struct (const char *structname, int need_internal, struct fieldinfo *
n_dummys--;
}
if (n_dummys>0) {
printf(" void* __toku_dummy%d[%d];\n", dummy_counter++, n_dummys);
if (!TDB_NATIVE)
printf(" void* __toku_dummy%d[%d];\n", dummy_counter, n_dummys);
dummy_counter++;
}
diff64-=diff*2;
diff32-=diff;
......@@ -210,7 +220,9 @@ void print_struct (const char *structname, int need_internal, struct fieldinfo *
}
assert(diff32==diff64);
if (diff32>0) {
printf(" char __toku_dummy%d[%d];\n", dummy_counter++, diff32);
if (!TDB_NATIVE)
printf(" char __toku_dummy%d[%d];\n", dummy_counter, diff32);
dummy_counter++;
}
current_32 = this_32;
current_64 = this_64;
......@@ -220,7 +232,10 @@ void print_struct (const char *structname, int need_internal, struct fieldinfo *
}
if (i+1<N) {
assert(strcmp(fields32[i].decl, fields64[i].decl)==0);
printf(" %s; /* 32-bit offset=%d size=%d, 64=bit offset=%d size=%d */\n", fields32[i].decl, fields32[i].off, fields32[i].size, fields64[i].off, fields64[i].size);
printf(" %s;", fields32[i].decl);
if (!TDB_NATIVE)
printf(" /* 32-bit offset=%d size=%d, 64=bit offset=%d size=%d */", fields32[i].off, fields32[i].size, fields64[i].off, fields64[i].size);
printf("\n");
} else {
assert(fields32[i].decl==0);
assert(fields64[i].decl==0);
......@@ -236,16 +251,22 @@ void print_struct (const char *structname, int need_internal, struct fieldinfo *
unsigned int diff64 = this_64-current_64;
if (diff32>0 && diff32<diff64) {
unsigned int diff = diff64-diff32;
printf(" void* __toku_dummy%d[%d]; /* Padding at the end */ \n", dummy_counter++, diff/4);
if (!TDB_NATIVE)
printf(" void* __toku_dummy%d[%d]; /* Padding at the end */ \n", dummy_counter, diff/4);
dummy_counter++;
diff64-=diff*2;
diff32-=diff;
}
if (diff32>0) {
printf(" char __toku_dummy%d[%d]; /* Padding at the end */ \n", dummy_counter++, diff32);
if (!TDB_NATIVE)
printf(" char __toku_dummy%d[%d]; /* Padding at the end */ \n", dummy_counter, diff32);
dummy_counter++;
diff64-=diff32;
diff32=0;
}
if (diff64>0) printf(" /* %d more bytes of alignment in the 64-bit case. */\n", diff64);
if (diff64>0)
if (!TDB_NATIVE)
printf(" /* %d more bytes of alignment in the 64-bit case. */\n", diff64);
assert(diff64<8); /* there could be a few left from alignment. */
}
printf("};\n");
......@@ -266,6 +287,7 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__un
assert(DB_VERSION_MAJOR==DB_VERSION_MAJOR_32);
assert(DB_VERSION_MINOR==DB_VERSION_MINOR_32);
printf("#define TOKUDB 1\n");
printf("#define TOKUDB_NATIVE_H %d\n", TDB_NATIVE);
dodefine(DB_VERSION_MAJOR);
dodefine(DB_VERSION_MINOR);
dodefine(DB_VERSION_PATCH);
......@@ -274,7 +296,7 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__un
printf("#else\n");
printf("#define DB_VERSION_STRING_ydb \"Tokutek: TokuDB (wrapped bdb)\"\n");
printf("#endif\n");
if (0) {
printf("#ifndef __BIT_TYPES_DEFINED__\n");
printf("/* Define some int types if not provided by the system. BIND does this, so we do it too. */\n");
......@@ -303,6 +325,8 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__un
printf("typedef int(*YDB_HEAVISIDE_CALLBACK_FUNCTION)(DBT const *key, DBT const *value, void *extra_f, int r_h);\n");
printf("typedef int(*YDB_HEAVISIDE_FUNCTION)(const DBT *key, const DBT *value, void *extra_h);\n");
printf("#include <tdb-internal.h>\n");
//stat64
printf("typedef struct __toku_db_btree_stat64 {\n");
printf(" u_int64_t bt_nkeys; /* how many unique keys (guaranteed only to be an estimate, even when flattened) */\n");
......
#ifndef _DB_H
#define _DB_H
/* This code generated by make_db_h. Copyright (c) 2007, 2008 Tokutek */
#ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved."
#include <sys/types.h>
/*stdio is needed for the FILE* in db->verify*/
#include <stdio.h>
#if defined(__cplusplus)
extern "C" {
#endif
#define TOKUDB 1
#define TOKUDB_NATIVE_H 1
#define DB_VERSION_MAJOR 4
#define DB_VERSION_MINOR 6
#define DB_VERSION_PATCH 19
#ifndef _TOKUDB_WRAP_H
#define DB_VERSION_STRING "Tokutek: TokuDB 4.6.19"
#else
#define DB_VERSION_STRING_ydb "Tokutek: TokuDB (wrapped bdb)"
#endif
#ifndef TOKU_OFF_T_DEFINED
#define TOKU_OFF_T_DEFINED
typedef int64_t toku_off_t;
#endif
typedef struct __toku_db_env DB_ENV;
typedef struct __toku_db_key_range DB_KEY_RANGE;
typedef struct __toku_db_lsn DB_LSN;
typedef struct __toku_db DB;
typedef struct __toku_db_txn DB_TXN;
typedef struct __toku_db_txn_active DB_TXN_ACTIVE;
typedef struct __toku_db_txn_stat DB_TXN_STAT;
typedef struct __toku_dbc DBC;
typedef struct __toku_dbt DBT;
typedef u_int32_t db_recno_t;
typedef int(*YDB_CALLBACK_FUNCTION)(DBT const*, DBT const*, void*);
typedef int(*YDB_HEAVISIDE_CALLBACK_FUNCTION)(DBT const *key, DBT const *value, void *extra_f, int r_h);
typedef int(*YDB_HEAVISIDE_FUNCTION)(const DBT *key, const DBT *value, void *extra_h);
#include <tdb-internal.h>
typedef struct __toku_db_btree_stat64 {
u_int64_t bt_nkeys; /* how many unique keys (guaranteed only to be an estimate, even when flattened) */
u_int64_t bt_ndata; /* how many key-value pairs (an estimate, but exact when flattened) */
u_int64_t bt_dsize; /* how big are the keys+values (not counting the lengths) (an estimate, unless flattened) */
u_int64_t bt_fsize; /* how big is the underlying file */
} DB_BTREE_STAT64;
typedef enum {
DB_BTREE=1,
DB_UNKNOWN=5
} DBTYPE;
#ifndef _TOKUDB_WRAP_H
#define DB_VERB_DEADLOCK 1
#define DB_VERB_RECOVERY 8
#define DB_VERB_REPLICATION 32
#define DB_VERB_WAITSFOR 64
#define DB_DBT_MALLOC 8
#define DB_DBT_REALLOC 64
#define DB_DBT_USERMEM 256
#define DB_DBT_DUPOK 2
#define DB_ARCH_ABS 1
#define DB_ARCH_LOG 4
#define DB_CREATE 1
#define DB_CXX_NO_EXCEPTIONS 1
#define DB_EXCL 16384
#define DB_PRIVATE 8388608
#define DB_RDONLY 32
#define DB_RECOVER 64
#define DB_THREAD 128
#define DB_TXN_NOSYNC 512
#define DB_LOCK_DEFAULT 1
#define DB_LOCK_OLDEST 7
#define DB_LOCK_RANDOM 8
#define DB_DUP 32768
#define DB_DUPSORT 65536
#define DB_KEYFIRST 13
#define DB_KEYLAST 14
#define DB_NODUPDATA 19
#define DB_NOOVERWRITE 20
#define DB_YESOVERWRITE 254
#define DB_OPFLAGS_MASK 255
#define DB_AUTO_COMMIT 33554432
#define DB_INIT_LOCK 131072
#define DB_INIT_LOG 262144
#define DB_INIT_MPOOL 524288
#define DB_INIT_TXN 2097152
#define DB_USE_ENVIRON 16384
#define DB_USE_ENVIRON_ROOT 32768
#define DB_READ_UNCOMMITTED 134217728
#define DB_KEYEXIST -30996
#define DB_LOCK_DEADLOCK -30995
#define DB_LOCK_NOTGRANTED -30994
#define DB_NOTFOUND -30989
#define DB_SECONDARY_BAD -30974
#define DB_DONOTINDEX -30998
#define DB_BUFFER_SMALL -30999
#define DB_BADFORMAT -30500
#define DB_DELETE_ANY 65536
#define DB_FIRST 7
#define DB_GET_BOTH 8
#define DB_GET_BOTH_RANGE 10
#define DB_LAST 15
#define DB_CURRENT 6
#define DB_NEXT 16
#define DB_NEXT_DUP 17
#define DB_NEXT_NODUP 18
#define DB_PREV 23
#define DB_PREV_DUP 24
#define DB_PREV_NODUP 25
#define DB_SET 26
#define DB_SET_RANGE 27
#define DB_CURRENT_BINDING 253
#define DB_RMW 1073741824
#define DB_PRELOCKED 0x00800000
#define DB_PRELOCKED_WRITE 0x00400000
#define DB_DBT_APPMALLOC 1
#define DB_DBT_MULTIPLE 16
#define DB_LOG_AUTOREMOVE 524288
#define DB_TXN_WRITE_NOSYNC 4096
#define DB_TXN_NOWAIT 1024
#define DB_TXN_SYNC 16384
#endif
/* TOKUDB specific error codes */
#define TOKUDB_OUT_OF_LOCKS -100000
#define TOKUDB_SUCCEEDED_EARLY -100001
#define TOKUDB_DICTIONARY_TOO_OLD -100004
#define TOKUDB_FOUND_BUT_REJECTED -100002
#define TOKUDB_USER_CALLBACK_ERROR -100003
/* in wrap mode, top-level function txn_begin is renamed, but the field isn't renamed, so we have to hack it here.*/
#ifdef _TOKUDB_WRAP_H
#undef txn_begin
#endif
struct __toku_db_env {
struct __toku_db_env_internal *i;
#define db_env_struct_i(x) ((x)->i)
int (*checkpointing_postpone) (DB_ENV*) /* Use for 'rename table' or any other operation that must be disjoint from a checkpoint */;
int (*checkpointing_resume) (DB_ENV*) /* Alert tokudb 'postpone' is no longer necessary */;
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 */;
int (*checkpointing_end_atomic_operation) (DB_ENV*) /* End a set of operations (that must be atomic as far as checkpoints are concerned). */;
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. */;
int (*set_default_dup_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (val) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */;
void *app_private;
void *api1_internal;
int (*close) (DB_ENV *, u_int32_t);
void (*err) (const DB_ENV *, int, const char *, ...);
int (*get_cachesize) (DB_ENV *, u_int32_t *, u_int32_t *, int *);
int (*get_flags) (DB_ENV *, u_int32_t *);
int (*get_lg_max) (DB_ENV *, u_int32_t*);
int (*get_lk_max_locks) (DB_ENV *, u_int32_t *);
int (*log_archive) (DB_ENV *, char **[], u_int32_t);
int (*log_flush) (DB_ENV *, const DB_LSN *);
int (*open) (DB_ENV *, const char *, u_int32_t, int);
int (*set_cachesize) (DB_ENV *, u_int32_t, u_int32_t, int);
int (*set_data_dir) (DB_ENV *, const char *);
void (*set_errcall) (DB_ENV *, void (*)(const DB_ENV *, const char *, const char *));
void (*set_errfile) (DB_ENV *, FILE*);
void (*set_errpfx) (DB_ENV *, const char *);
int (*set_flags) (DB_ENV *, u_int32_t, int);
int (*set_lg_bsize) (DB_ENV *, u_int32_t);
int (*set_lg_dir) (DB_ENV *, const char *);
int (*set_lg_max) (DB_ENV *, u_int32_t);
int (*set_lk_detect) (DB_ENV *, u_int32_t);
int (*set_lk_max_locks) (DB_ENV *, u_int32_t);
int (*set_tmp_dir) (DB_ENV *, const char *);
int (*set_verbose) (DB_ENV *, u_int32_t, int);
int (*txn_begin) (DB_ENV *, DB_TXN *, DB_TXN **, u_int32_t);
int (*txn_checkpoint) (DB_ENV *, u_int32_t, u_int32_t, u_int32_t);
int (*txn_stat) (DB_ENV *, DB_TXN_STAT **, u_int32_t);
};
struct __toku_db_key_range {
double less;
double equal;
double greater;
};
struct __toku_db_lsn {
};
struct __toku_dbt {
void*data;
u_int32_t size;
u_int32_t ulen;
u_int32_t flags;
};
struct __toku_db {
struct __toku_db_internal *i;
#define db_struct_i(x) ((x)->i)
int (*key_range64)(DB*, DB_TXN *, DBT *, u_int64_t *less, u_int64_t *equal, u_int64_t *greater, int *is_exact);
int (*stat64)(DB *, DB_TXN *, DB_BTREE_STAT64 *);
void *app_private;
DB_ENV *dbenv;
int (*pre_acquire_read_lock)(DB*, DB_TXN*, const DBT*, const DBT*, const DBT*, const DBT*);
int (*pre_acquire_table_lock)(DB*, DB_TXN*);
const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/;
const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/;
int (*delboth) (DB*, DB_TXN*, DBT*, DBT*, u_int32_t) /* Delete the key/value pair. */;
int (*row_size_supported) (DB*, u_int32_t) /* Test whether a row size is supported. */;
const DBT *descriptor /* saved row/dictionary descriptor for aiding in comparisons */;
int (*set_descriptor) (DB*, const DBT*) /* set row/dictionary descriptor for a db. Available only while db is open */;
void *api_internal;
int (*close) (DB*, u_int32_t);
int (*cursor) (DB *, DB_TXN *, DBC **, u_int32_t);
int (*del) (DB *, DB_TXN *, DBT *, u_int32_t);
int (*fd) (DB *, int *);
int (*get) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t);
int (*get_flags) (DB *, u_int32_t *);
int (*get_pagesize) (DB *, u_int32_t *);
int (*key_range) (DB *, DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t);
int (*open) (DB *, DB_TXN *, const char *, const char *, DBTYPE, u_int32_t, int);
int (*put) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t);
int (*remove) (DB *, const char *, const char *, u_int32_t);
int (*rename) (DB *, const char *, const char *, const char *, u_int32_t);
int (*set_bt_compare) (DB *, int (*)(DB *, const DBT *, const DBT *));
int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *));
void (*set_errfile) (DB *, FILE*);
int (*set_flags) (DB *, u_int32_t);
int (*set_pagesize) (DB *, u_int32_t);
int (*stat) (DB *, void *, u_int32_t);
int (*truncate) (DB *, DB_TXN *, u_int32_t *, u_int32_t);
int (*verify) (DB *, const char *, const char *, FILE *, u_int32_t);
};
struct __toku_db_txn_active {
u_int32_t txnid;
DB_LSN lsn;
};
struct txn_stat {
u_int64_t rolltmp_raw_count;
};
struct __toku_db_txn {
DB_ENV *mgrp /*In TokuDB, mgrp is a DB_ENV not a DB_TXNMGR*/;
DB_TXN *parent;
struct __toku_db_txn_internal ii;
#define db_txn_struct_i(x) (&(x)->ii)
int (*txn_stat)(DB_TXN *, struct txn_stat **);
void *api_internal;
int (*abort) (DB_TXN *);
int (*commit) (DB_TXN*, u_int32_t);
u_int32_t (*id) (DB_TXN *);
};
struct __toku_db_txn_stat {
u_int32_t st_nactive;
DB_TXN_ACTIVE *st_txnarray;
};
struct __toku_dbc {
DB *dbp;
struct __toku_dbc_internal ii;
#define dbc_struct_i(x) (&(x)->ii)
int (*c_getf_first)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *);
int (*c_getf_last)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *);
int (*c_getf_next)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *);
int (*c_getf_next_dup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *);
int (*c_getf_next_nodup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *);
int (*c_getf_prev)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *);
int (*c_getf_prev_dup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *);
int (*c_getf_prev_nodup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *);
int (*c_getf_current)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *);
int (*c_getf_current_binding)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *);
int (*c_getf_heaviside)(DBC *, u_int32_t, YDB_HEAVISIDE_CALLBACK_FUNCTION f, void *extra_f, YDB_HEAVISIDE_FUNCTION h, void *extra_h, int direction);
int (*c_getf_set)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *);
int (*c_getf_set_range)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *);
int (*c_getf_get_both)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *);
int (*c_getf_get_both_range)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *);
int (*c_close) (DBC *);
int (*c_count) (DBC *, db_recno_t *, u_int32_t);
int (*c_del) (DBC *, u_int32_t);
int (*c_get) (DBC *, DBT *, DBT *, u_int32_t);
};
#ifdef _TOKUDB_WRAP_H
#define txn_begin txn_begin_tokudb
#endif
int db_env_create(DB_ENV **, u_int32_t) __attribute__((__visibility__("default")));
int db_create(DB **, DB_ENV *, u_int32_t) __attribute__((__visibility__("default")));
char *db_strerror(int) __attribute__((__visibility__("default")));
const char *db_version(int*,int *,int *) __attribute__((__visibility__("default")));
int log_compare (const DB_LSN*, const DB_LSN *) __attribute__((__visibility__("default")));
int db_env_set_func_fsync (int (*)(int)) __attribute__((__visibility__("default")));
int toku_set_trace_file (char *fname) __attribute__((__visibility__("default")));
int toku_close_trace_file (void) __attribute__((__visibility__("default")));
int db_env_set_func_free (void (*)(void*)) __attribute__((__visibility__("default")));
int db_env_set_func_malloc (void *(*)(size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default")));
int db_env_set_func_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_realloc (void *(*)(void*, size_t)) __attribute__((__visibility__("default")));
#if defined(__cplusplus)
}
#endif
#endif
......@@ -9,6 +9,7 @@
extern "C" {
#endif
#define TOKUDB 1
#define TOKUDB_NATIVE_H 1
#define DB_VERSION_MAJOR 4
#define DB_VERSION_MINOR 6
#define DB_VERSION_PATCH 19
......@@ -34,6 +35,7 @@ typedef u_int32_t db_recno_t;
typedef int(*YDB_CALLBACK_FUNCTION)(DBT const*, DBT const*, void*);
typedef int(*YDB_HEAVISIDE_CALLBACK_FUNCTION)(DBT const *key, DBT const *value, void *extra_f, int r_h);
typedef int(*YDB_HEAVISIDE_FUNCTION)(const DBT *key, const DBT *value, void *extra_h);
#include <tdb-internal.h>
typedef struct __toku_db_btree_stat64 {
u_int64_t bt_nkeys; /* how many unique keys (guaranteed only to be an estimate, even when flattened) */
u_int64_t bt_ndata; /* how many key-value pairs (an estimate, but exact when flattened) */
......@@ -127,92 +129,61 @@ typedef enum {
#endif
struct __toku_db_env {
struct __toku_db_env_internal *i;
#define db_env_struct_i(x) ((x)->i)
int (*checkpointing_postpone) (DB_ENV*) /* Use for 'rename table' or any other operation that must be disjoint from a checkpoint */;
int (*checkpointing_resume) (DB_ENV*) /* Alert tokudb 'postpone' is no longer necessary */;
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 */;
int (*checkpointing_end_atomic_operation) (DB_ENV*) /* End a set of operations (that must be atomic as far as checkpoints are concerned). */;
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. */;
int (*set_default_dup_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (val) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */;
void* __toku_dummy0[6];
void *app_private; /* 32-bit offset=52 size=4, 64=bit offset=104 size=8 */
void* __toku_dummy1[39];
char __toku_dummy2[144];
void *api1_internal; /* 32-bit offset=356 size=4, 64=bit offset=568 size=8 */
void* __toku_dummy3[8];
int (*close) (DB_ENV *, u_int32_t); /* 32-bit offset=392 size=4, 64=bit offset=640 size=8 */
void* __toku_dummy4[2];
void (*err) (const DB_ENV *, int, const char *, ...); /* 32-bit offset=404 size=4, 64=bit offset=664 size=8 */
void* __toku_dummy5[3];
int (*get_cachesize) (DB_ENV *, u_int32_t *, u_int32_t *, int *); /* 32-bit offset=420 size=4, 64=bit offset=696 size=8 */
void* __toku_dummy6[5];
int (*get_flags) (DB_ENV *, u_int32_t *); /* 32-bit offset=444 size=4, 64=bit offset=744 size=8 */
void* __toku_dummy7[4];
int (*get_lg_max) (DB_ENV *, u_int32_t*); /* 32-bit offset=464 size=4, 64=bit offset=784 size=8 */
void* __toku_dummy8[4];
int (*get_lk_max_locks) (DB_ENV *, u_int32_t *); /* 32-bit offset=484 size=4, 64=bit offset=824 size=8 */
void* __toku_dummy9[22];
int (*log_archive) (DB_ENV *, char **[], u_int32_t); /* 32-bit offset=576 size=4, 64=bit offset=1008 size=8 */
void* __toku_dummy10[2];
int (*log_flush) (DB_ENV *, const DB_LSN *); /* 32-bit offset=588 size=4, 64=bit offset=1032 size=8 */
void* __toku_dummy11[25];
int (*open) (DB_ENV *, const char *, u_int32_t, int); /* 32-bit offset=692 size=4, 64=bit offset=1240 size=8 */
void* __toku_dummy12[30];
int (*set_cachesize) (DB_ENV *, u_int32_t, u_int32_t, int); /* 32-bit offset=816 size=4, 64=bit offset=1488 size=8 */
void* __toku_dummy13[1];
int (*set_data_dir) (DB_ENV *, const char *); /* 32-bit offset=824 size=4, 64=bit offset=1504 size=8 */
void* __toku_dummy14[1];
void (*set_errcall) (DB_ENV *, void (*)(const DB_ENV *, const char *, const char *)); /* 32-bit offset=832 size=4, 64=bit offset=1520 size=8 */
void (*set_errfile) (DB_ENV *, FILE*); /* 32-bit offset=836 size=4, 64=bit offset=1528 size=8 */
void (*set_errpfx) (DB_ENV *, const char *); /* 32-bit offset=840 size=4, 64=bit offset=1536 size=8 */
void* __toku_dummy15[2];
int (*set_flags) (DB_ENV *, u_int32_t, int); /* 32-bit offset=852 size=4, 64=bit offset=1560 size=8 */
void* __toku_dummy16[2];
int (*set_lg_bsize) (DB_ENV *, u_int32_t); /* 32-bit offset=864 size=4, 64=bit offset=1584 size=8 */
int (*set_lg_dir) (DB_ENV *, const char *); /* 32-bit offset=868 size=4, 64=bit offset=1592 size=8 */
void* __toku_dummy17[1];
int (*set_lg_max) (DB_ENV *, u_int32_t); /* 32-bit offset=876 size=4, 64=bit offset=1608 size=8 */
void* __toku_dummy18[2];
int (*set_lk_detect) (DB_ENV *, u_int32_t); /* 32-bit offset=888 size=4, 64=bit offset=1632 size=8 */
void* __toku_dummy19[1];
int (*set_lk_max_locks) (DB_ENV *, u_int32_t); /* 32-bit offset=896 size=4, 64=bit offset=1648 size=8 */
void* __toku_dummy20[14];
int (*set_tmp_dir) (DB_ENV *, const char *); /* 32-bit offset=956 size=4, 64=bit offset=1768 size=8 */
void* __toku_dummy21[2];
int (*set_verbose) (DB_ENV *, u_int32_t, int); /* 32-bit offset=968 size=4, 64=bit offset=1792 size=8 */
void* __toku_dummy22[1];
int (*txn_begin) (DB_ENV *, DB_TXN *, DB_TXN **, u_int32_t); /* 32-bit offset=976 size=4, 64=bit offset=1808 size=8 */
int (*txn_checkpoint) (DB_ENV *, u_int32_t, u_int32_t, u_int32_t); /* 32-bit offset=980 size=4, 64=bit offset=1816 size=8 */
void* __toku_dummy23[1];
int (*txn_stat) (DB_ENV *, DB_TXN_STAT **, u_int32_t); /* 32-bit offset=988 size=4, 64=bit offset=1832 size=8 */
void* __toku_dummy24[2]; /* Padding at the end */
char __toku_dummy25[16]; /* Padding at the end */
void *app_private;
void *api1_internal;
int (*close) (DB_ENV *, u_int32_t);
void (*err) (const DB_ENV *, int, const char *, ...);
int (*get_cachesize) (DB_ENV *, u_int32_t *, u_int32_t *, int *);
int (*get_flags) (DB_ENV *, u_int32_t *);
int (*get_lg_max) (DB_ENV *, u_int32_t*);
int (*get_lk_max_locks) (DB_ENV *, u_int32_t *);
int (*log_archive) (DB_ENV *, char **[], u_int32_t);
int (*log_flush) (DB_ENV *, const DB_LSN *);
int (*open) (DB_ENV *, const char *, u_int32_t, int);
int (*set_cachesize) (DB_ENV *, u_int32_t, u_int32_t, int);
int (*set_data_dir) (DB_ENV *, const char *);
void (*set_errcall) (DB_ENV *, void (*)(const DB_ENV *, const char *, const char *));
void (*set_errfile) (DB_ENV *, FILE*);
void (*set_errpfx) (DB_ENV *, const char *);
int (*set_flags) (DB_ENV *, u_int32_t, int);
int (*set_lg_bsize) (DB_ENV *, u_int32_t);
int (*set_lg_dir) (DB_ENV *, const char *);
int (*set_lg_max) (DB_ENV *, u_int32_t);
int (*set_lk_detect) (DB_ENV *, u_int32_t);
int (*set_lk_max_locks) (DB_ENV *, u_int32_t);
int (*set_tmp_dir) (DB_ENV *, const char *);
int (*set_verbose) (DB_ENV *, u_int32_t, int);
int (*txn_begin) (DB_ENV *, DB_TXN *, DB_TXN **, u_int32_t);
int (*txn_checkpoint) (DB_ENV *, u_int32_t, u_int32_t, u_int32_t);
int (*txn_stat) (DB_ENV *, DB_TXN_STAT **, u_int32_t);
};
struct __toku_db_key_range {
double less; /* 32-bit offset=0 size=8, 64=bit offset=0 size=8 */
double equal; /* 32-bit offset=8 size=8, 64=bit offset=8 size=8 */
double greater; /* 32-bit offset=16 size=8, 64=bit offset=16 size=8 */
void* __toku_dummy0[214]; /* Padding at the end */
char __toku_dummy1[136]; /* Padding at the end */
double less;
double equal;
double greater;
};
struct __toku_db_lsn {
char __toku_dummy0[8]; /* Padding at the end */
};
struct __toku_dbt {
void*data; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */
u_int32_t size; /* 32-bit offset=4 size=4, 64=bit offset=8 size=4 */
u_int32_t ulen; /* 32-bit offset=8 size=4, 64=bit offset=12 size=4 */
void* __toku_dummy0[1];
char __toku_dummy1[8];
u_int32_t flags; /* 32-bit offset=24 size=4, 64=bit offset=32 size=4 */
/* 4 more bytes of alignment in the 64-bit case. */
void*data;
u_int32_t size;
u_int32_t ulen;
u_int32_t flags;
};
struct __toku_db {
struct __toku_db_internal *i;
#define db_struct_i(x) ((x)->i)
int (*key_range64)(DB*, DB_TXN *, DBT *, u_int64_t *less, u_int64_t *equal, u_int64_t *greater, int *is_exact);
int (*stat64)(DB *, DB_TXN *, DB_BTREE_STAT64 *);
char __toku_dummy0[8];
void *app_private; /* 32-bit offset=20 size=4, 64=bit offset=32 size=8 */
DB_ENV *dbenv; /* 32-bit offset=24 size=4, 64=bit offset=40 size=8 */
void *app_private;
DB_ENV *dbenv;
int (*pre_acquire_read_lock)(DB*, DB_TXN*, const DBT*, const DBT*, const DBT*, const DBT*);
int (*pre_acquire_table_lock)(DB*, DB_TXN*);
const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/;
......@@ -221,85 +192,54 @@ struct __toku_db {
int (*row_size_supported) (DB*, u_int32_t) /* Test whether a row size is supported. */;
const DBT *descriptor /* saved row/dictionary descriptor for aiding in comparisons */;
int (*set_descriptor) (DB*, const DBT*) /* set row/dictionary descriptor for a db. Available only while db is open */;
void* __toku_dummy1[34];
char __toku_dummy2[80];
void *api_internal; /* 32-bit offset=276 size=4, 64=bit offset=464 size=8 */
void* __toku_dummy3[5];
int (*close) (DB*, u_int32_t); /* 32-bit offset=300 size=4, 64=bit offset=512 size=8 */
void* __toku_dummy4[1];
int (*cursor) (DB *, DB_TXN *, DBC **, u_int32_t); /* 32-bit offset=308 size=4, 64=bit offset=528 size=8 */
int (*del) (DB *, DB_TXN *, DBT *, u_int32_t); /* 32-bit offset=312 size=4, 64=bit offset=536 size=8 */
void* __toku_dummy5[3];
int (*fd) (DB *, int *); /* 32-bit offset=328 size=4, 64=bit offset=568 size=8 */
int (*get) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t); /* 32-bit offset=332 size=4, 64=bit offset=576 size=8 */
void* __toku_dummy6[8];
int (*get_flags) (DB *, u_int32_t *); /* 32-bit offset=368 size=4, 64=bit offset=648 size=8 */
void* __toku_dummy7[7];
int (*get_pagesize) (DB *, u_int32_t *); /* 32-bit offset=400 size=4, 64=bit offset=712 size=8 */
void* __toku_dummy8[9];
int (*key_range) (DB *, DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t); /* 32-bit offset=440 size=4, 64=bit offset=792 size=8 */
int (*open) (DB *, DB_TXN *, const char *, const char *, DBTYPE, u_int32_t, int); /* 32-bit offset=444 size=4, 64=bit offset=800 size=8 */
void* __toku_dummy9[1];
int (*put) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t); /* 32-bit offset=452 size=4, 64=bit offset=816 size=8 */
int (*remove) (DB *, const char *, const char *, u_int32_t); /* 32-bit offset=456 size=4, 64=bit offset=824 size=8 */
int (*rename) (DB *, const char *, const char *, const char *, u_int32_t); /* 32-bit offset=460 size=4, 64=bit offset=832 size=8 */
void* __toku_dummy10[2];
int (*set_bt_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); /* 32-bit offset=472 size=4, 64=bit offset=856 size=8 */
void* __toku_dummy11[3];
int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); /* 32-bit offset=488 size=4, 64=bit offset=888 size=8 */
void* __toku_dummy12[2];
void (*set_errfile) (DB *, FILE*); /* 32-bit offset=500 size=4, 64=bit offset=912 size=8 */
void* __toku_dummy13[2];
int (*set_flags) (DB *, u_int32_t); /* 32-bit offset=512 size=4, 64=bit offset=936 size=8 */
void* __toku_dummy14[7];
int (*set_pagesize) (DB *, u_int32_t); /* 32-bit offset=544 size=4, 64=bit offset=1000 size=8 */
void* __toku_dummy15[7];
int (*stat) (DB *, void *, u_int32_t); /* 32-bit offset=576 size=4, 64=bit offset=1064 size=8 */
void* __toku_dummy16[2];
int (*truncate) (DB *, DB_TXN *, u_int32_t *, u_int32_t); /* 32-bit offset=588 size=4, 64=bit offset=1088 size=8 */
void* __toku_dummy17[1];
int (*verify) (DB *, const char *, const char *, FILE *, u_int32_t); /* 32-bit offset=596 size=4, 64=bit offset=1104 size=8 */
void* __toku_dummy18[5]; /* Padding at the end */
char __toku_dummy19[16]; /* Padding at the end */
void *api_internal;
int (*close) (DB*, u_int32_t);
int (*cursor) (DB *, DB_TXN *, DBC **, u_int32_t);
int (*del) (DB *, DB_TXN *, DBT *, u_int32_t);
int (*fd) (DB *, int *);
int (*get) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t);
int (*get_flags) (DB *, u_int32_t *);
int (*get_pagesize) (DB *, u_int32_t *);
int (*key_range) (DB *, DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t);
int (*open) (DB *, DB_TXN *, const char *, const char *, DBTYPE, u_int32_t, int);
int (*put) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t);
int (*remove) (DB *, const char *, const char *, u_int32_t);
int (*rename) (DB *, const char *, const char *, const char *, u_int32_t);
int (*set_bt_compare) (DB *, int (*)(DB *, const DBT *, const DBT *));
int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *));
void (*set_errfile) (DB *, FILE*);
int (*set_flags) (DB *, u_int32_t);
int (*set_pagesize) (DB *, u_int32_t);
int (*stat) (DB *, void *, u_int32_t);
int (*truncate) (DB *, DB_TXN *, u_int32_t *, u_int32_t);
int (*verify) (DB *, const char *, const char *, FILE *, u_int32_t);
};
struct __toku_db_txn_active {
u_int32_t txnid; /* 32-bit offset=0 size=4, 64=bit offset=0 size=4 */
void* __toku_dummy0[2];
char __toku_dummy1[4];
DB_LSN lsn; /* 32-bit offset=16 size=8, 64=bit offset=24 size=8 */
char __toku_dummy2[200]; /* Padding at the end */
u_int32_t txnid;
DB_LSN lsn;
};
struct txn_stat {
u_int64_t rolltmp_raw_count;
};
struct __toku_db_txn {
DB_ENV *mgrp /*In TokuDB, mgrp is a DB_ENV not a DB_TXNMGR*/; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */
DB_TXN *parent; /* 32-bit offset=4 size=4, 64=bit offset=8 size=8 */
struct __toku_db_txn_internal *i;
DB_ENV *mgrp /*In TokuDB, mgrp is a DB_ENV not a DB_TXNMGR*/;
DB_TXN *parent;
struct __toku_db_txn_internal ii;
#define db_txn_struct_i(x) (&(x)->ii)
int (*txn_stat)(DB_TXN *, struct txn_stat **);
void* __toku_dummy0[16];
char __toku_dummy1[8];
void *api_internal; /* 32-bit offset=88 size=4, 64=bit offset=168 size=8 */
void* __toku_dummy2[2];
int (*abort) (DB_TXN *); /* 32-bit offset=100 size=4, 64=bit offset=192 size=8 */
int (*commit) (DB_TXN*, u_int32_t); /* 32-bit offset=104 size=4, 64=bit offset=200 size=8 */
void* __toku_dummy3[2];
u_int32_t (*id) (DB_TXN *); /* 32-bit offset=116 size=4, 64=bit offset=224 size=8 */
void* __toku_dummy4[5]; /* Padding at the end */
void *api_internal;
int (*abort) (DB_TXN *);
int (*commit) (DB_TXN*, u_int32_t);
u_int32_t (*id) (DB_TXN *);
};
struct __toku_db_txn_stat {
void* __toku_dummy0[2];
char __toku_dummy1[28];
u_int32_t st_nactive; /* 32-bit offset=36 size=4, 64=bit offset=44 size=4 */
void* __toku_dummy2[1];
char __toku_dummy3[8];
DB_TXN_ACTIVE *st_txnarray; /* 32-bit offset=52 size=4, 64=bit offset=64 size=8 */
void* __toku_dummy4[1]; /* Padding at the end */
char __toku_dummy5[8]; /* Padding at the end */
u_int32_t st_nactive;
DB_TXN_ACTIVE *st_txnarray;
};
struct __toku_dbc {
DB *dbp; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */
struct __toku_dbc_internal *i;
DB *dbp;
struct __toku_dbc_internal ii;
#define dbc_struct_i(x) (&(x)->ii)
int (*c_getf_first)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *);
int (*c_getf_last)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *);
int (*c_getf_next)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *);
......@@ -315,14 +255,10 @@ struct __toku_dbc {
int (*c_getf_set_range)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *);
int (*c_getf_get_both)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *);
int (*c_getf_get_both_range)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *);
void* __toku_dummy0[18];
char __toku_dummy1[104];
int (*c_close) (DBC *); /* 32-bit offset=244 size=4, 64=bit offset=384 size=8 */
int (*c_count) (DBC *, db_recno_t *, u_int32_t); /* 32-bit offset=248 size=4, 64=bit offset=392 size=8 */
int (*c_del) (DBC *, u_int32_t); /* 32-bit offset=252 size=4, 64=bit offset=400 size=8 */
void* __toku_dummy2[1];
int (*c_get) (DBC *, DBT *, DBT *, u_int32_t); /* 32-bit offset=260 size=4, 64=bit offset=416 size=8 */
void* __toku_dummy3[10]; /* Padding at the end */
int (*c_close) (DBC *);
int (*c_count) (DBC *, db_recno_t *, u_int32_t);
int (*c_del) (DBC *, u_int32_t);
int (*c_get) (DBC *, DBT *, DBT *, u_int32_t);
};
#ifdef _TOKUDB_WRAP_H
#define txn_begin txn_begin_tokudb
......
#ifndef _TDB_INTERNAL_H
#define _TDB_INTERNAL_H
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
// Included by db.h, defines some internal structures. These structures are inlined in some versions of db.h
// the types DB_TXN and so forth have been defined.
struct simple_dbt {
u_int32_t len;
void *data;
};
struct __toku_db_txn_internal {
//TXNID txnid64; /* A sixty-four bit txn id. */
struct tokutxn *tokutxn;
struct __toku_lth *lth;
u_int32_t flags;
DB_TXN *child, *next, *prev;
};
struct __toku_dbc_internal {
struct brt_cursor *c;
DB_TXN *txn;
struct simple_dbt skey_s,sval_s;
struct simple_dbt *skey,*sval;
};
// end of _TDB_INTERNAL_H:
#endif
......@@ -2,7 +2,7 @@
.DEFAULT_GOAL= build
TOKUROOT=../
INCLUDEDIRS=-I.
INCLUDEDIRS=-I. -I../include
COMBINE=1
#TODO: Replace DEPEND_COMPILE with auto-dependancy generation.
DEPEND_COMPILE += \
......
......@@ -7,7 +7,7 @@
#define _FILE_OFFSET_BITS 64
#include "brttypes.h"
#include "ybt.h"
#include "../include/db.h"
#include <db.h>
#include "cachetable.h"
#include "log.h"
#include "brt-search.h"
......
......@@ -9,7 +9,7 @@
#endif
#define _FILE_OFFSET_BITS 64
#include "../include/db.h"
#include <db.h>
#include <inttypes.h>
typedef struct brt *BRT;
......@@ -115,9 +115,4 @@ build_brt_cmd (enum brt_cmd_type type, TXNID xid, DBT *key, DBT *val) {
typedef struct leafentry *LEAFENTRY;
struct simple_dbt {
u_int32_t len;
void *data;
};
#endif
.DEFAULT_GOAL=build
TOKUROOT=../../
INCLUDEDIRS=-I. -I..
INCLUDEDIRS=-I. -I.. -I../../include
ifeq ($(CYGWIN),)
LINK_FILES += $(NEWBRT)
......
......@@ -5,7 +5,7 @@
// brttypes.h must be first to make 64-bit file mode work right in linux.
#include "brttypes.h"
#include "../include/db.h"
#include <db.h>
DBT* toku_init_dbt (DBT *);
......
......@@ -2,7 +2,7 @@
.DEFAULT_GOAL=build
TOKUROOT=../
INCLUDEDIRS=-I$(TOKUROOT)newbrt -I./lock_tree -I./range_tree
INCLUDEDIRS=-I$(TOKUROOT)newbrt -I../include -I./lock_tree -I./range_tree
DEPEND_COMPILE += \
ydb-internal.h \
$(TOKUROOT)include/db.h \
......@@ -10,7 +10,6 @@ DEPEND_COMPILE += \
$(TOKUROOT)newbrt/brt.h \
$(TOKUROOT)newbrt/log.c \
#End of line
ydbtrace.o tdbtrace.o: tdbtrace.h
include $(TOKUROOT)toku_include/Makefile.include
CPPFLAGS+=-D_GNU_SOURCE -D_THREAD_SAFE
......@@ -27,12 +26,9 @@ IPO_YDB = ipo_libtokudb.$(AEXT)
NOIPO_YDB = static_libtokudb.$(AEXT)
LIBNAME=libtokudb
TLIBNAME=libtokudbtrace
LIBRARY=$(LIBNAME).$(SOEXT)
TLIBRARY=$(TLIBNAME).$(SOEXT)
LIBRARY_S=$(LIBNAME).$(AEXT)
TLIBRARY_S=$(TLIBNAME).$(AEXT)
OBJS_RAW = \
ydb_lib \
ydb \
......@@ -44,9 +40,7 @@ OBJS_RAW = \
LIBRARIES= \
$(LIBRARY) \
$(TLIBRARY) \
$(LIBRARY_S) \
$(TLIBRARY_S) \
#Purposely here for \ at end of prev
INSTALL_LIBRARIES= $(patsubst %,%.install,$(LIBRARIES))
......@@ -61,10 +55,6 @@ local: buildlocktrees libs install_libs ;
build_tests: | local
cd tests && $(MAKE) build
TOBJS= tdbtrace.$(OEXT) $(patsubst ydb.$(OEXT),ydbtrace.$(OEXT),$(OBJS))
install_libs: $(INSTALL_LIBRARIES)
%.install: %
if ! diff $* ../lib/$* > /dev/null 2>&1; then cp $* ../lib/; fi
......@@ -82,27 +72,19 @@ export.def: export.map
buildlocktrees: $(LOCKTREE) $(RANGETREE) ;
$(OBJS) $(TOBJS): CPPFLAGS+=-I$(TOKUROOT)include
$(YDB): $(OBJS)
$(TYDB): $(TOBJS)
$(LIBRARY): $(YDB) $(LOCKTREE) $(RANGETREE) $(NEWBRT) $(DEPEND_COMPILE) $(DEPEND_LINK)
$(TLIBRARY): $(TYDB) $(LOCKTREE) $(RANGETREE) $(NEWBRT) $(DEPEND_COMPILE) $(DEPEND_LINK)
$(LIBRARY): LINK_FILES=ydb_lib.$(OEXT) $(YDB) $(LOCKTREE) $(RANGETREE) $(NEWBRT)
$(TLIBRARY): LINK_FILES=$(TYDB) $(LOCKTREE) $(RANGETREE) $(NEWBRT)
#Skip all BDB tests for CYGWIN+ICC
ifeq ($(CYGWIN),)
$(LIBRARY_S): $(patsubst %.$(AEXT),%.bundle, $(YDB) $(LOCKTREE) $(RANGETREE) $(NEWBRT) $(LIBPORTABILITY))
$(TLIBRARY_S): $(TYDB) $(LOCKTREE) $(RANGETREE) $(NEWBRT_BUNDLE) $(LIBPORTABILITY)
else ifneq ($(CC),icc)
$(LIBRARY_S): $(YDB) $(LOCKTREE) $(RANGETREE) $(NEWBRT) $(LIBPORTABILITY)
$(TLIBRARY_S): $(TYDB) $(LOCKTREE) $(RANGETREE) $(NEWBRT) $(LIBPORTABILITY)
else
$(LIBRARY_S): $(LIBRARY) ;
$(TLIBRARY_S): $(TLIBRARY) ;
#$(LIBRARY_S): $(YDB) $(LOCKTREE) $(RANGETREE) $(NEWBRT) $(LIBPORTABILITY)
#$(TLIBRARY_S): $(TYDB) $(LOCKTREE) $(RANGETREE) $(NEWBRT) $(LIBPORTABILITY)
endif
......@@ -136,8 +118,3 @@ clean:
cd tests && $(MAKE) clean
cd lock_tree && $(MAKE) clean
cd range_tree && $(MAKE) clean
ydbtrace.$(OEXT): CPPFLAGS+=-DTOKUTRACE
ydbtrace.$(OEXT): ydb.c $(DEPEND_COMPILE)
$(CC) -c $< $(CPPFLAGS) $(CFLAGS) $(OOUTPUT)$@
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved."
/* Provide an TokuDB API that performs tracing.
* This is a thin layer on top of ydb.c.
* Simply trace it and then call the ydb code.
* The trace file ends up in the cwd.
*/
#include "toku_portability.h"
#include "../include/db.h"
#include "toku_assert.h"
#include "memory.h"
#include "tdbtrace.h"
#include "ydb-internal.h"
#include <errno.h>
#include <toku_pthread.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
static toku_pthread_mutex_t tdb_big_lock = TOKU_PTHREAD_MUTEX_INITIALIZER;
static void tlock(void) {
int r = toku_pthread_mutex_lock(&tdb_big_lock); assert(r == 0);
}
static void tunlock(void) {
int r = toku_pthread_mutex_unlock(&tdb_big_lock); assert(r == 0);
}
static FILE *tracefile = 0;
enum tracetype { TT_ENV, TT_DB, TT_TXN, TT_DBC};
static struct tracepair {
int itemnum;
enum tracetype tt;
void *item;
struct tracepair *next;
} *tracepairs=0;
static int itemnum_counter=1;
static void find_ttpairp (void *item, struct tracepair ***ptr) {
*ptr = &tracepairs;
while (**ptr) {
if ((**ptr)->item==item) return;
*ptr = &(**ptr)->next;
}
}
static struct tracepair *create_tracepair (void *item, enum tracetype tt) {
struct tracepair *MALLOC(pair);
assert(pair);
pair->itemnum = itemnum_counter++;
pair->tt = tt;
pair->item = item;
pair->next = tracepairs;
tracepairs = pair;
return pair;
}
static struct tracepair * find_envpair (DB_ENV *e, int *itemnum) {
if (e==0) {
*itemnum=0;
return 0;
} else {
struct tracepair **pp;
find_ttpairp (e, &pp);
if (*pp==0) {
*itemnum = 0;
return 0;
} else {
struct tracepair *p=*pp;
assert(p->tt==TT_ENV);
*itemnum = p->itemnum;
return p;
}
}
}
static int pairnum (void *item, enum tracetype tt) {
struct tracepair **pp;
find_ttpairp(item, &pp);
if (*pp==0){
return 0;
} else {
assert ((*pp)->tt==tt);
return (*pp)->itemnum;
}
}
static int dbpairnum (DB *db) {
return pairnum(db, TT_DB);
}
static int txnpairnum (DB_TXN *txn) {
return pairnum(txn, TT_TXN);
}
static int dbcpairnum (DBC *dbc) {
return pairnum(dbc, TT_DBC);
}
int toku_set_trace_file (char *fname) {
tracefile = fopen(fname, "w");
assert(tracefile);
printf("Tracing to %s (file=%p)\n", fname, tracefile);
return 0;
}
int toku_close_trace_file (void) {
int r=0;
if (fclose(tracefile)!=0) { r=errno; }
tracefile=0;
return r;
}
static int tokutrace_env_close (DB_ENV *env, u_int32_t flags) {
tlock();
DB_ENV *e = (DB_ENV*)env->i;
int r = e->close(e, flags);
memset(env, 0, sizeof(*e));
struct tracepair **ptr;
find_ttpairp(env, &ptr);
if (*ptr) {
assert((*ptr)->tt==TT_ENV);
if (tracefile) {
fprintf(tracefile, "env_close %d %d %u\n", r, (*ptr)->itemnum, flags);
}
struct tracepair *hold=*ptr;
*ptr=(*ptr)->next;
toku_free(hold);
}
toku_free(env);
tunlock();
return r;
}
static void tokutrace_env_err(const DB_ENV * env, int error, const char *fmt, ...) __attribute__((format (printf, 3, 0)));
static void tokutrace_env_err(const DB_ENV * env, int error, const char *fmt, ...) {
// Don't need to trace the err call.
tlock();
va_list ap;
va_start(ap, fmt);
toku_ydb_error_all_cases(env, error, FALSE, TRUE, fmt, ap); // call it directly
va_end(ap);
tunlock();
}
static int tokutrace_env_get_cachesize (DB_ENV *env, u_int32_t *gbytes, u_int32_t *bytes, int *ncache) {
tlock();
DB_ENV *e = (DB_ENV*)env->i;
int r = e->get_cachesize(e, gbytes, bytes, ncache);
if (tracefile) {
int itemnum;
struct tracepair *ep = find_envpair(env, &itemnum);
if (env==0 || ep) {
if (r==0) {
fprintf(tracefile, "env_get_cachesize %d %d %u %u %d\n", r, itemnum, *gbytes, *bytes, *ncache);
} else {
fprintf(tracefile, "env_get_cachesize %d %d %d %d %d\n", r, itemnum, -1, -1, -1);
}
}
}
tunlock();
return r;
}
static void tokutrace_env_set_errfile(DB_ENV*env, FILE*errfile) {
// Don't need to trace the set_errfile
tlock();
DB_ENV *e = (DB_ENV*)env->i;
e->set_errfile(e, errfile);
tunlock();
}
static int tokutrace_env_open (DB_ENV *env, const char *home, u_int32_t flags, int mode) {
tlock();
DB_ENV *e = (DB_ENV*)env->i;
int r = e->open(e, home, flags, mode);
if (tracefile) {
int itemnum;
find_envpair(env, &itemnum);
fprintf(tracefile, "env_open %d %d %s %u %d\n", r, itemnum, home, flags, mode);
}
tunlock();
return r;
}
int db_env_create(DB_ENV ** envp, u_int32_t flags) {
tlock();
DB_ENV *MALLOC(result);
int r;
if (result==0) { r = errno; tunlock(); return r; }
memset(result, 0, sizeof(*result));
DB_ENV *native_env;
r = db_env_create_toku10(&native_env, flags);
if (r != 0) { toku_free(result); tunlock(); return r; }
result->i = (void*)native_env;
#define SE(name) result->name = tokutrace_env_ ## name;
SE(close);
result->err = (void (*)(const DB_ENV *, int, const char *, ...)) tokutrace_env_err;
SE(get_cachesize);
//SE(get_flags);
//SE(get_lk_max_locks);
//SE(log_archive);
//SE(log_flush);
SE(open);
//SE(set_cachesize);
//SE(set_data_dir);
//SE(set_errcall);
SE(set_errfile);
//SE(set_errpfx);
//SE(set_flags);
//SE(set_lg_bsize);
//SE(set_lg_dir);
//SE(set_lg_max);
//SE(set_lk_detect);
//SE(set_lk_max);
//SE(set_lk_max_locks);
//SE(set_tmp_dir);
//SE(set_verbose);
//SE(txn_begin);
//SE(txn_checkpoint);
//SE(txn_stat);
#undef SE
*envp = result;
if (tracefile) {
struct tracepair *pair = create_tracepair(result, TT_ENV);
fprintf(tracefile, "db_env_create %d %d %u\n", 0, pair->itemnum, flags);
}
tunlock();
return 0;
}
static int tokutrace_db_set_flags(DB *db, u_int32_t flags) {
tlock();
DB *d = (DB*)db->i;
int r = d->set_flags(d, flags);
if (tracefile) {
fprintf(tracefile, "db_set_flags %d %d %u\n", r, dbpairnum(db), flags);
}
tunlock();
return r;
}
static int tokutrace_db_set_pagesize(DB *db, u_int32_t pagesize) {
tlock();
DB *d = (DB*)db->i;
int r = d->set_pagesize(d, pagesize);
if (tracefile) {
fprintf(tracefile, "db_set_pagesize %d %d %u\n", r, dbpairnum(db), pagesize);
}
tunlock();
return r;
}
static int tokutrace_db_open(DB * db, DB_TXN * txn, const char *fname, const char *dbname, DBTYPE dbtype, u_int32_t flags, int mode) {
tlock();
DB *d = (DB*)db->i;
int r = d->open(d, txn ? (DB_TXN*)txn->i : 0, fname, dbname, dbtype, flags, mode);
if (tracefile) {
fprintf(tracefile, "db_open %d %d %d %s %s %d %u %d\n",
r,
dbpairnum(db), txnpairnum(txn), fname, dbname, (int)dbtype, flags, mode);
}
tunlock();
return r;
}
static int tokutrace_db_close (DB *db, u_int32_t flags) {
tlock();
DB *d = (DB*)db->i;
int r = d->close(d, flags);
if (tracefile) fprintf(tracefile, "db_close %d %d %u\n", r, dbpairnum(db), flags);
tunlock();
return r;
}
static void trace_char (unsigned char ch) {
if (isprint(ch) && ch!=' ' && !isxdigit(ch)) {
fprintf(tracefile, "%c", ch);
} else {
fprintf(tracefile, "%02x", ch);
}
}
static void trace_dbt (DBT *v) {
fprintf(tracefile,"{%u ", v->size);
unsigned int i;
for (i=0; i<v->size; i++) trace_char(((unsigned char*)v->data)[i]);
fprintf(tracefile," }");
}
static int tokutrace_db_put(DB * db, DB_TXN * txn, DBT * key, DBT * data, u_int32_t flags) {
tlock();
int remainingflags = flags;
int UU(yes_overwrite) = remainingflags & DB_YESOVERWRITE;
remainingflags &= ~DB_YESOVERWRITE;
assert(remainingflags==0); // if flags are nonzero we'll need to do something more carefully.
DB *d = (DB*)db->i;
int r = d->put(d, txn ? (DB_TXN*)txn->i : 0, key, data, flags);
if (tracefile) {
fprintf(tracefile, "db_put %d %d %d ",
r,
dbpairnum(db), txnpairnum(txn));
trace_dbt(key);
fprintf(tracefile, " ");
trace_dbt(data);
fprintf(tracefile, " %u\n", flags);
}
tunlock();
return r;
}
static int tokutrace_db_get (DB * db, DB_TXN * txn, DBT * key, DBT * data, u_int32_t flags) {
tlock();
assert(flags==0); // if flags are nonzero we'll need to do something more carefully.
DB *d = (DB*)db->i;
int r = d->get(d, txn ? (DB_TXN*)txn->i : 0, key, data, flags);
if (tracefile) {
fprintf(tracefile, "db_get %d %d %d ",
r,
dbpairnum(db), txnpairnum(txn));
trace_dbt(key);
fprintf(tracefile, " ");
trace_dbt(data);
fprintf(tracefile, " %u\n", flags);
}
tunlock();
return r;
}
static int tokutrace_dbc_c_get(DBC * c, DBT * key, DBT * data, u_int32_t flag) {
tlock();
DBC *native_cursor = (DBC*)c->i;
int r;
switch (flag) {
case DB_NEXT:
r = native_cursor->c_get(native_cursor, key,data, flag);
if (tracefile) {
fprintf(tracefile, "dbc_cget %d %d ", r, dbcpairnum(c));
trace_dbt(key);
fprintf(tracefile, " ");
trace_dbt(data);
fprintf(tracefile, " %u\n", flag);
}
break;
default:
abort();
}
tunlock();
return r;
}
static int tokutrace_dbc_c_close (DBC *dbc) {
tlock();
DBC *native_cursor = (DBC*)dbc->i;
int r = native_cursor->c_close(native_cursor);
if (tracefile) fprintf(tracefile, "dbc_close %d %d\n", r, dbcpairnum(dbc));
tunlock();
return r;
}
static int tokutrace_db_cursor(DB *db, DB_TXN *txn, DBC **c, u_int32_t flags) {
tlock();
DBC *MALLOC(result);
assert(result);
memset(result, 0, sizeof(*result));
DBC *native_cursor;
DB *native_db = (DB*)db->i;
DB_TXN *native_txn = txn ? (DB_TXN*)txn->i : 0;
int r = native_db->cursor(native_db, native_txn, &native_cursor, flags);
if (tracefile) {
struct tracepair *pair = create_tracepair(result, TT_DBC);
fprintf(tracefile, "db_cursor %d %d %d %d %u\n",
r, dbpairnum(db), txnpairnum(txn), pair->itemnum, flags);
}
tunlock();
#define SC(name) result->name = tokutrace_dbc_ ## name;
SC(c_get);
SC(c_close);
#undef SC
result->i = (void*)native_cursor;
*c = result;
return r;
}
int db_create(DB **dbp, DB_ENV *env, u_int32_t flags) {
tlock();
DB *MALLOC(result);
assert(result);
memset(result, 0, sizeof(*result));
DB *native_db;
int r = db_create_toku10(&native_db, env ? (DB_ENV*)env->i : 0, flags);
result->i = (void*)native_db;
#define SDB(name) result->name = tokutrace_db_ ## name;
SDB(close);
SDB(cursor);
SDB(open);
SDB(get);
SDB(put);
SDB(set_flags);
SDB(set_pagesize);
#undef SDB
*dbp = result;
if (tracefile) {
struct tracepair *pair = create_tracepair(result, TT_DB);
int envitemnum;
find_envpair(env, &envitemnum);
fprintf(tracefile, "db_create %d %d %d %u\n", 0, pair->itemnum, envitemnum, flags);
}
tunlock();
return r;
}
#ifndef TDB_TRACE_H
#define TDB_TRACE_H
int db_env_create_toku10(DB_ENV ** envp, u_int32_t flags);
int db_create_toku10 (DB **, DB_ENV *, u_int32_t flags);
#endif
......@@ -3,7 +3,7 @@
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
#include "../include/db.h"
#include <db.h>
#include "../newbrt/brttypes.h"
#include "../newbrt/brt.h"
#include "../newbrt/list.h"
......@@ -60,22 +60,6 @@ struct __toku_db_env_internal {
toku_ltm* ltm;
};
struct __toku_db_txn_internal {
//TXNID txnid64; /* A sixty-four bit txn id. */
TOKUTXN tokutxn;
toku_lth* lth;
u_int32_t flags;
DB_TXN *child, *next, *prev;
};
struct __toku_dbc_internal {
BRT_CURSOR c;
DB_TXN *txn;
struct simple_dbt skey_s,sval_s;
struct simple_dbt *skey,*sval;
};
/* *********************************************************
Ephemeral locking
......
......@@ -961,7 +961,7 @@ int DB_ENV_CREATE_FUN (DB_ENV ** envp, u_int32_t flags) {
static int toku_txn_release_locks(DB_TXN* txn) {
assert(txn);
toku_lth* lth = txn->i->lth;
toku_lth* lth = db_txn_struct_i(txn)->lth;
int r = ENOSYS;
int first_error = 0;
......@@ -969,7 +969,7 @@ static int toku_txn_release_locks(DB_TXN* txn) {
toku_lth_start_scan(lth);
toku_lock_tree* next = toku_lth_next(lth);
while (next) {
r = toku_lt_unlock(next, toku_txn_get_txnid(txn->i->tokutxn));
r = toku_lt_unlock(next, toku_txn_get_txnid(db_txn_struct_i(txn)->tokutxn));
if (!first_error && r!=0) { first_error = r; }
if (r == 0) {
r = toku_lt_remove_ref(next);
......@@ -978,7 +978,7 @@ static int toku_txn_release_locks(DB_TXN* txn) {
next = toku_lth_next(lth);
}
toku_lth_close(lth);
txn->i->lth = NULL;
db_txn_struct_i(txn)->lth = NULL;
}
r = first_error;
......@@ -998,45 +998,46 @@ static int toku_txn_commit(DB_TXN * txn, u_int32_t flags) {
HANDLE_PANICKED_ENV(txn->mgrp);
//Recursively kill off children
int r_child_first = 0;
while (txn->i->child) {
int r_child = toku_txn_commit(txn->i->child, flags);
while (db_txn_struct_i(txn)->child) {
int r_child = toku_txn_commit(db_txn_struct_i(txn)->child, flags);
if (!r_child_first) r_child_first = r_child;
//In a panicked env, the child may not be removed from the list.
HANDLE_PANICKED_ENV(txn->mgrp);
}
//Remove from parent
if (txn->parent) {
if (txn->parent->i->child==txn) txn->parent->i->child=txn->i->next;
if (txn->parent->i->child==txn) {
txn->parent->i->child=NULL;
if (db_txn_struct_i(txn->parent)->child==txn) db_txn_struct_i(txn->parent)->child=db_txn_struct_i(txn)->next;
if (db_txn_struct_i(txn->parent)->child==txn) {
db_txn_struct_i(txn->parent)->child=NULL;
}
else {
txn->i->next->i->prev = txn->i->prev;
txn->i->prev->i->next = txn->i->next;
db_txn_struct_i(db_txn_struct_i(txn)->next)->prev = db_txn_struct_i(txn)->prev;
db_txn_struct_i(db_txn_struct_i(txn)->prev)->next = db_txn_struct_i(txn)->next;
}
}
//toku_ydb_notef("flags=%d\n", flags);
int nosync = (flags & DB_TXN_NOSYNC)!=0 || (txn->i->flags&DB_TXN_NOSYNC);
int nosync = (flags & DB_TXN_NOSYNC)!=0 || (db_txn_struct_i(txn)->flags&DB_TXN_NOSYNC);
flags &= ~DB_TXN_NOSYNC;
int r;
if (r_child_first || flags!=0)
// frees the tokutxn
// Calls ydb_yield(NULL) occasionally
r = toku_logger_abort(txn->i->tokutxn, ydb_yield, NULL);
r = toku_logger_abort(db_txn_struct_i(txn)->tokutxn, ydb_yield, NULL);
else
// frees the tokutxn
// Calls ydb_yield(NULL) occasionally
r = toku_logger_commit(txn->i->tokutxn, nosync, ydb_yield, NULL);
r = toku_logger_commit(db_txn_struct_i(txn)->tokutxn, nosync, ydb_yield, NULL);
// Close the logger after releasing the locks
int r2 = toku_txn_release_locks(txn);
toku_logger_txn_close(txn->i->tokutxn);
toku_logger_txn_close(db_txn_struct_i(txn)->tokutxn);
// the toxutxn is freed, and we must free the rest. */
// The txn is no good after the commit even if the commit fails, so free it up.
if (txn->i)
toku_free(txn->i);
#if !TOKUDB_NATIVE_H
toku_free(db_txn_struct_i(txn));
#endif
toku_free(txn);
if (flags!=0) return EINVAL;
return r ? r : (r2 ? r2 : r_child_first);
......@@ -1053,28 +1054,30 @@ static int toku_txn_abort(DB_TXN * txn) {
HANDLE_PANICKED_ENV(txn->mgrp);
//Recursively kill off children
int r_child_first = 0;
while (txn->i->child) {
int r_child = toku_txn_abort(txn->i->child);
while (db_txn_struct_i(txn)->child) {
int r_child = toku_txn_abort(db_txn_struct_i(txn)->child);
if (!r_child_first) r_child_first = r_child;
//In a panicked env, the child may not be removed from the list.
HANDLE_PANICKED_ENV(txn->mgrp);
}
//Remove from parent
if (txn->parent) {
if (txn->parent->i->child==txn) txn->parent->i->child=txn->i->next;
if (txn->parent->i->child==txn) {
txn->parent->i->child=NULL;
if (db_txn_struct_i(txn->parent)->child==txn) db_txn_struct_i(txn->parent)->child=db_txn_struct_i(txn)->next;
if (db_txn_struct_i(txn->parent)->child==txn) {
db_txn_struct_i(txn->parent)->child=NULL;
}
else {
txn->i->next->i->prev = txn->i->prev;
txn->i->prev->i->next = txn->i->next;
db_txn_struct_i(db_txn_struct_i(txn)->next)->prev = db_txn_struct_i(txn)->prev;
db_txn_struct_i(db_txn_struct_i(txn)->prev)->next = db_txn_struct_i(txn)->next;
}
}
int r = toku_logger_abort(txn->i->tokutxn, ydb_yield, NULL);
int r = toku_logger_abort(db_txn_struct_i(txn)->tokutxn, ydb_yield, NULL);
int r2 = toku_txn_release_locks(txn);
toku_logger_txn_close(txn->i->tokutxn);
toku_logger_txn_close(db_txn_struct_i(txn)->tokutxn);
toku_free(txn->i);
#if !TOKUDB_NATIVE_H
toku_free(db_txn_struct_i(txn));
#endif
toku_free(txn);
return r ? r : (r2 ? r2 : r_child_first);
}
......@@ -1091,7 +1094,7 @@ static u_int32_t locked_txn_id(DB_TXN *txn) {
static int toku_txn_stat (DB_TXN *txn, struct txn_stat **txn_stat) {
XMALLOC(*txn_stat);
return toku_logger_txn_rolltmp_raw_count(txn->i->tokutxn, &(*txn_stat)->rolltmp_raw_count);
return toku_logger_txn_rolltmp_raw_count(db_txn_struct_i(txn)->tokutxn, &(*txn_stat)->rolltmp_raw_count);
}
static int locked_txn_stat (DB_TXN *txn, struct txn_stat **txn_stat) {
......@@ -1137,40 +1140,44 @@ static int toku_txn_begin(DB_ENV *env, DB_TXN * stxn, DB_TXN ** txn, u_int32_t f
result->id = locked_txn_id;
result->parent = stxn;
result->txn_stat = locked_txn_stat;
MALLOC(result->i);
if (!result->i) {
#if !TOKUDB_NATIVE_H
MALLOC(db_txn_struct_i(result));
if (!db_txn_struct_i(result)) {
toku_free(result);
return ENOMEM;
}
memset(result->i, 0, sizeof *result->i);
result->i->flags = txn_flags;
#endif
memset(db_txn_struct_i(result), 0, sizeof *db_txn_struct_i(result));
db_txn_struct_i(result)->flags = txn_flags;
int r;
if (env->i->open_flags & DB_INIT_LOCK && !stxn) {
r = toku_lth_create(&result->i->lth,
r = toku_lth_create(&db_txn_struct_i(result)->lth,
toku_malloc, toku_free, toku_realloc);
if (r!=0) {
toku_free(result->i);
#if !TOKUDB_NATIVE_H
toku_free(db_txn_struct_i(result));
#endif
toku_free(result);
return r;
}
}
r = toku_logger_txn_begin(stxn ? stxn->i->tokutxn : 0, &result->i->tokutxn, env->i->logger);
r = toku_logger_txn_begin(stxn ? db_txn_struct_i(stxn)->tokutxn : 0, &db_txn_struct_i(result)->tokutxn, env->i->logger);
if (r != 0)
return r;
//Add to the list of children for the parent.
if (result->parent) {
if (!result->parent->i->child) {
result->parent->i->child = result;
result->i->next = result;
result->i->prev = result;
if (!db_txn_struct_i(result->parent)->child) {
db_txn_struct_i(result->parent)->child = result;
db_txn_struct_i(result)->next = result;
db_txn_struct_i(result)->prev = result;
}
else {
result->i->prev = result->parent->i->child->i->prev;
result->i->next = result->parent->i->child;
result->parent->i->child->i->prev->i->next = result;
result->parent->i->child->i->prev = result;
db_txn_struct_i(result)->prev = db_txn_struct_i(db_txn_struct_i(result->parent)->child)->prev;
db_txn_struct_i(result)->next = db_txn_struct_i(result->parent)->child;
db_txn_struct_i(db_txn_struct_i(db_txn_struct_i(result->parent)->child)->prev)->next = result;
db_txn_struct_i(db_txn_struct_i(result->parent)->child)->prev = result;
}
}
*txn = result;
......@@ -1180,7 +1187,7 @@ static int toku_txn_begin(DB_ENV *env, DB_TXN * stxn, DB_TXN ** txn, u_int32_t f
#if 0
int txn_commit(DB_TXN * txn, u_int32_t flags) {
fprintf(stderr, "%s:%d\n", __FILE__, __LINE__);
return toku_logger_log_commit(txn->i->tokutxn);
return toku_logger_log_commit(db_txn_struct_i(txn)->tokutxn);
}
#endif
......@@ -1249,7 +1256,7 @@ static int get_nonmain_cursor_flags(u_int32_t flags) {
}
static inline BOOL toku_c_uninitialized(DBC* c) {
return toku_brt_cursor_uninitialized(c->i->c);
return toku_brt_cursor_uninitialized(dbc_struct_i(c)->c);
}
typedef struct query_context_wrapped_t {
......@@ -1263,8 +1270,8 @@ static inline void
query_context_wrapped_init(QUERY_CONTEXT_WRAPPED context, DBC *c, DBT *key, DBT *val) {
context->key = key;
context->val = val;
context->skey = c->i->skey;
context->sval = c->i->sval;
context->skey = dbc_struct_i(c)->skey;
context->sval = dbc_struct_i(c)->sval;
}
static int
......@@ -1278,7 +1285,7 @@ c_get_wrapper_callback(DBT const *key, DBT const *val, void *extra) {
static TOKULOGGER
c_get_logger(DBC *c) {
TOKUTXN txn = c->i->txn ? c->i->txn->i->tokutxn : NULL;
TOKUTXN txn = dbc_struct_i(c)->txn ? db_txn_struct_i(dbc_struct_i(c)->txn)->tokutxn : NULL;
TOKULOGGER logger = toku_txn_logger(txn);
return logger;
}
......@@ -1339,7 +1346,7 @@ static inline u_int32_t get_prelocked_flags(u_int32_t flags, DB_TXN* txn) {
u_int32_t lock_flags = flags & (DB_PRELOCKED | DB_PRELOCKED_WRITE);
//DB_READ_UNCOMMITTED transactions 'own' all read locks.
if (txn && txn->i->flags&DB_READ_UNCOMMITTED) lock_flags |= DB_PRELOCKED;
if (txn && db_txn_struct_i(txn)->flags&DB_READ_UNCOMMITTED) lock_flags |= DB_PRELOCKED;
return lock_flags;
}
......@@ -1565,7 +1572,7 @@ grab_range_lock(RANGE_LOCK_REQUEST request) {
DB_TXN *txn_anc = toku_txn_ancestor(request->txn);
r = toku_txn_add_lt(txn_anc, request->lt);
if (r==0) {
TXNID txn_anc_id = toku_txn_get_txnid(txn_anc->i->tokutxn);
TXNID txn_anc_id = toku_txn_get_txnid(db_txn_struct_i(txn_anc)->tokutxn);
if (request->is_read_lock)
r = toku_lt_acquire_range_read_lock(request->lt, request->db, txn_anc_id,
request->left_key, request->left_val,
......@@ -1606,11 +1613,11 @@ typedef struct query_context_with_input_t {
static void
query_context_base_init(QUERY_CONTEXT_BASE context, DBC *c, u_int32_t flag, void *extra) {
context->c = c->i->c;
context->txn = c->i->txn;
context->c = dbc_struct_i(c)->c;
context->txn = dbc_struct_i(c)->txn;
context->db = c->dbp;
context->f_extra = extra;
u_int32_t lock_flags = get_prelocked_flags(flag, c->i->txn);
u_int32_t lock_flags = get_prelocked_flags(flag, dbc_struct_i(c)->txn);
flag &= ~lock_flags;
assert(flag==0);
context->do_locking = (BOOL)(context->db->i->lt!=NULL && !lock_flags);
......@@ -1642,7 +1649,7 @@ toku_c_del(DBC * c, u_int32_t flags) {
//DB_DELETE_ANY means delete regardless of whether it exists in the db.
u_int32_t flag_for_brt = flags&DB_DELETE_ANY;
unchecked_flags &= ~flag_for_brt;
u_int32_t lock_flags = get_prelocked_flags(flags, c->i->txn);
u_int32_t lock_flags = get_prelocked_flags(flags, dbc_struct_i(c)->txn);
unchecked_flags &= ~lock_flags;
BOOL do_locking = (BOOL)(c->dbp->i->lt && !(lock_flags&DB_PRELOCKED_WRITE));
......@@ -1657,8 +1664,8 @@ toku_c_del(DBC * c, u_int32_t flags) {
}
if (r==0) {
//Do the actual delete.
TOKUTXN txn = c->i->txn ? c->i->txn->i->tokutxn : 0;
r = toku_brt_cursor_delete(c->i->c, flag_for_brt, txn);
TOKUTXN txn = dbc_struct_i(c)->txn ? db_txn_struct_i(dbc_struct_i(c)->txn)->tokutxn : 0;
r = toku_brt_cursor_delete(dbc_struct_i(c)->c, flag_for_brt, txn);
}
}
return r;
......@@ -1697,7 +1704,7 @@ toku_c_getf_first(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra)
query_context_init(&context, c, flag, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_first will call c_getf_first_callback(..., context) (if query is successful)
int r = toku_brt_cursor_first(c->i->c, c_getf_first_callback, &context, logger);
int r = toku_brt_cursor_first(dbc_struct_i(c)->c, c_getf_first_callback, &context, logger);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
return r;
}
......@@ -1751,7 +1758,7 @@ toku_c_getf_last(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra) {
query_context_init(&context, c, flag, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_last will call c_getf_last_callback(..., context) (if query is successful)
int r = toku_brt_cursor_last(c->i->c, c_getf_last_callback, &context, logger);
int r = toku_brt_cursor_last(dbc_struct_i(c)->c, c_getf_last_callback, &context, logger);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
return r;
}
......@@ -1808,7 +1815,7 @@ toku_c_getf_next(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra) {
query_context_init(&context, c, flag, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_next will call c_getf_next_callback(..., context) (if query is successful)
r = toku_brt_cursor_next(c->i->c, c_getf_next_callback, &context, logger);
r = toku_brt_cursor_next(dbc_struct_i(c)->c, c_getf_next_callback, &context, logger);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
}
return r;
......@@ -1862,7 +1869,7 @@ toku_c_getf_next_nodup(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *ex
query_context_init(&context, c, flag, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_next will call c_getf_next_callback(..., context) (if query is successful)
r = toku_brt_cursor_next_nodup(c->i->c, c_getf_next_callback, &context, logger);
r = toku_brt_cursor_next_nodup(dbc_struct_i(c)->c, c_getf_next_callback, &context, logger);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
}
return r;
......@@ -1879,7 +1886,7 @@ toku_c_getf_next_dup(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extr
query_context_init(&context, c, flag, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_next_dup will call c_getf_next_dup_callback(..., context) (if query is successful)
int r = toku_brt_cursor_next_dup(c->i->c, c_getf_next_dup_callback, &context, logger);
int r = toku_brt_cursor_next_dup(dbc_struct_i(c)->c, c_getf_next_dup_callback, &context, logger);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
return r;
}
......@@ -1934,7 +1941,7 @@ toku_c_getf_prev(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra) {
query_context_init(&context, c, flag, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_prev will call c_getf_prev_callback(..., context) (if query is successful)
r = toku_brt_cursor_prev(c->i->c, c_getf_prev_callback, &context, logger);
r = toku_brt_cursor_prev(dbc_struct_i(c)->c, c_getf_prev_callback, &context, logger);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
}
return r;
......@@ -1988,7 +1995,7 @@ toku_c_getf_prev_nodup(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *ex
query_context_init(&context, c, flag, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_prev will call c_getf_prev_callback(..., context) (if query is successful)
r = toku_brt_cursor_prev_nodup(c->i->c, c_getf_prev_callback, &context, logger);
r = toku_brt_cursor_prev_nodup(dbc_struct_i(c)->c, c_getf_prev_callback, &context, logger);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
}
return r;
......@@ -2005,7 +2012,7 @@ toku_c_getf_prev_dup(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extr
query_context_init(&context, c, flag, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_prev_dup will call c_getf_prev_dup_callback(..., context) (if query is successful)
int r = toku_brt_cursor_prev_dup(c->i->c, c_getf_prev_dup_callback, &context, logger);
int r = toku_brt_cursor_prev_dup(dbc_struct_i(c)->c, c_getf_prev_dup_callback, &context, logger);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
return r;
}
......@@ -2057,7 +2064,7 @@ toku_c_getf_current(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra
query_context_init(&context, c, flag, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_current will call c_getf_current_callback(..., context) (if query is successful)
int r = toku_brt_cursor_current(c->i->c, DB_CURRENT, c_getf_current_callback, &context, logger);
int r = toku_brt_cursor_current(dbc_struct_i(c)->c, DB_CURRENT, c_getf_current_callback, &context, logger);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
return r;
}
......@@ -2092,7 +2099,7 @@ toku_c_getf_current_binding(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, voi
query_context_init(&context, c, flag, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_current will call c_getf_current_callback(..., context) (if query is successful)
int r = toku_brt_cursor_current(c->i->c, DB_CURRENT_BINDING, c_getf_current_callback, &context, logger);
int r = toku_brt_cursor_current(dbc_struct_i(c)->c, DB_CURRENT_BINDING, c_getf_current_callback, &context, logger);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
return r;
}
......@@ -2107,7 +2114,7 @@ toku_c_getf_set(DBC *c, u_int32_t flag, DBT *key, YDB_CALLBACK_FUNCTION f, void
query_context_with_input_init(&context, c, flag, key, NULL, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_set will call c_getf_set_callback(..., context) (if query is successful)
int r = toku_brt_cursor_set(c->i->c, key, NULL, c_getf_set_callback, &context, logger);
int r = toku_brt_cursor_set(dbc_struct_i(c)->c, key, NULL, c_getf_set_callback, &context, logger);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
return r;
}
......@@ -2164,7 +2171,7 @@ toku_c_getf_set_range(DBC *c, u_int32_t flag, DBT *key, YDB_CALLBACK_FUNCTION f,
query_context_with_input_init(&context, c, flag, key, NULL, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_set_range will call c_getf_set_range_callback(..., context) (if query is successful)
int r = toku_brt_cursor_set_range(c->i->c, key, c_getf_set_range_callback, &context, logger);
int r = toku_brt_cursor_set_range(dbc_struct_i(c)->c, key, c_getf_set_range_callback, &context, logger);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
return r;
}
......@@ -2222,7 +2229,7 @@ toku_c_getf_get_both(DBC *c, u_int32_t flag, DBT *key, DBT *val, YDB_CALLBACK_FU
query_context_with_input_init(&context, c, flag, key, val, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_get_both will call c_getf_get_both_callback(..., context) (if query is successful)
int r = toku_brt_cursor_set(c->i->c, key, val, c_getf_get_both_callback, &context, logger);
int r = toku_brt_cursor_set(dbc_struct_i(c)->c, key, val, c_getf_get_both_callback, &context, logger);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
return r;
}
......@@ -2274,7 +2281,7 @@ toku_c_getf_get_both_range(DBC *c, u_int32_t flag, DBT *key, DBT *val, YDB_CALLB
query_context_with_input_init(&context, c, flag, key, val, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_get_both_range will call c_getf_get_both_range_callback(..., context) (if query is successful)
r = toku_brt_cursor_get_both_range(c->i->c, key, val, c_getf_get_both_range_callback, &context, logger);
r = toku_brt_cursor_get_both_range(dbc_struct_i(c)->c, key, val, c_getf_get_both_range_callback, &context, logger);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
}
return r;
......@@ -2367,7 +2374,7 @@ toku_c_getf_heaviside(DBC *c, u_int32_t flag,
query_context_heaviside_init(&context, c, flag, f, extra_f, &wrapper);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_heaviside will call c_getf_heaviside_callback(..., context) (if query is successful)
r = toku_brt_cursor_heaviside(c->i->c, c_getf_heaviside_callback, &context, logger, &wrapper);
r = toku_brt_cursor_heaviside(dbc_struct_i(c)->c, c_getf_heaviside_callback, &context, logger, &wrapper);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
return r;
}
......@@ -2501,10 +2508,12 @@ static int c_getf_heaviside_callback(ITEMLEN found_keylen, bytevec found_keyvec,
}
static int toku_c_close(DBC * c) {
int r = toku_brt_cursor_close(c->i->c);
toku_sdbt_cleanup(&c->i->skey_s);
toku_sdbt_cleanup(&c->i->sval_s);
toku_free(c->i);
int r = toku_brt_cursor_close(dbc_struct_i(c)->c);
toku_sdbt_cleanup(&dbc_struct_i(c)->skey_s);
toku_sdbt_cleanup(&dbc_struct_i(c)->sval_s);
#if !TOKUDB_NATIVE_H
toku_free(dbc_struct_i(c));
#endif
toku_free(c);
return r;
}
......@@ -2523,7 +2532,7 @@ toku_c_count(DBC *cursor, db_recno_t *count, u_int32_t flags) {
DBT currentkey;
init_dbt_realloc(&currentkey);
u_int32_t lock_flags = get_prelocked_flags(flags, cursor->i->txn);
u_int32_t lock_flags = get_prelocked_flags(flags, dbc_struct_i(cursor)->txn);
flags &= ~lock_flags;
if (flags != 0) {
r = EINVAL; goto finish;
......@@ -2538,7 +2547,7 @@ toku_c_count(DBC *cursor, db_recno_t *count, u_int32_t flags) {
// lock_flags |= DB_PRELOCKED
//}
r = toku_db_cursor(cursor->dbp, cursor->i->txn, &count_cursor, 0, 0);
r = toku_db_cursor(cursor->dbp, dbc_struct_i(cursor)->txn, &count_cursor, 0, 0);
if (r != 0) goto finish;
*count = 0;
......@@ -2617,7 +2626,7 @@ toku_db_del(DB *db, DB_TXN *txn, DBT *key, u_int32_t flags) {
}
if (r==0) {
//Do the actual deleting.
r = toku_brt_delete(db->i->brt, key, txn ? txn->i->tokutxn : 0);
r = toku_brt_delete(db->i->brt, key, txn ? db_txn_struct_i(txn)->tokutxn : 0);
}
return r;
}
......@@ -2670,20 +2679,23 @@ static int toku_db_cursor(DB * db, DB_TXN * txn, DBC ** c, u_int32_t flags, int
SCRS(c_getf_get_both);
SCRS(c_getf_get_both_range);
#undef SCRS
MALLOC(result->i);
#if !TOKUDB_NATIVE_H
MALLOC(result->i); // otherwise it is allocated as part of result->ii
assert(result->i);
#endif
result->dbp = db;
result->i->txn = txn;
result->i->skey_s = (struct simple_dbt){0,0};
result->i->sval_s = (struct simple_dbt){0,0};
dbc_struct_i(result)->txn = txn;
dbc_struct_i(result)->skey_s = (struct simple_dbt){0,0};
dbc_struct_i(result)->sval_s = (struct simple_dbt){0,0};
if (is_temporary_cursor) {
result->i->skey = &db->i->skey;
result->i->sval = &db->i->sval;
dbc_struct_i(result)->skey = &db->i->skey;
dbc_struct_i(result)->sval = &db->i->sval;
} else {
result->i->skey = &result->i->skey_s;
result->i->sval = &result->i->sval_s;
dbc_struct_i(result)->skey = &dbc_struct_i(result)->skey_s;
dbc_struct_i(result)->sval = &dbc_struct_i(result)->sval_s;
}
int r = toku_brt_cursor(db->i->brt, &result->i->c);
int r = toku_brt_cursor(db->i->brt, &dbc_struct_i(result)->c);
assert(r == 0);
*c = result;
return 0;
......@@ -2716,7 +2728,7 @@ toku_db_delboth(DB *db, DB_TXN *txn, DBT *key, DBT *val, u_int32_t flags) {
}
if (r==0) {
//Do the actual deleting.
r = toku_brt_delete_both(db->i->brt, key, val, txn ? txn->i->tokutxn : NULL);
r = toku_brt_delete_both(db->i->brt, key, val, txn ? db_txn_struct_i(txn)->tokutxn : NULL);
}
return r;
}
......@@ -2847,7 +2859,7 @@ static int toku_db_lt_panic(DB* db, int r) {
static int toku_txn_add_lt(DB_TXN* txn, toku_lock_tree* lt) {
int r = ENOSYS;
assert(txn && lt);
toku_lth* lth = txn->i->lth;
toku_lth* lth = db_txn_struct_i(txn)->lth;
assert(lth);
toku_lock_tree* find = toku_lth_find(lth, lt);
......@@ -3001,7 +3013,7 @@ static int toku_db_open(DB * db, DB_TXN * txn, const char *fname, const char *db
r = toku_brt_open(db->i->brt, db->i->full_fname, fname,
is_db_create, is_db_excl,
db->dbenv->i->cachetable,
txn ? txn->i->tokutxn : NULL_TXN,
txn ? db_txn_struct_i(txn)->tokutxn : NULL_TXN,
db);
if (r != 0)
goto error_cleanup;
......@@ -3146,7 +3158,7 @@ toku_db_put(DB *db, DB_TXN *txn, DBT *key, DBT *val, u_int32_t flags) {
}
if (r==0) {
//Insert into the brt.
r = toku_brt_insert(db->i->brt, key, val, txn ? txn->i->tokutxn : 0);
r = toku_brt_insert(db->i->brt, key, val, txn ? db_txn_struct_i(txn)->tokutxn : 0);
}
return r;
}
......@@ -3326,7 +3338,7 @@ static int toku_db_set_pagesize(DB *db, u_int32_t pagesize) {
static int toku_db_stat64(DB * db, DB_TXN *txn, DB_BTREE_STAT64 *s) {
HANDLE_PANICKED_DB(db);
return toku_brt_stat64(db->i->brt, txn->i->tokutxn, &s->bt_nkeys, &s->bt_ndata, &s->bt_dsize, &s->bt_fsize);
return toku_brt_stat64(db->i->brt, db_txn_struct_i(txn)->tokutxn, &s->bt_nkeys, &s->bt_ndata, &s->bt_dsize, &s->bt_fsize);
}
static int locked_db_stat64 (DB *db, DB_TXN *txn, DB_BTREE_STAT64 *s) {
toku_ydb_lock();
......@@ -3355,12 +3367,12 @@ static int toku_db_pre_acquire_read_lock(DB *db, DB_TXN *txn, const DBT *key_lef
HANDLE_PANICKED_DB(db);
if (!db->i->lt || !txn) return EINVAL;
//READ_UNCOMMITTED transactions do not need read locks.
if (txn->i->flags&DB_READ_UNCOMMITTED) return 0;
if (db_txn_struct_i(txn)->flags&DB_READ_UNCOMMITTED) return 0;
DB_TXN* txn_anc = toku_txn_ancestor(txn);
int r;
if ((r=toku_txn_add_lt(txn_anc, db->i->lt))) return r;
TXNID id_anc = toku_txn_get_txnid(txn_anc->i->tokutxn);
TXNID id_anc = toku_txn_get_txnid(db_txn_struct_i(txn_anc)->tokutxn);
r = toku_lt_acquire_range_read_lock(db->i->lt, db, id_anc,
key_left, val_left,
......@@ -3375,13 +3387,13 @@ static int toku_db_pre_acquire_table_lock(DB *db, DB_TXN *txn) {
DB_TXN* txn_anc = toku_txn_ancestor(txn);
int r;
if ((r=toku_txn_add_lt(txn_anc, db->i->lt))) return r;
TXNID id_anc = toku_txn_get_txnid(txn_anc->i->tokutxn);
TXNID id_anc = toku_txn_get_txnid(db_txn_struct_i(txn_anc)->tokutxn);
r = toku_lt_acquire_range_write_lock(db->i->lt, db, id_anc,
toku_lt_neg_infinity, toku_lt_neg_infinity,
toku_lt_infinity, toku_lt_infinity);
if (r==0) {
r = toku_brt_note_table_lock(db->i->brt, txn->i->tokutxn); // tell the BRT layer that the table is locked (so that it can reduce the amount of rollback (rolltmp) data.
r = toku_brt_note_table_lock(db->i->brt, db_txn_struct_i(txn)->tokutxn); // tell the BRT layer that the table is locked (so that it can reduce the amount of rollback (rolltmp) data.
}
return r;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment