Re: [SQL] Rows with exclusive lock
* Martin Marques: >> That's what SELECT FOR UPDATE does. > > Hi Alvaro, > > After the SELECT FOR UPDATE other transactions can still see the > locked rows. I want a read/write lock, so no one can access does rows. You should probably run the other transactions at SERIALIZABLE level. I suppose this will make them wait for the completion of the update. ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster
Re: [SQL] Rows with exclusive lock
Martin Marques escribió: > On Sat, 22 Jul 2006, Alvaro Herrera wrote: > > >Martin Marques escribió: > >>Is it posible to get an exclusive (read/write) lock on certain rows? I > >>don't want to block the whole table, only certain rows, but I want it to > >>be a read/write lock. > > > >That's what SELECT FOR UPDATE does. > > Hi Alvaro, > > After the SELECT FOR UPDATE other transactions can still see the locked > rows. I want a read/write lock, so no one can access does rows. SELECT FOR UPDATE acquires an exclusive lock, but other transactions must try to acquire a lock on the rows as well, or they won't be locked. You can try using SELECT FOR SHARE (new as of 8.1) if you want some transactions to hold shared (read) locks. IOW, SELECT FOR UPDATE blocks other SELECTs FOR UPDATE and SELECTs FOR SHARE, but it does not block plain SELECT. -- Alvaro Herrerahttp://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly
Re: [SQL] Referential integrity (foreign keys) across multiple tables
On Sat, Jul 22, 2006 at 14:32:57 +0100, Richard Jones <[EMAIL PROTECTED]> wrote: > > Now I want to add a column to page_contents, say called link_name, > which is going to reference the pages.url column for the particular > host that this page belongs to. What are you trying to accomplish by this? The information is available by doing a join. If you are trying to simplify things for applications, you can probably do it with a view or rules depending on whether you want to have an updatable view. If you are denormalizing for performance and want constraints to maintain consistancy, then you probably want to push the hostid down to page_contents as well as the url. These could both be set with a trigger. (I think a rule could be used as well.) ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match