Skip to content

Commit d6e8840

Browse files
committed
Update ChangeLog.md and add a test
1 parent f5163ad commit d6e8840

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

ChangeLog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ Non-breaking Changes:
1111

1212
* `DbError::new()` uses generics, which supports old types.
1313

14+
Internal Changes:
15+
16+
* Improve performance of iterator for [`ResultSet<T>`][`ResultSet`] where T is [`Row`]
17+
by sharing an internal fetch array buffer. Before this change, one row in the buffer
18+
is copied to `Row` for each iteration. After this, new fetch array buffer is allocated
19+
when more rows must be fetched into a buffer but the buffer is referenced by `Row`s.
20+
1421
## 0.6.0 (2024-05-20)
1522

1623
Breaking changes:

src/statement.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,4 +1485,25 @@ mod tests {
14851485

14861486
Ok(())
14871487
}
1488+
1489+
#[test]
1490+
fn fetch_rows_to_vec() -> Result<()> {
1491+
let conn = test_util::connect()?;
1492+
// The fetch array size must be less than the number of rows in TestStrings
1493+
// in order to make situation that a new fetch array buffer must allocated
1494+
// in Stmt::fetch_rows().
1495+
let mut stmt = conn
1496+
.statement("select IntCol from TestStrings order by IntCol")
1497+
.fetch_array_size(3)
1498+
.build()?;
1499+
let mut rows = Vec::new();
1500+
for row_result in stmt.query(&[])? {
1501+
rows.push(row_result?);
1502+
}
1503+
for (index, row) in rows.iter().enumerate() {
1504+
let int_col: usize = row.get(0)?;
1505+
assert_eq!(int_col, index + 1);
1506+
}
1507+
Ok(())
1508+
}
14881509
}

0 commit comments

Comments
 (0)