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 18:39:32
Message-ID: 1302.1213814372@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:
> and I notice that there isn't any rows specified for converting
> varchar or text to int. Which raises the question, if I run:

> SELECT '123'::int;

> What conversion is actually happening here?

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 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.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sam Mason 2008-06-18 18:49:20 Re: Understanding fsync (was: Need Help Recovering from Botched Upgrade Attempt)
Previous Message Greg Smith 2008-06-18 18:17:00 Re: Understanding fsync (was: Need Help Recovering from Botched Upgrade Attempt)