Re: [HACKERS] DISTINCT and ORDER BY bug?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [HACKERS] DISTINCT and ORDER BY bug?
Дата
Msg-id 13474.949901164@sss.pgh.pa.us
обсуждение исходный текст
Ответ на DISTINCT and ORDER BY bug?  (Don Baccus <dhogaza@pacifier.com>)
Ответы Re: [HACKERS] DISTINCT and ORDER BY bug?  (Taral <taral@taral.net>)
Re: [HACKERS] DISTINCT and ORDER BY bug?  (Don Baccus <dhogaza@pacifier.com>)
Список pgsql-hackers
Don Baccus <dhogaza@pacifier.com> writes:
> The following used to work in 6.5, works in Oracle, and is
> very useful:

> donb=# select distinct c from foo order by upper(c);
> ERROR:  For SELECT DISTINCT, ORDER BY expressions must appear in target list

Well, it's not a bug --- it was an entirely deliberate change.  It
might be a misfeature though.  The case we were concerned about was
select distinct x from foo order by y;

which produces ill-defined results.  If I recall the thread correctly,
Oracle and a number of other DBMSs reject this.  I think your point is
that
select distinct x from foo order by f(x);

*is* well-defined, and useful.  I think you are right, but how
far should we go in detecting common subexpressions?  You might
want to contemplate the difference in these examples:
select distinct sin(x) from foo order by abs(sin(x));
select distinct random(x) from foo order by abs(random(x));

It would be interesting to poke at Oracle to find out just what they
consider a legitimate ORDER BY expression for a SELECT DISTINCT.
        regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Chris Bitmead
Дата:
Сообщение: ONLY
Следующее
От: Chris Bitmead
Дата:
Сообщение: Re: [HACKERS] Advice needed,