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