Re: Aggregates with non-commutative transition functions - Mailing list pgsql-general

From Tom Lane
Subject Re: Aggregates with non-commutative transition functions
Date
Msg-id 2214.1045181458@sss.pgh.pa.us
Whole thread Raw
In response to Aggregates with non-commutative transition functions  (Emmanuel Charpentier <charpent@bacbuc.dyndns.org>)
Responses Re: Aggregates with non-commutative transition functions
List pgsql-general
Emmanuel Charpentier <charpent@bacbuc.dyndns.org> writes:
> In other words, may I guarantee that :
> select recnum, glue(linenum)as authors from (select recnum, linenum, author
> from cit_authors where <some conditions on recnum> order by recnum,
> linenum) as foo;
> will indeed give me the authors in the original order ?

The query as given is illegal; you'd need to add "GROUP BY recnum" to
the outer query to make it legal.  And once you do that, I don't think
you can rely on the ordering of the rows.

This problem has been discussed before, and I think we came up with some
workaround for it, but I don't have time to go trolling the archives for
the solution at the moment.

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: set returning functions in v7.3
Next
From: Greg Stark
Date:
Subject: Re: index scan with index cond on first column doesn't recognize sort order of second column