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

Re: SELECT FOR UPDATE and LIMIT 1 behave oddly

From: Neil Conway <neilc(at)samurai(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: SELECT FOR UPDATE and LIMIT 1 behave oddly
Date: 2004-10-15 02:14:45
Message-ID: 1097806485.29932.104.camel@localhost.localdomain (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
On Thu, 2004-10-14 at 14:02, Tom Lane wrote:
> The FOR UPDATE part executes after the LIMIT part.  Arguably this is a
> bad thing, but I'm concerned about the compatibility issues if we change
> it.

I agree backward compat is a concern, but it seems pretty clear to me
that this is not the optimal behavior. If there are any people who
actually need the old behavior, they can nest the FOR UPDATE in a
FROM-clause subselect:

SELECT * FROM foo FOR UPDATE LIMIT 5; -- used to lock the whole table

SELECT * FROM (SELECT * FROM foo FOR UPDATE) x LIMIT 5; -- will always
do so

Would it be sufficient to put a large warning in the "incompatibilities"
section of the release notes?


In response to


pgsql-bugs by date

Next:From: Alvaro HerreraDate: 2004-10-15 02:43:39
Subject: Re: 'configure' bug on Mac OS X 10.3.5
Previous:From: Neil ConwayDate: 2004-10-15 02:03:39
Subject: Re: 'configure' bug on Mac OS X 10.3.5

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