45#define FRAGMENT_HEADER_SIZE (2 * sizeof(OffsetNumber))
46#define MATCH_THRESHOLD FRAGMENT_HEADER_SIZE
47#define MAX_DELTA_SIZE (BLCKSZ + 2 * FRAGMENT_HEADER_SIZE)
76 const char *curpage,
const char *targetpage,
77 int targetStart,
int targetEnd,
78 int validStart,
int validEnd);
97 sizeof(length) + length <=
sizeof(pageData->
delta));
100 memcpy(ptr, &offset,
sizeof(offset));
101 ptr +=
sizeof(offset);
102 memcpy(ptr, &length,
sizeof(length));
103 ptr +=
sizeof(length);
104 memcpy(ptr,
data, length);
122 const char *curpage,
const char *targetpage,
123 int targetStart,
int targetEnd,
124 int validStart,
int validEnd)
132 if (validStart > targetStart)
134 fragmentBegin = targetStart;
135 targetStart = validStart;
139 loopEnd =
Min(targetEnd, validEnd);
145 if (curpage[
i] != targetpage[
i])
148 if (fragmentBegin < 0)
154 while (
i < loopEnd && curpage[
i] != targetpage[
i])
168 while (
i < loopEnd && curpage[
i] == targetpage[
i])
197 fragmentEnd - fragmentBegin,
198 targetpage + fragmentBegin);
205 if (loopEnd < targetEnd)
207 if (fragmentBegin < 0)
208 fragmentBegin = loopEnd;
209 fragmentEnd = targetEnd;
213 if (fragmentBegin >= 0)
216 fragmentEnd = targetEnd;
218 fragmentEnd - fragmentBegin,
219 targetpage + fragmentBegin);
230 int targetLower = ((
PageHeader) targetpage)->pd_lower,
231 targetUpper = ((
PageHeader) targetpage)->pd_upper,
255 memcpy(tmp.
data, curpage, BLCKSZ);
257 if (memcmp(tmp.
data, targetpage, targetLower) != 0 ||
258 memcmp(tmp.
data + targetUpper, targetpage + targetUpper,
259 BLCKSZ - targetUpper) != 0)
260 elog(
ERROR,
"result of generic xlog apply does not match");
316 else if (page->
buffer == buffer)
326 elog(
ERROR,
"maximum number %d of generic xlog buffers is exceeded",
378 memset(page + pageHeader->
pd_lower, 0,
455 const char *ptr = delta;
456 const char *end = delta + deltaSize;
463 memcpy(&offset, ptr,
sizeof(offset));
464 ptr +=
sizeof(offset);
465 memcpy(&length, ptr,
sizeof(length));
466 ptr +=
sizeof(length);
468 memcpy(page + offset, ptr, length);
519 memset(page + pageHeader->
pd_lower, 0,
#define BufferIsInvalid(buffer)
void mask_page_lsn_and_checksum(Page page)
void mask_unused_space(Page page)
void UnlockReleaseBuffer(Buffer buffer)
void MarkBufferDirty(Buffer buffer)
static Page BufferGetPage(Buffer buffer)
static bool BufferIsValid(Buffer bufnum)
PageHeaderData * PageHeader
static void PageSetLSN(Page page, XLogRecPtr lsn)
#define Assert(condition)
Page GenericXLogRegisterBuffer(GenericXLogState *state, Buffer buffer, int flags)
static void applyPageRedo(Page page, const char *delta, Size deltaSize)
void generic_redo(XLogReaderState *record)
static void computeRegionDelta(GenericXLogPageData *pageData, const char *curpage, const char *targetpage, int targetStart, int targetEnd, int validStart, int validEnd)
void generic_mask(char *page, BlockNumber blkno)
static void computeDelta(GenericXLogPageData *pageData, Page curpage, Page targetpage)
static void writeFragment(GenericXLogPageData *pageData, OffsetNumber offset, OffsetNumber length, const char *data)
GenericXLogState * GenericXLogStart(Relation relation)
XLogRecPtr GenericXLogFinish(GenericXLogState *state)
void GenericXLogAbort(GenericXLogState *state)
#define GENERIC_XLOG_FULL_IMAGE
#define MAX_GENERIC_XLOG_PAGES
if(TABLE==NULL||TABLE_index==NULL)
void pfree(void *pointer)
void * palloc_aligned(Size size, Size alignto, int flags)
#define START_CRIT_SECTION()
#define END_CRIT_SECTION()
#define RelationNeedsWAL(relation)
char delta[MAX_DELTA_SIZE]
PGIOAlignedBlock images[MAX_GENERIC_XLOG_PAGES]
GenericXLogPageData pages[MAX_GENERIC_XLOG_PAGES]
#define InvalidXLogRecPtr
void XLogRegisterBufData(uint8 block_id, const char *data, uint32 len)
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
void XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
void XLogBeginInsert(void)
#define REGBUF_FORCE_IMAGE
char * XLogRecGetBlockData(XLogReaderState *record, uint8 block_id, Size *len)
#define XLogRecMaxBlockId(decoder)
#define XLogRecHasBlockRef(decoder, block_id)
XLogRedoAction XLogReadBufferForRedo(XLogReaderState *record, uint8 block_id, Buffer *buf)