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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Dave Lee" <davelee(dot)com(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: migrating from mysql: need to convert empty string to null
Date: 2008-06-19 01:30:17
Message-ID: 10655.1213839017@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Dave Lee" <davelee(dot)com(at)gmail(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Douglas McNaught 2008-06-19 02:36:28 Re: HA best pratices with postgreSQL
Previous Message Craig Ringer 2008-06-19 00:56:20 Re: Understanding fsync