Re: Document that char () ignores spaces only in non-patterncomparisons

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>
Cc: pgsql-docs(at)postgresql(dot)org
Subject: Re: Document that char () ignores spaces only in non-patterncomparisons
Date: 2011-03-08 17:52:59
Message-ID: 201103081752.p28Hqxq18147@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

Kevin Grittner wrote:
> Bruce Momjian <bruce(at)momjian(dot)us> wrote:
>
> > A private email I received indicated that our documentation about
> > ignoring trailing spaces in CHAR() comparisons was slightly
> > inaccurate. I have update our docs to indicate it is only
> > non-pattern comparisons that ignore spaces with CHAR(). Applied
> > doc patch attached.
>
> This language:
>
> | disregarded when non-pattern comparing two values
>
> seems quite awkward.

Yes, it is. :-(

Oh, I wanted to show an example of the difference:

test=> SELECT 'abc'::char(4) = 'abc'::char(6);
?column?
----------
t
(1 row)

test=> SELECT 'abc'::char(4) LIKE 'abc'::char(6);
?column?
----------
f
(1 row)

> Isn't it a stretch to consider pattern-matching predicates to be
> compares, anyway? It seems like it would be better to distinguish
> between comparisons, where the trailing spaces are ignored, and
> other predicates such as pattern matching, where trailing spaces are
> not ignored.

Uh, how about I remove "pattern" from the first sentence, but keep the
second pattern mention and remove the word "comparison" there?

treated as semantically insignificant. Trailing spaces are
--> disregarded when comparing two values of type <type>character</type>,
and they will be removed when converting a <type>character</type> value
to one of the other string types. Note that trailing spaces
<emphasis>are</> semantically significant in
<type>character varying</type> and <type>text</type> values, and
--> when using pattern matching, e.g. <literal>LIKE</>,
regular expressions.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message Bruce Momjian 2011-03-08 17:54:33 Re: Document that char () ignores spaces only in non-patterncomparisons
Previous Message Tom Lane 2011-03-08 17:51:41 Re: Document that char () ignores spaces only in non-patterncomparisons