Re: invalid UTF-8 via pl/perl

Andrew Dunstan <andrew@dunslane.net>

From: Andrew Dunstan <andrew@dunslane.net>
To: Hannu Krosing <hannu@2ndquadrant.com>
Cc: pgsql-hackers@postgresql.org
Date: 2010-01-03T14:28:29Z
Lists: pgsql-hackers

Attachments


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 think the attached patch plugs the direct SPI holes as well.

One thing that I am pondering is: how does SPI handle things if the 
client encoding and server encoding are not the same? Won't the strings 
it passes the parser be interpreted in the client encoding? If so, that 
doesn't seem right at all, since these strings come from a server side 
call and not from the client at all. It looks to me like the call to 
pg_parse_query() in spi.c should possibly be surrounded by code to 
temporarily set the client encoding to the server encoding and then 
restore it afterwards.

cheers

andrew