Getting the clog bits for a particular xid - Mailing list pgsql-hackers

From Christophe Pettus
Subject Getting the clog bits for a particular xid
Date
Msg-id 91A060CE-181C-48E9-A3E1-37B7E6504653@thebuild.com
Whole thread Raw
List pgsql-hackers
As part of doing some database corruption investigation, I'm trying to get the pg_clog/ bit pair for a particular
transaction.

Let's say we check on a particular tuple, and get:

SELECT xmin, id FROM mytable WHERE pk=4727366;
  xmin    |    id
-----------+----------107898222 |  4727366

Each pg_clog file (as least, as of 9.3.1) is 256KB, so there are 256KB * 8 bits/byte / 2 bits/transaction = 1M
transactionsper file 

So:

107898222 / 1048576 = 102, or 0x0066
107898222 % 1048576 = 943470.

So, we're looking at file 0x0066.  It's the 943470th transaction in that file, or the 943470*2 = 1886940th bit.  So,
(countingfrom the MSB being 0), it's the 4th and 5th bit of byte offset 235867 in that file. 

Is that correct?
--
-- Christophe Pettus  xof@thebuild.com




pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: UTF8 national character data type support WIP patch and list of open issues.
Next
From: Merlin Moncure
Date:
Subject: Re: additional json functionality