* the same page though, so downstream we must be prepared to cope
* if this turns out to not be possible after all.
*/
+ newtup = brin_form_tuple(bdesc, heapBlk, dtup, &newsz);
samepage = brin_can_do_samepage_update(buf, origsz, newsz);
-
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
- newtup = brin_form_tuple(bdesc, heapBlk, dtup, &newsz);
-
/*
* Try to update the tuple. If this doesn't work for whatever
* reason, we need to restart from the top; the revmap might be
while (thisblock > state->bs_currRangeStart + state->bs_pagesPerRange - 1)
{
- BRIN_elog(DEBUG2, "brinbuildCallback: completed a range: %u--%u",
- state->bs_currRangeStart,
- state->bs_currRangeStart + state->bs_pagesPerRange);
+ BRIN_elog((DEBUG2,
+ "brinbuildCallback: completed a range: %u--%u",
+ state->bs_currRangeStart,
+ state->bs_currRangeStart + state->bs_pagesPerRange));
/* create the index tuple and insert it */
form_and_insert_tuple(state);
info = XLOG_BRIN_UPDATE | (extended ? XLOG_BRIN_INIT_PAGE : 0);
- xlrec.new.node = idxrel->rd_node;
- ItemPointerSet(&xlrec.new.tid, BufferGetBlockNumber(newbuf), newoff);
- xlrec.new.heapBlk = heapBlk;
- xlrec.new.tuplen = newsz;
- xlrec.new.revmapBlk = BufferGetBlockNumber(revmapbuf);
- xlrec.new.pagesPerRange = pagesPerRange;
+ xlrec.insert.node = idxrel->rd_node;
+ ItemPointerSet(&xlrec.insert.tid, BufferGetBlockNumber(newbuf), newoff);
+ xlrec.insert.heapBlk = heapBlk;
+ xlrec.insert.tuplen = newsz;
+ xlrec.insert.revmapBlk = BufferGetBlockNumber(revmapbuf);
+ xlrec.insert.pagesPerRange = pagesPerRange;
ItemPointerSet(&xlrec.oldtid, BufferGetBlockNumber(oldbuf), oldoff);
rdata[0].data = (char *) &xlrec;
elog(ERROR, "could not insert new index tuple to page");
MarkBufferDirty(*buffer);
- BRIN_elog(DEBUG2, "inserted tuple (%u,%u) for range starting at %u",
- blk, off, heapBlk);
+ BRIN_elog((DEBUG2, "inserted tuple (%u,%u) for range starting at %u",
+ blk, off, heapBlk));
ItemPointerSet(&tid, blk, off);
brinSetHeapBlockItemptr(revmapbuf, pagesPerRange, heapBlk, tid);
newblk = BufferGetBlockNumber(buf);
*was_extended = extended = true;
- BRIN_elog(DEBUG2, "brin_getinsertbuffer: extending to page %u",
- BufferGetBlockNumber(buf));
+ BRIN_elog((DEBUG2, "brin_getinsertbuffer: extending to page %u",
+ BufferGetBlockNumber(buf)));
}
else if (newblk == oldblk)
{
Assert(mapBlk != BRIN_METAPAGE_BLKNO &&
mapBlk <= revmap->rm_lastRevmapPage);
- BRIN_elog(DEBUG2, "getting revmap page for logical page %lu (physical %u) for heap %u",
- HEAPBLK_TO_REVMAP_BLK(revmap->rm_pagesPerRange, heapBlk),
- mapBlk, heapBlk);
-
/*
* Obtain the buffer from which we need to read. If we already have the
* correct buffer in our access struct, use that; otherwise, release that,
/* First remove the old tuple */
blkno = ItemPointerGetBlockNumber(&(xlrec->oldtid));
- action = XLogReadBufferForRedo(lsn, record, 2, xlrec->new.node,
+ action = XLogReadBufferForRedo(lsn, record, 2, xlrec->insert.node,
blkno, &buffer);
if (action == BLK_NEEDS_REDO)
{
}
/* Then insert the new tuple and update revmap, like in an insertion. */
- brin_xlog_insert_update(lsn, record, &xlrec->new, newtup);
+ brin_xlog_insert_update(lsn, record, &xlrec->insert, newtup);
if (BufferIsValid(buffer))
UnlockReleaseBuffer(buffer);
xl_brin_update *xlrec = (xl_brin_update *) rec;
appendStringInfo(buf, "rel %u/%u/%u heapBlk %u revmapBlk %u pagesPerRange %u old TID (%u,%u) TID (%u,%u)",
- xlrec->new.node.spcNode, xlrec->new.node.dbNode,
- xlrec->new.node.relNode,
- xlrec->new.heapBlk, xlrec->new.revmapBlk,
- xlrec->new.pagesPerRange,
+ xlrec->insert.node.spcNode, xlrec->insert.node.dbNode,
+ xlrec->insert.node.relNode,
+ xlrec->insert.heapBlk, xlrec->insert.revmapBlk,
+ xlrec->insert.pagesPerRange,
ItemPointerGetBlockNumber(&xlrec->oldtid),
ItemPointerGetOffsetNumber(&xlrec->oldtid),
- ItemPointerGetBlockNumber(&xlrec->new.tid),
- ItemPointerGetOffsetNumber(&xlrec->new.tid));
+ ItemPointerGetBlockNumber(&xlrec->insert.tid),
+ ItemPointerGetOffsetNumber(&xlrec->insert.tid));
}
else if (info == XLOG_BRIN_SAMEPAGE_UPDATE)
{
#define BRIN_PROCNUM_UNION 4
/* procedure numbers up to 10 are reserved for BRIN future expansion */
-#define BRIN_DEBUG
+#undef BRIN_DEBUG
-/* we allow debug if using GCC; otherwise don't bother */
-#if defined(BRIN_DEBUG) && defined(__GNUC__)
-#define BRIN_elog(level, ...) elog(level, __VA_ARGS__)
+#ifdef BRIN_DEBUG
+#define BRIN_elog(args) elog args
#else
-#define BRIN_elog(a) void(0)
+#define BRIN_elog(args) ((void) 0)
#endif
/* brin.c */
typedef struct xl_brin_update
{
ItemPointerData oldtid;
- xl_brin_insert new;
+ xl_brin_insert insert;
} xl_brin_update;
-#define SizeOfBrinUpdate (offsetof(xl_brin_update, new) + SizeOfBrinInsert)
+#define SizeOfBrinUpdate (offsetof(xl_brin_update, insert) + SizeOfBrinInsert)
/* This is what we need to know about a BRIN tuple samepage update */
typedef struct xl_brin_samepage_update