Unclear documentation
In the CREATE FUNCTION docs I notice this:
RETURNS NULL ON NULL INPUT or STRICT indicates that the function always
returns null whenever any of its arguments are null. If this parameter
is specified, the function is not executed when there are null
arguments; instead a null result is assumed automatically.
I'm wondering what this means when the function returns a composite
type, or a setof scalar or a setof composite?
So if you indicate STRICT, does PostgreSQL assume one row of all nulls
for each column in the return composite type? Perhaps someone who knows
better could tweak the docs a bit?
Cheers,
Chris
Christopher Kings-Lynne <chriskl@familyhealth.com.au> writes:
In the CREATE FUNCTION docs I notice this:
RETURNS NULL ON NULL INPUT or STRICT indicates that the function always
returns null whenever any of its arguments are null. If this parameter
is specified, the function is not executed when there are null
arguments; instead a null result is assumed automatically.
I'm wondering what this means when the function returns a composite
type,
You get a null rowtype value ... which is not really the same thing as a
row of nulls, though it behaves similarly in the sense that trying to
extract any one field from it produces null.
or a setof scalar or a setof composite?
You get zero rows.
So if you indicate STRICT, does PostgreSQL assume one row of all nulls
for each column in the return composite type?
No.
Perhaps someone who knows better could tweak the docs a bit?
Can you propose wording that defines all this without being even more
confusing? The point that the quoted sentence is making is merely that
the function is never actually called, which is true in all cases.
regards, tom lane