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 7706.1213824337@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>)
Responses 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 see. Other than directly modifying int4in (is this the one?), is
> there a way to plug-in our modified empty string handling logic? I'm
> picturing a scenario where we write write a wrapper function that
> tests for empty strings and returns NULL, else just calls into int4in,
> and then dynamically load this function, and finally update the
> corresponding rows in pg_proc? Is this even possible?

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).  If you don't want to fix your
clients then you'll really have little choice but to hack the Postgres
source code.  The good news is there are probably not very places you'd
have to change, depending on exactly what contexts you need this to
happen in.

            regards, tom lane

pgsql-general by date:

Previous
From: "Scott Marlowe"
Date:
Subject: Re: renumber table
Next
From: Jeff Davis
Date:
Subject: Re: Database design: Temporal databases