Re: [COMMITTERS] pgsql: Force strings passed to and from plperl to be in UTF8 encoding.

Поиск
Список
Период
Сортировка
От Alex Hunsaker
Тема Re: [COMMITTERS] pgsql: Force strings passed to and from plperl to be in UTF8 encoding.
Дата
Msg-id AANLkTinzzzJCJE=Ac_kZOOv4Hirogd9M2Wjjcecx_Si1@mail.gmail.com
обсуждение исходный текст
Ответы Re: Re: [COMMITTERS] pgsql: Force strings passed to and from plperl to be in UTF8 encoding.  (Amit Khandekar <amit.khandekar@enterprisedb.com>)
Список pgsql-hackers
On Sun, Feb 6, 2011 at 15:31, Andrew Dunstan <andrew@dunslane.net> wrote:
> Force strings passed to and from plperl to be in UTF8 encoding.
>
> String are converted to UTF8 on the way into perl and to the
> database encoding on the way back. This avoids a number of
> observed anomalies, and ensures Perl a consistent view of the
> world.

So I noticed a problem while playing with this in my discussion with
David Wheeler. pg_do_encoding() does nothing when the src encoding ==
the dest encoding. That means on a UTF-8 database we fail make sure
our strings are valid utf8.

An easy way to see this is to embed a null in the middle of a string:
=> create or replace function zerob() returns text as $$ return
"abcd\0efg"; $$ language plperl;
=> SELECT zerob();
abcd

Also It seems bogus to bogus to do any encoding conversion when we are
SQL_ASCII, and its really trivial to fix.

With the attached:
- when we are on a utf8 database make sure to verify our output string
in sv2cstr (we assume database strings coming in are already valid)

- Do no string conversion when we are SQL_ASCII in or out

- add plperl_helpers.h as a dep to plperl.o in our makefile

- remove some redundant calls to pg_verify_mbstr()

- as utf_e2u only as one caller dont pstrdup() instead have the caller
check (saves some cycles and memory)

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Jan Urbański
Дата:
Сообщение: Re: pl/python tracebacks
Следующее
От: Jan Urbański
Дата:
Сообщение: Re: pl/python explicit subtransactions