Commit 46907c25 authored by Yoni Fogel's avatar Yoni Fogel

Prevent DB->put from working on secondary indexes

(unless called internally with DB_NO_ASSOCIATE flag set)

Modified test_db_secondary to verify this behavior.
Closes #106

git-svn-id: file:///svn/tokudb@888 c7de825b-a66e-492c-adef-691d508d4ae1
parent 5b7b4df0
......@@ -98,9 +98,12 @@ void insert_test() {
data.size = sizeof(s);
//Set up secondary key
r = getname(sdbp, &key, &data, &skey); CKERR(r);
//Insert into primary.
r = dbp->put(dbp, null_txn, &key, &data, 0); CKERR(r);
//Make certain we fail to insert into secondary.
r = sdbp->put(sdbp, null_txn, &key, &data, 0); assert(r == EINVAL);
/* Try to get it from primary. */
r = dbp->get(dbp, null_txn, &key, &testdata, 0); CKERR(r);
......
......@@ -793,7 +793,7 @@ static int do_associated_inserts (DB_TXN *txn, DBT *key, DBT *data, DB *secondar
return EINVAL; // We aren't ready for this
}
#endif
r = secondary->put(secondary, txn, &idx, key, 0);
r = secondary->put(secondary, txn, &idx, key, DB_NO_ASSOCIATE);
if (idx.flags & DB_DBT_APPMALLOC) {
free(idx.data);
}
......@@ -803,9 +803,10 @@ static int do_associated_inserts (DB_TXN *txn, DBT *key, DBT *data, DB *secondar
static int toku_db_put(DB * db, DB_TXN * txn, DBT * key, DBT * data, u_int32_t flags) {
int r;
if (flags != 0)
return EINVAL;
if (db->i->primary == 0 && flags != 0) return EINVAL;
//Cannot put directly into a secondary.
if (db->i->primary != 0 && flags != DB_NO_ASSOCIATE) return EINVAL;
unsigned int brtflags;
r = toku_brt_get_flags(db->i->brt, &brtflags); assert(r == 0);
unsigned int nodesize;
......
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