Re: Casts

Поиск
Список
Период
Сортировка
От stark
Тема Re: Casts
Дата
Msg-id 87hd0m6tob.fsf@enterprisedb.com
обсуждение исходный текст
Ответ на Re: Casts  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Casts
Список pgsql-hackers
Tom Lane <tgl@sss.pgh.pa.us> writes:

Tom Lane <tgl@sss.pgh.pa.us> writes:

> stark <stark@enterprisedb.com> writes:
>> It seems odd to me that implicit casts are checked for when you call a
>> function but not when you're implicitly calling a function via a cast. As a
>> result there are a *lot* of redundant casts in our catalog, essentially n!
>> casts for a domain with n types in it. So for example there are 138 casts
>> between the various numeric data types including every possible pairing of
>> char, int2, int4, int8, float4, float8, and numeric.
>
> This is intentional.  If you explicitly cast type foo to type bar there
> should not be any question about what function will be invoked.  The
> cost is a few more rows in pg_cast ... so what?  

And hundreds of lines of copy-pasted code with potential bugs.

> As for "the parser ought to be able to find two-step cast pathways",
> no thanks.  The increase in search time and the decrease in
> predictability are both undesirable.
>
>> There has been some fear expressed in the past that too many implicit casts
>> create surprising side effects.
>
> Not "some fear" ... we have seen people badly burned, time and time
> again, by the ill-considered implicit casts that are already in there.
> IMHO we need fewer implicit casts, not more.

I agree we need fewer implicit casts. But I think you take that too far to
dogmatically imply that every implicit cast is suspect.

I think the ideal combination is having every type have precisely one implicit
cast "up" the type "tree" and assignment casts down the "tree". I don't see us
every needing anything more complex than a flat "tree" of a single base type
for each domain and everyone directly a child of that one type. So every
numeric data type would have an implicit cast to numeric, every text type
would have an implicit cast to text, etc.

The implicit casts from numeric to other types seem suspect to me. And there
are tons of cases where we have implicit casts in both directions such as bit
to varbit and varbit to bit. That makes no sense to me. That would be where
the surprising effects come from.

As long as every type has precisely one implicit cast up I think it would
become safe to rely on it for many of the operations and not have to define
redundant operations for every data type.

--  Gregory Stark EnterpriseDB          http://www.enterprisedb.com



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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: [COMMITTERS] pgsql: Move "#define inline __inline"
Следующее
От: Perez
Дата:
Сообщение: Re: An Idea for planner hints