Skip to content

Commit 888fda8

Browse files
committed
Clarify documentation for libpq's PQescapeBytea to mention the new hex
format. Modify PQescapeStringConn() docs to be consisent with other escaping functions. Add mention problems with pre-9.0 versions of libpq using not understanding bytea hex format to the 9.0 release notes. Backpatch to 9.0 docs.
1 parent d5478c3 commit 888fda8

File tree

2 files changed

+20
-29
lines changed

2 files changed

+20
-29
lines changed

doc/src/sgml/libpq.sgml

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3256,23 +3256,25 @@ size_t PQescapeStringConn(PGconn *conn,
32563256

32573257
<listitem>
32583258
<para>
3259+
<function>PQescapeString</> is an older, deprecated version of
3260+
<function>PQescapeStringConn</>.
32593261
<synopsis>
32603262
size_t PQescapeString (char *to, const char *from, size_t length);
32613263
</synopsis>
32623264
</para>
32633265

32643266
<para>
3265-
<function>PQescapeString</> is an older, deprecated version of
3266-
<function>PQescapeStringConn</>; the difference is that it does
3267-
not take <parameter>conn</> or <parameter>error</> parameters.
3267+
The only difference from <function>PQescapeStringConn</> is that
3268+
<function>PQescapeString</> does not take <structname>PGconn</>
3269+
or <parameter>error</> parameters.
32683270
Because of this, it cannot adjust its behavior depending on the
32693271
connection properties (such as character encoding) and therefore
32703272
<emphasis>it might give the wrong results</>. Also, it has no way
32713273
to report error conditions.
32723274
</para>
32733275

32743276
<para>
3275-
<function>PQescapeString</> can be used safely in single-threaded
3277+
<function>PQescapeString</> can be used safely in
32763278
client programs that work with only one <productname>PostgreSQL</>
32773279
connection at a time (in this case it can find out what it needs to
32783280
know <quote>behind the scenes</>). In other contexts it is a security
@@ -3304,16 +3306,11 @@ unsigned char *PQescapeByteaConn(PGconn *conn,
33043306
</para>
33053307

33063308
<para>
3307-
Certain byte values <emphasis>must</emphasis> be escaped (but all
3308-
byte values <emphasis>can</emphasis> be escaped) when used as part
3309-
of a <type>bytea</type> literal in an <acronym>SQL</acronym>
3310-
statement. In general, to escape a byte, it is converted into the
3311-
three digit octal number equal to the octet value, and preceded by
3312-
usually two backslashes. The single quote (<literal>'</>) and backslash
3313-
(<literal>\</>) characters have special alternative escape
3314-
sequences. See <xref linkend="datatype-binary"> for more
3315-
information. <function>PQescapeByteaConn</function> performs this
3316-
operation, escaping only the minimally required bytes.
3309+
Certain byte values must be escaped when used as part of a
3310+
<type>bytea</type> literal in an <acronym>SQL</acronym> statement.
3311+
<function>PQescapeByteaConn</function> escapes bytes using
3312+
either hex encoding or backslash escaping. See <xref
3313+
linkend="datatype-binary"> for more information.
33173314
</para>
33183315

33193316
<para>
@@ -3370,20 +3367,13 @@ unsigned char *PQescapeBytea(const unsigned char *from,
33703367
<para>
33713368
The only difference from <function>PQescapeByteaConn</> is that
33723369
<function>PQescapeBytea</> does not take a <structname>PGconn</>
3373-
parameter. Because of this, it cannot adjust its behavior
3374-
depending on the connection properties (in particular, whether
3375-
standard-conforming strings are enabled) and therefore
3376-
<emphasis>it might give the wrong results</>. Also, it has no
3377-
way to return an error message on failure.
3378-
</para>
3379-
3380-
<para>
3381-
<function>PQescapeBytea</> can be used safely in single-threaded
3382-
client programs that work with only one <productname>PostgreSQL</>
3383-
connection at a time (in this case it can find out what it needs
3384-
to know <quote>behind the scenes</>). In other contexts it is
3385-
a security hazard and should be avoided in favor of
3386-
<function>PQescapeByteaConn</>.
3370+
parameter. Because of this, <function>PQescapeBytea</> can
3371+
only be used safely in client programs that use a single
3372+
<productname>PostgreSQL</> connection at a time (in this case
3373+
it can find out what it needs to know <quote>behind the
3374+
scenes</>). It <emphasis>might give the wrong results</> if
3375+
used in programs that use multiple database connections (use
3376+
<function>PQescapeByteaConn</> in such cases).
33873377
</para>
33883378
</listitem>
33893379
</varlistentry>

doc/src/sgml/release-9.0.sgml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2342,7 +2342,8 @@
23422342
whether hex or traditional format is used for <type>bytea</>
23432343
output. Libpq's <function>PQescapeByteaConn()</> function automatically
23442344
uses the hex format when connected to <productname>PostgreSQL</> 9.0
2345-
or newer servers.
2345+
or newer servers. However, pre-9.0 libpq versions will not
2346+
correctly process hex format from newer servers.
23462347
</para>
23472348

23482349
<para>

0 commit comments

Comments
 (0)