Implement `get_results`
@@ -126,4 +126,46 @@ impl<'a> Prepare<'a> {
// FIXME: This is an end-of-file error. How we should bubble this up here?
unreachable!()
}
+
+ #[inline]
+ pub async fn get_results(self) -> io::Result<Vec<DataRow>> {
+ proto::bind::trailer(
+ &mut self.connection.wbuf,
+ self.bind_state,
+ self.bind_values,
+ &[],
+ );
+
+ self.connection.send(Execute::new("", 0));
+ self.connection.send(Sync);
+ self.connection.flush().await?;
+
+ let mut rows = vec![];
+
+ while let Some(message) = self.connection.receive().await? {
+ match message {
+ Message::BindComplete | Message::ParseComplete => {
+ // Indicates successful completion of a phase
+ }
+
+ Message::DataRow(row) => {
+ rows.push(row);
+ }
+
+ Message::CommandComplete(_) => {}
+
+ Message::ReadyForQuery(_) => {
+ // Successful completion of the whole cycle
+ return Ok(rows);
+ }
+
+ message => {
+ unimplemented!("received {:?} unimplemented message", message);
+ }
+ }
+ }
+
+ // FIXME: This is an end-of-file error. How we should bubble this up here?
+ unreachable!()
+ }
}
