diff --git a/src/lib.rs b/src/lib.rs index c0e4323..6e3f265 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -400,6 +400,17 @@ impl, R: Read, W: Write> MysqlIntermediary { })? .1; + if !handshake + .capabilities + .contains(CapabilityFlags::CLIENT_PROTOCOL_41) + { + let err = io::Error::new( + io::ErrorKind::ConnectionAborted, + "Required capability: CLIENT_PROTOCOL_41, please upgrade your MySQL client version", + ); + return Err(err.into()); + } + self.client_capabilities = handshake.capabilities; let mut auth_response = handshake.auth_response.clone(); let auth_plugin_expect = self.shim.auth_plugin_for_username(&handshake.username); @@ -579,10 +590,9 @@ impl, R: Read, W: Write> MysqlIntermediary { coltype: myc::constants::ColumnType::MYSQL_TYPE_SHORT, colflags: myc::constants::ColumnFlags::UNSIGNED_FLAG, }]; - writers::write_column_definitions( + writers::write_column_definitions_41( cols, &mut self.writer, - true, self.client_capabilities, )?; } diff --git a/src/writers.rs b/src/writers.rs index 5605398..d61c236 100644 --- a/src/writers.rs +++ b/src/writers.rs @@ -80,14 +80,15 @@ where w.write_u16::(0)?; // number of warnings w.end_packet()?; - write_column_definitions(pi, w, false, client_capabilities)?; - write_column_definitions(ci, w, false, client_capabilities) + write_column_definitions_41(pi, w, client_capabilities)?; + write_column_definitions_41(ci, w, client_capabilities) } -pub(crate) fn write_column_definitions<'a, I, W>( +/// works for Protocol::ColumnDefinition41 is set +/// see: https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_com_query_response_text_resultset_column_definition.html +pub(crate) fn write_column_definitions_41<'a, I, W>( i: I, w: &mut PacketWriter, - is_comm_field_list_response: bool, client_capabilities: CapabilityFlags, ) -> io::Result<()> where @@ -112,13 +113,6 @@ where w.write_all(&[0x00])?; // decimals w.write_all(&[0x00, 0x00])?; // unused - if is_comm_field_list_response { - // We should write length encoded int with string size - // followed by string with some "default values" (possibly it's column defaults). - // But we just send NULL for simplicity - w.write_u8(0xfb)?; - } - w.end_packet()?; empty = false; } @@ -143,5 +137,5 @@ where let i = i.into_iter(); w.write_lenenc_int(i.len() as u64)?; w.end_packet()?; - write_column_definitions(i, w, false, client_capabilities) + write_column_definitions_41(i, w, client_capabilities) }