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-18 21:25:37
Message-ID: 7706.1213824337@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 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Davis 2008-06-18 21:36:42 Re: Database design: Temporal databases
Previous Message Scott Marlowe 2008-06-18 21:24:01 Re: renumber table