From da58bee70af5ee84362a000ab2ab726e20f12df8 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Sat, 26 Mar 2011 11:19:01 +0000 Subject: [PATCH] Added documentation for the bytea parser --- NEWS | 2 ++ doc/src/faq.rst | 4 +++- doc/src/usage.rst | 23 ++++++++++++----------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/NEWS b/NEWS index 1eea8af6..8aef82e2 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,8 @@ What's new in psycopg 2.4.1 --------------------------- + - Use own parser for bytea output, not requiring anymore the libpq 9.0 + to parse the hex format. - Correctly detect an empty query sent to the backend (ticket #46). diff --git a/doc/src/faq.rst b/doc/src/faq.rst index 642c3e78..4ebf15a5 100644 --- a/doc/src/faq.rst +++ b/doc/src/faq.rst @@ -97,7 +97,9 @@ Psycopg converts :sql:`decimal`\/\ :sql:`numeric` database types into Python `!D Transferring binary data from PostgreSQL 9.0 doesn't work. PostgreSQL 9.0 uses by default `the "hex" format`__ to transfer :sql:`bytea` data: the format can't be parsed by the libpq 8.4 and - earlier. Three options to solve the problem are: + earlier. The problem is solved in Psycopg 2.4.1, that uses its own parser + for the :sql:`bytea` format. For previous Psycopg releases, three options + to solve the problem are: - set the bytea_output__ parameter to ``escape`` in the server; - execute the database command ``SET bytea_output TO escape;`` in the diff --git a/doc/src/usage.rst b/doc/src/usage.rst index 47b78bec..4d039dee 100644 --- a/doc/src/usage.rst +++ b/doc/src/usage.rst @@ -271,6 +271,10 @@ the SQL string that would be sent to the database. .. versionchanged:: 2.4 only strings were supported before. + .. versionchanged:: 2.4.1 + can parse the 'hex' format from 9.0 servers without relying on the + version of the client library. + .. note:: In Python 2, if you have binary data in a `!str` object, you can pass them @@ -282,18 +286,15 @@ the SQL string that would be sent to the database. .. warning:: - PostgreSQL 9 uses by default `a new "hex" format`__ to emit :sql:`bytea` - fields. Unfortunately this format can't be parsed by libpq versions - before 9.0. This means that using a library client with version lesser - than 9.0 to talk with a server 9.0 or later you may have problems - receiving :sql:`bytea` data. To work around this problem you can set the - `bytea_output`__ parameter to ``escape``, either in the server - configuration or in the client session using a query such as ``SET - bytea_output TO escape;`` before trying to receive binary data. + Since version 9.0 PostgreSQL uses by default `a new "hex" format`__ to + emit :sql:`bytea` fields. Starting from Psycopg 2.4.1 the format is + correctly supported. If you use a previous version you will need some + extra care when receiving bytea from PostgreSQL: you must have at least + the libpq 9.0 installed on the client or alternatively you can set the + `bytea_output`__ configutation parameter to ``escape``, either in the + server configuration file or in the client session (using a query such as + ``SET bytea_output TO escape;``) before receiving binary data. - Starting from Psycopg 2.4 this condition is detected and signaled with a - `~psycopg2.InterfaceError`. - .. __: http://www.postgresql.org/docs/9.0/static/datatype-binary.html .. __: http://www.postgresql.org/docs/9.0/static/runtime-config-client.html#GUC-BYTEA-OUTPUT