Skip to content

Commit 0ab9d1c

Browse files
committed
Replace XLogRecPtr struct with a 64-bit integer.
This simplifies code that needs to do arithmetic on XLogRecPtrs. To avoid changing on-disk format of data pages, the LSN on data pages is still stored in the old format. That should keep pg_upgrade happy. However, we have XLogRecPtrs embedded in the control file, and in the structs that are sent over the replication protocol, so this changes breaks compatibility of pg_basebackup and server. I didn't do anything about this in this patch, per discussion on -hackers, the right thing to do would to be to change the replication protocol to be architecture-independent, so that you could use a newer version of pg_receivexlog, for example, against an older server version.
1 parent 061e7ef commit 0ab9d1c

File tree

28 files changed

+280
-358
lines changed

28 files changed

+280
-358
lines changed

contrib/pageinspect/rawpage.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ page_header(PG_FUNCTION_ARGS)
206206
/* Extract information from the page header */
207207

208208
lsn = PageGetLSN(page);
209-
snprintf(lsnchar, sizeof(lsnchar), "%X/%X", lsn.xlogid, lsn.xrecoff);
209+
snprintf(lsnchar, sizeof(lsnchar), "%X/%X",
210+
(uint32) (lsn >> 32), (uint32) lsn);
210211

211212
values[0] = CStringGetTextDatum(lsnchar);
212213
values[1] = UInt16GetDatum(PageGetTLI(page));

src/backend/access/gist/gist.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate,
197197
SplitedPageLayout *dist = NULL,
198198
*ptr;
199199
BlockNumber oldrlink = InvalidBlockNumber;
200-
GistNSN oldnsn = {0, 0};
200+
GistNSN oldnsn = 0;
201201
SplitedPageLayout rootpg;
202202
BlockNumber blkno = BufferGetBlockNumber(buffer);
203203
bool is_rootsplit;
@@ -488,7 +488,7 @@ gistdoinsert(Relation r, IndexTuple itup, Size freespace, GISTSTATE *giststate)
488488

489489
/* Start from the root */
490490
firststack.blkno = GIST_ROOT_BLKNO;
491-
firststack.lsn.xrecoff = 0;
491+
firststack.lsn = 0;
492492
firststack.parent = NULL;
493493
firststack.downlinkoffnum = InvalidOffsetNumber;
494494
state.stack = stack = &firststack;

src/backend/access/gist/gistutil.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -706,13 +706,7 @@ gistoptions(PG_FUNCTION_ARGS)
706706
XLogRecPtr
707707
GetXLogRecPtrForTemp(void)
708708
{
709-
static XLogRecPtr counter = {0, 1};
710-
711-
counter.xrecoff++;
712-
if (counter.xrecoff == 0)
713-
{
714-
counter.xlogid++;
715-
counter.xrecoff++;
716-
}
709+
static XLogRecPtr counter = 1;
710+
counter++;
717711
return counter;
718712
}

src/backend/access/transam/transam.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
#include "access/transam.h"
2525
#include "utils/snapmgr.h"
2626

27-
/* Handy constant for an invalid xlog recptr */
28-
const XLogRecPtr InvalidXLogRecPtr = {0, 0};
29-
3027
/*
3128
* Single-item cache for results of TransactionLogFetch. It's worth having
3229
* such a cache because we frequently find ourselves repeatedly checking the

src/backend/access/transam/twophase.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,7 @@ MarkAsPreparing(TransactionId xid, const char *gid,
333333

334334
gxact->prepared_at = prepared_at;
335335
/* initialize LSN to 0 (start of WAL) */
336-
gxact->prepare_lsn.xlogid = 0;
337-
gxact->prepare_lsn.xrecoff = 0;
336+
gxact->prepare_lsn = 0;
338337
gxact->owner = owner;
339338
gxact->locking_xid = xid;
340339
gxact->valid = false;

src/backend/access/transam/xact.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ RecordTransactionCommit(void)
951951
if (XLogStandbyInfoActive())
952952
nmsgs = xactGetCommittedInvalidationMessages(&invalMessages,
953953
&RelcacheInitFileInval);
954-
wrote_xlog = (XactLastRecEnd.xrecoff != 0);
954+
wrote_xlog = (XactLastRecEnd != 0);
955955

956956
/*
957957
* If we haven't been assigned an XID yet, we neither can, nor do we want
@@ -1200,7 +1200,7 @@ RecordTransactionCommit(void)
12001200
SyncRepWaitForLSN(XactLastRecEnd);
12011201

12021202
/* Reset XactLastRecEnd until the next transaction writes something */
1203-
XactLastRecEnd.xrecoff = 0;
1203+
XactLastRecEnd = 0;
12041204

12051205
cleanup:
12061206
/* Clean up local data */
@@ -1402,7 +1402,7 @@ RecordTransactionAbort(bool isSubXact)
14021402
{
14031403
/* Reset XactLastRecEnd until the next transaction writes something */
14041404
if (!isSubXact)
1405-
XactLastRecEnd.xrecoff = 0;
1405+
XactLastRecEnd = 0;
14061406
return InvalidTransactionId;
14071407
}
14081408

@@ -1501,7 +1501,7 @@ RecordTransactionAbort(bool isSubXact)
15011501

15021502
/* Reset XactLastRecEnd until the next transaction writes something */
15031503
if (!isSubXact)
1504-
XactLastRecEnd.xrecoff = 0;
1504+
XactLastRecEnd = 0;
15051505

15061506
/* And clean up local data */
15071507
if (rels)
@@ -2170,7 +2170,7 @@ PrepareTransaction(void)
21702170
*/
21712171

21722172
/* Reset XactLastRecEnd until the next transaction writes something */
2173-
XactLastRecEnd.xrecoff = 0;
2173+
XactLastRecEnd = 0;
21742174

21752175
/*
21762176
* Let others know about no transaction in progress by me. This has to be

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