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

Re: Unexpected sort order (suspected bug)

From: Ron Mayer <rm_pg(at)cheapcomplexdevices(dot)com>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Subject: Re: Unexpected sort order (suspected bug)
Date: 2006-11-27 22:10:08
Message-ID: 456B6240.5030006@cheapcomplexdevices.com (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-general
Jeff Davis wrote:
> On Mon, 2006-11-27 at 12:44 -0800, Ron Mayer wrote:
>> Shouldn't the results of this query shown here been sorted by "b" rather than by "a"?
>>
>> I would have thought since "order by b" is in the outer sql statement it would have
>> been the one the final result gets ordered by.
>>
>> li=# select * from (select (random()*10)::int as a, (random()*10)::int as b from generate_series(1,10) order by a) as x order by b;
>>  a | b
>> ---+----
>>  0 |  8
>>  1 | 10
>>  3 |  4
>>  4 |  8
>>  5 |  1
>>  5 |  9
>>  6 |  4
>>  6 |  5
>>  8 |  4
>>  9 |  0
>> (10 rows)
>>...
> 
> It looks like a planner bug.
> 
> Below are two plans; the first fails and the second succeeds. That leads
> me to believe it's a planner bug, but what seems strangest to me is that
> it does order by a, and not by some new evaluation of (random()*10).
> 

Yeah, looks that way to me too.

So how would I report it.  Ccing the bugs list?  Guess it can't hurt.

In response to

pgsql-bugs by date

Next:From: Ron MayerDate: 2006-11-27 22:18:59
Subject: Re: Unexpected sort order.
Previous:From: Tom LaneDate: 2006-11-27 22:05:27
Subject: Re: Unexpected sort order.

pgsql-general by date

Next:From: Brandon AikenDate: 2006-11-27 22:10:28
Subject: Re: IS it a good practice to use SERIAL as Primary Key?
Previous:From: Tom LaneDate: 2006-11-27 22:05:27
Subject: Re: Unexpected sort order.

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