Re: String comparison and the SQL standard

Поиск
Список
Период
Сортировка
От Albe Laurenz
Тема Re: String comparison and the SQL standard
Дата
Msg-id A737B7A37273E048B164557ADEF4A58B0579A7D4@ntex2010a.host.magwien.gv.at
обсуждение исходный текст
Ответ на String comparison and the SQL standard  (Albe Laurenz <laurenz.albe@wien.gv.at>)
Список pgsql-general
I wrote:
> While researching a problem with a different database system,
> I came across the following in the SQL standard ISO/IEC 9075-2:2003,
> Section 8.2 (<comparison predicate>), General Rules:
>
> 3) [...]
>
> That would effectively mean that 'a'='a   ' is TRUE for
> all character string types.

Searching further, I found ISO/IEC 9075-2:2003,
Section 9.8 (Determination of identical values),
General Rules:

2) Case:
   a) If V1 and V2 are both null, then V1 is identical to V2.
   b) If V1 is null and V2 is not null, or if V1 is not null and
      V2 is null, then V1 is not identical to V2.
   c) If V1 and V2 are of comparable predefined types, then
      Case:
      i) If V1 and V2 are character strings, then let L be
         CHARACTER_LENGTH(V1).
         Case:
         1) If CHARACTER_LENGTH(V2) equals L, and if for all i,
            1 (one) ≤ i ≤ L, the i-th character of V1 corresponds
            to the same character position of ISO/IEC 10646 as
            the i-th character of V2, then V1 is identical to V2.
         2) Otherwise, V1 is not identical to V2.

That seems slightly contradictory to the above; I can only resolve
this to mean that 'a' and 'a   ' are not identical in SQL, but
the equality comparison operator should still treat them as equal.

Does anybody have deeper insight into this?

Yours,
Laurenz Albe


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

Предыдущее
От: Albe Laurenz
Дата:
Сообщение: String comparison and the SQL standard
Следующее
От: Brian Sutherland
Дата:
Сообщение: Re: plpython intermittent ImportErrors