Skip site navigation (1) Skip section navigation (2)

Re: LOCKing method in my situation?

From: Paul & Natalie T <pntil(at)shentel(dot)net>
To: pgsql-php(at)postgresql(dot)org
Subject: Re: LOCKing method in my situation?
Date: 2004-02-01 19:58:25
Message-ID: 401D5A61.9000509@shentel.net (view raw or flat)
Thread:
Lists: pgsql-php
Alexander:

It sounds like a lock preventing concurrent writes would be your best 
bet.  This would mean that only one instance of your script can be 
*changing* the table at one time, but it has no effect on transactions 
that only read from that.

If I read the docs correctly:
http://www.postgresql.org/docs/7.4/static/explicit-locking.html

You want to obtain a ROW EXCLUSIVE lock, e.g.,

LOCK TABLE <table name> IN ROW EXCLUSIVE;

Regards,

Paul Tillotson

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.  
>
>  
>



In response to

Responses

pgsql-php by date

Next:From: Alexander PopkovDate: 2004-02-01 21:14:23
Subject: Re: LOCKing method in my situation?
Previous:From: Alexander PopkovDate: 2004-02-01 19:11:54
Subject: Re: LOCKing method in my situation?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group