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
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-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 Content-Type Size
kyle.vcf text/x-vcard 291 bytes

In response to

Browse pgsql-hackers by date

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

Browse pgsql-sql by date

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