Re: [HACKERS] DISTINCT and ORDER BY bug? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] DISTINCT and ORDER BY bug?
Date
Msg-id 19769.949939403@sss.pgh.pa.us
Whole thread Raw
In response to Re: [HACKERS] DISTINCT and ORDER BY bug?  (Don Baccus <dhogaza@pacifier.com>)
Responses Re: [HACKERS] DISTINCT and ORDER BY bug?
List pgsql-hackers
Don Baccus <dhogaza@pacifier.com> writes:
> My first thought is that it is following a simple rule:

> For arithmetic "order by" expressions, either:

> 1. The exact expression must also appear in the "select" list,
>    and it must be exact, not just an expression that computes
>    the same value as the "order by" expression
>  or

> 2. all of the variables used by the expression must be listed 
>    in the "select" list as simple column names, not as part of
>    an expression.

Could be.  How about cases like
select distinct x,y+1 from foo order by x+y+1;

> At least, the rule is simple if you can compare expression trees.

I think we have something pretty similar for GROUP BY, actually,
so it may not be hard to make this work.
        regards, tom lane


pgsql-hackers by date:

Previous
From: wieck@debis.com (Jan Wieck)
Date:
Subject: Re: [HACKERS] New Globe
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] Longer Column Names