mirror of
https://github.com/launchbadge/sqlx
synced 2024-11-10 22:44:17 +00:00
fix errors from .send_raw()
additions that I didn't catch
This commit is contained in:
parent
892a179787
commit
b85618e5f8
4 changed files with 17 additions and 12 deletions
|
@ -11,16 +11,17 @@ use futures_util::AsyncWriteExt;
|
|||
use crate::{Describe, Error, io::{Buf, BufMut, BufStream}, mysql::{
|
||||
protocol::{
|
||||
Capabilities, ColumnCountPacket, ColumnDefinitionPacket, ComPing, ComQuit,
|
||||
ComStmtExecute, ComStmtPrepare, ComStmtPrepareOk, Encode, EofPacket, ErrPacket,
|
||||
OkPacket, ResultRow, StmtExecFlag,
|
||||
ComSetOption, ComStmtExecute,
|
||||
ComStmtPrepare, ComStmtPrepareOk, Encode, EofPacket, ErrPacket, OkPacket,
|
||||
ResultRow, SetOptionOptions, StmtExecFlag,
|
||||
},
|
||||
query::MySqlDbParameters,
|
||||
}, Result, ResultField, url::Url};
|
||||
|
||||
use super::establish;
|
||||
use crate::mysql::MySql;
|
||||
use crate::mysql::protocol::ComQuery;
|
||||
|
||||
use super::establish;
|
||||
|
||||
pub type StatementId = u32;
|
||||
|
||||
pub struct Connection {
|
||||
|
@ -311,10 +312,10 @@ impl Connection {
|
|||
async fn expect_eof_or_err(&mut self) -> crate::Result<()> {
|
||||
let packet = self.receive().await?;
|
||||
|
||||
match buf[0] {
|
||||
0xFE => EofPacket::decode(packet)?,
|
||||
0xFF => ErrPacket::decode(packet)?.expect_error()?,
|
||||
_ => return Err(protocol_err!("expected EOF or ERR, got {:02X}", buf[0]).into()),
|
||||
match packet[0] {
|
||||
0xFE => { EofPacket::decode(packet)?; },
|
||||
0xFF => { ErrPacket::decode(packet)?.expect_error()?; },
|
||||
_ => return Err(protocol_err!("expected EOF or ERR, got {:02X}", packet[0]).into()),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -337,7 +338,7 @@ impl Connection {
|
|||
let packet = self.receive().await?;
|
||||
|
||||
if packet[0] == 0xFF { return ErrPacket::decode(packet)?.expect_error() }
|
||||
/// otherwise ignore packet
|
||||
// otherwise ignore packet
|
||||
|
||||
self.expect_eof_or_err().await?;
|
||||
|
||||
|
|
|
@ -154,6 +154,6 @@ impl Executor for Connection {
|
|||
}
|
||||
|
||||
fn send<'e, 'q: 'e>(&'e mut self, commands: &'q str) -> BoxFuture<'e, crate::Result<()>> {
|
||||
unimplemented!()
|
||||
Box::pin(self.conn.send_raw(commands))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,4 +30,4 @@ pub use response::{
|
|||
ColumnCountPacket, ColumnDefinitionPacket, EofPacket, ErrPacket, OkPacket, ResultRow,
|
||||
};
|
||||
pub use server_status::ServerStatusFlag;
|
||||
pub use text::{ComDebug, ComInitDb, ComPing, ComProcessKill, ComQuery, ComQuit};
|
||||
pub use text::{ComDebug, ComInitDb, ComPing, ComProcessKill, ComQuery, ComQuit, ComSetOption, SetOptionOptions};
|
||||
|
|
|
@ -54,6 +54,10 @@ where
|
|||
) -> BoxFuture<'e, crate::Result<Describe<Self::Backend>>> {
|
||||
Box::pin(async move { <&Pool<DB> as Executor>::describe(&mut &*self, query).await })
|
||||
}
|
||||
|
||||
fn send<'e, 'q: 'e>(&'e mut self, commands: &'q str) -> BoxFuture<'e, crate::Result<()>> {
|
||||
Box::pin(async move { <&Pool<DB> as Executor>::send(&mut &*self, commands).await })
|
||||
}
|
||||
}
|
||||
|
||||
impl<DB> Executor for &'_ Pool<DB>
|
||||
|
@ -107,6 +111,6 @@ where
|
|||
}
|
||||
|
||||
fn send<'e, 'q: 'e>(&'e mut self, commands: &'q str) -> BoxFuture<'e, crate::Result<()>> {
|
||||
Box::pin(async move { self.acquire().await?.batch_exec(commands).await })
|
||||
Box::pin(async move { self.acquire().await?.send(commands).await })
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue