diff --git a/src/backend/access/brin/brin_pageops.c b/src/backend/access/brin/brin_pageops.c index b69217c1ec..659936144e 100644 --- a/src/backend/access/brin/brin_pageops.c +++ b/src/backend/access/brin/brin_pageops.c @@ -193,7 +193,7 @@ brin_doupdate(Relation idxrel, BlockNumber pagesPerRange, XLogRegisterData((char *) &xlrec, SizeOfBrinSamepageUpdate); XLogRegisterBuffer(0, oldbuf, REGBUF_STANDARD); - XLogRegisterBufData(0, (char *) unconstify(BrinTuple *, newtup), newsz); + XLogRegisterBufData(0, (const char *) newtup, newsz); recptr = XLogInsert(RM_BRIN_ID, info); @@ -285,7 +285,7 @@ brin_doupdate(Relation idxrel, BlockNumber pagesPerRange, XLogRegisterData((char *) &xlrec, SizeOfBrinUpdate); XLogRegisterBuffer(0, newbuf, REGBUF_STANDARD | (extended ? REGBUF_WILL_INIT : 0)); - XLogRegisterBufData(0, (char *) unconstify(BrinTuple *, newtup), newsz); + XLogRegisterBufData(0, (const char *) newtup, newsz); /* revmap page */ XLogRegisterBuffer(1, revmapbuf, 0); diff --git a/src/backend/access/transam/README b/src/backend/access/transam/README index 28d196cf62..6e4711dace 100644 --- a/src/backend/access/transam/README +++ b/src/backend/access/transam/README @@ -586,13 +586,13 @@ void XLogRegisterBuffer(uint8 block_id, Buffer buf, uint8 flags); XLogRegisterBufData() is included in the WAL record even if a full-page image is taken. -void XLogRegisterData(char *data, int len); +void XLogRegisterData(const char *data, int len); XLogRegisterData is used to include arbitrary data in the WAL record. If XLogRegisterData() is called multiple times, the data are appended, and will be made available to the redo routine as one contiguous chunk. -void XLogRegisterBufData(uint8 block_id, char *data, int len); +void XLogRegisterBufData(uint8 block_id, const char *data, int len); XLogRegisterBufData is used to include data associated with a particular buffer that was registered earlier with XLogRegisterBuffer(). If diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 0fe1630fca..87700c7c5c 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -5951,7 +5951,7 @@ XactLogCommitRecord(TimestampTz commit_time, { XLogRegisterData((char *) (&xl_twophase), sizeof(xl_xact_twophase)); if (xl_xinfo.xinfo & XACT_XINFO_HAS_GID) - XLogRegisterData(unconstify(char *, twophase_gid), strlen(twophase_gid) + 1); + XLogRegisterData(twophase_gid, strlen(twophase_gid) + 1); } if (xl_xinfo.xinfo & XACT_XINFO_HAS_ORIGIN) @@ -6097,7 +6097,7 @@ XactLogAbortRecord(TimestampTz abort_time, { XLogRegisterData((char *) (&xl_twophase), sizeof(xl_xact_twophase)); if (xl_xinfo.xinfo & XACT_XINFO_HAS_GID) - XLogRegisterData(unconstify(char *, twophase_gid), strlen(twophase_gid) + 1); + XLogRegisterData(twophase_gid, strlen(twophase_gid) + 1); } if (xl_xinfo.xinfo & XACT_XINFO_HAS_ORIGIN) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 4e06d86196..5211e4e108 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -1248,7 +1248,7 @@ CopyXLogRecordToWAL(int write_len, bool isLogSwitch, XLogRecData *rdata, written = 0; while (rdata != NULL) { - char *rdata_data = rdata->data; + const char *rdata_data = rdata->data; int rdata_len = rdata->len; while (rdata_len > freespace) diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 9047601534..f92d062608 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -72,7 +72,7 @@ typedef struct RelFileLocator rlocator; /* identifies the relation and block */ ForkNumber forkno; BlockNumber block; - Page page; /* page content */ + const char *page; /* page content */ uint32 rdata_len; /* total length of data in rdata chain */ XLogRecData *rdata_head; /* head of the chain of data registered with * this block */ @@ -138,7 +138,7 @@ static XLogRecData *XLogRecordAssemble(RmgrId rmid, uint8 info, XLogRecPtr RedoRecPtr, bool doPageWrites, XLogRecPtr *fpw_lsn, int *num_fpi, bool *topxid_included); -static bool XLogCompressBackupBlock(char *page, uint16 hole_offset, +static bool XLogCompressBackupBlock(const char *page, uint16 hole_offset, uint16 hole_length, char *dest, uint16 *dlen); /* @@ -307,7 +307,7 @@ XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags) */ void XLogRegisterBlock(uint8 block_id, RelFileLocator *rlocator, ForkNumber forknum, - BlockNumber blknum, Page page, uint8 flags) + BlockNumber blknum, const char *page, uint8 flags) { registered_buffer *regbuf; @@ -361,7 +361,7 @@ XLogRegisterBlock(uint8 block_id, RelFileLocator *rlocator, ForkNumber forknum, * XLogRecGetData(). */ void -XLogRegisterData(char *data, uint32 len) +XLogRegisterData(const char *data, uint32 len) { XLogRecData *rdata; @@ -402,7 +402,7 @@ XLogRegisterData(char *data, uint32 len) * limited) */ void -XLogRegisterBufData(uint8 block_id, char *data, uint32 len) +XLogRegisterBufData(uint8 block_id, const char *data, uint32 len) { registered_buffer *regbuf; XLogRecData *rdata; @@ -648,7 +648,7 @@ XLogRecordAssemble(RmgrId rmid, uint8 info, if (include_image) { - Page page = regbuf->page; + const char *page = regbuf->page; uint16 compressed_len = 0; /* @@ -941,23 +941,23 @@ XLogRecordAssemble(RmgrId rmid, uint8 info, * the length of compressed block image. */ static bool -XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, +XLogCompressBackupBlock(const char *page, uint16 hole_offset, uint16 hole_length, char *dest, uint16 *dlen) { int32 orig_len = BLCKSZ - hole_length; int32 len = -1; int32 extra_bytes = 0; - char *source; + const char *source; PGAlignedBlock tmp; if (hole_length != 0) { /* must skip the hole */ - source = tmp.data; - memcpy(source, page, hole_offset); - memcpy(source + hole_offset, + memcpy(tmp.data, page, hole_offset); + memcpy(tmp.data + hole_offset, page + (hole_offset + hole_length), BLCKSZ - (hole_length + hole_offset)); + source = tmp.data; /* * Extra data needs to be stored in WAL record for the compressed diff --git a/src/backend/replication/logical/message.c b/src/backend/replication/logical/message.c index 9e41aac281..26fca3a8e5 100644 --- a/src/backend/replication/logical/message.c +++ b/src/backend/replication/logical/message.c @@ -63,8 +63,8 @@ LogLogicalMessage(const char *prefix, const char *message, size_t size, XLogBeginInsert(); XLogRegisterData((char *) &xlrec, SizeOfLogicalMessage); - XLogRegisterData(unconstify(char *, prefix), xlrec.prefix_size); - XLogRegisterData(unconstify(char *, message), size); + XLogRegisterData(prefix, xlrec.prefix_size); + XLogRegisterData(message, size); /* allow origin filtering */ XLogSetRecordFlags(XLOG_INCLUDE_ORIGIN); diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index c6a91fb456..e5cdba0584 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -312,7 +312,7 @@ typedef struct xl_end_of_recovery typedef struct XLogRecData { struct XLogRecData *next; /* next struct in chain, or NULL */ - char *data; /* start of rmgr data to include */ + const char *data; /* start of rmgr data to include */ uint32 len; /* length of rmgr data to include */ } XLogRecData; diff --git a/src/include/access/xloginsert.h b/src/include/access/xloginsert.h index b44fa29eac..652f7bc9bd 100644 --- a/src/include/access/xloginsert.h +++ b/src/include/access/xloginsert.h @@ -44,12 +44,12 @@ extern void XLogBeginInsert(void); extern void XLogSetRecordFlags(uint8 flags); extern XLogRecPtr XLogInsert(RmgrId rmid, uint8 info); extern void XLogEnsureRecordSpace(int max_block_id, int ndatas); -extern void XLogRegisterData(char *data, uint32 len); +extern void XLogRegisterData(const char *data, uint32 len); extern void XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags); extern void XLogRegisterBlock(uint8 block_id, RelFileLocator *rlocator, - ForkNumber forknum, BlockNumber blknum, char *page, + ForkNumber forknum, BlockNumber blknum, const char *page, uint8 flags); -extern void XLogRegisterBufData(uint8 block_id, char *data, uint32 len); +extern void XLogRegisterBufData(uint8 block_id, const char *data, uint32 len); extern void XLogResetInsertion(void); extern bool XLogCheckBufferNeedsBackup(Buffer buffer); diff --git a/src/include/storage/bufpage.h b/src/include/storage/bufpage.h index 5999e5ca5a..6222d46e53 100644 --- a/src/include/storage/bufpage.h +++ b/src/include/storage/bufpage.h @@ -384,9 +384,9 @@ PageGetMaxOffsetNumber(Page page) * Additional functions for access to page headers. */ static inline XLogRecPtr -PageGetLSN(Page page) +PageGetLSN(const char *page) { - return PageXLogRecPtrGet(((PageHeader) page)->pd_lsn); + return PageXLogRecPtrGet(((const PageHeaderData *) page)->pd_lsn); } static inline void PageSetLSN(Page page, XLogRecPtr lsn)