-
+
Data Types
- When entering bytea values, octets of certain values
- must be escaped (but all octet values
- can be escaped) when used as part of a string
- literal in an
SQL statement. In general, to
- escape an octet, it is converted into the three-digit octal number
- equivalent of its decimal octet value, and preceded by two
- backslashes. shows the
- characters that must be escaped, and gives the alternate escape
- sequences where applicable.
+ When entering bytea values, octets of certain
+ values must be escaped (but all octet
+ values can be escaped) when used as part
+ of a string literal in an
SQL statement. In
+ general, to escape an octet, it is converted into the three-digit
+ octal number equivalent of its decimal octet value, and preceded
+ by two backslashes (or one backslash if
+ standard_conforming_strings> is off>).
+ shows the characters
+ that must be escaped, and gives the alternate escape sequences
+ where applicable.
- The reason that you have to write so many backslashes, as shown in
- , is that an input string
- written as a string literal must pass through two parse phases in
- the
PostgreSQL server. The first
- backslash of each pair is interpreted as an escape character by
- the string-literal parser and is therefore consumed, leaving the
- second backslash of the pair. The remaining backslash is then
- recognized by the bytea input function as starting
- either a three digit octal value or escaping another backslash.
- For example, a string literal passed to the server as
- '\\001' becomes \001 after
- passing through the string-literal parser. The
- \001 is then sent to the bytea
- input function, where it is converted to a single octet with a
- decimal value of 1. Note that the apostrophe character is not
- treated specially by bytea, so it follows the normal
- rules for string literals. (See also
- linkend="sql-syntax-strings">.)
+ The reason that you have to write so many backslashes, as shown
+ in , is that an input
+ string written as a string literal must pass through two parse
+ phases in the
PostgreSQL server.
+ The first backslash of each pair is interpreted as an escape
+ character by the string-literal parser (assuming
+ standard_conforming_strings> is off>)
+ and is therefore consumed, leaving the second backslash of the
+ pair. The remaining backslash is then recognized by the
+ bytea input function as starting either a three
+ digit octal value or escaping another backslash. For example,
+ a string literal passed to the server as '\\001'
+ becomes \001 after passing through the
+ string-literal parser. The \001 is then sent
+ to the bytea input function, where it is converted
+ to a single octet with a decimal value of 1. Note that the
+ apostrophe character is not treated specially by bytea,
+ so it follows the normal rules for string literals. (See also
+ .)