PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
brin_xlog.c File Reference
#include "postgres.h"
#include "access/brin_page.h"
#include "access/brin_pageops.h"
#include "access/brin_xlog.h"
#include "access/bufmask.h"
#include "access/xlogutils.h"
Include dependency graph for brin_xlog.c:

Go to the source code of this file.

Functions

static void brin_xlog_createidx (XLogReaderState *record)
 
static void brin_xlog_insert_update (XLogReaderState *record, xl_brin_insert *xlrec)
 
static void brin_xlog_insert (XLogReaderState *record)
 
static void brin_xlog_update (XLogReaderState *record)
 
static void brin_xlog_samepage_update (XLogReaderState *record)
 
static void brin_xlog_revmap_extend (XLogReaderState *record)
 
static void brin_xlog_desummarize_page (XLogReaderState *record)
 
void brin_redo (XLogReaderState *record)
 
void brin_mask (char *pagedata, BlockNumber blkno)
 

Function Documentation

void brin_mask ( char *  pagedata,
BlockNumber  blkno 
)

Definition at line 331 of file brin_xlog.c.

References BRIN_IS_REGULAR_PAGE, mask_page_hint_bits(), mask_page_lsn_and_checksum(), and mask_unused_space().

332 {
333  Page page = (Page) pagedata;
334 
336 
337  mask_page_hint_bits(page);
338 
339  if (BRIN_IS_REGULAR_PAGE(page))
340  {
341  /* Regular brin pages contain unused space which needs to be masked. */
342  mask_unused_space(page);
343  }
344 }
void mask_page_hint_bits(Page page)
Definition: bufmask.c:46
#define BRIN_IS_REGULAR_PAGE(page)
Definition: brin_page.h:57
void mask_unused_space(Page page)
Definition: bufmask.c:71
void mask_page_lsn_and_checksum(Page page)
Definition: bufmask.c:31
Pointer Page
Definition: bufpage.h:74
void brin_redo ( XLogReaderState record)

Definition at line 298 of file brin_xlog.c.

References brin_xlog_createidx(), brin_xlog_desummarize_page(), brin_xlog_insert(), brin_xlog_revmap_extend(), brin_xlog_samepage_update(), brin_xlog_update(), elog, PANIC, XLOG_BRIN_CREATE_INDEX, XLOG_BRIN_DESUMMARIZE, XLOG_BRIN_INSERT, XLOG_BRIN_OPMASK, XLOG_BRIN_REVMAP_EXTEND, XLOG_BRIN_SAMEPAGE_UPDATE, XLOG_BRIN_UPDATE, XLogRecGetInfo, and XLR_INFO_MASK.

299 {
300  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
301 
302  switch (info & XLOG_BRIN_OPMASK)
303  {
305  brin_xlog_createidx(record);
306  break;
307  case XLOG_BRIN_INSERT:
308  brin_xlog_insert(record);
309  break;
310  case XLOG_BRIN_UPDATE:
311  brin_xlog_update(record);
312  break;
315  break;
317  brin_xlog_revmap_extend(record);
318  break;
321  break;
322  default:
323  elog(PANIC, "brin_redo: unknown op code %u", info);
324  }
325 }
static void brin_xlog_revmap_extend(XLogReaderState *record)
Definition: brin_xlog.c:208
static void brin_xlog_update(XLogReaderState *record)
Definition: brin_xlog.c:135
static void brin_xlog_createidx(XLogReaderState *record)
Definition: brin_xlog.c:24
unsigned char uint8
Definition: c.h:256
#define XLOG_BRIN_CREATE_INDEX
Definition: brin_xlog.h:31
#define PANIC
Definition: elog.h:53
#define XLOG_BRIN_UPDATE
Definition: brin_xlog.h:33
static void brin_xlog_insert(XLogReaderState *record)
Definition: brin_xlog.c:124
#define XLOG_BRIN_DESUMMARIZE
Definition: brin_xlog.h:36
static void brin_xlog_desummarize_page(XLogReaderState *record)
Definition: brin_xlog.c:258
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:222
#define XLOG_BRIN_REVMAP_EXTEND
Definition: brin_xlog.h:35
#define XLOG_BRIN_INSERT
Definition: brin_xlog.h:32
static void brin_xlog_samepage_update(XLogReaderState *record)
Definition: brin_xlog.c:170
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_BRIN_SAMEPAGE_UPDATE
Definition: brin_xlog.h:34
#define XLOG_BRIN_OPMASK
Definition: brin_xlog.h:38
#define elog
Definition: elog.h:219
static void brin_xlog_createidx ( XLogReaderState record)
static

Definition at line 24 of file brin_xlog.c.

References Assert, brin_metapage_init(), buf, BufferGetPage, BufferIsValid, XLogReaderState::EndRecPtr, MarkBufferDirty(), PageSetLSN, xl_brin_createidx::pagesPerRange, UnlockReleaseBuffer(), xl_brin_createidx::version, XLogInitBufferForRedo(), and XLogRecGetData.

Referenced by brin_redo().

25 {
26  XLogRecPtr lsn = record->EndRecPtr;
28  Buffer buf;
29  Page page;
30 
31  /* create the index' metapage */
32  buf = XLogInitBufferForRedo(record, 0);
33  Assert(BufferIsValid(buf));
34  page = (Page) BufferGetPage(buf);
35  brin_metapage_init(page, xlrec->pagesPerRange, xlrec->version);
36  PageSetLSN(page, lsn);
37  MarkBufferDirty(buf);
39 }
void MarkBufferDirty(Buffer buffer)
Definition: bufmgr.c:1450
XLogRecPtr EndRecPtr
Definition: xlogreader.h:120
#define XLogRecGetData(decoder)
Definition: xlogreader.h:226
void brin_metapage_init(Page page, BlockNumber pagesPerRange, uint16 version)
Definition: brin_pageops.c:476
void UnlockReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3332
Buffer XLogInitBufferForRedo(XLogReaderState *record, uint8 block_id)
Definition: xlogutils.c:302
static char * buf
Definition: pg_test_fsync.c:67
#define BufferGetPage(buffer)
Definition: bufmgr.h:160
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define Assert(condition)
Definition: c.h:681
#define BufferIsValid(bufnum)
Definition: bufmgr.h:114
BlockNumber pagesPerRange
Definition: brin_xlog.h:52
#define PageSetLSN(page, lsn)
Definition: bufpage.h:364
int Buffer
Definition: buf.h:23
Pointer Page
Definition: bufpage.h:74
static void brin_xlog_desummarize_page ( XLogReaderState record)
static

Definition at line 258 of file brin_xlog.c.

References BLK_NEEDS_REDO, brinSetHeapBlockItemptr(), buffer, BufferGetPage, BufferIsValid, XLogReaderState::EndRecPtr, xl_brin_desummarize::heapBlk, ItemPointerSetInvalid, MarkBufferDirty(), PageIndexTupleDeleteNoCompact(), PageSetLSN, xl_brin_desummarize::pagesPerRange, xl_brin_desummarize::regOffset, UnlockReleaseBuffer(), XLogReadBufferForRedo(), and XLogRecGetData.

Referenced by brin_redo().

259 {
260  XLogRecPtr lsn = record->EndRecPtr;
261  xl_brin_desummarize *xlrec;
262  Buffer buffer;
263  XLogRedoAction action;
264 
265  xlrec = (xl_brin_desummarize *) XLogRecGetData(record);
266 
267  /* Update the revmap */
268  action = XLogReadBufferForRedo(record, 0, &buffer);
269  if (action == BLK_NEEDS_REDO)
270  {
271  ItemPointerData iptr;
272 
273  ItemPointerSetInvalid(&iptr);
274  brinSetHeapBlockItemptr(buffer, xlrec->pagesPerRange, xlrec->heapBlk, iptr);
275 
276  PageSetLSN(BufferGetPage(buffer), lsn);
277  MarkBufferDirty(buffer);
278  }
279  if (BufferIsValid(buffer))
280  UnlockReleaseBuffer(buffer);
281 
282  /* remove the leftover entry from the regular page */
283  action = XLogReadBufferForRedo(record, 1, &buffer);
284  if (action == BLK_NEEDS_REDO)
285  {
286  Page regPg = BufferGetPage(buffer);
287 
289 
290  PageSetLSN(regPg, lsn);
291  MarkBufferDirty(buffer);
292  }
293  if (BufferIsValid(buffer))
294  UnlockReleaseBuffer(buffer);
295 }
OffsetNumber regOffset
Definition: brin_xlog.h:139
BlockNumber pagesPerRange
Definition: brin_xlog.h:135
void MarkBufferDirty(Buffer buffer)
Definition: bufmgr.c:1450
XLogRecPtr EndRecPtr
Definition: xlogreader.h:120
#define XLogRecGetData(decoder)
Definition: xlogreader.h:226
void UnlockReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3332
#define BufferGetPage(buffer)
Definition: bufmgr.h:160
void PageIndexTupleDeleteNoCompact(Page page, OffsetNumber offnum)
Definition: bufpage.c:958
XLogRedoAction XLogReadBufferForRedo(XLogReaderState *record, uint8 block_id, Buffer *buf)
Definition: xlogutils.c:290
uint64 XLogRecPtr
Definition: xlogdefs.h:21
WalTimeSample buffer[LAG_TRACKER_BUFFER_SIZE]
Definition: walsender.c:214
XLogRedoAction
Definition: xlogutils.h:27
#define BufferIsValid(bufnum)
Definition: bufmgr.h:114
BlockNumber heapBlk
Definition: brin_xlog.h:137
#define ItemPointerSetInvalid(pointer)
Definition: itemptr.h:150
void brinSetHeapBlockItemptr(Buffer buf, BlockNumber pagesPerRange, BlockNumber heapBlk, ItemPointerData tid)
Definition: brin_revmap.c:158
#define PageSetLSN(page, lsn)
Definition: bufpage.h:364
int Buffer
Definition: buf.h:23
Pointer Page
Definition: bufpage.h:74
static void brin_xlog_insert ( XLogReaderState record)
static

Definition at line 124 of file brin_xlog.c.

References brin_xlog_insert_update(), and XLogRecGetData.

Referenced by brin_redo().

125 {
126  xl_brin_insert *xlrec = (xl_brin_insert *) XLogRecGetData(record);
127 
128  brin_xlog_insert_update(record, xlrec);
129 }
#define XLogRecGetData(decoder)
Definition: xlogreader.h:226
static void brin_xlog_insert_update(XLogReaderState *record, xl_brin_insert *xlrec)
Definition: brin_xlog.c:46
static void brin_xlog_insert_update ( XLogReaderState record,
xl_brin_insert xlrec 
)
static

Definition at line 46 of file brin_xlog.c.

References Assert, BLK_NEEDS_REDO, brin_page_init(), BRIN_PAGETYPE_REGULAR, brinSetHeapBlockItemptr(), BrinTuple::bt_blkno, buffer, BufferGetBlockNumber(), BufferGetPage, BufferIsValid, elog, XLogReaderState::EndRecPtr, xl_brin_insert::heapBlk, InvalidOffsetNumber, ItemPointerSet, MarkBufferDirty(), xl_brin_insert::offnum, PageAddItem, PageGetMaxOffsetNumber, PageSetLSN, xl_brin_insert::pagesPerRange, PANIC, UnlockReleaseBuffer(), XLOG_BRIN_INIT_PAGE, XLogInitBufferForRedo(), XLogReadBufferForRedo(), XLogRecGetBlockData(), and XLogRecGetInfo.

Referenced by brin_xlog_insert(), and brin_xlog_update().

48 {
49  XLogRecPtr lsn = record->EndRecPtr;
50  Buffer buffer;
51  BlockNumber regpgno;
52  Page page;
53  XLogRedoAction action;
54 
55  /*
56  * If we inserted the first and only tuple on the page, re-initialize the
57  * page from scratch.
58  */
59  if (XLogRecGetInfo(record) & XLOG_BRIN_INIT_PAGE)
60  {
61  buffer = XLogInitBufferForRedo(record, 0);
62  page = BufferGetPage(buffer);
64  action = BLK_NEEDS_REDO;
65  }
66  else
67  {
68  action = XLogReadBufferForRedo(record, 0, &buffer);
69  }
70 
71  /* need this page's blkno to store in revmap */
72  regpgno = BufferGetBlockNumber(buffer);
73 
74  /* insert the index item into the page */
75  if (action == BLK_NEEDS_REDO)
76  {
77  OffsetNumber offnum;
78  BrinTuple *tuple;
79  Size tuplen;
80 
81  tuple = (BrinTuple *) XLogRecGetBlockData(record, 0, &tuplen);
82 
83  Assert(tuple->bt_blkno == xlrec->heapBlk);
84 
85  page = (Page) BufferGetPage(buffer);
86  offnum = xlrec->offnum;
87  if (PageGetMaxOffsetNumber(page) + 1 < offnum)
88  elog(PANIC, "brin_xlog_insert_update: invalid max offset number");
89 
90  offnum = PageAddItem(page, (Item) tuple, tuplen, offnum, true, false);
91  if (offnum == InvalidOffsetNumber)
92  elog(PANIC, "brin_xlog_insert_update: failed to add tuple");
93 
94  PageSetLSN(page, lsn);
95  MarkBufferDirty(buffer);
96  }
97  if (BufferIsValid(buffer))
98  UnlockReleaseBuffer(buffer);
99 
100  /* update the revmap */
101  action = XLogReadBufferForRedo(record, 1, &buffer);
102  if (action == BLK_NEEDS_REDO)
103  {
104  ItemPointerData tid;
105 
106  ItemPointerSet(&tid, regpgno, xlrec->offnum);
107  page = (Page) BufferGetPage(buffer);
108 
109  brinSetHeapBlockItemptr(buffer, xlrec->pagesPerRange, xlrec->heapBlk,
110  tid);
111  PageSetLSN(page, lsn);
112  MarkBufferDirty(buffer);
113  }
114  if (BufferIsValid(buffer))
115  UnlockReleaseBuffer(buffer);
116 
117  /* XXX no FSM updates here ... */
118 }
BlockNumber heapBlk
Definition: brin_xlog.h:65
void MarkBufferDirty(Buffer buffer)
Definition: bufmgr.c:1450
Pointer Item
Definition: item.h:17
#define PageAddItem(page, item, size, offsetNumber, overwrite, is_heap)
Definition: bufpage.h:412
uint32 BlockNumber
Definition: block.h:31
#define PANIC
Definition: elog.h:53
#define PageGetMaxOffsetNumber(page)
Definition: bufpage.h:353
XLogRecPtr EndRecPtr
Definition: xlogreader.h:120
uint16 OffsetNumber
Definition: off.h:24
void UnlockReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3332
Buffer XLogInitBufferForRedo(XLogReaderState *record, uint8 block_id)
Definition: xlogutils.c:302
#define BRIN_PAGETYPE_REGULAR
Definition: brin_page.h:53
BlockNumber pagesPerRange
Definition: brin_xlog.h:68
#define BufferGetPage(buffer)
Definition: bufmgr.h:160
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:222
#define XLOG_BRIN_INIT_PAGE
Definition: brin_xlog.h:43
char * XLogRecGetBlockData(XLogReaderState *record, uint8 block_id, Size *len)
Definition: xlogreader.c:1333
#define InvalidOffsetNumber
Definition: off.h:26
BlockNumber bt_blkno
Definition: brin_tuple.h:57
XLogRedoAction XLogReadBufferForRedo(XLogReaderState *record, uint8 block_id, Buffer *buf)
Definition: xlogutils.c:290
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define Assert(condition)
Definition: c.h:681
WalTimeSample buffer[LAG_TRACKER_BUFFER_SIZE]
Definition: walsender.c:214
XLogRedoAction
Definition: xlogutils.h:27
size_t Size
Definition: c.h:350
OffsetNumber offnum
Definition: brin_xlog.h:71
#define BufferIsValid(bufnum)
Definition: bufmgr.h:114
BlockNumber BufferGetBlockNumber(Buffer buffer)
Definition: bufmgr.c:2605
#define elog
Definition: elog.h:219
void brinSetHeapBlockItemptr(Buffer buf, BlockNumber pagesPerRange, BlockNumber heapBlk, ItemPointerData tid)
Definition: brin_revmap.c:158
#define PageSetLSN(page, lsn)
Definition: bufpage.h:364
int Buffer
Definition: buf.h:23
Pointer Page
Definition: bufpage.h:74
#define ItemPointerSet(pointer, blockNumber, offNum)
Definition: itemptr.h:105
void brin_page_init(Page page, uint16 type)
Definition: brin_pageops.c:465
static void brin_xlog_revmap_extend ( XLogReaderState record)
static

Definition at line 208 of file brin_xlog.c.

References Assert, BLK_NEEDS_REDO, brin_page_init(), BRIN_PAGETYPE_REVMAP, buf, BufferGetPage, BufferIsValid, XLogReaderState::EndRecPtr, BrinMetaPageData::lastRevmapPage, MarkBufferDirty(), PageGetContents, PageSetLSN, xl_brin_revmap_extend::targetBlk, UnlockReleaseBuffer(), XLogInitBufferForRedo(), XLogReadBufferForRedo(), XLogRecGetBlockTag(), and XLogRecGetData.

Referenced by brin_redo().

209 {
210  XLogRecPtr lsn = record->EndRecPtr;
211  xl_brin_revmap_extend *xlrec;
212  Buffer metabuf;
213  Buffer buf;
214  Page page;
215  BlockNumber targetBlk;
216  XLogRedoAction action;
217 
218  xlrec = (xl_brin_revmap_extend *) XLogRecGetData(record);
219 
220  XLogRecGetBlockTag(record, 1, NULL, NULL, &targetBlk);
221  Assert(xlrec->targetBlk == targetBlk);
222 
223  /* Update the metapage */
224  action = XLogReadBufferForRedo(record, 0, &metabuf);
225  if (action == BLK_NEEDS_REDO)
226  {
227  Page metapg;
228  BrinMetaPageData *metadata;
229 
230  metapg = BufferGetPage(metabuf);
231  metadata = (BrinMetaPageData *) PageGetContents(metapg);
232 
233  Assert(metadata->lastRevmapPage == xlrec->targetBlk - 1);
234  metadata->lastRevmapPage = xlrec->targetBlk;
235 
236  PageSetLSN(metapg, lsn);
237  MarkBufferDirty(metabuf);
238  }
239 
240  /*
241  * Re-init the target block as a revmap page. There's never a full- page
242  * image here.
243  */
244 
245  buf = XLogInitBufferForRedo(record, 1);
246  page = (Page) BufferGetPage(buf);
248 
249  PageSetLSN(page, lsn);
250  MarkBufferDirty(buf);
251 
252  UnlockReleaseBuffer(buf);
253  if (BufferIsValid(metabuf))
254  UnlockReleaseBuffer(metabuf);
255 }
void MarkBufferDirty(Buffer buffer)
Definition: bufmgr.c:1450
uint32 BlockNumber
Definition: block.h:31
XLogRecPtr EndRecPtr
Definition: xlogreader.h:120
#define XLogRecGetData(decoder)
Definition: xlogreader.h:226
void UnlockReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3332
Buffer XLogInitBufferForRedo(XLogReaderState *record, uint8 block_id)
Definition: xlogutils.c:302
static char * buf
Definition: pg_test_fsync.c:67
#define BufferGetPage(buffer)
Definition: bufmgr.h:160
BlockNumber targetBlk
Definition: brin_xlog.h:121
BlockNumber lastRevmapPage
Definition: brin_page.h:69
bool XLogRecGetBlockTag(XLogReaderState *record, uint8 block_id, RelFileNode *rnode, ForkNumber *forknum, BlockNumber *blknum)
Definition: xlogreader.c:1309
#define PageGetContents(page)
Definition: bufpage.h:242
XLogRedoAction XLogReadBufferForRedo(XLogReaderState *record, uint8 block_id, Buffer *buf)
Definition: xlogutils.c:290
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define Assert(condition)
Definition: c.h:681
XLogRedoAction
Definition: xlogutils.h:27
#define BRIN_PAGETYPE_REVMAP
Definition: brin_page.h:52
#define BufferIsValid(bufnum)
Definition: bufmgr.h:114
#define PageSetLSN(page, lsn)
Definition: bufpage.h:364
int Buffer
Definition: buf.h:23
Pointer Page
Definition: bufpage.h:74
void brin_page_init(Page page, uint16 type)
Definition: brin_pageops.c:465
static void brin_xlog_samepage_update ( XLogReaderState record)
static

Definition at line 170 of file brin_xlog.c.

References BLK_NEEDS_REDO, buffer, BufferGetPage, BufferIsValid, elog, XLogReaderState::EndRecPtr, MarkBufferDirty(), xl_brin_samepage_update::offnum, PageIndexTupleOverwrite(), PageSetLSN, PANIC, UnlockReleaseBuffer(), XLogReadBufferForRedo(), XLogRecGetBlockData(), and XLogRecGetData.

Referenced by brin_redo().

171 {
172  XLogRecPtr lsn = record->EndRecPtr;
174  Buffer buffer;
175  XLogRedoAction action;
176 
177  xlrec = (xl_brin_samepage_update *) XLogRecGetData(record);
178  action = XLogReadBufferForRedo(record, 0, &buffer);
179  if (action == BLK_NEEDS_REDO)
180  {
181  Size tuplen;
182  BrinTuple *brintuple;
183  Page page;
184  OffsetNumber offnum;
185 
186  brintuple = (BrinTuple *) XLogRecGetBlockData(record, 0, &tuplen);
187 
188  page = (Page) BufferGetPage(buffer);
189 
190  offnum = xlrec->offnum;
191 
192  if (!PageIndexTupleOverwrite(page, offnum, (Item) brintuple, tuplen))
193  elog(PANIC, "brin_xlog_samepage_update: failed to replace tuple");
194 
195  PageSetLSN(page, lsn);
196  MarkBufferDirty(buffer);
197  }
198  if (BufferIsValid(buffer))
199  UnlockReleaseBuffer(buffer);
200 
201  /* XXX no FSM updates here ... */
202 }
void MarkBufferDirty(Buffer buffer)
Definition: bufmgr.c:1450
OffsetNumber offnum
Definition: brin_xlog.h:104
Pointer Item
Definition: item.h:17
#define PANIC
Definition: elog.h:53
XLogRecPtr EndRecPtr
Definition: xlogreader.h:120
uint16 OffsetNumber
Definition: off.h:24
#define XLogRecGetData(decoder)
Definition: xlogreader.h:226
void UnlockReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3332
bool PageIndexTupleOverwrite(Page page, OffsetNumber offnum, Item newtup, Size newsize)
Definition: bufpage.c:1066
#define BufferGetPage(buffer)
Definition: bufmgr.h:160
char * XLogRecGetBlockData(XLogReaderState *record, uint8 block_id, Size *len)
Definition: xlogreader.c:1333
XLogRedoAction XLogReadBufferForRedo(XLogReaderState *record, uint8 block_id, Buffer *buf)
Definition: xlogutils.c:290
uint64 XLogRecPtr
Definition: xlogdefs.h:21
WalTimeSample buffer[LAG_TRACKER_BUFFER_SIZE]
Definition: walsender.c:214
XLogRedoAction
Definition: xlogutils.h:27
size_t Size
Definition: c.h:350
#define BufferIsValid(bufnum)
Definition: bufmgr.h:114
#define elog
Definition: elog.h:219
#define PageSetLSN(page, lsn)
Definition: bufpage.h:364
int Buffer
Definition: buf.h:23
Pointer Page
Definition: bufpage.h:74
static void brin_xlog_update ( XLogReaderState record)
static

Definition at line 135 of file brin_xlog.c.

References BLK_NEEDS_REDO, brin_xlog_insert_update(), buffer, BufferGetPage, BufferIsValid, XLogReaderState::EndRecPtr, xl_brin_update::insert, MarkBufferDirty(), xl_brin_update::oldOffnum, PageIndexTupleDeleteNoCompact(), PageSetLSN, UnlockReleaseBuffer(), XLogReadBufferForRedo(), and XLogRecGetData.

Referenced by brin_redo().

136 {
137  XLogRecPtr lsn = record->EndRecPtr;
138  xl_brin_update *xlrec = (xl_brin_update *) XLogRecGetData(record);
139  Buffer buffer;
140  XLogRedoAction action;
141 
142  /* First remove the old tuple */
143  action = XLogReadBufferForRedo(record, 2, &buffer);
144  if (action == BLK_NEEDS_REDO)
145  {
146  Page page;
147  OffsetNumber offnum;
148 
149  page = (Page) BufferGetPage(buffer);
150 
151  offnum = xlrec->oldOffnum;
152 
153  PageIndexTupleDeleteNoCompact(page, offnum);
154 
155  PageSetLSN(page, lsn);
156  MarkBufferDirty(buffer);
157  }
158 
159  /* Then insert the new tuple and update revmap, like in an insertion. */
160  brin_xlog_insert_update(record, &xlrec->insert);
161 
162  if (BufferIsValid(buffer))
163  UnlockReleaseBuffer(buffer);
164 }
void MarkBufferDirty(Buffer buffer)
Definition: bufmgr.c:1450
XLogRecPtr EndRecPtr
Definition: xlogreader.h:120
uint16 OffsetNumber
Definition: off.h:24
#define XLogRecGetData(decoder)
Definition: xlogreader.h:226
void UnlockReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3332
#define BufferGetPage(buffer)
Definition: bufmgr.h:160
xl_brin_insert insert
Definition: brin_xlog.h:92
void PageIndexTupleDeleteNoCompact(Page page, OffsetNumber offnum)
Definition: bufpage.c:958
XLogRedoAction XLogReadBufferForRedo(XLogReaderState *record, uint8 block_id, Buffer *buf)
Definition: xlogutils.c:290
uint64 XLogRecPtr
Definition: xlogdefs.h:21
WalTimeSample buffer[LAG_TRACKER_BUFFER_SIZE]
Definition: walsender.c:214
XLogRedoAction
Definition: xlogutils.h:27
#define BufferIsValid(bufnum)
Definition: bufmgr.h:114
static void brin_xlog_insert_update(XLogReaderState *record, xl_brin_insert *xlrec)
Definition: brin_xlog.c:46
#define PageSetLSN(page, lsn)
Definition: bufpage.h:364
OffsetNumber oldOffnum
Definition: brin_xlog.h:90
int Buffer
Definition: buf.h:23
Pointer Page
Definition: bufpage.h:74