pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Hans-Jürgen Schönig <postgres@cybertec.at>
To: Alexander Popkov <voodoo@wenet.ru>
Cc: pgsql-php@postgresql.org
Subject: Re: LOCKing method in my situation?
Date: Sun, 01 Feb 2004 16:41:56 +0100
Message-ID: <401D1E44.9040408@cybertec.at> (raw)
In-Reply-To: <62364058618.20040201153901@wenet.ru>
References: <62364058618.20040201153901@wenet.ru>

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




view thread (5+ messages)  latest in thread

Message-ID: <401D1E44.9040408@cybertec.at>
Permalink:  ../401D1E44.9040408@cybertec.at/
Also on:    postgresql.org/message-id/401D1E44.9040408@cybertec.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: postgres@cybertec.at, voodoo@wenet.ru
  Subject: Re: LOCKing method in my situation?
  In-Reply-To: <401D1E44.9040408@cybertec.at>
  References: <62364058618.20040201153901@wenet.ru> <401D1E44.9040408@cybertec.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox