From: Tom Lane <tgl@sss.pgh.pa.us>
To: lei@aswsyst.cz
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #13638: Exception texts from plperl has bad encoding
Date: Fri, 25 Sep 2015 15:18:28 -0400
Message-ID: <18105.1443208708@sss.pgh.pa.us> (raw)
In-Reply-To: <20150925112345.26913.28407@wrigleys.postgresql.org>
References: <20150925112345.26913.28407@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
lei@aswsyst.cz writes:
> I have UTF-8 database and using UTF-8 text in plpgsql and plperl functions.
> Everything works ok, only exceptions from plperl functions have bad encoding
> (maybe double encoded).
> Compare output of these 2 functions:
> create or replace function perl_test() returns text
> language plperl as $$
> return "Český text ěščřžýáíé";
> $$;
> create or replace function perl_test_err() returns text
> language plperl as $$
> elog(ERROR, "Česká chyba ěščřžýáíé");
> $$;
I traced through this example to the extent of finding that:
* The string passed to elog() in do_util_elog() seems correctly
encoded.
* So does the string passed to croak() after elog does its longjmp,
which is unsurprising since elog.c doesn't really do anything to it.
* Back in plperl_call_perl_func, we use sv2cstr(ERRSV) to get the
error string. sv2cstr calls "SvPVutf8(sv, len)", and that is what
is giving back the bogusly-encoded data.
I suspect the root problem is that instead of baldly doing
croak("%s", edata->message);
in do_util_elog(), we need to do something to inform Perl what encoding
the message string is in. This is beyond my Perl-fu, however.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
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: tgl@sss.pgh.pa.us, lei@aswsyst.cz
Subject: Re: BUG #13638: Exception texts from plperl has bad encoding
In-Reply-To: <18105.1443208708@sss.pgh.pa.us>
References: <20150925112345.26913.28407@wrigleys.postgresql.org> <18105.1443208708@sss.pgh.pa.us>
* 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