Re: migrating from mysql: need to convert empty string to null - Mailing list pgsql-general

From Tom Lane
Subject Re: migrating from mysql: need to convert empty string to null
Date
Msg-id 10655.1213839017@sss.pgh.pa.us
Whole thread Raw
In response to Re: migrating from mysql: need to convert empty string to null  ("Dave Lee" <davelee.com@gmail.com>)
List pgsql-general
"Dave Lee" <davelee.com@gmail.com> writes:
> 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?

No, I'm stating it as a fact that that won't work.  You'd have to
change InputFunctionCall's API so that it could pass back a null to
its callers.

> Any idea why the input functions were designed this way?

Per above, and the fact that the behavior you're proposing is a
complete violation of the SQL spec (yeah, I know Oracle does it too).

            regards, tom lane

pgsql-general by date:

Previous
From: Craig Ringer
Date:
Subject: Re: Understanding fsync
Next
From: Bruce Momjian
Date:
Subject: Re: Forcibly vacating locks