pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #15373: null / utf-8
6+ messages / 3 participants
[nested] [flat]
* BUG #15373: null / utf-8
@ 2018-09-08 17:24 PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 6+ messages in thread
From: PG Bug reporting form @ 2018-09-08 17:24 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: orchideric@yahoo.com
The following bug has been logged on the website:
Bug reference: 15373
Logged by: Eric Hansen
Email address: orchideric@yahoo.com
PostgreSQL version: 10.5
Operating system: ubu 16
Description:
doesn’t support converting NULL bytes to UTF-8 and therefore returns an
error
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #15373: null / utf-8
@ 2018-09-08 17:36 Bruce Momjian <bruce@momjian.us>
parent: PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 6+ messages in thread
From: Bruce Momjian @ 2018-09-08 17:36 UTC (permalink / raw)
To: orchideric@yahoo.com; pgsql-bugs@lists.postgresql.org
On Sat, Sep 8, 2018 at 05:24:17PM +0000, PG Bug reporting form wrote:
> The following bug has been logged on the website:
>
> Bug reference: 15373
> Logged by: Eric Hansen
> Email address: orchideric@yahoo.com
> PostgreSQL version: 10.5
> Operating system: ubu 16
> Description:
>
> doesn’t support converting NULL bytes to UTF-8 and therefore returns an
> error
You need to encode binary values containing nulls as bytea strings.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #15373: null / utf-8
@ 2018-09-08 20:36 'Bruce Momjian' <bruce@momjian.us>
parent: Bruce Momjian <bruce@momjian.us>
0 siblings, 1 reply; 6+ messages in thread
From: Bruce Momjian @ 2018-09-08 20:36 UTC (permalink / raw)
To: André Hänsel <andre@webkr.de>; +Cc: orchideric@yahoo.com; pgsql-bugs@lists.postgresql.org
On Sat, Sep 8, 2018 at 09:43:18PM +0200, André Hänsel wrote:
> Bruce Momjian wrote:
>
> > On Sat, Sep 8, 2018 at 05:24:17PM +0000, PG Bug reporting form wrote:
> >> doesn’t support converting NULL bytes to UTF-8 and therefore returns an
> >> error
>
> > You need to encode binary values containing nulls as bytea strings.
>
> Actually this reminds me to log a documentation bug, or rather improvement.
>
> It is already slightly confusing that Postgres doesn't support null bytes
> in text columns at all and in bytea columns cannot take them in as a normal
> string literal. I'm assuming this is traditional and difficult to change.
>
> Now, there are two formats in which bytea column content can be specified,
> the "hex" and the deprecated "escape" format.
>
> This "escape" format is called that way because it allows escape sequences
> which are un-escaped before the data is written to the column. This step is
> comparable to the parsing of JSON for jsonb columns or the parsing of array
> syntax for any array type.
>
> However, during the parsing of an SQL there is a second, completely
> different, un-escaping step going on, the un-escaping of C-style escapes in
> string literals starting with an "E", *if* you start the string literal
> with an "E".
>
> For some reason the example given in the documentation for the "hex"
> format uses such an "escape string literal":
>
> SELECT E'\\xDEADBEEF';
>
> I found this very confusing. Can this example be changed to a normal
> string literal, like this?
>
> SELECT '\xDEADBEEF';
You know, I 100% agree with you. We used the E'' syntax so we would
produce the same results whether standard_conforming_strings was true or
false. However, we changed the standard_conforming_strings default to
true in Postgres 9.1 on 2011-09-12, and that release has been
end-of-life for a year.
I think it is time to clarify our documentation examples by assuming
that standard_conforming_strings is true. I will work on a patch.
Thanks.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #15373: null / utf-8
@ 2018-09-14 02:20 'Bruce Momjian' <bruce@momjian.us>
parent: 'Bruce Momjian' <bruce@momjian.us>
0 siblings, 1 reply; 6+ messages in thread
From: Bruce Momjian @ 2018-09-14 02:20 UTC (permalink / raw)
To: André Hänsel <andre@webkr.de>; +Cc: orchideric@yahoo.com; pgsql-bugs@lists.postgresql.org
On Sat, Sep 8, 2018 at 04:36:19PM -0400, 'Bruce Momjian' wrote:
> On Sat, Sep 8, 2018 at 09:43:18PM +0200, André Hänsel wrote:
> > For some reason the example given in the documentation for the "hex"
> > format uses such an "escape string literal":
> >
> > SELECT E'\\xDEADBEEF';
> >
> > I found this very confusing. Can this example be changed to a normal
> > string literal, like this?
> >
> > SELECT '\xDEADBEEF';
>
> You know, I 100% agree with you. We used the E'' syntax so we would
> produce the same results whether standard_conforming_strings was true or
> false. However, we changed the standard_conforming_strings default to
> true in Postgres 9.1 on 2011-09-12, and that release has been
> end-of-life for a year.
>
> I think it is time to clarify our documentation examples by assuming
> that standard_conforming_strings is true. I will work on a patch.
> Thanks.
I have developed the attached documentation patch to remove the E''
syntax. standard_conforming_strings defaulted to 'on' in PG 9.1.
I also found that our bytea data type section wasn't properly adjusted
when we changed the the default bytea_output to 'hex' in PG 9.0.
I think the only question is how far back to apply this patch. I am
thinking through 9.3.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +
Attachments:
escape.diff (text/x-diff, 18.9K) download
diff --git a/doc/src/sgml/array.sgml b/doc/src/sgml/array.sgml
index f4d4a61..038599d 100644
--- a/doc/src/sgml/array.sgml
+++ b/doc/src/sgml/array.sgml
@@ -788,7 +788,7 @@ SELECT f1[1][-2][3] AS e1, f1[1][-1][5] AS e2
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'{"\\\\","\\""}');
+INSERT ... VALUES ('{"\\","\""}');
</programlisting>
The escape string processor removes one level of backslashes, so that
what arrives at the array-value parser looks like <literal>{"\\","\""}</literal>.
diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml
index 3d36cca..f9458c9 100644
--- a/doc/src/sgml/datatype.sgml
+++ b/doc/src/sgml/datatype.sgml
@@ -1296,7 +1296,7 @@ SELECT b, char_length(b) FROM test2;
strings are distinguished from character strings in two
ways. First, binary strings specifically allow storing
octets of value zero and other <quote>non-printable</quote>
- octets (usually, octets outside the range 32 to 126).
+ octets (usually, octets outside the decimal range 32 to 126).
Character strings disallow zero octets, and also disallow any
other octet values and sequences of octet values that are invalid
according to the database's selected character set encoding.
@@ -1308,9 +1308,10 @@ SELECT b, char_length(b) FROM test2;
</para>
<para>
- The <type>bytea</type> type supports two external formats for
- input and output: <productname>PostgreSQL</productname>'s historical
- <quote>escape</quote> format, and <quote>hex</quote> format. Both
+ The <type>bytea</type> type supports two
+ formats for input and output: <quote>hex</quote> format
+ and <productname>PostgreSQL</productname>'s historical
+ <quote>escape</quote> format. Both
of these are always accepted on input. The output format depends
on the configuration parameter <xref linkend="guc-bytea-output"/>;
the default is hex. (Note that the hex format was introduced in
@@ -1348,7 +1349,7 @@ SELECT b, char_length(b) FROM test2;
<para>
Example:
<programlisting>
-SELECT E'\\xDEADBEEF';
+SELECT '\xDEADBEEF';
</programlisting>
</para>
</sect2>
@@ -1368,7 +1369,7 @@ SELECT E'\\xDEADBEEF';
convenient. But in practice it is usually confusing because it
fuzzes up the distinction between binary strings and character
strings, and also the particular escape mechanism that was chosen is
- somewhat unwieldy. So this format should probably be avoided
+ somewhat unwieldy. Therefore, this format should probably be avoided
for most new applications.
</para>
@@ -1381,7 +1382,7 @@ SELECT E'\\xDEADBEEF';
octal value and precede it
by a backslash (or two backslashes, if writing the value as a
literal using escape string syntax).
- Backslash itself (octet value 92) can alternatively be represented by
+ Backslash itself (octet decimal value 92) can alternatively be represented by
double backslashes.
<xref linkend="datatype-binary-sqlesc"/>
shows the characters that must be escaped, and gives the alternative
@@ -1405,33 +1406,33 @@ SELECT E'\\xDEADBEEF';
<row>
<entry>0</entry>
<entry>zero octet</entry>
- <entry><literal>E'\\000'</literal></entry>
- <entry><literal>SELECT E'\\000'::bytea;</literal></entry>
- <entry><literal>\000</literal></entry>
+ <entry><literal>'\000'</literal></entry>
+ <entry><literal>SELECT '\000'::bytea;</literal></entry>
+ <entry><literal>\x00</literal></entry>
</row>
<row>
<entry>39</entry>
<entry>single quote</entry>
- <entry><literal>''''</literal> or <literal>E'\\047'</literal></entry>
- <entry><literal>SELECT E'\''::bytea;</literal></entry>
- <entry><literal>'</literal></entry>
+ <entry><literal>''''</literal> or <literal>'\047'</literal></entry>
+ <entry><literal>SELECT ''''::bytea;</literal></entry>
+ <entry><literal>\x27</literal></entry>
</row>
<row>
<entry>92</entry>
<entry>backslash</entry>
- <entry><literal>E'\\\\'</literal> or <literal>E'\\134'</literal></entry>
- <entry><literal>SELECT E'\\\\'::bytea;</literal></entry>
- <entry><literal>\\</literal></entry>
+ <entry><literal>'\'</literal> or <literal>'\\134'</literal></entry>
+ <entry><literal>SELECT '\\'::bytea;</literal></entry>
+ <entry><literal>\x5c</literal></entry>
</row>
<row>
<entry>0 to 31 and 127 to 255</entry>
<entry><quote>non-printable</quote> octets</entry>
- <entry><literal>E'\\<replaceable>xxx'</replaceable></literal> (octal value)</entry>
- <entry><literal>SELECT E'\\001'::bytea;</literal></entry>
- <entry><literal>\001</literal></entry>
+ <entry><literal>'\<replaceable>xxx'</replaceable></literal> (octal value)</entry>
+ <entry><literal>SELECT '\001'::bytea;</literal></entry>
+ <entry><literal>\x01</literal></entry>
</row>
</tbody>
@@ -1459,7 +1460,7 @@ SELECT E'\\xDEADBEEF';
of escaping.) The remaining backslash is then recognized by the
<type>bytea</type> input function as starting either a three
digit octal value or escaping another backslash. For example,
- a string literal passed to the server as <literal>E'\\001'</literal>
+ a string literal passed to the server as <literal>'\001'</literal>
becomes <literal>\001</literal> after passing through the
escape string parser. The <literal>\001</literal> is then sent
to the <type>bytea</type> input function, where it is converted
@@ -1470,12 +1471,24 @@ SELECT E'\\xDEADBEEF';
</para>
<para>
- <type>Bytea</type> octets are sometimes escaped when output. In general, each
- <quote>non-printable</quote> octet is converted into
- its equivalent three-digit octal value and preceded by one backslash.
- Most <quote>printable</quote> octets are represented by their standard
- representation in the client character set. The octet with decimal
- value 92 (backslash) is doubled in the output.
+ <type>Bytea</type> octets are output in <literal>hex</literal>
+ format by default. If you change <xref linkend="guc-bytea-output"/>
+ to <literal>escape</literal>,
+ <quote>non-printable</quote> octet are converted to
+ equivalent three-digit octal value and preceded by one backslash.
+ Most <quote>printable</quote> octets are output by their standard
+ representation in the client character set, e.g.:
+
+<programlisting>
+SET bytea_output = 'escape';
+
+SELECT 'abc \153\154\155 \052\251\124'::bytea;
+ bytea
+----------------
+ abc klm *\251T
+</programlisting>
+
+ The octet with decimal value 92 (backslash) is doubled in the output.
Details are in <xref linkend="datatype-binary-resesc"/>.
</para>
@@ -1498,7 +1511,7 @@ SELECT E'\\xDEADBEEF';
<entry>92</entry>
<entry>backslash</entry>
<entry><literal>\\</literal></entry>
- <entry><literal>SELECT E'\\134'::bytea;</literal></entry>
+ <entry><literal>SELECT '\134'::bytea;</literal></entry>
<entry><literal>\\</literal></entry>
</row>
@@ -1506,7 +1519,7 @@ SELECT E'\\xDEADBEEF';
<entry>0 to 31 and 127 to 255</entry>
<entry><quote>non-printable</quote> octets</entry>
<entry><literal>\<replaceable>xxx</replaceable></literal> (octal value)</entry>
- <entry><literal>SELECT E'\\001'::bytea;</literal></entry>
+ <entry><literal>SELECT '\001'::bytea;</literal></entry>
<entry><literal>\001</literal></entry>
</row>
@@ -1514,7 +1527,7 @@ SELECT E'\\xDEADBEEF';
<entry>32 to 126</entry>
<entry><quote>printable</quote> octets</entry>
<entry>client character set representation</entry>
- <entry><literal>SELECT E'\\176'::bytea;</literal></entry>
+ <entry><literal>SELECT '\176'::bytea;</literal></entry>
<entry><literal>~</literal></entry>
</row>
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 4331beb..c44417d 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -1776,7 +1776,7 @@
octal sequences (<literal>\</literal><replaceable>nnn</replaceable>) and
doubles backslashes.
</entry>
- <entry><literal>encode(E'123\\000\\001', 'base64')</literal></entry>
+ <entry><literal>encode('123\000\001', 'base64')</literal></entry>
<entry><literal>MTIzAAE=</literal></entry>
</row>
@@ -2100,7 +2100,7 @@
the delimiter. See <xref linkend="functions-posix-regexp"/> for more
information.
</entry>
- <entry><literal>regexp_split_to_array('hello world', E'\\s+')</literal></entry>
+ <entry><literal>regexp_split_to_array('hello world', '\s+')</literal></entry>
<entry><literal>{hello,world}</literal></entry>
</row>
@@ -2117,7 +2117,7 @@
the delimiter. See <xref linkend="functions-posix-regexp"/> for more
information.
</entry>
- <entry><literal>regexp_split_to_table('hello world', E'\\s+')</literal></entry>
+ <entry><literal>regexp_split_to_table('hello world', '\s+')</literal></entry>
<entry><literal>hello</literal><para><literal>world</literal></para> (2 rows)</entry>
</row>
@@ -3301,8 +3301,8 @@ SELECT format('Testing %s, %s, %s, %%', 'one', 'two', 'three');
SELECT format('INSERT INTO %I VALUES(%L)', 'Foo bar', E'O\'Reilly');
<lineannotation>Result: </lineannotation><computeroutput>INSERT INTO "Foo bar" VALUES('O''Reilly')</computeroutput>
-SELECT format('INSERT INTO %I VALUES(%L)', 'locations', E'C:\\Program Files');
-<lineannotation>Result: </lineannotation><computeroutput>INSERT INTO locations VALUES(E'C:\\Program Files')</computeroutput>
+SELECT format('INSERT INTO %I VALUES(%L)', 'locations', 'C:\Program Files');
+<lineannotation>Result: </lineannotation><computeroutput>INSERT INTO locations VALUES('C:\Program Files')</computeroutput>
</screen>
</para>
@@ -3429,7 +3429,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
<secondary>concatenation</secondary>
</indexterm>
</entry>
- <entry><literal>E'\\\\Post'::bytea || E'\\047gres\\000'::bytea</literal></entry>
+ <entry><literal>'\\Post'::bytea || '\047gres\000'::bytea</literal></entry>
<entry><literal>\\Post'gres\000</literal></entry>
</row>
@@ -3442,7 +3442,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
</entry>
<entry><type>int</type></entry>
<entry>Number of bytes in binary string</entry>
- <entry><literal>octet_length(E'jo\\000se'::bytea)</literal></entry>
+ <entry><literal>octet_length('jo\000se'::bytea)</literal></entry>
<entry><literal>5</literal></entry>
</row>
@@ -3457,7 +3457,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
<entry>
Replace substring
</entry>
- <entry><literal>overlay(E'Th\\000omas'::bytea placing E'\\002\\003'::bytea from 2 for 3)</literal></entry>
+ <entry><literal>overlay('Th\000omas'::bytea placing '\002\003'::bytea from 2 for 3)</literal></entry>
<entry><literal>T\\002\\003mas</literal></entry>
</row>
@@ -3470,7 +3470,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
</entry>
<entry><type>int</type></entry>
<entry>Location of specified substring</entry>
- <entry><literal>position(E'\\000om'::bytea in E'Th\\000omas'::bytea)</literal></entry>
+ <entry><literal>position('\000om'::bytea in 'Th\000omas'::bytea)</literal></entry>
<entry><literal>3</literal></entry>
</row>
@@ -3485,7 +3485,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
<entry>
Extract substring
</entry>
- <entry><literal>substring(E'Th\\000omas'::bytea from 2 for 3)</literal></entry>
+ <entry><literal>substring('Th\000omas'::bytea from 2 for 3)</literal></entry>
<entry><literal>h\000o</literal></entry>
</row>
@@ -3504,7 +3504,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
<parameter>bytes</parameter> from the start
and end of <parameter>string</parameter>
</entry>
- <entry><literal>trim(E'\\000\\001'::bytea from E'\\000Tom\\001'::bytea)</literal></entry>
+ <entry><literal>trim('\000\001'::bytea from '\000Tom\001'::bytea)</literal></entry>
<entry><literal>Tom</literal></entry>
</row>
</tbody>
@@ -3547,7 +3547,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
<parameter>bytes</parameter> from the start and end of
<parameter>string</parameter>
</entry>
- <entry><literal>btrim(E'\\000trim\\001'::bytea, E'\\000\\001'::bytea)</literal></entry>
+ <entry><literal>btrim('\000trim\001'::bytea, '\000\001'::bytea)</literal></entry>
<entry><literal>trim</literal></entry>
</row>
@@ -3564,7 +3564,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
Decode binary data from textual representation in <parameter>string</parameter>.
Options for <parameter>format</parameter> are same as in <function>encode</function>.
</entry>
- <entry><literal>decode(E'123\\000456', 'escape')</literal></entry>
+ <entry><literal>decode('123\000456', 'escape')</literal></entry>
<entry><literal>123\000456</literal></entry>
</row>
@@ -3584,7 +3584,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
octal sequences (<literal>\</literal><replaceable>nnn</replaceable>) and
doubles backslashes.
</entry>
- <entry><literal>encode(E'123\\000456'::bytea, 'escape')</literal></entry>
+ <entry><literal>encode('123\000456'::bytea, 'escape')</literal></entry>
<entry><literal>123\000456</literal></entry>
</row>
@@ -3599,7 +3599,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
<entry>
Extract bit from string
</entry>
- <entry><literal>get_bit(E'Th\\000omas'::bytea, 45)</literal></entry>
+ <entry><literal>get_bit('Th\000omas'::bytea, 45)</literal></entry>
<entry><literal>1</literal></entry>
</row>
@@ -3614,7 +3614,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
<entry>
Extract byte from string
</entry>
- <entry><literal>get_byte(E'Th\\000omas'::bytea, 4)</literal></entry>
+ <entry><literal>get_byte('Th\000omas'::bytea, 4)</literal></entry>
<entry><literal>109</literal></entry>
</row>
@@ -3638,7 +3638,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
<see>binary strings, length</see>
</indexterm>
</entry>
- <entry><literal>length(E'jo\\000se'::bytea)</literal></entry>
+ <entry><literal>length('jo\000se'::bytea)</literal></entry>
<entry><literal>5</literal></entry>
</row>
@@ -3654,7 +3654,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
Calculates the MD5 hash of <parameter>string</parameter>,
returning the result in hexadecimal
</entry>
- <entry><literal>md5(E'Th\\000omas'::bytea)</literal></entry>
+ <entry><literal>md5('Th\000omas'::bytea)</literal></entry>
<entry><literal>8ab2d3c9689aaf18​b4958c334c82d8b1</literal></entry>
</row>
@@ -3670,7 +3670,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
<entry>
Set bit in string
</entry>
- <entry><literal>set_bit(E'Th\\000omas'::bytea, 45, 0)</literal></entry>
+ <entry><literal>set_bit('Th\000omas'::bytea, 45, 0)</literal></entry>
<entry><literal>Th\000omAs</literal></entry>
</row>
@@ -3686,7 +3686,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
<entry>
Set byte in string
</entry>
- <entry><literal>set_byte(E'Th\\000omas'::bytea, 4, 64)</literal></entry>
+ <entry><literal>set_byte('Th\000omas'::bytea, 4, 64)</literal></entry>
<entry><literal>Th\000o@as</literal></entry>
</row>
@@ -4377,7 +4377,7 @@ regexp_replace('foobarbaz', 'b..', 'X')
<lineannotation>fooXbaz</lineannotation>
regexp_replace('foobarbaz', 'b..', 'X', 'g')
<lineannotation>fooXX</lineannotation>
-regexp_replace('foobarbaz', 'b(..)', E'X\\1Y', 'g')
+regexp_replace('foobarbaz', 'b(..)', 'X\1Y', 'g')
<lineannotation>fooXarYXazY</lineannotation>
</programlisting>
</para>
@@ -4513,7 +4513,7 @@ SELECT col1, (SELECT regexp_matches(col2, '(bar)(beque)')) FROM tab;
Some examples:
<programlisting>
-SELECT foo FROM regexp_split_to_table('the quick brown fox jumps over the lazy dog', E'\\s+') AS foo;
+SELECT foo FROM regexp_split_to_table('the quick brown fox jumps over the lazy dog', '\s+') AS foo;
foo
-------
the
@@ -4527,13 +4527,13 @@ SELECT foo FROM regexp_split_to_table('the quick brown fox jumps over the lazy d
dog
(9 rows)
-SELECT regexp_split_to_array('the quick brown fox jumps over the lazy dog', E'\\s+');
+SELECT regexp_split_to_array('the quick brown fox jumps over the lazy dog', '\s+');
regexp_split_to_array
-----------------------------------------------
{the,quick,brown,fox,jumps,over,the,lazy,dog}
(1 row)
-SELECT foo FROM regexp_split_to_table('the quick brown fox', E'\\s*') AS foo;
+SELECT foo FROM regexp_split_to_table('the quick brown fox', '\s*') AS foo;
foo
-----
t
diff --git a/doc/src/sgml/lobj.sgml b/doc/src/sgml/lobj.sgml
index f56aeeb..7a9af9c 100644
--- a/doc/src/sgml/lobj.sgml
+++ b/doc/src/sgml/lobj.sgml
@@ -568,7 +568,7 @@ int lo_unlink(PGconn *conn, Oid lobjId);
Create a large object and store data there, returning its OID.
Pass <literal>0</literal> to have the system choose an OID.
</entry>
- <entry><literal>lo_from_bytea(0, E'\\xffffff00')</literal></entry>
+ <entry><literal>lo_from_bytea(0, '\xffffff00')</literal></entry>
<entry><literal>24528</literal></entry>
</row>
@@ -583,7 +583,7 @@ int lo_unlink(PGconn *conn, Oid lobjId);
<entry>
Write data at the given offset.
</entry>
- <entry><literal>lo_put(24528, 1, E'\\xaa')</literal></entry>
+ <entry><literal>lo_put(24528, 1, '\xaa')</literal></entry>
<entry></entry>
</row>
diff --git a/doc/src/sgml/rowtypes.sgml b/doc/src/sgml/rowtypes.sgml
index 2f924b1..a6f4f67 100644
--- a/doc/src/sgml/rowtypes.sgml
+++ b/doc/src/sgml/rowtypes.sgml
@@ -510,7 +510,7 @@ SELECT c.somefunc FROM inventory_item c;
containing a double quote and a backslash in a composite
value, you'd need to write:
<programlisting>
-INSERT ... VALUES (E'("\\"\\\\")');
+INSERT ... VALUES ('("\"\\")');
</programlisting>
The string-literal processor removes one level of backslashes, so that
what arrives at the composite-value parser looks like
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #15373: null / utf-8
@ 2018-09-14 19:49 'Bruce Momjian' <bruce@momjian.us>
parent: 'Bruce Momjian' <bruce@momjian.us>
0 siblings, 1 reply; 6+ messages in thread
From: Bruce Momjian @ 2018-09-14 19:49 UTC (permalink / raw)
To: André Hänsel <andre@webkr.de>; +Cc: orchideric@yahoo.com; pgsql-bugs@lists.postgresql.org
On Fri, Sep 14, 2018 at 10:15:48AM +0200, André Hänsel wrote:
> Bruce Momjian wrote:
> > I have developed the attached documentation patch to remove the E''
> > syntax. standard_conforming_strings defaulted to 'on' in PG 9.1.
>
> On https://www.postgresql.org/docs/current/static/arrays.html, there
> is a note at the bottom with an example currently using the C-style
> escape syntax. Your patch changes that, as agreed, but then the text
> of the note, as it is at the moment, doesn't make sense anymore
> because the note is about the doubling of backslashes that you have
> with C-style escape string literals.
Wow, good you saw that. I removed that entire paragraph since there is
no longer double-escape evaluation by default. Updated patch attached.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +
Attachments:
escape.diff (text/x-diff, 20.5K) download
diff --git a/doc/src/sgml/array.sgml b/doc/src/sgml/array.sgml
index f4d4a61..a473fa8 100644
--- a/doc/src/sgml/array.sgml
+++ b/doc/src/sgml/array.sgml
@@ -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
diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml
index 3d36cca..f9458c9 100644
--- a/doc/src/sgml/datatype.sgml
+++ b/doc/src/sgml/datatype.sgml
@@ -1296,7 +1296,7 @@ SELECT b, char_length(b) FROM test2;
strings are distinguished from character strings in two
ways. First, binary strings specifically allow storing
octets of value zero and other <quote>non-printable</quote>
- octets (usually, octets outside the range 32 to 126).
+ octets (usually, octets outside the decimal range 32 to 126).
Character strings disallow zero octets, and also disallow any
other octet values and sequences of octet values that are invalid
according to the database's selected character set encoding.
@@ -1308,9 +1308,10 @@ SELECT b, char_length(b) FROM test2;
</para>
<para>
- The <type>bytea</type> type supports two external formats for
- input and output: <productname>PostgreSQL</productname>'s historical
- <quote>escape</quote> format, and <quote>hex</quote> format. Both
+ The <type>bytea</type> type supports two
+ formats for input and output: <quote>hex</quote> format
+ and <productname>PostgreSQL</productname>'s historical
+ <quote>escape</quote> format. Both
of these are always accepted on input. The output format depends
on the configuration parameter <xref linkend="guc-bytea-output"/>;
the default is hex. (Note that the hex format was introduced in
@@ -1348,7 +1349,7 @@ SELECT b, char_length(b) FROM test2;
<para>
Example:
<programlisting>
-SELECT E'\\xDEADBEEF';
+SELECT '\xDEADBEEF';
</programlisting>
</para>
</sect2>
@@ -1368,7 +1369,7 @@ SELECT E'\\xDEADBEEF';
convenient. But in practice it is usually confusing because it
fuzzes up the distinction between binary strings and character
strings, and also the particular escape mechanism that was chosen is
- somewhat unwieldy. So this format should probably be avoided
+ somewhat unwieldy. Therefore, this format should probably be avoided
for most new applications.
</para>
@@ -1381,7 +1382,7 @@ SELECT E'\\xDEADBEEF';
octal value and precede it
by a backslash (or two backslashes, if writing the value as a
literal using escape string syntax).
- Backslash itself (octet value 92) can alternatively be represented by
+ Backslash itself (octet decimal value 92) can alternatively be represented by
double backslashes.
<xref linkend="datatype-binary-sqlesc"/>
shows the characters that must be escaped, and gives the alternative
@@ -1405,33 +1406,33 @@ SELECT E'\\xDEADBEEF';
<row>
<entry>0</entry>
<entry>zero octet</entry>
- <entry><literal>E'\\000'</literal></entry>
- <entry><literal>SELECT E'\\000'::bytea;</literal></entry>
- <entry><literal>\000</literal></entry>
+ <entry><literal>'\000'</literal></entry>
+ <entry><literal>SELECT '\000'::bytea;</literal></entry>
+ <entry><literal>\x00</literal></entry>
</row>
<row>
<entry>39</entry>
<entry>single quote</entry>
- <entry><literal>''''</literal> or <literal>E'\\047'</literal></entry>
- <entry><literal>SELECT E'\''::bytea;</literal></entry>
- <entry><literal>'</literal></entry>
+ <entry><literal>''''</literal> or <literal>'\047'</literal></entry>
+ <entry><literal>SELECT ''''::bytea;</literal></entry>
+ <entry><literal>\x27</literal></entry>
</row>
<row>
<entry>92</entry>
<entry>backslash</entry>
- <entry><literal>E'\\\\'</literal> or <literal>E'\\134'</literal></entry>
- <entry><literal>SELECT E'\\\\'::bytea;</literal></entry>
- <entry><literal>\\</literal></entry>
+ <entry><literal>'\'</literal> or <literal>'\\134'</literal></entry>
+ <entry><literal>SELECT '\\'::bytea;</literal></entry>
+ <entry><literal>\x5c</literal></entry>
</row>
<row>
<entry>0 to 31 and 127 to 255</entry>
<entry><quote>non-printable</quote> octets</entry>
- <entry><literal>E'\\<replaceable>xxx'</replaceable></literal> (octal value)</entry>
- <entry><literal>SELECT E'\\001'::bytea;</literal></entry>
- <entry><literal>\001</literal></entry>
+ <entry><literal>'\<replaceable>xxx'</replaceable></literal> (octal value)</entry>
+ <entry><literal>SELECT '\001'::bytea;</literal></entry>
+ <entry><literal>\x01</literal></entry>
</row>
</tbody>
@@ -1459,7 +1460,7 @@ SELECT E'\\xDEADBEEF';
of escaping.) The remaining backslash is then recognized by the
<type>bytea</type> input function as starting either a three
digit octal value or escaping another backslash. For example,
- a string literal passed to the server as <literal>E'\\001'</literal>
+ a string literal passed to the server as <literal>'\001'</literal>
becomes <literal>\001</literal> after passing through the
escape string parser. The <literal>\001</literal> is then sent
to the <type>bytea</type> input function, where it is converted
@@ -1470,12 +1471,24 @@ SELECT E'\\xDEADBEEF';
</para>
<para>
- <type>Bytea</type> octets are sometimes escaped when output. In general, each
- <quote>non-printable</quote> octet is converted into
- its equivalent three-digit octal value and preceded by one backslash.
- Most <quote>printable</quote> octets are represented by their standard
- representation in the client character set. The octet with decimal
- value 92 (backslash) is doubled in the output.
+ <type>Bytea</type> octets are output in <literal>hex</literal>
+ format by default. If you change <xref linkend="guc-bytea-output"/>
+ to <literal>escape</literal>,
+ <quote>non-printable</quote> octet are converted to
+ equivalent three-digit octal value and preceded by one backslash.
+ Most <quote>printable</quote> octets are output by their standard
+ representation in the client character set, e.g.:
+
+<programlisting>
+SET bytea_output = 'escape';
+
+SELECT 'abc \153\154\155 \052\251\124'::bytea;
+ bytea
+----------------
+ abc klm *\251T
+</programlisting>
+
+ The octet with decimal value 92 (backslash) is doubled in the output.
Details are in <xref linkend="datatype-binary-resesc"/>.
</para>
@@ -1498,7 +1511,7 @@ SELECT E'\\xDEADBEEF';
<entry>92</entry>
<entry>backslash</entry>
<entry><literal>\\</literal></entry>
- <entry><literal>SELECT E'\\134'::bytea;</literal></entry>
+ <entry><literal>SELECT '\134'::bytea;</literal></entry>
<entry><literal>\\</literal></entry>
</row>
@@ -1506,7 +1519,7 @@ SELECT E'\\xDEADBEEF';
<entry>0 to 31 and 127 to 255</entry>
<entry><quote>non-printable</quote> octets</entry>
<entry><literal>\<replaceable>xxx</replaceable></literal> (octal value)</entry>
- <entry><literal>SELECT E'\\001'::bytea;</literal></entry>
+ <entry><literal>SELECT '\001'::bytea;</literal></entry>
<entry><literal>\001</literal></entry>
</row>
@@ -1514,7 +1527,7 @@ SELECT E'\\xDEADBEEF';
<entry>32 to 126</entry>
<entry><quote>printable</quote> octets</entry>
<entry>client character set representation</entry>
- <entry><literal>SELECT E'\\176'::bytea;</literal></entry>
+ <entry><literal>SELECT '\176'::bytea;</literal></entry>
<entry><literal>~</literal></entry>
</row>
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 4331beb..c44417d 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -1776,7 +1776,7 @@
octal sequences (<literal>\</literal><replaceable>nnn</replaceable>) and
doubles backslashes.
</entry>
- <entry><literal>encode(E'123\\000\\001', 'base64')</literal></entry>
+ <entry><literal>encode('123\000\001', 'base64')</literal></entry>
<entry><literal>MTIzAAE=</literal></entry>
</row>
@@ -2100,7 +2100,7 @@
the delimiter. See <xref linkend="functions-posix-regexp"/> for more
information.
</entry>
- <entry><literal>regexp_split_to_array('hello world', E'\\s+')</literal></entry>
+ <entry><literal>regexp_split_to_array('hello world', '\s+')</literal></entry>
<entry><literal>{hello,world}</literal></entry>
</row>
@@ -2117,7 +2117,7 @@
the delimiter. See <xref linkend="functions-posix-regexp"/> for more
information.
</entry>
- <entry><literal>regexp_split_to_table('hello world', E'\\s+')</literal></entry>
+ <entry><literal>regexp_split_to_table('hello world', '\s+')</literal></entry>
<entry><literal>hello</literal><para><literal>world</literal></para> (2 rows)</entry>
</row>
@@ -3301,8 +3301,8 @@ SELECT format('Testing %s, %s, %s, %%', 'one', 'two', 'three');
SELECT format('INSERT INTO %I VALUES(%L)', 'Foo bar', E'O\'Reilly');
<lineannotation>Result: </lineannotation><computeroutput>INSERT INTO "Foo bar" VALUES('O''Reilly')</computeroutput>
-SELECT format('INSERT INTO %I VALUES(%L)', 'locations', E'C:\\Program Files');
-<lineannotation>Result: </lineannotation><computeroutput>INSERT INTO locations VALUES(E'C:\\Program Files')</computeroutput>
+SELECT format('INSERT INTO %I VALUES(%L)', 'locations', 'C:\Program Files');
+<lineannotation>Result: </lineannotation><computeroutput>INSERT INTO locations VALUES('C:\Program Files')</computeroutput>
</screen>
</para>
@@ -3429,7 +3429,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
<secondary>concatenation</secondary>
</indexterm>
</entry>
- <entry><literal>E'\\\\Post'::bytea || E'\\047gres\\000'::bytea</literal></entry>
+ <entry><literal>'\\Post'::bytea || '\047gres\000'::bytea</literal></entry>
<entry><literal>\\Post'gres\000</literal></entry>
</row>
@@ -3442,7 +3442,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
</entry>
<entry><type>int</type></entry>
<entry>Number of bytes in binary string</entry>
- <entry><literal>octet_length(E'jo\\000se'::bytea)</literal></entry>
+ <entry><literal>octet_length('jo\000se'::bytea)</literal></entry>
<entry><literal>5</literal></entry>
</row>
@@ -3457,7 +3457,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
<entry>
Replace substring
</entry>
- <entry><literal>overlay(E'Th\\000omas'::bytea placing E'\\002\\003'::bytea from 2 for 3)</literal></entry>
+ <entry><literal>overlay('Th\000omas'::bytea placing '\002\003'::bytea from 2 for 3)</literal></entry>
<entry><literal>T\\002\\003mas</literal></entry>
</row>
@@ -3470,7 +3470,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
</entry>
<entry><type>int</type></entry>
<entry>Location of specified substring</entry>
- <entry><literal>position(E'\\000om'::bytea in E'Th\\000omas'::bytea)</literal></entry>
+ <entry><literal>position('\000om'::bytea in 'Th\000omas'::bytea)</literal></entry>
<entry><literal>3</literal></entry>
</row>
@@ -3485,7 +3485,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
<entry>
Extract substring
</entry>
- <entry><literal>substring(E'Th\\000omas'::bytea from 2 for 3)</literal></entry>
+ <entry><literal>substring('Th\000omas'::bytea from 2 for 3)</literal></entry>
<entry><literal>h\000o</literal></entry>
</row>
@@ -3504,7 +3504,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
<parameter>bytes</parameter> from the start
and end of <parameter>string</parameter>
</entry>
- <entry><literal>trim(E'\\000\\001'::bytea from E'\\000Tom\\001'::bytea)</literal></entry>
+ <entry><literal>trim('\000\001'::bytea from '\000Tom\001'::bytea)</literal></entry>
<entry><literal>Tom</literal></entry>
</row>
</tbody>
@@ -3547,7 +3547,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
<parameter>bytes</parameter> from the start and end of
<parameter>string</parameter>
</entry>
- <entry><literal>btrim(E'\\000trim\\001'::bytea, E'\\000\\001'::bytea)</literal></entry>
+ <entry><literal>btrim('\000trim\001'::bytea, '\000\001'::bytea)</literal></entry>
<entry><literal>trim</literal></entry>
</row>
@@ -3564,7 +3564,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
Decode binary data from textual representation in <parameter>string</parameter>.
Options for <parameter>format</parameter> are same as in <function>encode</function>.
</entry>
- <entry><literal>decode(E'123\\000456', 'escape')</literal></entry>
+ <entry><literal>decode('123\000456', 'escape')</literal></entry>
<entry><literal>123\000456</literal></entry>
</row>
@@ -3584,7 +3584,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
octal sequences (<literal>\</literal><replaceable>nnn</replaceable>) and
doubles backslashes.
</entry>
- <entry><literal>encode(E'123\\000456'::bytea, 'escape')</literal></entry>
+ <entry><literal>encode('123\000456'::bytea, 'escape')</literal></entry>
<entry><literal>123\000456</literal></entry>
</row>
@@ -3599,7 +3599,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
<entry>
Extract bit from string
</entry>
- <entry><literal>get_bit(E'Th\\000omas'::bytea, 45)</literal></entry>
+ <entry><literal>get_bit('Th\000omas'::bytea, 45)</literal></entry>
<entry><literal>1</literal></entry>
</row>
@@ -3614,7 +3614,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
<entry>
Extract byte from string
</entry>
- <entry><literal>get_byte(E'Th\\000omas'::bytea, 4)</literal></entry>
+ <entry><literal>get_byte('Th\000omas'::bytea, 4)</literal></entry>
<entry><literal>109</literal></entry>
</row>
@@ -3638,7 +3638,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
<see>binary strings, length</see>
</indexterm>
</entry>
- <entry><literal>length(E'jo\\000se'::bytea)</literal></entry>
+ <entry><literal>length('jo\000se'::bytea)</literal></entry>
<entry><literal>5</literal></entry>
</row>
@@ -3654,7 +3654,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
Calculates the MD5 hash of <parameter>string</parameter>,
returning the result in hexadecimal
</entry>
- <entry><literal>md5(E'Th\\000omas'::bytea)</literal></entry>
+ <entry><literal>md5('Th\000omas'::bytea)</literal></entry>
<entry><literal>8ab2d3c9689aaf18​b4958c334c82d8b1</literal></entry>
</row>
@@ -3670,7 +3670,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
<entry>
Set bit in string
</entry>
- <entry><literal>set_bit(E'Th\\000omas'::bytea, 45, 0)</literal></entry>
+ <entry><literal>set_bit('Th\000omas'::bytea, 45, 0)</literal></entry>
<entry><literal>Th\000omAs</literal></entry>
</row>
@@ -3686,7 +3686,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
<entry>
Set byte in string
</entry>
- <entry><literal>set_byte(E'Th\\000omas'::bytea, 4, 64)</literal></entry>
+ <entry><literal>set_byte('Th\000omas'::bytea, 4, 64)</literal></entry>
<entry><literal>Th\000o@as</literal></entry>
</row>
@@ -4377,7 +4377,7 @@ regexp_replace('foobarbaz', 'b..', 'X')
<lineannotation>fooXbaz</lineannotation>
regexp_replace('foobarbaz', 'b..', 'X', 'g')
<lineannotation>fooXX</lineannotation>
-regexp_replace('foobarbaz', 'b(..)', E'X\\1Y', 'g')
+regexp_replace('foobarbaz', 'b(..)', 'X\1Y', 'g')
<lineannotation>fooXarYXazY</lineannotation>
</programlisting>
</para>
@@ -4513,7 +4513,7 @@ SELECT col1, (SELECT regexp_matches(col2, '(bar)(beque)')) FROM tab;
Some examples:
<programlisting>
-SELECT foo FROM regexp_split_to_table('the quick brown fox jumps over the lazy dog', E'\\s+') AS foo;
+SELECT foo FROM regexp_split_to_table('the quick brown fox jumps over the lazy dog', '\s+') AS foo;
foo
-------
the
@@ -4527,13 +4527,13 @@ SELECT foo FROM regexp_split_to_table('the quick brown fox jumps over the lazy d
dog
(9 rows)
-SELECT regexp_split_to_array('the quick brown fox jumps over the lazy dog', E'\\s+');
+SELECT regexp_split_to_array('the quick brown fox jumps over the lazy dog', '\s+');
regexp_split_to_array
-----------------------------------------------
{the,quick,brown,fox,jumps,over,the,lazy,dog}
(1 row)
-SELECT foo FROM regexp_split_to_table('the quick brown fox', E'\\s*') AS foo;
+SELECT foo FROM regexp_split_to_table('the quick brown fox', '\s*') AS foo;
foo
-----
t
diff --git a/doc/src/sgml/lobj.sgml b/doc/src/sgml/lobj.sgml
index f56aeeb..7a9af9c 100644
--- a/doc/src/sgml/lobj.sgml
+++ b/doc/src/sgml/lobj.sgml
@@ -568,7 +568,7 @@ int lo_unlink(PGconn *conn, Oid lobjId);
Create a large object and store data there, returning its OID.
Pass <literal>0</literal> to have the system choose an OID.
</entry>
- <entry><literal>lo_from_bytea(0, E'\\xffffff00')</literal></entry>
+ <entry><literal>lo_from_bytea(0, '\xffffff00')</literal></entry>
<entry><literal>24528</literal></entry>
</row>
@@ -583,7 +583,7 @@ int lo_unlink(PGconn *conn, Oid lobjId);
<entry>
Write data at the given offset.
</entry>
- <entry><literal>lo_put(24528, 1, E'\\xaa')</literal></entry>
+ <entry><literal>lo_put(24528, 1, '\xaa')</literal></entry>
<entry></entry>
</row>
diff --git a/doc/src/sgml/rowtypes.sgml b/doc/src/sgml/rowtypes.sgml
index 2f924b1..a6f4f67 100644
--- a/doc/src/sgml/rowtypes.sgml
+++ b/doc/src/sgml/rowtypes.sgml
@@ -510,7 +510,7 @@ SELECT c.somefunc FROM inventory_item c;
containing a double quote and a backslash in a composite
value, you'd need to write:
<programlisting>
-INSERT ... VALUES (E'("\\"\\\\")');
+INSERT ... VALUES ('("\"\\")');
</programlisting>
The string-literal processor removes one level of backslashes, so that
what arrives at the composite-value parser looks like
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #15373: null / utf-8
@ 2018-09-21 23:55 'Bruce Momjian' <bruce@momjian.us>
parent: 'Bruce Momjian' <bruce@momjian.us>
0 siblings, 0 replies; 6+ messages in thread
From: Bruce Momjian @ 2018-09-21 23:55 UTC (permalink / raw)
To: André Hänsel <andre@webkr.de>; +Cc: orchideric@yahoo.com; pgsql-bugs@lists.postgresql.org
On Fri, Sep 14, 2018 at 03:49:17PM -0400, 'Bruce Momjian' wrote:
> On Fri, Sep 14, 2018 at 10:15:48AM +0200, André Hänsel wrote:
> > Bruce Momjian wrote:
> > > I have developed the attached documentation patch to remove the E''
> > > syntax. standard_conforming_strings defaulted to 'on' in PG 9.1.
> >
> > On https://www.postgresql.org/docs/current/static/arrays.html, there
> > is a note at the bottom with an example currently using the C-style
> > escape syntax. Your patch changes that, as agreed, but then the text
> > of the note, as it is at the moment, doesn't make sense anymore
> > because the note is about the doubling of backslashes that you have
> > with C-style escape string literals.
>
> Wow, good you saw that. I removed that entire paragraph since there is
> no longer double-escape evaluation by default. Updated patch attached.
Patch applied through 9.3. Thanks for the report.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2018-09-21 23:55 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-09-08 17:24 BUG #15373: null / utf-8 PG Bug reporting form <noreply@postgresql.org>
2018-09-08 17:36 ` Bruce Momjian <bruce@momjian.us>
2018-09-08 20:36 ` 'Bruce Momjian' <bruce@momjian.us>
2018-09-14 02:20 ` 'Bruce Momjian' <bruce@momjian.us>
2018-09-14 19:49 ` 'Bruce Momjian' <bruce@momjian.us>
2018-09-21 23:55 ` 'Bruce Momjian' <bruce@momjian.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox