Commit 574016ff authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

More logging stuff

git-svn-id: file:///svn/tokudb@623 c7de825b-a66e-492c-adef-691d508d4ae1
parent de6a462f
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# GCOV_FLAGS = -fprofile-arcs -ftest-coverage # GCOV_FLAGS = -fprofile-arcs -ftest-coverage
# PROF_FLAGS = -pg # PROF_FLAGS = -pg
OPTFLAGS = -O2 # OPTFLAGS = -O2
ifeq ($(CYGWIN),cygwin) ifeq ($(CYGWIN),cygwin)
else else
...@@ -35,12 +35,14 @@ REGRESSION_TESTS = \ ...@@ -35,12 +35,14 @@ REGRESSION_TESTS = \
cachetable-test2 \ cachetable-test2 \
hashtest \ hashtest \
brt-test \ brt-test \
test_oexcl \
# This line intentially kept commented so I can have a \ on the end of the previous line # This line intentially kept commented so I can have a \ on the end of the previous line
BINS = $(REGRESSION_TESTS) \ BINS = $(REGRESSION_TESTS) \
benchmark-test \ benchmark-test \
randbrt \ randbrt \
randdb4 \ randdb4 \
logdump \
# This line intentially kept commented so I can have a \ on the end of the previous line # This line intentially kept commented so I can have a \ on the end of the previous line
logdump: LDFLAGS+=-lz logdump: LDFLAGS+=-lz
...@@ -48,6 +50,7 @@ logdump: LDFLAGS+=-lz ...@@ -48,6 +50,7 @@ logdump: LDFLAGS+=-lz
libs: log.o libs: log.o
bins: $(BINS) bins: $(BINS)
check: bins check: bins
$(DTOOL) ./test_oexcl
$(DTOOL) ./ybt-test $(DTOOL) ./ybt-test
$(DTOOL) ./pma-test $(DTOOL) ./pma-test
$(DTOOL) ./cachetable-test $(DTOOL) ./cachetable-test
...@@ -111,6 +114,7 @@ benchmark-test.o: brt.h ../include/db.h ...@@ -111,6 +114,7 @@ benchmark-test.o: brt.h ../include/db.h
clean: clean:
rm -rf $(REGRESSION_TESTS) $(BINS) *.o *.bb *.bbg *.da rm -rf $(REGRESSION_TESTS) $(BINS) *.o *.bb *.bbg *.da
rm -rf test_oexcl.c.tmp
randdb4: LOADLIBES=-ldb randdb4: LOADLIBES=-ldb
randbrt: brt.o hashtable.o cachetable.o memory.o brt-serialize.o randbrt: brt.o hashtable.o cachetable.o memory.o brt-serialize.o
......
...@@ -31,7 +31,7 @@ void setup (void) { ...@@ -31,7 +31,7 @@ void setup (void) {
int r; int r;
unlink(fname); unlink(fname);
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(fname, 0, 1, &t, nodesize, ct, default_compare_fun); assert(r==0); r = open_brt(fname, 0, 1, &t, nodesize, ct, NULL_TXN, default_compare_fun); assert(r==0);
} }
void shutdown (void) { void shutdown (void) {
......
...@@ -28,7 +28,7 @@ static void test0 (void) { ...@@ -28,7 +28,7 @@ static void test0 (void) {
assert(r==0); assert(r==0);
printf("%s:%d test0\n", __FILE__, __LINE__); printf("%s:%d test0\n", __FILE__, __LINE__);
unlink(fname); unlink(fname);
r = open_brt(fname, 0, 1, &t, 1024, ct, default_compare_fun); r = open_brt(fname, 0, 1, &t, 1024, ct, null_txn, default_compare_fun);
assert(r==0); assert(r==0);
//printf("%s:%d test0\n", __FILE__, __LINE__); //printf("%s:%d test0\n", __FILE__, __LINE__);
//printf("%s:%d n_items_malloced=%lld\n", __FILE__, __LINE__, n_items_malloced); //printf("%s:%d n_items_malloced=%lld\n", __FILE__, __LINE__, n_items_malloced);
...@@ -50,7 +50,7 @@ static void test1 (void) { ...@@ -50,7 +50,7 @@ static void test1 (void) {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
r = open_brt(fname, 0, 1, &t, 1024, ct, default_compare_fun); r = open_brt(fname, 0, 1, &t, 1024, ct, null_txn, default_compare_fun);
assert(r==0); assert(r==0);
brt_insert(t, fill_dbt(&k, "hello", 6), fill_dbt(&v, "there", 6), null_db, null_txn); brt_insert(t, fill_dbt(&k, "hello", 6), fill_dbt(&v, "there", 6), null_db, null_txn);
{ {
...@@ -76,7 +76,7 @@ static void test2 (int memcheck) { ...@@ -76,7 +76,7 @@ static void test2 (int memcheck) {
memory_check_all_free(); memory_check_all_free();
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
unlink(fname); unlink(fname);
r = open_brt(fname, 0, 1, &t, 1024, ct, default_compare_fun); r = open_brt(fname, 0, 1, &t, 1024, ct, null_txn, default_compare_fun);
printf("%s:%d did setup\n", __FILE__, __LINE__); printf("%s:%d did setup\n", __FILE__, __LINE__);
assert(r==0); assert(r==0);
for (i=0; i<2048; i++) { for (i=0; i<2048; i++) {
...@@ -115,7 +115,7 @@ static void test3 (int nodesize, int count, int memcheck) { ...@@ -115,7 +115,7 @@ static void test3 (int nodesize, int count, int memcheck) {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
gettimeofday(&t0, 0); gettimeofday(&t0, 0);
unlink(fname); unlink(fname);
r = open_brt(fname, 0, 1, &t, nodesize, ct, default_compare_fun); r = open_brt(fname, 0, 1, &t, nodesize, ct, null_txn, default_compare_fun);
assert(r==0); assert(r==0);
for (i=0; i<count; i++) { for (i=0; i<count; i++) {
char key[100],val[100]; char key[100],val[100];
...@@ -146,7 +146,7 @@ static void test4 (int nodesize, int count, int memcheck) { ...@@ -146,7 +146,7 @@ static void test4 (int nodesize, int count, int memcheck) {
memory_check=memcheck; memory_check=memcheck;
memory_check_all_free(); memory_check_all_free();
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(fname, 0, 1, &t, nodesize, ct, default_compare_fun); assert(r==0); r = open_brt(fname, 0, 1, &t, nodesize, ct, null_txn, default_compare_fun); assert(r==0);
for (i=0; i<count; i++) { for (i=0; i<count; i++) {
char key[100],val[100]; char key[100],val[100];
int rv = random(); int rv = random();
...@@ -178,7 +178,7 @@ static void test5 (void) { ...@@ -178,7 +178,7 @@ static void test5 (void) {
for (i=0; i<limit; i++) values[i]=-1; for (i=0; i<limit; i++) values[i]=-1;
unlink(fname); unlink(fname);
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(fname, 0, 1, &t, 1<<12, ct, default_compare_fun); assert(r==0); r = open_brt(fname, 0, 1, &t, 1<<12, ct, null_txn, default_compare_fun); assert(r==0);
for (i=0; i<limit/2; i++) { for (i=0; i<limit/2; i++) {
char key[100],val[100]; char key[100],val[100];
int rk = random()%limit; int rk = random()%limit;
...@@ -221,7 +221,7 @@ static void test_dump_empty_db (void) { ...@@ -221,7 +221,7 @@ static void test_dump_empty_db (void) {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
r = open_brt(fname, 0, 1, &t, 1024, ct, default_compare_fun); r = open_brt(fname, 0, 1, &t, 1024, ct, null_txn, default_compare_fun);
assert(r==0); assert(r==0);
dump_brt(t); dump_brt(t);
r = close_brt(t); assert(r==0); r = close_brt(t); assert(r==0);
...@@ -241,8 +241,8 @@ static void test_multiple_files_of_size (int size) { ...@@ -241,8 +241,8 @@ static void test_multiple_files_of_size (int size) {
unlink(n1); unlink(n1);
memory_check_all_free(); memory_check_all_free();
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n0, 0, 1, &t0, size, ct, default_compare_fun); assert(r==0); r = open_brt(n0, 0, 1, &t0, size, ct, null_txn, default_compare_fun); assert(r==0);
r = open_brt(n1, 0, 1, &t1, size, ct, default_compare_fun); assert(r==0); r = open_brt(n1, 0, 1, &t1, size, ct, null_txn, default_compare_fun); assert(r==0);
for (i=0; i<10000; i++) { for (i=0; i<10000; i++) {
char key[100],val[100]; char key[100],val[100];
DBT k,v; DBT k,v;
...@@ -265,10 +265,10 @@ static void test_multiple_files_of_size (int size) { ...@@ -265,10 +265,10 @@ static void test_multiple_files_of_size (int size) {
/* Now see if the data is all there. */ /* Now see if the data is all there. */
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n0, 0, 0, &t0, 1<<12, ct, default_compare_fun); r = open_brt(n0, 0, 0, &t0, 1<<12, ct, null_txn, default_compare_fun);
printf("%s:%d r=%d\n", __FILE__, __LINE__,r); printf("%s:%d r=%d\n", __FILE__, __LINE__,r);
assert(r==0); assert(r==0);
r = open_brt(n1, 0, 0, &t1, 1<<12, ct, default_compare_fun); assert(r==0); r = open_brt(n1, 0, 0, &t1, 1<<12, ct, null_txn, default_compare_fun); assert(r==0);
for (i=0; i<10000; i++) { for (i=0; i<10000; i++) {
char key[100],val[100]; char key[100],val[100];
...@@ -310,7 +310,7 @@ static void test_named_db (void) { ...@@ -310,7 +310,7 @@ static void test_named_db (void) {
unlink(n1); unlink(n1);
memory_check_all_free(); memory_check_all_free();
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n0, "db1", 1, &t0, 1<<12, ct, default_compare_fun); assert(r==0); r = open_brt(n0, "db1", 1, &t0, 1<<12, ct, null_txn, default_compare_fun); assert(r==0);
brt_insert(t0, fill_dbt(&k, "good", 5), fill_dbt(&v, "day", 4), null_db, null_txn); assert(r==0); brt_insert(t0, fill_dbt(&k, "good", 5), fill_dbt(&v, "day", 4), null_db, null_txn); assert(r==0);
...@@ -321,7 +321,7 @@ static void test_named_db (void) { ...@@ -321,7 +321,7 @@ static void test_named_db (void) {
memory_check_all_free(); memory_check_all_free();
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n0, "db1", 0, &t0, 1<<12, ct, default_compare_fun); assert(r==0); r = open_brt(n0, "db1", 0, &t0, 1<<12, ct, null_txn, default_compare_fun); assert(r==0);
{ {
r = brt_lookup(t0, fill_dbt(&k, "good", 5), init_dbt(&v), 0); r = brt_lookup(t0, fill_dbt(&k, "good", 5), init_dbt(&v), 0);
...@@ -347,8 +347,8 @@ static void test_multiple_dbs (void) { ...@@ -347,8 +347,8 @@ static void test_multiple_dbs (void) {
unlink(n1); unlink(n1);
memory_check_all_free(); memory_check_all_free();
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n0, "db1", 1, &t0, 1<<12, ct, default_compare_fun); assert(r==0); r = open_brt(n0, "db1", 1, &t0, 1<<12, ct, null_txn, default_compare_fun); assert(r==0);
r = open_brt(n1, "db2", 1, &t1, 1<<12, ct, default_compare_fun); assert(r==0); r = open_brt(n1, "db2", 1, &t1, 1<<12, ct, null_txn, default_compare_fun); assert(r==0);
brt_insert(t0, fill_dbt(&k, "good", 5), fill_dbt(&v, "grief", 6), null_db, null_txn); assert(r==0); brt_insert(t0, fill_dbt(&k, "good", 5), fill_dbt(&v, "grief", 6), null_db, null_txn); assert(r==0);
brt_insert(t1, fill_dbt(&k, "bad", 4), fill_dbt(&v, "night", 6), null_db, null_txn); assert(r==0); brt_insert(t1, fill_dbt(&k, "bad", 4), fill_dbt(&v, "night", 6), null_db, null_txn); assert(r==0);
...@@ -360,8 +360,8 @@ static void test_multiple_dbs (void) { ...@@ -360,8 +360,8 @@ static void test_multiple_dbs (void) {
memory_check_all_free(); memory_check_all_free();
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n0, "db1", 0, &t0, 1<<12, ct, default_compare_fun); assert(r==0); r = open_brt(n0, "db1", 0, &t0, 1<<12, ct, null_txn, default_compare_fun); assert(r==0);
r = open_brt(n1, "db2", 0, &t1, 1<<12, ct, default_compare_fun); assert(r==0); r = open_brt(n1, "db2", 0, &t1, 1<<12, ct, null_txn, default_compare_fun); assert(r==0);
{ {
r = brt_lookup(t0, fill_dbt(&k, "good", 5), init_dbt(&v), 0); r = brt_lookup(t0, fill_dbt(&k, "good", 5), init_dbt(&v), 0);
...@@ -403,7 +403,7 @@ static void test_multiple_dbs_many (void) { ...@@ -403,7 +403,7 @@ static void test_multiple_dbs_many (void) {
for (i=0; i<MANYN; i++) { for (i=0; i<MANYN; i++) {
char dbname[20]; char dbname[20];
snprintf(dbname, 20, "db%d", i); snprintf(dbname, 20, "db%d", i);
r = open_brt(name, dbname, 1, &trees[i], 1<<12, ct, default_compare_fun); r = open_brt(name, dbname, 1, &trees[i], 1<<12, ct, null_txn, default_compare_fun);
assert(r==0); assert(r==0);
} }
for (i=0; i<MANYN; i++) { for (i=0; i<MANYN; i++) {
...@@ -432,7 +432,7 @@ static void test_multiple_brts_one_db_one_file (void) { ...@@ -432,7 +432,7 @@ static void test_multiple_brts_one_db_one_file (void) {
unlink(name); unlink(name);
r = brt_create_cachetable(&ct, 32, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 32, ZERO_LSN, NULL_LOGGER); assert(r==0);
for (i=0; i<MANYN; i++) { for (i=0; i<MANYN; i++) {
r = open_brt(name, 0, (i==0), &trees[i], 1<<12, ct, default_compare_fun); r = open_brt(name, 0, (i==0), &trees[i], 1<<12, ct, null_txn, default_compare_fun);
assert(r==0); assert(r==0);
} }
for (i=0; i<MANYN; i++) { for (i=0; i<MANYN; i++) {
...@@ -475,7 +475,7 @@ static void test_read_what_was_written (void) { ...@@ -475,7 +475,7 @@ static void test_read_what_was_written (void) {
memory_check_all_free(); memory_check_all_free();
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n, 0, 1, &brt, 1<<12, ct, default_compare_fun); assert(r==0); r = open_brt(n, 0, 1, &brt, 1<<12, ct, null_txn, default_compare_fun); assert(r==0);
r = close_brt(brt); assert(r==0); r = close_brt(brt); assert(r==0);
r = cachetable_close(&ct); assert(r==0); r = cachetable_close(&ct); assert(r==0);
...@@ -483,7 +483,7 @@ static void test_read_what_was_written (void) { ...@@ -483,7 +483,7 @@ static void test_read_what_was_written (void) {
/* Now see if we can read an empty tree in. */ /* Now see if we can read an empty tree in. */
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n, 0, 0, &brt, 1<<12, ct, default_compare_fun); assert(r==0); r = open_brt(n, 0, 0, &brt, 1<<12, ct, null_txn, default_compare_fun); assert(r==0);
/* See if we can put something in it. */ /* See if we can put something in it. */
{ {
...@@ -498,7 +498,7 @@ static void test_read_what_was_written (void) { ...@@ -498,7 +498,7 @@ static void test_read_what_was_written (void) {
/* Now see if we can read it in and get the value. */ /* Now see if we can read it in and get the value. */
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n, 0, 0, &brt, 1<<12, ct, default_compare_fun); assert(r==0); r = open_brt(n, 0, 0, &brt, 1<<12, ct, null_txn, default_compare_fun); assert(r==0);
{ {
DBT k,v; DBT k,v;
...@@ -574,7 +574,7 @@ static void test_read_what_was_written (void) { ...@@ -574,7 +574,7 @@ static void test_read_what_was_written (void) {
memory_check_all_free(); memory_check_all_free();
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n, 0, 0, &brt, 1<<12, ct, default_compare_fun); assert(r==0); r = open_brt(n, 0, 0, &brt, 1<<12, ct, null_txn, default_compare_fun); assert(r==0);
{ {
DBT k,v; DBT k,v;
...@@ -622,7 +622,7 @@ void test_cursor_last_empty(void) { ...@@ -622,7 +622,7 @@ void test_cursor_last_empty(void) {
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items(); //printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items(); //printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
r = open_brt(n, 0, 1, &brt, 1<<12, ct, default_compare_fun); assert(r==0); r = open_brt(n, 0, 1, &brt, 1<<12, ct, null_txn, default_compare_fun); assert(r==0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items(); //printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
r = brt_cursor(brt, &cursor); assert(r==0); r = brt_cursor(brt, &cursor); assert(r==0);
init_dbt(&kbt); init_dbt(&kbt);
...@@ -654,7 +654,7 @@ void test_cursor_next (void) { ...@@ -654,7 +654,7 @@ void test_cursor_next (void) {
memory_check_all_free(); memory_check_all_free();
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items(); //printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
r = open_brt(n, 0, 1, &brt, 1<<12, ct, default_compare_fun); assert(r==0); r = open_brt(n, 0, 1, &brt, 1<<12, ct, null_txn, default_compare_fun); assert(r==0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items(); //printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
r = brt_insert(brt, fill_dbt(&kbt, "hello", 6), fill_dbt(&vbt, "there", 6), null_db, null_txn); r = brt_insert(brt, fill_dbt(&kbt, "hello", 6), fill_dbt(&vbt, "there", 6), null_db, null_txn);
r = brt_insert(brt, fill_dbt(&kbt, "byebye", 7), fill_dbt(&vbt, "byenow", 7), null_db, null_txn); r = brt_insert(brt, fill_dbt(&kbt, "byebye", 7), fill_dbt(&vbt, "byenow", 7), null_db, null_txn);
...@@ -734,7 +734,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) { ...@@ -734,7 +734,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
//printf("%s:%d WRONG=%d\n", __FILE__, __LINE__, wrong_p); //printf("%s:%d WRONG=%d\n", __FILE__, __LINE__, wrong_p);
if (0) { // ???? Why is this commented out? if (0) { // ???? Why is this commented out?
r = open_brt(n, 0, 1, &brt, 1<<20, ct, wrong_p ? wrong_compare_fun : default_compare_fun); assert(r==0); r = open_brt(n, 0, 1, &brt, 1<<20, ct, null_txn, wrong_p ? wrong_compare_fun : default_compare_fun); assert(r==0);
for (i=1; i<257; i+=255) { for (i=1; i<257; i+=255) {
unsigned char a[4],b[4]; unsigned char a[4],b[4];
b[3] = a[0] = i&255; b[3] = a[0] = i&255;
...@@ -767,7 +767,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) { ...@@ -767,7 +767,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
{ {
cachetable_verify(ct); cachetable_verify(ct);
r = open_brt(n, 0, 1, &brt, 1<<20, ct, wrong_p ? wrong_compare_fun : default_compare_fun); assert(r==0); r = open_brt(n, 0, 1, &brt, 1<<20, ct, null_txn, wrong_p ? wrong_compare_fun : default_compare_fun); assert(r==0);
cachetable_verify(ct); cachetable_verify(ct);
for (i=0; i<N; i++) { for (i=0; i<N; i++) {
...@@ -915,7 +915,7 @@ void test_brt_cursor_first(int n, DB *db) { ...@@ -915,7 +915,7 @@ void test_brt_cursor_first(int n, DB *db) {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
r = open_brt(fname, 0, 1, &brt, 1<<12, ct, test_brt_cursor_keycompare); r = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare);
assert(r==0); assert(r==0);
/* insert a bunch of kv pairs */ /* insert a bunch of kv pairs */
...@@ -957,7 +957,7 @@ void test_brt_cursor_last(int n, DB *db) { ...@@ -957,7 +957,7 @@ void test_brt_cursor_last(int n, DB *db) {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
r = open_brt(fname, 0, 1, &brt, 1<<12, ct, test_brt_cursor_keycompare); r = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare);
assert(r==0); assert(r==0);
/* insert keys 0, 1, .. (n-1) */ /* insert keys 0, 1, .. (n-1) */
...@@ -999,7 +999,7 @@ void test_brt_cursor_first_last(int n, DB *db) { ...@@ -999,7 +999,7 @@ void test_brt_cursor_first_last(int n, DB *db) {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
r = open_brt(fname, 0, 1, &brt, 1<<12, ct, test_brt_cursor_keycompare); r = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare);
assert(r==0); assert(r==0);
/* insert a bunch of kv pairs */ /* insert a bunch of kv pairs */
...@@ -1045,7 +1045,7 @@ void test_brt_cursor_rfirst(int n, DB *db) { ...@@ -1045,7 +1045,7 @@ void test_brt_cursor_rfirst(int n, DB *db) {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
r = open_brt(fname, 0, 1, &brt, 1<<12, ct, test_brt_cursor_keycompare); r = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare);
assert(r==0); assert(r==0);
/* insert keys n-1, n-2, ... , 0 */ /* insert keys n-1, n-2, ... , 0 */
...@@ -1120,7 +1120,7 @@ void test_brt_cursor_walk(int n, DB *db) { ...@@ -1120,7 +1120,7 @@ void test_brt_cursor_walk(int n, DB *db) {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
r = open_brt(fname, 0, 1, &brt, 1<<12, ct, test_brt_cursor_keycompare); r = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare);
assert(r==0); assert(r==0);
/* insert a bunch of kv pairs */ /* insert a bunch of kv pairs */
...@@ -1193,7 +1193,7 @@ void test_brt_cursor_rwalk(int n, DB *db) { ...@@ -1193,7 +1193,7 @@ void test_brt_cursor_rwalk(int n, DB *db) {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
r = open_brt(fname, 0, 1, &brt, 1<<12, ct, test_brt_cursor_keycompare); r = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare);
assert(r==0); assert(r==0);
/* insert a bunch of kv pairs */ /* insert a bunch of kv pairs */
...@@ -1272,7 +1272,7 @@ void test_brt_cursor_rand(int n, DB *db) { ...@@ -1272,7 +1272,7 @@ void test_brt_cursor_rand(int n, DB *db) {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
r = open_brt(fname, 0, 1, &brt, 1<<12, ct, test_brt_cursor_keycompare); r = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare);
assert(r==0); assert(r==0);
/* insert a bunch of kv pairs */ /* insert a bunch of kv pairs */
...@@ -1325,7 +1325,7 @@ void test_brt_cursor_split(int n, DB *db) { ...@@ -1325,7 +1325,7 @@ void test_brt_cursor_split(int n, DB *db) {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
r = open_brt(fname, 0, 1, &brt, 1<<12, ct, test_brt_cursor_keycompare); r = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare);
assert(r==0); assert(r==0);
/* insert a bunch of kv pairs */ /* insert a bunch of kv pairs */
...@@ -1403,7 +1403,7 @@ void test_multiple_brt_cursors(int n, DB *db) { ...@@ -1403,7 +1403,7 @@ void test_multiple_brt_cursors(int n, DB *db) {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
r = open_brt(fname, 0, 1, &brt, 1<<12, ct, test_brt_cursor_keycompare); r = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare);
assert(r==0); assert(r==0);
int i; int i;
...@@ -1453,7 +1453,7 @@ void test_multiple_brt_cursor_walk(int n, DB *db) { ...@@ -1453,7 +1453,7 @@ void test_multiple_brt_cursor_walk(int n, DB *db) {
r = brt_create_cachetable(&ct, cachesize, ZERO_LSN, NULL_LOGGER); r = brt_create_cachetable(&ct, cachesize, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
r = open_brt(fname, 0, 1, &brt, 1<<12, ct, test_brt_cursor_keycompare); r = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare);
assert(r==0); assert(r==0);
int c; int c;
...@@ -1535,7 +1535,7 @@ void test_brt_cursor_set(int n, int cursor_op, DB *db) { ...@@ -1535,7 +1535,7 @@ void test_brt_cursor_set(int n, int cursor_op, DB *db) {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
r = open_brt(fname, 0, 1, &brt, 1<<12, ct, test_brt_cursor_keycompare); r = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare);
assert(r==0); assert(r==0);
int i; int i;
...@@ -1606,7 +1606,7 @@ void test_brt_cursor_set_range(int n, DB *db) { ...@@ -1606,7 +1606,7 @@ void test_brt_cursor_set_range(int n, DB *db) {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
r = open_brt(fname, 0, 1, &brt, 1<<12, ct, test_brt_cursor_keycompare); r = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare);
assert(r==0); assert(r==0);
int i; int i;
...@@ -1673,7 +1673,7 @@ void test_brt_cursor_delete(int n, DB *db) { ...@@ -1673,7 +1673,7 @@ void test_brt_cursor_delete(int n, DB *db) {
error = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); error = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(error == 0); assert(error == 0);
error = open_brt(fname, 0, 1, &brt, 1<<12, ct, test_brt_cursor_keycompare); error = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare);
assert(error == 0); assert(error == 0);
error = brt_cursor(brt, &cursor); error = brt_cursor(brt, &cursor);
...@@ -1735,7 +1735,7 @@ void test_brt_cursor_get_both(int n, DB *db) { ...@@ -1735,7 +1735,7 @@ void test_brt_cursor_get_both(int n, DB *db) {
error = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); error = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(error == 0); assert(error == 0);
error = open_brt(fname, 0, 1, &brt, 1<<12, ct, test_brt_cursor_keycompare); error = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare);
assert(error == 0); assert(error == 0);
error = brt_cursor(brt, &cursor); error = brt_cursor(brt, &cursor);
...@@ -1887,7 +1887,7 @@ void test_large_kv(int bsize, int ksize, int vsize) { ...@@ -1887,7 +1887,7 @@ void test_large_kv(int bsize, int ksize, int vsize) {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
r = open_brt(fname, 0, 1, &t, bsize, ct, default_compare_fun); r = open_brt(fname, 0, 1, &t, bsize, ct, null_txn, default_compare_fun);
assert(r==0); assert(r==0);
DBT key, val; DBT key, val;
...@@ -1934,7 +1934,7 @@ void test_brt_delete_empty() { ...@@ -1934,7 +1934,7 @@ void test_brt_delete_empty() {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
r = open_brt(fname, 0, 1, &t, 4096, ct, default_compare_fun); r = open_brt(fname, 0, 1, &t, 4096, ct, null_txn, default_compare_fun);
assert(r==0); assert(r==0);
DBT key; DBT key;
...@@ -1963,7 +1963,7 @@ void test_brt_delete_present(int n) { ...@@ -1963,7 +1963,7 @@ void test_brt_delete_present(int n) {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
r = open_brt(fname, 0, 1, &t, 4096, ct, default_compare_fun); r = open_brt(fname, 0, 1, &t, 4096, ct, null_txn, default_compare_fun);
assert(r==0); assert(r==0);
DBT key, val; DBT key, val;
...@@ -2025,7 +2025,7 @@ void test_brt_delete_not_present(int n) { ...@@ -2025,7 +2025,7 @@ void test_brt_delete_not_present(int n) {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
r = open_brt(fname, 0, 1, &t, 4096, ct, default_compare_fun); r = open_brt(fname, 0, 1, &t, 4096, ct, null_txn, default_compare_fun);
assert(r==0); assert(r==0);
DBT key, val; DBT key, val;
...@@ -2072,7 +2072,7 @@ void test_brt_delete_cursor_first(int n) { ...@@ -2072,7 +2072,7 @@ void test_brt_delete_cursor_first(int n) {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
r = open_brt(fname, 0, 1, &t, 4096, ct, default_compare_fun); r = open_brt(fname, 0, 1, &t, 4096, ct, null_txn, default_compare_fun);
assert(r==0); assert(r==0);
DBT key, val; DBT key, val;
...@@ -2164,7 +2164,7 @@ void test_insert_delete_lookup(int n) { ...@@ -2164,7 +2164,7 @@ void test_insert_delete_lookup(int n) {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
r = open_brt(fname, 0, 1, &t, 4096, ct, default_compare_fun); r = open_brt(fname, 0, 1, &t, 4096, ct, null_txn, default_compare_fun);
assert(r==0); assert(r==0);
DBT key, val; DBT key, val;
......
...@@ -1237,7 +1237,7 @@ int brt_set_dup_compare(BRT brt, int (*dup_compare)(DB *, const DBT*, const DBT* ...@@ -1237,7 +1237,7 @@ int brt_set_dup_compare(BRT brt, int (*dup_compare)(DB *, const DBT*, const DBT*
return 0; return 0;
} }
int brt_open(BRT t, const char *fname, const char *dbname, int is_create, CACHETABLE cachetable) { int brt_open(BRT t, const char *fname, const char *dbname, int is_create, CACHETABLE cachetable, TOKUTXN txn __attribute__((__unused__))) {
/* If dbname is NULL then we setup to hold a single tree. Otherwise we setup an array. */ /* If dbname is NULL then we setup to hold a single tree. Otherwise we setup an array. */
int r; int r;
...@@ -1389,7 +1389,7 @@ int brt_remove_subdb(BRT brt, const char *dbname, u_int32_t flags) { ...@@ -1389,7 +1389,7 @@ int brt_remove_subdb(BRT brt, const char *dbname, u_int32_t flags) {
return r ? r : r2; return r ? r : r2;
} }
int open_brt (const char *fname, const char *dbname, int is_create, BRT *newbrt, int nodesize, CACHETABLE cachetable, int open_brt (const char *fname, const char *dbname, int is_create, BRT *newbrt, int nodesize, CACHETABLE cachetable, TOKUTXN txn,
int (*compare_fun)(DB*,const DBT*,const DBT*)) { int (*compare_fun)(DB*,const DBT*,const DBT*)) {
BRT brt; BRT brt;
int r; int r;
...@@ -1400,7 +1400,7 @@ int open_brt (const char *fname, const char *dbname, int is_create, BRT *newbrt, ...@@ -1400,7 +1400,7 @@ int open_brt (const char *fname, const char *dbname, int is_create, BRT *newbrt,
brt_set_nodesize(brt, nodesize); brt_set_nodesize(brt, nodesize);
brt_set_bt_compare(brt, compare_fun); brt_set_bt_compare(brt, compare_fun);
r = brt_open(brt, fname, dbname, is_create, cachetable); r = brt_open(brt, fname, dbname, is_create, cachetable, txn);
if (r != 0) { if (r != 0) {
return r; return r;
} }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "cachetable.h" #include "cachetable.h"
#include "log.h" #include "log.h"
typedef struct brt *BRT; typedef struct brt *BRT;
int open_brt (const char *fname, const char *dbname, int is_create, BRT *, int nodesize, CACHETABLE, int(*)(DB*,const DBT*,const DBT*)); int open_brt (const char *fname, const char *dbname, int is_create, BRT *, int nodesize, CACHETABLE, TOKUTXN, int(*)(DB*,const DBT*,const DBT*));
int brt_create(BRT *); int brt_create(BRT *);
int brt_set_flags(BRT, int flags); int brt_set_flags(BRT, int flags);
...@@ -18,7 +18,7 @@ int brt_set_nodesize(BRT, int nodesize); ...@@ -18,7 +18,7 @@ int brt_set_nodesize(BRT, int nodesize);
int brt_set_bt_compare(BRT, int (*bt_compare)(DB *, const DBT*, const DBT*)); int brt_set_bt_compare(BRT, int (*bt_compare)(DB *, const DBT*, const DBT*));
int brt_set_dup_compare(BRT, int (*dup_compare)(DB *, const DBT*, const DBT*)); int brt_set_dup_compare(BRT, int (*dup_compare)(DB *, const DBT*, const DBT*));
int brt_set_cachetable(BRT, CACHETABLE); int brt_set_cachetable(BRT, CACHETABLE);
int brt_open(BRT, const char *fname, const char *dbname, int is_create, CACHETABLE ct); int brt_open(BRT, const char *fname, const char *dbname, int is_create, CACHETABLE ct, TOKUTXN txn);
int brt_remove_subdb(BRT brt, const char *dbname, u_int32_t flags); int brt_remove_subdb(BRT brt, const char *dbname, u_int32_t flags);
int brt_insert (BRT, DBT *, DBT *, DB*, TOKUTXN); int brt_insert (BRT, DBT *, DBT *, DB*, TOKUTXN);
......
...@@ -22,6 +22,6 @@ typedef enum __toku_bool { FALSE=0, TRUE=1} BOOL; ...@@ -22,6 +22,6 @@ typedef enum __toku_bool { FALSE=0, TRUE=1} BOOL;
typedef struct tokulogger *TOKULOGGER; typedef struct tokulogger *TOKULOGGER;
#define NULL_LOGGER ((TOKULOGGER)0) #define NULL_LOGGER ((TOKULOGGER)0)
typedef struct tokutxn *TOKUTXN; typedef struct tokutxn *TOKUTXN;
#define NULL_TXN ((TOKUTXN)0)
#endif #endif
...@@ -86,13 +86,11 @@ int create_cachetable(CACHETABLE *result, long size_limit, LSN initial_lsn, TOKU ...@@ -86,13 +86,11 @@ int create_cachetable(CACHETABLE *result, long size_limit, LSN initial_lsn, TOKU
return 0; return 0;
} }
int cachetable_openf (CACHEFILE *cf, CACHETABLE t, const char *fname, int flags, mode_t mode) { static int cachetable_openfd (CACHEFILE *cf, CACHETABLE t, int fd) {
int r; int r;
CACHEFILE extant; CACHEFILE extant;
struct stat statbuf; struct stat statbuf;
struct fileid fileid; struct fileid fileid;
int fd = open(fname, flags, mode);
if (fd<0) return errno;
memset(&fileid, 0, sizeof(fileid)); memset(&fileid, 0, sizeof(fileid));
r=fstat(fd, &statbuf); r=fstat(fd, &statbuf);
assert(r==0); assert(r==0);
...@@ -120,6 +118,12 @@ int cachetable_openf (CACHEFILE *cf, CACHETABLE t, const char *fname, int flags, ...@@ -120,6 +118,12 @@ int cachetable_openf (CACHEFILE *cf, CACHETABLE t, const char *fname, int flags,
} }
} }
int cachetable_openf (CACHEFILE *cf, CACHETABLE t, const char *fname, int flags, mode_t mode) {
int fd = open(fname, flags, mode);
if (fd<0) return errno;
return cachetable_openfd (cf, t, fd);
}
CACHEFILE remove_cf_from_list (CACHEFILE cf, CACHEFILE list) { CACHEFILE remove_cf_from_list (CACHEFILE cf, CACHEFILE list) {
if (list==0) return 0; if (list==0) return 0;
else if (list==cf) { else if (list==cf) {
......
...@@ -23,7 +23,9 @@ enum { ...@@ -23,7 +23,9 @@ enum {
LT_DELETE = 'D', LT_DELETE = 'D',
LT_INSERT_WITH_NO_OVERWRITE = 'I', LT_INSERT_WITH_NO_OVERWRITE = 'I',
LT_CHECKPOINT = 'P', LT_CHECKPOINT = 'P',
LT_BLOCK_RENAME = 'R' LT_BLOCK_RENAME = 'R',
LT_FCREATE_TMP = 'T',
LT_UNLINK = 'U'
}; };
struct tokutxn { struct tokutxn {
......
...@@ -58,7 +58,7 @@ int tokulogger_log_bytes(TOKULOGGER logger, int nbytes, void *bytes) { ...@@ -58,7 +58,7 @@ int tokulogger_log_bytes(TOKULOGGER logger, int nbytes, void *bytes) {
int fnamelen = strlen(logger->directory)+50; int fnamelen = strlen(logger->directory)+50;
char fname[fnamelen]; char fname[fnamelen];
snprintf(fname, fnamelen, "%s/log%012llu.tokulog", logger->directory, logger->next_log_file_number); snprintf(fname, fnamelen, "%s/log%012llu.tokulog", logger->directory, logger->next_log_file_number);
fprintf(stderr, "%s:%d creat(%s, ...)\n", __FILE__, __LINE__, fname); //fprintf(stderr, "%s:%d creat(%s, ...)\n", __FILE__, __LINE__, fname);
logger->fd = creat(fname, O_EXCL | 0700); logger->fd = creat(fname, O_EXCL | 0700);
if (logger->fd==-1) return errno; if (logger->fd==-1) return errno;
logger->next_log_file_number++; logger->next_log_file_number++;
...@@ -92,7 +92,7 @@ int tokulogger_log_close(TOKULOGGER *loggerp) { ...@@ -92,7 +92,7 @@ int tokulogger_log_close(TOKULOGGER *loggerp) {
TOKULOGGER logger = *loggerp; TOKULOGGER logger = *loggerp;
int r = 0; int r = 0;
if (logger->fd!=-1) { if (logger->fd!=-1) {
printf("%s:%d closing log: n_in_buf=%d\n", __FILE__, __LINE__, logger->n_in_buf); //printf("%s:%d closing log: n_in_buf=%d\n", __FILE__, __LINE__, logger->n_in_buf);
if (logger->n_in_buf>0) { if (logger->n_in_buf>0) {
r = write(logger->fd, logger->buf, logger->n_in_buf); r = write(logger->fd, logger->buf, logger->n_in_buf);
if (r==-1) return errno; if (r==-1) return errno;
...@@ -263,6 +263,41 @@ int tokulogger_log_block_rename (TOKULOGGER logger, FILENUM fileid, DISKOFF oldd ...@@ -263,6 +263,41 @@ int tokulogger_log_block_rename (TOKULOGGER logger, FILENUM fileid, DISKOFF oldd
return tokulogger_finish(logger, &wbuf); return tokulogger_finish(logger, &wbuf);
} }
int tokulogger_log_fcreate_tmp (TOKUTXN txn, const char *fname, int mode) {
if (txn==0) return 0;
const int fnamelen = strlen(fname);
const int buflen = (+1 // log command
+4 // length of fname
+fnamelen
+4 // mode
+8 // crc & len
);
unsigned char buf[buflen];
struct wbuf wbuf;
wbuf_init (&wbuf, buf, buflen);
wbuf_char (&wbuf, LT_FCREATE_TMP);
wbuf_bytes(&wbuf, fname, fnamelen);
wbuf_int (&wbuf, mode);
return tokulogger_finish(txn->logger, &wbuf);
}
int tokulogger_log_unlink (TOKUTXN txn, const char *fname) {
if (txn==0) return 0;
const int fnamelen = strlen(fname);
const int buflen = (+1 // log command
+4 // length of fname
+fnamelen
+8 // crc & len
);
unsigned char buf[buflen];
struct wbuf wbuf;
wbuf_init (&wbuf, buf, buflen);
wbuf_char (&wbuf, LT_UNLINK);
wbuf_bytes(&wbuf, fname, fnamelen);
return tokulogger_finish(txn->logger, &wbuf);
};
/* /*
int brtenv_checkpoint (BRTENV env) { int brtenv_checkpoint (BRTENV env) {
init the checkpointing lock init the checkpointing lock
......
...@@ -16,4 +16,8 @@ int tokulogger_log_block_rename (TOKULOGGER logger, FILENUM fileid, DISKOFF oldd ...@@ -16,4 +16,8 @@ int tokulogger_log_block_rename (TOKULOGGER logger, FILENUM fileid, DISKOFF oldd
int tokutxn_begin (TOKUTXN /*parent*/,TOKUTXN *, TXNID txnid64, TOKULOGGER logger); int tokutxn_begin (TOKUTXN /*parent*/,TOKUTXN *, TXNID txnid64, TOKULOGGER logger);
int tokulogger_log_fcreate_tmp (TOKUTXN, const char */*fname*/, int /*mode*/);
int tokulogger_log_unlink (TOKUTXN, const char */*fname*/);
#endif #endif
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#define fname __FILE__ ".tmp"
int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) {
unlink(fname);
int fd0 = open (fname, O_RDWR|O_CREAT|O_EXCL, 0777);
assert(fd0>=0);
int fd1 = open (fname, O_RDWR|O_CREAT|O_EXCL, 0777);
assert(fd1==-1);
assert(errno==EEXIST);
return 0;
}
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