Re: Lock rekord

From: Herbert Liechti <Herbert(dot)Liechti(at)thinx(dot)ch>
To: postgres <pgsql-general(at)postgreSQL(dot)org>
Subject: Re: Lock rekord
Date: 2000-06-17 17:16:04
Message-ID: 394BB253.63E7A42@thinx.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Pawe³ Dubin" wrote:

> Hello
>
> I was listening Your discusion. I have practical problem for which I write my
> own locking system:
>
> Now A change zip and write all
> B change adress and write
>
> so zip is unchanged.
>
> In pgsql I can solve it by SELECT FOR UPDATE but if user A goes for caffe
> during his update
> user B hangs for several minutes ...
>
> Ther is no solution to check if record is in transaction ?

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.

Regards Herbie

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Herbert Liechti E-Mail: Herbert(dot)Liechti(at)thinx(dot)ch
ThinX networked business services Stahlrain 10, CH-5200 Brugg
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Snow 2000-06-17 17:35:15 RE: Lock rekord
Previous Message Trurl McByte 2000-06-17 15:41:36 Re: copying table to a file