Re: Question Regarding Locks

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Question Regarding Locks
Date: 2004-10-29 09:34:12
Message-ID: 20041029093408.GA28624@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice

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(at)svana(dot)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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message M.A. Oude Kotte 2004-10-29 10:12:45 Creating database problem
Previous Message Karsten Hilbert 2004-10-29 07:22:42 Re: Question Regarding Locks

Browse pgsql-novice by date

  From Date Subject
Next Message Karsten Hilbert 2004-10-29 10:41:43 Re: Question Regarding Locks
Previous Message Karsten Hilbert 2004-10-29 07:22:42 Re: Question Regarding Locks