Re: When is an explicit cast necessary?

From: Alan Millington <admillington(at)yahoo(dot)co(dot)uk>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Martijn van Oosterhout <kleptog(at)svana(dot)org>, Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl>, Greg Smith <greg(at)2ndquadrant(dot)com>, Postgres general mailing list <pgsql-general(at)postgresql(dot)org>
Subject: Re: When is an explicit cast necessary?
Date: 2010-04-14 10:08:26
Message-ID: 772828.52212.qm@web25404.mail.ukl.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

If you think that smallints are more bother than they are worth, perhaps you should remove support for smallints completely. Then people would know where they stood. (Or you could make smallint a synonym for int.)
 
The other half of my problem was having to cast the literal 'R' to char(1) explicitly. I know that string literals can be used to represent all sorts of datatypes, but that is no reason to disallow interpreting them as strings.
 
Or would an implicit cast have worked if I had omitted the length specifier?

--- On Tue, 13/4/10, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: [GENERAL] When is an explicit cast necessary?
To: "Martijn van Oosterhout" <kleptog(at)svana(dot)org>
Cc: "Alan Millington" <admillington(at)yahoo(dot)co(dot)uk>, "Alban Hertroys" <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl>, "Greg Smith" <greg(at)2ndquadrant(dot)com>, "Postgres general mailing list" <pgsql-general(at)postgresql(dot)org>
Date: Tuesday, 13 April, 2010, 20:16

Martijn van Oosterhout <kleptog(at)svana(dot)org> writes:
> The question is: does the column really need to be smallint.

Yeah.  Usually, declaring a function's argument as int rather than
smallint is the easiest fix.  We have looked into this in the past,
and concluded that the negative aspects of allowing integer constants
to implicitly cast to smallint parameters would outweigh the
positives.  As an example, such simple expressions as "2 + 2" would
start to fail because it'd be unclear whether int or smallint addition
is meant.  (And the point isn't academic, since for example it would
affect the overflow threshold.)

            regards, tom lane

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Shoaib Mir 2010-04-14 10:14:43 Re: Server not Starting
Previous Message Herouth Maoz 2010-04-14 09:07:55 auto vacuum