• Tom Lane's avatar
    Allow functions that return sets of tuples to return simple NULLs. · d8411a6c
    Tom Lane authored
    ExecMakeTableFunctionResult(), which is used in SELECT FROM function(...)
    cases, formerly treated a simple NULL output from a function that both
    returnsSet and returnsTuple as a violation of the SRF protocol.  What seems
    better is to treat a NULL output as equivalent to ROW(NULL,NULL,...).
    Without this, cases such as SELECT FROM unnest(...) on an array of
    composite are vulnerable to unexpected and not-very-helpful failures.
    Old code comments here suggested an alternative of just ignoring
    simple-NULL outputs, but that doesn't seem very principled.
    
    This change had been hung up for a long time due to uncertainty about
    how much we wanted to buy into the equivalence of simple NULL and
    ROW(NULL,NULL,...).  I think that's been mostly resolved by the discussion
    around bug #14235, so let's go ahead and do it.
    
    Per bug #7808 from Joe Van Dyk.  Although this is a pretty old report,
    fixing it smells a bit more like a new feature than a bug fix, and the
    lack of other similar complaints suggests that we shouldn't take much risk
    of destabilization by back-patching.  (Maybe that could be revisited once
    this patch has withstood some field usage.)
    
    Andrew Gierth and Tom Lane
    
    Report: <E1TurJE-0006Es-TK@wrigleys.postgresql.org>
    d8411a6c
rangefuncs.out 53.7 KB