Re: Need to select and update with the same sql statement

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
Cc: David Busby <busby(at)pnts(dot)com>, pgsql-php(at)postgresql(dot)org
Subject: Re: Need to select and update with the same sql statement
Date: 2002-11-14 13:45:14
Message-ID: 20021114134514.GA20110@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

On Wed, Nov 13, 2002 at 15:26:42 -0700,
"scott.marlowe" <scott(dot)marlowe(at)ihs(dot)com> wrote:
>
> Oh, I just thought of the better way than locking the whole table is to
> use a "select for update" on the row you want to lock. I think that'll do
> what you want and without locking the whole table. Of course, 20 lines of
> PHP code runs pretty fast, so unless you're handling lotsa traffic locking
> the table probably works fine too.

This came up in a discussion recently and it really isn't better. If you
do this you have to worry about the select for update returning zero
rows (even with the limit 1 clause) and retry the query if it does.

In response to

Browse pgsql-php by date

  From Date Subject
Next Message scott.marlowe 2002-11-14 19:35:12 Re: serial type question
Previous Message Phil Geer 2002-11-14 03:53:55 Re: serial type question