Thread: BUG #4158: client encoding is wrong in plpythonu code

BUG #4158: client encoding is wrong in plpythonu code

From
"Andriy Rysin"
Date:
The following bug has been logged online:

Bug reference:      4158
Logged by:          Andriy Rysin
Email address:      arysin@gmail.com
PostgreSQL version: 8.3.1
Operating system:   Linux (Mandriva 2008.1) x86_64
Description:        client encoding is wrong in plpythonu code
Details:

$ more test.py
set client_encoding = 'UTF8';

CREATE OR REPLACE FUNCTION test_encoding()
RETURNS varchar AS $$
    import sys

    return sys.getdefaultencoding() + ', can change: ' + str( hasattr(sys,
'setdefaultencoding') )

$$ LANGUAGE plpythonu;

show client_encoding;
select test_encoding();

$ psql krym -f test.py
SET
CREATE FUNCTION
 client_encoding
-----------------
 UTF8
(1 row)

      test_encoding
--------------------------
 ascii, can change: False
(1 row)