Skip to content

Commit

Permalink
backend: pack next record LSN into the encoded message (#33)
Browse files Browse the repository at this point in the history
This field only needs to be read after the batch is decoded,
so we can move into the body to get more efficient encoding.
  • Loading branch information
VladLazar authored Nov 27, 2024
1 parent 2a2a7c5 commit 00940fc
Showing 1 changed file with 0 additions and 11 deletions.
11 changes: 0 additions & 11 deletions postgres-protocol/src/message/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,15 +375,10 @@ impl ReplicationMessage<Bytes> {
INTERPRETED_WAL_RECORD_TAG => {
let streaming_lsn = buf.read_u64::<BigEndian>()?;
let commit_lsn = buf.read_u64::<BigEndian>()?;
let next_record_lsn = match buf.read_u64::<BigEndian>()? {
0 => None,
lsn => Some(lsn),
};

ReplicationMessage::RawInterpretedWalRecords(RawInterpretedWalRecordsBody {
streaming_lsn,
commit_lsn,
next_record_lsn,
data: buf.read_all(),
})
}
Expand Down Expand Up @@ -971,7 +966,6 @@ impl<D> XLogDataBody<D> {
pub struct RawInterpretedWalRecordsBody<D> {
streaming_lsn: u64,
commit_lsn: u64,
next_record_lsn: Option<u64>,
data: D,
}

Expand All @@ -986,11 +980,6 @@ impl<D> RawInterpretedWalRecordsBody<D> {
self.commit_lsn
}

#[inline]
pub fn next_record_lsn(&self) -> Option<u64> {
self.next_record_lsn
}

#[inline]
pub fn data(&self) -> &D {
&self.data
Expand Down

0 comments on commit 00940fc

Please sign in to comment.