From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alex Hunsaker <badalex@gmail.com>
Cc: Tim Bunce <Tim.Bunce@pobox.com>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: lei@aswsyst.cz, pgsql-bugs <pgsql-bugs@postgresql.org>
Subject: Re: BUG #13638: Exception texts from plperl has bad encoding
Date: Mon, 28 Sep 2015 12:28:03 -0400
Message-ID: <23013.1443457683@sss.pgh.pa.us> (raw)
In-Reply-To: <CAFaPBrR-yd0fFAh+tNQ=NQ_HW=xMsbZgS8dnRjF6x6FtnSTJTQ@mail.gmail.com>
References: <20150925112345.26913.28407@wrigleys.postgresql.org>
<18105.1443208708@sss.pgh.pa.us>
<18478.1443209624@sss.pgh.pa.us>
<20150925195120.GL295765@alvherre.pgsql>
<20150927141148.GA1416@timac.local>
<13303.1443397579@sss.pgh.pa.us>
<CAFaPBrR-yd0fFAh+tNQ=NQ_HW=xMsbZgS8dnRjF6x6FtnSTJTQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Alex Hunsaker <badalex@gmail.com> writes:
> Yeah, I was just looking at that. I couldn't find a good way to support
> 5.8. Doing: ...
> Works, but screws up the error line numbers.
I looked into this and determined that the problem is that the location
info doesn't get appended to ERRSV until after Perl has popped the stack.
A possibly-entirely-wrong hack that seems to fix that is to use mess()
to construct the SV, *and* append the location info, before we croak.
I tried this implementation of croak_cstr:
char *utf8_str = utf_e2u(str);
SV *ssv = mess("%s", utf8_str);
SV *errsv = get_sv("@", GV_ADD);
SvUTF8_on(ssv);
pfree(utf8_str);
sv_setsv(errsv, ssv);
croak(NULL);
with Perl 5.8.9 and it passed your proposed regression test. Obvious
questions include:
* I don't see mess() in the perlapi man page, so is it okay to use?
* Is there any leakage involved in this? (I don't know what prompted
you to add sv_2mortal() to the other implementation, but maybe we need
it here too?)
* Is there some other reason why this is wrong or a bad idea? Since we'd
only use this with versions lacking croak_sv(), future-proofing doesn't
seem like a good argument against it, but maybe there is another one.
BTW, I think we can't actually use this regression test case, because it
won't work as-is in non-UTF8 encodings. But the use of UTF8 characters in
the string doesn't seem like an essential property of the test. However,
other test cases may already provide sufficient coverage if we're not
going to test encoding conversion.
Also, I'm inclined to leave do_util_elog() alone other than replacing
croak("%s", edata->message) with croak_cstr(edata->message). Since
we have to have croak_cstr() anyway, there seems little value in taking
any risk that we've missed some reason why the existing coding there
is important.
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, badalex@gmail.com, Tim.Bunce@pobox.com, alvherre@2ndquadrant.com
Subject: Re: BUG #13638: Exception texts from plperl has bad encoding
In-Reply-To: <23013.1443457683@sss.pgh.pa.us>
References: <20150925112345.26913.28407@wrigleys.postgresql.org> <18105.1443208708@sss.pgh.pa.us> <18478.1443209624@sss.pgh.pa.us> <20150925195120.GL295765@alvherre.pgsql> <20150927141148.GA1416@timac.local> <13303.1443397579@sss.pgh.pa.us> <CAFaPBrR-yd0fFAh+tNQ=NQ_HW=xMsbZgS8dnRjF6x6FtnSTJTQ@mail.gmail.com> <23013.1443457683@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