mirror of
https://github.com/postgres/postgres.git
synced 2025-07-14 08:21:07 +03:00
docs: remove use of escape strings and use bytea hex output
standard_conforming_strings defaulted to 'on' in PG 9.1. bytea_output defaulted to 'hex' in PG 9.0. Reported-by: André Hänsel Discussion: https://postgr.es/m/12e601d447ac$345994a0$9d0cbde0$@webkr.de Backpatch-through: 9.3
This commit is contained in:
@ -766,9 +766,9 @@ SELECT f1[1][-2][3] AS e1, f1[1][-1][5] AS e2
|
||||
For example, elements containing curly braces, commas (or the data type's
|
||||
delimiter character), double quotes, backslashes, or leading or trailing
|
||||
whitespace must be double-quoted. Empty strings and strings matching the
|
||||
word <literal>NULL</literal> must be quoted, too. To put a double quote or
|
||||
backslash in a quoted array element value, use escape string syntax
|
||||
and precede it with a backslash. Alternatively, you can avoid quotes and use
|
||||
word <literal>NULL</literal> must be quoted, too. To put a double
|
||||
quote or backslash in a quoted array element value, precede it
|
||||
with a backslash. Alternatively, you can avoid quotes and use
|
||||
backslash-escaping to protect all data characters that would otherwise
|
||||
be taken as array syntax.
|
||||
</para>
|
||||
@ -781,27 +781,6 @@ SELECT f1[1][-2][3] AS e1, f1[1][-1][5] AS e2
|
||||
non-whitespace characters of an element, is not ignored.
|
||||
</para>
|
||||
|
||||
<note>
|
||||
<para>
|
||||
Remember that what you write in an SQL command will first be interpreted
|
||||
as a string literal, and then as an array. This doubles the number of
|
||||
backslashes you need. For example, to insert a <type>text</type> array
|
||||
value containing a backslash and a double quote, you'd need to write:
|
||||
<programlisting>
|
||||
INSERT ... VALUES (E'{"\\\\","\\""}');
|
||||
</programlisting>
|
||||
The escape string processor removes one level of backslashes, so that
|
||||
what arrives at the array-value parser looks like <literal>{"\\","\""}</literal>.
|
||||
In turn, the strings fed to the <type>text</type> data type's input routine
|
||||
become <literal>\</literal> and <literal>"</literal> respectively. (If we were working
|
||||
with a data type whose input routine also treated backslashes specially,
|
||||
<type>bytea</type> for example, we might need as many as eight backslashes
|
||||
in the command to get one backslash into the stored array element.)
|
||||
Dollar quoting (see <xref linkend="sql-syntax-dollar-quoting"/>) can be
|
||||
used to avoid the need to double backslashes.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
<tip>
|
||||
<para>
|
||||
The <literal>ARRAY</literal> constructor syntax (see
|
||||
|
Reference in New Issue
Block a user