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,28 +775,33 @@ static int toku_db_del(DB * db, DB_TXN * txn, DBT * key, u_int32_t flags) { ...@@ -775,28 +775,33 @@ static int toku_db_del(DB * db, DB_TXN * txn, DBT * key, u_int32_t flags) {
return r; 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; int r;
unsigned int brtflags; 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) { 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
// It's a get on a primary toku_brt_get_flags(db->i->brt, &brtflags);
toku_brt_get_flags(db->i->brt, &brtflags); if (brtflags & TOKU_DB_DUPSORT) {
if (brtflags & TOKU_DB_DUPSORT) { DBC *dbc;
DBC *dbc; r = db->cursor(db, txn, &dbc, 0);
r = db->cursor(db, txn, &dbc, 0); if (r!=0) return r;
if (r!=0) return r; r = dbc->c_get(dbc, key, data, DB_SET);
r = dbc->c_get(dbc, key, data, DB_SET); int r2 = dbc->c_close(dbc);
int r2 = dbc->c_close(dbc); if (r!=0) return r;
if (r!=0) return r; return r2;
return r2; }
} else else return toku_brt_lookup(db->i->brt, key, data);
return toku_brt_lookup(db->i->brt, key, data); }
} else {
// It's a get on a secondary. static int toku_db_get (DB * db, DB_TXN * txn, DBT * key, DBT * data, u_int32_t flags) {
DBT primary_key; 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
memset(&primary_key, 0, sizeof(primary_key)); if (db->i->primary==0) return toku_db_get_noassociate(db, txn, key, data, flags);
return db->pget(db, txn, key, &primary_key, data, 0); else {
// It's a get on a secondary.
DBT primary_key;
memset(&primary_key, 0, sizeof(primary_key));
return db->pget(db, txn, key, &primary_key, data, 0);
} }
} }
...@@ -804,7 +809,7 @@ static int toku_db_pget (DB *db, DB_TXN *txn, DBT *key, DBT *pkey, DBT *data, u_ ...@@ -804,7 +809,7 @@ static int toku_db_pget (DB *db, DB_TXN *txn, DBT *key, DBT *pkey, DBT *data, u_
int r; int r;
if (!db->i->primary) return EINVAL; // pget doesn't work on a primary. if (!db->i->primary) return EINVAL; // pget doesn't work on a primary.
assert(flags==0); // not ready to handle all those other options 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 (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. // 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. 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