Re: Declaring a strict function returns not null / eval speed

From: Tels <nospam-pg-abuse(at)bloodgate(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andreas Karlsson <andreas(at)proxel(dot)se>, Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Declaring a strict function returns not null / eval speed
Date: 2019-10-20 16:02:02
Message-ID: 65ed6d964aac3c42813bfed056171a98@bloodgate.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Moin,

On 2019-10-20 16:27, Tom Lane wrote:
> Tels <nospam-pg-abuse(at)bloodgate(dot)com> writes:
>> On 2019-10-20 13:30, Andreas Karlsson wrote:
>>> Agreed, this sounds like something useful to do since virtually all
>>> strict functions cannot return NULL, especially the ones which are
>>> used in tight loops. The main design issue seems to be to think up a
>>> name for this new level of strictness which is not too confusing for
>>> end users.
>
>> STRICT NONULL? That way you could do
>
>> CREATE FUNCTION f1 ... STRICT;
>> CREATE FUNCTION f2 ... STRICT NONULL;
>> CREATE FUNCTION f3 ... NONULL;
>
>> and the last wold throw "not implementet yet"? "NEVER RETURNS NULL"
>> would also ryme with the existing "RETURNS NULL ON NULL INPUT", but I
>> find the verbosity too high.
>
> "RETURNS NOT NULL", perhaps? That'd have the advantage of not
> requiring
> any new keyword.

Hm, yes, that would be a good compromise on verbosity and align even
better the other "RETURNS ..." variants.

> I'm a little bit skeptical of the actual value of adding this
> additional
> level of complexity, but I suppose we can't determine that reliably
> without doing most of the work :-(

Maybe it would be possible to simulate the effect somehow? Or at least
we could try to find practical queries where the additional information
results in a much better plan if RETRUNS NOT NULL was set.

Best regards,

Tels

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David G. Johnston 2019-10-20 17:14:50 Re: jsonb_set() strictness considered harmful to data
Previous Message Tom Lane 2019-10-20 14:27:19 Re: Declaring a strict function returns not null / eval speed