Skip to content

add support for binary format in tuple data #28

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

Merged
merged 1 commit into from
Nov 28, 2024
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
9 changes: 9 additions & 0 deletions postgres-replication/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 {
Expand All @@ -443,6 +446,12 @@ impl TupleData {
buf.read_exact(&mut data)?;
TupleData::Text(data.into())
}
TUPLE_DATA_BINARY_TAG => {
let len = buf.read_i32::<BigEndian>()?;
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,
Expand Down
Loading