pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: David Rowley <david.rowley@2ndquadrant.com>
Cc: Lukas Eder <lukas.eder@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-bugs@postgresql.org>
Subject: Re: Combination of ordered-set aggregate function terminates JDBC connection on PostgreSQL 9.6.5
Date: Thu, 12 Oct 2017 10:55:50 -0400
Message-ID: <748.1507820150@sss.pgh.pa.us> (raw)
In-Reply-To: <bc038d5f-a9c5-0396-9196-ee2703482a35@iki.fi>
References: <CAB4ELO5RZhOamuT9Xsf72ozbenDLLXZKSk07FiSVsuJNZB861A@mail.gmail.com>
	<23270.1507751492@sss.pgh.pa.us>
	<CAKJS1f-EHRN5v2K58D_unR1J0jP6s6TXOSEJPGevUv1JBRtszQ@mail.gmail.com>
	<3802.1507775225@sss.pgh.pa.us>
	<bc038d5f-a9c5-0396-9196-ee2703482a35@iki.fi>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Heikki Linnakangas <hlinnaka@iki.fi> writes:
> On 10/12/2017 05:27 AM, Tom Lane wrote:
>> Speaking of AggGetAggref, there's another thing that I think 804163bc2
>> did wrong for ordered-set aggregates: it can return the wrong Aggref
>> when two aggregates' intermediate states have been merged.

> Conceivably we could have another function like AggGetAggref() that 
> returns all of the Aggrefs. But I don't think it's worth the 
> complication. If the transition function needs to do something different 
> depending on the aggregate it's for, well, don't do that. Define a 
> different transition function for both aggregates.

Thinking about it more clearly, if a transition function is being run
on behalf of several different Aggrefs (with identical input states),
then no, the transition function should not care which Aggref it
looks at.  As you say it mustn't do anything different on the basis of
the finalfn-related fields.  The problem occurs when a finalfn calls
AggGetAggref --- then, I think that the finalfn is entirely entitled
to expect that it will see its own Aggref, not some other one that
happens to share input+transition.

So the issue is that we need some different behavior during
finalize_aggregate than during the transition function calls.
I'm inclined to put back the curperagg field we had before,
and populate that during finalize_aggregate.  Then, AggGetAggref
would look at either curperagg or curpertrans, whichever is set.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (12+ messages)  latest in thread

Message-ID: <748.1507820150@sss.pgh.pa.us>
Permalink:  ../748.1507820150@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/748.1507820150@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, hlinnaka@iki.fi, david.rowley@2ndquadrant.com, lukas.eder@gmail.com
  Subject: Re: Combination of ordered-set aggregate function terminates JDBC connection on PostgreSQL 9.6.5
  In-Reply-To: <748.1507820150@sss.pgh.pa.us>
  References: <CAB4ELO5RZhOamuT9Xsf72ozbenDLLXZKSk07FiSVsuJNZB861A@mail.gmail.com> <23270.1507751492@sss.pgh.pa.us> <CAKJS1f-EHRN5v2K58D_unR1J0jP6s6TXOSEJPGevUv1JBRtszQ@mail.gmail.com> <3802.1507775225@sss.pgh.pa.us> <bc038d5f-a9c5-0396-9196-ee2703482a35@iki.fi> <748.1507820150@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox