Re: String comparison and the SQL standard - Mailing list pgsql-general

From Albe Laurenz
Subject Re: String comparison and the SQL standard
Date
Msg-id A737B7A37273E048B164557ADEF4A58B0579A7D4@ntex2010a.host.magwien.gv.at
Whole thread Raw
In response to String comparison and the SQL standard  (Albe Laurenz <laurenz.albe@wien.gv.at>)
List 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 by date:

Previous
From: Albe Laurenz
Date:
Subject: String comparison and the SQL standard
Next
From: Brian Sutherland
Date:
Subject: Re: plpython intermittent ImportErrors