Re: mssql migration and boolean to integer problems

From: "robert lazarski" <robertlazarski(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Gregory Stark" <stark(at)enterprisedb(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: mssql migration and boolean to integer problems
Date: 2007-12-17 22:54:30
Message-ID: f87675ee0712171454r942767q3686714cbd90fead@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Dec 17, 2007 12:24 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> "robert lazarski" <robertlazarski(at)gmail(dot)com> writes:
> > Is there any way to get the above insert to work as is, via a function
> > or some other way? I tried the function of another poster but it seems
> > there is already a cast built in for 8.1.9 for integer to boolean, and
> > it didn't work for me on the above insert.
>
> You could mark the built-in cast as assignment-only (I wouldn't
> recommend setting it to implicit, as it's not clear what cases
> that might break).
>
> d1=# create table foo (f1 bool);
> CREATE TABLE
> d1=# insert into foo values(1);
> ERROR: column "f1" is of type boolean but expression is of type integer
> HINT: You will need to rewrite or cast the expression.
> d1=# update pg_cast set castcontext = 'a' where castsource = 'int'::regtype
> d1-# and casttarget = 'bool'::regtype;
> UPDATE 1
> d1=# insert into foo values(1);
> INSERT 0 1
>
> Unfortunately this is something you'd have to do over after any database
> reload, because pg_dump won't preserve changes to the definitions of
> built-in objects.
>
> regards, tom lane
>

Snoopy dance <http://www.google.com/search?q=snoopy+dance> :-) That
worked great!!!

Kind regards,
Robert

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2007-12-17 23:12:08 Re: spreadsheet interface
Previous Message Greg Smith 2007-12-17 22:54:17 Re: install problem