Re: Lock rekord
От | Herbert Liechti |
---|---|
Тема | Re: Lock rekord |
Дата | |
Msg-id | 394BB253.63E7A42@thinx.ch обсуждение исходный текст |
Ответ на | Lock rekord (Pawe³ Dubin <paweld@suimed.tpnet.pl>) |
Ответы |
RE: Lock rekord
|
Список | 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.Liechti@thinx.ch ThinX networked business services Stahlrain 10, CH-5200 Brugg ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
В списке pgsql-general по дате отправления: