Re: invalid UTF-8 via pl/perl - Mailing list pgsql-hackers

From Hannu Krosing
Subject Re: invalid UTF-8 via pl/perl
Date
Msg-id 1268085981.2855.13.camel@hvost
Whole thread Raw
In response to Re: invalid UTF-8 via pl/perl  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: invalid UTF-8 via pl/perl
List pgsql-hackers
On Sat, 2010-01-02 at 20:51 -0500, Andrew Dunstan wrote:
> 
> Andrew Dunstan wrote:
> >  
> > I think the plperl glue code should check returned strings using 
> > pg_verifymbstr().
> >
> >
> 
> Please test this patch. I think we'd probably want to trap the encoding 
> error and issue a customised error message, but this plugs all the holes 
> I can see with the possible exception of values inserted via SPI calls. 
> I'll check that out.

I got a report, that the patch fixes one case but leaves open another:

CREATE TABLE utf_test
( id serial PRIMARY KEY, data character varying
);

CREATE OR REPLACE FUNCTION utf_test() RETURNS character varying AS
$BODY$
return "\xd0";
$BODY$ LANGUAGE 'plperlu' VOLATILE STRICT;

CREATE OR REPLACE FUNCTION utf_test2() RETURNS character varying AS
$BODY$
spi_exec_query("insert into utf_test (data) values('\xd0');");
return "VIGA";
$BODY$ LANGUAGE 'plperlu' VOLATILE STRICT;


The report siad, that patch fixes case
       insert into utf_test (data) values(utf_test());

so that it return an error, but the second function
       select utf_test2();

still enters wrong data to the table

So SPI interface should also be fixed, either from perl side, or maybe
from inside SPI ?




-- 
Hannu Krosing   http://www.2ndQuadrant.com
PostgreSQL Scalability and Availability   Services, Consulting and Training




pgsql-hackers by date:

Previous
From: Jaime Casanova
Date:
Subject: Re: disabling log_min_duration_statement from pg_dump?
Next
From: Bruce Momjian
Date:
Subject: Re: disabling log_min_duration_statement from pg_dump?