Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
4ed0e8ed
Commit
4ed0e8ed
authored
Jul 17, 2013
by
Yoni Fogel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '6712'
parents
96d87f75
260df683
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
332 additions
and
35 deletions
+332
-35
buildheader/make_tdb.cc
buildheader/make_tdb.cc
+4
-1
ft/ft-internal.h
ft/ft-internal.h
+3
-1
ft/ft-ops.cc
ft/ft-ops.cc
+46
-5
ft/ft-ops.h
ft/ft-ops.h
+2
-1
ft/tests/test3856.cc
ft/tests/test3856.cc
+1
-1
src/tests/blocking-prelock-range.cc
src/tests/blocking-prelock-range.cc
+1
-1
src/tests/cursor-set-del-rmw.cc
src/tests/cursor-set-del-rmw.cc
+1
-1
src/tests/perf_iibench.cc
src/tests/perf_iibench.cc
+1
-1
src/tests/prelock-read-read.cc
src/tests/prelock-read-read.cc
+1
-1
src/tests/prelock-read-write.cc
src/tests/prelock-read-write.cc
+1
-1
src/tests/prelock-write-read.cc
src/tests/prelock-write-read.cc
+1
-1
src/tests/prelock-write-write.cc
src/tests/prelock-write-write.cc
+1
-1
src/tests/test_bulk_fetch.cc
src/tests/test_bulk_fetch.cc
+16
-8
src/tests/test_cmp_descriptor.cc
src/tests/test_cmp_descriptor.cc
+4
-2
src/tests/test_locktree_close.cc
src/tests/test_locktree_close.cc
+4
-2
src/tests/test_restrict.cc
src/tests/test_restrict.cc
+217
-0
src/tests/threaded_stress_test_helpers.h
src/tests/threaded_stress_test_helpers.h
+3
-3
src/ydb_cursor.cc
src/ydb_cursor.cc
+25
-4
No files found.
buildheader/make_tdb.cc
View file @
4ed0e8ed
...
...
@@ -205,6 +205,7 @@ enum {
TOKUDB_CURSOR_CONTINUE
=
-
100014
,
TOKUDB_BAD_CHECKSUM
=
-
100015
,
TOKUDB_HUGE_PAGES_ENABLED
=
-
100016
,
TOKUDB_OUT_OF_RANGE
=
-
100017
,
DONTUSE_I_JUST_PUT_THIS_HERE_SO_I_COULD_HAVE_A_COMMA_AFTER_EACH_ITEM
};
...
...
@@ -356,6 +357,7 @@ static void print_defines (void) {
dodefine
(
TOKUDB_CURSOR_CONTINUE
);
dodefine
(
TOKUDB_BAD_CHECKSUM
);
dodefine
(
TOKUDB_HUGE_PAGES_ENABLED
);
dodefine
(
TOKUDB_OUT_OF_RANGE
);
/* LOADER flags */
printf
(
"/* LOADER flags */
\n
"
);
...
...
@@ -590,7 +592,8 @@ static void print_dbc_struct (void) {
"int (*c_getf_set)(DBC *, uint32_t, DBT *, YDB_CALLBACK_FUNCTION, void *)"
,
"int (*c_getf_set_range)(DBC *, uint32_t, DBT *, YDB_CALLBACK_FUNCTION, void *)"
,
"int (*c_getf_set_range_reverse)(DBC *, uint32_t, DBT *, YDB_CALLBACK_FUNCTION, void *)"
,
"int (*c_pre_acquire_range_lock)(DBC*, const DBT*, const DBT*)"
,
"int (*c_set_bounds)(DBC*, const DBT*, const DBT*, bool pre_acquire, int out_of_range_error)"
,
"void (*c_remove_restriction)(DBC*)"
,
NULL
};
sort_and_dump_fields
(
"dbc"
,
false
,
extra
);
}
...
...
ft/ft-internal.h
View file @
4ed0e8ed
...
...
@@ -788,14 +788,16 @@ struct ft_cursor_leaf_info {
struct
ft_cursor
{
struct
toku_list
cursors_link
;
FT_HANDLE
ft_handle
;
bool
prefetching
;
DBT
key
,
val
;
// The key-value pair that the cursor currently points to
DBT
range_lock_left_key
,
range_lock_right_key
;
bool
prefetching
;
bool
left_is_neg_infty
,
right_is_pos_infty
;
bool
is_snapshot_read
;
// true if query is read_committed, false otherwise
bool
is_leaf_mode
;
bool
disable_prefetching
;
bool
is_temporary
;
int
out_of_range_error
;
int
direction
;
TOKUTXN
ttxn
;
struct
ft_cursor_leaf_info
leaf_info
;
};
...
...
ft/ft-ops.cc
View file @
4ed0e8ed
...
...
@@ -4100,6 +4100,11 @@ int toku_ft_cursor (
return
0
;
}
void
toku_ft_cursor_remove_restriction
(
FT_CURSOR
ftcursor
)
{
ftcursor
->
out_of_range_error
=
0
;
ftcursor
->
direction
=
0
;
}
void
toku_ft_cursor_set_temporary
(
FT_CURSOR
ftcursor
)
{
ftcursor
->
is_temporary
=
true
;
...
...
@@ -4117,7 +4122,8 @@ toku_ft_cursor_is_leaf_mode(FT_CURSOR ftcursor) {
void
toku_ft_cursor_set_range_lock
(
FT_CURSOR
cursor
,
const
DBT
*
left
,
const
DBT
*
right
,
bool
left_is_neg_infty
,
bool
right_is_pos_infty
)
bool
left_is_neg_infty
,
bool
right_is_pos_infty
,
int
out_of_range_error
)
{
// Destroy any existing keys and then clone the given left, right keys
toku_destroy_dbt
(
&
cursor
->
range_lock_left_key
);
...
...
@@ -4133,6 +4139,10 @@ toku_ft_cursor_set_range_lock(FT_CURSOR cursor, const DBT *left, const DBT *righ
}
else
{
toku_clone_dbt
(
&
cursor
->
range_lock_right_key
,
*
right
);
}
// TOKUDB_FOUND_BUT_REJECTED is a DB_NOTFOUND with instructions to stop looking. (Faster)
cursor
->
out_of_range_error
=
out_of_range_error
==
DB_NOTFOUND
?
TOKUDB_FOUND_BUT_REJECTED
:
out_of_range_error
;
cursor
->
direction
=
0
;
}
void
toku_ft_cursor_close
(
FT_CURSOR
cursor
)
{
...
...
@@ -4787,6 +4797,24 @@ toku_move_ftnode_messages_to_stale(FT ft, FTNODE node) {
}
}
static
int
cursor_check_restricted_range
(
FT_CURSOR
c
,
bytevec
key
,
ITEMLEN
keylen
)
{
if
(
c
->
out_of_range_error
)
{
FT
ft
=
c
->
ft_handle
->
ft
;
FAKE_DB
(
db
,
&
ft
->
cmp_descriptor
);
DBT
found_key
;
toku_fill_dbt
(
&
found_key
,
key
,
keylen
);
if
((
!
c
->
left_is_neg_infty
&&
c
->
direction
<=
0
&&
ft
->
compare_fun
(
&
db
,
&
found_key
,
&
c
->
range_lock_left_key
)
<
0
)
||
(
!
c
->
right_is_pos_infty
&&
c
->
direction
>=
0
&&
ft
->
compare_fun
(
&
db
,
&
found_key
,
&
c
->
range_lock_right_key
)
>
0
))
{
invariant
(
c
->
out_of_range_error
);
return
c
->
out_of_range_error
;
}
}
// Reset cursor direction to mitigate risk if some query type doesn't set the direction.
// It is always correct to check both bounds (which happens when direction==0) but it can be slower.
c
->
direction
=
0
;
return
0
;
}
static
int
ft_cursor_shortcut
(
FT_CURSOR
cursor
,
...
...
@@ -4870,8 +4898,10 @@ got_a_good_value:
&
vallen
,
&
val
);
r
=
getf
(
keylen
,
key
,
vallen
,
val
,
getf_v
,
false
);
r
=
cursor_check_restricted_range
(
ftcursor
,
key
,
keylen
);
if
(
r
==
0
)
{
r
=
getf
(
keylen
,
key
,
vallen
,
val
,
getf_v
,
false
);
}
if
(
r
==
0
||
r
==
TOKUDB_CURSOR_CONTINUE
)
{
ftcursor
->
leaf_info
.
to_be
.
omt
=
bn
->
buffer
;
ftcursor
->
leaf_info
.
to_be
.
index
=
idx
;
...
...
@@ -5455,6 +5485,7 @@ toku_ft_cursor_current(FT_CURSOR cursor, int op, FT_GET_CALLBACK_FUNCTION getf,
{
if
(
ft_cursor_not_set
(
cursor
))
return
EINVAL
;
cursor
->
direction
=
0
;
if
(
op
==
DB_CURRENT
)
{
struct
ft_cursor_search_struct
bcss
=
{
getf
,
getf_v
,
cursor
,
0
};
ft_search_t
search
;
ft_search_init
(
&
search
,
ft_cursor_compare_set
,
FT_SEARCH_LEFT
,
&
cursor
->
key
,
cursor
->
ft_handle
);
...
...
@@ -5468,6 +5499,7 @@ toku_ft_cursor_current(FT_CURSOR cursor, int op, FT_GET_CALLBACK_FUNCTION getf,
int
toku_ft_cursor_first
(
FT_CURSOR
cursor
,
FT_GET_CALLBACK_FUNCTION
getf
,
void
*
getf_v
)
{
cursor
->
direction
=
0
;
ft_search_t
search
;
ft_search_init
(
&
search
,
ft_cursor_compare_one
,
FT_SEARCH_LEFT
,
0
,
cursor
->
ft_handle
);
int
r
=
ft_cursor_search
(
cursor
,
&
search
,
getf
,
getf_v
,
false
);
ft_search_finish
(
&
search
);
...
...
@@ -5477,6 +5509,7 @@ toku_ft_cursor_first(FT_CURSOR cursor, FT_GET_CALLBACK_FUNCTION getf, void *getf
int
toku_ft_cursor_last
(
FT_CURSOR
cursor
,
FT_GET_CALLBACK_FUNCTION
getf
,
void
*
getf_v
)
{
cursor
->
direction
=
0
;
ft_search_t
search
;
ft_search_init
(
&
search
,
ft_cursor_compare_one
,
FT_SEARCH_RIGHT
,
0
,
cursor
->
ft_handle
);
int
r
=
ft_cursor_search
(
cursor
,
&
search
,
getf
,
getf_v
,
false
);
ft_search_finish
(
&
search
);
...
...
@@ -5488,7 +5521,6 @@ static int ft_cursor_compare_next(ft_search_t *search, DBT *x) {
return
compare_k_x
(
brt
,
search
->
k
,
x
)
<
0
;
/* return min xy: kv < xy */
}
static
int
ft_cursor_shortcut
(
FT_CURSOR
cursor
,
...
...
@@ -5527,7 +5559,11 @@ ft_cursor_shortcut (
val
);
r
=
getf
(
*
keylen
,
*
key
,
*
vallen
,
*
val
,
getf_v
,
false
);
cursor
->
direction
=
direction
;
r
=
cursor_check_restricted_range
(
cursor
,
*
key
,
*
keylen
);
if
(
r
==
0
)
{
r
=
getf
(
*
keylen
,
*
key
,
*
vallen
,
*
val
,
getf_v
,
false
);
}
if
(
r
==
0
||
r
==
TOKUDB_CURSOR_CONTINUE
)
{
//Update cursor.
cursor
->
leaf_info
.
to_be
.
index
=
index
;
...
...
@@ -5547,6 +5583,7 @@ ft_cursor_shortcut (
int
toku_ft_cursor_next
(
FT_CURSOR
cursor
,
FT_GET_CALLBACK_FUNCTION
getf
,
void
*
getf_v
)
{
cursor
->
direction
=
+
1
;
ft_search_t
search
;
ft_search_init
(
&
search
,
ft_cursor_compare_next
,
FT_SEARCH_LEFT
,
&
cursor
->
key
,
cursor
->
ft_handle
);
int
r
=
ft_cursor_search
(
cursor
,
&
search
,
getf
,
getf_v
,
true
);
ft_search_finish
(
&
search
);
...
...
@@ -5593,6 +5630,7 @@ static int ft_cursor_compare_prev(ft_search_t *search, DBT *x) {
int
toku_ft_cursor_prev
(
FT_CURSOR
cursor
,
FT_GET_CALLBACK_FUNCTION
getf
,
void
*
getf_v
)
{
cursor
->
direction
=
-
1
;
ft_search_t
search
;
ft_search_init
(
&
search
,
ft_cursor_compare_prev
,
FT_SEARCH_RIGHT
,
&
cursor
->
key
,
cursor
->
ft_handle
);
int
r
=
ft_cursor_search
(
cursor
,
&
search
,
getf
,
getf_v
,
true
);
ft_search_finish
(
&
search
);
...
...
@@ -5607,6 +5645,7 @@ static int ft_cursor_compare_set_range(ft_search_t *search, DBT *x) {
int
toku_ft_cursor_set
(
FT_CURSOR
cursor
,
DBT
*
key
,
FT_GET_CALLBACK_FUNCTION
getf
,
void
*
getf_v
)
{
cursor
->
direction
=
0
;
ft_search_t
search
;
ft_search_init
(
&
search
,
ft_cursor_compare_set_range
,
FT_SEARCH_LEFT
,
key
,
cursor
->
ft_handle
);
int
r
=
ft_cursor_search_eq_k_x
(
cursor
,
&
search
,
getf
,
getf_v
);
ft_search_finish
(
&
search
);
...
...
@@ -5616,6 +5655,7 @@ toku_ft_cursor_set(FT_CURSOR cursor, DBT *key, FT_GET_CALLBACK_FUNCTION getf, vo
int
toku_ft_cursor_set_range
(
FT_CURSOR
cursor
,
DBT
*
key
,
FT_GET_CALLBACK_FUNCTION
getf
,
void
*
getf_v
)
{
cursor
->
direction
=
0
;
ft_search_t
search
;
ft_search_init
(
&
search
,
ft_cursor_compare_set_range
,
FT_SEARCH_LEFT
,
key
,
cursor
->
ft_handle
);
int
r
=
ft_cursor_search
(
cursor
,
&
search
,
getf
,
getf_v
,
false
);
ft_search_finish
(
&
search
);
...
...
@@ -5630,6 +5670,7 @@ static int ft_cursor_compare_set_range_reverse(ft_search_t *search, DBT *x) {
int
toku_ft_cursor_set_range_reverse
(
FT_CURSOR
cursor
,
DBT
*
key
,
FT_GET_CALLBACK_FUNCTION
getf
,
void
*
getf_v
)
{
cursor
->
direction
=
0
;
ft_search_t
search
;
ft_search_init
(
&
search
,
ft_cursor_compare_set_range_reverse
,
FT_SEARCH_RIGHT
,
key
,
cursor
->
ft_handle
);
int
r
=
ft_cursor_search
(
cursor
,
&
search
,
getf
,
getf_v
,
false
);
ft_search_finish
(
&
search
);
...
...
ft/ft-ops.h
View file @
4ed0e8ed
...
...
@@ -256,8 +256,9 @@ void toku_ft_cursor_set_leaf_mode(FT_CURSOR);
// Sets a boolean on the brt cursor that prevents uncessary copying of
// the cursor duing a one query.
void
toku_ft_cursor_set_temporary
(
FT_CURSOR
);
void
toku_ft_cursor_remove_restriction
(
FT_CURSOR
);
int
toku_ft_cursor_is_leaf_mode
(
FT_CURSOR
);
void
toku_ft_cursor_set_range_lock
(
FT_CURSOR
,
const
DBT
*
,
const
DBT
*
,
bool
,
bool
);
void
toku_ft_cursor_set_range_lock
(
FT_CURSOR
,
const
DBT
*
,
const
DBT
*
,
bool
,
bool
,
int
);
// get is deprecated in favor of the individual functions below
int
toku_ft_cursor_get
(
FT_CURSOR
cursor
,
DBT
*
key
,
FT_GET_CALLBACK_FUNCTION
getf
,
void
*
getf_v
,
int
get_flags
)
__attribute__
((
warn_unused_result
));
...
...
ft/tests/test3856.cc
View file @
4ed0e8ed
...
...
@@ -149,7 +149,7 @@ test_main (int argc __attribute__((__unused__)), const char *argv[] __attribute_
snprintf
(
rkey
,
100
,
"hello%d"
,
i
+
100
);
toku_ft_cursor_set_range_lock
(
c
,
toku_fill_dbt
(
&
lk
,
lkey
,
1
+
strlen
(
lkey
)),
toku_fill_dbt
(
&
rk
,
rkey
,
1
+
strlen
(
rkey
)),
false
,
false
);
false
,
false
,
0
);
r
=
toku_ft_cursor_set
(
c
,
&
lk
,
found
,
NULL
);
assert
(
r
==
0
);
for
(
int
j
=
0
;
j
<
100
;
++
j
)
{
r
=
toku_ft_cursor_next
(
c
,
found
,
NULL
);
assert
(
r
==
0
);
...
...
src/tests/blocking-prelock-range.cc
View file @
4ed0e8ed
...
...
@@ -104,7 +104,7 @@ static void blocking_range_lock(DB_ENV *db_env, DB *db, uint64_t nrows, long sle
uint64_t
k
=
0
;
DBT
key
=
{
.
data
=
&
k
,
.
size
=
sizeof
k
};
r
=
cursor
->
c_
pre_acquire_range_lock
(
cursor
,
&
key
,
&
key
);
assert
(
r
==
0
);
r
=
cursor
->
c_
set_bounds
(
cursor
,
&
key
,
&
key
,
true
,
0
);
assert
(
r
==
0
);
usleep
(
sleeptime
);
...
...
src/tests/cursor-set-del-rmw.cc
View file @
4ed0e8ed
...
...
@@ -119,7 +119,7 @@ static void test_del_rmw(DB_ENV *env, DB *db, uint32_t t1_flags, uint32_t t2_fla
DBC
*
c2
=
NULL
;
r
=
db
->
cursor
(
db
,
txn2
,
&
c2
,
c2_flags
);
assert_zero
(
r
);
r
=
c1
->
c_
pre_acquire_range_lock
(
c1
,
db
->
dbt_neg_infty
(),
db
->
dbt_pos_infty
()
);
assert_zero
(
r
);
r
=
c1
->
c_
set_bounds
(
c1
,
db
->
dbt_neg_infty
(),
db
->
dbt_pos_infty
(),
true
,
0
);
assert_zero
(
r
);
int
k
=
htonl
(
2
);
DBT
key
;
dbt_init
(
&
key
,
&
k
,
sizeof
k
);
...
...
src/tests/perf_iibench.cc
View file @
4ed0e8ed
...
...
@@ -375,7 +375,7 @@ static void iibench_rangequery_db(DB *db, DB_TXN *txn, ARG arg, uint64_t max_pk)
dbt_init
(
&
end_key
,
&
end_k
,
8
);
r
=
db
->
cursor
(
db
,
txn
,
&
cursor
,
0
);
CKERR
(
r
);
r
=
cursor
->
c_
pre_acquire_range_lock
(
cursor
,
&
start_key
,
&
end_key
);
CKERR
(
r
);
r
=
cursor
->
c_
set_bounds
(
cursor
,
&
start_key
,
&
end_key
,
true
,
0
);
CKERR
(
r
);
struct
rangequery_cb_extra
extra
=
{
.
rows_read
=
0
,
.
limit
=
limit
,
...
...
src/tests/prelock-read-read.cc
View file @
4ed0e8ed
...
...
@@ -94,7 +94,7 @@ PATENT RIGHTS GRANT:
static
int
prelock_range
(
DBC
*
cursor
,
int
left
,
int
right
)
{
DBT
key_left
;
dbt_init
(
&
key_left
,
&
left
,
sizeof
left
);
DBT
key_right
;
dbt_init
(
&
key_right
,
&
right
,
sizeof
right
);
int
r
=
cursor
->
c_
pre_acquire_range_lock
(
cursor
,
&
key_left
,
&
key_right
);
int
r
=
cursor
->
c_
set_bounds
(
cursor
,
&
key_left
,
&
key_right
,
true
,
0
);
return
r
;
}
...
...
src/tests/prelock-read-write.cc
View file @
4ed0e8ed
...
...
@@ -94,7 +94,7 @@ PATENT RIGHTS GRANT:
static
int
prelock_range
(
DBC
*
cursor
,
int
left
,
int
right
)
{
DBT
key_left
;
dbt_init
(
&
key_left
,
&
left
,
sizeof
left
);
DBT
key_right
;
dbt_init
(
&
key_right
,
&
right
,
sizeof
right
);
int
r
=
cursor
->
c_
pre_acquire_range_lock
(
cursor
,
&
key_left
,
&
key_right
);
int
r
=
cursor
->
c_
set_bounds
(
cursor
,
&
key_left
,
&
key_right
,
true
,
0
);
return
r
;
}
...
...
src/tests/prelock-write-read.cc
View file @
4ed0e8ed
...
...
@@ -94,7 +94,7 @@ PATENT RIGHTS GRANT:
static
int
prelock_range
(
DBC
*
cursor
,
int
left
,
int
right
)
{
DBT
key_left
;
dbt_init
(
&
key_left
,
&
left
,
sizeof
left
);
DBT
key_right
;
dbt_init
(
&
key_right
,
&
right
,
sizeof
right
);
int
r
=
cursor
->
c_
pre_acquire_range_lock
(
cursor
,
&
key_left
,
&
key_right
);
int
r
=
cursor
->
c_
set_bounds
(
cursor
,
&
key_left
,
&
key_right
,
true
,
0
);
return
r
;
}
...
...
src/tests/prelock-write-write.cc
View file @
4ed0e8ed
...
...
@@ -94,7 +94,7 @@ PATENT RIGHTS GRANT:
static
int
prelock_range
(
DBC
*
cursor
,
int
left
,
int
right
)
{
DBT
key_left
;
dbt_init
(
&
key_left
,
&
left
,
sizeof
left
);
DBT
key_right
;
dbt_init
(
&
key_right
,
&
right
,
sizeof
right
);
int
r
=
cursor
->
c_
pre_acquire_range_lock
(
cursor
,
&
key_left
,
&
key_right
);
int
r
=
cursor
->
c_
set_bounds
(
cursor
,
&
key_left
,
&
key_right
,
true
,
0
);
return
r
;
}
...
...
src/tests/test_bulk_fetch.cc
View file @
4ed0e8ed
...
...
@@ -230,10 +230,12 @@ test_bulk_fetch (uint64_t n, bool prelock, bool disable_prefetching) {
r
=
db
->
cursor
(
db
,
NULL
,
&
cursor
,
flags
);
CKERR
(
r
);
if
(
prelock
)
{
r
=
cursor
->
c_
pre_acquire_range_lock
(
r
=
cursor
->
c_
set_bounds
(
cursor
,
db
->
dbt_neg_infty
(),
db
->
dbt_pos_infty
()
db
->
dbt_pos_infty
(),
true
,
0
);
CKERR
(
r
);
}
...
...
@@ -257,10 +259,12 @@ test_bulk_fetch (uint64_t n, bool prelock, bool disable_prefetching) {
r
=
db
->
cursor
(
db
,
NULL
,
&
cursor
,
flags
);
CKERR
(
r
);
if
(
prelock
)
{
r
=
cursor
->
c_
pre_acquire_range_lock
(
r
=
cursor
->
c_
set_bounds
(
cursor
,
db
->
dbt_neg_infty
(),
db
->
dbt_pos_infty
()
db
->
dbt_pos_infty
(),
true
,
0
);
CKERR
(
r
);
}
...
...
@@ -284,10 +288,12 @@ test_bulk_fetch (uint64_t n, bool prelock, bool disable_prefetching) {
r
=
db
->
cursor
(
db
,
NULL
,
&
cursor
,
flags
);
CKERR
(
r
);
if
(
prelock
)
{
r
=
cursor
->
c_
pre_acquire_range_lock
(
r
=
cursor
->
c_
set_bounds
(
cursor
,
db
->
dbt_neg_infty
(),
db
->
dbt_pos_infty
()
db
->
dbt_pos_infty
(),
true
,
0
);
CKERR
(
r
);
}
...
...
@@ -311,10 +317,12 @@ test_bulk_fetch (uint64_t n, bool prelock, bool disable_prefetching) {
r
=
db
->
cursor
(
db
,
NULL
,
&
cursor
,
flags
);
CKERR
(
r
);
if
(
prelock
)
{
r
=
cursor
->
c_
pre_acquire_range_lock
(
r
=
cursor
->
c_
set_bounds
(
cursor
,
db
->
dbt_neg_infty
(),
db
->
dbt_pos_infty
()
db
->
dbt_pos_infty
(),
true
,
0
);
CKERR
(
r
);
}
...
...
src/tests/test_cmp_descriptor.cc
View file @
4ed0e8ed
...
...
@@ -196,10 +196,12 @@ static void do_inserts_and_queries(DB* db) {
r
=
db
->
cursor
(
db
,
read_txn
,
&
cursor
,
0
);
CKERR
(
r
);
if
(
i
==
0
)
{
r
=
cursor
->
c_
pre_acquire_range_lock
(
r
=
cursor
->
c_
set_bounds
(
cursor
,
db
->
dbt_neg_infty
(),
db
->
dbt_pos_infty
()
db
->
dbt_pos_infty
(),
true
,
0
);
CKERR
(
r
);
}
...
...
src/tests/test_locktree_close.cc
View file @
4ed0e8ed
...
...
@@ -122,10 +122,12 @@ test_cursor (void) {
DB_TXN
*
txn
=
NULL
;
r
=
env
->
txn_begin
(
env
,
NULL
,
&
txn
,
DB_SERIALIZABLE
);
CKERR
(
r
);
r
=
db
->
cursor
(
db
,
txn
,
&
cursor
,
0
);
CKERR
(
r
);
r
=
cursor
->
c_
pre_acquire_range_lock
(
r
=
cursor
->
c_
set_bounds
(
cursor
,
db
->
dbt_neg_infty
(),
db
->
dbt_pos_infty
()
db
->
dbt_pos_infty
(),
true
,
0
);
r
=
cursor
->
c_close
(
cursor
);
CKERR
(
r
);
r
=
db
->
close
(
db
,
0
);
CKERR
(
r
);
...
...
src/tests/test_restrict.cc
0 → 100644
View file @
4ed0e8ed
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id$"
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#include "test.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <memory.h>
#include <sys/stat.h>
#include <db.h>
static
void
test_restrict
(
int64_t
n
,
int
error_to_expect
)
{
assert
(
n
>
30
);
DB_TXN
*
const
null_txn
=
0
;
int
r
;
toku_os_recursive_delete
(
TOKU_TEST_FILENAME
);
r
=
toku_os_mkdir
(
TOKU_TEST_FILENAME
,
S_IRWXU
+
S_IRWXG
+
S_IRWXO
);
assert
(
r
==
0
);
/* create the dup database file */
DB_ENV
*
env
;
r
=
db_env_create
(
&
env
,
0
);
assert
(
r
==
0
);
r
=
env
->
set_default_bt_compare
(
env
,
int64_dbt_cmp
);
CKERR
(
r
);
r
=
env
->
open
(
env
,
TOKU_TEST_FILENAME
,
DB_CREATE
+
DB_PRIVATE
+
DB_INIT_MPOOL
,
0
);
assert
(
r
==
0
);
DB
*
db
;
r
=
db_create
(
&
db
,
env
,
0
);
assert
(
r
==
0
);
r
=
db
->
set_flags
(
db
,
0
);
assert
(
r
==
0
);
r
=
db
->
open
(
db
,
null_txn
,
"restrict.db"
,
NULL
,
DB_BTREE
,
DB_CREATE
,
0666
);
assert
(
r
==
0
);
int64_t
keys
[
n
];
int64_t
i
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
keys
[
i
]
=
i
;
}
DBT
key
,
val
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
r
=
db
->
put
(
db
,
null_txn
,
dbt_init
(
&
key
,
&
keys
[
i
],
sizeof
keys
[
i
]),
dbt_init
(
&
val
,
&
i
,
sizeof
i
),
0
);
assert
(
r
==
0
);
}
DBC
*
cursor
;
r
=
db
->
cursor
(
db
,
NULL
,
&
cursor
,
0
);
CKERR
(
r
);
DBT
dbt_left
,
dbt_right
;
int64_t
int_left
,
int_right
;
int_left
=
n
/
3
;
int_right
=
2
*
n
/
3
;
dbt_init
(
&
dbt_left
,
&
keys
[
int_left
],
sizeof
keys
[
int_left
]);
dbt_init
(
&
dbt_right
,
&
keys
[
int_right
],
sizeof
keys
[
int_right
]);
r
=
cursor
->
c_set_bounds
(
cursor
,
&
dbt_left
,
&
dbt_right
,
true
,
error_to_expect
);
CKERR
(
r
);
for
(
i
=
0
;
i
<
n
;
i
++
)
{
r
=
cursor
->
c_get
(
cursor
,
dbt_init
(
&
key
,
&
keys
[
i
],
sizeof
keys
[
i
]),
dbt_init
(
&
val
,
NULL
,
0
),
DB_SET
);
if
(
i
<
int_left
||
i
>
int_right
)
{
CKERR2
(
r
,
error_to_expect
);
}
else
{
CKERR
(
r
);
assert
(
val
.
size
==
8
);
assert
(
*
(
int64_t
*
)
val
.
data
==
i
);
}
}
// Forwards
r
=
cursor
->
c_get
(
cursor
,
dbt_init
(
&
key
,
&
keys
[
int_left
],
sizeof
keys
[
int_left
]),
dbt_init
(
&
val
,
NULL
,
0
),
DB_SET
);
CKERR
(
r
);
assert
(
val
.
size
==
8
);
assert
(
*
(
int64_t
*
)
val
.
data
==
int_left
);
for
(
i
=
int_left
+
1
;
i
<
n
;
i
++
)
{
r
=
cursor
->
c_get
(
cursor
,
dbt_init
(
&
key
,
&
keys
[
i
],
sizeof
keys
[
i
]),
dbt_init
(
&
val
,
NULL
,
0
),
DB_NEXT
);
if
(
i
>=
int_left
&&
i
<=
int_right
)
{
CKERR
(
r
);
assert
(
val
.
size
==
8
);
assert
(
*
(
int64_t
*
)
val
.
data
==
i
);
}
else
{
CKERR2
(
r
,
error_to_expect
);
break
;
}
}
r
=
cursor
->
c_get
(
cursor
,
dbt_init
(
&
key
,
&
keys
[
int_right
],
sizeof
keys
[
int_right
]),
dbt_init
(
&
val
,
NULL
,
0
),
DB_SET
);
CKERR
(
r
);
assert
(
val
.
size
==
8
);
assert
(
*
(
int64_t
*
)
val
.
data
==
int_right
);
for
(
i
=
int_right
-
1
;
i
>=
0
;
i
--
)
{
r
=
cursor
->
c_get
(
cursor
,
dbt_init
(
&
key
,
&
keys
[
i
],
sizeof
keys
[
i
]),
dbt_init
(
&
val
,
NULL
,
0
),
DB_PREV
);
if
(
i
>=
int_left
&&
i
<=
int_right
)
{
CKERR
(
r
);
assert
(
val
.
size
==
8
);
assert
(
*
(
int64_t
*
)
val
.
data
==
i
);
}
else
{
CKERR2
(
r
,
error_to_expect
);
break
;
}
}
r
=
cursor
->
c_close
(
cursor
);
CKERR
(
r
);
r
=
db
->
close
(
db
,
0
);
CKERR
(
r
);
r
=
env
->
close
(
env
,
0
);
CKERR
(
r
);
}
int
test_main
(
int
argc
,
char
*
const
argv
[])
{
parse_args
(
argc
,
argv
);
for
(
int
i
=
3
*
64
;
i
<
3
*
1024
;
i
*=
2
)
{
test_restrict
(
i
,
DB_NOTFOUND
);
test_restrict
(
i
,
TOKUDB_OUT_OF_RANGE
);
test_restrict
(
i
,
0
);
}
return
0
;
}
src/tests/threaded_stress_test_helpers.h
View file @
4ed0e8ed
...
...
@@ -667,7 +667,7 @@ static int scan_op_and_maybe_check_sum(
{
int
chk_r
=
db
->
cursor
(
db
,
txn
,
&
cursor
,
0
);
CKERR
(
chk_r
);
}
if
(
sce
->
prefetch
)
{
r
=
cursor
->
c_
pre_acquire_range_lock
(
cursor
,
db
->
dbt_neg_infty
(),
db
->
dbt_pos_infty
()
);
r
=
cursor
->
c_
set_bounds
(
cursor
,
db
->
dbt_neg_infty
(),
db
->
dbt_pos_infty
(),
true
,
0
);
assert
(
r
==
0
);
}
while
(
r
!=
DB_NOTFOUND
)
{
...
...
@@ -1154,7 +1154,7 @@ static void rangequery_db(DB *db, DB_TXN *txn, ARG arg, rangequery_row_cb cb, vo
fill_key_buf
(
start_k
+
limit
,
end_keybuf
,
arg
->
cli
);
r
=
db
->
cursor
(
db
,
txn
,
&
cursor
,
0
);
CKERR
(
r
);
r
=
cursor
->
c_
pre_acquire_range_lock
(
cursor
,
&
start_key
,
&
end_key
);
CKERR
(
r
);
r
=
cursor
->
c_
set_bounds
(
cursor
,
&
start_key
,
&
end_key
,
true
,
0
);
CKERR
(
r
);
struct
rangequery_cb_extra
extra
=
{
.
rows_read
=
0
,
...
...
@@ -1323,7 +1323,7 @@ static int pre_acquire_write_lock(DB *db, DB_TXN *txn,
r
=
db
->
cursor
(
db
,
txn
,
&
cursor
,
DB_RMW
);
CKERR
(
r
);
int
cursor_r
=
cursor
->
c_
pre_acquire_range_lock
(
cursor
,
left_key
,
right_key
);
int
cursor_r
=
cursor
->
c_
set_bounds
(
cursor
,
left_key
,
right_key
,
true
,
0
);
r
=
cursor
->
c_close
(
cursor
);
CKERR
(
r
);
...
...
src/ydb_cursor.cc
View file @
4ed0e8ed
...
...
@@ -700,14 +700,29 @@ toku_c_close(DBC * c) {
}
static
int
c_pre_acquire_range_lock
(
DBC
*
dbc
,
const
DBT
*
left_key
,
const
DBT
*
right_key
)
{
c_set_bounds
(
DBC
*
dbc
,
const
DBT
*
left_key
,
const
DBT
*
right_key
,
bool
pre_acquire
,
int
out_of_range_error
)
{
if
(
out_of_range_error
!=
DB_NOTFOUND
&&
out_of_range_error
!=
TOKUDB_OUT_OF_RANGE
&&
out_of_range_error
!=
0
)
{
return
toku_ydb_do_error
(
dbc
->
dbp
->
dbenv
,
EINVAL
,
"Invalid out_of_range_error [%d] for %s
\n
"
,
out_of_range_error
,
__FUNCTION__
);
}
if
(
left_key
==
toku_dbt_negative_infinity
()
&&
right_key
==
toku_dbt_positive_infinity
())
{
out_of_range_error
=
0
;
}
DB
*
db
=
dbc
->
dbp
;
DB_TXN
*
txn
=
dbc_struct_i
(
dbc
)
->
txn
;
HANDLE_PANICKED_DB
(
db
);
toku_ft_cursor_set_range_lock
(
dbc_struct_i
(
dbc
)
->
c
,
left_key
,
right_key
,
(
left_key
==
toku_dbt_negative_infinity
()),
(
right_key
==
toku_dbt_positive_infinity
()));
if
(
!
db
->
i
->
lt
||
!
txn
)
(
right_key
==
toku_dbt_positive_infinity
()),
out_of_range_error
);
if
(
!
db
->
i
->
lt
||
!
txn
||
!
pre_acquire
)
return
0
;
//READ_UNCOMMITTED and READ_COMMITTED transactions do not need read locks.
if
(
!
dbc_struct_i
(
dbc
)
->
rmw
&&
dbc_struct_i
(
dbc
)
->
iso
!=
TOKU_ISO_SERIALIZABLE
)
...
...
@@ -719,6 +734,11 @@ c_pre_acquire_range_lock(DBC *dbc, const DBT *left_key, const DBT *right_key) {
return
r
;
}
static
void
c_remove_restriction
(
DBC
*
dbc
)
{
toku_ft_cursor_remove_restriction
(
dbc_struct_i
(
dbc
)
->
c
);
}
int
toku_c_get
(
DBC
*
c
,
DBT
*
key
,
DBT
*
val
,
uint32_t
flag
)
{
//This function exists for legacy (test compatibility) purposes/parity with bdb.
...
...
@@ -810,7 +830,8 @@ toku_db_cursor_internal(DB * db, DB_TXN * txn, DBC ** c, uint32_t flags, int is_
SCRS
(
c_getf_current
);
SCRS
(
c_getf_set_range
);
SCRS
(
c_getf_set_range_reverse
);
SCRS
(
c_pre_acquire_range_lock
);
SCRS
(
c_set_bounds
);
SCRS
(
c_remove_restriction
);
#undef SCRS
result
->
c_get
=
toku_c_get
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment