Commit 6a999eea authored by John Esmet's avatar John Esmet Committed by Yoni Fogel

[t:4826] return an error when we try to get/set compression methods instead of...

[t:4826] return an error when we try to get/set compression methods instead of possibly crashing. update the test to cover this code path.


git-svn-id: file:///svn/toku/tokudb@42965 c7de825b-a66e-492c-adef-691d508d4ae1
parent 4c7ac3ba
......@@ -65,6 +65,15 @@ with_open_db(db_callback cb, void *cb_extra, bool set_method, enum toku_compress
DB_TXN *txn;
r = env->txn_begin(env, 0, &txn, 0);
CKERR(r);
{
// we should not be able to successfully do this on an unopened DB
r = db->set_compression_method(db, TOKU_NO_COMPRESSION);
assert(r != 0);
enum toku_compression_method m = 999;
r = db->get_compression_method(db, &m);
assert(r != 0);
assert(m == 999);
}
r = db->open(db, txn, "foo.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO);
CKERR(r);
if (set_method) {
......
......@@ -594,14 +594,26 @@ toku_db_get_readpagesize(DB *db, u_int32_t *readpagesize_ptr) {
static int
toku_db_set_compression_method(DB *db, enum toku_compression_method compression_method) {
HANDLE_PANICKED_DB(db);
int r = toku_brt_set_compression_method(db->i->brt, compression_method);
int r;
// compression method is tracked in the brt header, so it must be open
if (!db_opened(db)) {
r = EINVAL;
} else {
r = toku_brt_set_compression_method(db->i->brt, compression_method);
}
return r;
}
static int
toku_db_get_compression_method(DB *db, enum toku_compression_method *compression_method_ptr) {
HANDLE_PANICKED_DB(db);
int r = toku_brt_get_compression_method(db->i->brt, compression_method_ptr);
int r;
// compression method is tracked in the brt header, so it must be open
if (!db_opened(db)) {
r = EINVAL;
} else {
r = toku_brt_get_compression_method(db->i->brt, compression_method_ptr);
}
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