From: | Christophe Pettus <xof(at)thebuild(dot)com> |
---|---|
To: | PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Getting the clog bits for a particular xid |
Date: | 2013-11-13 21:33:10 |
Message-ID: | 91A060CE-181C-48E9-A3E1-37B7E6504653@thebuild.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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 transactions per 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, (counting from the MSB being 0), it's the 4th and 5th bit of byte offset 235867 in that file.
Is that correct?
--
-- Christophe Pettus
xof(at)thebuild(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Merlin Moncure | 2013-11-13 21:58:31 | Re: additional json functionality |
Previous Message | Tom Lane | 2013-11-13 20:31:38 | Re: UTF8 national character data type support WIP patch and list of open issues. |