Re: Returning NULL to a set returning C type function - Mailing list pgsql-general

From Tom Lane
Subject Re: Returning NULL to a set returning C type function
Date
Msg-id 3247.1305138219@sss.pgh.pa.us
Whole thread Raw
In response to Returning NULL to a set returning C type function  (Bborie Park <bkpark@ucdavis.edu>)
Responses Re: Returning NULL to a set returning C type function  (Bborie Park <bkpark@ucdavis.edu>)
List pgsql-general
Bborie Park <bkpark@ucdavis.edu> writes:
> I have a C type function that returns a set of a type.  The problem I
> have is that the underlying function may return NULL.  When the
> underlying function returns NULL, I get the error message:

> ERROR:  function returning set of rows cannot return null value

> I'm wondering what is the proper way to correct this problem?

Don't do that ;-).  You could choose either to not return any row
at all when this happens, or to construct an all-nulls row to return.
ExecMakeTableFunctionResult doesn't want to guess which behavior is
appropriate for your use-case, so it just complains.

            regards, tom lane

pgsql-general by date:

Previous
From: Michael Nolan
Date:
Subject: Re: Query to return every 1st Sat of a month between two dates
Next
From: "David Johnston"
Date:
Subject: Re: Regexp match not working.. (SQL help)