Re: String comparison and the SQL standard

From: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: String comparison and the SQL standard
Date: 2013-01-17 09:49:19
Message-ID: A737B7A37273E048B164557ADEF4A58B0579A7D4@ntex2010a.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Brian Sutherland 2013-01-17 11:30:49 Re: plpython intermittent ImportErrors
Previous Message aasat 2013-01-17 09:36:09 Re: How to store clickmap points?