Commit 8e76507a authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

A bunch of symbols that don't start with toku_ are made static or start with toku_. Addresses #8.

git-svn-id: file:///svn/tokudb@801 c7de825b-a66e-492c-adef-691d508d4ae1
parent 3b16f5e7
......@@ -8,10 +8,10 @@
extern "C" {
#endif
#define DB_VERSION_MAJOR 4
#define DB_VERSION_MINOR 1
#define DB_VERSION_PATCH 25
#define DB_VERSION_MINOR 3
#define DB_VERSION_PATCH 29
#ifndef _TOKUDB_WRAP_H
#define DB_VERSION_STRING "Tokutek: TokuDB 4.1.25"
#define DB_VERSION_STRING "Tokutek: TokuDB 4.3.29"
#else
#define DB_VERSION_STRING_ydb "Tokutek: TokuDB (wrapped bdb)"
#endif
......@@ -29,10 +29,10 @@ typedef enum {
DB_BTREE=1
} DBTYPE;
#ifndef _TOKUDB_WRAP_H
#define DB_VERB_DEADLOCK 2
#define DB_VERB_RECOVERY 4
#define DB_VERB_REPLICATION 8
#define DB_VERB_WAITSFOR 16
#define DB_VERB_DEADLOCK 1
#define DB_VERB_RECOVERY 2
#define DB_VERB_REPLICATION 4
#define DB_VERB_WAITSFOR 8
#define DB_DBT_MALLOC 4
#define DB_DBT_REALLOC 16
#define DB_DBT_USERMEM 32
......@@ -40,38 +40,38 @@ typedef enum {
#define DB_ARCH_ABS 1
#define DB_ARCH_LOG 4
#define DB_CREATE 1
#define DB_EXCL 2048
#define DB_PRIVATE 262144
#define DB_EXCL 4096
#define DB_PRIVATE 1048576
#define DB_RDONLY 16
#define DB_RECOVER 32
#define DB_THREAD 64
#define DB_TXN_NOSYNC 256
#define DB_LOCK_DEFAULT 1
#define DB_LOCK_OLDEST 6
#define DB_LOCK_RANDOM 7
#define DB_LOCK_OLDEST 7
#define DB_LOCK_RANDOM 8
#define DB_DUP 2
#define DB_DUPSORT 4
#define DB_NOOVERWRITE 23
#define DB_INIT_LOCK 4096
#define DB_INIT_LOG 8192
#define DB_INIT_MPOOL 16384
#define DB_INIT_TXN 32768
#define DB_USE_ENVIRON 512
#define DB_USE_ENVIRON_ROOT 1024
#define DB_KEYEMPTY -30998
#define DB_KEYEXIST -30997
#define DB_LOCK_DEADLOCK -30996
#define DB_NOTFOUND -30991
#define DB_NOOVERWRITE 22
#define DB_INIT_LOCK 8192
#define DB_INIT_LOG 16384
#define DB_INIT_MPOOL 32768
#define DB_INIT_TXN 131072
#define DB_USE_ENVIRON 1024
#define DB_USE_ENVIRON_ROOT 2048
#define DB_KEYEMPTY -30997
#define DB_KEYEXIST -30996
#define DB_LOCK_DEADLOCK -30995
#define DB_NOTFOUND -30989
#define DB_BADFORMAT -30500
#define DB_FIRST 10
#define DB_GET_BOTH 11
#define DB_LAST 18
#define DB_NEXT 19
#define DB_NEXT_DUP 20
#define DB_PREV 27
#define DB_SET 30
#define DB_SET_RANGE 32
#define DB_RMW 1073741824
#define DB_FIRST 9
#define DB_GET_BOTH 10
#define DB_LAST 17
#define DB_NEXT 18
#define DB_NEXT_DUP 19
#define DB_PREV 25
#define DB_SET 28
#define DB_SET_RANGE 30
#define DB_RMW 536870912
#endif
/* 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
......@@ -81,57 +81,60 @@ struct __toku_db_btree_stat {
char __toku_dummy0[12];
u_int32_t bt_nkeys; /* 32-bit offset=12 size=4, 64=bit offset=12 size=4 */
u_int32_t bt_ndata; /* 32-bit offset=16 size=4, 64=bit offset=16 size=4 */
char __toku_dummy1[60]; /* Padding at the end */
char __toku_dummy1[64]; /* Padding at the end */
};
struct __toku_db_env {
struct __toku_db_env_internal *i;
void* __toku_dummy0[8];
void *app_private; /* 32-bit offset=36 size=4, 64=bit offset=72 size=8 */
void* __toku_dummy1[35];
char __toku_dummy2[64];
int (*close) (DB_ENV *, u_int32_t); /* 32-bit offset=244 size=4, 64=bit offset=424 size=8 */
void* __toku_dummy0[10];
void *app_private; /* 32-bit offset=44 size=4, 64=bit offset=88 size=8 */
void* __toku_dummy1[33];
char __toku_dummy2[96];
int (*close) (DB_ENV *, u_int32_t); /* 32-bit offset=276 size=4, 64=bit offset=456 size=8 */
void* __toku_dummy3[2];
void (*err) (const DB_ENV *, int, const char *, ...); /* 32-bit offset=256 size=4, 64=bit offset=448 size=8 */
void (*err) (const DB_ENV *, int, const char *, ...); /* 32-bit offset=288 size=4, 64=bit offset=480 size=8 */
void* __toku_dummy4[1];
int (*open) (DB_ENV *, const char *, u_int32_t, int); /* 32-bit offset=264 size=4, 64=bit offset=464 size=8 */
void* __toku_dummy5[1];
int (*set_data_dir) (DB_ENV *, const char *); /* 32-bit offset=272 size=4, 64=bit offset=480 size=8 */
void* __toku_dummy6[3];
void (*set_errcall) (DB_ENV *, void (*)(const char *, char *)); /* 32-bit offset=288 size=4, 64=bit offset=512 size=8 */
void* __toku_dummy7[1];
void (*set_errpfx) (DB_ENV *, const char *); /* 32-bit offset=296 size=4, 64=bit offset=528 size=8 */
void* __toku_dummy8[1];
int (*set_flags) (DB_ENV *, u_int32_t, int); /* 32-bit offset=304 size=4, 64=bit offset=544 size=8 */
void* __toku_dummy9[4];
int (*set_tmp_dir) (DB_ENV *, const char *); /* 32-bit offset=324 size=4, 64=bit offset=584 size=8 */
int (*set_verbose) (DB_ENV *, u_int32_t, int); /* 32-bit offset=328 size=4, 64=bit offset=592 size=8 */
int (*open) (DB_ENV *, const char *, u_int32_t, int); /* 32-bit offset=296 size=4, 64=bit offset=496 size=8 */
void* __toku_dummy5[9];
int (*set_data_dir) (DB_ENV *, const char *); /* 32-bit offset=336 size=4, 64=bit offset=576 size=8 */
void* __toku_dummy6[2];
void (*set_errcall) (DB_ENV *, void (*)(const char *, char *)); /* 32-bit offset=348 size=4, 64=bit offset=600 size=8 */
void* __toku_dummy7[3];
void (*set_errpfx) (DB_ENV *, const char *); /* 32-bit offset=364 size=4, 64=bit offset=632 size=8 */
void* __toku_dummy8[2];
int (*set_flags) (DB_ENV *, u_int32_t, int); /* 32-bit offset=376 size=4, 64=bit offset=656 size=8 */
void* __toku_dummy9[13];
int (*set_tmp_dir) (DB_ENV *, const char *); /* 32-bit offset=432 size=4, 64=bit offset=768 size=8 */
void* __toku_dummy10[1];
int (*set_lg_bsize) (DB_ENV *, u_int32_t); /* 32-bit offset=336 size=4, 64=bit offset=608 size=8 */
int (*set_lg_dir) (DB_ENV *, const char *); /* 32-bit offset=340 size=4, 64=bit offset=616 size=8 */
int (*set_lg_max) (DB_ENV *, u_int32_t); /* 32-bit offset=344 size=4, 64=bit offset=624 size=8 */
void* __toku_dummy11[1];
int (*log_archive) (DB_ENV *, char **[], u_int32_t); /* 32-bit offset=352 size=4, 64=bit offset=640 size=8 */
void* __toku_dummy12[2];
int (*log_flush) (DB_ENV *, const DB_LSN *); /* 32-bit offset=364 size=4, 64=bit offset=664 size=8 */
void* __toku_dummy13[4];
int (*set_lk_detect) (DB_ENV *, u_int32_t); /* 32-bit offset=384 size=4, 64=bit offset=704 size=8 */
int (*set_lk_max) (DB_ENV *, u_int32_t); /* 32-bit offset=388 size=4, 64=bit offset=712 size=8 */
void* __toku_dummy14[15];
int (*set_cachesize) (DB_ENV *, u_int32_t, u_int32_t, int); /* 32-bit offset=452 size=4, 64=bit offset=840 size=8 */
void* __toku_dummy15[21];
int (*txn_begin) (DB_ENV *, DB_TXN *, DB_TXN **, u_int32_t); /* 32-bit offset=540 size=4, 64=bit offset=1016 size=8 */
int (*txn_checkpoint) (DB_ENV *, u_int32_t, u_int32_t, u_int32_t); /* 32-bit offset=544 size=4, 64=bit offset=1024 size=8 */
void* __toku_dummy16[2];
int (*txn_stat) (DB_ENV *, DB_TXN_STAT **, u_int32_t); /* 32-bit offset=556 size=4, 64=bit offset=1048 size=8 */
void* __toku_dummy17[2]; /* Padding at the end */
char __toku_dummy18[8]; /* Padding at the end */
int (*set_verbose) (DB_ENV *, u_int32_t, int); /* 32-bit offset=440 size=4, 64=bit offset=784 size=8 */
void* __toku_dummy11[2];
int (*set_lg_bsize) (DB_ENV *, u_int32_t); /* 32-bit offset=452 size=4, 64=bit offset=808 size=8 */
void* __toku_dummy12[1];
int (*set_lg_dir) (DB_ENV *, const char *); /* 32-bit offset=460 size=4, 64=bit offset=824 size=8 */
void* __toku_dummy13[1];
int (*set_lg_max) (DB_ENV *, u_int32_t); /* 32-bit offset=468 size=4, 64=bit offset=840 size=8 */
void* __toku_dummy14[2];
int (*log_archive) (DB_ENV *, char **[], u_int32_t); /* 32-bit offset=480 size=4, 64=bit offset=864 size=8 */
void* __toku_dummy15[2];
int (*log_flush) (DB_ENV *, const DB_LSN *); /* 32-bit offset=492 size=4, 64=bit offset=888 size=8 */
void* __toku_dummy16[7];
int (*set_lk_detect) (DB_ENV *, u_int32_t); /* 32-bit offset=524 size=4, 64=bit offset=952 size=8 */
int (*set_lk_max) (DB_ENV *, u_int32_t); /* 32-bit offset=528 size=4, 64=bit offset=960 size=8 */
void* __toku_dummy17[16];
int (*set_cachesize) (DB_ENV *, u_int32_t, u_int32_t, int); /* 32-bit offset=596 size=4, 64=bit offset=1096 size=8 */
void* __toku_dummy18[28];
int (*txn_begin) (DB_ENV *, DB_TXN *, DB_TXN **, u_int32_t); /* 32-bit offset=712 size=4, 64=bit offset=1328 size=8 */
int (*txn_checkpoint) (DB_ENV *, u_int32_t, u_int32_t, u_int32_t); /* 32-bit offset=716 size=4, 64=bit offset=1336 size=8 */
void* __toku_dummy19[1];
int (*txn_stat) (DB_ENV *, DB_TXN_STAT **, u_int32_t); /* 32-bit offset=724 size=4, 64=bit offset=1352 size=8 */
void* __toku_dummy20[3]; /* Padding at the end */
char __toku_dummy21[16]; /* Padding at the end */
};
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[126]; /* Padding at the end */
char __toku_dummy1[48]; /* Padding at the end */
void* __toku_dummy0[161]; /* Padding at the end */
char __toku_dummy1[88]; /* Padding at the end */
};
struct __toku_db_lsn {
char __toku_dummy0[8]; /* Padding at the end */
......@@ -141,47 +144,50 @@ struct __toku_db {
void* __toku_dummy0[3];
void *app_private; /* 32-bit offset=16 size=4, 64=bit offset=32 size=8 */
DB_ENV *dbenv; /* 32-bit offset=20 size=4, 64=bit offset=40 size=8 */
void* __toku_dummy1[35];
void* __toku_dummy1[37];
char __toku_dummy2[96];
int (*close) (DB*, u_int32_t); /* 32-bit offset=260 size=4, 64=bit offset=424 size=8 */
int (*cursor) (DB *, DB_TXN *, DBC **, u_int32_t); /* 32-bit offset=264 size=4, 64=bit offset=432 size=8 */
int (*del) (DB *, DB_TXN *, DBT *, u_int32_t); /* 32-bit offset=268 size=4, 64=bit offset=440 size=8 */
void* __toku_dummy3[3];
int (*get) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t); /* 32-bit offset=284 size=4, 64=bit offset=472 size=8 */
void* __toku_dummy4[4];
int (*key_range) (DB *, DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t); /* 32-bit offset=304 size=4, 64=bit offset=512 size=8 */
int (*open) (DB *, DB_TXN *, const char *, const char *, DBTYPE, u_int32_t, int); /* 32-bit offset=308 size=4, 64=bit offset=520 size=8 */
int (*put) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t); /* 32-bit offset=312 size=4, 64=bit offset=528 size=8 */
int (*remove) (DB *, const char *, const char *, u_int32_t); /* 32-bit offset=316 size=4, 64=bit offset=536 size=8 */
int (*rename) (DB *, const char *, const char *, const char *, u_int32_t); /* 32-bit offset=320 size=4, 64=bit offset=544 size=8 */
void* __toku_dummy5[5];
int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); /* 32-bit offset=344 size=4, 64=bit offset=592 size=8 */
int (*associate) (DB*, DB_TXN*, DB*, int(*)(DB*, const DBT*, const DBT*, DBT*), u_int32_t); /* 32-bit offset=268 size=4, 64=bit offset=440 size=8 */
int (*close) (DB*, u_int32_t); /* 32-bit offset=272 size=4, 64=bit offset=448 size=8 */
int (*cursor) (DB *, DB_TXN *, DBC **, u_int32_t); /* 32-bit offset=276 size=4, 64=bit offset=456 size=8 */
int (*del) (DB *, DB_TXN *, DBT *, u_int32_t); /* 32-bit offset=280 size=4, 64=bit offset=464 size=8 */
void* __toku_dummy3[4];
int (*get) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t); /* 32-bit offset=300 size=4, 64=bit offset=504 size=8 */
void* __toku_dummy4[15];
int (*key_range) (DB *, DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t); /* 32-bit offset=364 size=4, 64=bit offset=632 size=8 */
int (*open) (DB *, DB_TXN *, const char *, const char *, DBTYPE, u_int32_t, int); /* 32-bit offset=368 size=4, 64=bit offset=640 size=8 */
int (*put) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t); /* 32-bit offset=372 size=4, 64=bit offset=648 size=8 */
int (*remove) (DB *, const char *, const char *, u_int32_t); /* 32-bit offset=376 size=4, 64=bit offset=656 size=8 */
int (*rename) (DB *, const char *, const char *, const char *, u_int32_t); /* 32-bit offset=380 size=4, 64=bit offset=664 size=8 */
void* __toku_dummy5[4];
int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); /* 32-bit offset=400 size=4, 64=bit offset=704 size=8 */
void* __toku_dummy6[5];
int (*set_flags) (DB *, u_int32_t); /* 32-bit offset=368 size=4, 64=bit offset=640 size=8 */
void* __toku_dummy7[1];
int (*set_pagesize) (DB *, u_int32_t); /* 32-bit offset=376 size=4, 64=bit offset=656 size=8 */
int (*set_flags) (DB *, u_int32_t); /* 32-bit offset=424 size=4, 64=bit offset=752 size=8 */
void* __toku_dummy7[4];
int (*set_pagesize) (DB *, u_int32_t); /* 32-bit offset=444 size=4, 64=bit offset=792 size=8 */
void* __toku_dummy8[1];
int (*stat) (DB *, void *, u_int32_t); /* 32-bit offset=384 size=4, 64=bit offset=672 size=8 */
void* __toku_dummy9[2];
int (*verify) (DB *, const char *, const char *, FILE *, u_int32_t); /* 32-bit offset=396 size=4, 64=bit offset=696 size=8 */
int (*set_bt_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); /* 32-bit offset=400 size=4, 64=bit offset=704 size=8 */
void* __toku_dummy10[15]; /* Padding at the end */
char __toku_dummy11[8]; /* Padding at the end */
int (*stat) (DB *, void *, u_int32_t); /* 32-bit offset=452 size=4, 64=bit offset=808 size=8 */
void* __toku_dummy9[3];
int (*verify) (DB *, const char *, const char *, FILE *, u_int32_t); /* 32-bit offset=468 size=4, 64=bit offset=840 size=8 */
void* __toku_dummy10[1];
int (*set_bt_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); /* 32-bit offset=476 size=4, 64=bit offset=856 size=8 */
void* __toku_dummy11[23]; /* Padding at the end */
char __toku_dummy12[8]; /* Padding at the end */
};
struct __toku_db_txn_active {
u_int32_t txnid; /* 32-bit offset=0 size=4, 64=bit offset=0 size=4 */
char __toku_dummy0[4];
DB_LSN lsn; /* 32-bit offset=8 size=8, 64=bit offset=8 size=8 */
char __toku_dummy1[132]; /* Padding at the end */
};
struct __toku_db_txn {
struct __toku_db_txn_internal *i;
void* __toku_dummy0[12];
void* __toku_dummy0[18];
char __toku_dummy1[24];
int (*abort) (DB_TXN *); /* 32-bit offset=76 size=4, 64=bit offset=128 size=8 */
int (*commit) (DB_TXN*, u_int32_t); /* 32-bit offset=80 size=4, 64=bit offset=136 size=8 */
int (*abort) (DB_TXN *); /* 32-bit offset=100 size=4, 64=bit offset=176 size=8 */
int (*commit) (DB_TXN*, u_int32_t); /* 32-bit offset=104 size=4, 64=bit offset=184 size=8 */
void* __toku_dummy2[1];
u_int32_t (*id) (DB_TXN *); /* 32-bit offset=88 size=4, 64=bit offset=152 size=8 */
void* __toku_dummy3[3]; /* Padding at the end */
u_int32_t (*id) (DB_TXN *); /* 32-bit offset=112 size=4, 64=bit offset=200 size=8 */
void* __toku_dummy3[4]; /* Padding at the end */
};
struct __toku_db_txn_stat {
void* __toku_dummy0[1];
......@@ -194,14 +200,14 @@ struct __toku_db_txn_stat {
};
struct __toku_dbc {
struct __toku_dbc_internal *i;
void* __toku_dummy0[20];
char __toku_dummy1[104];
int (*c_close) (DBC *); /* 32-bit offset=188 size=4, 64=bit offset=272 size=8 */
void* __toku_dummy0[18];
char __toku_dummy1[112];
int (*c_close) (DBC *); /* 32-bit offset=188 size=4, 64=bit offset=264 size=8 */
void* __toku_dummy2[1];
int (*c_del) (DBC *, u_int32_t); /* 32-bit offset=196 size=4, 64=bit offset=288 size=8 */
int (*c_del) (DBC *, u_int32_t); /* 32-bit offset=196 size=4, 64=bit offset=280 size=8 */
void* __toku_dummy3[1];
int (*c_get) (DBC *, DBT *, DBT *, u_int32_t); /* 32-bit offset=204 size=4, 64=bit offset=304 size=8 */
void* __toku_dummy4[11]; /* Padding at the end */
int (*c_get) (DBC *, DBT *, DBT *, u_int32_t); /* 32-bit offset=204 size=4, 64=bit offset=296 size=8 */
void* __toku_dummy4[10]; /* Padding at the end */
};
struct __toku_dbt {
void*data; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */
......
......@@ -84,7 +84,7 @@ int tokulogger_create_and_open_logger (const char *directory, TOKULOGGER *result
return tokulogger_log_bytes(result, 0, "");
}
int log_format_version=0;
static int log_format_version=0;
int tokulogger_log_bytes(TOKULOGGER logger, int nbytes, void *bytes) {
int r;
......@@ -556,7 +556,7 @@ int toku_logprint_LOGGEDBRTHEADER (FILE *outf, FILE *inf, const char *fieldname,
}
int read_and_print_logmagic (FILE *f, u_int32_t *versionp) {
int toku_read_and_print_logmagic (FILE *f, u_int32_t *versionp) {
{
char magic[8];
int r=fread(magic, 1, 8, f);
......
......@@ -49,7 +49,7 @@ int toku_logprint_u_int8_t (FILE *outf, FILE *inf, const char *fieldname,
int toku_logprint_u_int32_t (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len, const char *);
int toku_logprint_LOGGEDBRTHEADER (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len, const char *);
int read_and_print_logmagic (FILE *f, u_int32_t *version);
int toku_read_and_print_logmagic (FILE *f, u_int32_t *version);
TXNID toku_txn_get_txnid (TOKUTXN);
LSN toku_txn_get_last_lsn (TOKUTXN);
......
......@@ -135,7 +135,7 @@ void *toku_calloc(long nmemb, long size) {
return r;
}
#define FREELIST_LIMIT (64+1)
void *freelist[FREELIST_LIMIT];
static void *freelist[FREELIST_LIMIT];
#define MALLOC_SIZE_COUNTING_LIMIT 512
int malloc_counts[MALLOC_SIZE_COUNTING_LIMIT]; // We rely on static variables being initialized to 0.
......
......@@ -163,7 +163,7 @@ int main (int argc, char *argv[]) {
FILE *f = fopen(logfiles[i], "r");
struct log_entry le;
u_int32_t version;
r=read_and_print_logmagic(f, &version);
r=toku_read_and_print_logmagic(f, &version);
assert(r==0 && version==0);
while ((r = tokulog_fread(f, &le))==0) {
printf("Got cmd %c\n", le.cmd);
......
......@@ -129,7 +129,7 @@ void transcribe_header (void) {
static void newmain (int count) {
int i;
u_int32_t version;
int r = read_and_print_logmagic(stdin, &version);
int r = toku_read_and_print_logmagic(stdin, &version);
assert(r==0);
for (i=0; i!=count; i++) {
r = toku_logprint_one_record(stdout, stdin);
......
......@@ -3,7 +3,7 @@
#include "../include/db.h"
#include "../newbrt/brttypes.h"
#include "../newbrt/brt.h"
#include "../newbrt/list.h"
struct db_header {
int n_databases; // Or there can be >=1 named databases. This is the count.
......@@ -22,5 +22,8 @@ struct __toku_db_internal {
int open_mode;
BRT brt;
FILENUM fileid;
struct list associated; // All the associated databases. The primary is the head of the list.
DB *primary; // For secondary (associated) databases, what is the primary? NULL if not a secondary.
int(*associate_callback)(DB*, const DBT*, const DBT*, DBT*); // For secondary, the callback function for associate. NULL if not secondary
};
#endif
/* -*- mode: C; c-basic-offset: 4 -*- */
#include <assert.h>
#include <brt.h>
#include "ydb-internal.h"
#include <errno.h>
#include <limits.h>
#include <stdarg.h>
......@@ -16,7 +14,8 @@
#include <unistd.h>
#include <libgen.h>
#include "brt.h"
#include "ydb-internal.h"
#include "brt-internal.h"
#include "cachetable.h"
#include "log.h"
......@@ -400,14 +399,14 @@ int __toku_db_env_txn_stat(DB_ENV * env, DB_TXN_STAT ** statp, u_int32_t flags)
return 1;
}
void __toku_default_errcall(const char *errpfx, char *msg) {
void toku_default_errcall(const char *errpfx, char *msg) {
fprintf(stderr, "YDB: %s: %s", errpfx, msg);
}
static int __toku_txn_begin(DB_ENV * env, DB_TXN * stxn, DB_TXN ** txn, u_int32_t flags);
int db_env_create(DB_ENV ** envp, u_int32_t flags) {
DB_ENV *result = toku_malloc(sizeof(*result));
DB_ENV *MALLOC(result);
if (result == 0)
return ENOMEM;
memset(result, 0, sizeof *result);
......@@ -433,14 +432,14 @@ int db_env_create(DB_ENV ** envp, u_int32_t flags) {
result->txn_stat = __toku_db_env_txn_stat;
result->txn_begin = __toku_txn_begin;
result->i = toku_malloc(sizeof(*result->i));
MALLOC(result->i);
if (result->i == 0) {
toku_free(result);
return ENOMEM;
}
memset(result->i, 0, sizeof *result->i);
result->i->ref_count = 1;
result->i->errcall = __toku_default_errcall;
result->i->errcall = toku_default_errcall;
result->i->errpfx = toku_strdup("");
*envp = result;
......@@ -460,7 +459,7 @@ int __toku_db_txn_commit(DB_TXN * txn, u_int32_t flags) {
return 0;
}
u_int32_t __toku_db_txn_id(DB_TXN * txn) {
static u_int32_t toku_db_txn_id(DB_TXN * txn) {
barf();
abort();
}
......@@ -468,14 +467,14 @@ u_int32_t __toku_db_txn_id(DB_TXN * txn) {
static TXNID next_txn = 0;
static int __toku_txn_begin(DB_ENV * env, DB_TXN * stxn, DB_TXN ** txn, u_int32_t flags) {
DB_TXN *result = toku_malloc(sizeof(*result));
DB_TXN *MALLOC(result);
if (result == 0)
return ENOMEM;
memset(result, 0, sizeof *result);
//notef("parent=%p flags=0x%x\n", stxn, flags);
result->commit = __toku_db_txn_commit;
result->id = __toku_db_txn_id;
result->i = toku_malloc(sizeof(*result->i));
result->id = toku_db_txn_id;
MALLOC(result->i);
assert(result->i);
result->i->parent = stxn;
int r = tokutxn_begin(stxn ? stxn->i->tokutxn : 0, &result->i->tokutxn, next_txn++, env->i->logger);
......@@ -485,8 +484,8 @@ static int __toku_txn_begin(DB_ENV * env, DB_TXN * stxn, DB_TXN ** txn, u_int32_
return 0;
}
int __toku_txn_abort(DB_TXN * txn) {
fprintf(stderr, "__toku_txn_abort(%p)\n", txn);
static int toku_txn_abort(DB_TXN * txn) {
fprintf(stderr, "toku_txn_abort(%p)\n", txn);
abort();
}
......@@ -521,12 +520,12 @@ struct __toku_dbc_internal {
DB_TXN *txn;
};
int __toku_c_get(DBC * c, DBT * key, DBT * data, u_int32_t flag) {
static int toku_c_get(DBC * c, DBT * key, DBT * data, u_int32_t flag) {
int r = brt_cursor_get(c->i->c, key, data, flag, c->i->txn ? c->i->txn->i->tokutxn : 0);
return r;
}
int __toku_c_close(DBC * c) {
static int toku_c_close(DBC * c) {
int r = brt_cursor_close(c->i->c);
toku_free(c->i);
toku_free(c);
......@@ -539,14 +538,14 @@ int __toku_c_del(DBC * c, u_int32_t flags) {
}
int __toku_db_cursor(DB * db, DB_TXN * txn, DBC ** c, u_int32_t flags) {
DBC *result = toku_malloc(sizeof(*result));
DBC *MALLOC(result);
if (result == 0)
return ENOMEM;
memset(result, 0, sizeof *result);
result->c_get = __toku_c_get;
result->c_close = __toku_c_close;
result->c_get = toku_c_get;
result->c_close = toku_c_close;
result->c_del = __toku_c_del;
result->i = toku_malloc(sizeof(*result->i));
MALLOC(result->i);
assert(result->i);
result->i->db = db;
result->i->txn = txn;
......@@ -796,7 +795,7 @@ int db_create(DB ** db, DB_ENV * env, u_int32_t flags) {
assert(db_env_opened(env));
}
DB *result = toku_malloc(sizeof(*result));
DB *MALLOC(result);
if (result == 0) {
db_env_unref(env);
return ENOMEM;
......@@ -817,7 +816,7 @@ int db_create(DB ** db, DB_ENV * env, u_int32_t flags) {
result->set_pagesize = __toku_db_set_pagesize;
result->set_flags = __toku_db_set_flags;
result->stat = __toku_db_stat;
result->i = toku_malloc(sizeof(*result->i));
MALLOC(result->i);
if (result->i == 0) {
toku_free(result);
db_env_unref(env);
......@@ -832,6 +831,9 @@ int db_create(DB ** db, DB_ENV * env, u_int32_t flags) {
result->i->open_flags = 0;
result->i->open_mode = 0;
result->i->brt = 0;
list_init(&result->i->associated);
result->i->primary = 0;
result->i->associate_callback = 0;
r = brt_create(&result->i->brt);
if (r != 0) {
toku_free(result->i);
......
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