Re: Document that char () ignores spaces only in non-patterncomparisons
Re: Document that char () ignores spaces only in non-patterncomparisons
От:
"Kevin Grittner" <Kevin.Grittner@wicourts.gov>
Дата:
Bruce Momjian 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. 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. -Kevin
Re: Document that char () ignores spaces only in non-patterncomparisons
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Kevin Grittner" writes: > Bruce Momjian 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. I didn't like it either. I suggest reverting that part of the patch. The added text later on is sufficient. regards, tom lane
Re: Document that char () ignores spaces only in non-patterncomparisons
От:
Bruce Momjian <bruce@momjian.us>
Дата:
Kevin Grittner wrote:
> Bruce Momjian 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 character,
and they will be removed when converting a character value
to one of the other string types. Note that trailing spaces
are</> semantically significant in
character varying and text values, and
--> when using pattern matching, e.g. LIKE</>,
regular expressions.
--
Bruce Momjian http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
Re: Document that char () ignores spaces only in non-patterncomparisons
От:
Bruce Momjian <bruce@momjian.us>
Дата:
Tom Lane wrote:
> "Kevin Grittner" writes:
> > Bruce Momjian 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.
>
> I didn't like it either. I suggest reverting that part of the patch.
> The added text later on is sufficient.
OK, since you liked that idea too, I have applied an updated patch,
attached.
--
Bruce Momjian http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml
index 22d4c4e..0bb6594 100644
*** a/doc/src/sgml/datatype.sgml
--- b/doc/src/sgml/datatype.sgml
*************** SELECT '52093.89'::money::numeric::float
*** 1014,1025 ****
with spaces to the specified width n</>, and are
stored and displayed that way. However, the padding spaces are
treated as semantically insignificant. Trailing spaces are
! disregarded when non-pattern comparing two values of type character,
and they will be removed when converting a character value
to one of the other string types. Note that trailing spaces
are</> semantically significant in
character varying and text values, and
! when using pattern matching comparisons, e.g. LIKE</>,
regular expressions.
--- 1014,1025 ----
with spaces to the specified width n</>, and are
stored and displayed that way. However, the padding spaces are
treated as semantically insignificant. Trailing spaces are
! disregarded when comparing two values of type character,
and they will be removed when converting a character value
to one of the other string types. Note that trailing spaces
are</> semantically significant in
character varying and text values, and
! when using pattern matching, e.g. LIKE</>,
regular expressions.