Skip to content

Commit fea10a6

Browse files
committed
Rename VariableCacheData.nextFullXid to nextXid.
Including Full in variable names duplicates the type information and leads to overly long names. As FullTransactionId cannot accidentally be casted to TransactionId that does not seem necessary. Author: Andres Freund Discussion: https://postgr.es/m/20200724011143.jccsyvsvymuiqfxu@alap3.anarazel.de
1 parent 1f75b45 commit fea10a6

File tree

21 files changed

+96
-96
lines changed

21 files changed

+96
-96
lines changed

src/backend/access/gist/gistxlog.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ gistRedoPageReuse(XLogReaderState *record)
396396
if (InHotStandby)
397397
{
398398
FullTransactionId latestRemovedFullXid = xlrec->latestRemovedFullXid;
399-
FullTransactionId nextFullXid = ReadNextFullTransactionId();
399+
FullTransactionId nextXid = ReadNextFullTransactionId();
400400
uint64 diff;
401401

402402
/*
@@ -405,8 +405,8 @@ gistRedoPageReuse(XLogReaderState *record)
405405
* logged value is very old, so that XID wrap-around already happened
406406
* on it, there can't be any snapshots that still see it.
407407
*/
408-
nextFullXid = ReadNextFullTransactionId();
409-
diff = U64FromFullTransactionId(nextFullXid) -
408+
nextXid = ReadNextFullTransactionId();
409+
diff = U64FromFullTransactionId(nextXid) -
410410
U64FromFullTransactionId(latestRemovedFullXid);
411411
if (diff < MaxTransactionId / 2)
412412
{

src/backend/access/rmgrdesc/xlogdesc.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
5353
checkpoint->ThisTimeLineID,
5454
checkpoint->PrevTimeLineID,
5555
checkpoint->fullPageWrites ? "true" : "false",
56-
EpochFromFullTransactionId(checkpoint->nextFullXid),
57-
XidFromFullTransactionId(checkpoint->nextFullXid),
56+
EpochFromFullTransactionId(checkpoint->nextXid),
57+
XidFromFullTransactionId(checkpoint->nextXid),
5858
checkpoint->nextOid,
5959
checkpoint->nextMulti,
6060
checkpoint->nextMultiOffset,

src/backend/access/transam/clog.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -742,12 +742,12 @@ ZeroCLOGPage(int pageno, bool writeXlog)
742742

743743
/*
744744
* This must be called ONCE during postmaster or standalone-backend startup,
745-
* after StartupXLOG has initialized ShmemVariableCache->nextFullXid.
745+
* after StartupXLOG has initialized ShmemVariableCache->nextXid.
746746
*/
747747
void
748748
StartupCLOG(void)
749749
{
750-
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextFullXid);
750+
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
751751
int pageno = TransactionIdToPage(xid);
752752

753753
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -766,7 +766,7 @@ StartupCLOG(void)
766766
void
767767
TrimCLOG(void)
768768
{
769-
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextFullXid);
769+
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
770770
int pageno = TransactionIdToPage(xid);
771771

772772
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -785,7 +785,7 @@ TrimCLOG(void)
785785
* but makes no WAL entry). Let's just be safe. (We need not worry about
786786
* pages beyond the current one, since those will be zeroed when first
787787
* used. For the same reason, there is no need to do anything when
788-
* nextFullXid is exactly at a page boundary; and it's likely that the
788+
* nextXid is exactly at a page boundary; and it's likely that the
789789
* "current" page doesn't exist yet in that case.)
790790
*/
791791
if (TransactionIdToPgIndex(xid) != 0)

src/backend/access/transam/commit_ts.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ ZeroCommitTsPage(int pageno, bool writeXlog)
614614

615615
/*
616616
* This must be called ONCE during postmaster or standalone-backend startup,
617-
* after StartupXLOG has initialized ShmemVariableCache->nextFullXid.
617+
* after StartupXLOG has initialized ShmemVariableCache->nextXid.
618618
*/
619619
void
620620
StartupCommitTs(void)
@@ -704,7 +704,7 @@ ActivateCommitTs(void)
704704
}
705705
LWLockRelease(CommitTsLock);
706706

707-
xid = XidFromFullTransactionId(ShmemVariableCache->nextFullXid);
707+
xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
708708
pageno = TransactionIdToCTsPage(xid);
709709

710710
/*

src/backend/access/transam/multixact.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3265,7 +3265,7 @@ multixact_redo(XLogReaderState *record)
32653265
xlrec->moff + xlrec->nmembers);
32663266

32673267
/*
3268-
* Make sure nextFullXid is beyond any XID mentioned in the record.
3268+
* Make sure nextXid is beyond any XID mentioned in the record.
32693269
* This should be unnecessary, since any XID found here ought to have
32703270
* other evidence in the XLOG, but let's be safe.
32713271
*/

src/backend/access/transam/subtrans.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,15 @@ ZeroSUBTRANSPage(int pageno)
241241

242242
/*
243243
* This must be called ONCE during postmaster or standalone-backend startup,
244-
* after StartupXLOG has initialized ShmemVariableCache->nextFullXid.
244+
* after StartupXLOG has initialized ShmemVariableCache->nextXid.
245245
*
246-
* oldestActiveXID is the oldest XID of any prepared transaction, or nextFullXid
246+
* oldestActiveXID is the oldest XID of any prepared transaction, or nextXid
247247
* if there are none.
248248
*/
249249
void
250250
StartupSUBTRANS(TransactionId oldestActiveXID)
251251
{
252-
FullTransactionId nextFullXid;
252+
FullTransactionId nextXid;
253253
int startPage;
254254
int endPage;
255255

@@ -262,8 +262,8 @@ StartupSUBTRANS(TransactionId oldestActiveXID)
262262
LWLockAcquire(SubtransSLRULock, LW_EXCLUSIVE);
263263

264264
startPage = TransactionIdToPage(oldestActiveXID);
265-
nextFullXid = ShmemVariableCache->nextFullXid;
266-
endPage = TransactionIdToPage(XidFromFullTransactionId(nextFullXid));
265+
nextXid = ShmemVariableCache->nextXid;
266+
endPage = TransactionIdToPage(XidFromFullTransactionId(nextXid));
267267

268268
while (startPage != endPage)
269269
{

src/backend/access/transam/twophase.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -1813,16 +1813,16 @@ restoreTwoPhaseData(void)
18131813
*
18141814
* Scan the shared memory entries of TwoPhaseState and determine the range
18151815
* of valid XIDs present. This is run during database startup, after we
1816-
* have completed reading WAL. ShmemVariableCache->nextFullXid has been set to
1816+
* have completed reading WAL. ShmemVariableCache->nextXid has been set to
18171817
* one more than the highest XID for which evidence exists in WAL.
18181818
*
1819-
* We throw away any prepared xacts with main XID beyond nextFullXid --- if any
1819+
* We throw away any prepared xacts with main XID beyond nextXid --- if any
18201820
* are present, it suggests that the DBA has done a PITR recovery to an
18211821
* earlier point in time without cleaning out pg_twophase. We dare not
18221822
* try to recover such prepared xacts since they likely depend on database
18231823
* state that doesn't exist now.
18241824
*
1825-
* However, we will advance nextFullXid beyond any subxact XIDs belonging to
1825+
* However, we will advance nextXid beyond any subxact XIDs belonging to
18261826
* valid prepared xacts. We need to do this since subxact commit doesn't
18271827
* write a WAL entry, and so there might be no evidence in WAL of those
18281828
* subxact XIDs.
@@ -1832,7 +1832,7 @@ restoreTwoPhaseData(void)
18321832
* backup should be rolled in.
18331833
*
18341834
* Our other responsibility is to determine and return the oldest valid XID
1835-
* among the prepared xacts (if none, return ShmemVariableCache->nextFullXid).
1835+
* among the prepared xacts (if none, return ShmemVariableCache->nextXid).
18361836
* This is needed to synchronize pg_subtrans startup properly.
18371837
*
18381838
* If xids_p and nxids_p are not NULL, pointer to a palloc'd array of all
@@ -1842,8 +1842,8 @@ restoreTwoPhaseData(void)
18421842
TransactionId
18431843
PrescanPreparedTransactions(TransactionId **xids_p, int *nxids_p)
18441844
{
1845-
FullTransactionId nextFullXid = ShmemVariableCache->nextFullXid;
1846-
TransactionId origNextXid = XidFromFullTransactionId(nextFullXid);
1845+
FullTransactionId nextXid = ShmemVariableCache->nextXid;
1846+
TransactionId origNextXid = XidFromFullTransactionId(nextXid);
18471847
TransactionId result = origNextXid;
18481848
TransactionId *xids = NULL;
18491849
int nxids = 0;
@@ -2059,7 +2059,7 @@ RecoverPreparedTransactions(void)
20592059
*
20602060
* If setParent is true, set up subtransaction parent linkages.
20612061
*
2062-
* If setNextXid is true, set ShmemVariableCache->nextFullXid to the newest
2062+
* If setNextXid is true, set ShmemVariableCache->nextXid to the newest
20632063
* value scanned.
20642064
*/
20652065
static char *
@@ -2068,8 +2068,8 @@ ProcessTwoPhaseBuffer(TransactionId xid,
20682068
bool fromdisk,
20692069
bool setParent, bool setNextXid)
20702070
{
2071-
FullTransactionId nextFullXid = ShmemVariableCache->nextFullXid;
2072-
TransactionId origNextXid = XidFromFullTransactionId(nextFullXid);
2071+
FullTransactionId nextXid = ShmemVariableCache->nextXid;
2072+
TransactionId origNextXid = XidFromFullTransactionId(nextXid);
20732073
TransactionId *subxids;
20742074
char *buf;
20752075
TwoPhaseFileHeader *hdr;
@@ -2149,7 +2149,7 @@ ProcessTwoPhaseBuffer(TransactionId xid,
21492149

21502150
/*
21512151
* Examine subtransaction XIDs ... they should all follow main XID, and
2152-
* they may force us to advance nextFullXid.
2152+
* they may force us to advance nextXid.
21532153
*/
21542154
subxids = (TransactionId *) (buf +
21552155
MAXALIGN(sizeof(TwoPhaseFileHeader)) +
@@ -2160,7 +2160,7 @@ ProcessTwoPhaseBuffer(TransactionId xid,
21602160

21612161
Assert(TransactionIdFollows(subxid, xid));
21622162

2163-
/* update nextFullXid if needed */
2163+
/* update nextXid if needed */
21642164
if (setNextXid)
21652165
AdvanceNextFullTransactionIdPastXid(subxid);
21662166

src/backend/access/transam/varsup.c

+13-13
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ GetNewTransactionId(bool isSubXact)
7575

7676
LWLockAcquire(XidGenLock, LW_EXCLUSIVE);
7777

78-
full_xid = ShmemVariableCache->nextFullXid;
78+
full_xid = ShmemVariableCache->nextXid;
7979
xid = XidFromFullTransactionId(full_xid);
8080

8181
/*----------
@@ -159,7 +159,7 @@ GetNewTransactionId(bool isSubXact)
159159

160160
/* Re-acquire lock and start over */
161161
LWLockAcquire(XidGenLock, LW_EXCLUSIVE);
162-
full_xid = ShmemVariableCache->nextFullXid;
162+
full_xid = ShmemVariableCache->nextXid;
163163
xid = XidFromFullTransactionId(full_xid);
164164
}
165165

@@ -177,12 +177,12 @@ GetNewTransactionId(bool isSubXact)
177177
ExtendSUBTRANS(xid);
178178

179179
/*
180-
* Now advance the nextFullXid counter. This must not happen until after
180+
* Now advance the nextXid counter. This must not happen until after
181181
* we have successfully completed ExtendCLOG() --- if that routine fails,
182182
* we want the next incoming transaction to try it again. We cannot
183183
* assign more XIDs until there is CLOG space for them.
184184
*/
185-
FullTransactionIdAdvance(&ShmemVariableCache->nextFullXid);
185+
FullTransactionIdAdvance(&ShmemVariableCache->nextXid);
186186

187187
/*
188188
* We must store the new XID into the shared ProcArray before releasing
@@ -240,22 +240,22 @@ GetNewTransactionId(bool isSubXact)
240240
}
241241

242242
/*
243-
* Read nextFullXid but don't allocate it.
243+
* Read nextXid but don't allocate it.
244244
*/
245245
FullTransactionId
246246
ReadNextFullTransactionId(void)
247247
{
248248
FullTransactionId fullXid;
249249

250250
LWLockAcquire(XidGenLock, LW_SHARED);
251-
fullXid = ShmemVariableCache->nextFullXid;
251+
fullXid = ShmemVariableCache->nextXid;
252252
LWLockRelease(XidGenLock);
253253

254254
return fullXid;
255255
}
256256

257257
/*
258-
* Advance nextFullXid to the value after a given xid. The epoch is inferred.
258+
* Advance nextXid to the value after a given xid. The epoch is inferred.
259259
* This must only be called during recovery or from two-phase start-up code.
260260
*/
261261
void
@@ -266,14 +266,14 @@ AdvanceNextFullTransactionIdPastXid(TransactionId xid)
266266
uint32 epoch;
267267

268268
/*
269-
* It is safe to read nextFullXid without a lock, because this is only
269+
* It is safe to read nextXid without a lock, because this is only
270270
* called from the startup process or single-process mode, meaning that no
271271
* other process can modify it.
272272
*/
273273
Assert(AmStartupProcess() || !IsUnderPostmaster);
274274

275275
/* Fast return if this isn't an xid high enough to move the needle. */
276-
next_xid = XidFromFullTransactionId(ShmemVariableCache->nextFullXid);
276+
next_xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
277277
if (!TransactionIdFollowsOrEquals(xid, next_xid))
278278
return;
279279

@@ -286,7 +286,7 @@ AdvanceNextFullTransactionIdPastXid(TransactionId xid)
286286
* point in the WAL stream.
287287
*/
288288
TransactionIdAdvance(xid);
289-
epoch = EpochFromFullTransactionId(ShmemVariableCache->nextFullXid);
289+
epoch = EpochFromFullTransactionId(ShmemVariableCache->nextXid);
290290
if (unlikely(xid < next_xid))
291291
++epoch;
292292
newNextFullXid = FullTransactionIdFromEpochAndXid(epoch, xid);
@@ -296,7 +296,7 @@ AdvanceNextFullTransactionIdPastXid(TransactionId xid)
296296
* concurrent readers.
297297
*/
298298
LWLockAcquire(XidGenLock, LW_EXCLUSIVE);
299-
ShmemVariableCache->nextFullXid = newNextFullXid;
299+
ShmemVariableCache->nextXid = newNextFullXid;
300300
LWLockRelease(XidGenLock);
301301
}
302302

@@ -404,7 +404,7 @@ SetTransactionIdLimit(TransactionId oldest_datfrozenxid, Oid oldest_datoid)
404404
ShmemVariableCache->xidStopLimit = xidStopLimit;
405405
ShmemVariableCache->xidWrapLimit = xidWrapLimit;
406406
ShmemVariableCache->oldestXidDB = oldest_datoid;
407-
curXid = XidFromFullTransactionId(ShmemVariableCache->nextFullXid);
407+
curXid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
408408
LWLockRelease(XidGenLock);
409409

410410
/* Log the info */
@@ -480,7 +480,7 @@ ForceTransactionIdLimitUpdate(void)
480480

481481
/* Locking is probably not really necessary, but let's be careful */
482482
LWLockAcquire(XidGenLock, LW_SHARED);
483-
nextXid = XidFromFullTransactionId(ShmemVariableCache->nextFullXid);
483+
nextXid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
484484
xidVacLimit = ShmemVariableCache->xidVacLimit;
485485
oldestXid = ShmemVariableCache->oldestXid;
486486
oldestXidDB = ShmemVariableCache->oldestXidDB;

src/backend/access/transam/xact.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -5791,7 +5791,7 @@ xact_redo_commit(xl_xact_parsed_commit *parsed,
57915791

57925792
max_xid = TransactionIdLatest(xid, parsed->nsubxacts, parsed->subxacts);
57935793

5794-
/* Make sure nextFullXid is beyond any XID mentioned in the record. */
5794+
/* Make sure nextXid is beyond any XID mentioned in the record. */
57955795
AdvanceNextFullTransactionIdPastXid(max_xid);
57965796

57975797
Assert(((parsed->xinfo & XACT_XINFO_HAS_ORIGIN) == 0) ==
@@ -5931,7 +5931,7 @@ xact_redo_abort(xl_xact_parsed_abort *parsed, TransactionId xid)
59315931

59325932
Assert(TransactionIdIsValid(xid));
59335933

5934-
/* Make sure nextFullXid is beyond any XID mentioned in the record. */
5934+
/* Make sure nextXid is beyond any XID mentioned in the record. */
59355935
max_xid = TransactionIdLatest(xid,
59365936
parsed->nsubxacts,
59375937
parsed->subxacts);

0 commit comments

Comments
 (0)