Error and wrong lenghth of non-ASCII Unicode string in plpythonu - Mailing list pgsql-bugs

From Volker Paul
Subject Error and wrong lenghth of non-ASCII Unicode string in plpythonu
Date
Msg-id 569D27E5.90400@v-paul.de
Whole thread Raw
Responses Re: Error and wrong lenghth of non-ASCII Unicode string in plpythonu
List pgsql-bugs
Hi,

the following plpythonu function reveals wrong length calculation
and error on accessing single characters in a Unicode string.

Is the problem solved in more recent versions?

Or is there a possibility to work around the problem?


CREATE OR REPLACE FUNCTION test_plpython_unicode()
RETURNS TEXT AS $$
     s = u"abc"
     plpy.notice("s:%s len:%d; 2+:%s" % (s, len(s), s[2:]))
     # output: NOTICE:  s:abc len:3; 2+:c
     s = u"äbc"
     plpy.notice("len:%d; 2+:%s" % (len(s), s[2:]))
     # output:   NOTICE:  len:4; 2+:bc
     # expected: NOTICE:  len:3; 2+:c
     # Note that including s:%s as above leads to an error
     for c in u"abcÄÖÜ":
         plpy.notice(c)
     # output: (the first umlaut leads to error, even to error in error
reporting)
     #NOTICE:  a
     #NOTICE:  b
     #NOTICE:  c
     #ERROR:  plpy.Error: could not parse error message in plpy.elog
     # platform info:
     # psql (9.3.10, server 9.1.18)
     # Ubuntu 14.04.3 LTS
$$ LANGUAGE plpythonu;

pgsql-bugs by date:

Previous
From: Dean Rasheed
Date:
Subject: Re: BUG #13863: Select from views gives wrong results
Next
From: hukim99@gmail.com
Date:
Subject: BUG #13874: The index of a json field which is created after data are inserted doesn't work.