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

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

On Wed, Jun 18, 2008 at 12:39 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Cyril SCETBON 2008-06-18 20:43:27 Re: Error when trying to drop a tablespace
Previous Message Scott Marlowe 2008-06-18 20:08:02 Re: Easiest way to copy table from one db to another?