Re: [HACKERS] DISTINCT and ORDER BY bug?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Don Baccus <dhogaza(at)pacifier(dot)com>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] DISTINCT and ORDER BY bug?
Date: 2000-02-07 16:03:23
Message-ID: 19769.949939403@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Don Baccus <dhogaza(at)pacifier(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2000-02-07 16:06:23 Re: [HACKERS] Longer Column Names
Previous Message Tom Lane 2000-02-07 15:56:43 Re: [HACKERS] DISTINCT and ORDER BY bug?