@@ -1296,7 +1296,7 @@ SELECT b, char_length(b) FROM test2;
12961296 strings are distinguished from character strings in two
12971297 ways. First, binary strings specifically allow storing
12981298 octets of value zero and other <quote>non-printable</quote>
1299- octets (usually, octets outside the range 32 to 126).
1299+ octets (usually, octets outside the decimal range 32 to 126).
13001300 Character strings disallow zero octets, and also disallow any
13011301 other octet values and sequences of octet values that are invalid
13021302 according to the database's selected character set encoding.
@@ -1308,9 +1308,10 @@ SELECT b, char_length(b) FROM test2;
13081308 </para>
13091309
13101310 <para>
1311- The <type>bytea</type> type supports two external formats for
1312- input and output: <productname>PostgreSQL</productname>'s historical
1313- <quote>escape</quote> format, and <quote>hex</quote> format. Both
1311+ The <type>bytea</type> type supports two
1312+ formats for input and output: <quote>hex</quote> format
1313+ and <productname>PostgreSQL</productname>'s historical
1314+ <quote>escape</quote> format. Both
13141315 of these are always accepted on input. The output format depends
13151316 on the configuration parameter <xref linkend="guc-bytea-output"/>;
13161317 the default is hex. (Note that the hex format was introduced in
@@ -1348,7 +1349,7 @@ SELECT b, char_length(b) FROM test2;
13481349 <para>
13491350 Example:
13501351<programlisting>
1351- SELECT E'\ \xDEADBEEF';
1352+ SELECT ' \xDEADBEEF';
13521353</programlisting>
13531354 </para>
13541355 </sect2>
@@ -1368,7 +1369,7 @@ SELECT E'\\xDEADBEEF';
13681369 convenient. But in practice it is usually confusing because it
13691370 fuzzes up the distinction between binary strings and character
13701371 strings, and also the particular escape mechanism that was chosen is
1371- somewhat unwieldy. So this format should probably be avoided
1372+ somewhat unwieldy. Therefore, this format should probably be avoided
13721373 for most new applications.
13731374 </para>
13741375
@@ -1381,7 +1382,7 @@ SELECT E'\\xDEADBEEF';
13811382 octal value and precede it
13821383 by a backslash (or two backslashes, if writing the value as a
13831384 literal using escape string syntax).
1384- Backslash itself (octet value 92) can alternatively be represented by
1385+ Backslash itself (octet decimal value 92) can alternatively be represented by
13851386 double backslashes.
13861387 <xref linkend="datatype-binary-sqlesc"/>
13871388 shows the characters that must be escaped, and gives the alternative
@@ -1405,33 +1406,33 @@ SELECT E'\\xDEADBEEF';
14051406 <row>
14061407 <entry>0</entry>
14071408 <entry>zero octet</entry>
1408- <entry><literal>E'\ \000'</literal></entry>
1409- <entry><literal>SELECT E'\ \000'::bytea;</literal></entry>
1410- <entry><literal>\000 </literal></entry>
1409+ <entry><literal>' \000'</literal></entry>
1410+ <entry><literal>SELECT ' \000'::bytea;</literal></entry>
1411+ <entry><literal>\x00 </literal></entry>
14111412 </row>
14121413
14131414 <row>
14141415 <entry>39</entry>
14151416 <entry>single quote</entry>
1416- <entry><literal>''''</literal> or <literal>E'\ \047'</literal></entry>
1417- <entry><literal>SELECT E'\ ''::bytea;</literal></entry>
1418- <entry><literal>' </literal></entry>
1417+ <entry><literal>''''</literal> or <literal>' \047'</literal></entry>
1418+ <entry><literal>SELECT '' ''::bytea;</literal></entry>
1419+ <entry><literal>\x27 </literal></entry>
14191420 </row>
14201421
14211422 <row>
14221423 <entry>92</entry>
14231424 <entry>backslash</entry>
1424- <entry><literal>E'\\\\ '</literal> or <literal>E '\\134'</literal></entry>
1425- <entry><literal>SELECT E'\\ \\'::bytea;</literal></entry>
1426- <entry><literal>\\ </literal></entry>
1425+ <entry><literal>'\ '</literal> or <literal>'\\134'</literal></entry>
1426+ <entry><literal>SELECT ' \\'::bytea;</literal></entry>
1427+ <entry><literal>\x5c </literal></entry>
14271428 </row>
14281429
14291430 <row>
14301431 <entry>0 to 31 and 127 to 255</entry>
14311432 <entry><quote>non-printable</quote> octets</entry>
1432- <entry><literal>E'\ \<replaceable>xxx'</replaceable></literal> (octal value)</entry>
1433- <entry><literal>SELECT E'\ \001'::bytea;</literal></entry>
1434- <entry><literal>\001 </literal></entry>
1433+ <entry><literal>' \<replaceable>xxx'</replaceable></literal> (octal value)</entry>
1434+ <entry><literal>SELECT ' \001'::bytea;</literal></entry>
1435+ <entry><literal>\x01 </literal></entry>
14351436 </row>
14361437
14371438 </tbody>
@@ -1459,7 +1460,7 @@ SELECT E'\\xDEADBEEF';
14591460 of escaping.) The remaining backslash is then recognized by the
14601461 <type>bytea</type> input function as starting either a three
14611462 digit octal value or escaping another backslash. For example,
1462- a string literal passed to the server as <literal>E'\ \001'</literal>
1463+ a string literal passed to the server as <literal>' \001'</literal>
14631464 becomes <literal>\001</literal> after passing through the
14641465 escape string parser. The <literal>\001</literal> is then sent
14651466 to the <type>bytea</type> input function, where it is converted
@@ -1470,12 +1471,24 @@ SELECT E'\\xDEADBEEF';
14701471 </para>
14711472
14721473 <para>
1473- <type>Bytea</type> octets are sometimes escaped when output. In general, each
1474- <quote>non-printable</quote> octet is converted into
1475- its equivalent three-digit octal value and preceded by one backslash.
1476- Most <quote>printable</quote> octets are represented by their standard
1477- representation in the client character set. The octet with decimal
1478- value 92 (backslash) is doubled in the output.
1474+ <type>Bytea</type> octets are output in <literal>hex</literal>
1475+ format by default. If you change <xref linkend="guc-bytea-output"/>
1476+ to <literal>escape</literal>,
1477+ <quote>non-printable</quote> octet are converted to
1478+ equivalent three-digit octal value and preceded by one backslash.
1479+ Most <quote>printable</quote> octets are output by their standard
1480+ representation in the client character set, e.g.:
1481+
1482+ <programlisting>
1483+ SET bytea_output = 'escape';
1484+
1485+ SELECT 'abc \153\154\155 \052\251\124'::bytea;
1486+ bytea
1487+ ----------------
1488+ abc klm *\251T
1489+ </programlisting>
1490+
1491+ The octet with decimal value 92 (backslash) is doubled in the output.
14791492 Details are in <xref linkend="datatype-binary-resesc"/>.
14801493 </para>
14811494
@@ -1498,23 +1511,23 @@ SELECT E'\\xDEADBEEF';
14981511 <entry>92</entry>
14991512 <entry>backslash</entry>
15001513 <entry><literal>\\</literal></entry>
1501- <entry><literal>SELECT E'\ \134'::bytea;</literal></entry>
1514+ <entry><literal>SELECT ' \134'::bytea;</literal></entry>
15021515 <entry><literal>\\</literal></entry>
15031516 </row>
15041517
15051518 <row>
15061519 <entry>0 to 31 and 127 to 255</entry>
15071520 <entry><quote>non-printable</quote> octets</entry>
15081521 <entry><literal>\<replaceable>xxx</replaceable></literal> (octal value)</entry>
1509- <entry><literal>SELECT E'\ \001'::bytea;</literal></entry>
1522+ <entry><literal>SELECT ' \001'::bytea;</literal></entry>
15101523 <entry><literal>\001</literal></entry>
15111524 </row>
15121525
15131526 <row>
15141527 <entry>32 to 126</entry>
15151528 <entry><quote>printable</quote> octets</entry>
15161529 <entry>client character set representation</entry>
1517- <entry><literal>SELECT E'\ \176'::bytea;</literal></entry>
1530+ <entry><literal>SELECT ' \176'::bytea;</literal></entry>
15181531 <entry><literal>~</literal></entry>
15191532 </row>
15201533
0 commit comments