Re: Update existing system explicit cast to make it implicit

From: asia123321(at)op(dot)pl
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Update existing system explicit cast to make it implicit
Date: 2011-01-31 20:12:45
Message-ID: 15195694-9c9448ffa04fd53f2ff83446eeb47bb7@pkn6.m5r2.onet
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> napisał(a):
> asia123321(at)op(dot)pl writes:
> > I am trying to use bit(1) datatype with existing application that used int datatype before.
> > So I tried to create implicit cast that will allow me not to make code modifications and wanted to create implicit cast "int2bit", but it turned out that there is already system cast.
> > Unfortunately this cast is explicit and I need to make it implicit (it can be made implicit only for one schema).
>
> You will likely find that this is a really bad idea. Implicit
> casts between fundamentally different datatypes are *dangerous*.
> They tend to result in either surprising query behaviors or unexpected
> "operator is not unique" failures. Fixing the app would be a lot safer
> in the long run.
>
> > My question is that if there is any official way to overwrite this attribute
>
> No. If you're intent on breaking things, hacking the catalog is what to do.
>
> ???regards, tom lane
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general

> > > Thank you for your reply. I agree that this in not the right way so my question was also if there is any alternative way to do it, to make bit(1) behave similarly to integer so that I do not need to change hundreds of lines of code to insert e.g. B'1' instead of 1 like it is now in my application (btw it is quite heavy existing application which is migrating to PostgreSQL). It is quite natural to insert 0 or 1 into the bit values so why I cannot do it simply or there is other way I can achieve my goal? IMHO that this specific cast SHOULD be implicit and it surely would not result in anything more strange than simplyfing people's lifes ;-)

Thank you.
Joanna

Browse pgsql-general by date

  From Date Subject
Next Message vwu98034 2011-01-31 20:49:34 Some Problems - Shall I reinstall the DB?
Previous Message Kenneth Buckler 2011-01-31 20:12:20 Re: Autovacuum Issues?