lsn.diff
text/x-diff
Filename: lsn.diff
Type: text/x-diff
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/backend/access/transam/xloginsert.c | 0 | 0 |
diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c
new file mode 100644
index 3ec67d4..57f4d71
*** a/src/backend/access/transam/xloginsert.c
--- b/src/backend/access/transam/xloginsert.c
*************** XLogResetInsertion(void)
*** 208,213 ****
--- 208,215 ----
/*
* Register a reference to a buffer with the WAL record being constructed.
* This must be called for every page that the WAL-logged operation modifies.
+ * Because of page-level encryption, You cannot reference more than one
+ * RelFileNode in a WAL record; Assert checks for that.
*/
void
XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
*************** XLogRegisterBuffer(uint8 block_id, Buffe
*** 235,241 ****
/*
* Check that this page hasn't already been registered with some other
! * block_id.
*/
#ifdef USE_ASSERT_CHECKING
{
--- 237,243 ----
/*
* Check that this page hasn't already been registered with some other
! * block_id, and check for different RelFileNodes in the same WAL record.
*/
#ifdef USE_ASSERT_CHECKING
{
*************** XLogRegisterBuffer(uint8 block_id, Buffe
*** 248,256 ****
--- 250,274 ----
if (i == block_id || !regbuf_old->in_use)
continue;
+ /* check for duplicate block numbers */
Assert(!RelFileNodeEquals(regbuf_old->rnode, regbuf->rnode) ||
regbuf_old->forkno != regbuf->forkno ||
regbuf_old->block != regbuf->block);
+
+ /*
+ * The initialization vector (IV) is used for page-level
+ * encryption. We use the LSN and page number as the IV, and IV
+ * values must never be reused since it is insecure. It is safe
+ * to use the LSN on multiple pages in the same relation since
+ * the page number is part of the IV. It is unsafe to reuse the
+ * LSN in different relations because the page number might be
+ * the same, and hence the IV. Therefore, we check here that
+ * we don't have WAL records for different relations using the
+ * same LSN. We only encrypt MAIN_FORKNUM files.
+ */
+ Assert(RelFileNodeEquals(regbuf_old->rnode, regbuf->rnode) ||
+ regbuf_old->forkno != MAIN_FORKNUM ||
+ regbuf->forkno != MAIN_FORKNUM);
}
}
#endif