Re: SELECT CAST(123 AS char) -> 1

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: SELECT CAST(123 AS char) -> 1
Дата
Msg-id 47B3367D.6050808@archonet.com
обсуждение исходный текст
Ответ на Re: SELECT CAST(123 AS char) -> 1  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Tom Lane wrote:
> Richard Huxton <dev@archonet.com> writes:
>> [ proof that cast(123 as char) actually produces varchar in mysql ]
>
> Egad.  I wonder if they think this is a feature?

Well, presumably its what all the other "convenient" (for Ken's
particular problem) databases do. The only alternative I could see would
be to use a varchar while casting values and then check lengths at the
end before re-casting to e.g. char(6).

Interestingly, it must have some lookup table mapping numeric types to
lengths of varchar because a standard int gives you varchar(11) whereas
an expression that pushes you beyond 32 bits gives varchar(32) and a
tinyint gives you varchar(4). Clearly some thought has gone into this.

--
   Richard Huxton
   Archonet Ltd

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: SELECT CAST(123 AS char) -> 1
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: Order of SUBSTR and UPPER in statement