Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
95f202c0
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
95f202c0
编写于
8月 24, 2005
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adjust description of use_strict parameter. Some other minor editorial
cleanup.
上级
f21e2622
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
36 addition
and
43 deletion
+36
-43
doc/src/sgml/plperl.sgml
doc/src/sgml/plperl.sgml
+32
-39
doc/src/sgml/runtime.sgml
doc/src/sgml/runtime.sgml
+4
-4
未找到文件。
doc/src/sgml/plperl.sgml
浏览文件 @
95f202c0
<!--
$PostgreSQL: pgsql/doc/src/sgml/plperl.sgml,v 2.4
3 2005/08/12 21:42:53 momjian
Exp $
$PostgreSQL: pgsql/doc/src/sgml/plperl.sgml,v 2.4
4 2005/08/24 18:56:07 tgl
Exp $
-->
<chapter id="plperl">
...
...
@@ -46,46 +46,18 @@ $PostgreSQL: pgsql/doc/src/sgml/plperl.sgml,v 2.43 2005/08/12 21:42:53 momjian E
<para>
To create a function in the PL/Perl language, use the standard
<xref linkend="sql-createfunction" endterm="sql-createfunction-title">
syntax. A PL/Perl function must always return a scalar value. You
can return more complex structures (arrays, records, and sets)
in the appropriate context by returning a reference.
Never return a list. Here follows an example of a PL/Perl
function.
syntax:
<programlisting>
CREATE FUNCTION <replaceable>funcname</replaceable> (<replaceable>argument-types</replaceable>) RETURNS <replaceable>return-type</replaceable> AS $$
# PL/Perl function body
$$ LANGUAGE plperl;
</programlisting>
The body of the function is ordinary Perl code.
The body of the function is ordinary Perl code. A PL/Perl function must
always return a scalar value. You can return more complex structures
(arrays, records, and sets) by returning a reference, as discussed below.
Never return a list.
</para>
<para>
As with ordinary Perl code, you should use the strict pragma,
which you can do in one of two ways:
<itemizedlist>
<listitem>
<para>
Globally, by adding <quote>plperl</quote> to the list of <xref
linkend="guc-custom-variable-classes"> and setting
<literal>plperl.use_strict</literal> to true in
<filename>postgresql.conf</filename>
</para>
</listitem>
<listitem>
<para>
One function at a time, by using PL/PerlU (you must be database
superuser to do this) and including
<programlisting>
use strict;
</programlisting>
in the function body.
</para>
</listitem>
</itemizedlist>
</para>
<para>
The syntax of the <command>CREATE FUNCTION</command> command requires
...
...
@@ -205,13 +177,13 @@ SELECT * FROM perl_row();
<para>
PL/Perl functions can also return sets of either scalar or
composite types.
In general,
you'll want to return rows one at a
time both to speed up startup time and to keep from queueing up
composite types.
Usually
you'll want to return rows one at a
time
,
both to speed up startup time and to keep from queueing up
the entire result set in memory. You can do this with
<function>return_next</function> as illustrated below. Note that
after the last <function>return_next</function>, you must put
either <literal>return
;
</literal> or (better) <literal>return
undef
;</literal>
either <literal>return</literal> or (better) <literal>return
undef
</literal>.
<programlisting>
CREATE OR REPLACE FUNCTION perl_set_int(int)
...
...
@@ -237,7 +209,7 @@ $$ LANGUAGE plperl;
contains either scalars, references to arrays, or references to
hashes for simple types, array types, and composite types,
respectively. Here are some simple examples of returning the entire
result set as a reference:
result set as a
n array
reference:
<programlisting>
CREATE OR REPLACE FUNCTION perl_set_int(int) RETURNS SETOF INTEGER AS $$
...
...
@@ -267,6 +239,27 @@ SELECT * FROM perl_set();
it is a hazard if you declare a <application>PL/Perl</> function
as returning a domain type.
</para>
<para>
If you wish to use the <literal>strict</> pragma with your code,
the easiest way to do so is to <command>SET</>
<literal>plperl.use_strict</literal> to true. This parameter affects
subsequent compilations of <application>PL/Perl</> functions, but not
functions already compiled in the current session. To set the
parameter before <application>PL/Perl</> has been loaded, it is
necessary to have added <quote><literal>plperl</></> to the <xref
linkend="guc-custom-variable-classes"> list in
<filename>postgresql.conf</filename>.
</para>
<para>
Another way to use the <literal>strict</> pragma is to just put
<programlisting>
use strict;
</programlisting>
in the function body. But this only works for <application>PL/PerlU</>
functions, since <literal>use</> is not a trusted operation.
</para>
</sect1>
<sect1 id="plperl-database">
...
...
doc/src/sgml/runtime.sgml
浏览文件 @
95f202c0
<!--
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.34
7 2005/08/22 17:34:56 momjian
Exp $
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.34
8 2005/08/24 18:56:07 tgl
Exp $
-->
<chapter Id="runtime">
...
...
@@ -4382,10 +4382,10 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
when using custom variables:
<programlisting>
custom_variable_classes = 'plr,pl
java
'
custom_variable_classes = 'plr,pl
perl
'
plr.path = '/usr/lib/R'
pl
java.foo = 1
plruby.
bar = true # generates error,
unknown class name
pl
perl.use_strict = true
plruby.
use_strict = true # generates error:
unknown class name
</programlisting>
</para>
</sect2>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录