pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Volker Paul <volker.paul@v-paul.de>
To: pgsql-bugs@postgresql.org
Subject: Error and wrong lenghth of non-ASCII Unicode string in plpythonu
Date: Mon, 18 Jan 2016 18:59:01 +0100
Message-ID: <569D27E5.90400@v-paul.de> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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;



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (2+ messages)  latest in thread

Message-ID: <569D27E5.90400@v-paul.de>
Permalink:  ../569D27E5.90400@v-paul.de/
Also on:    postgresql.org/message-id/569D27E5.90400@v-paul.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: volker.paul@v-paul.de
  Subject: Re: Error and wrong lenghth of non-ASCII Unicode string in plpythonu
  In-Reply-To: <569D27E5.90400@v-paul.de>
  References: <569D27E5.90400@v-paul.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox