Re: Strict-typing benefits/costs

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Strict-typing benefits/costs
Дата
Msg-id 20844.1203032041@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Strict-typing benefits/costs  (Ken Johanson <pg-user@kensystem.com>)
Список pgsql-general
Ken Johanson <pg-user@kensystem.com> writes:
> For case 1, regarding type safety: we know use of LIKE (and SUBSTR)
> requires *implicit or explicit* conversion to a text type. Why require
> that explicitly?

Because it's way too easy to burn yourself with implicit conversions.
Cases comparable to the one mentioned (current_date < 2017-11-17
silently doing something very different than the user expected) have
been cropping up every month or two for *years* --- try trolling the
PG list archives for awhile for examples.  After you've wasted a day or
three chasing a problem like that, or pehaps had your app fail in the
field because of a problem like that, you'll realize that having to
write a few explicit casts is a small price to pay for not having such
booby-traps in the system.

As for the lack of a compatibility switch, we would probably have
provided one if we could do so reasonably; but a large part of the
change consisted of altering the initial contents of pg_cast and some
other system catalogs.  There isn't any good way to flip that on and
off.

            regards, tom lane

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

Предыдущее
От: Ken Johanson
Дата:
Сообщение: Strict-typing benefits/costs
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: SELECT CAST(123 AS char) -> 1