Re: When is an explicit cast necessary?

Поиск
Список
Период
Сортировка
От Alban Hertroys
Тема Re: When is an explicit cast necessary?
Дата
Msg-id 8A9CE1BF-F854-4AA0-9AA6-D232A0034D1E@solfertje.student.utwente.nl
обсуждение исходный текст
Ответ на Re: When is an explicit cast necessary?  (Alan Millington <admillington@yahoo.co.uk>)
Ответы Re: When is an explicit cast necessary?  (Alan Millington <admillington@yahoo.co.uk>)
Список pgsql-general
On 9 Apr 2010, at 16:57, Alan Millington wrote:

> However, every language that I have ever used will implicitly convert an integer 1 to a smallint (or short) 1 when
requiredto do so. How can such a cast be called "surprising behaviour", or produce "misleading results", to quote the
firstarticle? 

No, they probably don't cast integer values down to smallint. What they do is cast the smallint up to integer, as
that'sa safe cast. After all, numbers that fit in an int may not fit in a smallint (try "select 75000::smallint;" for
example)and you'd lose data casting it down, but it's fine the other way around. 

Since your function has smallint as one of its parameter types the database can't cast the smallint up to an int like
itwould normally do in such cases as the function doesn't accept integer values for that parameter. PG can't do much
butthrow an error. 

Alban Hertroys

--
Screwing up is an excellent way to attach something to the ceiling.


!DSPAM:737,4bc0584910411899921361!



В списке pgsql-general по дате отправления:

Предыдущее
От: Allan Kamau
Дата:
Сообщение: @> and <@ (contains and is contained by) operations on large arrays
Следующее
От: Alan Millington
Дата:
Сообщение: Re: When is an explicit cast necessary?