Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Zi1uv-000461-Q7 for pgsql-bugs@arkaria.postgresql.org; Fri, 02 Oct 2015 15:06:37 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1Zi1uu-0008J5-BZ for pgsql-bugs@arkaria.postgresql.org; Fri, 02 Oct 2015 15:06:36 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZhyBO-0000oQ-8X for pgsql-bugs@postgresql.org; Fri, 02 Oct 2015 11:07:22 +0000 Received: from indigo.leisoft.cz ([194.213.194.162]) by magus.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZhyBM-0004Ps-Bw for pgsql-bugs@postgresql.org; Fri, 02 Oct 2015 11:07:21 +0000 Received: (qmail 30896 invoked from network); 2 Oct 2015 13:07:19 +0200 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on indigo-user.leisoft.cz X-Spam-Level: * X-Spam-Status: No, score=1.6 required=4.0 tests=BAYES_50,RDNS_NONE autolearn=no version=3.3.2 Received: from unknown (HELO leisoft.cz) (192.168.254.4) by 192.168.254.3 with SMTP; 2 Oct 2015 13:07:17 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 02 Oct 2015 13:07:17 +0200 From: Michal Leinweber To: Alex Hunsaker Cc: Tom Lane , Tim Bunce , Alvaro Herrera , pgsql-bugs Subject: Re: BUG #13638: Exception texts from plperl has bad encoding In-Reply-To: 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> <23013.1443457683@sss.pgh.pa.us> Message-ID: <8a47f0bd70f38a49fdcb8d7ef93f7694@leisoft.cz> X-Sender: lei@aswsyst.cz User-Agent: Roundcube Webmail/1.1.3 X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Hello, just reporting that the attached patch solves my problem. Thanks. Best Regards Michal Leinweber On 2015-09-29 05:51, Alex Hunsaker wrote: > On Mon, Sep 28, 2015 at 10:28 AM, Tom Lane wrote: > >> Alex Hunsaker 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. > >> I tried this implementation of croak_cstr: ... > > Yeah that seems to work great! > >> * I don't see mess() in the perlapi man page, so is it okay to use? > > Looks like they added it to perlapi in 5.12, given that it exists and > seems to work in 5.8 and 5.10 I think we are ok to use it. I tested > your above usage on 5.8, 5.10, 5.12. > >> * 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?) > > No, $@ is global and mess() also uses a global. (unless perl is > destructing). > > In the croak_sv() case, we never use/assign what cstr2sv() returns > anywhere in perl land, so it always has a refcount of 1. We have > similar usage of sv_2mortal(cstr2sv()) albeit not on the same line in > plperl.c. > >> * 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. > > The only argument that comes to mind is AFAIK perl 5.8 and 5.10 are > more or less unmaintained so it might not be worth the effort to make > them work. And it's been this way forever. > >> BTW, I think we can't actually use this regression test case, [...] >> However, > >> other test cases may already provide sufficient coverage if we're not >> going to test encoding conversion. > > Agreed. I'll attach it separately just for easy verification that > everything is working as intended. > >> Also, I'm inclined to leave do_util_elog() alone other than replacing >> croak("%s", edata->message) with croak_cstr(edata->message). > > Done that way. > > The attached was tested on 5.8.9, 5.10.1, 5.12.5, 5.14.4, 5.18.2 and > 5.22.0. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs