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

Re: lock table question

From: "Andy Kriger" <akriger(at)greaterthanone(dot)com>
To: "Pgsql-General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: lock table question
Date: 2002-12-30 20:48:38
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
It doesn't lock the row from being read. I want to make sure the row cannot
be read until I have done my read and updated if necessary. LOCK TABLE does
that but also prevents other rows from being read which is a bit overzealous
for my taste (the app is small so it's probably not a big deal in this case,
but I can see in future possibilities how it would be).

-----Original Message-----
From: pgsql-general-owner(at)postgresql(dot)org
[mailto:pgsql-general-owner(at)postgresql(dot)org]On Behalf Of Doug McNaught
Sent: Monday, December 30, 2002 15:18
To: Andy Kriger
Cc: Pgsql-General
Subject: Re: [GENERAL] lock table question

"Andy Kriger" <akriger(at)greaterthanone(dot)com> writes:

> I have an inventory table. I need to be able to lock a row from being
> read/written while I: check the quantity value; modify it if necessary.
> my experiments, it appears I can only do this with LOCK TABLE. Since this
> locks the whole table and not just the individual row, I'm guessing this
> would create quite a bottleneck if our application were larger. I'm also
> guessing that there's a better way to approach this probably common need.

Does SELECT ... FOR UPDATE not do what you want?


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)

In response to


pgsql-general by date

Next:From: Tom LaneDate: 2002-12-30 21:17:08
Subject: Re: lock table question
Previous:From: Medi MontaseriDate: 2002-12-30 20:31:45
Subject: Re: pg and transactions

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