bool_plperl_transform_v1.patch
application/octet-stream
Filename: bool_plperl_transform_v1.patch
Type: application/octet-stream
Part: 0
Message:
bool_plperl transform
Patch
Format: unified
Series: patch v1
| File | + | − |
|---|---|---|
| contrib/Makefile | 2 | 2 |
| doc/src/sgml/plperl.sgml | 34 | 1 |
| src/tools/msvc/Mkvcbuild.pm | 5 | 0 |
diff --git a/contrib/Makefile b/contrib/Makefile
index 92184ed487..795f69cf64 100644
--- a/contrib/Makefile
+++ b/contrib/Makefile
@@ -75,9 +75,9 @@ ALWAYS_SUBDIRS += sepgsql
endif
ifeq ($(with_perl),yes)
-SUBDIRS += hstore_plperl jsonb_plperl
+SUBDIRS += hstore_plperl jsonb_plperl bool_plperl
else
-ALWAYS_SUBDIRS += hstore_plperl jsonb_plperl
+ALWAYS_SUBDIRS += hstore_plperl jsonb_plperl bool_plperl
endif
ifeq ($(with_python),yes)
diff --git a/doc/src/sgml/plperl.sgml b/doc/src/sgml/plperl.sgml
index e4769c0e38..79f781a4ce 100644
--- a/doc/src/sgml/plperl.sgml
+++ b/doc/src/sgml/plperl.sgml
@@ -55,7 +55,10 @@
syntax:
<programlisting>
-CREATE FUNCTION <replaceable>funcname</replaceable> (<replaceable>argument-types</replaceable>) RETURNS <replaceable>return-type</replaceable> AS $$
+CREATE FUNCTION <replaceable>funcname</replaceable> (<replaceable>argument-types</replaceable>)
+ RETURNS <replaceable>return-type</replaceable>
+ -- function attributes
+ AS $$
# PL/Perl function body
$$ LANGUAGE plperl;
</programlisting>
@@ -347,6 +350,36 @@ SELECT * FROM perl_set();
</programlisting>
</para>
+ <para>
+ By default, <type>json</type> and <type>jsonb</type> values are passed to
+ PL/Perl functions and procedures as text. For <type>jsonb</type> it is
+ possible to convert the values into internal Perl representation automatically
+ using the transforms, see <xref linkend="sql-createtransform"/> and <xref linkend="sql-createfunction"/>.
+ <filename>jsonb_plperl</filename> extension provides such transform for <type>jsonb</type> data type.
+ To enable the transform, create this extension and then specify
+<programlisting>
+ TRANSFORM FOR TYPE jsonb
+</programlisting>
+ in the <literal>CREATE FUNCTION</literal> statement.
+ </para>
+
+ <para>
+ By default, boolean values are passed to plperl as text, namely <literal>'t'</literal>
+ for <literal>true</literal> and <literal>'f'</literal> for <literal>false</literal>.
+ To transform these values into Perl true and false values, use the transform
+ provided by <filename>bool_plperl</filename> extension.
+ To enable the transform, create this extension and then specify
+<programlisting>
+ TRANSFORM FOR TYPE bool
+</programlisting>
+ in the <literal>CREATE FUNCTION</literal> statement.
+ </para>
+
+ <para>
+ The above mentioned <type>jsonb</type> and <type>bool</type> transforms are applied for function arguments,
+ its return value and results of SPI database queries performed inside the function.
+ </para>
+
<para>
If you wish to use the <literal>strict</literal> pragma with your code you
have a few options. For temporary global use you can <command>SET</command>
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 834c2c39d1..809a2bab0d 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -43,6 +43,7 @@ my $contrib_extrasource = {
'seg' => [ 'contrib/seg/segscan.l', 'contrib/seg/segparse.y' ],
};
my @contrib_excludes = (
+ 'bool_plperl',
'commit_ts', 'hstore_plperl',
'hstore_plpython', 'intagg',
'jsonb_plperl', 'jsonb_plpython',
@@ -763,6 +764,9 @@ sub mkvcbuild
}
# Add transform modules dependent on plperl
+ my $bool_plperl = AddTransformModule(
+ 'bool_plperl', 'contrib/bool_plperl',
+ 'plperl', 'src/pl/plperl');
my $hstore_plperl = AddTransformModule(
'hstore_plperl', 'contrib/hstore_plperl',
'plperl', 'src/pl/plperl',
@@ -773,6 +777,7 @@ sub mkvcbuild
foreach my $f (@perl_embed_ccflags)
{
+ $bool_plperl->AddDefine($f);
$hstore_plperl->AddDefine($f);
$jsonb_plperl->AddDefine($f);
}