@@ -189,6 +189,23 @@ UPDATE "my_table" SET "a" = 5;
189
189
ampersands. The length limitation still applies.
190
190
</para>
191
191
192
+ <para>
193
+ Quoting an identifier also makes it case-sensitive, whereas
194
+ unquoted names are always folded to lower case. For example, the
195
+ identifiers <literal>FOO</literal>, <literal>foo</literal>, and
196
+ <literal>"foo"</literal> are considered the same by
197
+ <productname>PostgreSQL</productname>, but
198
+ <literal>"Foo"</literal> and <literal>"FOO"</literal> are
199
+ different from these three and each other. (The folding of
200
+ unquoted names to lower case in <productname>PostgreSQL</productname> is
201
+ incompatible with the SQL standard, which says that unquoted names
202
+ should be folded to upper case. Thus, <literal>foo</literal>
203
+ should be equivalent to <literal>"FOO"</literal> not
204
+ <literal>"foo"</literal> according to the standard. If you want
205
+ to write portable applications you are advised to always quote a
206
+ particular name or never quote it.)
207
+ </para>
208
+
192
209
<indexterm>
193
210
<primary>Unicode escape</primary>
194
211
<secondary>in identifiers</secondary>
@@ -230,7 +247,8 @@ U&"d!0061t!+000061" UESCAPE '!'
230
247
The escape character can be any single character other than a
231
248
hexadecimal digit, the plus sign, a single quote, a double quote,
232
249
or a whitespace character. Note that the escape character is
233
- written in single quotes, not double quotes.
250
+ written in single quotes, not double quotes,
251
+ after <literal>UESCAPE</literal>.
234
252
</para>
235
253
236
254
<para>
@@ -239,32 +257,18 @@ U&"d!0061t!+000061" UESCAPE '!'
239
257
</para>
240
258
241
259
<para>
242
- The Unicode escape syntax works only when the server encoding is
243
- <literal>UTF8</literal>. When other server encodings are used, only code
244
- points in the ASCII range (up to <literal>\007F</literal>) can be
245
- specified. Both the 4-digit and the 6-digit form can be used to
260
+ Either the 4-digit or the 6-digit escape form can be used to
246
261
specify UTF-16 surrogate pairs to compose characters with code
247
262
points larger than U+FFFF, although the availability of the
248
263
6-digit form technically makes this unnecessary. (Surrogate
249
- pairs are not stored directly, but combined into a single
250
- code point that is then encoded in UTF-8 .)
264
+ pairs are not stored directly, but are combined into a single
265
+ code point.)
251
266
</para>
252
267
253
268
<para>
254
- Quoting an identifier also makes it case-sensitive, whereas
255
- unquoted names are always folded to lower case. For example, the
256
- identifiers <literal>FOO</literal>, <literal>foo</literal>, and
257
- <literal>"foo"</literal> are considered the same by
258
- <productname>PostgreSQL</productname>, but
259
- <literal>"Foo"</literal> and <literal>"FOO"</literal> are
260
- different from these three and each other. (The folding of
261
- unquoted names to lower case in <productname>PostgreSQL</productname> is
262
- incompatible with the SQL standard, which says that unquoted names
263
- should be folded to upper case. Thus, <literal>foo</literal>
264
- should be equivalent to <literal>"FOO"</literal> not
265
- <literal>"foo"</literal> according to the standard. If you want
266
- to write portable applications you are advised to always quote a
267
- particular name or never quote it.)
269
+ If the server encoding is not UTF-8, the Unicode code point identified
270
+ by one of these escape sequences is converted to the actual server
271
+ encoding; an error is reported if that's not possible.
268
272
</para>
269
273
</sect2>
270
274
@@ -427,25 +431,11 @@ SELECT 'foo' 'bar';
427
431
<para>
428
432
It is your responsibility that the byte sequences you create,
429
433
especially when using the octal or hexadecimal escapes, compose
430
- valid characters in the server character set encoding. When the
431
- server encoding is UTF-8, then the Unicode escapes or the
434
+ valid characters in the server character set encoding.
435
+ A useful alternative is to use Unicode escapes or the
432
436
alternative Unicode escape syntax, explained
433
- in <xref linkend="sql-syntax-strings-uescape"/>, should be used
434
- instead. (The alternative would be doing the UTF-8 encoding by
435
- hand and writing out the bytes, which would be very cumbersome.)
436
- </para>
437
-
438
- <para>
439
- The Unicode escape syntax works fully only when the server
440
- encoding is <literal>UTF8</literal>. When other server encodings are
441
- used, only code points in the ASCII range (up
442
- to <literal>\u007F</literal>) can be specified. Both the 4-digit and
443
- the 8-digit form can be used to specify UTF-16 surrogate pairs to
444
- compose characters with code points larger than U+FFFF, although
445
- the availability of the 8-digit form technically makes this
446
- unnecessary. (When surrogate pairs are used when the server
447
- encoding is <literal>UTF8</literal>, they are first combined into a
448
- single code point that is then encoded in UTF-8.)
437
+ in <xref linkend="sql-syntax-strings-uescape"/>; then the server
438
+ will check that the character conversion is possible.
449
439
</para>
450
440
451
441
<caution>
@@ -524,16 +514,23 @@ U&'d!0061t!+000061' UESCAPE '!'
524
514
</para>
525
515
526
516
<para>
527
- The Unicode escape syntax works only when the server encoding is
528
- <literal>UTF8</literal>. When other server encodings are used, only
529
- code points in the ASCII range (up to <literal>\007F</literal>)
530
- can be specified. Both the 4-digit and the 6-digit form can be
531
- used to specify UTF-16 surrogate pairs to compose characters with
532
- code points larger than U+FFFF, although the availability of the
533
- 6-digit form technically makes this unnecessary. (When surrogate
534
- pairs are used when the server encoding is <literal>UTF8</literal>, they
535
- are first combined into a single code point that is then encoded
536
- in UTF-8.)
517
+ To include the escape character in the string literally, write
518
+ it twice.
519
+ </para>
520
+
521
+ <para>
522
+ Either the 4-digit or the 6-digit escape form can be used to
523
+ specify UTF-16 surrogate pairs to compose characters with code
524
+ points larger than U+FFFF, although the availability of the
525
+ 6-digit form technically makes this unnecessary. (Surrogate
526
+ pairs are not stored directly, but are combined into a single
527
+ code point.)
528
+ </para>
529
+
530
+ <para>
531
+ If the server encoding is not UTF-8, the Unicode code point identified
532
+ by one of these escape sequences is converted to the actual server
533
+ encoding; an error is reported if that's not possible.
537
534
</para>
538
535
539
536
<para>
@@ -546,11 +543,6 @@ U&'d!0061t!+000061' UESCAPE '!'
546
543
parameter is set to off, this syntax will be rejected with an
547
544
error message.
548
545
</para>
549
-
550
- <para>
551
- To include the escape character in the string literally, write it
552
- twice.
553
- </para>
554
546
</sect3>
555
547
556
548
<sect3 id="sql-syntax-dollar-quoting">
0 commit comments