mysql: handle EOF packets if the server still requires them (MariaDB 10.1)

This commit is contained in:
Ryan Leckey 2020-03-14 17:29:59 -07:00
parent 12fa401556
commit cc88efe436
2 changed files with 12 additions and 3 deletions

View file

@ -78,14 +78,19 @@ async fn next<'a, 'c: 'a, 'q: 'a>(
loop {
let packet_id = conn.stream.receive().await?[0];
match packet_id {
// OK or EOF packet
0x00 | 0xFE
if conn.stream.packet().len() < 0xFF_FF_FF && (packet_id != 0x00 || initial) =>
{
let ok = conn.stream.handle_ok()?;
let status = if let Some(eof) = conn.stream.maybe_handle_eof()? {
eof.status
} else {
conn.stream.handle_ok()?.status
};
if ok.status.contains(Status::SERVER_MORE_RESULTS_EXISTS) {
if status.contains(Status::SERVER_MORE_RESULTS_EXISTS) {
// There is more to this query
initial = true;
} else {
@ -124,6 +129,10 @@ async fn next<'a, 'c: 'a, 'q: 'a>(
}
}
if cc.columns > 0 {
conn.stream.maybe_receive_eof().await?;
}
cursor.column_names = Arc::new(column_names);
initial = false;
}

View file

@ -170,7 +170,7 @@ impl MySqlStream {
}
pub(crate) fn maybe_handle_eof(&mut self) -> crate::Result<Option<EofPacket>> {
if !self.capabilities.contains(Capabilities::DEPRECATE_EOF) {
if !self.capabilities.contains(Capabilities::DEPRECATE_EOF) && self.packet()[0] == 0xFE {
Ok(Some(EofPacket::decode(self.packet())?))
} else {
Ok(None)