Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitab79444

Browse files
committed
Add "(assuming <varname>standard_conforming_strings</> is
<literal>off</>)" clauses for bytea.
1 parent5f78aa5 commitab79444

File tree

1 file changed

+31
-28
lines changed

1 file changed

+31
-28
lines changed

‎doc/src/sgml/datatype.sgml

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.180 2006/10/2318:10:30 petere Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.181 2006/11/2304:27:33 momjian Exp $ -->
22

33
<chapter id="datatype">
44
<title id="datatype-title">Data Types</title>
@@ -1097,15 +1097,17 @@ SELECT b, char_length(b) FROM test2;
10971097
</para>
10981098

10991099
<para>
1100-
When entering <type>bytea</type> values, octets of certain values
1101-
<emphasis>must</emphasis> be escaped (but all octet values
1102-
<emphasis>can</emphasis> be escaped) when used as part of a string
1103-
literal in an <acronym>SQL</acronym> statement. In general, to
1104-
escape an octet, it is converted into the three-digit octal number
1105-
equivalent of its decimal octet value, and preceded by two
1106-
backslashes. <xref linkend="datatype-binary-sqlesc"> shows the
1107-
characters that must be escaped, and gives the alternate escape
1108-
sequences where applicable.
1100+
When entering <type>bytea</type> values, octets of certain
1101+
values <emphasis>must</emphasis> be escaped (but all octet
1102+
values <emphasis>can</emphasis> be escaped) when used as part
1103+
of a string literal in an <acronym>SQL</acronym> statement. In
1104+
general, to escape an octet, it is converted into the three-digit
1105+
octal number equivalent of its decimal octet value, and preceded
1106+
by two backslashes (or one backslash if
1107+
<varname>standard_conforming_strings</> is <literal>off</>).
1108+
<xref linkend="datatype-binary-sqlesc"> shows the characters
1109+
that must be escaped, and gives the alternate escape sequences
1110+
where applicable.
11091111
</para>
11101112

11111113
<table id="datatype-binary-sqlesc">
@@ -1168,24 +1170,25 @@ SELECT b, char_length(b) FROM test2;
11681170
</para>
11691171

11701172
<para>
1171-
The reason that you have to write so many backslashes, as shown in
1172-
<xref linkend="datatype-binary-sqlesc">, is that an input string
1173-
written as a string literal must pass through two parse phases in
1174-
the <productname>PostgreSQL</productname> server. The first
1175-
backslash of each pair is interpreted as an escape character by
1176-
the string-literal parser and is therefore consumed, leaving the
1177-
second backslash of the pair. The remaining backslash is then
1178-
recognized by the <type>bytea</type> input function as starting
1179-
either a three digit octal value or escaping another backslash.
1180-
For example, a string literal passed to the server as
1181-
<literal>'\\001'</literal> becomes <literal>\001</literal> after
1182-
passing through the string-literal parser. The
1183-
<literal>\001</literal> is then sent to the <type>bytea</type>
1184-
input function, where it is converted to a single octet with a
1185-
decimal value of 1. Note that the apostrophe character is not
1186-
treated specially by <type>bytea</type>, so it follows the normal
1187-
rules for string literals. (See also <xref
1188-
linkend="sql-syntax-strings">.)
1173+
The reason that you have to write so many backslashes, as shown
1174+
in <xref linkend="datatype-binary-sqlesc">, is that an input
1175+
string written as a string literal must pass through two parse
1176+
phases in the <productname>PostgreSQL</productname> server.
1177+
The first backslash of each pair is interpreted as an escape
1178+
character by the string-literal parser (assuming
1179+
<varname>standard_conforming_strings</> is <literal>off</>)
1180+
and is therefore consumed, leaving the second backslash of the
1181+
pair. The remaining backslash is then recognized by the
1182+
<type>bytea</type> input function as starting either a three
1183+
digit octal value or escaping another backslash. For example,
1184+
a string literal passed to the server as <literal>'\\001'</literal>
1185+
becomes <literal>\001</literal> after passing through the
1186+
string-literal parser. The <literal>\001</literal> is then sent
1187+
to the <type>bytea</type> input function, where it is converted
1188+
to a single octet with a decimal value of 1. Note that the
1189+
apostrophe character is not treated specially by <type>bytea</type>,
1190+
so it follows the normal rules for string literals. (See also
1191+
<xref linkend="sql-syntax-strings">.)
11891192
</para>
11901193

11911194
<para>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp