Re: Combination of ordered-set aggregate function terminates JDBC connection on PostgreSQL 9.6.5

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Pantelis Theodosiou <ypercube@gmail.com>
Cc: Pavel Stehule <pavel.stehule@gmail.com>, Lukas Eder <lukas.eder@gmail.com>, "pgsql-bugs@postgresql.org" <pgsql-bugs@postgresql.org>
Date: 2017-10-11T15:03:01Z
Lists: pgsql-bugs

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Treat aggregate direct arguments as per-agg data not per-trans data.

  2. Allow the built-in ordered-set aggregates to share transition state.

  3. Fix AggGetAggref() so it won't lie to aggregate final functions.

  4. Prevent sharing transition states between ordered-set aggregates.

Pantelis Theodosiou <ypercube@gmail.com> writes:
> - it can be seen with only rank and dense_rank, with any order by (asc,
> desc, null):
> select
>   rank(1) within group (order by a),
>   dense_rank(1) within group (order by a)
> from (values (1)) t(a) ;

Check ...

> - but it doesn't happen if   (values (1)) is replaced with a single row
> table.

It did for me.  I'm using a debug-enabled build, which typically helps
to make this sort of thing more reproducible.

regression=# create table t(a int) ;
CREATE TABLE
regression=# insert into t values(1);
INSERT 0 1
regression=# select
  rank(1) within group (order by a),
  dense_rank(1) within group (order by a)
from t;                 
server closed the connection unexpectedly

			regards, tom lane