summaryrefslogtreecommitdiff
path: root/src/pl/plperl/sql/plperl_elog.sql
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2015-09-29 10:52:22 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2015-09-29 10:52:22 -0400
commitaae40cf13b9b1b250db4a29e043e019fe85b0522 (patch)
tree10d29943aaeb00b42d8f3da8a815b85bd5408994 /src/pl/plperl/sql/plperl_elog.sql
parenta959db8acd058a311478d3692ac4ca35b747079c (diff)
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
Diffstat (limited to 'src/pl/plperl/sql/plperl_elog.sql')
-rw-r--r--src/pl/plperl/sql/plperl_elog.sql15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/pl/plperl/sql/plperl_elog.sql b/src/pl/plperl/sql/plperl_elog.sql
index 032fd8b8ba7..9ea1350069b 100644
--- a/src/pl/plperl/sql/plperl_elog.sql
+++ b/src/pl/plperl/sql/plperl_elog.sql
@@ -76,3 +76,18 @@ return $a + $b;
$$;
select indirect_die_caller();
+
+-- Test non-ASCII error messages
+--
+-- Note: this test case is known to fail if the database encoding is
+-- EUC_CN, EUC_JP, EUC_KR, or EUC_TW, for lack of any equivalent to
+-- U+00A0 (no-break space) in those encodings. However, testing with
+-- plain ASCII data would be rather useless, so we must live with that.
+
+SET client_encoding TO UTF8;
+
+create or replace function error_with_nbsp() returns void language plperl as $$
+ elog(ERROR, "this message contains a no-break space");
+$$;
+
+select error_with_nbsp();