Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-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."

http://www.postgresql.org/docs/9.0/static/sql-createtype.html

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:
  ' ' IS NULL
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.

Regards,
	Jeff Davis


In response to

pgsql-hackers by date

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

pgsql-general by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group