Re: [HACKERS] select order by for update - Mailing list pgsql-hackers

From Vadim Mikheev
Subject Re: [HACKERS] select order by for update
Date
Msg-id 375FD687.6D9394AB@krs.ru
Whole thread Raw
In response to Re: [HACKERS] select order by for update  ("Mark Wright" <mwright@pro-ns.net>)
List pgsql-hackers
Mark Wright wrote:
> 
> |SELECT * FROM test_attendees
> |WHERE print_status = 'R'
> |AND id_number = (select min(id_number) from test_attendees  )
   ^^^
 
Ops - add "AND print_status = 'R'" here!

> |FOR UPDATE OF test_attendees
> |
> |and run it in loop.
> 
> That would only work the first time, since after updating print_status to
> 'C', the record where id_number = (select min(id_number) from
> test_attendees) would no longer have print_status = 'R', so no records would
> match the query.

And this is why I said "run select in loop": if no one row will
be returned (i.e. row returned by subselect is already updated
by concurrent xaction) then re-run select!

Vadim


pgsql-hackers by date:

Previous
From: Thomas Lockhart
Date:
Subject: Re: [HACKERS] Postgres 6.5 beta2 and beta3 problem
Next
From: A James Lewis
Date:
Subject: Re: Real Programmers (was: [HACKERS] Priorities for 6.6)