diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2012-08-06 13:02:15 +0300 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2012-08-06 14:09:50 +0300 |
commit | 3ff15883b1b4bcefb2278313a3137a688ebda505 (patch) | |
tree | 768c907716499bbc60ccc7c8a451ff06c9f0b772 /src/backend/parser/parse_node.c | |
parent | 149ac7d45595f64f7b60833de7f146bc9a599656 (diff) | |
download | postgresql-3ff15883b1b4bcefb2278313a3137a688ebda505.tar.gz postgresql-3ff15883b1b4bcefb2278313a3137a688ebda505.zip |
Perform conversion from Python unicode to string/bytes object via UTF-8.
We used to convert the unicode object directly to a string in the server
encoding by calling Python's PyUnicode_AsEncodedString function. In other
words, we used Python's routines to do the encoding. However, that has a
few problems. First of all, it required keeping a mapping table of Python
encoding names and PostgreSQL encodings. But the real killer was that Python
doesn't support EUC_TW and MULE_INTERNAL encodings at all.
Instead, convert the Python unicode object to UTF-8, and use PostgreSQL's
encoding conversion functions to convert from UTF-8 to server encoding. We
were already doing the same in the other direction in PLyUnicode_FromString,
so this is more consistent, too.
Note: This makes SQL_ASCII to behave more leniently. We used to map
SQL_ASCII to Python's 'ascii', which on Python means strict 7-bit ASCII
only, so you got an error if the python string contained anything but pure
ASCII. You no longer get an error; you get the UTF-8 representation of the
string instead.
Backpatch to 9.0, where these conversions were introduced.
Jan UrbaĆski
Diffstat (limited to 'src/backend/parser/parse_node.c')
0 files changed, 0 insertions, 0 deletions