Re: LOCKing method in my situation?

From: Hans-Jürgen Schönig <postgres(at)cybertec(dot)at>
To: Alexander Popkov <voodoo(at)wenet(dot)ru>
Cc: pgsql-php(at)postgresql(dot)org
Subject: Re: LOCKing method in my situation?
Date: 2004-02-01 15:41:56
Message-ID: 401D1E44.9040408@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

Alexander Popkov wrote:
> Hello PostgreSQL gurus!
>
> I am have question to you.
>
> I am have table 'chall_item' in my database.
> In many PHP scripts i am do 'SELECT * FROM chall_item....', but
> in one script (join.php) i do
> a) SELECT COUNT(*) FROM chall_item WHERE chall_no = XXX;
> b) if returned number less then 10, then i do INSERT INTO chall_item (chall_no, ...) VALUES (XXX, ...);
>
> But if beetwen a) and b) other instance of 'join.php' do part "a)" - then odd row are added ;(
>
> I can do LOCK TABLE chall_item IN ACCESS EXCLUSIVE MODE,
> but IMHO this is not true method in this situation, because i need lock only for 'join.php'
> not for all scripts. Help me plz. Which other methods are exist in this situation.
>

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

Regards,

Hans

--
Cybertec Geschwinde u Schoenig
Schoengrabern 134, A-2020 Hollabrunn, Austria
Tel: +43/2952/30706 or +43/664/233 90 75
www.cybertec.at, www.postgresql.at, kernel.cybertec.at

In response to

Responses

Browse pgsql-php by date

  From Date Subject
Next Message Alexander Popkov 2004-02-01 19:11:54 Re: LOCKing method in my situation?
Previous Message Alexander Popkov 2004-02-01 12:39:01 LOCKing method in my situation?