[PATCH] Documentation: remove confusing paragraph about backslash escaping

Started by Hannes Frederic Sowaalmost 14 years ago6 messages
1 attachment(s)

Hi!

As with recent changes to `standard_conforming_strings' the paragraph
about backslash escaping in the description of `LIKE' is only confusing.
Thus I attached a patch to remove it.

Greetings,

Hannes

--
Hannes Sowa <hsowa@bfk.de>
BFK edv-consulting GmbH http://www.bfk.de/
Kriegsstra�e 100 tel: +49-721-96201-1
D-76133 Karlsruhe fax: +49-721-96201-99

Attachments:

like-backslash-remove-paragrah.patchtext/x-patch; name=like-backslash-remove-paragrah.patchDownload
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index e8e637b..4b582f7 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -3383,18 +3383,6 @@ cast(-44 as bit(12))           <lineannotation>111111010100</lineannotation>
    </para>
 
    <para>
-    Note that the backslash already has a special meaning in string literals,
-    so to write a pattern constant that contains a backslash you must write two
-    backslashes in an SQL statement (assuming escape string syntax is used, see
-    <xref linkend="sql-syntax-strings">).  Thus, writing a pattern that
-    actually matches a literal backslash means writing four backslashes in the
-    statement.  You can avoid this by selecting a different escape character
-    with <literal>ESCAPE</literal>; then a backslash is not special to
-    <function>LIKE</function> anymore. (But backslash is still special to the
-    string literal parser, so you still need two of them to match a backslash.)
-   </para>
-
-   <para>
     It's also possible to select no escape character by writing
     <literal>ESCAPE ''</literal>.  This effectively disables the
     escape mechanism, which makes it impossible to turn off the
#2Robert Haas
robertmhaas@gmail.com
In reply to: Hannes Frederic Sowa (#1)
Re: [PATCH] Documentation: remove confusing paragraph about backslash escaping

On Mon, Feb 27, 2012 at 10:17 AM, Hannes Frederic Sowa <hsowa@bfk.de> wrote:

As with recent changes to `standard_conforming_strings' the paragraph about
backslash escaping in the description of `LIKE' is only confusing. Thus I
attached a patch to remove it.

I think I agree with removing this paragraph; it made sense when
standard_conforming_strings=off was the default, but that's not so
anymore. We could come up with some alternative text to insert here
but I think that might be unnecessarily long-winded.

Other opinions?

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Hannes Frederic Sowa (#1)
Re: [PATCH] Documentation: remove confusing paragraph about backslash escaping

Hannes Frederic Sowa <hsowa@bfk.de> writes:

As with recent changes to `standard_conforming_strings' the paragraph
about backslash escaping in the description of `LIKE' is only confusing.
Thus I attached a patch to remove it.

The para is still relevant if you don't have standard_conforming_strings
on. It could probably use work but I don't think simply removing it
is appropriate.

regards, tom lane

#4Florian Weimer
fweimer@bfk.de
In reply to: Tom Lane (#3)
Re: [PATCH] Documentation: remove confusing paragraph about backslash escaping

* Tom Lane:

Hannes Frederic Sowa <hsowa@bfk.de> writes:

As with recent changes to `standard_conforming_strings' the paragraph
about backslash escaping in the description of `LIKE' is only confusing.
Thus I attached a patch to remove it.

The para is still relevant if you don't have standard_conforming_strings
on.

And if you aren't using parametrized queries. The old text is a bit
misleading even with standard_conforming_strings set to off. It is
technically correct because it refers to the SQL statement parser which
is run on parameters, but this seems a pretty fine distinction.

--
Florian Weimer <fweimer@bfk.de>
BFK edv-consulting GmbH http://www.bfk.de/
Kriegsstraße 100 tel: +49-721-96201-1
D-76133 Karlsruhe fax: +49-721-96201-99

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Robert Haas (#2)
Re: [PATCH] Documentation: remove confusing paragraph about backslash escaping

Robert Haas <robertmhaas@gmail.com> writes:

On Mon, Feb 27, 2012 at 10:17 AM, Hannes Frederic Sowa <hsowa@bfk.de> wrote:

As with recent changes to `standard_conforming_strings' the paragraph about
backslash escaping in the description of `LIKE' is only confusing. Thus I
attached a patch to remove it.

I think I agree with removing this paragraph; it made sense when
standard_conforming_strings=off was the default, but that's not so
anymore. We could come up with some alternative text to insert here
but I think that might be unnecessarily long-winded.

On a closer look, I see three different places in the
functions-matching.html page that talk about doubling backslashes, of
which this one might be the least bogus, since it at least provides
a cross-reference to someplace where you would read about
standard_conforming_strings.

I suggest replacing the first and third cases with something along the
lines of

Note: if you have standard_conforming_strings turned off, any
backslashes you write in literal string constants will need to be
doubled. See Section 4.1.2.1 for more information.

The second case is just a parenthetical comment and perhaps could be
removed.

regards, tom lane

In reply to: Tom Lane (#5)
Re: [PATCH] Documentation: remove confusing paragraph about backslash escaping

On 02/28/2012 12:10 AM, Tom Lane wrote:

I suggest replacing the first and third cases with something along the
lines of

Note: if you have standard_conforming_strings turned off, any
backslashes you write in literal string constants will need to be
doubled. See Section 4.1.2.1 for more information.

The second case is just a parenthetical comment and perhaps could be
removed.

Definitely OK by me. Thanks for looking into this!

--
Hannes Sowa <hsowa@bfk.de>
BFK edv-consulting GmbH http://www.bfk.de/
Kriegsstra�e 100 tel: +49-721-96201-1
D-76133 Karlsruhe fax: +49-721-96201-99