@@ -1253,7 +1253,7 @@ SELECT b, char_length(b) FROM test2;
1253
1253
strings are distinguished from character strings in two
1254
1254
ways. First, binary strings specifically allow storing
1255
1255
octets of value zero and other <quote>non-printable</quote>
1256
- octets (usually, octets outside the range 32 to 126).
1256
+ octets (usually, octets outside the decimal range 32 to 126).
1257
1257
Character strings disallow zero octets, and also disallow any
1258
1258
other octet values and sequences of octet values that are invalid
1259
1259
according to the database's selected character set encoding.
@@ -1265,9 +1265,10 @@ SELECT b, char_length(b) FROM test2;
1265
1265
</para>
1266
1266
1267
1267
<para>
1268
- The <type>bytea</type> type supports two external formats for
1269
- input and output: <productname>PostgreSQL</productname>'s historical
1270
- <quote>escape</quote> format, and <quote>hex</quote> format. Both
1268
+ The <type>bytea</type> type supports two
1269
+ formats for input and output: <quote>hex</quote> format
1270
+ and <productname>PostgreSQL</productname>'s historical
1271
+ <quote>escape</quote> format. Both
1271
1272
of these are always accepted on input. The output format depends
1272
1273
on the configuration parameter <xref linkend="guc-bytea-output">;
1273
1274
the default is hex. (Note that the hex format was introduced in
@@ -1305,7 +1306,7 @@ SELECT b, char_length(b) FROM test2;
1305
1306
<para>
1306
1307
Example:
1307
1308
<programlisting>
1308
- SELECT E'\ \xDEADBEEF';
1309
+ SELECT ' \xDEADBEEF';
1309
1310
</programlisting>
1310
1311
</para>
1311
1312
</sect2>
@@ -1325,7 +1326,7 @@ SELECT E'\\xDEADBEEF';
1325
1326
convenient. But in practice it is usually confusing because it
1326
1327
fuzzes up the distinction between binary strings and character
1327
1328
strings, and also the particular escape mechanism that was chosen is
1328
- somewhat unwieldy. So this format should probably be avoided
1329
+ somewhat unwieldy. Therefore, this format should probably be avoided
1329
1330
for most new applications.
1330
1331
</para>
1331
1332
@@ -1338,7 +1339,7 @@ SELECT E'\\xDEADBEEF';
1338
1339
octal value and precede it
1339
1340
by a backslash (or two backslashes, if writing the value as a
1340
1341
literal using escape string syntax).
1341
- Backslash itself (octet value 92) can alternatively be represented by
1342
+ Backslash itself (octet decimal value 92) can alternatively be represented by
1342
1343
double backslashes.
1343
1344
<xref linkend="datatype-binary-sqlesc">
1344
1345
shows the characters that must be escaped, and gives the alternative
@@ -1362,33 +1363,33 @@ SELECT E'\\xDEADBEEF';
1362
1363
<row>
1363
1364
<entry>0</entry>
1364
1365
<entry>zero octet</entry>
1365
- <entry><literal>E'\ \000'</literal></entry>
1366
- <entry><literal>SELECT E'\ \000'::bytea;</literal></entry>
1367
- <entry><literal>\000 </literal></entry>
1366
+ <entry><literal>' \000'</literal></entry>
1367
+ <entry><literal>SELECT ' \000'::bytea;</literal></entry>
1368
+ <entry><literal>\x00 </literal></entry>
1368
1369
</row>
1369
1370
1370
1371
<row>
1371
1372
<entry>39</entry>
1372
1373
<entry>single quote</entry>
1373
- <entry><literal>''''</literal> or <literal>E'\ \047'</literal></entry>
1374
- <entry><literal>SELECT E'\ ''::bytea;</literal></entry>
1375
- <entry><literal>' </literal></entry>
1374
+ <entry><literal>''''</literal> or <literal>' \047'</literal></entry>
1375
+ <entry><literal>SELECT '' ''::bytea;</literal></entry>
1376
+ <entry><literal>\x27 </literal></entry>
1376
1377
</row>
1377
1378
1378
1379
<row>
1379
1380
<entry>92</entry>
1380
1381
<entry>backslash</entry>
1381
- <entry><literal>E'\\\\ '</literal> or <literal>E '\\134'</literal></entry>
1382
- <entry><literal>SELECT E'\\ \\'::bytea;</literal></entry>
1383
- <entry><literal>\\ </literal></entry>
1382
+ <entry><literal>'\ '</literal> or <literal>'\\134'</literal></entry>
1383
+ <entry><literal>SELECT ' \\'::bytea;</literal></entry>
1384
+ <entry><literal>\x5c </literal></entry>
1384
1385
</row>
1385
1386
1386
1387
<row>
1387
1388
<entry>0 to 31 and 127 to 255</entry>
1388
1389
<entry><quote>non-printable</quote> octets</entry>
1389
- <entry><literal>E'\\ <replaceable>xxx'</></literal> (octal value)</entry>
1390
- <entry><literal>SELECT E'\ \001'::bytea;</literal></entry>
1391
- <entry><literal>\001 </literal></entry>
1390
+ <entry><literal>'\ <replaceable>xxx'</replaceable ></literal> (octal value)</entry>
1391
+ <entry><literal>SELECT ' \001'::bytea;</literal></entry>
1392
+ <entry><literal>\x01 </literal></entry>
1392
1393
</row>
1393
1394
1394
1395
</tbody>
@@ -1416,7 +1417,7 @@ SELECT E'\\xDEADBEEF';
1416
1417
of escaping.) The remaining backslash is then recognized by the
1417
1418
<type>bytea</type> input function as starting either a three
1418
1419
digit octal value or escaping another backslash. For example,
1419
- a string literal passed to the server as <literal>E'\ \001'</literal>
1420
+ a string literal passed to the server as <literal>' \001'</literal>
1420
1421
becomes <literal>\001</literal> after passing through the
1421
1422
escape string parser. The <literal>\001</literal> is then sent
1422
1423
to the <type>bytea</type> input function, where it is converted
@@ -1427,12 +1428,24 @@ SELECT E'\\xDEADBEEF';
1427
1428
</para>
1428
1429
1429
1430
<para>
1430
- <type>Bytea</type> octets are sometimes escaped when output. In general, each
1431
- <quote>non-printable</quote> octet is converted into
1432
- its equivalent three-digit octal value and preceded by one backslash.
1433
- Most <quote>printable</quote> octets are represented by their standard
1434
- representation in the client character set. The octet with decimal
1435
- value 92 (backslash) is doubled in the output.
1431
+ <type>Bytea</type> octets are output in <literal>hex</literal>
1432
+ format by default. If you change <xref linkend="guc-bytea-output">
1433
+ to <literal>escape</literal>,
1434
+ <quote>non-printable</quote> octet are converted to
1435
+ equivalent three-digit octal value and preceded by one backslash.
1436
+ Most <quote>printable</quote> octets are output by their standard
1437
+ representation in the client character set, e.g.:
1438
+
1439
+ <programlisting>
1440
+ SET bytea_output = 'escape';
1441
+
1442
+ SELECT 'abc \153\154\155 \052\251\124'::bytea;
1443
+ bytea
1444
+ ----------------
1445
+ abc klm *\251T
1446
+ </programlisting>
1447
+
1448
+ The octet with decimal value 92 (backslash) is doubled in the output.
1436
1449
Details are in <xref linkend="datatype-binary-resesc">.
1437
1450
</para>
1438
1451
@@ -1455,23 +1468,23 @@ SELECT E'\\xDEADBEEF';
1455
1468
<entry>92</entry>
1456
1469
<entry>backslash</entry>
1457
1470
<entry><literal>\\</literal></entry>
1458
- <entry><literal>SELECT E'\ \134'::bytea;</literal></entry>
1471
+ <entry><literal>SELECT ' \134'::bytea;</literal></entry>
1459
1472
<entry><literal>\\</literal></entry>
1460
1473
</row>
1461
1474
1462
1475
<row>
1463
1476
<entry>0 to 31 and 127 to 255</entry>
1464
1477
<entry><quote>non-printable</quote> octets</entry>
1465
1478
<entry><literal>\<replaceable>xxx</></literal> (octal value)</entry>
1466
- <entry><literal>SELECT E'\ \001'::bytea;</literal></entry>
1479
+ <entry><literal>SELECT ' \001'::bytea;</literal></entry>
1467
1480
<entry><literal>\001</literal></entry>
1468
1481
</row>
1469
1482
1470
1483
<row>
1471
1484
<entry>32 to 126</entry>
1472
1485
<entry><quote>printable</quote> octets</entry>
1473
1486
<entry>client character set representation</entry>
1474
- <entry><literal>SELECT E'\ \176'::bytea;</literal></entry>
1487
+ <entry><literal>SELECT ' \176'::bytea;</literal></entry>
1475
1488
<entry><literal>~</literal></entry>
1476
1489
</row>
1477
1490
0 commit comments