pg.ddx.io pgsql-docs@postgresql.org mailing list archive
help / color / mirror / Atom feedDocument that char() ignores spaces only in non-pattern comparisons
6+ messages / 3 participants
[nested] [flat]
* Document that char() ignores spaces only in non-pattern comparisons
@ 2011-03-08 16:41 Bruce Momjian <bruce@momjian.us>
0 siblings, 0 replies; 6+ messages in thread
From: Bruce Momjian @ 2011-03-08 16:41 UTC (permalink / raw)
To: pgsql-docs
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.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
Attachments:
/rtmp/bpchar.diff (text/x-diff, 1.5K) download
diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml
index b8f6e23..22d4c4e 100644
*** a/doc/src/sgml/datatype.sgml
--- b/doc/src/sgml/datatype.sgml
*************** SELECT '52093.89'::money::numeric::float
*** 1014,1024 ****
with spaces to the specified width <replaceable>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 <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.
</para>
<para>
--- 1014,1026 ----
with spaces to the specified width <replaceable>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 <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 comparisons, e.g. <literal>LIKE</>,
! regular expressions.
</para>
<para>
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Document that char () ignores spaces only in non-patterncomparisons
@ 2011-03-08 17:13 Kevin Grittner <Kevin.Grittner@wicourts.gov>
0 siblings, 2 replies; 6+ messages in thread
From: Kevin Grittner @ 2011-03-08 17:13 UTC (permalink / raw)
To: bruce@momjian.us; pgsql-docs
Bruce Momjian <bruce@momjian.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.
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
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Document that char () ignores spaces only in non-patterncomparisons
@ 2011-03-08 17:51 Tom Lane <tgl@sss.pgh.pa.us>
parent: Kevin Grittner <Kevin.Grittner@wicourts.gov>
1 sibling, 1 reply; 6+ messages in thread
From: Tom Lane @ 2011-03-08 17:51 UTC (permalink / raw)
To: Kevin Grittner <Kevin.Grittner@wicourts.gov>; +Cc: bruce@momjian.us; pgsql-docs
"Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
> Bruce Momjian <bruce@momjian.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.
I didn't like it either. I suggest reverting that part of the patch.
The added text later on is sufficient.
regards, tom lane
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Document that char () ignores spaces only in non-patterncomparisons
@ 2011-03-08 17:52 Bruce Momjian <bruce@momjian.us>
parent: Kevin Grittner <Kevin.Grittner@wicourts.gov>
1 sibling, 0 replies; 6+ messages in thread
From: Bruce Momjian @ 2011-03-08 17:52 UTC (permalink / raw)
To: Kevin Grittner <Kevin.Grittner@wicourts.gov>; +Cc: pgsql-docs
Kevin Grittner wrote:
> Bruce Momjian <bruce@momjian.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@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Document that char () ignores spaces only in non-patterncomparisons
@ 2011-03-08 17:54 Bruce Momjian <bruce@momjian.us>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 6+ messages in thread
From: Bruce Momjian @ 2011-03-08 17:54 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>; pgsql-docs
Tom Lane wrote:
> "Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
> > Bruce Momjian <bruce@momjian.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.
>
> 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 <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
Attachments:
/rtmp/bpchar2.diff (text/x-diff, 1.5K) download
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 <replaceable>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 <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 comparisons, e.g. <literal>LIKE</>,
regular expressions.
</para>
--- 1014,1025 ----
with spaces to the specified width <replaceable>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 <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.
</para>
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Document that char () ignores spaces only in non-patterncomparisons
@ 2011-03-08 17:57 Kevin Grittner <Kevin.Grittner@wicourts.gov>
parent: Bruce Momjian <bruce@momjian.us>
0 siblings, 0 replies; 6+ messages in thread
From: Kevin Grittner @ 2011-03-08 17:57 UTC (permalink / raw)
To: Bruce Momjian <bruce@momjian.us>; Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-docs
Bruce Momjian <bruce@momjian.us> wrote:
> I have applied an updated patch
FWIW, that looks good to me.
-Kevin
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2011-03-08 17:57 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-03-08 16:41 Document that char() ignores spaces only in non-pattern comparisons Bruce Momjian <bruce@momjian.us>
2011-03-08 17:13 Re: Document that char () ignores spaces only in non-patterncomparisons Kevin Grittner <Kevin.Grittner@wicourts.gov>
2011-03-08 17:51 ` Re: Document that char () ignores spaces only in non-patterncomparisons Tom Lane <tgl@sss.pgh.pa.us>
2011-03-08 17:54 ` Re: Document that char () ignores spaces only in non-patterncomparisons Bruce Momjian <bruce@momjian.us>
2011-03-08 17:57 ` Re: Document that char () ignores spaces only in non-patterncomparisons Kevin Grittner <Kevin.Grittner@wicourts.gov>
2011-03-08 17:52 ` Re: Document that char () ignores spaces only in non-patterncomparisons Bruce Momjian <bruce@momjian.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox