Commit ac546f1c authored by Yoni Fogel's avatar Yoni Fogel

Fixes #1626 Flags array is updated when removing a subdb. Added test that verifies fix

git-svn-id: file:///svn/toku/tokudb@10777 c7de825b-a66e-492c-adef-691d508d4ae1
parent 0dc75e24
......@@ -2932,6 +2932,7 @@ int toku_brt_remove_subdb(BRT brt, const char *dbname, u_int32_t flags) {
brt->h->names[i - 1] = brt->h->names[i];
brt->h->roots[i - 1] = brt->h->roots[i];
brt->h->root_hashes[i - 1] = brt->h->root_hashes[i];
brt->h->flags_array[i - 1] = brt->h->flags_array[i];
}
brt->h->n_named_roots--;
brt->h->dirty = 1;
......@@ -2939,6 +2940,7 @@ int toku_brt_remove_subdb(BRT brt, const char *dbname, u_int32_t flags) {
XREALLOC_N(brt->h->n_named_roots, brt->h->names);
XREALLOC_N(brt->h->n_named_roots, brt->h->roots);
XREALLOC_N(brt->h->n_named_roots, brt->h->root_hashes);
XREALLOC_N(brt->h->n_named_roots, brt->h->flags_array);
return 0;
}
......
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved."
#include "includes.h"
#include "test.h"
static TOKUTXN const null_txn = 0;
static DB * const null_db = 0;
CACHETABLE ct;
#define FNAME __FILE__ ".brt"
static BRT
open_db(u_int32_t flags, char *subdb) {
BRT t;
int r;
r = toku_brt_create(&t); assert(r == 0);
r = toku_brt_set_flags(t, flags); assert(r == 0);
r = toku_brt_set_nodesize(t, 4096); assert(r == 0);
r = toku_brt_open(t, FNAME, FNAME, subdb, 1, 0, ct, null_txn, (DB*)0);
assert(r==0);
return t;
}
int
test_main (int argc , const char *argv[]) {
default_parse_args(argc, argv);
int r;
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
unlink_file_and_bit(FNAME);
BRT one;
BRT two;
BRT three;
char *name1 = "dupsort";
char *name2 = "dup and dupsort";
char *name3 = "temp";
one = open_db(TOKU_DB_DUPSORT, name1);
two = open_db(TOKU_DB_DUP | TOKU_DB_DUPSORT, name2);
three = open_db(TOKU_DB_DUPSORT, name3);
r = toku_close_brt(one, 0, 0); assert(r==0);
r = toku_close_brt(two, 0, 0); assert(r==0);
r = toku_brt_remove_subdb(three, name1, 0);
assert(r==0);
two = open_db(TOKU_DB_DUP | TOKU_DB_DUPSORT, name2);
r = toku_close_brt(two, 0, 0); assert(r==0);
r = toku_close_brt(three, 0, 0); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
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