Re: XID comparations

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: "Carlos H(dot) Reimer" <carlosreimer(at)terra(dot)com(dot)br>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: XID comparations
Date: 2006-06-13 15:47:14
Message-ID: 20060613154714.GG19212@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Jun 13, 2006 at 12:10:26PM -0300, Carlos H. Reimer wrote:
> When xid overflows (32 bits) the next one will be 3 (1 and 2 are reserved).
>
> In this case, we could have have lines with cmin 4.294.967.295 and lines
> with cmin 3. How are they compared to determine that
> rows with cmin 3 are newer than rows with cmin 4.294.967.295?

The same way you handle any circular numbering system, compare the
difference. i.e.

if( (xmin1-xmin2) mod (2^32) < 2^31 )
{
xmin1 is newer than xmin2
}

In the example you give:

(3 - 4.294.967.295) mod (2^32)
= -4294967292 mod (2^32)
= 4

Hence XID 3 is newer compared to XID 4.294.967.295.

Note in such a circular system, it is possible for A < B, B < C and C <
A to all be simultaneously true. However, we always know where the
current transaction is, so everything is compared to that.

I hope this clears it up for you.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Benjamin Arai 2006-06-13 16:04:15 Question about clustering multiple columns
Previous Message Tom Lane 2006-06-13 15:40:06 Re: XID comparations