Skip to content

Commit 71e0d0a

Browse files
committed
Tidy up XLogSource code in xlog.c.
This commit replaces 0 used as an initial value of XLogSource variable, with XLOG_FROM_ANY. Also this commit changes those variable so that XLogSource instead of int is used as the type for them. These changes are for code readability and debugger-friendliness. Author: Kyotaro Horiguchi Reviewed-by: Fujii Masao Discussion: https://postgr.es/m/20200227.124830.2197604521555566121.horikyota.ntt@gmail.com
1 parent 8728b2c commit 71e0d0a

File tree

1 file changed

+13
-13
lines changed
  • src/backend/access/transam

1 file changed

+13
-13
lines changed

src/backend/access/transam/xlog.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ static int readFile = -1;
795795
static XLogSegNo readSegNo = 0;
796796
static uint32 readOff = 0;
797797
static uint32 readLen = 0;
798-
static XLogSource readSource = 0; /* XLOG_FROM_* code */
798+
static XLogSource readSource = XLOG_FROM_ANY;
799799

800800
/*
801801
* Keeps track of which source we're currently reading from. This is
@@ -804,7 +804,7 @@ static XLogSource readSource = 0; /* XLOG_FROM_* code */
804804
* attempt to read from currentSource failed, and we should try another source
805805
* next.
806806
*/
807-
static XLogSource currentSource = 0; /* XLOG_FROM_* code */
807+
static XLogSource currentSource = XLOG_FROM_ANY;
808808
static bool lastSourceFailed = false;
809809

810810
typedef struct XLogPageReadPrivate
@@ -823,7 +823,7 @@ typedef struct XLogPageReadPrivate
823823
* XLogReceiptSource tracks where we last successfully read some WAL.)
824824
*/
825825
static TimestampTz XLogReceiptTime = 0;
826-
static XLogSource XLogReceiptSource = 0; /* XLOG_FROM_* code */
826+
static XLogSource XLogReceiptSource = XLOG_FROM_ANY;
827827

828828
/* State information for XLOG reading */
829829
static XLogRecPtr ReadRecPtr; /* start of last record read */
@@ -886,8 +886,8 @@ static bool InstallXLogFileSegment(XLogSegNo *segno, char *tmppath,
886886
bool find_free, XLogSegNo max_segno,
887887
bool use_lock);
888888
static int XLogFileRead(XLogSegNo segno, int emode, TimeLineID tli,
889-
int source, bool notfoundOk);
890-
static int XLogFileReadAnyTLI(XLogSegNo segno, int emode, int source);
889+
XLogSource source, bool notfoundOk);
890+
static int XLogFileReadAnyTLI(XLogSegNo segno, int emode, XLogSource source);
891891
static int XLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr,
892892
int reqLen, XLogRecPtr targetRecPtr, char *readBuf);
893893
static bool WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
@@ -3633,7 +3633,7 @@ XLogFileOpen(XLogSegNo segno)
36333633
*/
36343634
static int
36353635
XLogFileRead(XLogSegNo segno, int emode, TimeLineID tli,
3636-
int source, bool notfoundOk)
3636+
XLogSource source, bool notfoundOk)
36373637
{
36383638
char xlogfname[MAXFNAMELEN];
36393639
char activitymsg[MAXFNAMELEN + 16];
@@ -3715,7 +3715,7 @@ XLogFileRead(XLogSegNo segno, int emode, TimeLineID tli,
37153715
* This version searches for the segment with any TLI listed in expectedTLEs.
37163716
*/
37173717
static int
3718-
XLogFileReadAnyTLI(XLogSegNo segno, int emode, int source)
3718+
XLogFileReadAnyTLI(XLogSegNo segno, int emode, XLogSource source)
37193719
{
37203720
char path[MAXPGPATH];
37213721
ListCell *cell;
@@ -4387,7 +4387,7 @@ ReadRecord(XLogReaderState *xlogreader, int emode,
43874387
* so that we will check the archive next.
43884388
*/
43894389
lastSourceFailed = false;
4390-
currentSource = 0;
4390+
currentSource = XLOG_FROM_ANY;
43914391

43924392
continue;
43934393
}
@@ -11673,7 +11673,7 @@ XLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr, int reqLen,
1167311673

1167411674
close(readFile);
1167511675
readFile = -1;
11676-
readSource = 0;
11676+
readSource = XLOG_FROM_ANY;
1167711677
}
1167811678

1167911679
XLByteToSeg(targetPagePtr, readSegNo, wal_segment_size);
@@ -11693,7 +11693,7 @@ XLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr, int reqLen,
1169311693
close(readFile);
1169411694
readFile = -1;
1169511695
readLen = 0;
11696-
readSource = 0;
11696+
readSource = XLOG_FROM_ANY;
1169711697

1169811698
return -1;
1169911699
}
@@ -11799,7 +11799,7 @@ XLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr, int reqLen,
1179911799
close(readFile);
1180011800
readFile = -1;
1180111801
readLen = 0;
11802-
readSource = 0;
11802+
readSource = XLOG_FROM_ANY;
1180311803

1180411804
/* In standby-mode, keep trying */
1180511805
if (StandbyMode)
@@ -11870,7 +11870,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
1187011870
*/
1187111871
if (!InArchiveRecovery)
1187211872
currentSource = XLOG_FROM_PG_WAL;
11873-
else if (currentSource == 0 ||
11873+
else if (currentSource == XLOG_FROM_ANY ||
1187411874
(!StandbyMode && currentSource == XLOG_FROM_STREAM))
1187511875
{
1187611876
lastSourceFailed = false;
@@ -11879,7 +11879,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
1187911879

1188011880
for (;;)
1188111881
{
11882-
int oldSource = currentSource;
11882+
XLogSource oldSource = currentSource;
1188311883

1188411884
/*
1188511885
* First check if we failed to read from the current source, and

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy