@@ -1282,7 +1282,7 @@ SELECT b, char_length(b) FROM test2;
1282
1282
strings are distinguished from character strings in two
1283
1283
ways. First, binary strings specifically allow storing
1284
1284
octets of value zero and other <quote>non-printable</quote>
1285
- octets (usually, octets outside the range 32 to 126).
1285
+ octets (usually, octets outside the decimal range 32 to 126).
1286
1286
Character strings disallow zero octets, and also disallow any
1287
1287
other octet values and sequences of octet values that are invalid
1288
1288
according to the database's selected character set encoding.
@@ -1294,9 +1294,10 @@ SELECT b, char_length(b) FROM test2;
1294
1294
</para>
1295
1295
1296
1296
<para>
1297
- The <type>bytea</type> type supports two external formats for
1298
- input and output: <productname>PostgreSQL</productname>'s historical
1299
- <quote>escape</quote> format, and <quote>hex</quote> format. Both
1297
+ The <type>bytea</type> type supports two
1298
+ formats for input and output: <quote>hex</quote> format
1299
+ and <productname>PostgreSQL</productname>'s historical
1300
+ <quote>escape</quote> format. Both
1300
1301
of these are always accepted on input. The output format depends
1301
1302
on the configuration parameter <xref linkend="guc-bytea-output">;
1302
1303
the default is hex. (Note that the hex format was introduced in
@@ -1334,7 +1335,7 @@ SELECT b, char_length(b) FROM test2;
1334
1335
<para>
1335
1336
Example:
1336
1337
<programlisting>
1337
- SELECT E'\ \xDEADBEEF';
1338
+ SELECT ' \xDEADBEEF';
1338
1339
</programlisting>
1339
1340
</para>
1340
1341
</sect2>
@@ -1354,7 +1355,7 @@ SELECT E'\\xDEADBEEF';
1354
1355
convenient. But in practice it is usually confusing because it
1355
1356
fuzzes up the distinction between binary strings and character
1356
1357
strings, and also the particular escape mechanism that was chosen is
1357
- somewhat unwieldy. So this format should probably be avoided
1358
+ somewhat unwieldy. Therefore, this format should probably be avoided
1358
1359
for most new applications.
1359
1360
</para>
1360
1361
@@ -1367,7 +1368,7 @@ SELECT E'\\xDEADBEEF';
1367
1368
octal value and precede it
1368
1369
by a backslash (or two backslashes, if writing the value as a
1369
1370
literal using escape string syntax).
1370
- Backslash itself (octet value 92) can alternatively be represented by
1371
+ Backslash itself (octet decimal value 92) can alternatively be represented by
1371
1372
double backslashes.
1372
1373
<xref linkend="datatype-binary-sqlesc">
1373
1374
shows the characters that must be escaped, and gives the alternative
@@ -1391,33 +1392,33 @@ SELECT E'\\xDEADBEEF';
1391
1392
<row>
1392
1393
<entry>0</entry>
1393
1394
<entry>zero octet</entry>
1394
- <entry><literal>E'\ \000'</literal></entry>
1395
- <entry><literal>SELECT E'\ \000'::bytea;</literal></entry>
1396
- <entry><literal>\000 </literal></entry>
1395
+ <entry><literal>' \000'</literal></entry>
1396
+ <entry><literal>SELECT ' \000'::bytea;</literal></entry>
1397
+ <entry><literal>\x00 </literal></entry>
1397
1398
</row>
1398
1399
1399
1400
<row>
1400
1401
<entry>39</entry>
1401
1402
<entry>single quote</entry>
1402
- <entry><literal>''''</literal> or <literal>E'\ \047'</literal></entry>
1403
- <entry><literal>SELECT E'\ ''::bytea;</literal></entry>
1404
- <entry><literal>' </literal></entry>
1403
+ <entry><literal>''''</literal> or <literal>' \047'</literal></entry>
1404
+ <entry><literal>SELECT '' ''::bytea;</literal></entry>
1405
+ <entry><literal>\x27 </literal></entry>
1405
1406
</row>
1406
1407
1407
1408
<row>
1408
1409
<entry>92</entry>
1409
1410
<entry>backslash</entry>
1410
- <entry><literal>E'\\\\ '</literal> or <literal>E '\\134'</literal></entry>
1411
- <entry><literal>SELECT E'\\ \\'::bytea;</literal></entry>
1412
- <entry><literal>\\ </literal></entry>
1411
+ <entry><literal>'\ '</literal> or <literal>'\\134'</literal></entry>
1412
+ <entry><literal>SELECT ' \\'::bytea;</literal></entry>
1413
+ <entry><literal>\x5c </literal></entry>
1413
1414
</row>
1414
1415
1415
1416
<row>
1416
1417
<entry>0 to 31 and 127 to 255</entry>
1417
1418
<entry><quote>non-printable</quote> octets</entry>
1418
- <entry><literal>E'\\ <replaceable>xxx'</></literal> (octal value)</entry>
1419
- <entry><literal>SELECT E'\ \001'::bytea;</literal></entry>
1420
- <entry><literal>\001 </literal></entry>
1419
+ <entry><literal>'\ <replaceable>xxx'</replaceable ></literal> (octal value)</entry>
1420
+ <entry><literal>SELECT ' \001'::bytea;</literal></entry>
1421
+ <entry><literal>\x01 </literal></entry>
1421
1422
</row>
1422
1423
1423
1424
</tbody>
@@ -1445,7 +1446,7 @@ SELECT E'\\xDEADBEEF';
1445
1446
of escaping.) The remaining backslash is then recognized by the
1446
1447
<type>bytea</type> input function as starting either a three
1447
1448
digit octal value or escaping another backslash. For example,
1448
- a string literal passed to the server as <literal>E'\ \001'</literal>
1449
+ a string literal passed to the server as <literal>' \001'</literal>
1449
1450
becomes <literal>\001</literal> after passing through the
1450
1451
escape string parser. The <literal>\001</literal> is then sent
1451
1452
to the <type>bytea</type> input function, where it is converted
@@ -1456,12 +1457,24 @@ SELECT E'\\xDEADBEEF';
1456
1457
</para>
1457
1458
1458
1459
<para>
1459
- <type>Bytea</type> octets are sometimes escaped when output. In general, each
1460
- <quote>non-printable</quote> octet is converted into
1461
- its equivalent three-digit octal value and preceded by one backslash.
1462
- Most <quote>printable</quote> octets are represented by their standard
1463
- representation in the client character set. The octet with decimal
1464
- value 92 (backslash) is doubled in the output.
1460
+ <type>Bytea</type> octets are output in <literal>hex</literal>
1461
+ format by default. If you change <xref linkend="guc-bytea-output">
1462
+ to <literal>escape</literal>,
1463
+ <quote>non-printable</quote> octet are converted to
1464
+ equivalent three-digit octal value and preceded by one backslash.
1465
+ Most <quote>printable</quote> octets are output by their standard
1466
+ representation in the client character set, e.g.:
1467
+
1468
+ <programlisting>
1469
+ SET bytea_output = 'escape';
1470
+
1471
+ SELECT 'abc \153\154\155 \052\251\124'::bytea;
1472
+ bytea
1473
+ ----------------
1474
+ abc klm *\251T
1475
+ </programlisting>
1476
+
1477
+ The octet with decimal value 92 (backslash) is doubled in the output.
1465
1478
Details are in <xref linkend="datatype-binary-resesc">.
1466
1479
</para>
1467
1480
@@ -1484,23 +1497,23 @@ SELECT E'\\xDEADBEEF';
1484
1497
<entry>92</entry>
1485
1498
<entry>backslash</entry>
1486
1499
<entry><literal>\\</literal></entry>
1487
- <entry><literal>SELECT E'\ \134'::bytea;</literal></entry>
1500
+ <entry><literal>SELECT ' \134'::bytea;</literal></entry>
1488
1501
<entry><literal>\\</literal></entry>
1489
1502
</row>
1490
1503
1491
1504
<row>
1492
1505
<entry>0 to 31 and 127 to 255</entry>
1493
1506
<entry><quote>non-printable</quote> octets</entry>
1494
1507
<entry><literal>\<replaceable>xxx</></literal> (octal value)</entry>
1495
- <entry><literal>SELECT E'\ \001'::bytea;</literal></entry>
1508
+ <entry><literal>SELECT ' \001'::bytea;</literal></entry>
1496
1509
<entry><literal>\001</literal></entry>
1497
1510
</row>
1498
1511
1499
1512
<row>
1500
1513
<entry>32 to 126</entry>
1501
1514
<entry><quote>printable</quote> octets</entry>
1502
1515
<entry>client character set representation</entry>
1503
- <entry><literal>SELECT E'\ \176'::bytea;</literal></entry>
1516
+ <entry><literal>SELECT ' \176'::bytea;</literal></entry>
1504
1517
<entry><literal>~</literal></entry>
1505
1518
</row>
1506
1519
0 commit comments