Thread

  1. Re: BUG #18715: replace() function silently fails if 3rd argument is null

    Erik Wienhold <ewie@ewie.name> — 2024-11-19T23:31:12Z

    On 2024-11-19 23:40 +0100, Tom Lane wrote:
    > Erik Wienhold <ewie@ewie.name> writes:
    > > On 2024-11-19 17:47 +0100, Tom Lane wrote:
    > >> I thought we documented somewhere that built-in functions are strict
    > >> unless explicitly stated otherwise ... but I sure can't find that
    > >> statement right now.
    > 
    > > Perhaps this one?:
    > >> (Most internal functions expect to be declared “strict”.)
    > >> https://www.postgresql.org/docs/current/xfunc-internal.html
    > 
    > I did see that one, but it's not exactly in an obvious-to-novices
    > place.
    > 
    > David was working on a new docs section that would talk more about
    > SQL NULLs in general.  Maybe that would be a reasonable place?
    
    Definitely.  Looking at David's v4 patch [1] right now, I see that it
    already covers strict functions (new section "Null-Valued Arguments in
    Normal Function Calls").
    
    > An alternative could be somewhere early in func.sgml, but that chapter
    > doesn't really have anything I would call an overview section.
    
    We have this intro page [2] which explains the notation used throughout
    the chapter.  How about mentioning there that all functions in this
    chapter, unless stated otherwise, return NULL when called with any NULL
    arguments?
    
    [1] https://www.postgresql.org/message-id/CAKFQuwbHuT82b3jYwH%2ByhuKrpLoa0Ebr%2BsT6mTFS%2BnfjAAGUFQ%40mail.gmail.com
    [2] https://www.postgresql.org/docs/current/functions.html
    
    -- 
    Erik