From 20265ef38e32a06f76b6f9b678e2077fc2211f6b Mon Sep 17 00:00:00 2001 From: Raminder Singh Date: Fri, 8 Nov 2024 17:46:31 +0530 Subject: [PATCH] add support for binary format in tuple data --- postgres-replication/src/protocol.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/postgres-replication/src/protocol.rs b/postgres-replication/src/protocol.rs index d9482501..2344f372 100644 --- a/postgres-replication/src/protocol.rs +++ b/postgres-replication/src/protocol.rs @@ -26,6 +26,7 @@ const TUPLE_OLD_TAG: u8 = b'O'; const TUPLE_DATA_NULL_TAG: u8 = b'n'; const TUPLE_DATA_TOAST_TAG: u8 = b'u'; const TUPLE_DATA_TEXT_TAG: u8 = b't'; +const TUPLE_DATA_BINARY_TAG: u8 = b'b'; // replica identity tags const REPLICA_IDENTITY_DEFAULT_TAG: u8 = b'd'; @@ -428,6 +429,8 @@ pub enum TupleData { UnchangedToast, /// Column data as text formatted value. Text(Bytes), + /// Column data as binary formatted value. + Binary(Bytes), } impl TupleData { @@ -443,6 +446,12 @@ impl TupleData { buf.read_exact(&mut data)?; TupleData::Text(data.into()) } + TUPLE_DATA_BINARY_TAG => { + let len = buf.read_i32::()?; + let mut data = vec![0; len as usize]; + buf.read_exact(&mut data)?; + TupleData::Binary(data.into()) + } tag => { return Err(io::Error::new( io::ErrorKind::InvalidInput,