Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit 5e75a39

Browse files
authored
fix: make the order of commands the same as with node-pg (#9)
1 parent 9913ef3 commit 5e75a39

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

tokio-postgres/src/query.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,8 @@ where
7979
let params = params.into_iter();
8080

8181
let buf = client.with_buf(|buf| {
82-
// prepare
82+
// Prepare
8383
frontend::parse("", query, std::iter::empty(), buf).map_err(Error::encode)?;
84-
frontend::describe(b'S', "", buf).map_err(Error::encode)?;
8584

8685
// Bind, pass params as text, retrieve as binary
8786
match frontend::bind(
@@ -104,14 +103,15 @@ where
104103
Err(frontend::BindError::Serialization(e)) => Err(Error::encode(e)),
105104
}?;
106105

106+
// Describe
107+
frontend::describe(b'S', "", buf).map_err(Error::encode)?;
108+
107109
// Execute
108110
frontend::execute("", 0, buf).map_err(Error::encode)?;
111+
109112
// Sync
110113
frontend::sync(buf);
111114

112-
// Close
113-
// frontend::close(b'S', "", buf).map_err(Error::encode)?;
114-
115115
Ok(buf.split().freeze())
116116
})?;
117117

@@ -212,7 +212,7 @@ async fn start(client: &InnerClient, buf: Bytes) -> Result<(Option<Statement>, R
212212

213213
loop {
214214
match responses.next().await? {
215-
Message::CloseComplete | Message::ParseComplete | Message::ReadyForQuery(_) => {}
215+
Message::ParseComplete => {}
216216
Message::BindComplete => return Ok((statement, responses)),
217217
Message::ParameterDescription(body) => {
218218
parameter_description = Some(body); // tooo-o-ooo-o loooove

tokio-postgres/src/simple_query.rs

-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ pub async fn batch_execute(client: &InnerClient, query: &str) -> Result<(), Erro
5656
Message::ReadyForQuery(_) => return Ok(()),
5757
Message::CommandComplete(_)
5858
| Message::EmptyQueryResponse
59-
| Message::CloseComplete
6059
| Message::RowDescription(_)
6160
| Message::DataRow(_) => {}
6261
m => return Err(Error::unexpected_message(m)),

0 commit comments

Comments
 (0)