Skip to content

Commit f5c798e

Browse files
committed
Fix no-longer-correct bit-pushing in TransactionIdSetStatus, per Alvaro.
1 parent e34082e commit f5c798e

File tree

1 file changed

+7
-2
lines changed
  • src/backend/access/transam

1 file changed

+7
-2
lines changed

src/backend/access/transam/clog.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
1414
* Portions Copyright (c) 1994, Regents of the University of California
1515
*
16-
* $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.21 2004/07/01 00:49:42 tgl Exp $
16+
* $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.22 2004/07/03 02:55:56 tgl Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -92,6 +92,7 @@ TransactionIdSetStatus(TransactionId xid, XidStatus status)
9292
int byteno = TransactionIdToByte(xid);
9393
int bshift = TransactionIdToBIndex(xid) * CLOG_BITS_PER_XACT;
9494
char *byteptr;
95+
char byteval;
9596

9697
Assert(status == TRANSACTION_STATUS_COMMITTED ||
9798
status == TRANSACTION_STATUS_ABORTED ||
@@ -107,7 +108,11 @@ TransactionIdSetStatus(TransactionId xid, XidStatus status)
107108
((*byteptr >> bshift) & CLOG_XACT_BITMASK) == TRANSACTION_STATUS_SUB_COMMITTED ||
108109
((*byteptr >> bshift) & CLOG_XACT_BITMASK) == status);
109110

110-
*byteptr |= (status << bshift);
111+
/* note this assumes exclusive access to the clog page */
112+
byteval = *byteptr;
113+
byteval &= ~(((1 << CLOG_BITS_PER_XACT) - 1) << bshift);
114+
byteval |= (status << bshift);
115+
*byteptr = byteval;
111116

112117
/* ...->page_status[slotno] = SLRU_PAGE_DIRTY; already done */
113118

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