]> granicus.if.org Git - postgresql/commitdiff
Update documentation for backslashes to mention escape string syntax
authorBruce Momjian <bruce@momjian.us>
Tue, 30 Jan 2007 22:29:40 +0000 (22:29 +0000)
committerBruce Momjian <bruce@momjian.us>
Tue, 30 Jan 2007 22:29:40 +0000 (22:29 +0000)
more, and standard_conforming_strings less, because in the future non-E
strings will not treat backslashes specially.

Also use E'' strings where backslashes are used in examples. (The
existing examples would have drawn warnings.)

Backpatch to 8.2.X.

doc/src/sgml/array.sgml
doc/src/sgml/datatype.sgml
doc/src/sgml/func.sgml
doc/src/sgml/libpq.sgml
doc/src/sgml/plperl.sgml
doc/src/sgml/plpgsql.sgml
doc/src/sgml/pltcl.sgml
doc/src/sgml/rowtypes.sgml
doc/src/sgml/xfunc.sgml

index 3ed8ce9c04363f3fbea6e077bcbf815ca374f074..3908181c923a32ed8e1068142fb3693d64a20eea 100644 (file)
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/array.sgml,v 1.52 2006/09/29 21:22:21 tgl Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/array.sgml,v 1.52.2.1 2007/01/30 22:29:40 momjian Exp $ -->
 
 <sect1 id="arrays">
  <title>Arrays</title>
@@ -597,17 +597,17 @@ SELECT f1[1][-2][3] AS e1, f1[1][-1][5] AS e2
   </para>
 
   <para>
-   As shown previously, when writing an array value you may write double
+   As shown previously, when writing an array value you can write double
    quotes around any individual array element. You <emphasis>must</> do so
    if the element value would otherwise confuse the array-value parser.
    For example, elements containing curly braces, commas (or whatever the
    delimiter character is), double quotes, backslashes, or leading or trailing
    whitespace must be double-quoted.  Empty strings and strings matching the
    word <literal>NULL</> must be quoted, too.  To put a double quote or
-   backslash in a
-   quoted array element value, precede it with a backslash. Alternatively, you
-   can use backslash-escaping to protect all data characters that would
-   otherwise be taken as array syntax.
+   backslash in a quoted array element value, use escape string syntax
+   and precede it with a backslash. Alternatively, you can use
+   backslash-escaping to protect all data characters that would otherwise
+   be taken as array syntax.
   </para>
 
   <para>
@@ -625,16 +625,16 @@ SELECT f1[1][-2][3] AS e1, f1[1][-1][5] AS e2
    backslashes you need.  For example, to insert a <type>text</> array
    value containing a backslash and a double quote, you'd need to write
 <programlisting>
-INSERT ... VALUES ('{"\\\\","\\""}');
+INSERT ... VALUES (E'{"\\\\","\\""}');
 </programlisting>
-   The string-literal processor removes one level of backslashes, so that
+   The escape string processor removes one level of backslashes, so that
    what arrives at the array-value parser looks like <literal>{"\\","\""}</>.
    In turn, the strings fed to the <type>text</> data type's input routine
    become <literal>\</> and <literal>"</> respectively.  (If we were working
    with a data type whose input routine also treated backslashes specially,
    <type>bytea</> for example, we might need as many as eight backslashes
    in the command to get one backslash into the stored array element.)
-   Dollar quoting (see <xref linkend="sql-syntax-dollar-quoting">) may be
+   Dollar quoting (see <xref linkend="sql-syntax-dollar-quoting">) can be
    used to avoid the need to double backslashes.
   </para>
  </note>
index 4bc950acf0bdf70ea2fb0ba0ebc7d3f6d18c4b2a..deeba7bc68ce3667f08cecf0e9da8f6f1363c484 100644 (file)
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.181 2006/11/23 04:27:33 momjian Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.181.2.1 2007/01/30 22:29:40 momjian Exp $ -->
 
  <chapter id="datatype">
   <title id="datatype-title">Data Types</title>
@@ -1103,11 +1103,9 @@ SELECT b, char_length(b) FROM test2;
     of a string literal in an <acronym>SQL</acronym> statement. In
     general, to escape an octet, it is converted into the three-digit
     octal number equivalent of its decimal octet value, and preceded
-    by two backslashes (or one backslash if
-    <varname>standard_conforming_strings</> is <literal>off</>).
-    <xref linkend="datatype-binary-sqlesc"> shows the characters
-    that must be escaped, and gives the alternate escape sequences
-    where applicable.
+    by two backslashes.  <xref linkend="datatype-binary-sqlesc">
+    shows the characters that must be escaped, and gives the alternate
+    escape sequences where applicable.
    </para>
 
    <table id="datatype-binary-sqlesc">
@@ -1127,32 +1125,32 @@ SELECT b, char_length(b) FROM test2;
       <row>
        <entry>0</entry>
        <entry>zero octet</entry>
-       <entry><literal>'\\000'</literal></entry>
-       <entry><literal>SELECT '\\000'::bytea;</literal></entry>
+       <entry><literal>E'\\000'</literal></entry>
+       <entry><literal>SELECT E'\\000'::bytea;</literal></entry>
        <entry><literal>\000</literal></entry>
       </row>
 
       <row>
        <entry>39</entry>
        <entry>single quote</entry>
-       <entry><literal>'\''</literal> or <literal>'\\047'</literal></entry>
-       <entry><literal>SELECT '\''::bytea;</literal></entry>
+       <entry><literal>''''</literal> or <literal>E'\\047'</literal></entry>
+       <entry><literal>SELECT E'\''::bytea;</literal></entry>
        <entry><literal>'</literal></entry>
       </row>
 
       <row>
        <entry>92</entry>
        <entry>backslash</entry>
-       <entry><literal>'\\\\'</literal> or <literal>'\\134'</literal></entry>
-       <entry><literal>SELECT '\\\\'::bytea;</literal></entry>
+       <entry><literal>E'\\\\'</literal> or <literal>E'\\134'</literal></entry>
+       <entry><literal>SELECT E'\\\\'::bytea;</literal></entry>
        <entry><literal>\\</literal></entry>
       </row>
 
       <row>
        <entry>0 to 31 and 127 to 255</entry>
        <entry><quote>non-printable</quote> octets</entry>
-       <entry><literal>'\\<replaceable>xxx'</></literal> (octal value)</entry>
-       <entry><literal>SELECT '\\001'::bytea;</literal></entry>
+       <entry><literal>E'\\<replaceable>xxx'</></literal> (octal value)</entry>
+       <entry><literal>SELECT E'\\001'::bytea;</literal></entry>
        <entry><literal>\001</literal></entry>
       </row>
 
@@ -1175,18 +1173,18 @@ SELECT b, char_length(b) FROM test2;
     string written as a string literal must pass through two parse
     phases in the <productname>PostgreSQL</productname> server.
     The first backslash of each pair is interpreted as an escape
-    character by the string-literal parser (assuming
-    <varname>standard_conforming_strings</> is <literal>off</>)
-    and is therefore consumed, leaving the second backslash of the
-    pair.  The remaining backslash is then recognized by the
+    character by the string-literal parser (assuming escape string
+    syntax is used) and is therefore consumed, leaving the second backslash of the
+    pair.  (Dollar-quoted strings can be used to avoid this level
+    of escaping.)  The remaining backslash is then recognized by the
     <type>bytea</type> input function as starting either a three
     digit octal value or escaping another backslash.  For example,
-    a string literal passed to the server as <literal>'\\001'</literal>
+    a string literal passed to the server as <literal>E'\\001'</literal>
     becomes <literal>\001</literal> after passing through the
-    string-literal parser. The <literal>\001</literal> is then sent
+    escape string parser. The <literal>\001</literal> is then sent
     to the <type>bytea</type> input function, where it is converted
     to a single octet with a decimal value of 1.  Note that the
-    apostrophe character is not treated specially by <type>bytea</type>,
+    single-quote character is not treated specially by <type>bytea</type>,
     so it follows the normal rules for string literals.  (See also
     <xref linkend="sql-syntax-strings">.)
    </para>
@@ -1220,7 +1218,7 @@ SELECT b, char_length(b) FROM test2;
        <entry>92</entry>
        <entry>backslash</entry>
        <entry><literal>\\</literal></entry>
-       <entry><literal>SELECT '\\134'::bytea;</literal></entry>
+       <entry><literal>SELECT E'\\134'::bytea;</literal></entry>
        <entry><literal>\\</literal></entry>
       </row>
 
@@ -1228,7 +1226,7 @@ SELECT b, char_length(b) FROM test2;
        <entry>0 to 31 and 127 to 255</entry>
        <entry><quote>non-printable</quote> octets</entry>
        <entry><literal>\<replaceable>xxx</></literal> (octal value)</entry>
-       <entry><literal>SELECT '\\001'::bytea;</literal></entry>
+       <entry><literal>SELECT E'\\001'::bytea;</literal></entry>
        <entry><literal>\001</literal></entry>
       </row>
 
@@ -1236,7 +1234,7 @@ SELECT b, char_length(b) FROM test2;
        <entry>32 to 126</entry>
        <entry><quote>printable</quote> octets</entry>
        <entry>client character set representation</entry>
-       <entry><literal>SELECT '\\176'::bytea;</literal></entry>
+       <entry><literal>SELECT E'\\176'::bytea;</literal></entry>
        <entry><literal>~</literal></entry>
       </row>
 
index 8c3ca324a4c3fdaeb35ed9badad4a84693fea260..b00b139002c79e9b508e7a863d47a90066d0e9d2 100644 (file)
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.347.2.2 2007/01/30 02:32:04 momjian Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.347.2.3 2007/01/30 22:29:40 momjian Exp $ -->
 
  <chapter id="functions">
   <title>Functions and Operators</title>
         Encode binary data to <acronym>ASCII</acronym>-only representation.  Supported
         types are: <literal>base64</>, <literal>hex</>, <literal>escape</>.
        </entry>
-       <entry><literal>encode( '123\\000\\001', 'base64')</literal></entry>
+       <entry><literal>encode( E'123\\000\\001', 'base64')</literal></entry>
        <entry><literal>MTIzAAE=</literal></entry>
       </row>       
 
        <entry>
         Return the given string suitably quoted to be used as a string literal
         in an <acronym>SQL</acronym> statement string.
-        Embedded quotes and backslashes are properly doubled.
+        Embedded single-quotes and backslashes are properly doubled.
        </entry>
        <entry><literal>quote_literal( 'O\'Reilly')</literal></entry>
        <entry><literal>'O''Reilly'</literal></entry>
          <secondary>concatenation</secondary>
         </indexterm>
        </entry>
-       <entry><literal>'\\\\Post'::bytea || '\\047gres\\000'::bytea</literal></entry>
+       <entry><literal>E'\\\\Post'::bytea || E'\\047gres\\000'::bytea</literal></entry>
        <entry><literal>\\Post'gres\000</literal></entry>
       </row>
 
          <primary>get_bit</primary>
         </indexterm>
        </entry>
-       <entry><literal>get_bit('Th\\000omas'::bytea, 45)</literal></entry>
+       <entry><literal>get_bit(E'Th\\000omas'::bytea, 45)</literal></entry>
        <entry><literal>1</literal></entry>
       </row>
 
          <primary>get_byte</primary>
         </indexterm>
        </entry>
-       <entry><literal>get_byte('Th\\000omas'::bytea, 4)</literal></entry>
+       <entry><literal>get_byte(E'Th\\000omas'::bytea, 4)</literal></entry>
        <entry><literal>109</literal></entry>
       </row>
 
        <entry><literal><function>octet_length</function>(<parameter>string</parameter>)</literal></entry>
        <entry><type>int</type></entry>
        <entry>Number of bytes in binary string</entry>
-       <entry><literal>octet_length( 'jo\\000se'::bytea)</literal></entry>
+       <entry><literal>octet_length( E'jo\\000se'::bytea)</literal></entry>
        <entry><literal>5</literal></entry>
       </row>
 
        <entry><literal><function>position</function>(<parameter>substring</parameter> in <parameter>string</parameter>)</literal></entry>
        <entry><type>int</type></entry>
        <entry>Location of specified substring</entry>
-      <entry><literal>position('\\000om'::bytea in 'Th\\000omas'::bytea)</literal></entry>
+      <entry><literal>position(E'\\000om'::bytea in E'Th\\000omas'::bytea)</literal></entry>
        <entry><literal>3</literal></entry>
       </row>
 
          <primary>set_bit</primary>
         </indexterm>
        </entry>
-       <entry><literal>set_bit('Th\\000omas'::bytea, 45, 0)</literal></entry>
+       <entry><literal>set_bit(E'Th\\000omas'::bytea, 45, 0)</literal></entry>
        <entry><literal>Th\000omAs</literal></entry>
       </row>
 
          <primary>set_byte</primary>
         </indexterm>
        </entry>
-       <entry><literal>set_byte('Th\\000omas'::bytea, 4, 64)</literal></entry>
+       <entry><literal>set_byte(E'Th\\000omas'::bytea, 4, 64)</literal></entry>
        <entry><literal>Th\000o@as</literal></entry>
       </row>
 
          <primary>substring</primary>
         </indexterm>
        </entry>
-       <entry><literal>substring('Th\\000omas'::bytea from 2 for 3)</literal></entry>
+       <entry><literal>substring(E'Th\\000omas'::bytea from 2 for 3)</literal></entry>
        <entry><literal>h\000o</literal></entry>
       </row>
 
         <parameter>bytes</parameter> from the start
         and end of <parameter>string</parameter>
        </entry>
-       <entry><literal>trim('\\000'::bytea from '\\000Tom\\000'::bytea)</literal></entry>
+       <entry><literal>trim(E'\\000'::bytea from E'\\000Tom\\000'::bytea)</literal></entry>
        <entry><literal>Tom</literal></entry>
       </row>
      </tbody>
         in <parameter>bytes</parameter> from the start and end of
         <parameter>string</parameter>
       </entry>
-      <entry><literal>btrim('\\000trim\\000'::bytea, '\\000'::bytea)</literal></entry>
+      <entry><literal>btrim(E'\\000trim\\000'::bytea, E'\\000'::bytea)</literal></entry>
       <entry><literal>trim</literal></entry>
      </row>
 
        Decode binary string from <parameter>string</parameter> previously 
        encoded with <function>encode</>.  Parameter type is same as in <function>encode</>.
       </entry>
-      <entry><literal>decode('123\\000456', 'escape')</literal></entry>
+      <entry><literal>decode(E'123\\000456', 'escape')</literal></entry>
       <entry><literal>123\000456</literal></entry>
      </row>
 
        Encode binary string to <acronym>ASCII</acronym>-only representation.  Supported
        types are: <literal>base64</>, <literal>hex</>, <literal>escape</>.
       </entry>
-      <entry><literal>encode('123\\000456'::bytea, 'escape')</literal></entry>
+      <entry><literal>encode(E'123\\000456'::bytea, 'escape')</literal></entry>
       <entry><literal>123\000456</literal></entry>
      </row>
 
         <see>binary strings, length</see>
        </indexterm>
       </entry>
-      <entry><literal>length('jo\\000se'::bytea)</literal></entry>
+      <entry><literal>length(E'jo\\000se'::bytea)</literal></entry>
       <entry><literal>5</literal></entry>
      </row>
 
        Calculates the MD5 hash of <parameter>string</parameter>,
        returning the result in hexadecimal
       </entry>
-      <entry><literal>md5('Th\\000omas'::bytea)</literal></entry>
+      <entry><literal>md5(E'Th\\000omas'::bytea)</literal></entry>
       <entry><literal>8ab2d3c9689aaf18 b4958c334c82d8b1</literal></entry>
      </row>
     </tbody>
@@ -2802,7 +2802,8 @@ cast(-44 as bit(12))           <lineannotation>111111010100</lineannotation>
    <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.  Thus, writing a pattern
+    you must write two backslashes in an SQL statement (assuming escape
+    string syntax is used).  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
@@ -3096,7 +3097,7 @@ substring('foobar' from 'o(.)b')   <lineannotation>o</lineannotation>
      substring matching the entire pattern should be inserted.  Write
      <literal>\\</> if you need to put a literal backslash in the replacement
      text.  (As always, remember to double backslashes written in literal
-     constant strings.)
+     constant strings, assuming escape string syntax is used.)
      The <replaceable>flags</> parameter is an optional text
      string containing zero or more single-letter flags that change the
      function's behavior.  Flag <literal>i</> specifies case-insensitive
@@ -3111,7 +3112,7 @@ regexp_replace('foobarbaz', 'b..', 'X')
                                    <lineannotation>fooXbaz</lineannotation>
 regexp_replace('foobarbaz', 'b..', 'X', 'g')
                                    <lineannotation>fooXX</lineannotation>
-regexp_replace('foobarbaz', 'b(..)', 'X\\1Y', 'g')
+regexp_replace('foobarbaz', 'b(..)', E'X\\1Y', 'g')
                                    <lineannotation>fooXarYXazY</lineannotation>
 </programlisting>
    </para>
@@ -3273,7 +3274,8 @@ regexp_replace('foobarbaz', 'b(..)', 'X\\1Y', 'g')
      Remember that the backslash (<literal>\</literal>) already has a special
      meaning in <productname>PostgreSQL</> string literals.
      To write a pattern constant that contains a backslash,
-     you must write two backslashes in the statement.
+     you must write two backslashes in the statement, assuming escape
+     string syntax is used.
     </para>
    </note>
 
@@ -3584,7 +3586,7 @@ regexp_replace('foobarbaz', 'b(..)', 'X\\1Y', 'g')
      Keep in mind that an escape's leading <literal>\</> will need to be
      doubled when entering the pattern as an SQL string constant.  For example:
 <programlisting>
-'123' ~ '^\\d{3}' <lineannotation>true</lineannotation>
+'123' ~ E'^\\d{3}' <lineannotation>true</lineannotation>
 </programlisting>
     </para>
    </note>
@@ -4746,10 +4748,10 @@ SELECT SUBSTRING('XY1234Z', 'Y*?([0-9]{1,3})');
      <listitem>
       <para>
        If you want to have a double quote in the output you must
-       precede it with a backslash, for example <literal>'\\"YYYY
+       precede it with a backslash, for example <literal>E'\\"YYYY
        Month\\"'</literal>. <!-- "" font-lock sanity :-) -->
        (Two backslashes are necessary because the backslash already
-       has a special meaning in a string constant.)
+       has a special meaning when using the escape string syntax.)
       </para>
      </listitem>
 
index 40d0bcb1fbdcd67a36ef3397bf0fbc1fcf213d5a..b9726aa6a5a4120268adfa51afa7c4b7f443f8ea 100644 (file)
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.220 2006/11/10 22:15:26 tgl Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.220.2.1 2007/01/30 22:29:40 momjian Exp $ -->
 
  <chapter id="libpq">
   <title><application>libpq</application> - C Library</title>
@@ -910,7 +910,7 @@ in a numeric form that is much easier to compare against.
 
 <para>
 If no value for <literal>standard_conforming_strings</> is reported,
-applications may assume it is <literal>false</>, that is, backslashes
+applications may assume it is <literal>off</>, that is, backslashes
 are treated as escapes in string literals.  Also, the presence of this
 parameter may be taken as an indication that the escape string syntax
 (<literal>E'...'</>) is accepted.
@@ -2488,7 +2488,7 @@ unsigned char *PQescapeByteaConn(PGconn *conn,
    of a <type>bytea</type> literal in an <acronym>SQL</acronym>
    statement. In general, to escape a byte, it is converted into the
    three digit octal number equal to the octet value, and preceded by
-   one or two backslashes. The single quote (<literal>'</>) and backslash
+   usually two backslashes. The single quote (<literal>'</>) and backslash
    (<literal>\</>) characters have special alternative escape
    sequences. See <xref linkend="datatype-binary"> for more
    information. <function>PQescapeByteaConn</function> performs this
index a94163e7be693064e59603e05bae100ea777cc14..eab66860ed7e20454aceafef08a53a318e8d2e6e 100644 (file)
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/plperl.sgml,v 2.59 2006/11/13 17:13:56 adunstan Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/plperl.sgml,v 2.59.2.1 2007/01/30 22:29:40 momjian Exp $ -->
 
  <chapter id="plperl">
   <title>PL/Perl - Perl Procedural Language</title>
@@ -80,10 +80,10 @@ $$ LANGUAGE plperl;
    the function body to be written as a string constant.  It is usually
    most convenient to use dollar quoting (see <xref
    linkend="sql-syntax-dollar-quoting">) for the string constant.
-   If you choose to use regular single-quoted string constant syntax,
-   you must escape single quote marks (<literal>'</>) and backslashes
-   (<literal>\</>) used in the body of the function, typically by
-   doubling them (see <xref linkend="sql-syntax-strings">).
+   If you choose to use escape string syntax <literal>E''</>,
+   you must double the single quote marks (<literal>'</>) and backslashes
+   (<literal>\</>) used in the body of the function 
+   (see <xref linkend="sql-syntax-strings">).
   </para>
 
   <para>
index 57e6672fc0abc6e858ec6e00a8158be6e28f74e8..5ac169dc3cc55feaccb95b1dbba22d4665cd667d 100644 (file)
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.101 2006/10/23 18:10:31 petere Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.101.2.1 2007/01/30 22:29:40 momjian Exp $ -->
 
 <chapter id="plpgsql"> 
   <title><application>PL/pgSQL</application> - <acronym>SQL</acronym> Procedural Language</title>
@@ -288,7 +288,8 @@ $$ LANGUAGE plpgsql;
     <command>CREATE FUNCTION</command> as a string literal.  If you
     write the string literal in the ordinary way with surrounding
     single quotes, then any single quotes inside the function body
-    must be doubled; likewise any backslashes must be doubled.
+    must be doubled; likewise any backslashes must be doubled (assuming
+    escape string syntax is used).
     Doubling quotes is at best tedious, and in more complicated cases
     the code can become downright incomprehensible, because you can
     easily find yourself needing half a dozen or more adjacent quote marks.
@@ -434,13 +435,6 @@ a_output := a_output || $$ if v_$$ || referrer_keys.kind || $$ like '$$
    </varlistentry>
   </variablelist>
 
-   <para>
-    A variant approach is to escape quotation marks in the function body
-    with a backslash rather than by doubling them.  With this method
-    you'll find yourself writing things like <literal>\'\'</> instead
-    of <literal>''''</>.  Some find this easier to keep track of, some
-    do not.
-   </para>
   </sect2>
  </sect1>
 
index 3242c891e7a87aad9c067359bcf10c1881c43a95..270c2f1514a2133413fd5498bd9b09dee3b999e6 100644 (file)
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/pltcl.sgml,v 2.42 2006/09/16 00:30:15 momjian Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/pltcl.sgml,v 2.42.2.1 2007/01/30 22:29:40 momjian Exp $ -->
 
  <chapter id="pltcl">
   <title>PL/Tcl - Tcl Procedural Language</title>
@@ -387,11 +387,11 @@ CREATE FUNCTION t1_count(integer, integer) RETURNS integer AS $$
 $$ LANGUAGE pltcl;
 </programlisting>
 
-    We need backslashes inside the query string given to
-    <function>spi_prepare</> to ensure that the
-    <literal>$<replaceable>n</replaceable></> markers will be passed
-    through to <function>spi_prepare</> as-is, and not replaced by Tcl
-    variable substitution.
+        We need backslashes inside the query string given to
+        <function>spi_prepare</> to ensure that the
+        <literal>$<replaceable>n</replaceable></> markers will be passed
+        through to <function>spi_prepare</> as-is, and not replaced by Tcl
+        variable substitution.
 
        </para>
       </listitem>
index 42bbf53916249b4dc32391273da141a41c1feee8..30b4e07d7cc631adb34cc9e1c1f986fb7b53a4de 100644 (file)
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/rowtypes.sgml,v 2.6 2005/11/04 23:14:01 petere Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/rowtypes.sgml,v 2.6.4.1 2007/01/30 22:29:40 momjian Exp $ -->
 
 <sect1 id="rowtypes">
  <title>Composite Types</title>
@@ -294,11 +294,12 @@ INSERT INTO mytab (complex_col.r, complex_col.i) VALUES(1.1, 2.2);
   <para>
    Remember that what you write in an SQL command will first be interpreted
    as a string literal, and then as a composite.  This doubles the number of
-   backslashes you need.  For example, to insert a <type>text</> field
+   backslashes you need (assuming escape string syntax is used).
+   For example, to insert a <type>text</> field
    containing a double quote and a backslash in a composite
    value, you'd need to write
 <programlisting>
-INSERT ... VALUES ('("\\"\\\\")');
+INSERT ... VALUES (E'("\\"\\\\")');
 </programlisting>
    The string-literal processor removes one level of backslashes, so that
    what arrives at the composite-value parser looks like
index 75699eb79b3c3f6eb4c293664c6c725079e0b0b5..6cac5ec3fb76c21d9b7d21d4da3ba80854b72770 100644 (file)
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.120 2006/11/23 05:43:32 neilc Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.120.2.1 2007/01/30 22:29:40 momjian Exp $ -->
 
  <sect1 id="xfunc">
   <title>User-Defined Functions</title>
@@ -147,9 +147,9 @@ SELECT clean_emp();
     most convenient to use dollar quoting (see <xref
     linkend="sql-syntax-dollar-quoting">) for the string constant.
     If you choose to use regular single-quoted string constant syntax,
-    you must escape single quote marks (<literal>'</>) and backslashes
-    (<literal>\</>) used in the body of the function, typically by
-    doubling them (see <xref linkend="sql-syntax-strings">).
+    you must double single quote marks (<literal>'</>) and backslashes
+    (<literal>\</>) (assuming escape string syntax) in the body of
+    the function (see <xref linkend="sql-syntax-strings">).
    </para>
 
    <para>