Re: When is an explicit cast necessary?
От | Alan Millington |
---|---|
Тема | Re: When is an explicit cast necessary? |
Дата | |
Msg-id | 477832.62631.qm@web25407.mail.ukl.yahoo.com обсуждение исходный текст |
Ответ на | Re: When is an explicit cast necessary? (Alban Hertroys <dalroi@solfertje.student.utwente.nl>) |
Ответы |
Re: When is an explicit cast necessary?
|
Список | pgsql-general |
In C, if I declare a short variable shortvar, I can write an assignment shortvar = 1. The literal value 1 is an int, but the compiler will implicitly convert it to a short. Similarly, if I write a function func() which takes a short argument, then provided I use function prototypes, I can write a call func(1). Again the compiler will implicitly convert the int 1 to a short. In the case of my PL/pgSQL function, the syntax that I have to use to call it select col1, col2, col3 from func(?, ?, ?) as (col1 int, col2 smallint, col3 char(1)) clearly indicates what I expect the return datatypes to be. There is no ambiguity. The only question is whether 1 can be converted to a smallint, and 'R' to char(1). Clearly the answer is Yes, as otherwise the explicit casts would fail. But it seems that with the change made in Postgres 8.3, I now have to write the type information twice. I do not regard that as an improvement! --- On Sat, 10/4/10, Alban Hertroys <dalroi@solfertje.student.utwente.nl> wrote:
|
В списке pgsql-general по дате отправления: