postgres_ffi/wal_generate: add last_wal_record_xlog_switch and use it in tests

Fix #1190: WalDecoder did not return correct LSN of the next record after
processing a XLOG_SWITCH record
This commit is contained in:
Egor Suvorov
2022-06-25 00:53:45 +03:00
committed by Egor Suvorov
parent 52f445094a
commit 85bda437de
4 changed files with 26 additions and 4 deletions

View File

@@ -226,10 +226,10 @@ impl WalStreamDecoder {
self.padlen = self.lsn.calc_padding(8u32) as u32;
}
// Always align resulting LSN on 0x8 boundary -- that is important for getPage()
// and WalReceiver integration. Since this code is used both for WalReceiver and
// initial WAL import let's force alignment right here.
let result = (self.lsn.align(), recordbuf);
// We should return LSN of the next record, not the last byte of this record or
// the byte immediately after. Note that this handles both XLOG_SWITCH and usual
// records, the former "spans" until the next WAL segment (see test_xlog_switch).
let result = (self.lsn + self.padlen as u64, recordbuf);
Ok(Some(result))
}
}