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

From Dave Lee
Subject Re: migrating from mysql: need to convert empty string to null
Date
Msg-id cb13bf640806181310i25849b88xd4d967402848aa4b@mail.gmail.com
Whole thread Raw
In response to Re: migrating from mysql: need to convert empty string to null  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: migrating from mysql: need to convert empty string to null
List pgsql-general
On Wed, Jun 18, 2008 at 12:39 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> None.  There is no type coercion there --- what that is really
> specifying is invocation of the int data type's input function
> on the given string.

I thought that something like this may be this was the case.

> I don't think your approach is going to work; you would have to
> make your client programs emit things like
>
>        insert into mytab(integercol) values (''::varchar)
>
> in order to get a runtime varchar-to-int cast to be applied.
> At that point you might as well fix them properly.

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?

thanks for your explanation Tom,

Dave

pgsql-general by date:

Previous
From: "Scott Marlowe"
Date:
Subject: Re: Easiest way to copy table from one db to another?
Next
From: Steve Clark
Date:
Subject: renumber table