fix: use walk_range on import_table_with_range (#1364)

Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
Co-authored-by: Roman Krasiuk <rokrassyuk@gmail.com>
This commit is contained in:
joshieDo
2023-02-16 03:22:24 +08:00
committed by GitHub
parent c415221876
commit 6da8967082

View File

@@ -101,19 +101,20 @@ pub trait TableImporter<'tx>: for<'a> DbTxMut<'a> {
source_tx: &R,
from: Option<<T as Table>::Key>,
to: <T as Table>::Key,
) -> Result<(), Error> {
) -> Result<(), Error>
where
T::Key: Default,
{
let mut destination_cursor = self.cursor_write::<T>()?;
let mut source_cursor = source_tx.cursor_read::<T>()?;
for row in source_cursor.walk(from)? {
let source_range = match from {
Some(from) => source_cursor.walk_range(from..=to),
None => source_cursor.walk_range(..=to),
};
for row in source_range? {
let (key, value) = row?;
let finished = key == to;
destination_cursor.append(key, value)?;
if finished {
break
}
}
Ok(())