Discussion:
Would you help to review our modifications
rohtodeveloper
2014-10-20 14:34:25 UTC
Permalink
Dear All,
L've got a question for you.
If the value of the integer type is converted to a value of type Boolean£¬PostgreSQL will display just like"The rule has already exist";
1. CREATE CAST (integer AS bool) WITH INOUT AS IMPLICIT;

ERROR: cast from type integer to type boolean already exists
If I want to drop the rule,will be told like"From integer to boolean type rules may not be dropped";
2. DROP CAST (integer AS bool) ;
ERROR: cannot drop cast from integer to boolean because it is required by the database system
Since the rule has already exist,Why execute the following methods will be in error?
3. insert into testbool(p1,p2)values(20,0::integer);
ERROR: column "p2" is of type boolean but expression is of type integer
So how to deal with this kind of situation if I want a implicit conversion?
Best Regards,
rohtodeveloper
David G Johnston
2014-10-20 16:02:32 UTC
Permalink
Post by rohtodeveloper
So how to deal with this kind of situation if I want a implicit conversion?
As of the out-of-support 8.3 release many of the implicit casts previously
defined have been changed to explicit casts. It is a catalog change -
obviously, since you can still define implicit casts - so if you absolutely
must have the pre-existing cast be implicit you can modify the catalog
directly.

You may wish to describe why you think this is the solution you need - with
implicit casting there are generally more downsides that upsides.

Dave





--
View this message in context: http://postgresql.1045698.n5.nabble.com/Would-you-help-to-review-our-modifications-tp5823666p5823679.html
Sent from the PostgreSQL - hackers mailing list archive at Nabble.com.
--
Sent via pgsql-hackers mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Merlin Moncure
2014-10-21 13:16:30 UTC
Permalink
On Mon, Oct 20, 2014 at 11:02 AM, David G Johnston
Post by David G Johnston
Post by rohtodeveloper
So how to deal with this kind of situation if I want a implicit conversion?
As of the out-of-support 8.3 release many of the implicit casts previously
defined have been changed to explicit casts. It is a catalog change -
obviously, since you can still define implicit casts - so if you absolutely
must have the pre-existing cast be implicit you can modify the catalog
directly.
You may wish to describe why you think this is the solution you need - with
implicit casting there are generally more downsides that upsides.
I feel your pain. My company just last year completed a nine month
effort to validate a sprawling code base for post 8.3 casts. We were
orphaned on 8.1 and were very nearly forced to switch to another
database.

merlin
--
Sent via pgsql-hackers mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Loading...