Skip to content

Commit cf65b26

Browse files
committed
Fix Range bug.
This includes some logic to deal with TiKV intrinsics. Signed-off-by: Ana Hobden <[email protected]>
1 parent d932a20 commit cf65b26

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/rpc/tikv/client.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,19 @@ impl KvClient {
556556
start_key
557557
.map(|k| req.set_start_key(k.into_inner()))
558558
.unwrap();
559-
end_key.map(|k| req.set_end_key(k.into_inner())).unwrap();
559+
end_key
560+
.map(|k| {
561+
// Scan in TiKV has a weird particularity to it.
562+
// The **start** of a scan is inclusive, unless appended with an '\0', then it is exclusive.
563+
// The **end** of a scan is exclusive, unless appended with an '\0', then it is inclusive.
564+
//
565+
// We work around this behavior in this client by making all our scans (Inclusive, Inclusive),
566+
// if we have exclusive bounds our own bounds calculation adjusts it.
567+
let mut end_key = k.into_inner();
568+
end_key.append(&mut vec![0]);
569+
req.set_end_key(end_key);
570+
})
571+
.unwrap();
560572
req.set_limit(limit);
561573
req.set_key_only(key_only);
562574

0 commit comments

Comments
 (0)