Re: invalid UTF-8 via pl/perl

From: Hannu Krosing <hannu(at)2ndquadrant(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: invalid UTF-8 via pl/perl
Date: 2010-03-08 22:06:21
Message-ID: 1268085981.2855.13.camel@hvost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2010-03-08 22:57:20 Re: disabling log_min_duration_statement from pg_dump?
Previous Message Jaime Casanova 2010-03-08 22:01:41 Re: disabling log_min_duration_statement from pg_dump?