Re: [GENERAL] migrating from mysql: need to convert empty string to null

2008-06-18 Thread Tom Lane
"Dave Lee" <[EMAIL PROTECTED]> writes: > I've read src/backend/utils/fmgr/README and it states that returning > NULL is just a matter of setting isnull to true in the > FunctionCallInfo struct, and provides a convenience macro, > PG_RETURN_NULL. But then, in InputFunctionCall, I presume you're > re

Re: [GENERAL] migrating from mysql: need to convert empty string to null

2008-06-18 Thread Dave Lee
On Wed, Jun 18, 2008 at 3:25 PM, Tom Lane <[EMAIL PROTECTED]> wrote: > 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 Inpu

Re: [GENERAL] migrating from mysql: need to convert empty string to null

2008-06-18 Thread Tom Lane
"Dave Lee" <[EMAIL PROTECTED]> 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 jus

Re: [GENERAL] migrating from mysql: need to convert empty string to null

2008-06-18 Thread Dave Lee
On Wed, Jun 18, 2008 at 12:39 PM, Tom Lane <[EMAIL PROTECTED]> 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 thi

Re: [GENERAL] migrating from mysql: need to convert empty string to null

2008-06-18 Thread Tom Lane
"Dave Lee" <[EMAIL PROTECTED]> 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 reall

[GENERAL] migrating from mysql: need to convert empty string to null

2008-06-18 Thread Dave Lee
Hi, We have an existing (PHP) code base that is being converted to use PostgreSQL from MySQL. In most places, our insert and update statements are formed using single quoted values, and when there is no value, the empty string is being passed in. PostgreSQL objects to empty strings for certain col