Re: Smallint needs explicit cast in psql?

Поиск
Список
Период
Сортировка
От Matt Musgrove
Тема Re: Smallint needs explicit cast in psql?
Дата
Msg-id C0FE28B9352B6F4F8CE371643EC3B251210877DE@EFJDFWMB01.EFJDFW.local
обсуждение исходный текст
Ответ на Re: Smallint needs explicit cast in psql?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
Tom Lane <tgl@sss.pgh.pa.us> writes:
> Right, because assigning to a table column is an "assignment" cast ---
> which has more liberal rules, because either you can coerce the value
> to the table column's type or you're going to fail anyway.  So the
> system will take the integer literal and try to downcast to smallint,
> and if that doesn't work then the query was doomed anyhow.

This one sank in last night when I re-read the docs for CREATE CAST.

> Coercion of a value to match a function argument is a different matter;
> the system will not choose a coercion that is "surprising" in any way
> or has the potential to fail due to issues such as range limitations.
> The reason for the difference in behavior is probably not very obvious
> when you have only one possible function to match, but we need this
> restriction in order for things to behave sanely with overloaded
> functions (or operators).  The text in chapter 10 expands on that a
> bit.

This is exactly what was confusing us; we aren't using function overloading so at the time it seemed like it should
justwork. I think I finally understand it again re-reading chapter 10 again. 

Thanks,
Matt





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

Предыдущее
От: Rob Richardson
Дата:
Сообщение: Re: How do I convert four table columns into a box?
Следующее
От: Ioannis Anagnostopoulos
Дата:
Сообщение: Re: Index slow down insertions...