提交 a794b99a 编写于 作者: A Andrew Dunstan

Fix example of de-escaping bytea argument, per Florian Weimer. Also fix example

of escaping bytea return value. Both cases did not handle backslash values properly.
上级 353a1cca
<!-- $PostgreSQL: pgsql/doc/src/sgml/plperl.sgml,v 2.66 2007/05/04 14:55:32 adunstan Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/plperl.sgml,v 2.67 2008/01/25 15:28:35 adunstan Exp $ -->
<chapter id="plperl"> <chapter id="plperl">
<title>PL/Perl - Perl Procedural Language</title> <title>PL/Perl - Perl Procedural Language</title>
...@@ -150,7 +150,7 @@ $$ LANGUAGE plperl; ...@@ -150,7 +150,7 @@ $$ LANGUAGE plperl;
<programlisting> <programlisting>
my $arg = shift; my $arg = shift;
$arg =~ s!\\(\d{3})!chr(oct($1))!ge; $arg =~ s!\\(?:\\|(\d{3}))!$1 ? chr(oct($1)) : "\\"!ge;
</programlisting> </programlisting>
</para> </para>
...@@ -161,7 +161,7 @@ $$ LANGUAGE plperl; ...@@ -161,7 +161,7 @@ $$ LANGUAGE plperl;
is how to escape binary data for a return value of type <type>bytea</>: is how to escape binary data for a return value of type <type>bytea</>:
<programlisting> <programlisting>
$retval =~ s!([^ -~])!sprintf("\\%03o",ord($1))!ge; $retval =~ s!(\\|[^ -~])!sprintf("\\%03o",ord($1))!ge;
return $retval; return $retval;
</programlisting> </programlisting>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册