Commit eb0b85fa authored by Yoni Fogel's avatar Yoni Fogel

DB->get split into two functions to avoid using

DB_NOASSOCIATE
addresses #116

git-svn-id: file:///svn/tokudb@929 c7de825b-a66e-492c-adef-691d508d4ae1
parent f6476e01
......@@ -775,12 +775,12 @@ static int toku_db_del(DB * db, DB_TXN * txn, DBT * key, u_int32_t flags) {
return r;
}
static int toku_db_get (DB * db, DB_TXN * txn, DBT * key, DBT * data, u_int32_t flags) {
static int toku_db_get_noassociate(DB * db, DB_TXN * txn, DBT * key, DBT * data, u_int32_t flags) {
int r;
unsigned int brtflags;
assert(flags == 0 || flags==DB_NO_ASSOCIATE); // We aren't ready to handle flags such as DB_GET_BOTH or DB_READ_COMMITTED or DB_READ_UNCOMMITTED or DB_RMW
if (db->i->primary==0 || flags==DB_NO_ASSOCIATE) {
// It's a get on a primary
assert(flags == 0); // We aren't ready to handle flags such as DB_GET_BOTH or DB_READ_COMMITTED or DB_READ_UNCOMMITTED or DB_RMW
toku_brt_get_flags(db->i->brt, &brtflags);
if (brtflags & TOKU_DB_DUPSORT) {
DBC *dbc;
......@@ -790,9 +790,14 @@ static int toku_db_get (DB * db, DB_TXN * txn, DBT * key, DBT * data, u_int32_t
int r2 = dbc->c_close(dbc);
if (r!=0) return r;
return r2;
} else
return toku_brt_lookup(db->i->brt, key, data);
} else {
}
else return toku_brt_lookup(db->i->brt, key, data);
}
static int toku_db_get (DB * db, DB_TXN * txn, DBT * key, DBT * data, u_int32_t flags) {
assert(flags == 0); // We aren't ready to handle flags such as DB_GET_BOTH or DB_READ_COMMITTED or DB_READ_UNCOMMITTED or DB_RMW
if (db->i->primary==0) return toku_db_get_noassociate(db, txn, key, data, flags);
else {
// It's a get on a secondary.
DBT primary_key;
memset(&primary_key, 0, sizeof(primary_key));
......@@ -804,7 +809,7 @@ static int toku_db_pget (DB *db, DB_TXN *txn, DBT *key, DBT *pkey, DBT *data, u_
int r;
if (!db->i->primary) return EINVAL; // pget doesn't work on a primary.
assert(flags==0); // not ready to handle all those other options
r = toku_db_get (db, txn, key, pkey, DB_NO_ASSOCIATE);
r = toku_db_get_noassociate (db, txn, key, pkey, 0);
if (r!=0) return r;
// If data and primary_key are both zeroed, the temporary storage used to fill in data is different in the two cases because they come from different trees.
assert(db->i->brt != db->i->primary->i->brt); // Make sure they realy are different trees.
......
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