Re: Combine function returning NULL unhandled?

From: Andres Freund <andres(at)anarazel(dot)de>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Simon Riggs <simon(at)2ndquadrant(dot)com>, David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
Subject: Re: Combine function returning NULL unhandled?
Date: 2017-11-24 01:20:32
Message-ID: 20171124012032.2i54jps6gjpzrjb5@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2017-11-21 15:51:59 -0500, Robert Haas wrote:
> On Mon, Nov 20, 2017 at 10:36 PM, Andres Freund <andres(at)anarazel(dot)de> wrote:
> > The plain transition case contains:
> > if (pergroupstate->transValueIsNull)
> > {
> > /*
> > * Don't call a strict function with NULL inputs. Note it is
> > * possible to get here despite the above tests, if the transfn is
> > * strict *and* returned a NULL on a prior cycle. If that happens
> > * we will propagate the NULL all the way to the end.
> > */
> > return;
> > }
> >
> > how come similar logic is not present for combine functions? I don't see
> > any checks preventing a combinefunc from returning NULL, nor do I see
> > https://www.postgresql.org/docs/devel/static/sql-createaggregate.html
> > spell out a requirement that that not be the case.
>
> I don't know of a reason why that logic shouldn't be present for the
> combine-function case as well. It seems like it should be pretty
> straightforward to write a test that hits that case and watch it blow
> up ... assuming it does, then I guess we should back-patch the
> addition of that logic.

Found it surprisingly not that straightforward ;)

Pushed a fix to the relevant branches, including tests of the
trans/combine functions returns NULL cases.

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2017-11-24 01:47:48 Re: [HACKERS] HASH_CHUNK_SIZE vs malloc rounding
Previous Message atorikoshi 2017-11-24 01:20:23 Re: Failed to delete old ReorderBuffer spilled files