Kind people, The enclose patch clarifies and makes a more useful example for the Global Values in PL/Perl section of the documents.
Cheers, D -- David Fetter [EMAIL PROTECTED] http://fetter.org/ phone: +1 510 893 6100 mobile: +1 415 235 3778 Remember to vote!
? plperl.diff Index: plperl.sgml =================================================================== RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/plperl.sgml,v retrieving revision 2.26 diff -u -r2.26 plperl.sgml --- plperl.sgml 21 Jul 2004 20:44:52 -0000 2.26 +++ plperl.sgml 13 Aug 2004 21:42:22 -0000 @@ -317,23 +317,25 @@ <sect1 id="plperl-global"> <title>Global Values in PL/Perl</title> <para> - You can use the %_SHARED to store data between function calls. WHY -IS THIS A HASH, AND NOT A HASH REF? + You can use the %_SHARED to store data between function calls. </para> <para> For example: <programlisting> -CREATE OR REPLACE FUNCTION set_var(TEXT) RETURNS TEXT AS $$ - $_SHARED{first} = 'Hello, PL/Perl!'; - return 'ok'; +CREATE OR REPLACE FUNCTION set_var(name TEXT, val TEXT) RETURNS TEXT AS $$ + if ($_SHARED{$_[0]} = $_[1]) { + return 'ok'; + } else { + return "Can't set shared variable $_[0] to $_[1]"; + } $$ LANGUAGE plperl; -CREATE OR REPLACE FUNCTION get_var() RETURNS text AS $$ - return $_SHARED{first}; +CREATE OR REPLACE FUNCTION get_var(name TEXT) RETURNS text AS $$ + return $_SHARED{$_[0]}; $$ LANGUAGE plperl; -SELECT set_var('hello plperl'); -SELECT get_var(); +SELECT set_var('sample', $q$Hello, PL/Perl! How's tricks?$q$); +SELECT get_var('sample'); </programlisting> </para>
---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match