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