Skip to content

Commit 2e372c3

Browse files
author
Konstantin Knizhnik
committed
Supprot opaque mode for log_newpages
1 parent b810fdf commit 2e372c3

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed

src/backend/access/gist/gistbuild.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ gist_indexsortbuild_flush_ready_pages(GISTBuildState *state)
685685

686686
if (RelationNeedsWAL(state->indexrel))
687687
log_newpages(&state->indexrel->rd_locator, MAIN_FORKNUM, state->ready_num_pages,
688-
state->ready_blknos, state->ready_pages, true);
688+
state->ready_blknos, state->ready_pages, REGBUF_STANDARD);
689689

690690
for (int i = 0; i < state->ready_num_pages; i++)
691691
pfree(state->ready_pages[i]);

src/backend/access/transam/xloginsert.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,8 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
638638

639639
if ((regbuf->flags & REGBUF_WILL_INIT) == REGBUF_WILL_INIT)
640640
bkpb.fork_flags |= BKPBLOCK_WILL_INIT;
641+
if (regbuf->flags & REGBUF_OPAQUE)
642+
bkpb.fork_flags |= BKPBLOCK_OPAQUE;
641643

642644
/*
643645
* If needs_backup is true or WAL checking is enabled for current
@@ -1186,16 +1188,13 @@ log_newpage(RelFileLocator *rlocator, ForkNumber forknum, BlockNumber blkno,
11861188
*/
11871189
void
11881190
log_newpages(RelFileLocator *rlocator, ForkNumber forknum, int num_pages,
1189-
BlockNumber *blknos, Page *pages, bool page_std)
1191+
BlockNumber *blknos, Page *pages, int flags)
11901192
{
1191-
int flags;
11921193
XLogRecPtr recptr;
11931194
int i;
11941195
int j;
11951196

1196-
flags = REGBUF_FORCE_IMAGE;
1197-
if (page_std)
1198-
flags |= REGBUF_STANDARD;
1197+
flags |= REGBUF_FORCE_IMAGE;
11991198

12001199
/*
12011200
* Iterate over all the pages. They are collected into batches of
@@ -1228,7 +1227,7 @@ log_newpages(RelFileLocator *rlocator, ForkNumber forknum, int num_pages,
12281227
* The page may be uninitialized. If so, we can't set the LSN
12291228
* because that would corrupt the page.
12301229
*/
1231-
if (!PageIsNew(pages[j]))
1230+
if (!(flags & REGBUF_OPAQUE) && !PageIsNew(pages[j]))
12321231
{
12331232
PageSetLSN(pages[j], recptr);
12341233
}

src/backend/access/transam/xlogutils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ XLogReadBufferForRedoExtended(XLogReaderState *record,
418418
* The page may be uninitialized. If so, we can't set the LSN because
419419
* that would corrupt the page.
420420
*/
421-
if (!PageIsNew(page))
421+
if (!(XLogRecGetBlock(record, block_id)->flags & BKPBLOCK_OPAQUE) && !PageIsNew(page))
422422
{
423423
PageSetLSN(page, lsn);
424424
}

src/include/access/xloginsert.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
* will be skipped) */
3838
#define REGBUF_KEEP_DATA 0x10 /* include data even if a full-page image
3939
* is taken */
40+
#define REGBUF_OPAQUE 0x40 /* Do not interprete page header */
4041

4142
extern int max_replication_apply_lag;
4243
extern int max_replication_flush_lag;
@@ -59,7 +60,7 @@ extern bool XLogCheckBufferNeedsBackup(Buffer buffer);
5960
extern XLogRecPtr log_newpage(RelFileLocator *rlocator, ForkNumber forknum,
6061
BlockNumber blkno, char *page, bool page_std);
6162
extern void log_newpages(RelFileLocator *rlocator, ForkNumber forknum, int num_pages,
62-
BlockNumber *blknos, char **pages, bool page_std);
63+
BlockNumber *blknos, char **pages, int flags);
6364
extern XLogRecPtr log_newpage_buffer(Buffer buffer, bool page_std);
6465
extern void log_newpage_range(Relation rel, ForkNumber forknum,
6566
BlockNumber startblk, BlockNumber endblk, bool page_std);

src/include/access/xlogrecord.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,12 @@ typedef struct XLogRecordBlockCompressHeader
190190
sizeof(BlockNumber))
191191

192192
/*
193-
* The fork number fits in the lower 4 bits in the fork_flags field. The upper
193+
* The fork number fits in the lower 3 bits in the fork_flags field. The upper
194194
* bits are used for flags.
195195
*/
196-
#define BKPBLOCK_FORK_MASK 0x0F
197-
#define BKPBLOCK_FLAG_MASK 0xF0
196+
#define BKPBLOCK_FORK_MASK 0x07
197+
#define BKPBLOCK_FLAG_MASK 0xF8
198+
#define BKPBLOCK_OPAQUE 0x08
198199
#define BKPBLOCK_HAS_IMAGE 0x10 /* block data is an XLogRecordBlockImage */
199200
#define BKPBLOCK_HAS_DATA 0x20
200201
#define BKPBLOCK_WILL_INIT 0x40 /* redo will re-init the page */

0 commit comments

Comments
 (0)