BUG #5563: Odd behavior with aggregate_func(DISTINCT foo ORDER BY foo)

From: "Daniel Grace" <dgrace(at)wingsnw(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #5563: Odd behavior with aggregate_func(DISTINCT foo ORDER BY foo)
Date: 2010-07-17 00:04:08
Message-ID: 201007170004.o6H0485p075061@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 5563
Logged by: Daniel Grace
Email address: dgrace(at)wingsnw(dot)com
PostgreSQL version: 9.0beta3
Operating system: Windows XP 32-bit
Description: Odd behavior with aggregate_func(DISTINCT foo ORDER BY
foo)
Details:

The manual states:
"If DISTINCT is specified in addition to an order_by_clause, then all the
ORDER BY expressions must match regular arguments of the aggregate; that is,
you cannot sort on an expression that is not included in the DISTINCT list.
"

However, in some circumstances Postgres will fail

DROP TABLE IF EXISTS foo;
CREATE TABLE foo (
t VARCHAR
);

INSERT INTO foo (t) VALUES ('a'), ('a'), ('b'), ('b'), ('c');

SELECT STRING_AGG(DISTINCT t::TEXT ORDER BY t::TEXT) FROM foo;

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Daniel Grace 2010-07-17 00:07:53 BUG #5564: Odd behavior with aggregate_func(DISTINCT foo ORDER BY foo)
Previous Message Heinz Groote 2010-07-16 10:39:05 BUG #5562: icon "terrestrial globe" much too big