Re: TODO: Fix CREATE CAST on DOMAINs

Поиск
Список
Период
Сортировка
От Mark Dilger
Тема Re: TODO: Fix CREATE CAST on DOMAINs
Дата
Msg-id 451179DF.1010608@markdilger.com
обсуждение исходный текст
Ответ на Re: TODO: Fix CREATE CAST on DOMAINs  (Mark Dilger <pgsql@markdilger.com>)
Ответы Re: TODO: Fix CREATE CAST on DOMAINs  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: TODO: Fix CREATE CAST on DOMAINs  (Martijn van Oosterhout <kleptog@svana.org>)
Список pgsql-hackers
Mark Dilger wrote:
> Casts from int2 -> int4, int2 -> int8, and int4 -> int8 would all be 
> SAFE, I think, because they are not lossy.  But perhaps I have not 
> thought enough about this and these should be IMPLICIT rather than SAFE.

I have thought about this some more.  I think these are indeed SAFE.  The 
distinction between SAFE and IMPLICIT should not, I think, be whether the 
storage type is identical, but rather whether there is any possible loss of 
precision, range, accuracy, etc., or whether there is any change in the 
fundamental interpretation of the data when cast from the source to destination 
type.

The built-in cast from int2 -> int4, which is currently IMPLICIT, cannot lose 
any information, nor can it cause the data to be interpreted differently. 
Therefore it is SAFE.

The built-in cast from int8 -> float8 is currently marked as IMPLICIT, but since  a large integer value which is cast
inthis fashion might be somewhat altered, 
 
it is not SAFE.  It is also interpreted differently, since floating point 
numbers are typically interpreted as approximations, whereas integers are 
interpreted as exact.  (Hence the tendency to compare integers for equality, but 
not floats.)

Can anyone think of examples where chaining together SAFE casts would cause 
problems, using the guidelines for what is SAFE outlined above?

mark


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

Предыдущее
От: Gregory Stark
Дата:
Сообщение: Re: Release Notes: Major Changes in 8.2
Следующее
От: Tom Lane
Дата:
Сообщение: Re: TODO: Fix CREATE CAST on DOMAINs