RE: Lock rekord - Mailing list pgsql-general

From Andrew Snow
Subject RE: Lock rekord
Date
Msg-id NHEALMDKDACEIPBNOOOCOEMICFAA.als@fl.net.au
Whole thread Raw
In response to Re: Lock rekord  (Herbert Liechti <Herbert.Liechti@thinx.ch>)
List pgsql-general
> I usually prefer the following trick for preventing long locking
> times. On every
> table I define a timestamp field which is updated every time the record is
> written to the database. If a user edits a record (without
> locking) and commit his changes
> the timestamp is returned from the client program unchanged. The program
> reads the record again for update and compares the timestamp from
> the database
> and the timestamp from the user program.  If the timestamp has changed
> in the meantime the record was updated from someone else and the
> transaction will be rejected.

What happens if someone else updates the record *just* after the record is
reread for update and timestamp compared?


- Andrew



pgsql-general by date:

Previous
From: Herbert Liechti
Date:
Subject: Re: Lock rekord
Next
From: Vipin Samtani
Date:
Subject: ALTER TABLE to add Foreign Key Constraint