Re: LOCKing method in my situation? - Mailing list pgsql-php

From Alexander Popkov
Subject Re: LOCKing method in my situation?
Date
Msg-id 106387628840.20040201221154@wenet.ru
Whole thread Raw
In response to Re: LOCKing method in my situation?  (Hans-Jürgen Schönig <postgres@cybertec.at>)
List pgsql-php
Hello Hans-Jьrgen,

Sunday, February 1, 2004, 6:41:56 PM, you wrote:


HJS> If I understand you question correctly you have to use a SERIALIZABLE
HJS> transaction to make sure that you can see the same snapshot during your
HJS> transaction.

My problem is same as:
[quote from: http://www.postgresql.org/docs/7.2/interactive/xact-serializable.html]
-----------------------------------------------------------------------------------
I don't think serializable transactions quite give you this.

Consider the following transaction:

BEGIN
SELECT count(*) FROM bottles WHERE wall = 3; [*]
[if count < 10]
INSERT INTO bottles (wall, colour) VALUES (3, 'green');
[end if]
END

If this were run several times sequentially, it could never increase the number of
bottles on wall 3 so that there were more than 10. But if it ran several times
simultaneously, even with serializable transaction isolation, it could do so.
-----------------------------------------------------------------------------------

Which methods are fix this trouble? Desirable not slow methods...

Very important detail:
SELECT query, marked by [*] is executed only from one function, for
example from
function bottle_add() {
  BEGIN
  SELECT count(*) FROM bottles WHERE wall = 3; [*]
  [if count < 10]
    INSERT INTO bottles (wall, colour) VALUES (3, 'green');
  [end if]
  END
}

but in all other (many many) functions exists selects from 'battles'
table too, and locking _all_ rows in table 'battles' for read/write
are disagree. May be i need to do locking not row's, but queries?
Locking on application layer? Help plz.

Sorry for bad english ;(

--
Best regards,
 Alexander                            mailto:voodoo@wenet.ru


pgsql-php by date:

Previous
From: Hans-Jürgen Schönig
Date:
Subject: Re: LOCKing method in my situation?
Next
From: Paul & Natalie T
Date:
Subject: Re: LOCKing method in my situation?