Skip site navigation (1) Skip section navigation (2)

Re: Casts in 7.0 vs 6.5 (was Re: [SQL] 7.0beta bug (or feature)?)

From: Kyle Bateman <kyle(at)actarg(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-sql(at)postgreSQL(dot)org, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Casts in 7.0 vs 6.5 (was Re: [SQL] 7.0beta bug (or feature)?)
Date: 2000-03-08 16:22:17
Message-ID: 38C67E39.DA7EE8A5@actarg.com (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-sql
Tom Lane wrote:

>
> I am not sure whether this should be regarded as a bug or a feature.
> On the one hand you could argue that ambiguous casts are a bad thing,
> but on the other hand, if text(foo) works, why shouldn't foo::text work?
>
> One thing to realize while considering whether to change this is that if
> we generalize the behavior of casts, we may also affect the behavior of
> implicit casts, such as the one applied to convert supplied data in an
> INSERT or UPDATE to the target column type.  This could result in loss
> of error detection capability.  Currently, both 6.5 and 7.0 do this:
>
> regression=# create table foo(f1 text);
> CREATE
> regression=# insert into foo values('now'::date);
> ERROR:  Attribute 'f1' is of type 'text' but expression is of type 'date'
>         You will need to rewrite or cast the expression
>
> but if we allow datevalue::text to work, then (barring still more
> pushups in the code) the above will be accepted.  Should it be?
>
> Comments anyone?
>

What if you could to a "set AutoCasting=yes" just as you might set the
datestyle variable.  Then the DBA could decide whether type mismatches
should be quitely translated or reported?


Attachment: kyle.vcf
Description: text/x-vcard (291 bytes)

In response to

pgsql-hackers by date

Next:From: Karel Zak - ZakkrDate: 2000-03-08 16:26:14
Subject: regex (from TODO)
Previous:From: Tom LaneDate: 2000-03-08 16:15:56
Subject: Re: [HACKERS] DROP TABLE inside a transaction block

pgsql-sql by date

Next:From: Matthew HagertyDate: 2000-03-08 20:00:06
Subject: END or COMMIT?
Previous:From: Tom LaneDate: 2000-03-08 16:04:37
Subject: Re: FW: [SQL] Errors loading null dates in 7.0beta1

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group