Search Postgresql Archives

Re: migrating from mysql: need to convert empty string to null

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 18, 2008 at 3:25 PM, Tom Lane <tgl@xxxxxxxxxxxxx> wrote:
> There isn't any really nice way to do that :-(.  You could put a wrapper
> function around int4in but it would not help, because the internal API
> for datatype input functions doesn't support having them return NULL
> (see InputFunctionCall in the sources).

I've read src/backend/utils/fmgr/README and it states that returning
NULL is just a matter of setting isnull to true in the
FunctionCallInfo struct, and provides a convenience macro,
PG_RETURN_NULL. But then, in InputFunctionCall, I presume you're
referring to the logic that that only allows NULL to be returned if
the source input string is also NULL, otherwise raising an error. At a
basic level, you're suggesting I need to take out this NULL check in
InputFunctionCall to get the capability I'm looking for?

Any idea why the input functions were designed this way? For users
migrating from other RDBMs, if no one else, being able to return NULL
from an input function seems to be a valuable feature. I might use
this hacked functionality to return NULL for '0000-00-00' dates which
MySQL foolishly accepts. Maybe it's only useful to former MySQL users

thanks,
Dave


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux