Re: String comparison and the SQL standard

Поиск
Список
Период
Сортировка
От Kevin Grittner
Тема Re: String comparison and the SQL standard
Дата
Msg-id 20130117212053.108990@gmx.com
обсуждение исходный текст
Ответ на String comparison and the SQL standard  (Albe Laurenz <laurenz.albe@wien.gv.at>)
Список pgsql-general
Tom Lane wrote:

> This probably has more to do with what these systems think the
> data type of an undecorated literal is, than with whether they do
> trailing-space-insensitive comparison all the time.

I suspect so. Keep in mind that PostgreSQL does not comply with the
standard in this regard, but this has been discussed before and it
is a concious decision to deviate.  See section section 5.3
<literal> syntax 17:

| The declared type of a <character string literal> is fixed-length
| character string.

... so according to the standard 'a' is CHAR(1) and 'a   ' is
CHAR(4), and they should compare as equal. To make literals for
user-defined types more convenient to write, PostgreSQL treats
those literals as type UNKOWN until forced to resolve them to a
type, and in the absence of any other clues uses text instead of
char(n). The reason for that is that the community finds the
semantics of char(n) strange and generally encourages use of text
or varchar(n) for character-based types.

I'm not sure that this is as clearly and prominently documented as
it should be.

-Kevin


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

Предыдущее
От: Kirk Wythers
Дата:
Сообщение: Re: speeding up a join query that utilizes a view
Следующее
От: Igor Neyman
Дата:
Сообщение: Re: speeding up a join query that utilizes a view