Skip site navigation (1) Skip section navigation (2)

Re: [PATCHES] Doc patch: New PL/Perl Features

From: Neil Conway <neilc(at)samurai(dot)com>
To: David Fetter <david(at)fetter(dot)org>
Cc: PostgreSQL Docs <pgsql-docs(at)postgresql(dot)org>,PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [PATCHES] Doc patch: New PL/Perl Features
Date: 2005-07-13 02:17:05
Message-ID: 42D479A1.9020701@samurai.com (view raw or flat)
Thread:
Lists: pgsql-docspgsql-patches
David Fetter wrote:
> On Tue, Jul 12, 2005 at 12:21:29PM -0700, David Fetter wrote:
> 
>>Folks,
>>
>>Please find enclosed document patches for PL/Perl features recently
>>introduced in CVS TIP.  These include:
>>
>>return_next
>>returning PostgreSQL arrays
>>spi_query/spi_fetchrow
>>use strict
>>
>>Cheers,
>>D
> 
> 
> Oops.  Persuant to corrections and clarifications by Andrew Dunstan,
> please find enclosed a better patch.

Applied with editorialization; see comments below. Thanks for the patch.

> +     <itemizedlist>
> +     <listitem>
> +         <para>
> +         Globally, by turning on plperl (one of the <xref
> +         linkend="guc-custom-variable-classes"
> +         endterm="custom_variable_classes"> you can use) and setting
> +         plperl.use_strict to true in your postgresql.conf, or
> +         </para>

Needs a <filename/> and a <literal/>. Also the <xref/> doesn't compile 
using openjade 1.3.1

>     <para>
> +    Perl can return PostgreSQL arrays as references to Perl arrays.
> +     Here is an example:

Needs <productname/> around "PostgreSQL" for consistency with the rest 
of the SGML docs.

> + <programlisting>
> + CREATE OR REPLACE function returns_array()
> + RETURNS text[][]
> + LANGUAGE plperl
> + AS $$
> +     return [['a"b','c,d'],['e\\f','g']];
> + $$;
> + 
> + select returns_array();

CREATE FUNCTION ... AS $$ ... $$ LANGUAGE plperl; would be more 
consistent with the other PL/Perl examples.

> ! CREATE OR REPLACE FUNCTION perl_set()
> ! RETURNS SETOF testrowperl
> ! LANGUAGE plperl AS $$
> !     return_next({f1 => 1, f2 => 'Hello', f3 => 'World' });
> !     return_next({ f1 => 2, f2 => 'Hello', f3 => 'PostgreSQL' });
> !     return_next({ f1 => 3, f2 => 'Hello', f3 => 'PL/Perl' });
> !     return undef;
> ! $$;
> ! </programlisting>

Should probably use "&gt;" not ">".

>        <term><literal><function>spi_exec_query</>(<replaceable>query</replaceable> [, <replaceable>max-rows</replaceable>])</literal></term>
>        <term><literal><function>spi_exec_query</>(<replaceable>command</replaceable>)</literal></term>
> +      <term><literal><function>spi_query</>(<replaceable>query</replaceable>)</literal></term>
> +      <term><literal><function>spi_fetchrow</>(<replaceable>result of spi_query</replaceable>)</literal></term>
> +      <term><literal>
> +      </literal></term>
>        <listitem>
>         <para>
>          Executes an SQL command.  Here is an example of a query

This needs more work -- the difference in behavior between spi_query() 
and spi_exec_query() is not described, so I didn't apply this hunk.

> *** 4103,4111 ****
>        when using custom variables:
>   
>   <programlisting>
> ! custom_variable_classes = 'plr,pljava'
>   plr.path = '/usr/lib/R'
>   pljava.foo = 1
>   plruby.bar = true        # generates error, unknown class name
>   </programlisting>
>       </para>
> --- 4103,4112 ----
>        when using custom variables:
>   
>   <programlisting>
> ! custom_variable_classes = 'plperl,plr,pljava'
>   plr.path = '/usr/lib/R'
>   pljava.foo = 1
> + plperl.use_strict = true # now without having to use pl/perlU! :)
>   plruby.bar = true        # generates error, unknown class name
>   </programlisting>
>       </para>

I didn't see why this was relevant, so I didn't apply it.

-Neil

In response to

pgsql-docs by date

Next:From: Bruce MomjianDate: 2005-07-13 04:22:42
Subject: Re: Doc patch: New PL/Perl Features
Previous:From: Michael FuhrDate: 2005-07-12 23:59:18
Subject: Re: PL/Perl list value return causes segfault

pgsql-patches by date

Next:From: Bruce MomjianDate: 2005-07-13 02:31:00
Subject: Re: [PATCHES] thousands comma numeric formatting in psql
Previous:From: Bruce MomjianDate: 2005-07-13 02:10:22
Subject: Re: [PATCHES] HEAD doesn't cope with libraries in non-default

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group