Skip to content

Commit 20265ef

Browse files
committed
add support for binary format in tuple data
1 parent 548f00c commit 20265ef

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Diff for: postgres-replication/src/protocol.rs

+9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const TUPLE_OLD_TAG: u8 = b'O';
2626
const TUPLE_DATA_NULL_TAG: u8 = b'n';
2727
const TUPLE_DATA_TOAST_TAG: u8 = b'u';
2828
const TUPLE_DATA_TEXT_TAG: u8 = b't';
29+
const TUPLE_DATA_BINARY_TAG: u8 = b'b';
2930

3031
// replica identity tags
3132
const REPLICA_IDENTITY_DEFAULT_TAG: u8 = b'd';
@@ -428,6 +429,8 @@ pub enum TupleData {
428429
UnchangedToast,
429430
/// Column data as text formatted value.
430431
Text(Bytes),
432+
/// Column data as binary formatted value.
433+
Binary(Bytes),
431434
}
432435

433436
impl TupleData {
@@ -443,6 +446,12 @@ impl TupleData {
443446
buf.read_exact(&mut data)?;
444447
TupleData::Text(data.into())
445448
}
449+
TUPLE_DATA_BINARY_TAG => {
450+
let len = buf.read_i32::<BigEndian>()?;
451+
let mut data = vec![0; len as usize];
452+
buf.read_exact(&mut data)?;
453+
TupleData::Binary(data.into())
454+
}
446455
tag => {
447456
return Err(io::Error::new(
448457
io::ErrorKind::InvalidInput,

0 commit comments

Comments
 (0)