opt-snapshot-txcmp.patch
text/x-patch
Filename: opt-snapshot-txcmp.patch
Type: text/x-patch
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/backend/storage/ipc/procarray.c | 3 | 3 |
| src/include/access/transam.h | 3 | 0 |
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 19ff524..59ff996 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1324,7 +1324,7 @@ GetSnapshotData(Snapshot snapshot)
/* Update globalxmin to be the smallest valid xmin */
xid = pgxact->xmin; /* fetch just once */
if (TransactionIdIsNormal(xid) &&
- TransactionIdPrecedes(xid, globalxmin))
+ TransactionIdPrecedesBothNormal(xid, globalxmin))
globalxmin = xid;
/* Fetch xid just once - see GetNewTransactionId */
@@ -1341,11 +1341,11 @@ GetSnapshotData(Snapshot snapshot)
*/
if (TransactionIdIsNormal(xid))
{
- if (TransactionIdFollowsOrEquals(xid, xmax))
+ if (TransactionIdFollowsOrEqualsBothNormal(xid, xmax))
continue;
if (pgxact != MyPgXact)
snapshot->xip[count++] = xid;
- if (TransactionIdPrecedes(xid, xmin))
+ if (TransactionIdPrecedesBothNormal(xid, xmin))
xmin = xid;
}
diff --git a/src/include/access/transam.h b/src/include/access/transam.h
index c038fd9..31401f9 100644
--- a/src/include/access/transam.h
+++ b/src/include/access/transam.h
@@ -44,6 +44,9 @@
#define TransactionIdStore(xid, dest) (*(dest) = (xid))
#define StoreInvalidTransactionId(dest) (*(dest) = InvalidTransactionId)
+#define TransactionIdPrecedesBothNormal(id1, id2) ((int32) (id1 - id2) < 0)
+#define TransactionIdFollowsOrEqualsBothNormal(id1, id2) ((int32) (id1 - id2) >= 0)
+
/* advance a transaction ID variable, handling wraparound correctly */
#define TransactionIdAdvance(dest) \
do { \