Add const qualifiers to XLogRegister*() functions
Add const qualifiers to XLogRegisterData() and XLogRegisterBufData(). Several unconstify() calls can be removed. Reviewed-by: Aleksander Alekseev <aleksander@timescale.com> Discussion: https://www.postgresql.org/message-id/dd889784-9ce7-436a-b4f1-52e4a5e577bd@eisentraut.org
This commit is contained in:
parent
4236825197
commit
2b5f57977f
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user