Skip to content

Commit c73816e

Browse files
authored
Merge pull request jonhoo#18 from datafuse-extras/COM_FIELD_LIST
Fix response in serving COM_FIELD_LIST
2 parents 8d3e953 + 76b8ae3 commit c73816e

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ impl<B: MysqlShim<W>, R: Read, W: Write> MysqlIntermediary<B, R, W> {
388388
coltype: myc::constants::ColumnType::MYSQL_TYPE_SHORT,
389389
colflags: myc::constants::ColumnFlags::UNSIGNED_FLAG,
390390
}];
391-
writers::write_column_definitions(cols, &mut self.writer, true)?;
391+
writers::write_column_definitions(cols, &mut self.writer, true, true)?;
392392
}
393393
Command::Init(schema) => {
394394
let w = InitWriter {

src/writers.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,14 @@ where
6464
w.write_u16::<LittleEndian>(0)?; // number of warnings
6565
w.end_packet()?;
6666

67-
write_column_definitions(pi, w, true)?;
68-
write_column_definitions(ci, w, true)
67+
write_column_definitions(pi, w, false, true)?;
68+
write_column_definitions(ci, w, false, true)
6969
}
7070

7171
pub(crate) fn write_column_definitions<'a, I, W>(
7272
i: I,
7373
w: &mut PacketWriter<W>,
74+
is_comm_field_list_response: bool,
7475
only_eof_on_nonempty: bool,
7576
) -> io::Result<()>
7677
where
@@ -94,6 +95,14 @@ where
9495
w.write_u16::<LittleEndian>(c.colflags.bits())?;
9596
w.write_all(&[0x00])?; // decimals
9697
w.write_all(&[0x00, 0x00])?; // unused
98+
99+
if is_comm_field_list_response {
100+
// We should write length encoded int with string size
101+
// followed by string with some "default values" (possibly it's column defaults).
102+
// But we just send NULL for simplicity
103+
w.write_u8(0xfb)?;
104+
}
105+
97106
w.end_packet()?;
98107
empty = false;
99108
}
@@ -114,5 +123,5 @@ where
114123
let i = i.into_iter();
115124
w.write_lenenc_int(i.len() as u64)?;
116125
w.end_packet()?;
117-
write_column_definitions(i, w, false)
126+
write_column_definitions(i, w, false, false)
118127
}

0 commit comments

Comments
 (0)