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

Commitd0096a4

Browse files
committed
Fix some inconsistent choices of datatypes in xlog.c. Make buffer
indexes all be int, rather than variously int, uint16 and uint32;add some casts where necessary to support large buffer arrays.
1 parent6fcaaf2 commitd0096a4

File tree

1 file changed

+34
-32
lines changed
  • src/backend/access/transam

1 file changed

+34
-32
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.216 2005/08/20 23:26:10 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.217 2005/08/22 00:41:28 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -112,7 +112,7 @@
112112

113113
/*
114114
* Limitation of buffer-alignment for direct IO depends on OS and filesystem,
115-
* but BLCKSZ is assumed to be enough for it.
115+
* but BLCKSZ is assumed to be enough for it.
116116
*/
117117
#ifdefO_DIRECT
118118
#defineALIGNOF_XLOG_BUFFERBLCKSZ
@@ -339,7 +339,7 @@ typedef struct XLogCtlInsert
339339
{
340340
XLogwrtResultLogwrtResult;/* a recent value of LogwrtResult */
341341
XLogRecPtrPrevRecord;/* start of previously-inserted record */
342-
uint16curridx;/* current block index in cache */
342+
intcurridx;/* current block index in cache */
343343
XLogPageHeadercurrpage;/* points to header of block in cache */
344344
char*currpos;/* current insertion point in cache */
345345
XLogRecPtrRedoRecPtr;/* current redo point for insertions */
@@ -351,7 +351,7 @@ typedef struct XLogCtlInsert
351351
typedefstructXLogCtlWrite
352352
{
353353
XLogwrtResultLogwrtResult;/* current value of LogwrtResult */
354-
uint16curridx;/* cache index of next block to write */
354+
intcurridx;/* cache index of next block to write */
355355
}XLogCtlWrite;
356356

357357
/*
@@ -375,8 +375,8 @@ typedef struct XLogCtlData
375375
*/
376376
char*pages;/* buffers for unwritten XLOG pages */
377377
XLogRecPtr*xlblocks;/* 1st byte ptr-s + BLCKSZ */
378-
uint32XLogCacheByte;/* # bytes in xlog buffers */
379-
uint32XLogCacheBlck;/* highest allocated xlog buffer index */
378+
SizeXLogCacheByte;/* # bytes in xlog buffers */
379+
intXLogCacheBlck;/* highest allocated xlog buffer index */
380380
TimeLineIDThisTimeLineID;
381381

382382
slock_tinfo_lck;/* locks shared LogwrtRqst/LogwrtResult */
@@ -497,13 +497,14 @@ static void ReadControlFile(void);
497497
staticchar*str_time(time_ttnow);
498498
staticvoidissue_xlog_fsync(void);
499499

500-
/* XLog gather-writestaffs */
500+
/* XLog gather-writestuff */
501501
typedefstructXLogPages
502502
{
503-
char*head;/*Head of first page */
504-
intsize;/* Total bytesof pages == count(pages) * BLCKSZ */
505-
intoffset;/*Offsetin xlog segment file */
503+
char*head;/*Start of first page to write */
504+
Sizesize;/* Total bytesto write == count(pages) * BLCKSZ */
505+
uint32offset;/*Starting offsetin xlog segment file */
506506
}XLogPages;
507+
507508
staticvoidXLogPageReset(XLogPages*pages);
508509
staticvoidXLogPageWrite(XLogPages*pages,intindex);
509510
staticvoidXLogPageFlush(XLogPages*pages,intindex);
@@ -539,7 +540,7 @@ XLogInsert(RmgrId rmid, uint8 info, XLogRecData *rdata)
539540
XLogRecPtrRecPtr;
540541
XLogRecPtrWriteRqst;
541542
uint32freespace;
542-
uint16curridx;
543+
intcurridx;
543544
XLogRecData*rdt;
544545
Bufferdtbuf[XLR_MAX_BKP_BLOCKS];
545546
booldtbuf_bkp[XLR_MAX_BKP_BLOCKS];
@@ -1154,7 +1155,7 @@ AdvanceXLInsertBuffer(void)
11541155
{
11551156
XLogCtlInsert*Insert=&XLogCtl->Insert;
11561157
XLogCtlWrite*Write=&XLogCtl->Write;
1157-
uint16nextidx=NextBufIdx(Insert->curridx);
1158+
intnextidx=NextBufIdx(Insert->curridx);
11581159
boolupdate_needed= true;
11591160
XLogRecPtrOldPageRqstPtr;
11601161
XLogwrtRqstWriteRqst;
@@ -1239,7 +1240,7 @@ AdvanceXLInsertBuffer(void)
12391240
else
12401241
NewPageEndPtr.xrecoff+=BLCKSZ;
12411242
XLogCtl->xlblocks[nextidx]=NewPageEndPtr;
1242-
NewPage= (XLogPageHeader) (XLogCtl->pages+nextidx*BLCKSZ);
1243+
NewPage= (XLogPageHeader) (XLogCtl->pages+nextidx*(Size)BLCKSZ);
12431244
Insert->curridx=nextidx;
12441245
Insert->currpage=NewPage;
12451246
Insert->currpos= ((char*)NewPage)+SizeOfXLogShortPHD;
@@ -3625,19 +3626,19 @@ XLOGShmemSize(void)
36253626
void
36263627
XLOGShmemInit(void)
36273628
{
3628-
boolfoundXLog,
3629-
foundCFile;
3629+
boolfoundCFile,
3630+
foundXLog;
36303631
char*allocptr;
36313632

3632-
XLogCtl= (XLogCtlData*)
3633-
ShmemInitStruct("XLOG Ctl",XLOGShmemSize(),&foundXLog);
36343633
ControlFile= (ControlFileData*)
36353634
ShmemInitStruct("Control File",sizeof(ControlFileData),&foundCFile);
3635+
XLogCtl= (XLogCtlData*)
3636+
ShmemInitStruct("XLOG Ctl",XLOGShmemSize(),&foundXLog);
36363637

3637-
if (foundXLog||foundCFile)
3638+
if (foundCFile||foundXLog)
36383639
{
36393640
/* both should be present or neither */
3640-
Assert(foundXLog&&foundCFile);
3641+
Assert(foundCFile&&foundXLog);
36413642
return;
36423643
}
36433644

@@ -3658,13 +3659,13 @@ XLOGShmemInit(void)
36583659
*/
36593660
allocptr= (char*)TYPEALIGN(ALIGNOF_XLOG_BUFFER,allocptr);
36603661
XLogCtl->pages=allocptr;
3661-
memset(XLogCtl->pages,0,BLCKSZ*XLOGbuffers);
3662+
memset(XLogCtl->pages,0,(Size)BLCKSZ*XLOGbuffers);
36623663

36633664
/*
36643665
* Do basic initialization of XLogCtl shared data. (StartupXLOG will
36653666
* fill in additional info.)
36663667
*/
3667-
XLogCtl->XLogCacheByte=BLCKSZ*XLOGbuffers;
3668+
XLogCtl->XLogCacheByte=(Size)BLCKSZ*XLOGbuffers;
36683669
XLogCtl->XLogCacheBlck=XLOGbuffers-1;
36693670
XLogCtl->Insert.currpage= (XLogPageHeader) (XLogCtl->pages);
36703671
SpinLockInit(&XLogCtl->info_lck);
@@ -5747,7 +5748,7 @@ pg_stop_backup(PG_FUNCTION_ARGS)
57475748
BACKUP_LABEL_FILE)));
57485749

57495750
RemoveOldBackupHistory();
5750-
5751+
57515752
/*
57525753
* Notify archiver that history file may be archived immediately
57535754
*/
@@ -5899,7 +5900,7 @@ remove_backup_label(void)
58995900
}
59005901

59015902

5902-
/* XLog gather-writestaffs */
5903+
/* XLog gather-writestuff */
59035904

59045905
staticvoid
59055906
XLogPageReset(XLogPages*pages)
@@ -5910,12 +5911,12 @@ XLogPageReset(XLogPages *pages)
59105911
staticvoid
59115912
XLogPageWrite(XLogPages*pages,intindex)
59125913
{
5913-
char*page=XLogCtl->pages+index*BLCKSZ;
5914-
intsize=BLCKSZ;
5915-
intoffset= (LogwrtResult.Write.xrecoff-BLCKSZ) %XLogSegSize;
5914+
char*page=XLogCtl->pages+index*(Size)BLCKSZ;
5915+
Sizesize=BLCKSZ;
5916+
uint32offset= (LogwrtResult.Write.xrecoff-BLCKSZ) %XLogSegSize;
59165917

5917-
if (pages->head+pages->size==page
5918-
&&pages->offset+pages->size==offset)
5918+
if (pages->head+pages->size==page&&
5919+
pages->offset+pages->size==offset)
59195920
{/* Pages are continuous. Append new page. */
59205921
pages->size+=size;
59215922
}
@@ -5932,11 +5933,11 @@ static void
59325933
XLogPageFlush(XLogPages*pages,intindex)
59335934
{
59345935
if (!pages->head)
5935-
{/*No needsto write pages. */
5936+
{/*Nothingto write */
59365937
XLogCtl->Write.curridx=index;
59375938
return;
59385939
}
5939-
5940+
59405941
/* Need to seek in the file? */
59415942
if (openLogOff!=pages->offset)
59425943
{
@@ -5957,8 +5958,9 @@ XLogPageFlush(XLogPages *pages, int index)
59575958
errno=ENOSPC;
59585959
ereport(PANIC,
59595960
(errcode_for_file_access(),
5960-
errmsg("could not write to log file %u, segment %u at offset %u: %m",
5961-
openLogId,openLogSeg,openLogOff)));
5961+
errmsg("could not write to log file %u, segment %u length %u at offset %u: %m",
5962+
openLogId,openLogSeg,
5963+
(unsignedint)pages->size,openLogOff)));
59625964
}
59635965

59645966
openLogOff+=pages->size;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp