Commit e22d67bb authored by Yoni Fogel's avatar Yoni Fogel

Addresses #893

Implement db->pre_acquire_read_lock(), db->dbt_pos_infty(), and db->dbt_neg_infty()
functions.

Example usage to lock entire table:
db->pre_acquire_read_lock(db, txn, db->dbt_neg_infty(), NULL, db->dbt_pos_infty(), NULL);
(Above is for db with no duplicates, i.e. primary index).

For db with duplicates:
db->pre_acquire_read_lock(db, txn, db->dbt_neg_infty(), db->dbt_neg_infty(), db->dbt_pos_infty(), db->dbt_pos_infty());

Will return same lock error codes as db calls do (when locks fail).
0 = success
DB_LOCK_NOTGRANTED = failed to obtain the lock.
We can theoretically sleep and try again here.

If you want to grab from DBT* A to infinity..
db->pre_acquire_read_lock(db, txn, A, NULL, db->dbt_pos_infty(), NULL);


git-svn-id: file:///svn/tokudb@4402 c7de825b-a66e-492c-adef-691d508d4ae1
parent 98feb209
......@@ -172,15 +172,18 @@ struct __toku_db {
void* __toku_dummy0[2];
void *app_private; /* 32-bit offset=16 size=4, 64=bit offset=32 size=8 */
DB_ENV *dbenv; /* 32-bit offset=20 size=4, 64=bit offset=40 size=8 */
void* __toku_dummy1[29];
int (*pre_acquire_read_lock)(DB*, DB_TXN*, DBT*, DBT*, DBT*, DBT*);
void* __toku_dummy1[28];
char __toku_dummy2[96];
void *api_internal; /* 32-bit offset=236 size=4, 64=bit offset=376 size=8 */
void* __toku_dummy3[4];
const DBT* (*dbt_pos_infty)(void);
void* __toku_dummy3[3];
int (*associate) (DB*, DB_TXN*, DB*, int(*)(DB*, const DBT*, const DBT*, DBT*), u_int32_t); /* 32-bit offset=256 size=4, 64=bit offset=416 size=8 */
int (*close) (DB*, u_int32_t); /* 32-bit offset=260 size=4, 64=bit offset=424 size=8 */
int (*cursor) (DB *, DB_TXN *, DBC **, u_int32_t); /* 32-bit offset=264 size=4, 64=bit offset=432 size=8 */
int (*del) (DB *, DB_TXN *, DBT *, u_int32_t); /* 32-bit offset=268 size=4, 64=bit offset=440 size=8 */
void* __toku_dummy4[2];
const DBT* (*dbt_neg_infty)(void);
void* __toku_dummy4[1];
int (*fd) (DB *, int *); /* 32-bit offset=280 size=4, 64=bit offset=464 size=8 */
int (*get) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t); /* 32-bit offset=284 size=4, 64=bit offset=472 size=8 */
int (*pget) (DB *, DB_TXN *, DBT *, DBT *, DBT *, u_int32_t); /* 32-bit offset=288 size=4, 64=bit offset=480 size=8 */
......
......@@ -182,15 +182,18 @@ struct __toku_db {
void* __toku_dummy0[2];
void *app_private; /* 32-bit offset=16 size=4, 64=bit offset=32 size=8 */
DB_ENV *dbenv; /* 32-bit offset=20 size=4, 64=bit offset=40 size=8 */
void* __toku_dummy1[32];
int (*pre_acquire_read_lock)(DB*, DB_TXN*, DBT*, DBT*, DBT*, DBT*);
void* __toku_dummy1[31];
char __toku_dummy2[96];
void *api_internal; /* 32-bit offset=248 size=4, 64=bit offset=400 size=8 */
void* __toku_dummy3[4];
const DBT* (*dbt_pos_infty)(void);
void* __toku_dummy3[3];
int (*associate) (DB*, DB_TXN*, DB*, int(*)(DB*, const DBT*, const DBT*, DBT*), u_int32_t); /* 32-bit offset=268 size=4, 64=bit offset=440 size=8 */
int (*close) (DB*, u_int32_t); /* 32-bit offset=272 size=4, 64=bit offset=448 size=8 */
int (*cursor) (DB *, DB_TXN *, DBC **, u_int32_t); /* 32-bit offset=276 size=4, 64=bit offset=456 size=8 */
int (*del) (DB *, DB_TXN *, DBT *, u_int32_t); /* 32-bit offset=280 size=4, 64=bit offset=464 size=8 */
void* __toku_dummy4[3];
const DBT* (*dbt_neg_infty)(void);
void* __toku_dummy4[2];
int (*fd) (DB *, int *); /* 32-bit offset=296 size=4, 64=bit offset=496 size=8 */
int (*get) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t); /* 32-bit offset=300 size=4, 64=bit offset=504 size=8 */
int (*pget) (DB *, DB_TXN *, DBT *, DBT *, DBT *, u_int32_t); /* 32-bit offset=304 size=4, 64=bit offset=512 size=8 */
......
......@@ -184,45 +184,47 @@ struct __toku_db {
void* __toku_dummy0[2];
void *app_private; /* 32-bit offset=16 size=4, 64=bit offset=32 size=8 */
DB_ENV *dbenv; /* 32-bit offset=20 size=4, 64=bit offset=40 size=8 */
void* __toku_dummy1[34];
int (*pre_acquire_read_lock)(DB*, DB_TXN*, DBT*, DBT*, DBT*, DBT*);
void* __toku_dummy1[33];
char __toku_dummy2[96];
void *api_internal; /* 32-bit offset=256 size=4, 64=bit offset=416 size=8 */
void* __toku_dummy3[4];
const DBT* (*dbt_pos_infty)(void);
void* __toku_dummy3[3];
int (*associate) (DB*, DB_TXN*, DB*, int(*)(DB*, const DBT*, const DBT*, DBT*), u_int32_t); /* 32-bit offset=276 size=4, 64=bit offset=456 size=8 */
int (*close) (DB*, u_int32_t); /* 32-bit offset=280 size=4, 64=bit offset=464 size=8 */
void* __toku_dummy4[1];
const DBT* (*dbt_neg_infty)(void);
int (*cursor) (DB *, DB_TXN *, DBC **, u_int32_t); /* 32-bit offset=288 size=4, 64=bit offset=480 size=8 */
int (*del) (DB *, DB_TXN *, DBT *, u_int32_t); /* 32-bit offset=292 size=4, 64=bit offset=488 size=8 */
void* __toku_dummy5[2];
void* __toku_dummy4[2];
int (*fd) (DB *, int *); /* 32-bit offset=304 size=4, 64=bit offset=512 size=8 */
int (*get) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t); /* 32-bit offset=308 size=4, 64=bit offset=520 size=8 */
void* __toku_dummy6[8];
void* __toku_dummy5[8];
int (*get_flags) (DB *, u_int32_t *); /* 32-bit offset=344 size=4, 64=bit offset=592 size=8 */
void* __toku_dummy7[6];
void* __toku_dummy6[6];
int (*get_pagesize) (DB *, u_int32_t *); /* 32-bit offset=372 size=4, 64=bit offset=648 size=8 */
void* __toku_dummy8[8];
void* __toku_dummy7[8];
int (*key_range) (DB *, DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t); /* 32-bit offset=408 size=4, 64=bit offset=720 size=8 */
int (*open) (DB *, DB_TXN *, const char *, const char *, DBTYPE, u_int32_t, int); /* 32-bit offset=412 size=4, 64=bit offset=728 size=8 */
int (*pget) (DB *, DB_TXN *, DBT *, DBT *, DBT *, u_int32_t); /* 32-bit offset=416 size=4, 64=bit offset=736 size=8 */
int (*put) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t); /* 32-bit offset=420 size=4, 64=bit offset=744 size=8 */
int (*remove) (DB *, const char *, const char *, u_int32_t); /* 32-bit offset=424 size=4, 64=bit offset=752 size=8 */
int (*rename) (DB *, const char *, const char *, const char *, u_int32_t); /* 32-bit offset=428 size=4, 64=bit offset=760 size=8 */
void* __toku_dummy9[2];
void* __toku_dummy8[2];
int (*set_bt_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); /* 32-bit offset=440 size=4, 64=bit offset=784 size=8 */
void* __toku_dummy10[3];
void* __toku_dummy9[3];
int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); /* 32-bit offset=456 size=4, 64=bit offset=816 size=8 */
void* __toku_dummy11[2];
void* __toku_dummy10[2];
void (*set_errfile) (DB *, FILE*); /* 32-bit offset=468 size=4, 64=bit offset=840 size=8 */
void* __toku_dummy12[2];
void* __toku_dummy11[2];
int (*set_flags) (DB *, u_int32_t); /* 32-bit offset=480 size=4, 64=bit offset=864 size=8 */
void* __toku_dummy13[6];
void* __toku_dummy12[6];
int (*set_pagesize) (DB *, u_int32_t); /* 32-bit offset=508 size=4, 64=bit offset=920 size=8 */
void* __toku_dummy14[6];
void* __toku_dummy13[6];
int (*stat) (DB *, void *, u_int32_t); /* 32-bit offset=536 size=4, 64=bit offset=976 size=8 */
void* __toku_dummy15[4];
void* __toku_dummy14[4];
int (*verify) (DB *, const char *, const char *, FILE *, u_int32_t); /* 32-bit offset=556 size=4, 64=bit offset=1016 size=8 */
void* __toku_dummy16[5]; /* Padding at the end */
char __toku_dummy17[16]; /* Padding at the end */
void* __toku_dummy15[5]; /* Padding at the end */
char __toku_dummy16[16]; /* Padding at the end */
};
struct __toku_db_txn_active {
u_int32_t txnid; /* 32-bit offset=0 size=4, 64=bit offset=0 size=4 */
......
......@@ -183,45 +183,47 @@ struct __toku_db {
void* __toku_dummy0[2];
void *app_private; /* 32-bit offset=16 size=4, 64=bit offset=32 size=8 */
DB_ENV *dbenv; /* 32-bit offset=20 size=4, 64=bit offset=40 size=8 */
void* __toku_dummy1[37];
int (*pre_acquire_read_lock)(DB*, DB_TXN*, DBT*, DBT*, DBT*, DBT*);
void* __toku_dummy1[36];
char __toku_dummy2[96];
void *api_internal; /* 32-bit offset=268 size=4, 64=bit offset=440 size=8 */
void* __toku_dummy3[4];
const DBT* (*dbt_pos_infty)(void);
void* __toku_dummy3[3];
int (*associate) (DB*, DB_TXN*, DB*, int(*)(DB*, const DBT*, const DBT*, DBT*), u_int32_t); /* 32-bit offset=288 size=4, 64=bit offset=480 size=8 */
int (*close) (DB*, u_int32_t); /* 32-bit offset=292 size=4, 64=bit offset=488 size=8 */
void* __toku_dummy4[1];
const DBT* (*dbt_neg_infty)(void);
int (*cursor) (DB *, DB_TXN *, DBC **, u_int32_t); /* 32-bit offset=300 size=4, 64=bit offset=504 size=8 */
int (*del) (DB *, DB_TXN *, DBT *, u_int32_t); /* 32-bit offset=304 size=4, 64=bit offset=512 size=8 */
void* __toku_dummy5[2];
void* __toku_dummy4[2];
int (*fd) (DB *, int *); /* 32-bit offset=316 size=4, 64=bit offset=536 size=8 */
int (*get) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t); /* 32-bit offset=320 size=4, 64=bit offset=544 size=8 */
void* __toku_dummy6[8];
void* __toku_dummy5[8];
int (*get_flags) (DB *, u_int32_t *); /* 32-bit offset=356 size=4, 64=bit offset=616 size=8 */
void* __toku_dummy7[6];
void* __toku_dummy6[6];
int (*get_pagesize) (DB *, u_int32_t *); /* 32-bit offset=384 size=4, 64=bit offset=672 size=8 */
void* __toku_dummy8[8];
void* __toku_dummy7[8];
int (*key_range) (DB *, DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t); /* 32-bit offset=420 size=4, 64=bit offset=744 size=8 */
int (*open) (DB *, DB_TXN *, const char *, const char *, DBTYPE, u_int32_t, int); /* 32-bit offset=424 size=4, 64=bit offset=752 size=8 */
int (*pget) (DB *, DB_TXN *, DBT *, DBT *, DBT *, u_int32_t); /* 32-bit offset=428 size=4, 64=bit offset=760 size=8 */
int (*put) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t); /* 32-bit offset=432 size=4, 64=bit offset=768 size=8 */
int (*remove) (DB *, const char *, const char *, u_int32_t); /* 32-bit offset=436 size=4, 64=bit offset=776 size=8 */
int (*rename) (DB *, const char *, const char *, const char *, u_int32_t); /* 32-bit offset=440 size=4, 64=bit offset=784 size=8 */
void* __toku_dummy9[2];
void* __toku_dummy8[2];
int (*set_bt_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); /* 32-bit offset=452 size=4, 64=bit offset=808 size=8 */
void* __toku_dummy10[3];
void* __toku_dummy9[3];
int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); /* 32-bit offset=468 size=4, 64=bit offset=840 size=8 */
void* __toku_dummy11[2];
void* __toku_dummy10[2];
void (*set_errfile) (DB *, FILE*); /* 32-bit offset=480 size=4, 64=bit offset=864 size=8 */
void* __toku_dummy12[2];
void* __toku_dummy11[2];
int (*set_flags) (DB *, u_int32_t); /* 32-bit offset=492 size=4, 64=bit offset=888 size=8 */
void* __toku_dummy13[6];
void* __toku_dummy12[6];
int (*set_pagesize) (DB *, u_int32_t); /* 32-bit offset=520 size=4, 64=bit offset=944 size=8 */
void* __toku_dummy14[6];
void* __toku_dummy13[6];
int (*stat) (DB *, void *, u_int32_t); /* 32-bit offset=548 size=4, 64=bit offset=1000 size=8 */
void* __toku_dummy15[4];
void* __toku_dummy14[4];
int (*verify) (DB *, const char *, const char *, FILE *, u_int32_t); /* 32-bit offset=568 size=4, 64=bit offset=1040 size=8 */
void* __toku_dummy16[5]; /* Padding at the end */
char __toku_dummy17[16]; /* Padding at the end */
void* __toku_dummy15[5]; /* Padding at the end */
char __toku_dummy16[16]; /* Padding at the end */
};
struct __toku_db_txn_active {
u_int32_t txnid; /* 32-bit offset=0 size=4, 64=bit offset=0 size=4 */
......
......@@ -187,45 +187,47 @@ struct __toku_db {
char __toku_dummy1[8];
void *app_private; /* 32-bit offset=20 size=4, 64=bit offset=32 size=8 */
DB_ENV *dbenv; /* 32-bit offset=24 size=4, 64=bit offset=40 size=8 */
void* __toku_dummy2[42];
int (*pre_acquire_read_lock)(DB*, DB_TXN*, DBT*, DBT*, DBT*, DBT*);
void* __toku_dummy2[41];
char __toku_dummy3[80];
void *api_internal; /* 32-bit offset=276 size=4, 64=bit offset=464 size=8 */
void* __toku_dummy4[4];
const DBT* (*dbt_pos_infty)(void);
void* __toku_dummy4[3];
int (*associate) (DB*, DB_TXN*, DB*, int(*)(DB*, const DBT*, const DBT*, DBT*), u_int32_t); /* 32-bit offset=296 size=4, 64=bit offset=504 size=8 */
int (*close) (DB*, u_int32_t); /* 32-bit offset=300 size=4, 64=bit offset=512 size=8 */
void* __toku_dummy5[1];
const DBT* (*dbt_neg_infty)(void);
int (*cursor) (DB *, DB_TXN *, DBC **, u_int32_t); /* 32-bit offset=308 size=4, 64=bit offset=528 size=8 */
int (*del) (DB *, DB_TXN *, DBT *, u_int32_t); /* 32-bit offset=312 size=4, 64=bit offset=536 size=8 */
void* __toku_dummy6[3];
void* __toku_dummy5[3];
int (*fd) (DB *, int *); /* 32-bit offset=328 size=4, 64=bit offset=568 size=8 */
int (*get) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t); /* 32-bit offset=332 size=4, 64=bit offset=576 size=8 */
void* __toku_dummy7[8];
void* __toku_dummy6[8];
int (*get_flags) (DB *, u_int32_t *); /* 32-bit offset=368 size=4, 64=bit offset=648 size=8 */
void* __toku_dummy8[7];
void* __toku_dummy7[7];
int (*get_pagesize) (DB *, u_int32_t *); /* 32-bit offset=400 size=4, 64=bit offset=712 size=8 */
void* __toku_dummy9[9];
void* __toku_dummy8[9];
int (*key_range) (DB *, DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t); /* 32-bit offset=440 size=4, 64=bit offset=792 size=8 */
int (*open) (DB *, DB_TXN *, const char *, const char *, DBTYPE, u_int32_t, int); /* 32-bit offset=444 size=4, 64=bit offset=800 size=8 */
int (*pget) (DB *, DB_TXN *, DBT *, DBT *, DBT *, u_int32_t); /* 32-bit offset=448 size=4, 64=bit offset=808 size=8 */
int (*put) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t); /* 32-bit offset=452 size=4, 64=bit offset=816 size=8 */
int (*remove) (DB *, const char *, const char *, u_int32_t); /* 32-bit offset=456 size=4, 64=bit offset=824 size=8 */
int (*rename) (DB *, const char *, const char *, const char *, u_int32_t); /* 32-bit offset=460 size=4, 64=bit offset=832 size=8 */
void* __toku_dummy10[2];
void* __toku_dummy9[2];
int (*set_bt_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); /* 32-bit offset=472 size=4, 64=bit offset=856 size=8 */
void* __toku_dummy11[3];
void* __toku_dummy10[3];
int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); /* 32-bit offset=488 size=4, 64=bit offset=888 size=8 */
void* __toku_dummy12[2];
void* __toku_dummy11[2];
void (*set_errfile) (DB *, FILE*); /* 32-bit offset=500 size=4, 64=bit offset=912 size=8 */
void* __toku_dummy13[2];
void* __toku_dummy12[2];
int (*set_flags) (DB *, u_int32_t); /* 32-bit offset=512 size=4, 64=bit offset=936 size=8 */
void* __toku_dummy14[7];
void* __toku_dummy13[7];
int (*set_pagesize) (DB *, u_int32_t); /* 32-bit offset=544 size=4, 64=bit offset=1000 size=8 */
void* __toku_dummy15[7];
void* __toku_dummy14[7];
int (*stat) (DB *, void *, u_int32_t); /* 32-bit offset=576 size=4, 64=bit offset=1064 size=8 */
void* __toku_dummy16[4];
void* __toku_dummy15[4];
int (*verify) (DB *, const char *, const char *, FILE *, u_int32_t); /* 32-bit offset=596 size=4, 64=bit offset=1104 size=8 */
void* __toku_dummy17[5]; /* Padding at the end */
char __toku_dummy18[16]; /* Padding at the end */
void* __toku_dummy16[5]; /* Padding at the end */
char __toku_dummy17[16]; /* Padding at the end */
};
struct __toku_db_txn_active {
u_int32_t txnid; /* 32-bit offset=0 size=4, 64=bit offset=0 size=4 */
......
......@@ -301,7 +301,11 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__un
print_struct("db_lsn", 0, db_lsn_fields32, db_lsn_fields64, sizeof(db_lsn_fields32)/sizeof(db_lsn_fields32[0]), 0);
assert(sizeof(db_fields32)==sizeof(db_fields64));
const char *extra[]={"int (*key_range64)(DB*, DB_TXN *, DBT *, u_int64_t *less, u_int64_t *equal, u_int64_t *greater, int *is_exact)"};
const char *extra[]={"int (*key_range64)(DB*, DB_TXN *, DBT *, u_int64_t *less, u_int64_t *equal, u_int64_t *greater, int *is_exact)",
"int (*pre_acquire_read_lock)(DB*, DB_TXN*, DBT*, DBT*, DBT*, DBT*)",
"const DBT* (*dbt_pos_infty)(void)",
"const DBT* (*dbt_neg_infty)(void)",
NULL};
print_struct("db", 1, db_fields32, db_fields64, sizeof(db_fields32)/sizeof(db_fields32[0]), extra);
assert(sizeof(db_txn_active_fields32)==sizeof(db_txn_active_fields64));
......
......@@ -184,45 +184,47 @@ struct __toku_db {
void* __toku_dummy0[2];
void *app_private; /* 32-bit offset=16 size=4, 64=bit offset=32 size=8 */
DB_ENV *dbenv; /* 32-bit offset=20 size=4, 64=bit offset=40 size=8 */
void* __toku_dummy1[34];
int (*pre_acquire_read_lock)(DB*, DB_TXN*, DBT*, DBT*, DBT*, DBT*);
void* __toku_dummy1[33];
char __toku_dummy2[96];
void *api_internal; /* 32-bit offset=256 size=4, 64=bit offset=416 size=8 */
void* __toku_dummy3[4];
const DBT* (*dbt_pos_infty)(void);
void* __toku_dummy3[3];
int (*associate) (DB*, DB_TXN*, DB*, int(*)(DB*, const DBT*, const DBT*, DBT*), u_int32_t); /* 32-bit offset=276 size=4, 64=bit offset=456 size=8 */
int (*close) (DB*, u_int32_t); /* 32-bit offset=280 size=4, 64=bit offset=464 size=8 */
void* __toku_dummy4[1];
const DBT* (*dbt_neg_infty)(void);
int (*cursor) (DB *, DB_TXN *, DBC **, u_int32_t); /* 32-bit offset=288 size=4, 64=bit offset=480 size=8 */
int (*del) (DB *, DB_TXN *, DBT *, u_int32_t); /* 32-bit offset=292 size=4, 64=bit offset=488 size=8 */
void* __toku_dummy5[2];
void* __toku_dummy4[2];
int (*fd) (DB *, int *); /* 32-bit offset=304 size=4, 64=bit offset=512 size=8 */
int (*get) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t); /* 32-bit offset=308 size=4, 64=bit offset=520 size=8 */
void* __toku_dummy6[8];
void* __toku_dummy5[8];
int (*get_flags) (DB *, u_int32_t *); /* 32-bit offset=344 size=4, 64=bit offset=592 size=8 */
void* __toku_dummy7[6];
void* __toku_dummy6[6];
int (*get_pagesize) (DB *, u_int32_t *); /* 32-bit offset=372 size=4, 64=bit offset=648 size=8 */
void* __toku_dummy8[8];
void* __toku_dummy7[8];
int (*key_range) (DB *, DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t); /* 32-bit offset=408 size=4, 64=bit offset=720 size=8 */
int (*open) (DB *, DB_TXN *, const char *, const char *, DBTYPE, u_int32_t, int); /* 32-bit offset=412 size=4, 64=bit offset=728 size=8 */
int (*pget) (DB *, DB_TXN *, DBT *, DBT *, DBT *, u_int32_t); /* 32-bit offset=416 size=4, 64=bit offset=736 size=8 */
int (*put) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t); /* 32-bit offset=420 size=4, 64=bit offset=744 size=8 */
int (*remove) (DB *, const char *, const char *, u_int32_t); /* 32-bit offset=424 size=4, 64=bit offset=752 size=8 */
int (*rename) (DB *, const char *, const char *, const char *, u_int32_t); /* 32-bit offset=428 size=4, 64=bit offset=760 size=8 */
void* __toku_dummy9[2];
void* __toku_dummy8[2];
int (*set_bt_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); /* 32-bit offset=440 size=4, 64=bit offset=784 size=8 */
void* __toku_dummy10[3];
void* __toku_dummy9[3];
int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); /* 32-bit offset=456 size=4, 64=bit offset=816 size=8 */
void* __toku_dummy11[2];
void* __toku_dummy10[2];
void (*set_errfile) (DB *, FILE*); /* 32-bit offset=468 size=4, 64=bit offset=840 size=8 */
void* __toku_dummy12[2];
void* __toku_dummy11[2];
int (*set_flags) (DB *, u_int32_t); /* 32-bit offset=480 size=4, 64=bit offset=864 size=8 */
void* __toku_dummy13[6];
void* __toku_dummy12[6];
int (*set_pagesize) (DB *, u_int32_t); /* 32-bit offset=508 size=4, 64=bit offset=920 size=8 */
void* __toku_dummy14[6];
void* __toku_dummy13[6];
int (*stat) (DB *, void *, u_int32_t); /* 32-bit offset=536 size=4, 64=bit offset=976 size=8 */
void* __toku_dummy15[4];
void* __toku_dummy14[4];
int (*verify) (DB *, const char *, const char *, FILE *, u_int32_t); /* 32-bit offset=556 size=4, 64=bit offset=1016 size=8 */
void* __toku_dummy16[5]; /* Padding at the end */
char __toku_dummy17[16]; /* Padding at the end */
void* __toku_dummy15[5]; /* Padding at the end */
char __toku_dummy16[16]; /* Padding at the end */
};
struct __toku_db_txn_active {
u_int32_t txnid; /* 32-bit offset=0 size=4, 64=bit offset=0 size=4 */
......
......@@ -439,7 +439,6 @@ static int toku_env_get_cachesize(DB_ENV * env, u_int32_t *gbytes, u_int32_t *by
static int locked_env_get_cachesize(DB_ENV *env, u_int32_t *gbytes, u_int32_t *bytes, int *ncache) {
toku_ydb_lock(); int r = toku_env_get_cachesize(env, gbytes, bytes, ncache); toku_ydb_unlock(); return r;
}
#endif
static int toku_env_set_data_dir(DB_ENV * env, const char *dir) {
......@@ -2604,7 +2603,7 @@ static int toku_db_fd(DB *db, int *fdp) {
return toku_brt_get_fd(db->i->brt, fdp);
}
static int toku_db_keyrange64(DB* db, DB_TXN* txn __attribute__((__unused__)), DBT* key, u_int64_t* less, u_int64_t* equal, u_int64_t* greater, int* is_exact) {
static int toku_db_key_range64(DB* db, DB_TXN* txn __attribute__((__unused__)), DBT* key, u_int64_t* less, u_int64_t* equal, u_int64_t* greater, int* is_exact) {
HANDLE_PANICKED_DB(db);
// note that toku_brt_keyrange does not have a txn param
......@@ -2619,6 +2618,21 @@ static int toku_db_keyrange64(DB* db, DB_TXN* txn __attribute__((__unused__)), D
return r;
}
int toku_db_pre_acquire_read_lock(DB *db, DB_TXN *txn, DBT *key_left, DBT *val_left, DBT *key_right, DBT *val_right) {
HANDLE_PANICKED_DB(db);
if (!db->i->lt || !txn) return EINVAL;
DB_TXN* txn_anc = toku_txn_ancestor(txn);
int r;
if ((r=toku_txn_add_lt(txn_anc, db->i->lt))) return r;
TXNID id_anc = toku_txn_get_txnid(txn_anc->i->tokutxn);
r = toku_lt_acquire_range_read_lock(db->i->lt, db, id_anc,
key_left, val_left,
key_right, val_right);
return r;
}
//TODO: DB_AUTO_COMMIT.
//TODO: Nowait only conditionally?
......@@ -2702,6 +2716,13 @@ static int locked_db_get (DB * db, DB_TXN * txn, DBT * key, DBT * data, u_int32_
toku_ydb_lock(); int r = autotxn_db_get(db, txn, key, data, flags); toku_ydb_unlock(); return r;
}
int locked_db_pre_acquire_read_lock(DB *db, DB_TXN *txn, DBT *key_left, DBT *val_left, DBT *key_right, DBT *val_right) {
toku_ydb_lock();
int r = toku_db_pre_acquire_read_lock(db, txn, key_left, val_left, key_right, val_right);
toku_ydb_unlock();
return r;
}
static inline int autotxn_db_pget(DB* db, DB_TXN* txn, DBT* key, DBT* pkey,
DBT* data, u_int32_t flags) {
BOOL changed; int r;
......@@ -2778,8 +2799,18 @@ static int locked_db_fd(DB *db, int *fdp) {
}
static int locked_db_keyrange64(DB* db, DB_TXN* txn, DBT* dbt, u_int64_t* less, u_int64_t* equal, u_int64_t* greater, int* is_exact) {
toku_ydb_lock(); int r = toku_db_keyrange64(db, txn, dbt, less, equal, greater, is_exact); toku_ydb_unlock(); return r;
static int locked_db_key_range64(DB* db, DB_TXN* txn, DBT* dbt, u_int64_t* less, u_int64_t* equal, u_int64_t* greater, int* is_exact) {
toku_ydb_lock(); int r = toku_db_key_range64(db, txn, dbt, less, equal, greater, is_exact); toku_ydb_unlock(); return r;
}
static const DBT* toku_db_dbt_pos_infty(void) __attribute__((pure));
static const DBT* toku_db_dbt_pos_infty(void) {
return toku_lt_infinity;
}
static const DBT* toku_db_dbt_neg_infty(void) __attribute__((pure));
static const DBT* toku_db_dbt_neg_infty(void) {
return toku_lt_neg_infinity;
}
static int toku_db_create(DB ** db, DB_ENV * env, u_int32_t flags) {
......@@ -2811,27 +2842,32 @@ static int toku_db_create(DB ** db, DB_ENV * env, u_int32_t flags) {
return ENOMEM;
}
memset(result, 0, sizeof *result);
result->key_range64 = locked_db_keyrange64;
result->dbenv = env;
result->associate = locked_db_associate;
result->close = locked_db_close;
result->cursor = locked_db_cursor;
result->del = locked_db_del;
result->get = locked_db_get;
// result->key_range = locked_db_key_range;
result->open = locked_db_open;
result->pget = locked_db_pget;
result->put = locked_db_put;
result->remove = locked_db_remove;
result->rename = locked_db_rename;
result->set_bt_compare = locked_db_set_bt_compare;
result->set_dup_compare = locked_db_set_dup_compare;
result->set_errfile = locked_db_set_errfile;
result->set_pagesize = locked_db_set_pagesize;
result->set_flags = locked_db_set_flags;
result->get_flags = locked_db_get_flags;
// result->stat = locked_db_stat;
result->fd = locked_db_fd;
#define SDB(name) result->name = locked_db_ ## name
SDB(key_range64);
SDB(associate);
SDB(close);
SDB(cursor);
SDB(del);
SDB(get);
// SDB(key_range);
SDB(open);
SDB(pget);
SDB(put);
SDB(remove);
SDB(rename);
SDB(set_bt_compare);
SDB(set_dup_compare);
SDB(set_errfile);
SDB(set_pagesize);
SDB(set_flags);
SDB(get_flags);
// SDB(stat);
SDB(fd);
SDB(pre_acquire_read_lock);
#undef SDB
result->dbt_pos_infty = toku_db_dbt_pos_infty;
result->dbt_neg_infty = toku_db_dbt_neg_infty;
MALLOC(result->i);
if (result->i == 0) {
toku_free(result);
......
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