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



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

Reply via email to