Error and wrong lenghth of non-ASCII Unicode string in plpythonu

From: Volker Paul <volker(dot)paul(at)v-paul(dot)de>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Error and wrong lenghth of non-ASCII Unicode string in plpythonu
Date: 2016-01-18 17:59:01
Message-ID: 569D27E5.90400@v-paul.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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;

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Igal @ Lucee.org 2016-01-18 18:20:24 Re: BUG #13859: pg_upgrade permissions on Windows
Previous Message Bruce Momjian 2016-01-18 17:41:14 Re: BUG #13859: pg_upgrade permissions on Windows