Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb3480f8

Browse files
peterepull[bot]
authored andcommitted
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 parentb7385d3 commitb3480f8

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, (constchar*)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, (constchar*)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(constchar *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,constchar *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+
constchar*rdata_data=rdata->data;
12521252
intrdata_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
RelFileLocatorrlocator;/* identifies the relation and block */
7373
ForkNumberforkno;
7474
BlockNumberblock;
75-
Pagepage;/* page content */
75+
constchar*page;/* page content */
7676
uint32rdata_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
XLogRecPtrRedoRecPtr,booldoPageWrites,
139139
XLogRecPtr*fpw_lsn,int*num_fpi,
140140
bool*topxid_included);
141-
staticboolXLogCompressBackupBlock(char*page,uint16hole_offset,
141+
staticboolXLogCompressBackupBlock(constchar*page,uint16hole_offset,
142142
uint16hole_length,char*dest,uint16*dlen);
143143

144144
/*
@@ -307,7 +307,7 @@ XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
307307
*/
308308
void
309309
XLogRegisterBlock(uint8block_id,RelFileLocator*rlocator,ForkNumberforknum,
310-
BlockNumberblknum,Pagepage,uint8flags)
310+
BlockNumberblknum,constchar*page,uint8flags)
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,uint32len)
364+
XLogRegisterData(constchar*data,uint32len)
365365
{
366366
XLogRecData*rdata;
367367

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

649649
if (include_image)
650650
{
651-
Pagepage=regbuf->page;
651+
constchar*page=regbuf->page;
652652
uint16compressed_len=0;
653653

654654
/*
@@ -941,23 +941,23 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
941941
* the length of compressed block image.
942942
*/
943943
staticbool
944-
XLogCompressBackupBlock(char*page,uint16hole_offset,uint16hole_length,
944+
XLogCompressBackupBlock(constchar*page,uint16hole_offset,uint16hole_length,
945945
char*dest,uint16*dlen)
946946
{
947947
int32orig_len=BLCKSZ-hole_length;
948948
int32len=-1;
949949
int32extra_bytes=0;
950-
char*source;
950+
constchar*source;
951951
PGAlignedBlocktmp;
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
typedefstructXLogRecData
313313
{
314314
structXLogRecData*next;/* next struct in chain, or NULL */
315-
char*data;/* start of rmgr data to include */
315+
constchar*data;/* start of rmgr data to include */
316316
uint32len;/* 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
externvoidXLogSetRecordFlags(uint8flags);
4545
externXLogRecPtrXLogInsert(RmgrIdrmid,uint8info);
4646
externvoidXLogEnsureRecordSpace(intmax_block_id,intndatas);
47-
externvoidXLogRegisterData(char*data,uint32len);
47+
externvoidXLogRegisterData(constchar*data,uint32len);
4848
externvoidXLogRegisterBuffer(uint8block_id,Bufferbuffer,uint8flags);
4949
externvoidXLogRegisterBlock(uint8block_id,RelFileLocator*rlocator,
50-
ForkNumberforknum,BlockNumberblknum,char*page,
50+
ForkNumberforknum,BlockNumberblknum,constchar*page,
5151
uint8flags);
52-
externvoidXLogRegisterBufData(uint8block_id,char*data,uint32len);
52+
externvoidXLogRegisterBufData(uint8block_id,constchar*data,uint32len);
5353
externvoidXLogResetInsertion(void);
5454
externboolXLogCheckBufferNeedsBackup(Bufferbuffer);
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
staticinlineXLogRecPtr
387-
PageGetLSN(Pagepage)
387+
PageGetLSN(constchar*page)
388388
{
389-
returnPageXLogRecPtrGet(((PageHeader)page)->pd_lsn);
389+
returnPageXLogRecPtrGet(((constPageHeaderData*)page)->pd_lsn);
390390
}
391391
staticinlinevoid
392392
PageSetLSN(Pagepage,XLogRecPtrlsn)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp