Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2b5f579

Browse files
committed
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
1 parent 4236825 commit 2b5f579

File tree

9 files changed

+26
-26
lines changed

9 files changed

+26
-26
lines changed

src/backend/access/brin/brin_pageops.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ brin_doupdate(Relation idxrel, BlockNumber pagesPerRange,
193193
XLogRegisterData((char *) &xlrec, SizeOfBrinSamepageUpdate);
194194

195195
XLogRegisterBuffer(0, oldbuf, REGBUF_STANDARD);
196-
XLogRegisterBufData(0, (char *) unconstify(BrinTuple *, newtup), newsz);
196+
XLogRegisterBufData(0, (const char *) newtup, newsz);
197197

198198
recptr = XLogInsert(RM_BRIN_ID, info);
199199

@@ -285,7 +285,7 @@ brin_doupdate(Relation idxrel, BlockNumber pagesPerRange,
285285
XLogRegisterData((char *) &xlrec, SizeOfBrinUpdate);
286286

287287
XLogRegisterBuffer(0, newbuf, REGBUF_STANDARD | (extended ? REGBUF_WILL_INIT : 0));
288-
XLogRegisterBufData(0, (char *) unconstify(BrinTuple *, newtup), newsz);
288+
XLogRegisterBufData(0, (const char *) newtup, newsz);
289289

290290
/* revmap page */
291291
XLogRegisterBuffer(1, revmapbuf, 0);

src/backend/access/transam/README

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,13 +586,13 @@ void XLogRegisterBuffer(uint8 block_id, Buffer buf, uint8 flags);
586586
XLogRegisterBufData() is included in the WAL record even if a full-page
587587
image is taken.
588588

589-
void XLogRegisterData(char *data, int len);
589+
void XLogRegisterData(const char *data, int len);
590590

591591
XLogRegisterData is used to include arbitrary data in the WAL record. If
592592
XLogRegisterData() is called multiple times, the data are appended, and
593593
will be made available to the redo routine as one contiguous chunk.
594594

595-
void XLogRegisterBufData(uint8 block_id, char *data, int len);
595+
void XLogRegisterBufData(uint8 block_id, const char *data, int len);
596596

597597
XLogRegisterBufData is used to include data associated with a particular
598598
buffer that was registered earlier with XLogRegisterBuffer(). If

src/backend/access/transam/xact.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5951,7 +5951,7 @@ XactLogCommitRecord(TimestampTz commit_time,
59515951
{
59525952
XLogRegisterData((char *) (&xl_twophase), sizeof(xl_xact_twophase));
59535953
if (xl_xinfo.xinfo & XACT_XINFO_HAS_GID)
5954-
XLogRegisterData(unconstify(char *, twophase_gid), strlen(twophase_gid) + 1);
5954+
XLogRegisterData(twophase_gid, strlen(twophase_gid) + 1);
59555955
}
59565956

59575957
if (xl_xinfo.xinfo & XACT_XINFO_HAS_ORIGIN)
@@ -6097,7 +6097,7 @@ XactLogAbortRecord(TimestampTz abort_time,
60976097
{
60986098
XLogRegisterData((char *) (&xl_twophase), sizeof(xl_xact_twophase));
60996099
if (xl_xinfo.xinfo & XACT_XINFO_HAS_GID)
6100-
XLogRegisterData(unconstify(char *, twophase_gid), strlen(twophase_gid) + 1);
6100+
XLogRegisterData(twophase_gid, strlen(twophase_gid) + 1);
61016101
}
61026102

61036103
if (xl_xinfo.xinfo & XACT_XINFO_HAS_ORIGIN)

src/backend/access/transam/xlog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1248,7 +1248,7 @@ CopyXLogRecordToWAL(int write_len, bool isLogSwitch, XLogRecData *rdata,
12481248
written = 0;
12491249
while (rdata != NULL)
12501250
{
1251-
char *rdata_data = rdata->data;
1251+
const char *rdata_data = rdata->data;
12521252
int rdata_len = rdata->len;
12531253

12541254
while (rdata_len > freespace)

src/backend/access/transam/xloginsert.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ typedef struct
7272
RelFileLocator rlocator; /* identifies the relation and block */
7373
ForkNumber forkno;
7474
BlockNumber block;
75-
Page page; /* page content */
75+
const char *page; /* page content */
7676
uint32 rdata_len; /* total length of data in rdata chain */
7777
XLogRecData *rdata_head; /* head of the chain of data registered with
7878
* this block */
@@ -138,7 +138,7 @@ static XLogRecData *XLogRecordAssemble(RmgrId rmid, uint8 info,
138138
XLogRecPtr RedoRecPtr, bool doPageWrites,
139139
XLogRecPtr *fpw_lsn, int *num_fpi,
140140
bool *topxid_included);
141-
static bool XLogCompressBackupBlock(char *page, uint16 hole_offset,
141+
static bool XLogCompressBackupBlock(const char *page, uint16 hole_offset,
142142
uint16 hole_length, char *dest, uint16 *dlen);
143143

144144
/*
@@ -307,7 +307,7 @@ XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
307307
*/
308308
void
309309
XLogRegisterBlock(uint8 block_id, RelFileLocator *rlocator, ForkNumber forknum,
310-
BlockNumber blknum, Page page, uint8 flags)
310+
BlockNumber blknum, const char *page, uint8 flags)
311311
{
312312
registered_buffer *regbuf;
313313

@@ -361,7 +361,7 @@ XLogRegisterBlock(uint8 block_id, RelFileLocator *rlocator, ForkNumber forknum,
361361
* XLogRecGetData().
362362
*/
363363
void
364-
XLogRegisterData(char *data, uint32 len)
364+
XLogRegisterData(const char *data, uint32 len)
365365
{
366366
XLogRecData *rdata;
367367

@@ -402,7 +402,7 @@ XLogRegisterData(char *data, uint32 len)
402402
* limited)
403403
*/
404404
void
405-
XLogRegisterBufData(uint8 block_id, char *data, uint32 len)
405+
XLogRegisterBufData(uint8 block_id, const char *data, uint32 len)
406406
{
407407
registered_buffer *regbuf;
408408
XLogRecData *rdata;
@@ -648,7 +648,7 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
648648

649649
if (include_image)
650650
{
651-
Page page = regbuf->page;
651+
const char *page = regbuf->page;
652652
uint16 compressed_len = 0;
653653

654654
/*
@@ -941,23 +941,23 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
941941
* the length of compressed block image.
942942
*/
943943
static bool
944-
XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length,
944+
XLogCompressBackupBlock(const char *page, uint16 hole_offset, uint16 hole_length,
945945
char *dest, uint16 *dlen)
946946
{
947947
int32 orig_len = BLCKSZ - hole_length;
948948
int32 len = -1;
949949
int32 extra_bytes = 0;
950-
char *source;
950+
const char *source;
951951
PGAlignedBlock tmp;
952952

953953
if (hole_length != 0)
954954
{
955955
/* must skip the hole */
956-
source = tmp.data;
957-
memcpy(source, page, hole_offset);
958-
memcpy(source + hole_offset,
956+
memcpy(tmp.data, page, hole_offset);
957+
memcpy(tmp.data + hole_offset,
959958
page + (hole_offset + hole_length),
960959
BLCKSZ - (hole_length + hole_offset));
960+
source = tmp.data;
961961

962962
/*
963963
* Extra data needs to be stored in WAL record for the compressed

src/backend/replication/logical/message.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ LogLogicalMessage(const char *prefix, const char *message, size_t size,
6363

6464
XLogBeginInsert();
6565
XLogRegisterData((char *) &xlrec, SizeOfLogicalMessage);
66-
XLogRegisterData(unconstify(char *, prefix), xlrec.prefix_size);
67-
XLogRegisterData(unconstify(char *, message), size);
66+
XLogRegisterData(prefix, xlrec.prefix_size);
67+
XLogRegisterData(message, size);
6868

6969
/* allow origin filtering */
7070
XLogSetRecordFlags(XLOG_INCLUDE_ORIGIN);

src/include/access/xlog_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ typedef struct xl_end_of_recovery
312312
typedef struct XLogRecData
313313
{
314314
struct XLogRecData *next; /* next struct in chain, or NULL */
315-
char *data; /* start of rmgr data to include */
315+
const char *data; /* start of rmgr data to include */
316316
uint32 len; /* length of rmgr data to include */
317317
} XLogRecData;
318318

src/include/access/xloginsert.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ extern void XLogBeginInsert(void);
4444
extern void XLogSetRecordFlags(uint8 flags);
4545
extern XLogRecPtr XLogInsert(RmgrId rmid, uint8 info);
4646
extern void XLogEnsureRecordSpace(int max_block_id, int ndatas);
47-
extern void XLogRegisterData(char *data, uint32 len);
47+
extern void XLogRegisterData(const char *data, uint32 len);
4848
extern void XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags);
4949
extern void XLogRegisterBlock(uint8 block_id, RelFileLocator *rlocator,
50-
ForkNumber forknum, BlockNumber blknum, char *page,
50+
ForkNumber forknum, BlockNumber blknum, const char *page,
5151
uint8 flags);
52-
extern void XLogRegisterBufData(uint8 block_id, char *data, uint32 len);
52+
extern void XLogRegisterBufData(uint8 block_id, const char *data, uint32 len);
5353
extern void XLogResetInsertion(void);
5454
extern bool XLogCheckBufferNeedsBackup(Buffer buffer);
5555

src/include/storage/bufpage.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,9 @@ PageGetMaxOffsetNumber(Page page)
384384
* Additional functions for access to page headers.
385385
*/
386386
static inline XLogRecPtr
387-
PageGetLSN(Page page)
387+
PageGetLSN(const char *page)
388388
{
389-
return PageXLogRecPtrGet(((PageHeader) page)->pd_lsn);
389+
return PageXLogRecPtrGet(((const PageHeaderData *) page)->pd_lsn);
390390
}
391391
static inline void
392392
PageSetLSN(Page page, XLogRecPtr lsn)

0 commit comments

Comments
 (0)