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

Поиск
Список
Период
Сортировка
От Gregory Stark
Тема Re: SELECT CAST(123 AS char) -> 1
Дата
Msg-id 877ihapik6.fsf@oxford.xeocode.com
обсуждение исходный текст
Ответ на Re: SELECT CAST(123 AS char) -> 1  (Ken Johanson <pg-user@kensystem.com>)
Ответы Re: SELECT CAST(123 AS char) -> 1
Список pgsql-general
"Ken Johanson" <pg-user@kensystem.com> writes:

> Tom Lane wrote:
>
>> SQL92 section 6.1 <data type> quoth
>>
>>          <character string type> ::=
>>                 CHARACTER [ <left paren> <length> <right paren> ]
>>               | CHAR [ <left paren> <length> <right paren> ]
>>
>>          ...
>>
>>          4) If <length> is omitted, then a <length> of 1 is implicit.
>>
>> Therefore, writing just "char" is defined as equivalent to "char(1)".
>
> However when length is not defined I think it will generally be safe(r) to
> auto-size. In the grand scheme auto-size creates much more sensible output than
> a 1-char wide one (even if right-padded to max char-length of the type).

Sure, but you're a prime candidate for understanding the value of following
the spec if you're trying to write software that works with multiple
databases.

It's a bit crazy to be using CHAR and then complaining about padding... That's
what CHAR is for. If the other database doesn't support varchar it's so far
from the SQL spec that writing something portable between it and something
else is probably hopeless.


--
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com
  Ask me about EnterpriseDB's On-Demand Production Tuning

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

Предыдущее
От: "Oliver Weichhold"
Дата:
Сообщение: TSearch2 Migration Guide from 8.2 to 8.3
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: TSearch2 Migration Guide from 8.2 to 8.3