Re: XID comparations - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: XID comparations
Date
Msg-id 20060613154714.GG19212@svana.org
Whole thread Raw
In response to XID comparations  ("Carlos H. Reimer" <carlosreimer@terra.com.br>)
Responses RES: XID comparations
List 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@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Attachment

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: XID comparations
Next
From: "jqpx37"
Date:
Subject: PostgreSQL and Apache: authentication and authorization