Skip to content

Commit d63782c

Browse files
committed
store: Introduce a VidRange struct
1 parent 8749f20 commit d63782c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

store/postgres/src/vid_batcher.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,10 @@ impl VidRange {
271271
}
272272

273273
pub fn size(&self) -> usize {
274-
(self.max - self.min + 1) as usize
274+
(self.max - self.min) as usize + 1
275275
}
276276

277+
/// Return the full range of `vid` values in the table `src`
277278
pub fn for_copy(
278279
conn: &mut PgConnection,
279280
src: &Table,
@@ -285,11 +286,13 @@ impl VidRange {
285286
"lower(block_range) <= $1"
286287
};
287288
let vid_range = sql_query(format!(
288-
"select coalesce(min(vid), 0) as min_vid, \
289+
"/* controller=copy,target={target_number} */ \
290+
select coalesce(min(vid), 0) as min_vid, \
289291
coalesce(max(vid), -1) as max_vid \
290-
from {} where {}",
291-
src.qualified_name.as_str(),
292-
max_block_clause
292+
from {src_name} where {max_block_clause}",
293+
target_number = target_block.number,
294+
src_name = src.qualified_name.as_str(),
295+
max_block_clause = max_block_clause
293296
))
294297
.bind::<Integer, _>(&target_block.number)
295298
.load::<VidRange>(conn)?

0 commit comments

Comments
 (0)