On Wednesday 21 October 2009 05:37:36 Thach Anh Tran wrote:
> The following bug has been logged online:
>
> Bug reference: 5129
> Logged by: Thach Anh Tran
> Email address: myquartz@gmail.com
> PostgreSQL version: 8.3.8
> Operating system: Linux
> Description: LIMIT not correct.
> Details:
>
> the LIMIT clause is not reply correct number of rows and rows returns.
Read the second caution block in the relevant section of the manual:
http://www.postgresql.org/docs/current/interactive/sql-select.html#SQL-FOR-
UPDATE-SHARE
"It is possible for a SELECT command using both LIMIT and FOR UPDATE/SHARE
clauses to return fewer rows than specified by LIMIT. This is because LIMIT is
applied first. The command selects the specified number of rows, but might then
block trying to obtain a lock on one or more of them. Once the SELECT
unblocks, the row might have been deleted or updated so that it does not meet
the query WHERE condition anymore, in which case it will not be returned.
"
Andres