Re: BUG #8629: Strange resultset when using CTE or a subselect - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #8629: Strange resultset when using CTE or a subselect
Date
Msg-id 9529.1385486528@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #8629: Strange resultset when using CTE or a subselect  (bricklen <bricklen@gmail.com>)
Responses Re: BUG #8629: Strange resultset when using CTE or a subselect  ("jonathan.camile" <jonathan.camile@gmail.com>)
List pgsql-bugs
bricklen <bricklen@gmail.com> writes:
> On Tue, Nov 26, 2013 at 1:50 AM, jonathan.camile
> <jonathan.camile@gmail.com>wrote:
>> I always have the same last result regardless of the offset or the limit I
>> use.

> I cannot reproduce your problem in 9.2.5 nor 9.3.1. Rerunning the query
> with different OFFSET values gives me different results each time.

I do reproduce the behavior, at least when offset+limit is small enough
that the executor will use a top-N heapsort.  As already stated, it's
not a bug; the ordering is underdetermined so any set of the correct
number of rows with status = 5 is a valid output.  As for what's actually
happening: the row that always shows up seems to be the physically first
one with status = 5.  I think that's starting out as the top of the top-N
heap, and it just stays there because there's nothing that can displace
it.

            regards, tom lane

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #8628: md5 security hole
Next
From: Eduardo Armendariz
Date:
Subject: Re: BUG #8612: Truncate did not release disk space