1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-13 14:22:43 +03:00

Fix plperl to handle non-ASCII error message texts correctly.

We were passing error message texts to croak() verbatim, which turns out
not to work if the text contains non-ASCII characters; Perl mangles their
encoding, as reported in bug #13638 from Michal Leinweber.  To fix, convert
the text into a UTF8-encoded SV first.

It's hard to test this without risking failures in different database
encodings; but we can follow the lead of plpython, which is already
assuming that no-break space (U+00A0) has an equivalent in all encodings
we care about running the regression tests in (cf commit 2dfa15de5).

Back-patch to 9.1.  The code is quite different in 9.0, and anyway it seems
too risky to put something like this into 9.0's final minor release.

Alex Hunsaker, with suggestions from Tim Bunce and Tom Lane
This commit is contained in:
Tom Lane
2015-09-29 10:52:22 -04:00
parent 758fcfdc01
commit b631a46ed8
7 changed files with 87 additions and 8 deletions

View File

@@ -3066,7 +3066,7 @@ plperl_spi_exec(char *query, int limit)
SPI_restore_connection();
/* Punt the error to Perl */
croak("%s", edata->message);
croak_cstr(edata->message);
/* Can't get here, but keep compiler quiet */
return NULL;
@@ -3299,7 +3299,7 @@ plperl_spi_query(char *query)
SPI_restore_connection();
/* Punt the error to Perl */
croak("%s", edata->message);
croak_cstr(edata->message);
/* Can't get here, but keep compiler quiet */
return NULL;
@@ -3385,7 +3385,7 @@ plperl_spi_fetchrow(char *cursor)
SPI_restore_connection();
/* Punt the error to Perl */
croak("%s", edata->message);
croak_cstr(edata->message);
/* Can't get here, but keep compiler quiet */
return NULL;
@@ -3560,7 +3560,7 @@ plperl_spi_prepare(char *query, int argc, SV **argv)
SPI_restore_connection();
/* Punt the error to Perl */
croak("%s", edata->message);
croak_cstr(edata->message);
/* Can't get here, but keep compiler quiet */
return NULL;
@@ -3701,7 +3701,7 @@ plperl_spi_exec_prepared(char *query, HV *attr, int argc, SV **argv)
SPI_restore_connection();
/* Punt the error to Perl */
croak("%s", edata->message);
croak_cstr(edata->message);
/* Can't get here, but keep compiler quiet */
return NULL;
@@ -3830,7 +3830,7 @@ plperl_spi_query_prepared(char *query, int argc, SV **argv)
SPI_restore_connection();
/* Punt the error to Perl */
croak("%s", edata->message);
croak_cstr(edata->message);
/* Can't get here, but keep compiler quiet */
return NULL;