Re: Question Regarding Locks - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Question Regarding Locks
Date
Msg-id 20041029093408.GA28624@svana.org
Whole thread Raw
In response to Re: Question Regarding Locks  (Karsten Hilbert <Karsten.Hilbert@gmx.net>)
Responses Re: Question Regarding Locks  (Karsten Hilbert <Karsten.Hilbert@gmx.net>)
List pgsql-general
On Fri, Oct 29, 2004 at 09:22:42AM +0200, Karsten Hilbert wrote:
> The docs say that XMIN is the transaction ID of the *inserting*
> transaction for this row version. IOW updates will change XMIN.
> Will XMIN also be changed by a *deleting* transaction ? I guess
> it depends on how deletion is handled: Either the *unchanged*
> row version is marked as deleted (hence XMIN would not change)
> OR a new row version is created and marked deleted (which would
> indeed change xmin).

You need to look at it in conjunction with XMAX. A newly insert row has
XMIN set and XMAX null. When a row is updated the XMAX of the old row
is set and a new row is created with an XMIN. When you delete a row it
just sets the XMAX.

> IOW, can I also detect my row being *deleted* from under me by
> another transation by way of checking XMIN ? Else I would
> likely need to check XMAX, too.

Easy, look for it. If you can't find it, it got deleted...

--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Attachment

pgsql-general by date:

Previous
From: Karsten Hilbert
Date:
Subject: Re: Question Regarding Locks
Next
From: "M.A. Oude Kotte"
Date:
Subject: Creating database problem