Skip to content

Commit b4c3b20

Browse files
author
James William Pye
committed
Add section discussing binary typio related issues.
1 parent 886a592 commit b4c3b20

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

postgresql/documentation/gotchas.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
some sense into a confusing situation, this document was drawn.
1212
1313
14-
client_encoding GUC should be altered carefully
15-
-----------------------------------------------
14+
client_encoding setting should be altered carefully
15+
---------------------------------------------------
1616
1717
`postgresql.driver`'s streaming cursor implementation reads a fixed set of rows
1818
when it queries the server for more. In order to optimize some situations, the
@@ -49,14 +49,31 @@
4949
value of the target server will allow the driver to properly encode *some* of
5050
the parameters. Also, any GUC parameters passed via the `settings` parameter
5151
should use typed objects when possible to hint that the server encoding should
52-
not be used on that parameter.
52+
not be used on that parameter(`bytes`, for instance).
5353
5454
5555
Backslash characters are being treated literally
5656
------------------------------------------------
5757
5858
The driver enables standard compliant strings. Stop using non-standard features.
5959
;)
60+
61+
If support for non-standard strings was provided it would require to the
62+
driver to provide subjective quote interfaces(eg, db.quote_literal). Doing so is
63+
not desirable as it introduces difficulties for the driver *and* the user.
64+
65+
66+
Types without binary support in the driver are unsupported in arrays and records
67+
--------------------------------------------------------------------------------
68+
69+
When an array or composite type is identified, `postgresql.protocol.typio`
70+
ultimately chooses the binary format for the transfer of the column or
71+
parameter. When this is done, PostgreSQL will pack or expect *all* the values
72+
in binary format as well. If that binary format is not a ``client_encoding``
73+
string, it will fail to unpack the row or pack the appropriate data for the
74+
element or attribute.
75+
76+
In, most cases issues related to this can be avoided with exlicit casts to text.
6077
'''
6178

6279
__docformat__ = 'reStructuredText'

0 commit comments

Comments
 (0)