Re: [HACKERS] Error calling PG_RETURN_NULL()

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Alexandre Savaris <alexandre(dot)savaris(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: [HACKERS] Error calling PG_RETURN_NULL()
Date: 2011-07-26 03:15:45
Message-ID: 1311650145.29391.15.camel@jdavis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

[ Moved to pgsql-general. pgsql-hackers is for development of PostgreSQL
itself. ]

On Mon, 2011-07-25 at 20:06 -0300, Alexandre Savaris wrote:
> ********** Error **********
> ERRO: input function 49344 returned NULL
> SQL state: XX000
> Character: 45
> It seems like the call to PG_RETURN_NULL() on the input function is
> causing the error. Is this the correct behaviour? There's another way to
> return a NULL value as the result of a data type's input function?

The docs say:

"The input function must return a value of the data type itself."

Which means you can't return a NULL from the input function when there
is non-NULL input. The context around that statement is a little more
informative, but perhaps it could be more clear.

I assume that postgresql has that requirement because it needs to know
whether something is NULL without necessarily knowing what type it is.
For instance:
Should that be true or false? If it depends on the type of the
left-hand-side, how do you figure out what type it is? I'm not sure if
this is the exact reason it's prohibited, but it seems like there would
be a problem somewhere along these lines.

Interesting idea though.

Jeff Davis

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2011-07-26 03:19:55 Re: pgsql error
Previous Message Joe Conway 2011-07-26 00:45:35 Re: create table as select... with auto increment id ?

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2011-07-26 03:25:18 Re: Error calling PG_RETURN_NULL()
Previous Message Jerry Sievers 2011-07-26 02:59:46 Re: Check constraints on partition parents only?