Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(mysql): Invaild column definitions lead to incorrect mariadb-client behavior #13

Merged
merged 1 commit into from
Mar 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions mysql/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,18 +561,11 @@ impl<B: AsyncMysqlShim<Cursor<Vec<u8>>> + Send + Sync, S: AsyncRead + AsyncWrite
// NOTE: spec dictates no response from server
}
Command::ListFields(_) => {
let cols = &[Column {
table: String::new(),
column: "not implemented".to_owned(),
coltype: myc::constants::ColumnType::MYSQL_TYPE_SHORT,
colflags: myc::constants::ColumnFlags::UNSIGNED_FLAG,
}];
writers::write_column_definitions_41(
cols,
&mut self.writer,
self.client_capabilities,
true,
)?;
// mysql_list_fields (CommandByte::COM_FIELD_LIST / 0x04) has been deprecated in mysql 5.7
// and will be removed in a future version.
// The mysql command line tool issues one of these commands after switching databases with USE <DB>.
// Return a invalid column definitions lead to incorrect mariadb-client behaviour,
// see https://github.com/datafuselabs/databend/issues/4439
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But will this make incorrect to old mysql client behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not returning column definitions is acceptable behavior for the client. column information is used as completion, no return is better than invalid.

I also tested mysql-client 5.7 locally, it works.

let ok_packet = OkResponse {
header: 0xfe,
..Default::default()
Expand Down