Skip to content

Commit

Permalink
fix: incorrect stripe table join
Browse files Browse the repository at this point in the history
  • Loading branch information
burmecia committed Nov 13, 2023
1 parent 3c19feb commit 8ae0df1
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions wrappers/src/fdw/stripe_fdw/stripe_fdw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ pub(crate) struct StripeFdw {
scan_result: Option<Vec<Row>>,
obj: String,
rowid_col: String,
iter_idx: usize,
}

impl StripeFdw {
Expand Down Expand Up @@ -645,6 +646,7 @@ impl ForeignDataWrapper<StripeFdwError> for StripeFdw {
scan_result: None,
obj: String::default(),
rowid_col: String::default(),
iter_idx: 0,
})
}

Expand Down Expand Up @@ -737,16 +739,20 @@ impl ForeignDataWrapper<StripeFdwError> for StripeFdw {

fn iter_scan(&mut self, row: &mut Row) -> StripeFdwResult<Option<()>> {
if let Some(ref mut result) = self.scan_result {
if !result.is_empty() {
return Ok(result
.drain(0..1)
.last()
.map(|src_row| row.replace_with(src_row)));
if self.iter_idx < result.len() {
row.replace_with(result[self.iter_idx].clone());
self.iter_idx += 1;
return Ok(Some(()));
}
}
Ok(None)
}

fn re_scan(&mut self) -> StripeFdwResult<()> {
self.iter_idx = 0;
Ok(())
}

fn end_scan(&mut self) -> StripeFdwResult<()> {
self.scan_result.take();
Ok(())
Expand Down

0 comments on commit 8ae0df1

Please sign in to comment.